Snippets Collections
// You are using GCC
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    cout<<"sorted array after selection sort:";
    for(int i=0;i<n;i++){
        int index=i;
        for(int j=i+1;j<n;j++){
            if(arr[j]<arr[index] || arr[j]==arr[index]){
                index=j;
            }
        }
        swap(arr[i],arr[index]);
        cout<<arr[i]<<" ";
    }
    return 0;
}
// You are using GCC
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=0;i<n;i++){
        int min=arr[i];
        int j=i-1;
        while(j>=0 && arr[j]>min){
            arr[j+1]=arr[j];
            j--;
        }
        arr[j+1]=min;
        // cout<<"iretation "<<i+1<<":";
        // for(int k=0;k<n;k++){
        //     cout<<arr[k]<<" ";
        // }
        // cout<<endl;
    }
    cout<<"after sorted using insertion sort:"<<endl;
    for(int i=0;i<n;i++){
        cout<<arr[i]<<" ";
    }
    
    return 0;
}
// You are using GCC
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    cout<<"after sorted using bubble sort: ";
    for(int i=0;i<n-1;i++){
        for(int j=0;j<n-i-1;j++){
            if(arr[j]>arr[j+1]){
                swap(arr[j],arr[j+1]);
            //   int temp=arr[j];
            //   arr[j]=arr[j+1];
            //   arr[j+1]=temp;
            }
        }
    }
        for(int i=0;i<n;i++){
        cout<<arr[i]<<" ";
        }
    }
  { 8,              40,          8,           1,        40 ,     8,       8,      3,       3,  {0xFF, 0xFF, 0x99, 0x99, 0xE7, 0xC3, 0xC3, 0xDB} ,     34,     -34}, // Minecraft Creeper Hard Mode
  { 12,             70,          8,           1,        40 ,     8,       8,      3,       5,  {0xFF, 0xFF, 0x99, 0x99, 0xE7, 0xC3, 0xC3, 0xDB} ,     28,     -28}, // Minecraft Creeper EZ Mode
  { 12,             70,          8,           1,        40 ,     8,       8,      3,       5,  {0xFF, 0xFF, 0x99, 0x99, 0xE7, 0xC3, 0xC3, 0xDB} ,     28,     -28}, // Minecraft Creeper Placeholder for Hard Mode (Part 3)
#define GAMES_NUMBER 14 // Define the number of different game boards
// Author : Khadiza Sultana
// Date : 1/4/2025
#include <iostream>
#include <vector>
using namespace std;

int search(vector<int>& nums, int target) {
    int st = 0, end = nums.size() - 1;
    while (st <= end) {
        int mid = st + (end - st) / 2;
        if (nums[mid] == target) {
            return mid;
        }
        if (nums[st] <= nums[mid]) { // Left half is sorted
            if (nums[st] <= target && target <= nums[mid]) {
                end = mid - 1;
            } else {
                st = mid + 1;
            }
        } else { // Right half is sorted
            if (nums[mid] <= target && target <= nums[end]) {
                st = mid + 1;
            } else {
                end = mid - 1;
            }
        }
    }
    return -1;
}

int main() {
    vector<int> nums = {4, 5, 6, 7, 0, 1, 2};
    int target = 0;

    int result = search(nums, target);

    if (result != -1) {
        cout << "Target " << target << " found at index: " << result << endl;
    } else {
        cout << "Target " << target << " not found in the array." << endl;
    }

    return 0;
}
// Author : Khadiza Sultana
// Date : 1/4/2025
#include<iostream>
#include<vector>
using namespace std;

int binarySearch(vector<int>&arr, int tar) { // practical implementation
    int n = arr.size();
    int st = 0, end = n-1;
    while(st <= end) {
        int mid = st + (end-st)/2; // not using (st+end)/2 to avoid integer overflow
        if (tar > arr[mid]) {
            st = mid+1;
        }
        else if (tar < arr[mid]) {
            end = mid-1;
        }
        else {
            return mid;
        }
    }
    return -1;
}

int binarySearch2(vector<int>&arr, int tar, int st, int end) { // recursive implementation
    if (st > end) { // base case
        return -1;
    }
    int mid = st + (end-st)/2;
    if (tar > arr[mid]) {
        binarySearch2(arr, tar, mid+1, end);
    }
    else if (tar < arr[mid]) {
        binarySearch2(arr, tar, st, mid-1);
    }
    else {
        return mid;
    }
}

int main() {
    vector<int>arr1 = {3, 5, 7, 12, 15, 18}; // even no of elements
    int tar1 = 3;
    vector<int>arr2 = {4, 6, 10, 11, 12, 18, 19}; // odd no of elements
    int tar2 = 19;

    cout << "Index at which tar1 is found(even no of elements) : " << binarySearch(arr1, tar1) << endl;
    cout << "Index at which tar2 is found(odd no of elements) : " << binarySearch(arr2, tar2) << endl;
    
    cout << "Using Recusive function index at which tar1 is found : " << binarySearch2(arr1, tar1, 0, 5) << endl;
    cout << "Using Recusive function index at which tar1 is found : " << binarySearch2(arr2, tar2, 0, 6) << endl;

    return 0;
}
// Author : Khadiza Sultana
#include<iostream>
#include<vector>
using namespace std;

int main() {
    int a = 10;
    int* ptr = &a;
    int** parPtr = &ptr;
    cout << ptr << endl;
    cout << parPtr << endl;
    cout << *(&a) << endl;
    cout << *(ptr) << endl;
    cout << *(parPtr) << endl;
    cout << **(parPtr) << endl;
    return 0;
}
      remainderAnswer = String(answer) + String(" rem ") + String(remainder); // Create a String combining the Integer Division "answer", "rem" for remainder, and remainder answer "remainder"
      ans = remainderAnswer; // Pass the "remainderAnswer" to the "ans" variable
      remainder = num1.toInt() % num2.toInt(); // Calculate the remainder from the division operation using the "%" operator
int               remainder; // Integer variable to hold the result of the "%" operation
String            remainderAnswer; // String variable to hold the integer division and remainder operation results
#include <iostream>

void swap(int &a, int &b) {
    int temp = a; // Store the value of a in a temporary variable
    a = b;        // Assign the value of b to a
    b = temp;    // Assign the value of temp (original a) to b
}

int main() {
    int x = 5;
    int y = 10;

    std::cout << "Before swap: x = " << x << ", y = " << y << std::endl;
    swap(x, y); // Call the swap function
    std::cout << "After swap: x = " << x << ", y = " << y << std::endl;

    return 0;
}
#include <iostream>
#include <stdexcept>
#include <string>

int main() {
	setlocale(LC_ALL, "RU");

	class Car {
	private:
		std::string name; // Приватное поле
		int mx_speed; // Приватное поле

	public:
		Car(const std::string& name, int mx_speed) {
			setName(name);
			setMaxspeed(mx_speed);
		}

		void setName(const std::string& name) {
			this->name = name;
		}

		std::string getName() const {
			return name;
		}

		void setMaxspeed(int mx_speed) {
			if (mx_speed < 0) {
				throw std::invalid_argument("Скорость машины не может быть отрицательной.");
			}
			this->mx_speed = mx_speed;
		}

		int getMaxspeed() const {
			return mx_speed;
		}
	};

	// Производный класс
	class Porshe : public Car {
	private:
		std::string color; // Новое поле

	public:
		Porshe(const std::string& name, int mx_speed, const std::string& color)
			: Car(name, mx_speed), color(color) {}

		void display() const {
			std::cout << "Porshe: " << getName() << ", Максимальная скорость: " << getMaxspeed() << ", Цвет: " << color << std::endl;
		}
	};

	// Класс, основанный на двух других
	class Price : public Porshe {
	private:
		int cost; // Новое поле

	public:
		Price(const std::string& name, int mx_speed, const std::string& color, int cost)
			: Porshe(name, mx_speed, color), cost(cost) {}

		void showPrice() const {
			display();
			std::cout << "Цена: " << cost << std::endl;
		}
	};

	// Класс, наследующий от Rose
	class SpecialPorshe : public Porshe {
	public:
		using Porshe::Porshe; // Наследуем конструктор

	private:
		// Доступ к полям базового класса ограничен
		void setColor(const std::string& color) {
			// Метод для изменения цвета, доступен только в классе
		}
	};

	// Основная функция
	try {
		Car car("Porshe Cayenne", 260);
		car.setMaxspeed(300);
		std::cout << "Машина: " << car.getName() << ", Максимальная скорость: " << car.getMaxspeed() << std::endl;

		Porshe porshe("Porshe Macan", 330, "Голубой");
		porshe.display();

		Price price("Porshe Panamera", 250, "Белый", 3000000);
		price.showPrice();

		SpecialPorshe specialPorshe("Porshe 911", 330, "Синий");
		// specialRose.setColor("Зеленый"); // Это вызовет ошибку, так как метод недоступен в main

	}
	catch (const std::invalid_argument& e) {
		std::cerr << "Ошибка: " << e.what() << std::endl;
	}

	return 0;
}
 webPage += "<br> 18 - Pikachu<br> 19 - Poke Ball";
else if(spriteInc == 18) { blitRGB(pokeball); }
static uint8_t pokeball[RGB_SPRITE_WIDTH * RGB_SPRITE_HEIGHT] = {
    0x00, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0x00, 0x00, 0x00,
    0xFF, 0x00, 0x00,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,
    0xFF, 0x00, 0x00,   0xFF, 0xFF, 0xFF,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,
    0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,   0x00, 0x00, 0x00,   0x00, 0x00, 0x00,   0x00, 0x00, 0x00,   0xFF, 0x00, 0x00,   0xFF, 0x00, 0x00,
    0x00, 0x00, 0x00,   0x00, 0x00, 0x00,   0x00, 0x00, 0x00,   0x00, 0x00, 0x00,   0xFF, 0xFF, 0xFF,   0x00, 0x00, 0x00,   0x00, 0x00, 0x00,   0x00, 0x00, 0x00,
    0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0x00, 0x00, 0x00,   0x00, 0x00, 0x00,   0x00, 0x00, 0x00,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,
    0x00, 0x00, 0x00,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0xFF, 0xFF, 0xFF,   0x00, 0x00, 0x00
};
// Challenge Solution
  // Create functions for 6 points: the pre-pickup, the pickup, the lift, the move, 
  // the place, and the departure. Set a small delay between each of these points.
  Position_1(); // Pre-pickup position
  delay(1000);  // Short Delay
  Position_2(); // Pickup position
  delay(1000);  // Short Delay
  Position_3(); // Lift Position
  delay(1000);  // Short Delay
  Position_4(); // Move Position
  delay(1000);  // Short Delay
  Position_5(); // Place Position
  delay(1000);  // Short Delay
  Position_6(); // Departure Position
  delay(5000);  // Long Delay before next loop
  // End Challenge Solution
// Challenge Solution Functions
void Position_1() // Starting "Prep" position
{
  // Set the target positions to the starting positions
  posBase = 125;
  posShoulder = 55;
  posElbow = 50;
  posGripper = 0;

  // Write the starting position to each servo.
  servoBase.write(posBase);
  servoShoulder.write(posShoulder);
  servoElbow.write(posElbow);
  servoGripper.write(posGripper);
}


void Position_2() // "Grab" position
{
  // Set the target positions to the starting positions
  posBase = 125;
  posShoulder = 75;
  posElbow = 40;
  posGripper = 90;

  // Write the starting position to each servo.
  servoBase.write(posBase);
  servoShoulder.write(posShoulder);
  servoElbow.write(posElbow);
  servoGripper.write(posGripper);
}


void Position_3() // "Lift" position
{
  // Set the target positions to the starting positions
  posBase = 125;
  posShoulder =55;
  posElbow = 90;
  posGripper = 90;

  // Write the starting position to each servo.
  servoBase.write(posBase);
  servoShoulder.write(posShoulder);
  servoElbow.write(posElbow);
  servoGripper.write(posGripper);
}


void Position_4() // "Move" Position
{
  // Set the target positions to the starting positions
  posBase = 55;
  posShoulder =55;
  posElbow = 90;
  posGripper = 90;

  // Write the starting position to each servo.
  servoBase.write(posBase);
  servoShoulder.write(posShoulder);
  servoElbow.write(posElbow);
  servoGripper.write(posGripper);
}


void Position_5() // "Place" Position
{
  // Set the target positions to the starting positions
  posBase = 55;
  posShoulder = 75;
  posElbow = 40;
  posGripper = 60;

  // Write the starting position to each servo.
  servoBase.write(posBase);
  servoShoulder.write(posShoulder);
  servoElbow.write(posElbow);
  servoGripper.write(posGripper);
}


void Position_6() // "Depart" Position
{
  // Set the target positions to the starting positions
  posBase = 55;
  posShoulder = 55;
  posElbow = 50;
  posGripper = 0;

  // Write the starting position to each servo.
  servoBase.write(posBase);
  servoShoulder.write(posShoulder);
  servoElbow.write(posElbow);
  servoGripper.write(posGripper);
}
else {
   leftServo.write(90);
   rightServo.write(90);
}
else if(leftJoystick > 600) {
    leftJSVal = map(leftJoystick, 600, 1023, 85, 80);
    rightJSVal = map(leftJoystick, 600, 1023, 95, 100);

    if(rightJoystick < 420) {
      rightJSVal = rightJSVal + map(rightJoystick, 420, 0, 1, 75);
    }
    else if(rightJoystick > 600) {
      leftJSVal = leftJSVal - map(rightJoystick, 600, 1023, 1, 75);
    }

    leftServo.write(leftJSVal);
    rightServo.write(rightJSVal);
  }
leftServo.write(leftJSVal);
rightServo.write(rightJSVal);
    if(rightJoystick < 420) {
      rightJSVal = rightJSVal - map(rightJoystick, 420, 0, 1, 75);
    }
    else if(rightJoystick > 600) {
      leftJSVal = leftJSVal + map(rightJoystick, 600, 1023, 1, 75);
    }
if(leftJoystick < 420) {
   leftJSVal = map(leftJoystick, 420, 0, 95, 100);
   rightJSVal = map(leftJoystick, 420, 0, 85, 80);

}
       //Display "Super Secret Message"
        lcd.clear();
        // Set the LCD cursor to the second line, 4th position
        lcd.setCursor(4,1);
        // Write 'Super Secret' beginning at that location
        lcd.print("Super Secret");
        // Move cursor to the third line, 8th position
        lcd.setCursor(7,2);
        // Write 'Message' beginning at that location
        lcd.print("Message");
        // Display the message for 5-seconds
        delay(5000);
        // Clear the display to prepare for the next time update
        lcd.clear();
      // If the knob is in this range, display a message
      if((anaAlarm > 400) && (anaAlarm < 425)) {

      }
      // Read the Dial Potentiometer value
      anaAlarm = analogRead(A1);
 
#include <iostream>
#include <stdexcept>
#include <string>

int main() {
    setlocale(LC_ALL, "RU");

    class Flower {
    private:
        std::string name; // Приватное поле
        int petals; // Приватное поле

    public:
        Flower(const std::string& name, int petals) {
            setName(name);
            setPetals(petals);
        }

        void setName(const std::string& name) {
            this->name = name;
        }

        std::string getName() const {
            return name;
        }

        void setPetals(int petals) {
            if (petals < 0) {
                throw std::invalid_argument("Количество лепестков не может быть отрицательным.");
            }
            this->petals = petals;
        }

        int getPetals() const {
            return petals;
        }
    };

    // Производный класс
    class Rose : public Flower {
    private:
        std::string color; // Новое поле

    public:
        Rose(const std::string& name, int petals, const std::string& color)
            : Flower(name, petals), color(color) {}

        void display() const {
            std::cout << "Роза: " << getName() << ", Лепестки: " << getPetals() << ", Цвет: " << color << std::endl;
        }
    };

    // Класс, основанный на двух других
    class Bouquet : public Rose {
    private:
        int quantity; // Новое поле

    public:
        Bouquet(const std::string& name, int petals, const std::string& color, int quantity)
            : Rose(name, petals, color), quantity(quantity) {}

        void showBouquet() const {
            display();
            std::cout << "Количество: " << quantity << std::endl;
        }
    };

    // Класс, наследующий от Rose
    class SpecialRose : public Rose {
    public:
        using Rose::Rose; // Наследуем конструктор

    private:
        // Доступ к полям базового класса ограничен
        void setColor(const std::string& color) {
            // Метод для изменения цвета, доступен только в классе
        }
    };

    // Основная функция
    try {
        Flower flower("Тюльпан", 5);
        flower.setPetals(10);
        std::cout << "Цветок: " << flower.getName() << ", Лепестки: " << flower.getPetals() << std::endl;

        Rose rose("Роза", 8, "Красный");
        rose.display();

        Bouquet bouquet("Букет", 6, "Белый", 12);
        bouquet.showBouquet();

        SpecialRose specialRose("Специальная Роза", 7, "Синий");
        // specialRose.setColor("Зеленый"); // Это вызовет ошибку, так как метод недоступен в main

    }
    catch (const std::invalid_argument& e) {
        std::cerr << "Ошибка: " << e.what() << std::endl;
    }

    return 0;
}
// Author : Khadiza Sultana
#include<iostream>
#include<vector>
using namespace std;
int LinearSearch(vector<int> &vec, int target){
    int i = 0;
    for(int val : vec){
        if(val == target)
           return i;
        i++;
    }
    return -1;
}
int main(){
    vector<int> vec = {1, 2, 5, 8, 5, 7, 8};
    int target = 7;
    cout << LinearSearch(vec, target) << endl;
    return 0;
}
// Khadiza Sultana
#include<iostream>
#include <climits>
using namespace std;
int sum(int arr[], int size){
    int sum = 0;
    for(int i = 0; i < size; i++){
        sum += arr[i];
    }
    return sum;
}
int product(int arr[], int size){
    int product = 1;
    for(int i = 0; i < size; i++){
        product *= arr[i];
    }
    return product;
}
void swap(int &a, int &b){
    a = a + b;
    b = a - b;
    a = a - b;
}
void uniqueElement(int arr[], int size){
    for(int i = 0; i < size; i++){
        bool isUnique = true;
        for(int j = 0; j < size; j++){
            if(i != j && arr[i] == arr[j]){
                isUnique = false;
                break;
            }
        }
        if(isUnique) cout << arr[i] << " ";
    }
    cout << endl;
} 
void reverseMinAndMax(int arr[], int size){
    int largest = INT_MIN, smallest = INT_MAX, largest_index = -1, smallest_index = -1;
    for(int i = 0; i < size; i++){
        if(arr[i] > largest){
            largest = arr[i];
            largest_index = i;
        }
        if(arr[i] < smallest){
            smallest = arr[i];
            smallest_index = i;
        }
    }
    swap(arr[largest_index], arr[smallest_index]);
    for(int i = 0; i < size; i++){
        cout << arr[i] << " ";
    }
    cout << endl;
}
void intersection(int arr1[], int size1, int arr2[], int size2){
    for(int i = 0; i < size1; i++){
        bool repeated = false;
        for(int j = 0; j < size1; j++){
            if(i != j && arr1[i] == arr1[j]){
               repeated = true;
               break;
            }
        }
        if(repeated) arr1[i] = INT_MAX;
        for(int j = 0; j < size2; j++){
            if(arr1[i] == arr2[j]){
               cout << arr1[i] << " ";
               break;
            }
        }

    }
    cout << endl;
}
int main(){
    int arr1[] = {1, 2, 4, 6, 4, 6, 2, 5, 9};
    int size1 = sizeof(arr1) / sizeof(int);
    int arr2[] = {2, 4, 3, 5, 8, 6, 3};
    int size2 = sizeof(arr2) / sizeof(int);
    cout << "Sum of elements : " << sum(arr1, size1) << endl;
    cout << "Product of elements : " << product(arr1, size1) << endl;
    cout << "The elements of the first array after the maximum element and minimum element are reversed : ";
    reverseMinAndMax(arr1, size1);
    cout << "The unique elements in the first array : ";
    uniqueElement(arr1, size1);
    cout << "The intersecting elements between the first and second array : ";
    intersection(arr1, size1, arr2, size2);
    return 0;
}
// Author : Khadiza Sultana 
#include<iostream>
 using namespace std;
  int binTodec(int binNum){
    int ans = 0, pow = 1;
    while(binNum > 0){
        int rem = binNum % 10; // accessing the last digit
        ans += rem * pow;
        binNum /= 10; // removing the last digit
        pow *= 2;
    }
    return ans;
  }

  int main(){
    int binNum;
    cin >> binNum;
    cout << binTodec(binNum) << endl;
    return 0;
  }
// Author : Khadiza Sultana
#include<iostream>
using namespace std;

int decimalToBinary(int decNum){
    int ans = 0, pow = 1;
    while(decNum > 0){
        int rem = decNum % 2; // documenting the remainder for example for 3 % 2 = 1
        decNum /= 2; // determining the divisor 3 / 2 = 1
        ans += (rem * pow); // determining the position for the remainder as it goes from down to up
        pow *= 10; // updating the position of the digits
    }
    return ans;
}

int main(){
    int decNum = 50;  
    cout << decimalToBinary(decNum) << endl;
    return 0;
}
// Khadiza Sultana
#include<iostream>
using namespace std;
int primecheck(int n){
    bool isprime = true;
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            isprime = false;
            return false;
        }
    }
    if(isprime)
       return true;
}
void printprime(int num){
    for(int i = 2; i <= num; i++){
        if(primecheck(i))
           cout << i << " ";
    }
}
int primecount(int num){
    int count = 0;
    for(int i = 2; i <= num; i++){
        if(primecheck(i))
           count++;
    }
    return count;
}
int main(){
    int num;
    cin >> num;
    printprime(num);
    cout << endl;
    cout << primecount(num) << endl;
    return 0;
}
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

//Initialize the pins
int moisture = A0;
int manual = A2;
int relay = 8;

//Setup
void setup() {
  pinMode(relay, OUTPUT);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(2, 0);
  lcd.print("Initializing");
  lcd.setCursor(0, 1);
  lcd.print("STYRERIUM MODULE");
  Serial.begin(9600);
  delay(10000);

}
void loop() {
  lcd.clear();
  //Convert to percentage
  int moistureValue = analogRead(moisture);
  int moisturePercent = map(moistureValue, 0, 1023, 100, 0);
  int manualValue = analogRead(manual);
  int manualPercent = map(manualValue, 0, 1023, 0, 100);
  //Relay control
  if (moisturePercent < 13 || moisturePercent < manualPercent) {
    digitalWrite(relay, HIGH);
  } else {  //Turn off relay
    digitalWrite(relay, LOW);
  }
  //Displaying the stats
  lcd.setCursor(0, 0);
  lcd.print("Moisture: ");
  lcd.setCursor(12, 0);
  lcd.print(moisturePercent);
  lcd.print("%");
  //Manual watering display
  lcd.setCursor(0, 1);
  lcd.print("Manual: ");
  lcd.setCursor(12, 1);
  lcd.print(manualPercent);
  lcd.print("%");
  delay(100);
}
#include <Wire.h>
#include "DHT.h"
#include <LiquidCrystal_I2C.h>
//Define DHT pin and type
#define DHTPIN 9
#define DHTTYPE DHT11
//Initialize the sensor and LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT dht(DHTPIN, DHTTYPE);

const int pumpPin = 8;
const int soilMoisturePin = A0;
const int potentiometerPin = A2;
unsigned long pumpStartTime = 0;  // unsigned: only >=0
bool pumpRunning = false;

void setup() {
  lcd.init();
  lcd.backlight();
  dht.begin();

  pinMode(pumpPin, OUTPUT);
  pinMode(soilMoisturePin, INPUT);
  pinMode(potentiometerPin, INPUT);
  lcd.setCursor(2, 0);
  lcd.print("Initializing");
  lcd.setCursor(0, 1);
  delay(2000);
  lcd.clear();
}

void loop() {
  int moistureValue = analogRead(soilMoisturePin);        // Read current soil moisture level
  int potentiometerValue = analogRead(potentiometerPin);  // Read potentiometer value
  int targetMoisturePercent;
  // Map values to percentage
  int moisturePercent = map(moistureValue, 1023, 0, 0, 100);
  int potentiometerPercent = map(potentiometerValue, 0, 1023, 0, 100);
  if (potentiometerPercent >= 40) {
  targetMoisturePercent = potentiometerPercent;
  } else {
    targetMoisturePercent = 40;
  }
  // Check if pump should be running
  if (pumpRunning) {
    unsigned long elapsedTime = millis() - pumpStartTime;

    // If pump has been running for 20 seconds and soil moisture hasn't increased
    if (elapsedTime >= 20000 && moisturePercent <= 30) {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Low water! Pump");
      lcd.setCursor(0, 1);
      lcd.print("stopped.");

      // Stop the pump
      digitalWrite(pumpPin, LOW);
      pumpRunning = false;
      delay(20000);
      lcd.clear();
    }
    // Stop the pump if desired soil moisture level is reached
    else if (moisturePercent >= targetMoisturePercent) {
      digitalWrite(pumpPin, LOW);  // Stop the pump
      pumpRunning = false;

      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Plants watered!");
      lcd.setCursor(7, 1);
      lcd.print(":)");
      delay(2000);  // Display message for 2 seconds
      lcd.clear();
    } else {
      lcd.setCursor(0, 0);
      lcd.print("Pump running...");
      lcd.setCursor(0, 1);
      lcd.print("Soil: ");
      lcd.print(moisturePercent);
      lcd.print("% Man: ");
      lcd.print(potentiometerPercent);
      lcd.print("%");
    }
  } else {
    float h = dht.readHumidity();
    // Read temperature as Celsius (the default)
    float t = dht.readTemperature();
    if (isnan(h) || isnan(t)) {
      Serial.println(F("Failed to read from DHT sensor!"));
    }
    // If pump has stopped, continuously display moisture and potentiometer levels
    lcd.setCursor(0, 0);
    lcd.print("Mst:");
    lcd.print(moisturePercent);
    lcd.print("%  ");

    lcd.setCursor(8, 0);
    lcd.print("Tmp:");

    if (!isnan(t)) {
      lcd.print(t);
      lcd.print("oC ");
    }
    lcd.setCursor(8, 1);
    lcd.print("Hum:");
    if (!isnan(h)) {
      lcd.print(h);
      lcd.print("% ");
    }

    lcd.setCursor(0, 1);
    lcd.print("Man:");
    lcd.print(potentiometerPercent);
    lcd.print("% ");


    // Start the pump if potentiometerPercent is above 50% and soil is below target
    if (moisturePercent < targetMoisturePercent) {
      digitalWrite(pumpPin, HIGH);
      pumpStartTime = millis();
      pumpRunning = true;

      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Pump running...");
    }
  }

  delay(2000);  // Adjust delay as needed to update readings
}
//
//#include <iostream> 
//using namespace std;
//
//int main() {
//    int n;
//    setlocale(LC_ALL, "");
//    cout << "Введите количество чисел: ";
//    cin >> n;
//    int* arr = new int[n];
//
//    // Ввод чисел в массив 
//    cout << "Введите " << n << " чисел:" << endl;
//    for (int i = 0; i < n; ++i) {
//        cin >> *(arr+i);
//    }
//
//    // Поиск наибольшего числа
//    int max_value = *(arr);
//
//    for (int i = 1; i < n; ++i) {
//        if (arr[i] > max_value) {
//            max_value = *(arr+i);
//        }
//    }
//
//    // Вывод результата 
//    cout << "Наибольшее число: " << max_value << endl;
//    delete[] arr;
//    return 0;
//
//}

//#include<iostream>
//#include<vector>
//#include<windows.h>
//using namespace std;
//
//int main()
//{
//    SetConsoleCP(1251);
//    SetConsoleOutputCP(1251);
//    int n; // Количествострок
//    cout << "Введите количество строк: ";
//    cin >> n;
//
//    vector<string>lines; // Вектор для хранения строк
//
//    // Ввод строк
//    cout << "Введите " << n << " строк:" << endl;
//    for (int i = 0; i < n; ++i)
//    {
//        string line;
//        cin >> line; // Считываем строку без пробелов
//
//        // Вставляем строку в отсортированное место
//        vector<string>::iterator it = lines.begin();
//        while (it != lines.end() && *it < line)
//        {
//            ++it; // Находим место для вставки
//        }
//        lines.insert(it, line); // Вставляемстроку
//    }
//
//    // Вывод результата
//    cout << "Строки в алфавитном порядке:" << endl;
//    for (vector<string>::size_type i = 0; i < lines.size(); ++i)
//    {
//        cout << lines[i] << endl;
//    }
//
//    return 0;
//}
//

#include <iostream>
#include <windows.h>
using namespace std;

void print_array_using_pointers(int r, int c, int* ptr)
{
	int i, j;
	for (i = 0; i < r; i++)
	{
		cout << "[";
		for (j = 0; j < c; j++)
		{
			cout << " " << *ptr;
			ptr = ptr + 1;
		}
		cout << " ]" << endl;
	}
	return;
}

double determinant(int m, int* p)
{
	double ans = 0, inner_sol, inner_determinant;
	int a, b, c, d;

	if ((m == 1) || (m == 2))
	{
		if (m == 1)
			ans = *p;
		else
		{
			a = *p;
			b = *(p + 1);
			c = *(p + 2);
			d = *(p + 3);
			ans = (a * d) - (b * c);
		}
	}
	else
	{
		int i, j, k, l, n, sign, basic, element;
		n = 0;
		sign = +1;
		int* q;
		q = new int[(m - 1) * (m - 1)];

		for (i = 0; i < m; i++)
		{
			l = 0;
			n = 0;
			basic = *(p + i);

			for (j = 0; j < m; j++)
			{
				for (k = 0; k < m; k++)
				{
					element = *(p + l);
					cout << element << " ";
					if ((j == 0) || (i == k));
					else
					{
						*(q + n) = element;
						n = n + 1;
					}
					l = l + 1;
				}
			}
			cout << endl << basic << " x " << endl;
			print_array_using_pointers((m - 1), (m - 1), q);

			inner_determinant = determinant(m - 1, q);
			inner_sol = sign * basic * inner_determinant;

			cout << "Знак:" << sign << "x Базис: " << basic << "x Определитель" << inner_determinant << " = " << inner_sol << endl;
			ans = ans + inner_sol;
			sign = sign * -1;
		}
		delete[] q;
	}
	return ans;
}

void initialize_array(int r, int c, int* ptr)
{
	int i, j, k;
	cout << "Вводите числа в матрицу" << endl;
	cout << "После каждого числа нажимайте Enter" << endl;

	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			cin >> k;
			*(ptr + i * c + j) = k;

		}
	}
}

int main()
{
	SetConsoleCP(1251);
	SetConsoleOutputCP(1251);


	int r, * p;
	cout << "Количество рядов: ";
	cin >> r;

	p = new int[r * r];

	initialize_array(r, r, p);
	print_array_using_pointers(r, r, p);
	double ans = determinant(r, p);

	cout << "Определитель: " << ans << endl;
	delete[] p;

	return 0;

}
#include <iostream>
#include <windows.h>
using namespace std;

void print_array_using_pointers(int r, int c, int* ptr)
{
	int i, j;
	for (i = 0; i < r; i++)
	{
		cout << "[";
		for (j = 0; j < c; j++)
		{
			cout << " " << *ptr;
			ptr = ptr + 1;
		}
		cout << " ]" << endl;
	}
	return;
}

double determinant(int m, int* p)
{
	double ans = 0, inner_sol, inner_determinant;
	int a, b, c, d;

	if ((m == 1) || (m == 2))
	{
		if (m == 1)
			ans = *p;
		else
		{
			a = *p;
			b = *(p + 1);
			c = *(p + 2);
			d = *(p + 3);
			ans = (a * d) - (b * c);
		}
	}
	else
	{
		int i, j, k, l, n, sign, basic, element;
		n = 0;
		sign = +1;
		int* q;
		q = new int[(m - 1) * (m - 1)];

		for (i = 0; i < m; i++)
		{
			l = 0;
			n = 0;
			basic = *(p + i);

			for (j = 0; j < m; j++)
			{
				for (k = 0; k < m; k++)
				{
					element = *(p + l);
					cout << element << " ";
					if ((j == 0) || (i == k));
					else
					{
						*(q + n) = element;
						n = n + 1;
					}
					l = l + 1;
				}
			}
			cout << endl << basic << " x " << endl;
			print_array_using_pointers((m - 1), (m - 1), q);

			inner_determinant = determinant(m - 1, q);
			inner_sol = sign * basic * inner_determinant;

			cout << "Знак:" << sign << "x Базис: " << basic << "x Определитель" << inner_determinant << " = " << inner_sol << endl;
			ans = ans + inner_sol;
			sign = sign * -1;
		}
		delete[] q;
	}
	return ans;
}

void initialize_array(int r, int c, int* ptr)
{
	int i, j, k;
	cout << "Вводите числа в матрицу" << endl;
	cout << "После каждого числа нажимайте Enter" << endl;

	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			cin >> k;
			*(ptr + i * c + j) = k;

		}
	}
}

int main()
{
	SetConsoleCP(1251);
	SetConsoleOutputCP(1251);


	int r, * p;
	cout << "Количество рядов: ";
	cin >> r;

	p = new int[r * r];

	initialize_array(r, r, p);
	print_array_using_pointers(r, r, p);
	double ans = determinant(r, p);

	cout << "Определитель: " << ans << endl;
	delete[] p;

	return 0;

}
#include <iostream>
#include <vector>
using namespace std; 
 
int main() {
    vector<int> arr = { 64, 34, 25, 12, 22, 11, 90 };
    int n = arr.size();
    bool swapped;
  
    for (int i = 0; i < n - 1; i++) {
        swapped = false;
        for (int j = 0; j < n - i - 1; j++) {
            if (arr[j] > arr[j + 1]) {
                int temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
                swapped = true;
            }
        }
      
        // If no two elements were swapped, then break
        if (!swapped)
            break;
    }
    
    for (int num : arr)
        cout << " " << num;
}
#include <iostream>
#include <vector>
using namespace std; 
 
int main() { 
    int n; 
    setlocale(LC_ALL, ""); 
    cout <<"Введите количество чисел: ";
    cin >> n;
	std::vector <int> arr(n);
 
    // Ввод чисел в массив 
    cout << "Введите " << n << " чисел:" << endl; 
    for (int i = 0; i < n; ++i) { 
        cin >> arr[i]; 
    } 
 
    // Поиск наибольшего числа  
    int max_value = arr[0];              
 
    for (int i = 1; i < n; ++i) { 
        if (arr[i] > max_value) { 
            max_value = arr[i]; 
        } 
    } 
 
    // Вывод результата 
    cout << "Наибольшее число: " << max_value<< endl; 
 
    return 0;
    
}
#include <iostream> 
using namespace std; 
 
int main() { 
    int n; 
    setlocale(LC_ALL, ""); 
    cout <<"Введите количество чисел: ";
    cin >> n;
    int *arr = new int[n];
 
    // Ввод чисел в массив 
    cout << "Введите " << n << " чисел:" << endl; 
    for (int i = 0; i < n; ++i) { 
        cin >> arr[i]; 
    } 
 
    // Поиск наибольшего числа
    int max_value = arr[0];              
 
    for (int i = 1; i < n; ++i) { 
        if (arr[i] > max_value) { 
            max_value = arr[i]; 
        } 
    } 
 
    // Вывод результата 
    cout << "Наибольшее число: " << max_value<< endl; 
 	delete[] arr;
    return 0;
    
}
class DisjointSet {
    vector<int> rank, parent, size;
    
public:
    DisjointSet(int n) {
        rank.resize(n + 1, 0);
        parent.resize(n + 1);
        size.resize(n + 1, 1);
        for (int i = 0; i <= n; i++) {
            parent[i] = i;
        }
    }

    int findUPar(int node) {
        if (node == parent[node])
            return node;
        return parent[node] = findUPar(parent[node]); // Path compression
    }

    void unionByRank(int u, int v) {
        int pu = findUPar(u);
        int pv = findUPar(v);
        if (pu == pv) return;

        if (rank[pu] < rank[pv]) {
            parent[pu] = pv;
        } else if (rank[pv] < rank[pu]) {
            parent[pv] = pu;
        } else {
            parent[pv] = pu;
            rank[pu]++;
        }
    }

    void unionBySize(int u, int v) {
        int pu = findUPar(u);
        int pv = findUPar(v);
        if (pu == pv) return;

        if (size[pu] < size[pv]) {
            parent[pu] = pv;
            size[pv] += size[pu];
        } else {
            parent[pv] = pu;
            size[pu] += size[pv];
        }
    }
};

class Solution {
public:
    vector<int> sp(int n) {
        vector<int> spf(n + 1);
        for (int i = 0; i <= n; ++i) spf[i] = i;
        for (int i = 2; i * i <= n; ++i) {
            if (spf[i] == i) {
                for (int j = i * i; j <= n; j += i) {
                    if (spf[j] == j) spf[j] = i;
                }
            }
        }
        return spf;
    }

    vector<int> fac(int x, vector<int>& spf) {
        vector<int> f;
        while (x > 1) {
            int p = spf[x];
            f.push_back(p);
            while (x % p == 0) x /= p;
        }
        return f;
    }

    int largestComponentSize(vector<int>& nums) {
        int n = nums.size();
        int maxNum = *max_element(nums.begin(), nums.end());

        vector<int> spf = sp(maxNum);
        DisjointSet ds(maxNum + 1);

        for (int num : nums) {
            vector<int> primes = fac(num, spf);
            for (int prime : primes) {
                ds.unionBySize(num, prime); // Union by size
            }
        }

        unordered_map<int, int> cnt;
        int maxSize = 0;
        for (int num : nums) {
            int root = ds.findUPar(num);
            cnt[root]++;
            maxSize = max(maxSize, cnt[root]);
        }

        return maxSize;
    }
};
#include <bits/stdc++.h>
using namespace std;

int mod = 1e9 + 7;
const int MAX = 1e5 + 1;

#define ll long long
#define ull unsigned long long
#define int64 long long int
#define vi vector<int>
#define pii pair<int, int>
#define ppi pair<pii>
#define all(v) v.begin(), v.end()
#define ff first
#define ss second
#define eb emplace_back
#define sz(x) (int(x.size()))
#define mset(dp, x) memset(dp, x, sizeof(dp))

int dir[5] = {0, 1, 0, -1, 0};
int dirI[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dirJ[8] = {0, -1, -1, -1, 0, 1, 1, 1};

ll fact[MAX] = {1};

ll add(ll a, ll b)
{
    return (a % mod + b % mod) % mod;
}

ll sub(ll a, ll b)
{
    return (a % mod - b % mod + mod) % mod;
}

ll mul(ll a, ll b)
{
    return ((a % mod) * (b % mod)) % mod;
}

ll exp(ll a, ll b)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

ll inv(ll b)
{
    return exp(b, mod - 2) % mod;
}

ll division(ll a, ll b)
{
    return ((a % mod) * (inv(b) % mod)) % mod;
}

ll nCr(ll n, ll r)
{
    if (r > n)
        return 0;
    return division(fact[n], mul(fact[r], fact[n - r]));
}

ll nPr(ll n, ll r)
{
    if (r > n)
        return 0;
    return division(fact[n], fact[n - r]);
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void pre(int _mod = mod)
{
    mod = _mod;
    fact[0] = 1;
    for (int i = 1; i < MAX; i++)
    {
        fact[i] = mul(fact[i - 1], i);
    }
}

void solve() {
    cout << "write code here" << "\n";
}

int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int tt = 1;
	cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
  if(!a) return b;
  return gcd(b % a, a);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main() {
  cout << gcd(12, 18) << endl;
  cout << gcd(0, 18) << endl;
  cout << lcm(12, 18) << endl;
  return 0;
}
#include <iostream>
#include <vector>
using namespace std;

// Function to calculate the smallest prime factors (SPF)
vector<int> calculate_spf(int n) {
    vector<int> SPF(n + 1, 0); // SPF array initialized to 0

    for (int i = 2; i <= n; i++) {
        if (SPF[i] == 0) { // i is a prime number
            for (int j = i; j <= n; j += i) {
                if (SPF[j] == 0) { // Mark only if not marked
                    SPF[j] = i; // Assign smallest prime factor
                }
            }
        }
    }
    return SPF;
}

// Function to get the prime factors of a number using the SPF array
vector<int> get_prime_factors(int n, const vector<int>& SPF) {
    vector<int> prime_factors;
    while (n != 1) {
        prime_factors.push_back(SPF[n]);
        n /= SPF[n]; // Divide n by its smallest prime factor
    }
    return prime_factors;
}

int main() {
    int N = 100; // Precompute SPF array for numbers up to N
    vector<int> SPF = calculate_spf(N);

    // Example: Factorizing multiple numbers
    vector<int> numbers_to_factor = {30, 45, 84, 97};

    for (int num : numbers_to_factor) {
        cout << "Prime factors of " << num << ": ";
        vector<int> factors = get_prime_factors(num, SPF);
        for (int f : factors) {
            cout << f << " ";
        }
        cout << endl;
    }

    return 0;
}
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

// Function to perform the simple sieve of Eratosthenes up to sqrt(b)
vector<int> simple_sieve(int limit) {
    vector<bool> is_prime(limit + 1, true);
    vector<int> primes;
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i <= limit; i++) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (int j = i * i; j <= limit; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return primes;
}

// Function to find all primes in the range [a, b] using the segmented sieve
void segmented_sieve(int a, int b) {
    int limit = sqrt(b);
    vector<int> primes = simple_sieve(limit);

    // Create a boolean array for the range [a, b]
    vector<bool> is_prime_segment(b - a + 1, true);

    // Mark multiples of each prime in the range [a, b]
    for (int prime : primes) {
        int start = max(prime * prime, a + (prime - a % prime) % prime);

        for (int j = start; j <= b; j += prime) {
            is_prime_segment[j - a] = false;
        }
    }

    // If a is 1, then it's not a prime number
    if (a == 1) {
        is_prime_segment[0] = false;
    }

    // Output all primes in the range [a, b]
    cout << "Prime numbers in the range [" << a << ", " << b << "] are:" << endl;
    for (int i = 0; i <= b - a; i++) {
        if (is_prime_segment[i]) {
            cout << (a + i) << " ";
        }
    }
    cout << endl;
}

int main() {
    int a = 10, b = 50;
    segmented_sieve(a, b);
    return 0;
}
#include <iostream>
#include <vector>
using namespace std;
void sieve_of_eratosthenes(int n) {
    vector<bool> is_prime(n + 1, true); // Initialize all entries as true
    is_prime[0] = is_prime[1] = false;  // 0 and 1 are not prime numbers
    for (int i = 2; i * i <= n; i++) {
        if (is_prime[i]) {
            // Mark all multiples of i as false
            for (int j = i * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }

    // Output all prime numbers
    cout << "Prime numbers up to " << n << " are:" << endl;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            cout << i << " ";
        }
    }
    cout << endl;
}

int main() {
    int n = 50;
    sieve_of_eratosthenes(n);
    return 0;
}
#include <iostream>
using namespace std;

int main(void){

}
struct node {
    node* arr[26] = {nullptr};
    bool flag = false;
    vector<string> below;
    bool contains(char ch) {
        if (arr[ch - 'a']) return true;
        else return false;
    }
    void add(char ch, node* sub) {
        arr[ch - 'a'] = sub;
    }
    node* next(char ch) {
        return arr[ch - 'a'];
    }
    void end() {
        flag = true;
    }
    bool isend() {
        return flag;
    }
    void ins(string bel) {
        below.push_back(bel);
    }
    void put(vector<string>& res) {
        int count = 0;
        for (auto it : below) {
            res.push_back(it);
            if (++count == 3) break;
        }
    }
};

class Trie {
private:
    node* root = new node();
public:
    void insert(string word) {
        node* nod = root;
        for (int i = 0; i < word.length(); ++i) {
            if (!nod->contains(word[i])) {
                nod->add(word[i], new node()); 
            }
            nod = nod->next(word[i]);
            nod->ins(word);
        }
        nod->end();
    }

    vector<vector<string>> search(string word) {
        vector<vector<string>> res;
        node* nod = root;
        for (int i = 0; i < word.length(); ++i) {
            vector<string> ans;
            if (!nod->contains(word[i])) {
                break;
            }
            nod = nod->next(word[i]);
            nod->put(ans);
            res.push_back(ans);
        }
        while (res.size() < word.size()) {
            res.push_back({});
        }
        return res;
    }
};

class Solution {
public:
    vector<vector<string>> suggestedProducts(vector<string>& products, string searchWord) {
        sort(products.begin(), products.end());
        Trie a;
        for (auto it : products) {
            a.insert(it);
        }
        return a.search(searchWord);
    }
};
// Challenge Solution - Part #4
  // Add Challenge Color - Soft-White Triangle
  0x888888,   // soft white triangle
// Challenge Solution - Part #3
  // Add Challenge Element Name
  piece_Tri, 
 
// Challenge Solution - Part #2
// Challenge Element "Triangle"
const char piece_Tri[] = {
  // Rotation 1
  1, 1, 1, 0,
  1, 1, 0, 0,
  1, 0, 0, 0, 
  0, 0, 0, 0,

  // Rotation 2
  1, 1, 1, 0,
  1, 1, 0, 0,
  1, 0, 0, 0, 
  0, 0, 0, 0,

  // Rotation 3
  1, 1, 1, 0,
  1, 1, 0, 0,
  1, 0, 0, 0, 
  0, 0, 0, 0,

  // Rotation 4
  1, 1, 1, 0,
  1, 1, 0, 0,
  1, 0, 0, 0, 
  0, 0, 0, 0,
}; // End Challenge Element
 
#define NUM_ELEMENT_TYPES       8 // Challenge Solution - Part #1 - Add 1 for Number of Element Types
 
// Challenge Solution - Part #3 ------------------------------------------------------
// Create cheatingOpponent() Function
void cheatingOpponent(){
  // For each position on Player 1's grid, if it is green, that position has not been hit yet.
  // So target it with the next (cheating) hit.
  for (int k = 0; k < MATRIX_H * MATRIX_W; k++) {
    if (grid1S[k] == 4) { // If position is green, then ship is present
      target2[k] = 1; // Red Color == Hit
      grid1S[k] = 1;  // Red Color == Hit

      // Mark the attack as complete
      attackComplete = 1;
      break;
    }
  }

  // Delay briefly for smoother gameplay
  delay(500);
}
// End Challenge Solution ------------------------------------------------------------
 
  
    // Challenge Solution - Part #2 ------------------------------------------------------
    // Check to see if the cheating variable is below the cheating threshold
    // If it is, then call the "cheatingOpponent" function which you will create next
    if (pz <= cheatingPercentage){
      // Call the Cheating Function to find a target from Player 1's grid to hit. 
      cheatingOpponent();
    }
 
    // Challenge Solution - Part #1 ------------------------------------------------------
    // Comment out the following code
    /*if(hit == 1){
      post_hit_AI();
    } else {
      try_to_place_targetAI();
    }*/

    // Create a variable that represents the computer's "chance of cheating"
    int cheatingPercentage = 30;

    // Create a variable to hold the value from the "dice roll"
    int pz;

    // Roll the dice to get a percentage chance of cheating
    pz = random(100);
    
class DisjointSet {
    vector<int> rank, parent;
public:
    DisjointSet(int n) {
        rank.resize(n + 1, 0);
        parent.resize(n + 1);
        for (int i = 0; i <= n; i++) {
            parent[i] = i;
        }
    }

    int findUPar(int node) {
        if (node == parent[node])
            return node;
        return parent[node] = findUPar(parent[node]);
    }

    void unionByRank(int u, int v) {
        int ulp_u = findUPar(u);
        int ulp_v = findUPar(v);
        if (ulp_u == ulp_v) return;
        if (rank[ulp_u] < rank[ulp_v]) {
            parent[ulp_u] = ulp_v;
        }
        else if (rank[ulp_v] < rank[ulp_u]) {
            parent[ulp_v] = ulp_u;
        }
        else {
            parent[ulp_v] = ulp_u;
            rank[ulp_u]++;
        }
    }
};
using namespace std;

// An iterative binary search function.
int binarySearch(int arr[], int low, int high, int x)
{
    while (low <= high) {
        int mid = low + (high - low) / 2;

        // Check if x is present at mid
        if (arr[mid] == x)
            return mid;

        // If x greater, ignore left half
        if (arr[mid] < x)
            low = mid + 1;

        // If x is smaller, ignore right half
        else
            high = mid - 1;
    }

    // If we reach here, then element was not present
    return -1;
}

// Driver code
int main(void)
{
    int arr[] = { 2, 3, 4, 10, 40 };
    int x = 10;
    int n = sizeof(arr) / sizeof(arr[0]);
    int result = binarySearch(arr, 0, n - 1, x);
    if(result == -1) cout << "Element is not present in array";
    else cout << "Element is present at index " << result;
    return 0;
}
// Use the ColorFromPalette function to rotate through the rainbow by the colorIndex
//ColorFromPalette( paletteName, colorIndex[0-255], brightness[0-255], blendType[NOBLEND or LINEARBLEND])
leds[j] = ColorFromPalette(RainbowColors_p, colorIndex, 255, LINEARBLEND);
colorIndex += 15;  // Increment the colorIndex to change the color for the next LED
// Add new variable to track the color palette indices
uint8_t colorIndex;
#include <iostream>
#include <iomanip>
using namespace std;

struct Time {
    int hours;
    int minutes;
    int seconds;
};

// Function to calculate time difference
Time calculateTimeDifference(Time t1, Time t2) {
    Time difference;

    // Calculate total seconds for both times
    int seconds1 = t1.hours * 3600 + t1.minutes * 60 + t1.seconds;
    int seconds2 = t2.hours * 3600 + t2.minutes * 60 + t2.seconds;

    // Difference in seconds
    int diffSeconds = seconds1 - seconds2;

    // Convert difference back to hours, minutes, seconds
    difference.hours = diffSeconds / 3600;
    diffSeconds = diffSeconds % 3600;
    difference.minutes = diffSeconds / 60;
    difference.seconds = diffSeconds % 60;

    return difference;
}

int main() {
    // Input the two times
    Time t1, t2;
    char colon;
    cin >> t1.hours >> colon >> t1.minutes >> colon >> t1.seconds;
    cin >> t2.hours >> colon >> t2.minutes >> colon >> t2.seconds;

    // Calculate the difference
    Time difference = calculateTimeDifference(t1, t2);

    // Output the difference in HH:MM:SS format
    cout << setfill('0') << setw(2) << difference.hours << ":"
         << setfill('0') << setw(2) << difference.minutes << ":"
         << setfill('0') << setw(2) << difference.seconds << endl;

    return 0;
}
#include <iostream>
#include <string>

using namespace std;

class Person {
private:
    string name;
    int age;
    string gender;

public:
    void setDetails(string n, int a, string g) {
        name = n;
        age = a;
        gender = g;
    }

    void displayDetails() {
        string uppercaseName = "";
        string uppercaseGender = "";

        for (char c : name) {
            uppercaseName += toupper(c);
        }

        for (char c : gender) {
            uppercaseGender += toupper(c);
        }

        cout << uppercaseName << " " << age << " " << uppercaseGender << endl;
    }
};

int main() {
    Person person;
    string name;
    int age;
    string gender;


    cin >> name;
 
    cin >> age;

    cin >> gender;

    person.setDetails(name, age, gender);
    person.displayDetails();

    return 0;
}
#include <iostream>
#include <string>

using namespace std;

class dayOfWeek {
public:
    int dayNumber;
    string dayName;

    void setDay(int n) {
        dayNumber = n;
        switch (dayNumber) {
            case 1: dayName = "Sunday"; break;
            case 2: dayName = "Monday"; break;
            case 3: dayName = "Tuesday"; break;
            case 4: dayName = "Wednesday"; break;
            case 5: dayName = "Thursday"; break;
            case 6: dayName = "Friday"; break;
            case 7: dayName = "Saturday"; break;
            case 0: dayName = "Weekend"; break;
            default: dayName = "Invalid"; break;
        }
    }

    void printDay() {
        cout << dayName << endl;
    }
};

int main() {
    dayOfWeek day;
    int dayNumber;

    cin >> dayNumber;

    day.setDay(dayNumber);
    day.printDay();

    return 0;
}
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    long long binaryNumber;

    cin >> binaryNumber;

    long long decimalNumber = 0;
    int power = 0;

    while (binaryNumber != 0) {
        int digit = binaryNumber % 10;
        decimalNumber += digit * pow(2, power);
        binaryNumber /= 10;
        power++;
    }

    cout << "Decimal: " << decimalNumber << endl;

    return 0;
}
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <limits>
using namespace std;

void D(int N, vector<pair<int,int>> adj[N]; int source){
    vector<int> dist(V,1000000);
    dist[source] = 0;
    priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int>>> pq;
    pq.push({0,source});
    
    while(pq.empty() != 0) {
        int u = pq.top().second;
        int d = pq.top().first;
        pq.pop();
        
        for(int i = 0; i < adj[u].size(); i++){
            int v = adj[u][i].first;
            int weight = adj[u][i].second;
            
            if(dist[adj[u][i].first] > pq.top().first + adj[u][i].second){
                dist[adj[u][i].first] = pq.top().first + adj[u][i].second;
                pq.push({dist[adj[u][i].first], adj[u][i].first});
            }
    }
}


int main(){
    int N,M; //số đỉnh, cạnh
    cin >> N >> M;
    
    vector<pair<int,int>> adj;
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        adj[a].push_back({b,c}); // Nếu đồ thị là vô hướng
        adj[b].push_back({a,c});
    }
    
    int source;
    cin >> source;
    D(N, adj, source);
    return 0;
    
}
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    string s;
    cin >> s;
    int temp = 1;
    int ans;
    for(int i = 1; i < s.size(); i++){
        if(s[i] == s[i-1]){
            temp += 1;
            cout << temp << " ";
        }
        else;
            ans = max(ans, temp);
            temp = 1;
        }
    if(ans >= 7){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    
    vector<vector<int>> S(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            int a;
            cin >> a;
            S[i].push_back(a);
        }
    }

    vector<vector<int>> dp(n);
    for(int i = 0; i < n; i++){
        dp[i] = vector<int>(i + 1, 1);
    }
    
    dp[0][0] = S[0][0];

    for(int i = 1; i < n; i++){
        for(int j = 0; j <= i; j++){
            if (j == 0) {
                dp[i][j] = dp[i-1][j] * S[i][j];
            } else if (j == i) {
                dp[i][j] = dp[i-1][j-1] * S[i][j];
            } else {
                if(S[i][j] > 0){
                    dp[i][j] = max(dp[i-1][j], dp[i-1][j-1]) * S[i][j];
                } else {
                    dp[i][j] = min(dp[i-1][j], dp[i-1][j-1]) * S[i][j];
                }
            }
        }
    }
    
    cout << *max_element(dp[n-1].begin(), dp[n-1].end());

    return 0;
}
// Driver function
        for(int i = 0; i < V; i++){
            if(!vis[i]) {
                if(cycleBFS(i, vis, adj)) return true;
            }
        }



// cycle check fun by BFS
    bool cycleBFS(int src, vector<int> &vis, vector<int> adj[]){
        queue<pair<int,int>> q;
        vis[src] = 1;
        q.push({src,-1});
        
        while(!q.empty()){
            int node = q.front().first;
            int parent = q.front().second;
            q.pop();
            
            for(auto it: adj[node]){
                if(!vis[it]){
                    vis[it] = 1;
                    q.push({it, node});
                }
                else if(parent != it){
                    return true;
                }
            }
        }
        return false;
    }




#include <bits/stdc++.h>
#include <iostream>
using namespace std;

#define MOD 1000000007
#define ll long long int
#define fr(i, a, b) for (int i = a; i < b; i++)

inline int binaryExponentiation(ll base, int exp, int mod = MOD) {
    ll result = 1;
    while (exp) {
        if (exp & 1) result = (result * base) % mod;
        base = (base * base) % mod;
        exp >>= 1;
    }
    return (int)result;
}

void solve() {
    int n;
    cin >> n;
    ll answer = 0;
    fr(i, 1, n) {
        ll current = binaryExponentiation(2, n - i - 1);
        current = (2 * current * (n - i)) % MOD;
        current = (current * i) % MOD;
        current = (current * i) % MOD;
        answer = (answer + current) % MOD;
    }
    cout << answer << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) solve();
    return 0;
}
// check if a linked list is circular or not
bool isCircular (node* head) {
  if (head == NULL) {
    return true;
  }
  node* temp = head -> next;
  while (temp != NULL && temp != head) {
    temp = temp -> next;
  }
  if (temp == head) {
    return true;
  }
  return false;
}
node* kReverse (node* head, int k) {
  // base case
  if (head == NULL) {
    return NULL;
  }

  // step 1: reverse first k nodes
  node* forward = NULL;
  node* curr = head;
  node* prev = NULL;
  int cnt = 0;
  while (curr != NULL && cnt < k) {
    forward = curr -> next;
    curr -> next = prev;
    prev = curr;
    curr = forward;
    cnt++;
    
  }
  // step 2: recursion
  if (forward != NULL) {
    head -> next = kReverse(forward, k);
    
  }
  // step 3: return head of the modified list
  return prev;
}
int getLength (node* head) {
  int length = 0;
  node* temp = head;
  while (temp != NULL) {
    length++;
    temp = temp -> next;
  }
  return length;
}

node* middleNode (node* head) {
  int length = getLength(head);
  int mid = (length/2) + 1;
  int cnt = 1;
  node* temp = head;
  while (cnt < mid) {
    temp = temp -> next;
    cnt++;
  }
  return temp;
}
node* reverseLinkedList (node* & head) {
  //empty list or single node
  if (head == NULL || head -> next == NULL) {
    return head;
  }
  node* prev = NULL;
  node* curr = head;
  node* forword = NULL;
  while (curr != NULL) {
    forword = curr -> next;
    curr -> next = prev;
    prev = curr;
    curr = forword;
  }
  return prev;
}
// it will return the head of the reversed linked list
node* reverse1 (node* head) {
  // base case
  if (head == NULL || head -> next == NULL) {
    return head;
  }
  node* chotaHead = reverse1(head -> next) {
    head -> next -> next = head;
    head -> next = NULL;

    return chotaHead;
  }
}
node* reverseLinkedList (node* head) {
  // empty  list 
	if (head == NULL || head -> next == NULL) {
	return head;
	}
  node* prev = NULL;
  node* curr = head;
  node* forword = NULL;
  
  while (curr != NULL) {
	forword = curr -> next;
    curr -> next = prev;
    prev = curr;
    curr = forword;
  }
  return prev;
}
void deleteNode (node* &head, node* &tail, int position) {
  // delete first node
  if (position == 1) {
    node* temp = head;
    temp -> next -> prev = NULL;
    head = temp -> next;
    temp -> next = NULL;
    delete temp;
    return;
  }
  node* curr = head;
  node* back = NULL;
  int cnt = 1;
  while (cnt < position) {
    back = curr;
    curr = curr -> next;
    cnt++;
  }
  //delete last node 
  if (curr -> next == NULL) {
    tail = back;
    back -> next = NULL;
    curr -> prev = NULL;
    delete curr;
    return;
  }
  // delete in between node 
  back -> next = curr -> next;
  curr -> next -> prev = back;
  curr -> next = NULL;
  curr -> prev = NULL;
  delete curr;
}
void insertAtPosition(node *&head, node *&tail, int position, int d) {
  // insert at start
  if (position == 1) {
    insertAtHead(head, tail, d);
    return;
  }
  node *temp = new node(d);
  node *curr = head;
  int cnt = 1;
  while (cnt < position - 1) {
    curr = curr->next;
    cnt++;
  }
  // insert at last
  if (curr->next == NULL) {
    insertAtTail(tail, head, d);
    return;
  } else {
    temp->next = curr->next;
    curr->next = temp;
    temp->prev = curr;
    curr->next->prev = temp;
  }
}
void insertAtTail(node *&tail, node* &head, int d) {
  node *temp = new node(d);
  if (tail == NULL) {
    tail = head = temp;
  } else {
    tail->next = temp;
    temp->prev = tail;
    tail = temp;
  }
}
void insertAtHead(node *&head, node* & tail, int d) {
  node *temp = new node(d);
  if (head == NULL) {
    head = tail = temp;
  } else {
    head->prev = temp;
    temp->next = head;
    head = temp;
  }
}
int getLen(node *head) {
  int len = 0;
  node *temp = head;
  while (temp != NULL) {
    len++;
    temp = temp->next;
  }
  return len;
}
class node {
public:
  int data;
  node *next;
  node *prev;
  node(int d) {
    this->data = d;
    this->next = NULL;
    this->prev = NULL;
  }
  ~node() {
    int value = this -> data;
    if (next != NULL) {
      delete next;
      next = NULL;
    }
    cout << "memory free for node with data " << value << endl;
  }
};
void insertInPosition(node *&head, node *&tail, int d, int position) {
  if (position == 1) {
    insertAtHead(head, d);
    return;
  }

  node *temp = head;
  int count = 1;
  while (count < position - 1) {
    temp = temp->next;
    count++;
  }
  if (temp->next == NULL) {
    insertAtTail(tail, d);
    return;
  }

  node *nodeToInsert = new node(d);
  nodeToInsert->next = temp->next;
  temp->next = nodeToInsert;
}
void print (node* &head) {
  node* temp = head;
  while (temp != NULL) {
    cout << temp -> data << " ";
    temp = temp -> next;
  }
}
void insertAtTail(node *&tail, int d) {
  node *temp = new node(d);
  tail->next = temp;
  tail = temp;
}
void insertAtHead(node *&head, int d) {
  node *temp = new node(d);
  temp->next = head;
  head = temp;
}
void deleteNode(node *&head, int position) {
  if (position == 1) {
    node *temp = head;
    head = head->next;
    temp->next = NULL;
    delete temp;
  }

  else {
    node *curr = head;
    node *prev = NULL;
    int cnt = 1;
    while (cnt < position) {
      prev = curr;
      curr = curr->next;
      cnt++;
    }
    prev->next = curr->next;
    curr->next = NULL;
    delete curr;
  }
}
void merge(int *arr, int s, int e) {
  int mid = s + (e - s) / 2;
  int len1 = mid - s + 1;
  int len2 = e - mid;
  int *first = new int[len1];
  int *second = new int[len2];

  // copy vales
  int mainArrayIndex = s;
  for (int i = 0; i < len1; i++) {
    first[i] = arr[mainArrayIndex++];
  }
  mainArrayIndex = mid + 1;
  for (int i = 0; i < len2; i++) {
    second[i] = arr[mainArrayIndex++];
  }

  // merge 2 sorted arrays
  int index1 = 0;
  int index2 = 0;
  mainArrayIndex = s;
  while (index1 < len1 && index2 < len2) {
    if (first[index1] < second[index2]) {
      arr[mainArrayIndex++] = first[index1++];
    } else {
      arr[mainArrayIndex++] = second[index2++];
    }
  }
  while (index1 < len1) {
    arr[mainArrayIndex++] = first[index1++];
  }
  while (index2 < len2) {
    arr[mainArrayIndex++] = second[index2++];
  }
}

void mergeSort(int *arr, int s, int e) {
  if (s >= e) {
    return;
  }
  int mid = s + (e - s) / 2;
  // left  part
  mergeSort(arr, s, mid);
  // right part
  mergeSort(arr, mid + 1, e);
  // merge
  merge(arr, s, e);
}
bool checkPalindrome (string s, int start, int length) {
  if (start>length) {
    return true;
	}
  if (s[start] != s[length]) {
    return false;
	}
  else {
    return checkPalindrome(s,start+1,length-1;)
  }
}
bool isprime(int x){
    if(x<=1) return false;
    if(x==2 || x==3) return true;
    if(x%2==0 || x%3==0) return false;
    for(int i=5;i*i<=x;i+=6){
        if(x%i==0 || x%(i+2)==0) return false;
    }
    return true;
}
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

bool isSafe(int x, int y, int n, vector<vector<int>> visited,
            vector<vector<int>> &m) {
  if ((x >= 0 && x < n) && (y >= 0 && y < n) && visited[x][y] == 0 &&
      m[x][y] == 1) {
    return true;
  } else {
    return false;
  }
}

void solve(vector<vector<int>> &m, int n, vector<string> &ans, int x, int y,
           string path, vector<vector<int>> visited) {
  // you have reached x,y here

  // base case
  if (x == n - 1 && y == n - 1) {
    ans.push_back(path);
    return;
  }
  visited[x][y] = 1;

  // 4 choices D,L,R,U
  // down

  int newx = x + 1;
  int newy = y;
  if (isSafe(newx, newy, n, visited, m)) {
    path.push_back('D');
    solve(m, n, ans, newx, newy, path, visited);
    path.pop_back();
  }

  // left

  newx = x;
  newy = y - 1;
  if (isSafe(newx, newy, n, visited, m)) {
    path.push_back('L');
    solve(m, n, ans, newx, newy, path, visited);
    path.pop_back();
  }

  // right

  newx = x;
  newy = y + 1;
  if (isSafe(newx, newy, n, visited, m)) {
    path.push_back('R');
    solve(m, n, ans, newx, newy, path, visited);
    path.pop_back();
  }

  // up

  newx = x - 1;
  newy = y;
  if (isSafe(newx, newy, n, visited, m)) {
    path.push_back('U');
    solve(m, n, ans, newx, newy, path, visited);
    path.pop_back();
  }

  visited[x][y] = 0;
}

vector<string> findPath(vector<vector<int>> &m, int n) {
  vector<string> ans;
  if (m[0][0] == 0) {
    return ans;
  }
  int srcx = 0;
  int srcy = 0;

  vector<vector<int>> visited = m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      visited[i][j] = 0;
    }
  }

  string path = "";
  solve(m, n, ans, srcx, srcy, path, visited);
  sort(ans.begin(), ans.end());
  return ans;
}

int main() {
  int n = 4;
  vector<vector<int>> m = {
      {1, 0, 0, 0}, {1, 1, 0, 1}, {1, 1, 0, 0}, {0, 1, 1, 1}};
  vector<string> ans = findPath(m, n);
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
void sortArray (int *arr, int n) {
  if (n==0||n==1)
    return;
  for (int i=0; i<n-1; i++) {
    if (arr[i]>arr[i+1]) {
      swap(arr[i],arr[i+1]);
    }
  }
  sortArray(arr,n-1);
}
int power (int a, int b) {
  if (b==0)
    return 1;
  if (b==1)
    return a;
  int ans = power(a,b/2);
  if (b%2==0)
    return ans*ans;
  else
    return a*ans*ans;
}
bool binarySearch(int arr[], int s, int e, int key) {
  if (s > e)
    return false;
  int mid = s + (e - s) / 2;
  if (arr[mid] == key)
    return true;
  if (arr[mid] < key)
    return binarySearch(arr, mid + 1, e, key);
  else
    return binarySearch(arr, s, mid - 1, key);
}
bool linearsearch (int *arr, int size, int key) {
  if (size == 0)
    return false;
  if(arr[0]==key)
    return true;
  else 
    return linearsearch(arr+1, size-1, key);
}
bool isArraySorted (int arr[],int size) {
  if (size == 0 || size == 1) 
    return true;
  if (arr[0]>arr[1]) 
    return false;
  else {
    bool remainingPart = isArraySorted(arr+1,size-1); 
    return remainingPart;
  }
  
}
class Solution {
public:
    int fib(int n) {
        if (n==0)
        return 0;
        if (n==1)
        return 1;
        return fib(n-1)+fib(n-2);
        
    }
};
#include <iostream>
using namespace std;

void sayDigit (int n,string arr[]) {
  if (n==0) 
    return;
  if (n>0) {
    int digit = n%10;
    n = n/10;
    sayDigit(n,arr);
    cout << arr[digit] << " ";
  }
}

int main () {
  string arr[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
  int n;
  cin >> n;
  sayDigit(n,arr);
  return 0;
}
vector<int> spiralPrint(vector<vector<int>> v, int r, int c) {
  vector<int> ans;
  int count = 0;
  ;
  int total = r * c;
  int startingRow = 0;
  int endingRow = r - 1;
  int startingCol = 0;
  int endingCol = c - 1;

  while (count < total) {
    // print starting row
    for (int i = startingCol; i <= endingCol && count < total; i++) {
      ans.push_back(v[startingRow][i]);
      count++;
    }
    startingRow++;
    // printing ending col
    for (int i = startingRow; i <= endingRow && count < total; i++) {
      ans.push_back(v[i][endingCol]);
      count++;
    }
    endingCol--;
    // printing ending row
    for (int i = endingCol; i >= startingCol && count < total; i--) {
      ans.push_back(v[endingRow][i]);
      count++;
    }
    endingRow--;
    // printing starting col
    for (int i = endingRow; i >= startingRow && count < total; i--) {
      ans.push_back(v[i][startingCol]);
      count++;
    }
    startingCol++;
  }

  return ans;
}
vector<int> wavePrint(vector<vector<int>> arr, int r, int c) {
  vector<int> ans;
  for (int col = 0; col < c; col++) {
    if (col & 1) {
      // odd index -> bottom to top
      for (int row = r - 1; row >= 0; row--) {
        cout << arr[row][col] << " ";
        ans.push_back(arr[row][col]);
      }
    }
    // 0 or even index -> top to bottom
    else {
      for (int row = 0; row < r; row++) {
        cout << arr[row][col] << " ";
        ans.push_back(arr[row][col]);
      }
    }
  }

  return ans;
}
#include <iostream>
#include <string>
using namespace std;

string addInplaceOfSpaces (string &s) {
  string temp = "";
  for (int i = 0; i < s.length(); i ++) {
    if (s[i] == ' ') {
      temp.push_back('@');
      temp.push_back('2');
      temp.push_back('3');
    }
    else {
      temp.push_back(s[i]);
    }
  }
  return temp;
}

int main() {
  string s ="my name is vishnu deb jha" ;
  string v = addInplaceOfSpaces(s);
  cout << v << endl;
  return 0;
}
// output is my@23name@23is@23vishnu@23deb@23jha
char getMaxOccCharacter(string s) {
  int arr[26] = {0};
  for (int i = 0; i < s.length(); i++) {
    char ch = s[i];
    int number = 0;
    number = ch - 'a';
    arr[number]++;
  }
  int maxi = -1, ans = 0;
  for (int i = 0; i < 26; i++) {
    if (arr[i] > maxi) {
      maxi = arr[i];
      ans = i;
    }
  }
  return 'a' + ans;
}
 void dfs(int node, vector<int> adjLs[], int vis[]) {
        // mark the more as visited
        vis[node] = 1; 
        for(auto it: adjLs[node]) {
            if(!vis[it]) {
                dfs(it, adjLs, vis); 
            }
        }
    }
 vector<int> adjLs[V]; 
        
        // to change adjacency matrix to list 
        for(int i = 0;i<V;i++) {
            for(int j = 0;j<V;j++) {
                // self nodes are not considered
                if(adj[i][j] == 1 && i != j) {
                    adjLs[i].push_back(j); 
                    adjLs[j].push_back(i); 
                }
            }
        }
int f(int ind,int prev,vector<int>& nums,vector<vector<int>>& dp)
{
    if(ind<0)
    return 0;
    if(dp[ind][prev]!=-1)
    return dp[ind][prev];
    int nonpick,pick;
    nonpick = f(ind-1,prev,nums,dp);
    pick=0;
    if(nums[ind]<nums[prev])
    pick = 1+f(ind-1,ind,nums,dp);
    return dp[ind][prev] = max(pick,nonpick);
}
    int lengthOfLIS(vector<int>& nums) {
        int n = nums.size();
        int p = n-1;
        vector<vector<int>>dp(n+1,vector<int>(n+1,-1));
        nums.push_back(INT_MAX);
        return f(n-1,n,nums,dp);
        
        
        
    }
#include <bits/stdc++.h>
using namespace std;




class Solution
{
private:
    void dfs(int node, vector<int> &vis, vector<int> adj[],
             stack<int> &st) {
        vis[node] = 1;
        for (auto it : adj[node]) {
            if (!vis[it]) {
                dfs(it, vis, adj, st);
            }
        }

        st.push(node);
    }
private:
    void dfs3(int node, vector<int> &vis, vector<int> adjT[]) {
        vis[node] = 1;
        for (auto it : adjT[node]) {
            if (!vis[it]) {
                dfs3(it, vis, adjT);
            }
        }
    }
public:
    //Function to find number of strongly connected components in the graph.
    int kosaraju(int V, vector<int> adj[])
    {
        vector<int> vis(V, 0);
        stack<int> st;
        for (int i = 0; i < V; i++) {
            if (!vis[i]) {
                dfs(i, vis, adj, st);
            }
        }

        vector<int> adjT[V];
        for (int i = 0; i < V; i++) {
            vis[i] = 0;
            for (auto it : adj[i]) {
                // i -> it
                // it -> i
                adjT[it].push_back(i);
            }
        }
        int scc = 0;
        while (!st.empty()) {
            int node = st.top();
            st.pop();
            if (!vis[node]) {
                scc++;
                dfs3(node, vis, adjT);
            }
        }
        return scc;
    }
};

int main() {

    int n = 5;
    int edges[5][2] = {
        {1, 0}, {0, 2},
        {2, 1}, {0, 3},
        {3, 4}
    };
    vector<int> adj[n];
    for (int i = 0; i < n; i++) {
        adj[edges[i][0]].push_back(edges[i][1]);
    }
    Solution obj;
    int ans = obj.kosaraju(n, adj);
    cout << "The number of strongly connected components is: " << ans << endl;
    return 0;
}
void mergeArray(int arr1[], int n, int arr2[], int m, int arr3[]) {
  int i, j, k;
  i = j = k = 0;
  while (i < n && j < m) {
    if (arr1[i] < arr2[j]) {
      arr3[k] = arr1[i];
      k++;
      i++;
    } else {
      arr3[k] = arr2[j];
      k++;
      j++;
    }
  }
  while (i < n) {
    arr3[k] = arr1[i];
    i++;
    k++;
  }
  while (j < m) {
    arr3[k] = arr2[j];
    k++;
    j++;
  }
}
void reverseArray (int arr[],int n) {
  int start = 0;
  int end = n-1;
  while (start<=end) {
    swap (arr[start],arr[end]);
      start++;
    end--;
  }
}
//string s2 = reverse(s.begin(),s.end()); THIS IS WRONG
reverse(s.begin(),s.end());//THIS IS CORRECT
void sortArray(int arr[], int n) {
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < (n - i); j++) {
      if (arr[j] > arr[j + 1]) {
        swap(arr[j], arr[j + 1]);
      }
    }
  }
}
#include <iostream>
using namespace std;

void printArray (int arr[],int n) {
  for (int i= 0; i< n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}

void sortArray (int arr[], int n) {
  for (int i = 0; i < (n-1); i ++) {
    for (int j = (i+1); j < n; j++) {
      if (arr[i] > arr[j]) {
        swap (arr[i], arr[j]);
      }
    }
  }
}

int main () {
  int n;
  cout << "Enter the size of the array: " << endl;
  cin >> n;
  int arr[n];
  cout << "Enter the elements of the array: " << endl;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cout << "The array before sorting: " << endl;
  printArray (arr, n);
  sortArray (arr, n);
  cout << "the array after sorting :" << endl;
  printArray(arr,n);
  return 0;
}
#include <iostream>
using namespace std;

bool allocationIsPossible(int arr[], int n, int m, int mid) {
    int sum = 0;
    int studentCount = 1;
    for (int i = 0; i < n; i++) {
        if (sum + arr[i] <= mid) {
            sum += arr[i];
        } else {
            studentCount++;
            if (studentCount > m || arr[i] > mid) {
                return false;
            }
            sum = arr[i];
        }
    }
    return true;
}

int bookAllocate(int arr[], int n, int m) {
    int start = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += arr[i];
    }
    int end = sum;
    int mid = start + (end - start) / 2;
    int ans = -1;
    while (start <= end) {
        if (allocationIsPossible(arr, n, m, mid)) {
            ans = mid;
            end = mid - 1;
        } else {
            start = mid + 1;
        }
        mid = start + (end - start) / 2;
    }
    return ans;
}

int main() {
    int arr[4] = {10, 20, 30, 40};
    int ans = bookAllocate(arr, 4, 2);
    cout << "Minimum pages: " << ans << endl;
    return 0;
}
  

// output is 60
#include <iostream>
using namespace std;

bool allocationIsPossible(int arr[], int n, int m, int mid) {
    int sum = 0;
    int studentCount = 1;
    for (int i = 0; i < n; i++) {
        if (sum + arr[i] <= mid) {
            sum += arr[i];
        } else {
            studentCount++;
            if (studentCount > m || arr[i] > mid) {
                return false;
            }
            sum = arr[i];
        }
    }
    return true;
}

int bookAllocate(int arr[], int n, int m) {
    int start = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += arr[i];
    }
    int end = sum;
    int mid = start + (end - start) / 2;
    int ans = -1;
    while (start <= end) {
        if (allocationIsPossible(arr, n, m, mid)) {
            ans = mid;
            end = mid - 1;
        } else {
            start = mid + 1;
        }
        mid = start + (end - start) / 2;
    }
    return ans;
}

int main() {
    int arr[4] = {10, 20, 30, 40};
    int ans = bookAllocate(arr, 4, 2);
    cout << "Minimum pages: " << ans << endl;
    return 0;
}
  

// output is 60
#include <iostream>
#include <vector>
#include <algorithm>

class DisjointSet {
public:
    DisjointSet(int n) {
        rank.resize(n + 1, 0);
        parent.resize(n + 1);
        size.resize(n + 1, 1);
        for (int i = 0; i <= n; ++i) {
            parent[i] = i;
        }
    }

    int find_upar(int node) {
        if (node == parent[node]) {
            return node;
        }
        return parent[node] = find_upar(parent[node]);
    }

    void union_by_rank(int u, int v) {
        int ulp_u = find_upar(u);
        int ulp_v = find_upar(v);
        if (ulp_u == ulp_v) {
            return;
        }
        if (rank[ulp_u] < rank[ulp_v]) {
            parent[ulp_u] = ulp_v;
        } else if (rank[ulp_v] < rank[ulp_u]) {
            parent[ulp_v] = ulp_u;
        } else {
            parent[ulp_v] = ulp_u;
            rank[ulp_u]++;
        }
    }

    void union_by_size(int u, int v) {
        int ulp_u = find_upar(u);
        int ulp_v = find_upar(v);
        if (ulp_u == ulp_v) {
            return;
        }
        if (size[ulp_u] < size[ulp_v]) {
            parent[ulp_u] = ulp_v;
            size[ulp_v] += size[ulp_u];
        } else {
            parent[ulp_v] = ulp_u;
            size[ulp_u] += size[ulp_v];
        }
    }

private:
    std::vector<int> rank;
    std::vector<int> parent;
    std::vector<int> size;
};

class Solution {
public:
    int spanningTree(int V, std::vector<std::vector<std::pair<int, int>>>& adj) {
        std::vector<std::tuple<int, int, int>> edges;
        for (int i = 0; i < V; ++i) {
            for (auto& it : adj[i]) {
                int adjNode = it.first;
                int wt = it.second;
                int node = i;
                edges.push_back(std::make_tuple(wt, node, adjNode));
            }
        }

        DisjointSet ds(V);
        std::sort(edges.begin(), edges.end());

        int mstWt = 0;
        for (auto& edge : edges) {
            int wt = std::get<0>(edge);
            int u = std::get<1>(edge);
            int v = std::get<2>(edge);
            if (ds.find_upar(u) != ds.find_upar(v)) {
                mstWt += wt;
                ds.union_by_size(u, v);
            }
        }

        return mstWt;
    }
};

int main() {
    int V = 5;
    std::vector<std::vector<std::pair<int, int>>> adj(V);

    std::vector<std::vector<int>> edges = {
        {0, 1, 2}, {0, 2, 1}, {1, 2, 1}, {2, 3, 2}, {3, 4, 1}, {4, 2, 2}
    };

    for (auto& it : edges) {
        int u = it[0], v = it[1], wt = it[2];
        adj[u].emplace_back(v, wt);
        adj[v].emplace_back(u, wt);
    }

    Solution obj;
    int mstWt = obj.spanningTree(V, adj);
    std::cout << "The sum of all the edge weights: " << mstWt << std::endl;

    return 0;
}
#include <iostream>
#include <vector>

class DisjointSet {
public:
    DisjointSet(int n) {
        rank.resize(n + 1, 0);
        parent.resize(n + 1);
        size.resize(n + 1, 1);
        for (int i = 0; i <= n; ++i) {
            parent[i] = i;
        }
    }

    int find_upar(int node) {
        if (node == parent[node]) {
            return node;
        }
        return parent[node] = find_upar(parent[node]);
    }

    void union_by_rank(int u, int v) {
        int ulp_u = find_upar(u);
        int ulp_v = find_upar(v);
        if (ulp_u == ulp_v) {
            return;
        }
        if (rank[ulp_u] < rank[ulp_v]) {
            parent[ulp_u] = ulp_v;
        } else if (rank[ulp_v] < rank[ulp_u]) {
            parent[ulp_v] = ulp_u;
        } else {
            parent[ulp_v] = ulp_u;
            rank[ulp_u]++;
        }
    }

    void union_by_size(int u, int v) {
        int ulp_u = find_upar(u);
        int ulp_v = find_upar(v);
        if (ulp_u == ulp_v) {
            return;
        }
        if (size[ulp_u] < size[ulp_v]) {
            parent[ulp_u] = ulp_v;
            size[ulp_v] += size[ulp_u];
        } else {
            parent[ulp_v] = ulp_u;
            size[ulp_u] += size[ulp_v];
        }
    }

private:
    std::vector<int> rank;
    std::vector<int> parent;
    std::vector<int> size;
};

class Solution {
public:
    int Solve(int n, std::vector<std::vector<int>>& edge) {
        DisjointSet ds(n);
        int cnt_extras = 0;
        for (auto& e : edge) {
            int u = e[0];
            int v = e[1];
            if (ds.find_upar(u) == ds.find_upar(v)) {
                cnt_extras++;
            } else {
                ds.union_by_size(u, v);
            }
        }
        int cnt_c = 0;
        for (int i = 0; i < n; ++i) {
            if (ds.find_upar(i) == i) {
                cnt_c++;
            }
        }
        int ans = cnt_c - 1;
        if (cnt_extras >= ans) {
            return ans;
        }
        return -1;
    }
};

int main() {
    int V = 9;
    std::vector<std::vector<int>> edge = { {0, 1}, {0, 2}, {0, 3}, {1, 2}, {2, 3}, {4, 5}, {5, 6}, {7, 8} };

    Solution obj;
    int ans = obj.Solve(V, edge);
    std::cout << "The number of operations needed: " << ans << std::endl;

    return 0;
}
class Solution
{
	public:
	//Function to find sum of weights of edges of the Minimum Spanning Tree.
    int spanningTree(int V, vector<vector<int>> adj[])
    {
        // code here
        vector<int> vis(V,0);
        vector<tuple<int,int,int>> mst;
        //wt,node,parent
        priority_queue<vector<int>,vector<vector<int>>, greater<vector<int>>> pq;
        
        pq.push({0,0,-1});
        int sum =0;
        
        while(!pq.empty()){
            auto it = pq.top();
            pq.pop();
            int node = it[1];
            int wt = it[0];
            int par = it[2];
            
            if(vis[node]==1) continue;
            vis[node]=1;
            sum+=wt;
            if(par!=-1){
                mst.push_back(make_tuple(wt,par,node));
            }
            for(auto it: adj[node]){
                int ch = it[0];
                int ch_w = it[1];
                if(!vis[ch]){
                    pq.push({ch_w, ch,node});
                }
            }
        }
        for(auto it: mst){
            int weight, u, v;
            tie(weight, u, v) = it;
            cout<<weight<<":"<<u<<"->"<<v<<endl;
        }
        return sum;
    }
};
class Solution {
  public:
    /*  Function to implement Bellman Ford
    *   edges: vector of vectors which represents the graph
    *   S: source vertex to start traversing graph with
    *   V: number of vertices
    */
    vector<int> bellman_ford(int V, vector<vector<int>>& edges, int S) {
        // Code here
        //iterate through edges ond keep on updating the distance array. Iterate through all the edges for 
        //V-1 times
        vector<int> dis(V,1e8);
        dis[S]=0;
        for(int i=0;i<V-1;i++){
            
            for(int j =0;j<edges.size();j++){
                int u = edges[j][0];
                int v = edges[j][1];
                int w = edges[j][2];
                if(dis[u] != 1e8 && dis[u]+w<dis[v]){
                    dis[v]=dis[u]+w;
                }
            }
        }
        for(int i=0;i<1;i++){
            
            for(int j =0;j<edges.size();j++){
                int u = edges[j][0];
                int v = edges[j][1];
                int w = edges[j][2];
                if(dis[u] != 1e8 && dis[u]+w<dis[v]){
                    return {-1};
                }
            }
        }
        
        return dis;
    }
};
int f(int ind,int buy, vector<int>& nums ,vector<vector<int>>& dp )
{
    if(ind==(nums.size()))
    return 0;
    if(dp[ind][buy]!=-1)
    return dp[ind][buy];
    int profit;
    if(buy)
    profit = max((-nums[ind]+f(ind+1,0,nums,dp)),(f(ind+1,1,nums,dp)));
    else
    profit = max((nums[ind]+f(ind+2,1,nums,dp)),(f(ind+1,0,nums,dp)));
    return dp[ind][buy]=profit;
}
    int maxProfit(vector<int>& prices) {
        int n = prices.size();
         vector<vector<int>> dp(n,vector<int>(2,-1));
         return f(0,1,prices,dp);
        
    }
class Solution
{
	public:
	//Function to find sum of weights of edges of the Minimum Spanning Tree.
    int spanningTree(int V, vector<vector<int>> adj[])
    {
        // code here
        vector<int> vis(V,0);
        vector<tuple<int,int,int>> mst;
        //wt,node,parent
        priority_queue<vector<int>,vector<vector<int>>, greater<vector<int>>> pq;
        
        pq.push({0,0,-1});
        int sum =0;
        
        while(!pq.empty()){
            auto it = pq.top();
            pq.pop();
            int node = it[1];
            int wt = it[0];
            int par = it[2];
            
            if(vis[node]==1) continue;
            vis[node]=1;
            sum+=wt;
            if(par!=-1){
                mst.push_back(make_tuple(wt,par,node));
            }
            for(auto it: adj[node]){
                int ch = it[0];
                int ch_w = it[1];
                if(!vis[ch]){
                    pq.push({ch_w, ch,node});
                }
            }
        }
        for(auto it: mst){
            int weight, u, v;
            tie(weight, u, v) = it;
            cout<<weight<<":"<<u<<"->"<<v<<endl;
        }
        return sum;
    }
};
int f(int ind,int buy,int t, vector<int>& nums, vector<vector<vector<int>>>& dp)
{
    if(ind==(nums.size()) || t==0)
    return 0;
    if(dp[ind][buy][t]!=-1)
    return dp[ind][buy][t];
    int profit;
    if(buy && t)
    profit = max((-nums[ind]+f(ind+1,0,t,nums,dp)),(f(ind+1,1,t,nums,dp)));
    else
    profit = max((nums[ind]+f(ind+1,1,t-1,nums,dp)),(f(ind+1,0,t,nums,dp)));
    return dp[ind][buy][t]=profit;
}
    int maxProfit(vector<int>& prices) {
         int n = prices.size();
     vector<vector<vector<int>>> dp(n, vector<vector<int>>(2, vector<int>(3, -1)));


         return f(0,1,2,prices,dp);
        
    }
int f(int ind,int buy, vector<int>& nums ,vector<vector<int>>& dp )
{
    if(ind==(nums.size()))
    return 0;
    if(dp[ind][buy]!=-1)
    return dp[ind][buy];
    int profit;
    if(buy)
    profit = max((-nums[ind]+f(ind+1,0,nums,dp)),(f(ind+1,1,nums,dp)));
    else
    profit = max((nums[ind]+f(ind+1,1,nums,dp)),(f(ind+1,0,nums,dp)));
    return dp[ind][buy]=profit;
}
    int maxProfit(vector<int>& prices) {
        int n = prices.size();
         vector<vector<int>> dp(n,vector<int>(2,-1));
         return f(0,1,prices,dp);
        
    }
#include <iostream>
using namespace std;
int sqrt(int arr[], int n, int key) {
  int start = 0;
  int end = n - 1;
  int mid = start + (end - start) / 2;
  int ans = -1;
  while (start <= end) {
    int square = mid * mid;
    if (square == key) {
      return mid;
    } else if (square > key) {
      end = mid - 1;
    } else {
      start = mid + 1;
      ans = mid;
    }
    mid = start + (end - start) / 2;
  }
  return ans;
}
double precision(int n, int precision, int integer) {
  double factor = 1;
  double ans = integer;
  for (int i = 0; i < precision; i++) {
    factor = factor / 10;
    for (double j = ans; j * j < n; j += factor) {
      ans = j;
    }
  }
  return ans;
}
int main() {
  int n;
  cout << "enter the number :" << endl;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    arr[i] = (i + 1);
  }
  int squareRoot = sqrt(arr, n, n);
  double finalAns = precision(n, 3, squareRoot);
  cout << "square root of " << n << " is " << finalAns << endl;
  return 0;
}
#include <iostream>
using namespace std;
long long int binarySearch(int arr[],int n,int key) {
  int start = 0;
  int end = n-1;
  long long int mid = start + (end-start)/2;
  long long int ans = -1;
while (start <= end){
  long long int square = mid*mid;
  if (square == key) {
    return mid;
  }
  else if (square > key) {
    end = mid - 1;
  }
  else {
    start = mid + 1;
    ans = mid;
  }
  mid = start + (end-start)/2;
}
  return ans;
}
int main() {
  int n;
  cout << "enter the number :" << endl;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
     arr[i] = (i+1);
  }
  int squareRoot = binarySearch(arr,n,n);
  cout << "square root of " << n << " is " << squareRoot << endl;
  return 0;
}
class Solution {
  public:
    /*  Function to implement Bellman Ford
    *   edges: vector of vectors which represents the graph
    *   S: source vertex to start traversing graph with
    *   V: number of vertices
    */
    vector<int> bellman_ford(int V, vector<vector<int>>& edges, int S) {
        // Code here
        //iterate through edges ond keep on updating the distance array. Iterate through all the edges for 
        //V-1 times
        vector<int> dis(V,1e8);
        dis[S]=0;
        for(int i=0;i<V-1;i++){
            
            for(int j =0;j<edges.size();j++){
                int u = edges[j][0];
                int v = edges[j][1];
                int w = edges[j][2];
                if(dis[u] != 1e8 && dis[u]+w<dis[v]){
                    dis[v]=dis[u]+w;
                }
            }
        }
        for(int i=0;i<1;i++){
            
            for(int j =0;j<edges.size();j++){
                int u = edges[j][0];
                int v = edges[j][1];
                int w = edges[j][2];
                if(dis[u] != 1e8 && dis[u]+w<dis[v]){
                    return {-1};
                }
            }
        }
        
        return dis;
    }
};
#include <iostream>
using namespace std;
int pivotSearch (int arr[],int n) {
  int start = 0;
  int end = n-1;
  int mid = start + (end-start)/2;
  while (start < end) {
    if (arr[mid] >= arr[0]) {
      start = mid + 1;
    }
    else {
      end = mid;
    }
    mid = start + (end-start)/2;
  }
  return end;
}
int binarySearch(int arr[],int n,int s,int e,int key) {
  int start = s;
  int end = e;
  int mid = start + (end-start)/2;
while (start <= end){
  if (arr[mid] == key) {
    return mid;
  }
  else if (arr[mid] > key) {
    end = mid - 1;
  }
  else {
    start = mid + 1;
  }
  mid = start + (end-start)/2;
}
  return -1;
}
int main() {
  int arr[6] = {3,8,10,0,1,2};
  int ans = pivotSearch(arr,6);
  cout << "the pivot is at : "<< ans << endl;
  if (2>=arr[ans]&&2<=arr[5]) {
    cout << "the element is present in the array at index     :" << binarySearch(arr,6,ans,5,2); 
  }
  else {
    cout << "the element is present in the array at index     :" << binarySearch(arr,6,0,ans-1,2);
  }
  return 0;
}
#include <iostream>
using namespace std;
int pivotSearch (int arr[],int n) {
  int start = 0;
  int end = n-1;
  int mid = start + (end-start)/2;
  while (start < end) {
    if (arr[mid] >= arr[0]) {
      start = mid + 1;
    }
    else {
      end = mid;
    }
    mid = start + (end-start)/2;
  }
  return end;
}
int main() {
  int arr[5] = {3,8,10,17,1};
  int ans = pivotSearch(arr,5);
  cout << "the pivot is : "<< ans;
  return 0;
}
#include <iostream>
using namespace std;
int firstOcc(int arr[], int n, int key) {
  int start = 0;
  int end = n-1;
  int ans = -1;
  int mid = start + (end-start)/2;
  while (start <= end) {
    if (arr[mid] == key) {
      ans = mid;
      end = mid - 1;
    }
    else if (arr[mid] < key) {
      start = mid + 1;
    }
    else {
      end = mid - 1;
    } 
    mid = start + (end-start)/2;
  }
  return ans;
}
int lastOcc(int arr[], int n, int key) {
  int start = 0;
  int end = n-1;
  int ans = -1;
  int mid = start + (end-start)/2;
  while (start <= end) {
    if (arr[mid] == key) {
      ans = mid;
      start = mid + 1;
    }
    else if (arr[mid] < key) {
      start = mid + 1;
    }
    else {
      end = mid - 1;
    } 
    mid = start + (end-start)/2;
  }
  return ans;
}
int main() {
  int array[6] = {1,2,2,2,2,3};
  int first = firstOcc(array,6,2);
  cout << "first occurance of 2 is at index " << first << endl;
  int last = lastOcc(array,6,2);
  cout << "last occurance of 2 is at index " << last << endl;
  return 0;
}
void getNumberPattern(int n) {
    // Write your code here.
    for(int i=0;i<2*n-1;i++){
        for(int j=0;j<2*n-1;j++){
            int top=i;
            int left=j;
            int bottom=(2*n-2)-i;
            int right=(2*n-2)-j;
            cout<<n-min(min(top,left),min(right,bottom));
        }
        cout<<"\n";
    }
}
  int f(int ind,vector<int>& nums,vector<int>& dp)
  {
      int one,two=INT_MAX;
      if(ind==0)return 0;
      if(dp[ind]!=-1)
      return dp[ind];
       one = f(ind-1,nums,dp)+abs(nums[ind]-nums[ind-1]);
      if(ind>1)
       two = f(ind-2,nums,dp)+abs(nums[ind]-nums[ind-2]);
      return dp[ind]=min(one,two);
  }
    int minimumEnergy(vector<int>& height, int n) {
        // Code here
        vector<int> dp(n,-1);
        return f(n-1,height,dp);
    }
 int f(int ind,int wt, int w[],int v[],vector<vector<int>>& dp)
    {
        if(ind==0)
        {
            return (w[0]<=wt)?v[0]:0;
        }
        int pick,nonpick;
        if(dp[ind][wt]!=-1)
        return dp[ind][wt];
        nonpick = f(ind-1,wt,w,v,dp);
        pick = INT_MIN;
        if(wt>=w[ind])
        pick = v[ind] + f(ind-1,wt-w[ind],w,v,dp);
        
        return dp[ind][wt] = max(pick,nonpick);
    }
    int knapSack(int W, int wt[], int val[], int n) 
    { 
       // Your code here
       vector<vector<int>> dp(n + 1, vector<int>(W + 1, -1));
       return f(n-1,W,wt,val,dp);
    }
   int f(int ind,int target,vector<int>& a,vector<vector<int>>& dp)
   {
    int pick,nonPick;
      
      if(ind==0)
      {
        if(target%a[0]==0)
        return 1;
        else return 0;
      }
      if(dp[ind][target]!=-1)return dp[ind][target];
       nonPick = f(ind-1,target,a,dp);
       pick=0;
      if(a[ind]<=target)
        pick = f(ind,target-a[ind],a,dp);
      return dp[ind][target]=(pick+nonPick);
   }
    int change(int amount,vector<int>& coins) {
        int n = coins.size();
        vector<vector<int>> dp(n,vector<int>(amount+1,-1));
        return f(n-1,amount,coins,dp);
        
        
    }
   int f(int ind,int target,vector<int>& a,vector<vector<int>>& dp)
   {
    int pick,nonPick;
      
      if(ind==0)
      {
        if(target%a[0]==0)return target/a[0];
        else return INT_MAX;
      }
      if(dp[ind][target]!=-1)return dp[ind][target];
       nonPick = f(ind-1,target,a,dp);
       pick = 1e9;
      if(a[ind]<=target)
        pick = 1+f(ind,target-a[ind],a,dp);
      return dp[ind][target]=min(pick,nonPick);
   }
    int coinChange(vector<int>& coins, int amount) {
        int n = coins.size();
        vector<vector<int>> dp(n,vector<int>(amount+1,-1));
        int res =f(n-1,amount,coins,dp);
        return (res>=1e9)?-1:res;
        
    }
int gcd(int a,int b){
  if(a==0 || b==0) return (a+b);
  else if(a>=b) return gcd(a-b,b);
  else return gcd(a,b-a);
}
//{ Driver Code Starts
#include <bits/stdc++.h> 
using namespace std; 

// } Driver Code Ends

class Solution
{   
    public:
    //Function to rotate matrix anticlockwise by 90 degrees.
    void rotateby90(vector<vector<int> >& matrix, int n) 
    { 
        for(int i=0;i<n;i++){
            reverse(matrix[i].begin(),matrix[i].end());
        }
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                swap(matrix[i][j],matrix[j][i]);
            }
        }
    } 
};


//{ Driver Code Starts.
int main() {
    int t;
    cin>>t;
    
    while(t--) 
    {
        int n;
        cin>>n;
        vector<vector<int> > matrix(n); 

        for(int i=0; i<n; i++)
        {
            matrix[i].assign(n, 0);
            for( int j=0; j<n; j++)
            {
                cin>>matrix[i][j];
            }
        }

        Solution ob;
        ob.rotateby90(matrix, n);
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                cout<<matrix[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}
// } Driver Code Ends
bool f(int ind,int target,vector<int>& nums,vector<vector<int>>& dp)
  {
      if(dp[ind][target]!=-1)
      return dp[ind][target];
      if(target==0)return true;
      if(ind==0)return (nums[0]==target);
      bool nottake = f(ind-1,target,nums,dp);
      bool take=false;
      if(target>=nums[ind])
       take = f(ind-1,target-nums[ind],nums,dp);
      return dp[ind][target]=(take || nottake);
  }
    bool isSubsetSum(vector<int>arr, int sum){
        // code here
        
        int n = arr.size();
        vector<vector<int>> dp(n,vector<int>(sum+1,-1));
        return f(n-1,sum,arr,dp);
    }
//{ Driver Code Starts
// Initial Template for C++

#include <bits/stdc++.h>
using namespace std;

// } Driver Code Ends
// User function Template for C++

class Solution {
  public:
    vector<vector<int>> sortedMatrix(int N, vector<vector<int>> Mat) {
        // code here
        vector<int> v;
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                v.push_back(Mat[i][j]);
            }
        }
        sort(v.begin(),v.end());
        vector<vector<int>> sorted(N);
        for(int i=0;i<v.size();i++){
            sorted[i/N].push_back(v[i]);
        }
        return sorted;
    }
};

//{ Driver Code Starts.

int main() {
    int t;
    cin >> t;
    while (t--) {
        int N;
        cin >> N;
        vector<vector<int>> v(N, vector<int>(N));
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++) cin >> v[i][j];
        Solution ob;
        v = ob.sortedMatrix(N, v);
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) cout << v[i][j] << " ";
            cout << "\n";
        }
    }
}
// } Driver Code Ends
class Solution {
public:
    bool searchMatrix(vector<vector<int>>& matrix, int target) {
        int s=0,e=(matrix.size()*matrix[0].size())-1;
        while(s<=e){
            int n=matrix[0].size();
            int mid=s+(e-s)/2;
            int i=mid/n;
            int j=(mid%n);
            if(matrix[i][j]==target){
                return true;
            }
            else if( matrix[i][j]<target) s=mid+1;
            else e=mid-1;
        }
        return false;
    }
};
//{ Driver Code Starts
#include <bits/stdc++.h> 
using namespace std; 

// } Driver Code Ends
class Solution
{   
    public: 
    //Function to return a list of integers denoting spiral traversal of matrix.
    vector<int> spirallyTraverse(vector<vector<int> > matrix, int r, int c) 
    {   
        vector<int> v;
        int startrow=0;
        int endrow=r-1;
        int startcol=0;
        int endcol=c-1;
        while(startrow<=endrow && startcol<=endcol){
            for(int i=startcol;i<=endcol && startrow<=endrow && startcol<=endcol;i++){
                v.push_back(matrix[startrow][i]);
            }
            startrow++;
            for(int i=startrow;i<=endrow && startrow<=endrow && startcol<=endcol;i++){
                v.push_back(matrix[i][endcol]);
            }
            endcol--;
            for(int i=endcol;i>=startcol && startrow<=endrow && startcol<=endcol;i--){
                v.push_back(matrix[endrow][i]);
            }
            endrow--;
            for(int i=endrow;i>=startrow && startrow<=endrow && startcol<=endcol;i--){
                v.push_back(matrix[i][startcol]);
            }
            startcol++;
        }
        return v;
        
    }
};

//{ Driver Code Starts.
int main() {
    int t;
    cin>>t;
    
    while(t--) 
    {
        int r,c;
        cin>>r>>c;
        vector<vector<int> > matrix(r); 

        for(int i=0; i<r; i++)
        {
            matrix[i].assign(c, 0);
            for( int j=0; j<c; j++)
            {
                cin>>matrix[i][j];
            }
        }

        Solution ob;
        vector<int> result = ob.spirallyTraverse(matrix, r, c);
        for (int i = 0; i < result.size(); ++i)
                cout<<result[i]<<" ";
        cout<<endl;
    }
    return 0;
}
// } Driver Code Ends
//{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;

// } Driver Code Ends
//User function template for C++
class Solution{
public:
    
    int onesinrow(vector<vector<int>> &arr, int i){
        int lower = lower_bound(arr[i].begin(), arr[i].end(), 1) - arr[i].begin();
        return arr[i].size() - lower;
    }

    int rowWithMax1s(vector<vector<int>> &arr, int n, int m) {
        int ans = 0;
        int ind = -1;
        for(int i = 0; i < n; i++){
            int ones = onesinrow(arr, i);
            if(ones > ans){
                ans = ones;
                ind = i;
            }
        }
        return ind;
    }
};

//{ Driver Code Starts.
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        vector< vector<int> > arr(n,vector<int>(m));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cin>>arr[i][j];
            }
        }
        Solution ob;
        auto ans = ob.rowWithMax1s(arr, n, m);
        cout << ans << "\n";
    }
    return 0;
}

// } Driver Code Ends
    int orangesRotting(vector<vector<int>>& grid) {
        int n= grid.size();
        int t;
        int m = grid[0].size();
        int vis[n][m];
        queue<pair<pair<int,int>,int>> q;
        for(int i=0;i<n;++i)
        {
            for(int j=0;j<m;++j)
            {
                if(grid[i][j]==2){
                q.push({{i,j},0});
                vis[i][j]=2;}
                else
                    vis[i][j]=0;
            }
        }
        int tm=0;
            while(!q.empty())
            {
                int r = q.front().first.first;
                int c = q.front().first.second;
                 t = q.front().second;
                 tm = max(t,tm);
                q.pop();
                int drow[] = {0,1,-1,0};
                int dcol[] = {1,0,0,-1};
                for(int i=0;i<4;++i)
                {
                    int nr = r+drow[i];
                    int nc = c+dcol[i];
                    if(nr>=0 && nr<n && nc>=0 && nc<m && vis[nr][nc]!=2 && grid[nr][nc]==1)
                    {
                        q.push({{nr,nc},t+1});
                        vis[nr][nc]=2;
                    }
                    
                }
            }
        
        for(int i=0;i<n;++i)
        {
            for(int j=0;j<m;++j)
            {
                if(grid[i][j]==1 && vis[i][j]!=2)
                return -1; 
            }

        }

        return tm;
    }
 vector<int> bfsOfGraph(int v,vector<int> adj[])
{
  vector<int> vis(v+1,0);
  vis[0]=1;
  queue<int> q;
  q.push(0);
  vector<int> bfs;
  while(!q.empty())
    {
      int node = q.front();
      bfs.push_back(node);
      q.pop();
      vis[node]=1;
      for(auto x:adj[node])
        {
          if(!vis[x]){
            q.push(x);
              vis[x]=1;
          }
        }
    }
    return bfs;
}
#include <iostream>
using namespace std;

int main() {
    float a, b, c;

    for (int i = 1; i < 30; ++i) {
        cout << "Digite as notas: " << endl;
        cin >> a >> b >> c;
       cout << "Media do aluno e de: "<< (a + b + c)/3 << endl;
    }

    return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(){
  string meses[12] = {"Janeiro", "Fevereiro", "Marco", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"};
  int numero;
  cin >> numero;
  if (numero >= 1 && numero <= 12){
    cout << meses[numero -1] << endl;
  } else {
    cout << "Numero invalido" << endl;
  }
}
class Solution {
public:
  
   
  int f(int ind, vector<int> &nums, vector<int> &dp) {
    if(ind == 0) return nums[ind];
    if(ind < 0) return 0;
    if(dp[ind] != -1) return dp[ind];
    int pick = nums[ind] + f(ind - 2, nums, dp);
    int notPick = 0 + f(ind - 1, nums, dp);
    return dp[ind] = max(pick, notPick);
}
    int rob(vector<int>& nums) {
        int n=nums.size();
        vector<int> dp(nums.size()+2,-1);
         int a = f(n-1,nums,dp);
         return a;
        
    }
};
vector<int> pf(int n)
{
    vector<int> v;
    for(int i=2;i<=n;++i)
    {
        while(n%i==0)
        {
            v.push_back(i);
            n/=i;
        }
    }
    return v;
}
int main() {
    std::vector<int> vec = {1, 2, 2, 3, 4, 4, 5};

    // Sort the vector
    std::sort(vec.begin(), vec.end());

    // Use unique to remove duplicates
    auto last = std::unique(vec.begin(), vec.end());

    // Erase the unused elements
    vec.erase(last, vec.end());

    // Print the result
    for(int n : vec) {
        std::cout << n << " ";
    }

    return 0;
}
 vector<vector<int>> v;

    void f(int i, int tar, vector<int>& nums, vector<int>& can) {
        if ( tar == 0) {
            v.push_back(nums);
            return;
        }
        if (i == can.size() || tar < 0)
            return;
     

        nums.push_back(can[i]);
        f(i, tar - can[i], nums, can);
        nums.pop_back();

        f(i + 1, tar, nums, can);
        
    }

    vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
        vector<int> ds;
        f(0, target, ds, candidates);
        return v;
    }
vector<vector<int>> subset;
 
  void gen(vector<int>& nums,int i,vector<int> sub)
  {
     if(i==nums.size())
        {
            subset.push_back(sub);
            return;
        }
        gen(nums,i+1,sub);

        sub.push_back(nums[i]);
        gen(nums,i+1,sub);

        
  }
vector<string> valid;
  void generate(string& s , int open,int close)
  {
    
    if(open==0 && close==0)
    {
        valid.push_back(s);
        return;
    }
    if(open>0)
    {
        s.push_back('(');
        generate(s,open-1,close);
        s.pop_back();
    }
    if(close>0 && open<close)
    {
        s.push_back(')');
        generate(s,open,close-1);
        s.pop_back();
    }
  }
#include<bits/stdc++.h>
using namespace std;
int sum=0;
vector<int> rev(vector<int>& nums,int f,int r)
{
    if(f<=r)
    {
        swap(nums[f],nums[r]);
        rev(nums,f+1,r-1);
    }
    return nums;
}
int main()
{

    vector<int> v = {4,5,2,6,3,56,5};
    rev(v,0,6);
    for(int i=0;i<=6;++i)
    cout<<v[i]<<" ";
    
}
void f(int n)
{
    n--;
    if(n)
    f(n);
    cout<<"AYUSH"<<endl;
}

void f(int n)
{
    if(n)
    f(n-1);
    cout<<"AYUSH"<<endl;
}
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+5;
vector<int> graph[N];
bool visited[N];
void dfs(int vertex)
{
  visited[vertex]=true;
  for(int child:graph[vertex])
    {
      
      if(visited[child])
        continue;
      dfs(child);
    }
}
int main()
{
    int v,e,j,k;
    cin>>v>>e;
    for(int i=0;i<v;++i)
    {
        cin>>j>>k;
        graph[k].push_back(j);
        graph[j].push_back(k);
        
    }
}
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+5;
vector<int> graph[N];
int main()
{
    int v,e,j,k;
    cin>>v>>e;
    for(int i=0;i<v;++i)
    {
        cin>>j>>k;
        graph[k].push_back(j);
        graph[j].push_back(k);
        
    }
}
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+5;
int graph[N][N];
int main()
{
    int v,e,j,k;
    cin>>v>>e;
    for(int i=0;i<e;++i)
    {
        cin>>j>>k;
        graph[i][j]=1;
        graph[j][i]=1;
        
    }
}
vector<int> Primrlist()
{
    isPrime[0]=isPrime[1]=false;
    for(int i=0;i<N;++i)
    {
        if(isPrime[i]==true)
        {
            for(int j=2*i;j<=N;j+=i)
            isPrime[j]=0;
        }
    }
    return isPrime;
}
vector<int> bin(int num) 
{
    vector<int> binaryNum;
    if (num == 0) {
        binaryNum.push_back(0);
        return binaryNum;
    }
     while (num > 0) {
        binaryNum.push_back(num % 2);
        num = num / 2;
    }
    reverse(binaryNum.begin(), binaryNum.end());
    return binaryNum;
}
//Source.ccp

//Setup SDL
bool InitSDL() {
	//If failed to Initialize
	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		cout << "Failed to Init SDL. Error: " << SDL_GetError() << "\n";
		return false;
	}

	//If Sucesss
	else {
		//Create Window
		gWindow = SDL_CreateWindow("MarioBrosClone", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN); 
		
		//Create renderer
		gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED);

		//Check if Window is null
		if (gWindow == NULL) {
			cout << "Failed to create Window, Error: " << SDL_GetError() << "\n";
			return false;
		}

		//Check if renderer is null;
		if (gRenderer == NULL) {
			cout << "Failed to create Renderer, Error " << SDL_GetError() << "\n";
			return false;
		}

		//Set Texture
		else {
			int imageFlags = IMG_INIT_PNG;

			if (!(IMG_Init(imageFlags)) && imageFlags) {
				cout << "Failed to load SDL_Image, Error " << SDL_GetError() << "\n";
				return false;
			}
		}

		//Create Mixer
		if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) {
			cout << "Mixer could not initialise. Error: " << Mix_GetError();
			return false;
		}

		if (TTF_Init() < 0) {
			cout << "Error: " << TTF_GetError() << endl;
			return false;
		}
	}

	return true;
}

//Close SDL
void CloseSDL() {
	SDL_DestroyWindow(gWindow);
	gWindow = NULL;

	IMG_Quit();
	SDL_Quit();

	SDL_DestroyRenderer(gRenderer);
	gRenderer = NULL;

	delete gTexture;
	gTexture = NULL;

	delete gameScreenManager;
	gameScreenManager = NULL;
}

//Render 
void Render() {
	//Clear Screen
	SDL_SetRenderDrawColor(gRenderer, 0x00, 0x00, 0x00, 0x00);
	SDL_RenderClear(gRenderer);
	
	//Render Texture to Screen
	gameScreenManager->Render();

	//Update Screen
	SDL_RenderPresent(gRenderer);
}
//GameScreenLevel1.cpp
void GameScreenLevel1::SetLevelMap() {
	//0 blank, 1 wall, 2 win condition
	int map[MAP_HEIGHT][MAP_WIDTH] = {
		{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		{1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1},
		{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		{0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0},
		{1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
		{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		{1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1},
		{0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
		{0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
		{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
	};

	//Clear up any old map
	if (mLevelMap != NULL)
	{
		delete mLevelMap;

	}

	//Set up the new one
	mLevelMap = new LevelMap(map);
}


//Collision.cpp
bool Collision::Circle(Character* character1, Character* character2) {
	//Calculate Vector between 2 characters
	Vector2D vec = Vector2D((character1->GetPosition().x - character2->GetPosition().x), (character1->GetPosition().y - character2->GetPosition().y));

	//Calculate lenght from vector
	double distance = sqrt((vec.x * vec.x) + (vec.y * vec.y));

	//Get Collision Radius 
	double combinedDistance = (character1->GetCollisionRadius() - character2->GetCollisionRadius());

	if (distance < combinedDistance) {
		return true;
	}
	else return false;
}

bool Collision::Box(Rect2D rect1, Rect2D rect2) {
	if (rect1.x + (rect1.width / 2) > rect2.x && rect1.x + (rect1.width / 2) < rect2.x + rect2.width && rect1.y + (rect1.height / 2) > rect2.y && rect1.y + (rect1.height / 2) < rect2.y + rect2.height) {
		return true;
	}
	return false;
}
 ListNode *hasCycle(ListNode *head) {
        ListNode *slow=head;
        ListNode *fast=head;
      while(fast!=NULL && fast->next!=NULL)
      {
        slow=slow->next;
        fast=fast->next->next;
        if(fast==slow)
        return slow;
      }
     return NULL;
    }
    ListNode *detectCycle(ListNode *head) {
         ListNode *t1=hasCycle(head);
         if(t1==NULL)return NULL;
        ListNode *t=head;
       

        while(t!=t1)
        {
            t=t->next;
            t1=t1->next;
        }
        return t;
        
    }
bool hasCycle(ListNode *head) {
        ListNode *slow=head;
        ListNode *fast=head;
      while(fast!=NULL && fast->next!=NULL)
      {
        slow=slow->next;
        fast=fast->next->next;
        if(fast==slow)
        return true;
      }
      return false;
    }
 bool hasCycle(ListNode *head) {
        ListNode* temp = head;
        unordered_map<ListNode*,int> m;
         while(temp != NULL) {
            m[temp]++;
            if(m[temp] == 2) {
                return true;
            }
            temp = temp->next;
        }

        return false;
    }
int maxSubArray(vector<int>& nums)
{
    int sum=0;
    int maxi = INT_MIN;
    for(int i=0;i<nums.size();++i)
    {   sum+=nums[i];
        maxi = max(maxi,sum);
        if(sum<0)
        sum=0;
    }
    return maxi;
}
int maxSubArray(vector<int>& nums)
 {
    int n=nums.size();
    if(n==1)
    return nums[0];
    vector<int> pf;
    pf.push_back(nums[0]);
    for(int i=1;i<n;++i)
    pf.push_back(nums[i]+pf[i-1]);
    int m = INT_MIN;
    int elem = *max_element(pf.begin(),pf.end());
    for(int j=0;j<n-1;++j)
    {
        for(int k=j+1;k<n;++k)
        m = max(m,(pf[k]-pf[j]));
        
    }
    m = max(m,elem);
    int mi = *max_element(nums.begin(),nums.end());
    cout<<m<<" "<<mi;
    
    if(mi>m)
    return mi;
    else return m;
    

 }
 vector<int> nextGreaterElement(vector<int>& nums1, vector<int>& nums2) {
        stack<int> s;
        const int N =1e5;
        vector<int> ans;
        vector<int> v(N);
        int n=nums2.size();
        s.push(nums2[n-1]);
        v[nums2[n-1]]=-1;
        
        for(int i=nums2.size()-2;i>=0;--i)
        {
             if(nums2[i]<(s.top()))
            {
                
                v[nums2[i]]=s.top();
                s.push(nums2[i]);
            }
            else
            {
                while(!s.empty() && s.top()<nums2[i]  )//order matters in &&
                s.pop();
                if(s.empty())
                v[nums2[i]]=-1;
                else
                v[nums2[i]]=s.top();
                s.push(nums2[i]);
            }
        }
        for(int j=0;j<nums1.size();++j)
        {
            ans.push_back(v[nums1[j]]);
        }


        return ans;
    }
   
Things to keep in Mind in Linked List
1) Make sure where to use temp->next1=NULL  OR temp!=NULL
2) fast!=NULL && fast->next!=NULL 
Use this order only else it will give runtime error
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* deleteMiddle(ListNode* head) {

           ListNode* o=head;
           ListNode* t=head;
           ListNode* prev=head;
           if(head->next==NULL)
           {
            return head=NULL;
           }
           if(head->next->next==NULL)
           {
            delete head->next;
            head->next=NULL;
            return head;
           }
          while(t!=NULL && t->next!=NULL) 
           {
             if(t!=head)
             prev=prev->next;
             o=o->next;
             t=t->next->next; 
           }
           prev->next=o->next;
           delete o;
        return head;
    }
};
    ListNode* reverseList(ListNode* head)
    {ListNode* t1,*t2,*t3;
        t1 = head;
        if(head!=NULL)
         t2 = head->next;
        else
        return head;
        if(t2!=NULL)
        t3 = head->next->next;
        else
        {
            
            return head;
        }
        head->next=NULL;
        while(t3!=NULL)
        {
            t2->next=t1;
            t1=t2;
            t2=t3;
            t3=t3->next;
        }
        t2->next=t1;
        head = t2;
        return head;

    }
     
ListNode* reverseList(ListNode* head) {
        stack<int> s;
        ListNode* t=head;
           while(t!=NULL)
           {
             s.push(t->val);
             t=t->next;
           }
           t=head;
             while(t!=NULL)
           {
             t->val = s.top();
             s.pop();
             t=t->next;
           }
           return head;
    
int search(vector<int>& nums, int target) {
        int low = 0;
        int n = nums.size();
        int high = n-1;
        
        while(high>=low){
            int mid = (high+low)/2;
        if(nums[mid]==target)return mid;
        else if(target>nums[mid])
        {
            low = mid+1;
        }
        else
        {
            high=mid-1;
        }
        }
        return -1;
    }
bool cmp(pair<int,int> a,pair<int,int> b)
{return a>b;}
sort(p.begin(),p.end(),cmp);
bool cmp(int a,int b)
{
  return a>b;
}
sort(v.begin(),v.end(),cmp);
//Remember in sort use cmp not cmp()
Example 1. without virtual keyword / Using scope resolution
#include <iostream>

using namespace std;

class classA {
    public:
    int a;
};

class classB : public classA {
    public:
    int b;
};
class classC : public classA {
    public:
    int c;
};
class classD : public classB, public classC {
    public:
    int d;
    
};

int main() {
   
   classD objD;
   //objD.a; Error
   
   objD.classB::a = 100; // this way is correct
   objD.classC::a = 200;
   
   cout<<"A from classB = "<<objD.classB::a<<endl;
   cout<<"A from classc = "<<objD.classC::a<<endl;
   objD.b = 10;
   objD.c = 20;
   objD.d = 30;
   cout<<"B = "<<objD.b<<endl;
   cout<<"C = "<<objD.c<<endl;
   cout<<"D = "<<objD.d<<endl;
   
    
    return 0;
}
//Output:
A from classB = 100
A from classc = 200
B = 10
C = 20
D = 30

_______________________________________________________________-
  
  Example 2. Using Virtual Kwyeord
  #include <iostream>

using namespace std;

class classA {
    public:
    int a;
};

class classB : virtual public classA {
    public:
    int b;
};
class classC : virtual public classA {
    public:
    int c;
};
class classD : public classB, public classC {
    public:
    int d;
    
};

int main() {
   
   classD objD;
   
   objD.a = 100; // is correct using virtual keyword. we can access a value from one copy.
   cout<<"Using Virtual keyword: "<<endl;
   classB objB;
   objB.a =600;
   cout<<"A from class B = "<<objB.a<<endl;
   cout<<"A from class D = "<<objD.a<<endl;
   objD.b = 10;
   objD.c = 20;
   objD.d = 30;
   cout<<"B = "<<objD.b<<endl;
   cout<<"C = "<<objD.c<<endl;
   cout<<"D = "<<objD.d<<endl;
   
    
    return 0;
}
//Output:
Using Virtual keyword: 
A from class B = 600
A from class D = 100
B = 10
C = 20
D = 30
none_of(v.begin(),v.end(),[](int x){return x>0;});
//it returns boolean value
any_of(v.begin(),v.end(),[](int x){return x%2==0;});
//it returns boolean value
all_of(v.begin(),v.end(),[](int x){return x>0;});
//it returns boolean value
it = find(v.begin(),v.end(),num);
//if not found it returns v.end();
int sum = accumulated(v.begin(),v.end(),0);
int a =*(max_element(v.begin(),v.end()));
int a =*(min_element(v.begin(),v.end()));
pair<int, int> findNonDivisiblePair(const std::vector<int>& vec) {
    for (size_t i = 0; i < vec.size(); ++i) {
        for (size_t j = i + 1; j < vec.size(); ++j) {
            if (vec[i] % vec[j] != 0 && vec[j] % vec[i] != 0) {
                return std::make_pair(vec[i], vec[j]);
            }
        }
    }
    // If no pair is found, return a pair of -1, -1 or handle as required
    return std::make_pair(-1, -1);
}
pair<int, int> findMinimumNonDivisiblePair(const std::vector<int>& vec) {
    std::pair<int, int> minPair = std::make_pair(-1, -1);
    int minSum = std::numeric_limits<int>::max();

    for (size_t i = 0; i < vec.size(); ++i) {
        for (size_t j = i + 1; j < vec.size(); ++j) {
            if (vec[i] % vec[j] != 0 && vec[j] % vec[i] != 0) {
                int currentSum = vec[i] + vec[j];
                if (currentSum < minSum) {
                    minSum = currentSum;
                    minPair = std::make_pair(vec[i], vec[j]);
                }
            }
        }
    }
    return minPair;
}
bool check(vector<int>& nums) {
        int count = 0 ;
        if (nums[0] < nums[nums.size()-1]) count++ ;
        for (int i=1; i<nums.size(); i++){
            if (nums[i] < nums[i-1]){
                count++ ;
                if (count > 1) return false ;
            }
        }
        return true ;
    }
#include <iostream>

using namespace std;

int main() {
    
    char variable1 = 'b';
    int variable2 = 15;
    double variable3 = 10.2;
    
    char *pntr1 = &variable1;
    int *pntr2 = &variable2;
    double *pntr3 = &variable3;
    
    cout<<"before changing: "<<endl;
    cout<<"variable1 value= "<<variable1<<",\t\tAddress: "<<&variable1<<",\t*pntr1 value = "<<*pntr1<<endl;
    cout<<"variable2 value= "<<variable2<<",\tAddress: "<<&variable2<<",\t*pntr2 = "<<*pntr2<<endl;
    cout<<"variable3 value= "<<variable3<<",\tAddress: "<<&variable3<<",\t*pntr3 = "<<*pntr3<<endl;
    
    *pntr1 = 'c';
    *pntr2 = 25;
    *pntr3 = 12.50;
    
    cout<<"____________________"<<endl;
    cout<<"After changing: "<<endl;
    cout<<"variable1 value= "<<variable1<<",\t\tAddress: "<<&variable1<<",\t*pntr1 value = "<<*pntr1<<endl;
    cout<<"variable2 value= "<<variable2<<",\tAddress: "<<&variable2<<",\t*pntr2 = "<<*pntr2<<endl;
    cout<<"variable3 value= "<<variable3<<",\tAddress: "<<&variable3<<",\t*pntr3 = "<<*pntr3<<endl;

    
    return 0;
}
//OUTPUT:
before changing: 
variable1 value= b,		Address: b(b5��,	*pntr1 value = b
variable2 value= 15,	Address: 0x7ffce6356230,	*pntr2 = 15
variable3 value= 10.2,	Address: 0x7ffce6356228,	*pntr3 = 10.2
____________________
After changing: 
variable1 value= c,		Address: c(b5��,	*pntr1 value = c
variable2 value= 25,	Address: 0x7ffce6356230,	*pntr2 = 25
variable3 value= 12.5,	Address: 0x7ffce6356228,	*pntr3 = 12.5
 int findMaxConsecutiveOnes(vector<int>& nums) {
        int count = 0;
        int m=0;
        int n=nums.size();
        for(int j=0;j<n;++j)
        {
            if(nums[j]==1)
            {
                count++;
                 m=max(count,m);
            }
            else{
               
                count=0;
            }
        }
        return m;
        
    }
    vector<int> v;
        int n=nums.size();
        int f=k%(n);
        int a=n-f;
        for(int i=0;i<n;++i)
        {
            if((a+i)<=(n-1))
            v.push_back(nums[a+i]);
            else
            v.push_back(nums[a+i-nums.size()]);
        }
        nums=v;}
};
 int removeDuplicates(vector<int>& nums) {
       int i=0;
       int n=nums.size();
       for(int j=1;j<n;++j)
       {if(nums[i]!=nums[j])
        {  nums[i+1]=nums[j]; i++;}}
       return i+1;}
 int removeDuplicates(vector<int>& nums) {
        set<int> s;
        for(int i=0;i<nums.size();++i)
        {
            s.insert(nums[i]);
        }
        set<int> :: iterator it;
        vector<int> v;
        for(it=s.begin();it!=s.end();++it)
        {
            v.push_back(*it);
        }
        nums=v;
        int a = s.size();
        return a;
        
    }
int setBit(int n)
    {
        // Write Youwhile(r Code here
        int count=0;
        while((n%2)!=0)
    {
        n=n>>1;
        count++;
    }
    n=n+1;
    for(int i=0;i<count;++i)
    {
        n=n*2+1;
    }
        return n;
    }
int setBit(int n)
    {
        // Write Youwhile(r Code here
        int count=0;
        while((n%2)!=0)
    {
        n=n>>1;
        count++;
    }
    n=n+1;
    for(int i=0;i<count;++i)
    {
        n=n*2+1;
    }
        return n;
    }
 const int N = 1e5;
        vector<int> dp(N,-1);
class Solution {
public:
    int climbStairs(int n) {
       
        if(n==1)return 1;
        if(n==2)return 2;
        if(dp[n]!=-1)return dp[n];
        return dp[n]=climbStairs(n-1)+climbStairs(n-2);
      }
};
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;
vector<int> dp(N,-1);
int fib(int n)
{
    if(n==0)return 0;
    if(n==1)return 1;
    if(dp[n]!=-1)return dp[n];
    return dp[n]=fib(n-1)+fib(n-2);
}
int main()
{
    int n=6;
    cout<<fib(n);
}
string reverseWords(string s) {
       int n = s.size();
       std::string reverse_string = "";
       for ( int i = n-1 ; i > -1; --i ){
        if (s[i] == ' '){
            continue;
        }
        int count = 0;
        while ( i > -1 && s[i] != ' '){
            --i; count++;
        }
        if (reverse_string != ""){
            reverse_string.append(" ");
        }
        reverse_string.append(s.substr(i+1,count));
       }
       return reverse_string; 
    }
class Solution {
public:
    string frequencySort(string s) {
        map<char,int> m1;
        multimap<int,char> m2;
        map<char,int> :: iterator it;
        multimap<int,char>::iterator it1;
        string str = "";
        for(int i=0;i<s.length();++i)
         m1[s[i]]++;
        for(it=m1.begin();it!=m1.end();++it)
        m2.insert({it->second,it->first});
        for(it1=m2.begin();it1!=m2.end();++it1)
         {
            for(int j=it1->first;j>0;--j)
            {str.push_back(it1->second);}
         }
         reverse(str.begin(),str.end());
         return str;
     }
};
class Solution {
public:
    bool isIsomorphic(string s, string t) {
        string r;
        if(s.length()!=t.length())
        return false;
        map<char,char> m1,m2,m3;
        for(int i=0;i<s.length();++i)
        {
            m1.insert({s[i],t[i]});
            m2.insert({t[i],s[i]});
        }
        if(m1.size()>=m2.size())
        {m3=m2;
        r=s;}
        else
        {m3=m1;r=t;}
        for(int j=0;j<s.length();++j)
        {
            if(r[j]==m3[t[j]])
            continue;
            else
            return false;
        }
        return true;
        
    }
};
 string s= "ayush";
    sort(s.begin(),s.end());
    cout<<s;
if(str.find(goal) != string::npos)
           {return true;}
           else{return false;}
if(str.find(goal) != string::npos)
           {return true;}
           else{return false;}
if(n==1)return v[0];
if(v[0]!=v[1])return v[0];
if(v[n-1]!=v[n-2])return v[n-1];
low=1;high=n-2;
while(low<high)
  {
    mid=high-((high-low)/2);
    if(v[mid]!=v[mid-1] && v[mid]!=v[mid+1])return v[mid];
    if((mid%2==0 && v[mid-1]==v[mid]) || (mid%2==1 && v[mid+1]==v[mid]))
      {
        high=mid-1;
      }
    else if((mid%2==1 && v[mid-1]==v[mid]) || (mid%2==0 && v[mid+1]==v[mid]))
      {
        low=mid+1;
      }
  }
  
#include <iostream>
#include <istream>
#include <string>
#include <vector>

using namespace std;

class Book {
    int BookID;
    std::string Title;
    std::string Author;
    double price;
    static int numOfBooks;
    
  friend class Library; // Declare Library as a friend class

    public:
    Book(int BookID, std::string Title, std::string Author, double price){
        this->BookID = BookID;
        this->Title = Title;
        this->Author = Author;
        this->price = price;
        numOfBooks ++;
    }
    int getBookID() const {
    return BookID;
}

    
    std::string getTitle() const {
    return Title;
}
   std::string getAuthor() const {
    return Author;
}
   double getPrice() const {
    return price;
}
    //Static Function
   static int getTotalNumOfBooks(){
        return numOfBooks;
    };

};

int Book::numOfBooks = 0;


//Class User
class Users{
    
    public:
    std::string name;
    std::string address;
    std::string email;
    int phoneNum;
    
    Users(std::string n, std::string addre,std::string em, int pN){
        name = n;
        address = addre;
        email = em;
        phoneNum = pN;
    }
    
    //Virtual Function & Overiding function
    virtual void display(){
    }
    
};
//Derived Class from Base class User
class Student: public Users{
    
    int studentID;
    public:
    Student(int studentID, std::string name, std::string address, std::string email, int phoneNum):Users(name, address, email, phoneNum){
        this->studentID = studentID;
    }
    
    int getStudentID() const {
    return studentID;
}
    
    //Function Overloading, Same Name but different arguments.
    void print(std::string name){
        cout<<"student Name: "<<name<<endl;
    }
    void print(std::string name, int studentID){
        cout<<"Student Name: "<<name<<endl;
        cout<<"Student ID: "<<studentID<<endl;
    }
    //Default arguments
    void print(std::string name, std::string email, int studentID = 1111){
        cout<<"Student Name: "<<name<<endl;
        cout<<"Student Email: "<<email<<endl;
        cout<<"Student ID: "<<studentID<<endl;
    }
    
    void display(){
        cout<<"\n__Student Info:_ "<<endl;
        cout<<"ID: "<<studentID<<endl;
        cout<<"Name: "<<name<<endl;
        cout<<"Address: "<<address<<endl;
        cout<<"Email: "<<email<<endl;
        cout<<"Phone Number: "<<phoneNum<<endl;
    }
    
    //Friend Function
    friend void globalFunction(Student &stud);
};
class Staff: public Users{
    int staffID;
    public:
    Staff(int staffID, std::string name, std::string address, std::string email, int phoneNum):Users(name, address, email, phoneNum){
        this->staffID = staffID;
    }
    int getStaffID(){
        return staffID;
    }
    
    void display(){
        cout<<"\n___Staff Info:_ "<<endl;
        cout<<"ID: "<<staffID<<endl;
        cout<<"Name: "<<name<<endl;
        cout<<"Address: "<<address<<endl;
        cout<<"Email: "<<email<<endl;
        cout<<"Phone Number: "<<phoneNum<<endl;
    }
    friend void globalFunction(Staff &staf);
};

//Friend Function implementation
void globalFunction(Student &stud, Staff &staf){
    cout<<"\nAccessing Student ID: "<<stud.getStudentID()<<endl;
    cout<<"Accessing Staff ID: "<<staf.getStaffID()<<endl;
}

 class Library{

vector<Book*> books; // Declaration of books vector
vector<Student*> students;
    
    Book *book;
    std::string name;
    std::string address;
    
    public:
    Library(std::string name, std::string address){
        this->name = name;
        this->address = address;
    }
    
    void setBook(Book *book){
        this->book = book;
    }
    Book* getBook(){
        return book;
    }
    std::string getName(){
        return name;
    }
    void setName(std::string name){
        this->name = name;
    }
    std::string getAddress(){
        return address;
    }
    void setAddress(std::string address){
        this->address = address;
    }
    void addBook(const std::string& title, const std::string& author, double price) {
        int id = books.size() + 1; // Generate ID automatically based on the number of books
        books.push_back(new Book(id, title, author, price));
        cout << "Book added successfully with ID: " << id << endl;
    }
    bool deleteBook(int id) {
        auto it = find_if(books.begin(), books.end(), [id](const Book* book) {
            return book->getBookID() == id;
        });
        if (it != books.end()) {
            books.erase(it);
            return true;
        }
        return false;
    }
    void editBook(int id, std::string newTitle, std::string newAuthor, double newPrice) {
        auto it = find_if(books.begin(), books.end(), [id](const Book* book) {
            return book->getBookID() == id;
        });
        if (it != books.end()) {
            (*it)->Title = newTitle;
            (*it)->Author = newAuthor;
            (*it)->price = newPrice;
        }
    }
    void showBookInfo(int id) {
        auto it = std::find_if(books.begin(), books.end(), [id](const Book* book) {
            return book->getBookID() == id;
        });
        if (it != books.end()) {
            std::cout << "Book ID: " << (*it)->getBookID() << std::endl;
            std::cout << "Book Title: " << (*it)->getTitle() << std::endl;
            std::cout << "Book Author: " << (*it)->getAuthor() << std::endl;
            std::cout << "Book Price: " << (*it)->getPrice() << std::endl;
        }
    }

    std::vector<Book*>& getBooks() { // Return a reference to the vector of books
        return books;
    }


    void addStudent(const std::string& name, const std::string& address, const std::string& email, int phoneNum) {
        int id = students.size() + 1; // Generate ID automatically based on the number of students
        students.push_back(new Student(id, name, address, email, phoneNum));
        cout << "Student added successfully with ID: " << id << endl;
    }

    bool deleteStudent(int id) {
        auto it = find_if(students.begin(), students.end(), [id](const Student* student) {
            return student->getStudentID() == id;
        });
        if (it != students.end()) {
            students.erase(it);
            return true;
        }
        return false;
    }

    void editStudent(int id, const string& newName, const string& newAddress, const string& newEmail, int newPhoneNum) {
        auto it = find_if(students.begin(), students.end(), [id](const Student* student) {
            return student->getStudentID() == id;
        });
        if (it != students.end()) {
            (*it)->name = newName;
            (*it)->address = newAddress;
            (*it)->email = newEmail;
            (*it)->phoneNum = newPhoneNum;
        }
    }

    void showStudentInfo(int id) {
    auto it = find_if(students.begin(), students.end(), [id](const Student* student) {
        return student->getStudentID() == id;
    });
    if (it != students.end()) {
        cout << "Student ID: " << (*it)->getStudentID() << endl;
        cout << "Student Name: " << (*it)->name << endl;
        cout << "Student Address: " << (*it)->address << endl;
        cout << "Student Email: " << (*it)->email << endl;
        cout << "Student Phone Number: " << (*it)->phoneNum << endl;
    }
}
};





int main() {
    Library library("University Library", "Uskudar");

    while (true) {
        cout << "\nMenu:" << endl;
        cout << "1. Manage Books" << endl;
        cout << "2. Manage Students" << endl;
        cout << "3. Exit" << endl;
        cout << "Enter your choice: ";

        int choice;
        cin >> choice;

        switch (choice) {
        case 1: {
            cout << "\nBooks Menu:" << endl;
            cout << "1. Add Book" << endl;
            cout << "2. Delete Book" << endl;
            cout << "3. Edit Book" << endl;
            cout << "4. Show Book Information" << endl;
            cout << "5. Book List" << endl;
            cout << "Enter your choice: ";

            int bookChoice;
            cin >> bookChoice;

            switch (bookChoice) {
            case 1: {
              std::string title, author;
              double price;
              cout << "Enter book title: ";
                 cin.ignore();
                 getline(cin, title);
                 cout << "Enter book author: ";
                     getline(cin, author);
                   cout << "Enter book price: ";
                   cin >> price;
                   library.addBook(title, author, price);

                
                break;
            }
            case 2: {
                int id;
                cout << "Enter ID of the book to delete: ";
                cin >> id;
                if (library.deleteBook(id)) {
                    cout << "Book with ID " << id << " deleted successfully." << endl;
                }
                else {
                    cout << "Book with ID " << id << " not found." << endl;
                }
                break;
            }
            case 3: {
                int id;
                string newTitle, newAuthor;
                double newPrice;
                cout << "Enter ID of the book to edit: ";
                cin >> id;
                cout << "Enter new title: ";
                cin.ignore();
                getline(cin, newTitle);
                cout << "Enter new author: ";
                getline(cin, newAuthor);
                cout << "Enter new price: ";
                cin >> newPrice;
                library.editBook(id, newTitle, newAuthor, newPrice);
                cout << "Book edited successfully." << endl;
                break;
            }
            case 4: {
                int id;
                cout << "Enter ID of the book to show information: ";
                cin >> id;
                library.showBookInfo(id);
                break;
            }
           case 5: {
            vector<Book*> books = library.getBooks();
             cout << "\nBook List:" << endl;
            for (Book* book : books) {
    cout << "Book ID: " << book->getBookID() << ", Title: " << book->getTitle() << ", Author: " << book->getAuthor() << ", Price: " << book->getPrice() << endl;
}
                 break;
               }

            default:
                cout << "Invalid choice." << endl;
            }
            break;
        }
            case 2: {
                cout << "\nStudents Menu:" << endl;
                cout << "1. Add Student" << endl;
                cout << "2. Remove Student" << endl;
                cout << "3. Edit Student" << endl;
                cout << "4. Get Student Info" << endl;
                cout << "5. Exit" << endl;
                cout << "Enter your choice: ";

                int studentChoice;
                cin >> studentChoice;

                switch (studentChoice) {
                    case 1: {
                         std::string name, address, email;
                        int phoneNum;
                        cout << "Enter student name: ";
                        cin.ignore();
                        getline(cin, name);
                        cout << "Enter student address: ";
                        getline(cin, address);
                        cout << "Enter student email: ";
                        cin >> email;
                         cout << "Enter student phone number: ";
                        cin >> phoneNum;
                        library.addStudent(name, address, email, phoneNum);
                        
                        break;
                    }
                    case 2: {
                        int id;
                        cout << "Enter ID of the student to remove: ";
                        cin >> id;
                        if (library.deleteStudent(id)) {
                            cout << "Student with ID " << id << " removed successfully." << endl;
                        } else {
                            cout << "Student with ID " << id << " not found." << endl;
                        }
                        break;
                    }
                    case 3: {
                        int id;
                        string newName, newAddress, newEmail;
                        int newPhoneNum;
                        cout << "Enter ID of the student to edit: ";
                        cin >> id;
                        cout << "Enter new name: ";
                        cin.ignore();
                        getline(cin, newName);
                        cout << "Enter new address: ";
                        getline(cin, newAddress);
                        cout << "Enter new email: ";
                        cin >> newEmail;
                        cout << "Enter new phone number: ";
                        cin >> newPhoneNum;
                        library.editStudent(id, newName, newAddress, newEmail, newPhoneNum);
                        cout << "Student edited successfully." << endl;
                        break;
                    }
                    case 4: {
                        int id;
                        cout << "Enter ID of the student to get information: ";
                        cin >> id;
                        library.showStudentInfo(id);
                        break;
                    }
                    case 5: {
                        cout << "Exiting students menu..." << endl;
                        break;
                    }
                    default:
                        cout << "Invalid choice." << endl;
                }
                break;
            }
        case 3:
            cout << "Exiting..." << endl;
            return 0;
        default:
            cout << "Invalid choice. Please enter a number from 1 to 3." << endl;
        }
    }

    return 0;
}
//OUTPUT:


Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 1

Books Menu:
1. Add Book
2. Delete Book
3. Edit Book
4. Show Book Information
5. Book List
Enter your choice: 1
Enter book title: The Power
Enter book author: James
Enter book price: 23
Book added successfully with ID: 1

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 1

Books Menu:
1. Add Book
2. Delete Book
3. Edit Book
4. Show Book Information
5. Book List
Enter your choice: 1
Enter book title: Psychology
Enter book author: Mike
Enter book price: 21
Book added successfully with ID: 2

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 1

Books Menu:
1. Add Book
2. Delete Book
3. Edit Book
4. Show Book Information
5. Book List
Enter your choice: 5

Book List:
Book ID: 1, Title: The Power, Author: James, Price: 23
Book ID: 2, Title: Physcology, Author: Mike, Price: 21

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 1

Books Menu:
1. Add Book
2. Delete Book
3. Edit Book
4. Show Book Information
5. Book List
Enter your choice: 2
Enter ID of the book to delete: 2
Book with ID 2 deleted successfully.

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 1

Books Menu:
1. Add Book
2. Delete Book
3. Edit Book
4. Show Book Information
5. Book List
Enter your choice: 5

Book List:
Book ID: 1, Title: The Power, Author: James, Price: 23

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 2

Students Menu:
1. Add Student
2. Remove Student
3. Edit Student
4. Get Student Info
5. Exit
Enter your choice: 1
Enter student name: Mohamed
Enter student address: Istanbul
Enter student email: moha@gmail.com
Enter student phone number: 5544
Student added successfully with ID: 1

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 2

Students Menu:
1. Add Student
2. Remove Student
3. Edit Student
4. Get Student Info
5. Exit
Enter your choice: 1
Enter student name: Nasir
Enter student address: Istanbul
Enter student email: nasir@gmail.com
Enter student phone number: 1122
Student added successfully with ID: 2

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 2

Students Menu:
1. Add Student
2. Remove Student
3. Edit Student
4. Get Student Info
5. Exit
Enter your choice: 2
Enter ID of the student to remove: 2
Student with ID 2 removed successfully.

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 2

Students Menu:
1. Add Student
2. Remove Student
3. Edit Student
4. Get Student Info
5. Exit
Enter your choice: 4
Enter ID of the student to get information: 2

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 2

Students Menu:
1. Add Student
2. Remove Student
3. Edit Student
4. Get Student Info
5. Exit
Enter your choice: 4
Enter ID of the student to get information: 1
Student ID: 1
Student Name: Mohamed
Student Address: Istanbul
Student Email: moha@gmail.com
Student Phone Number: 5544

Menu:
1. Manage Books
2. Manage Students
3. Exit
Enter your choice: 3
Exiting...
 
Normal program termination. Exit status: 0
#include <iostream>

using namespace std;

class Book{
    int BookID;
    string Title;
    string Author;
    double price;
    static int numOfBooks;
    
    public:
    //Parameter Constructor
    Book(int BookID, string Title, string Author, double price){
        this->BookID = BookID;
        this->Title = Title;
        this->Author = Author;
        this->price = price;
        numOfBooks ++;
    }
    int getBookID(){
        return BookID;
    }
    string getTitle(){
        return Title;
    }
    string getAuthor(){
        return Author;
    }
    double getPrice(){
        return price;
    }
    //Static Function
   static int getTotalNumOfBooks(){
        return numOfBooks;
    }
};
int Book::numOfBooks = 0;

class Library{
    Book *book;
    string name;
    string address;
    
    public:
    Library(string name, string address){
        this->name = name;
        this->address = address;
    }
    
    void setBook(Book *book){
        this->book = book;
    }
    Book* getBook(){
        return book;
    }
    string getName(){
        return name;
    }
    void setName(string name){
        this->name = name;
    }
    string getAddress(){
        return address;
    }
    void setAddress(string address){
        this->address = address;
    }
};

//Class User
class Users{
    
    public:
    string name;
    string address;
    string email;
    int phoneNum;
    
    Users(string n, string addre,string em, int pN){
        name = n;
        address = addre;
        email = em;
        phoneNum = pN;
    }
    
    //Virtual Function & Overiding function
    virtual void display(){
    }
    
};
//Derived Class from Base class User
class Student: public Users{
    
    int studentID;
    public:
    Student(int studentID, string name, string address, string email, int phoneNum):Users(name, address, email, phoneNum){
        this->studentID = studentID;
    }
    
    int getStudentID(){
        return studentID;
    }
    
    //Function Overloading, Same Name but different arguments.
    void print(string name){
        cout<<"student Name: "<<name<<endl;
    }
    void print(string name, int studentID){
        cout<<"Student Name: "<<name<<endl;
        cout<<"Student ID: "<<studentID<<endl;
    }
    //Default arguments
    void print(string name, string email, int studentID = 1111){
        cout<<"Student Name: "<<name<<endl;
        cout<<"Student Email: "<<email<<endl;
        cout<<"Student ID: "<<studentID<<endl;
    }
    
    void display(){
        cout<<"\n_____Student Info:____ "<<endl;
        cout<<"ID: "<<studentID<<endl;
        cout<<"Name: "<<name<<endl;
        cout<<"Address: "<<address<<endl;
        cout<<"Email: "<<email<<endl;
        cout<<"Phone Number: "<<phoneNum<<endl;
    }
    
    //Friend Function
    friend void globalFunction(Student &stud);
};
class Staff: public Users{
    int staffID;
    public:
    Staff(int staffID, string name, string address, string email, int phoneNum):Users(name, address, email, phoneNum){
        this->staffID = staffID;
    }
    int getStaffID(){
        return staffID;
    }
    
    void display(){
        cout<<"\n______Staff Info:____ "<<endl;
        cout<<"ID: "<<staffID<<endl;
        cout<<"Name: "<<name<<endl;
        cout<<"Address: "<<address<<endl;
        cout<<"Email: "<<email<<endl;
        cout<<"Phone Number: "<<phoneNum<<endl;
    }
    friend void globalFunction(Staff &staf);
};

//Friend Function implementation
void globalFunction(Student &stud, Staff &staf){
    cout<<"\nAccessing Student ID: "<<stud.getStudentID()<<endl;
    cout<<"Accessing Staff ID: "<<staf.getStaffID()<<endl;
}

int main() {

    cout<<"_____Library Management System._____"<<endl;
    
    Library lib("University Library","Uskudar");
    cout<<"\n____Library Info____"<<endl;
    cout<<"Name: "<<lib.getName()<<endl;
    cout<<"Address: "<<lib.getAddress()<<endl;
    
    lib.setBook(new Book(1, "Java", "James", 20.99));
    cout<<"____Book Info____"<<endl;
    cout<<"Book ID: "<<lib.getBook()->getBookID()<<endl;
    cout<<"Book Title: "<<lib.getBook()->getTitle()<<endl;
    cout<<"Book Author: "<<lib.getBook()->getAuthor()<<endl;
    cout<<"Book Price: "<<lib.getBook()->getPrice()<<endl;
    //Calling static function in the Book class
    cout<<"Total Books in the Library are: "<<Book::getTotalNumOfBooks()<<endl;
    
    lib.setBook(new Book(2, "Math", "Mike", 24.99));
    cout<<"____Book Info____"<<endl;
    cout<<"Book ID: "<<lib.getBook()->getBookID()<<endl;
    cout<<"Book Title: "<<lib.getBook()->getTitle()<<endl;
    cout<<"Book Author: "<<lib.getBook()->getAuthor()<<endl;
    cout<<"Book Price: "<<lib.getBook()->getPrice()<<endl;
    
    cout<<"Total Books in the Library are: "<<Book::getTotalNumOfBooks()<<endl;
    
    Student s1(2023, "Mohamed","Istanbul","Student@gmail.com", 11111);
    Users *user;
    user = & s1;
    user->display();
    
    Staff stff(3034,"Staff1","Istnabul","Staff@gmail.com", 9999);
    user = &stff;
    user->display();
    
    //Friend Function
    globalFunction(s1,stff);
    
    //Calling Overloading Function in the Student class
    cout<<"_____"<<endl;
    s1.print("Musa");
    s1.print("Musa",5555);
    //Calling default arguments in the student class
    s1.print("Yahya", "yahya@emial.com");

    return 0;
}
___________________________________________________________________________
//OUTPUT:

_____Library Management System._____

____Library Info____
Name: University Library
Address: Uskudar
____Book Info____
Book ID: 1
Book Title: Java
Book Author: James
Book Price: 20.99
Total Books in the Library are: 1
____Book Info____
Book ID: 2
Book Title: Math
Book Author: Mike
Book Price: 24.99
Total Books in the Library are: 2

_____Student Info:____ 
ID: 2023
Name: Mohamed
Address: Istanbul
Email: Student@gmail.com
Phone Number: 11111

______Staff Info:____ 
ID: 3034
Name: Staff1
Address: Istnabul
Email: Staff@gmail.com
Phone Number: 9999

Accessing Student ID: 2023
Accessing Staff ID: 3034
_____
student Name: Musa
Student Name: Musa
Student ID: 5555
Student Name: Yahya
Student Email: yahya@emial.com
Student ID: 1111
#include <iostream>

using namespace std;

class Base{
   
    public:
    virtual void output(){
        cout<<"Virtual Function"<<endl;
    }
    void display(){
        cout<<"Display Base Function"<<endl;
    }
};

class derived:public Base{
    
    public:
    void output(){
        cout<<"Function in the derived "<<endl;
    }
    void display(){
        cout<<"Display Derived Function"<<endl;
    }
};


int main() {
    
    Base *ptr;
    derived d;
    ptr = &d;
  //Run time binding, it will call output function in the drived class
    ptr->output();
  
  //Compile time binding, it will call display function in the base class.
    ptr->display();

    return 0;
}
//OUTPUT:
Function in the derived 
Display Base Function
question 1.

#include <iostream>

using namespace std;
//Abstract class becuase it contain ppure virtual function
class Vehicle{
    
    public:
   virtual void drive() = 0;
};

class Car: public Vehicle{
    public:
    void drive(){
        cout<<"Driving a car "<<endl;
    }
};

class Motorcycle: public Vehicle{
    public:
    void drive(){
        cout<<"Driving a motorcycle"<<endl;
    }
};


int main() {
    //Abstract class can not be instantiated. but you can write as pointer and 
    Vehicle *obj;
   Car c;
   obj = &c;
   obj->drive();
   Motorcycle m;
   obj = &m;
   obj->drive();

    return 0;
}
//OUTPUT:
Driving a car 
Driving a motorcycle
____________________________________________________________

Question 2:
#include <iostream>

using namespace std;

class Shape{
    
    public:
   double Area(){
       return 0.0;
   }
   
};

class Rectangle: public Shape{
    double width;
    double length;
    public:
    Rectangle(double width, double length){
        this->width = 10;
        this->length = 10;
    }
    double Area(){
        //int area = width * length;
        return width * length;
        //cout<<"Area of Rectangle = "<<area<<endl;
    }
    
};

class Triangle: public Shape{
    double base;
    double heigth;
    public:
    Triangle(double b, double h):base(b),heigth(h){
        
    }
    double Area(){
        return 0.5 * base * heigth;
    }
};

int main() {
    Shape *shape;
    Rectangle rect(10, 10);
    shape = &rect;
    shape->Area();
   
    

    return 0;
}

________________________________________________________________-
  Question 3.
#include <iostream>

using namespace std;

class Animal{
    
    protected:
    string name;
    public:
    Animal(string name){
        this->name = name;
    }
    virtual void makeSound(){
        cout<<"Animal: "<<endl;
    }
   
};

class Dog: public Animal{
    string breed;
    public:
    Dog(string name, string breed):Animal(name){
        this->breed = breed;
    }
    void makeSound(){
        //Animal::makeSound(); to call makeSound function in Animal class
        cout<<"Dog makes Sound."<<endl;
    }
    void display(){
        cout<<"Dog Name: "<<name<<endl;
        cout<<"Dog Breed: "<<breed<<endl;
    }
};

class Cat: public Animal{
    string color;
    
    public:
    Cat(string name, string color):Animal(name){
        this->color = color;
    }
    void makeSound(){
        cout<<"Cat makes Sound."<<endl;
    }
    void display(){
        cout<<"Cat Name: "<<name<<endl;
        cout<<"Cat Color "<<color<<endl;
    }
};

int main() {
    
    
    Dog d("Doggy","Male");
    d.display();
    d.makeSound();
    cout<<endl;
    Cat c("Catty","Brown");
    c.display();
    c.makeSound();
   
    

    return 0;
}
//OUTPUT:
Dog Name: Doggy
Dog Breed: Male
Dog makes Sound.

Cat Name: Catty
Cat Color Brown
Cat makes Sound.
#include <iostream>

using namespace std;
//PUre Virtual Function
class Employee{
    int code;
    string name[20];
    public:
    virtual void getData();
    virtual void Display();
};
class Grade : public Employee{
    char grade[20];
    float salary;
    
    public:
    void getData();
    void Display();
};

void Employee::getData(){
    
}
void Employee::Display(){
    
}
void Grade::getData(){
    cout<<"Enter Employee Grade: "<<endl;
    cin>>grade;
    cout<<"Enter Employee Salaray: "<<endl;
    cin>>salary;
}
void Grade::Display(){
    cout<<"Employee Grade is: "<<grade<<endl;
    cout<<"Employee Salaray is: "<<salary<<endl;
}

int main() {
    Employee *ptr;
    Grade obj;
    ptr = &obj;
    ptr->getData();
    ptr->Display();

    return 0;
}
//OUTPUT:
Enter Employee Grade: 
A
Enter Employee Salaray: 
24000
Employee Grade is: A
Employee Salaray is: 24000
#include <iostream>

using namespace std;
//Hierarchical inheritance
class Employee{
    
    protected:
    string name;
    int employeeID;
    
    public:
    
    void inputEmployeeInfo(){
        cout<<"Enter name: "<<endl;
        cin>>name;
        cout<<"Enter Employee ID: "<<endl;
        cin>>employeeID;
    }
    void displayEmployeeInfo(){
        cout<<"Name: "<<name<<endl;
        cout<<"Employee ID: "<<employeeID<<endl;
    }
};
//Derived Manager Class From Employee Class

class Manager :virtual public Employee{
    protected:
    int level;
    public:
    void inputManagerInfo(){
        //inputEmployeeInfo();
        cout<<"Enter Manager Level: "<<endl;
        cin>>level;
    }
    void displayManagerInfo(){
        //displayEmployeeInfo();
        cout<<"Manager Level: "<<level<<endl;
    }
};
//Derived Developer Class From Employee
class Developer : virtual public Employee{
    protected:
    int progLang;
    public:
    void inputDeveloperInfo(){
        //inputEmployeeInfo();
        cout<<"Enter Programing Language: "<<endl;
        cin>>progLang;
    }
    void displayDeveloperInfo(){
        //displayEmployeeInfo();
        cout<<"Programing Language: "<<progLang<<endl;
    }
};
//DErived class for Teamlead That will display both info manager and developer
class TeamLead : public Manager, public Developer{
    
    public:
    
    void inputInfo(){
        inputEmployeeInfo();   // Employee Info
        inputManagerInfo();    // Manager Info
        inputDeveloperInfo();   //Developer Info
    }

    void displayInfo(){
        cout<<"Team Lead Details: "<<endl;
        displayEmployeeInfo(); // Employee Info
        displayManagerInfo();  // Manager Info
        displayDeveloperInfo();  //Developer Info
    }
};

int main() {
    
    TeamLead tl;
    tl.inputInfo();
    cout<<endl;
    tl.displayInfo();
    
   

    return 0;
}

//OUTPUT:
Enter name: 
mohamed
Enter Employee ID: 
1222
Enter Manager Level: 
7
Enter Programing Language: 
java

Team Lead Details: 
Name: mohamed
Employee ID: 1222
Manager Level: 7
Programing Language: java
#include <iostream>

using namespace std;
//Hierarchical inheritance
class Shape{
    
    public:
    double area(){
    return 0.0;
    }
    
    void displayShape(){
        cout<<"Generic Shape: ";
    }
};
//Derived REctangle Class From Shape Class
class Rectangle:public Shape{
    double width;
    double length;
    
    public:
    //You can write like this also:
    Rectangle(double w, double l){
        width = w;
        length = l;
    }
    //Both of them are same
    //Rectangle(double w, double l):width(w),length(l){
        
    //}
    double AreaRectangle(){
        return width * length;
    }
    void displayRectangleInfo(){
        displayShape();
        cout<<"Rectangle: \nLength = "<<length<<"\nwidth = "<<width<<"\nArea of Rectangle = "<<AreaRectangle()<<endl;
    }
};
//Second Derived Circle class from Shape class
class Circle:public Shape{
    
    double radius;
    
    public:
    Circle(double r):radius(r){
        
    }
    double AreaCircle(){
        return 3.14 * radius * radius;
    }
    void displayCircleInfo(){
        displayShape();
        cout<<"Circle: \nRadius = "<<radius<<"\nArea of Circle = "<<AreaCircle()<<endl;
    }
};
//Third Derived class from Shape
class Triangle:public Shape {
    
    double base;
    double heigth;
    
    public:
    Triangle(double b, double h):base(b),heigth(h){
        
    }
    double AreaTriangle(){
        return 0.5 * base * heigth;
    }
    void displayTriangleInfo(){
        displayShape();
        cout<<"Triangle: \nBase = "<<base<<"\nHeigth = "<<heigth<<"\nArea of Triangle = "<<AreaTriangle()<<endl;
    }
};

int main() {
    Rectangle rect(10.2, 20.2);
    rect.displayRectangleInfo();
    cout<<endl;
    Circle c(10);
    c.displayCircleInfo();
    cout<<endl;
    Triangle tri(10.2, 10.1);
    tri.displayTriangleInfo();

    return 0;
}
//OUTPUT:
Generic Shape: Rectangle: 
Length = 20.2
width = 10.2
Area of Rectangle = 206.04

Generic Shape: Circle: 
Radius = 10
Area of Circle = 314

Generic Shape: Triangle: 
Base = 10.2
Heigth = 10.1
Area of Triangle = 51.51
Question 1.
#include <iostream>

using namespace std;

class course
{
	protected:
		int course_code;
		string course_name;
		course(int cc, string cn)
		{
			course_code = cc;
			course_name = cn;
			
		}
		void displayCourseInfo()
		{
			cout<<"Course code: "<<course_code<<endl;
			cout<<"Course name: "<<course_name<<endl;
		}
};
class studentCourse:public course
{
	public:
	int id;
	string grade;
	studentCourse(int cc, string cn, int ID, string Grade):course(cc, cn)
	{
		id = ID;
		grade = Grade;
		
	}
	void displayStudentInfo()
	{
		displayCourseInfo();
		cout<<"ID: "<<id<<endl;
		cout<<"Grade: "<<grade<<endl;
	}
};
int main()
{
	studentCourse s1(202,"OOP II", 20021212, "A");
	s1.displayStudentInfo();
	
	cout<<endl;
	studentCourse s2(201, "Software Design", 210209327, "A");
	s2.displayStudentInfo();
	return 0;
}
//OUTPUT:
Course code: 202
Course name: OOP II
ID: 20021212
Grade: A

Course code: 201
Course name: Software Design
ID: 210209327
Grade: A

Question 2.
#include <iostream>
#include <string>
using namespace std;

class Vehicle
{
	public: 
	int max_speed;
	int num_wheels;
	Vehicle(int speed, int wheels)
	{
		max_speed = speed;
		num_wheels = wheels;
	}
	void vehicle_info()
	{
		
		cout<<"Vehicle Max Speed: "<<max_speed<<endl;
		cout<<"Vehicle Wheels: "<<num_wheels<<endl;

	}
};
class Car:public Vehicle
{
	public: 
	string car_name;
	string car_model;
	Car(int speed, int wheels, string cname, string cmodel): Vehicle(speed, wheels)
	{
		car_name = cname;
		car_model = cmodel;
	}
	void car_info()
	{
		vehicle_info();
		cout<<"Car Name: "<<car_name<<endl;
		cout<<"Car Model: "<<car_model<<endl;
	}
};

class Motorcycle:public Vehicle
{
	public: 
	string mcar_name;
	string mcar_model;
	Motorcycle(int speed, int wheels, string mcname, string mcmodel): Vehicle(speed, wheels)
	{
		mcar_name = mcname;
		mcar_model = mcmodel;
	}
	void Motorcycle_info()
	{
		vehicle_info();
		cout<<"Motorcycle Name: "<<mcar_name<<endl;
		cout<<"Motorcycle Model: "<<mcar_model<<endl;
	}
};
class ConvertibleCar: public Car, public Motorcycle
{
	public: 

	ConvertibleCar(int speed, int wheels, string cname, string cmodel, string mcname, string mcmodel): 
	Car(speed, wheels, cname, cmodel), Motorcycle(speed, wheels, mcname, mcmodel)
	{}
	void ConvertibleCar_info()
	{
		car_info();
		cout<<endl;
		Motorcycle_info();
	}
}; 
int main()
{
	Car car(200, 4, "Honda", "Sedan");
    Motorcycle bike(180, 2, "Vespa", "Sport");
    ConvertibleCar convertible(220, 4, "Convertible Car", "Sport Car", "Convertible Motocycle", "Vespa");

    cout << "Car Information:" << endl;
    car.car_info();
    cout << endl;

    cout << "Motorcycle Information:" << endl;
    bike.Motorcycle_info();
    cout << endl;

    cout << "Convertible Car Information:" << endl;
    convertible.ConvertibleCar_info();


	return 0;
}
//OUTPUT:
Car Information:
Vehicle Max Speed: 200
Vehicle Wheels: 4
Car Name: Honda
Car Model: Sedan

Motorcycle Information:
Vehicle Max Speed: 180
Vehicle Wheels: 2
Motorcycle Name: Vespa
Motorcycle Model: Sport

Convertible Car Information:
Vehicle Max Speed: 220
Vehicle Wheels: 4
Car Name: Convertible Car
Car Model: Sport Car

Vehicle Max Speed: 220
Vehicle Wheels: 4
Motorcycle Name: Convertible Motocycle
Motorcycle Model: Vespa
#include <iostream>

using namespace std;

class Father{
    int age;
    char name[10];
    
    public:
    void get();
    void show();
    
};
void Father::get(){
    cout<<"Father Name Please: "<<endl;
    cin>>name;
    cout<<"Father Age Please: "<<endl;
    cin>>age;
}
void Father::show(){
    cout<<"Father name is: "<<name<<endl;
    cout<<"Father Age is: "<<age<<endl;
}

class doughter: public Father{
    int age;
    char name[10];
    
    public:
    void get();
    void show();
 
};
void doughter::get(){
    Father::get();
    cout<<"doughter name Please: "<<endl;
    cin>>name;
    cout<<"doughter Age Please: "<<endl;
    cin>>age;
}
void doughter::show(){
    Father::show();
    cout<<"doughter Name is: "<<name<<endl;
    cout<<"doughter Age is: "<<age<<endl;
}

class Son: public Father{
    int age;
    char name[10];
    
    public:
    void get();
    void show();
};

void Son::get(){
    Father::get();
    cout<<"Son name Please: "<<endl;
    cin>>name;
    cout<<"Son Age Please: "<<endl;
    cin>>age;
    
}
void Son::show(){
    Father::show();
    cout<<"Son name is: "<<name<<endl;
    cout<<"Son Age is: "<<age<<endl;
}

int main() {
    
   Son s1;
   doughter d1;
   s1.get();
   d1.get();
   s1.show();
   d1.show();
   
    return 0;
} 
//OUTPUT:
Father Name Please: 
ABdi
Father Age Please: 
56
Son name Please: 
moha
Son Age Please: 
23
Father Name Please: 
Abdi
Father Age Please: 
56
doughter name Please: 
aisha
doughter Age Please: 
21
Father name is: ABdi
Father Age is: 56
Son name is: moha
Son Age is: 23
Father name is: Abdi
Father Age is: 56
doughter Name is: aisha
doughter Age is: 21
#include <iostream>

using namespace std;

class Father{
    int age;
    char name[10];
    
    public:
    void get();
    void show();
    
};
void Father::get(){
    cout<<"Father Name Please: "<<endl;
    cin>>name;
    cout<<"Father Age Please: "<<endl;
    cin>>age;
}
void Father::show(){
    cout<<"Father name is: "<<name<<endl;
    cout<<"Father Age is: "<<age<<endl;
}

class Mother{
    int age;
    char name[10];
    
    public:
    void get();
    void show();
 
};
void Mother::get(){
    cout<<"Mother name Please: "<<endl;
    cin>>name;
    cout<<"Mother Age Please: "<<endl;
    cin>>age;
}
void Mother::show(){
    cout<<"Mother Name is: "<<name<<endl;
    cout<<"Mother Age is: "<<age<<endl;
    
}

class Son: public Father, public Mother{
    int age;
    char name[10];
    
    public:
    void get();
    void show();
};

void Son::get(){
    Father::get();
    Mother::get();
    cout<<"Son name Please: "<<endl;
    cin>>name;
    cout<<"Son Age Please: "<<endl;
    cin>>age;
    
}
void Son::show(){
    Father::show();
    Mother::show();
    cout<<"Son name is: "<<name<<endl;
    cout<<"Son Age is: "<<age<<endl;
}

int main() {
    
   Son s;
   s.get();
   s.show();
   
    return 0;
}
//OUTPUT:
Father Name Please: 
Abdi
Father Age Please: 
54
Mother name Please: 
Qamar
Mother Age Please: 
37
Son name Please: 
Moahmed
Son Age Please: 
23
Father name is: Abdi
Father Age is: 54
Mother Name is: Qamar
Mother Age is: 37
Son name is: Moahmed
Son Age is: 23
#include <iostream>

using namespace std;

class worker{
    int age;
    char name[10];
    
    public:
    void get();
    void show();
    
};
void worker::get(){
    cout<<"Your Name Please: "<<endl;
    cin>>name;
    cout<<"Your Age Please: "<<endl;
    cin>>age;
}
void worker::show(){
    cout<<"My name is: "<<name<<endl;
    cout<<"My Age is: "<<age<<endl;
}

class manager:public worker{
    int now;
    
    public:
    void get();
    void show();
 
};
void manager::get(){
    worker::get();
    cout<<"Num of workers are: "<<endl;
    cin>>now;
}
void manager::show(){
    worker::show();
    cout<<"Num of workers are: "<<now<<endl;
}

class ceo: public manager{
    int nom;
    
    public:
    void get();
    void show();
    void print();
};

void ceo::get(){
    manager::get();
    cout<<"Num of managers are: "<<endl;
    cin>>nom;
}
void ceo::show(){
    manager::show();
    cout<<"Num of managers are: "<<nom<<endl;
}

int main() {
    
    worker w1;
    manager m1;
    ceo c1;
    c1.get();
    c1.show();
 

    return 0;
}
//OUTPUT:

Your Name Please: 
moha
Your Age Please: 
45
Num of workers are: 
787
Num of managers are: 
897
My name is: moha
My Age is: 45
Num of workers are: 787
Num of managers are: 897
#include <iostream>

using namespace std;

class worker{
    int age;
    char name[10];
    
    public:
    void get();
    void show();
    
};
void worker::get(){
    cout<<"Your Name Please: "<<endl;
    cin>>name;
    cout<<"Your Age Please: "<<endl;
    cin>>age;
}
void worker::show(){
    cout<<"My name is: "<<name<<endl;
    cout<<"My Age is: "<<age<<endl;
}

class manager: public worker{
    int now;
    
    public:
    void get();
    void show();
 
};
void manager::get(){
    worker::get();
    cout<<"Num of workers are: "<<endl;
    cin>>now;
}
void manager::show(){
    worker::show();
    cout<<"Num of workers are: "<<now<<endl;
}

int main() {
    
    worker w1;
    manager m1;
    m1.get();
    m1.show();
   

    return 0;
}

//Output:
Your Name Please: 
moha
Your Age Please: 
34
Num of workers are: 
67
My name is: moha
My Age is: 34
Num of workers are: 67
void ComponentGraphics::UpdateBackground(GLFWwindow* window, Shader shader, ComponentCamera* camera, glm::vec3 difference)
{
    if (camera->getlockParallax() == false)
    {
        if (difference[0] > 0.0001f) //right
        {
            posX -= backgroundSpeed;
        }
        if (difference[0] < -0.0001f) //left
        {
           posX += backgroundSpeed;
        }
    }
    //96.0f / 50.0f, 84.0f / 50.0f
    float CurrentCameraX = camera->getCameraPosition().x;
    UpdateGraphics(0.0001, window, shader, camera, ConvertTo4x4Affine(AffineScaleMatrix(96.0f / 50.0f, 84.0f / 50.0f) * AffineTranslationMatrix(posX, posY)), "NoCamX");
}

void ComponentGraphics::setBackgroundSpeedFromFile(Stream stream)
{
    backgroundSpeed = StreamReadFloat(stream);
}

void ComponentGraphics::setBackgroundSpeed(float speed)
{
   backgroundSpeed = speed;
}

void ComponentGraphics::setPosFromFile(Stream stream)
{
    posX = StreamReadFloat(stream);
    posY = StreamReadFloat(stream);
}
//------------------------------------------------------------------------------
/*!
\file	ComponentCamera.cpp
\main author: Mary (m.khuu) Camera movement : Riti 
\par	Copyright © 2021 DigiPen (USA) Corporation.
\brief
\reference http://www.opengl-tutorial.org/beginners-tutorials/tutorial-6-keyboard-and-mouse/
*/
//------------------------------------------------------------------------------
#pragma once

//------------------------------------------------------------------------------
// Includes:
//------------------------------------------------------------------------------
#include "ComponentCamera.h"

ComponentCamera::ComponentCamera(void)
{
	ModelMatrix = mat4(0.0f);
	ViewMatrix = mat4(1.0f);
	ProjectionMatrix = mat4(0.0f);
	MVPmatrix = mat4(0.0f);

	position = glm::vec3(0.0f, 0.0f, 1.0f);

	cameraBoundariesMax = glm::vec3(0.0f, 0.0f, 1.0f);
	cameraBoundariesMin = glm::vec3(0.0f, 0.0f, 1.0f);
	cameraSize = glm::vec3(0.0f, 0.0f, 1.0f);
	cameraSpeed = glm::vec3(0.45f, 0.35f, 0.0f);

	horizontalAngle = 3.14f;
	verticalAngle = 0.0f;

	lockParallax = 0;

	lastTime = 0;
}

glm::mat4 ComponentCamera::cameraInput(GLFWwindow* window)
{
	double currentTime = glfwGetTime();
	float deltaTime = float(currentTime - lastTime);

	// Direction : Spherical coordinates to Cartesian coordinates conversion
	glm::vec3 direction(
		cos(verticalAngle) * sin(horizontalAngle),
		sin(verticalAngle),
		cos(verticalAngle) * cos(horizontalAngle)
	);

	// Right vector
	glm::vec3 right = glm::vec3(
		sin(horizontalAngle - 3.14f / 2.0f),
		0,
		cos(horizontalAngle - 3.14f / 2.0f)
	);

	// Up vector
	glm::vec3 up = glm::cross(right, direction);


	//vertical movements currently move diagonally
	if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS)
	{
		position += deltaTime * cameraSpeed[1];
		position -= right * deltaTime * cameraSpeed[1];
	}
	if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS)
	{
		position -= deltaTime * cameraSpeed[1];
		position += right * deltaTime * cameraSpeed[1];
	}

	if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS)
	{
		position += right * deltaTime * cameraSpeed[0];
	}
	if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS)
	{
		position -= right * deltaTime * cameraSpeed[0];
	}

	ProjectionMatrix = glm::ortho((-cameraSize.x / 2), (cameraSize.x / 2), -(cameraSize.y / 2), (cameraSize.y / 2), 0.0f, 100.0f);

	ViewMatrix = glm::lookAt(position, position + direction, up);
	ModelMatrix = glm::mat4(1.0f);

	lastTime = currentTime;
	MVPmatrix = (ProjectionMatrix * ViewMatrix * ModelMatrix);
	return MVPmatrix; //returns MVP matrix
}

glm::mat4 ComponentCamera::tieCameraToPlayer(GLFWwindow* window, glm::vec3 playerPos)
{
	setlockParallax(false);
	glm::vec3 direction(
		cos(verticalAngle) * sin(horizontalAngle),
		sin(verticalAngle),
		cos(verticalAngle) * cos(horizontalAngle)
	);

	glm::vec3 right = glm::vec3(
		sin(horizontalAngle - 3.14f / 2.0f),
		0,
		cos(horizontalAngle - 3.14f / 2.0f)
	);

	glm::vec3 up = glm::cross(right, direction);

	ProjectionMatrix = glm::ortho((-cameraSize.x / 2), (cameraSize.x / 2), -(cameraSize.y / 2), (cameraSize.y / 2), 0.0f, 100.0f);

	vec3 CamPos = getCameraPosition();
	CamPos.x = playerPos.x;
	CamPos.y = playerPos.y;

	if (CamPos.x  - (cameraSize.x / 2) < cameraBoundariesMin[0])
	{
		CamPos.x = cameraBoundariesMin[0] + (cameraSize.x / 2);
	}
	if (CamPos.x + (cameraSize.x / 2) > cameraBoundariesMax[0])
	{
		CamPos.x = cameraBoundariesMax[0] -(cameraSize.x / 2);
	}
	if (CamPos.y < cameraBoundariesMin[1])
	{
		CamPos.y = cameraBoundariesMin[1];
	}


	//uncommented to always lock the center of camera to player
	//when player goes up
	
	if (CamPos.y > cameraBoundariesMax[1])
	{
		CamPos.y = cameraBoundariesMax[1];
	}


	setCameraPosition(CamPos);
	ViewMatrix = glm::lookAt(position, position + direction, up);

	ModelMatrix = glm::mat4(1.0f);

	MVPmatrix = (ProjectionMatrix * ViewMatrix * ModelMatrix);
	return MVPmatrix; //returns MVP matrix
}

void ComponentCamera::UpdateCamera(GLFWwindow* window, Shader shader, glm::vec3 position)
{
	shader.use();
	if (position != glm::vec3(0))
	{
		GLuint MatrixID = glGetUniformLocation(shader.ID, "transformation");
		//glm::matddddd4 MVP = cameraInput(window);
		glm::mat4 MVP = tieCameraToPlayer(window, position);
		glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
	}
}

glm::mat4 ComponentCamera::getModelMatrix()
{
	return ModelMatrix;
}

glm::mat4 ComponentCamera::getViewMatrix()
{
	return ViewMatrix;
}

glm::mat4 ComponentCamera::getProjectionMatrix()
{
	return ProjectionMatrix;
}

glm::mat4 ComponentCamera::getMVPmatrix()
{
	return MVPmatrix;
}

glm::vec3 ComponentCamera::getCameraBoundariesMin()
{
	return cameraBoundariesMin;
}

glm::vec3 ComponentCamera::getCameraBoundariesMax()
{
	return cameraBoundariesMax;
}

glm::vec3 ComponentCamera::getCameraPosition()
{
	return position;
}

glm::vec3 ComponentCamera::getCameraSize()
{
	return cameraSize;
}

bool ComponentCamera::getlockParallax()
{
	return lockParallax;
}

void ComponentCamera::setCameraBoundariesMin(glm::vec3 boundaries)
{
	cameraBoundariesMin = boundaries;
}

void ComponentCamera::setCameraBoundariesMax(glm::vec3 boundaries)
{
	cameraBoundariesMax = boundaries;
}

void ComponentCamera::setCameraPosition(glm::vec3 P)
{
	position = P;
}

void ComponentCamera::setCameraSize(glm::vec3 S)
{
	cameraSize = S;
}

void ComponentCamera::setCameraSpeed(float speedX, float speedY)
{
	cameraSpeed[0] = speedX;
	cameraSpeed[1] = speedY;
}

void ComponentCamera::setCameraSpeedVec(glm::vec3 speed)
{
	cameraSpeed = speed;
}

void ComponentCamera::setMVPmatrix(glm::mat4 matrix)
{
	MVPmatrix = matrix;
}

void ComponentCamera::setlockParallax(bool value)
{
	lockParallax = value;
}
// ---------------------------------------------------------------------------
// Project Name		:	Nook
// File Name		:	LevelSelect.c
// Author			:	Mary Khuu
// Creation Date	:	19 Mar 2021
// Purpose			:	Level Select
//
// All content © 2021 DigiPen (USA) Corporation, all rights reserved.
// ---------------------------------------------------------------------------

#include "framework.h"
#include "AEEngine.h"
#include "Audio.h"
#include "GameStateManager.h"
#include "Sprite.h"
#include "object_data.h"

#include "LevelSelect.h"

//------------------------------------------------------------------------------
// Private Constants:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Private Structures:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Public Variables:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Private Variables:
//------------------------------------------------------------------------------

static vec2 backgroundSize = { 1670.0f, 564.0f };
static vec2 buttonSize = { 100.0f, 30.0f };
static vec2 textSize = { 150.0f, 50.0f };
static vec2 iconSize = { 30.0f, 30.0f };
static vec2 menuPos = { 0.0f, 200.0f };
static vec2 tutorialPos = { 0.0f, 100.0f };
static vec2 level1Pos = { 0.0f, 0.0f };
static vec2 level2Pos = { 0.0f, -100.0f };
static vec2 level3Pos = { 0.0f, -200.0f };

static signed long mouseX, mouseY;
static float mouseInWorldX, mouseInWorldY;

static AEGfxVertexList* bgMesh;
static AEGfxVertexList* buttonMesh;
static AEGfxVertexList* fontMesh;
static AEGfxVertexList* iconMesh;
static AEGfxVertexList* numMesh;

static AEGfxTexture* bgTexture;
static AEGfxTexture* buttonTexture;
static AEGfxTexture* fontTexture;
static AEGfxTexture* iconTexture;
static AEGfxTexture* numTexture;

static TextureOffset numOffsets[10];
static TextureOffset fontOffsets[30];
static int* currentfontOffset = 0;
static int currfontFrame = 0;
static float* fontTime;

//------------------------------------------------------------------------------
// Private Function Declarations:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Public Functions:
//------------------------------------------------------------------------------

void LevelSelectLoad()
{
    /*mesh for bg*/
    AEGfxMeshStart();

    AEGfxTriAdd(
        -backgroundSize.x, -backgroundSize.y, 0xFF00FF00, 0.0f, 1.0f,
        backgroundSize.x, -backgroundSize.y, 0xFF00FF00, 1.0f, 1.0f,
        -backgroundSize.x, backgroundSize.y, 0xFF00FF00, 0.0f, 0.0f);

    AEGfxTriAdd(
        backgroundSize.x, -backgroundSize.y, 0xFF00FF00, 1.0f, 1.0f,
        backgroundSize.x, backgroundSize.y, 0xFF00FF00, 1.0f, 0.0f,
        -backgroundSize.x, backgroundSize.y, 0xFF00FF00, 0.0f, 0.0f);

    bgMesh = AEGfxMeshEnd();
    AE_ASSERT_MESG(bgMesh, "Failed to create button!");

    bgTexture = AEGfxTextureLoad("Assets/CityscapeGrey.png");
    AE_ASSERT_MESG(bgTexture, "Failed to create pTex!!");

    /*mesh for buttons: green*/
    AEGfxMeshStart();

    AEGfxTriAdd(
        -buttonSize.x, -buttonSize.y, 0xFF00FF00, 0.0f, 1.0f,
        buttonSize.x, -buttonSize.y, 0xFF00FF00, 1.0f, 1.0f,
        -buttonSize.x, buttonSize.y, 0xFF00FF00, 0.0f, 0.0f);

    AEGfxTriAdd(
        buttonSize.x, -buttonSize.y, 0xFF00FF00, 1.0f, 1.0f,
        buttonSize.x, buttonSize.y, 0xFF00FF00, 1.0f, 0.0f,
        -buttonSize.x, buttonSize.y, 0xFF00FF00, 0.0f, 0.0f);

    buttonMesh = AEGfxMeshEnd();
    AE_ASSERT_MESG(buttonMesh, "Failed to create button!");

    buttonTexture = AEGfxTextureLoad("Assets/NookButtonBright.png");
    AE_ASSERT_MESG(buttonTexture, "Failed to create texture!");

    /*mesh for hover icon*/
    iconMesh = createQuadMesh(iconSize.x, iconSize.y, 1.0f, 1.0f, "yarn");

    iconTexture = AEGfxTextureLoad("Assets/TempHover.png");
    AE_ASSERT_MESG(iconTexture, "Failed to create texture!");

    /*mesh for text*/
    fontMesh = createQuadMesh(15.0f, 15.0f, 1.0 / 5, 1.0f / 6, "alphabets");

    fontTexture = AEGfxTextureLoad("Assets/NookFontSheet_alphabet.png");
    AE_ASSERT_MESG(fontTexture, "Failed to create texture!");    

    fontOffsets[0].mX = 0.0f;			    fontOffsets[0].mY = 0.0f / 6;  //A
    fontOffsets[1].mX = 1.0f / 5;		    fontOffsets[1].mY = 0.0f / 6;  //B
    fontOffsets[2].mX = 2.0f / 5;			fontOffsets[2].mY = 0.0f / 6;  //C
    fontOffsets[3].mX = 3.0f / 5;			fontOffsets[3].mY = 0.0f / 6;  //D
    fontOffsets[4].mX = 4.0f / 5;			fontOffsets[4].mY = 0.0f / 6;  //E

    fontOffsets[5].mX = 0.0f;			    fontOffsets[5].mY = 1.0f / 6;  //F
    fontOffsets[6].mX = 1.0f / 5;		    fontOffsets[6].mY = 1.0f / 6;  //G
    fontOffsets[7].mX = 2.0f / 5;			fontOffsets[7].mY = 1.0f / 6;  //H
    fontOffsets[8].mX = 3.0f / 5;			fontOffsets[8].mY = 1.0f / 6;  //I
    fontOffsets[9].mX = 4.0f / 5;			fontOffsets[9].mY = 1.0f / 6;  //J

    fontOffsets[10].mX = 0.0f;			    fontOffsets[10].mY = 2.0f / 6;  //K
    fontOffsets[11].mX = 1.0f / 5;		    fontOffsets[11].mY = 2.0f / 6;  //L
    fontOffsets[12].mX = 2.0f / 5;			fontOffsets[12].mY = 2.0f / 6;  //M
    fontOffsets[13].mX = 3.0f / 5;			fontOffsets[13].mY = 2.0f / 6;  //N
    fontOffsets[14].mX = 4.0f / 5;			fontOffsets[14].mY = 2.0f / 6;  //O

    fontOffsets[15].mX = 0.0f;			    fontOffsets[15].mY = 3.0f / 6;  //P
    fontOffsets[16].mX = 1.0f / 5;		    fontOffsets[16].mY = 3.0f / 6;  //Q
    fontOffsets[17].mX = 2.0f / 5;			fontOffsets[17].mY = 3.0f / 6;  //R
    fontOffsets[18].mX = 3.0f / 5;			fontOffsets[18].mY = 3.0f / 6;  //S
    fontOffsets[19].mX = 4.0f / 5;			fontOffsets[19].mY = 3.0f / 6;  //T

    fontOffsets[20].mX = 0.0f;			    fontOffsets[20].mY = 4.0f / 6;  //U
    fontOffsets[21].mX = 1.0f / 5;		    fontOffsets[21].mY = 4.0f / 6;  //V
    fontOffsets[22].mX = 2.0f / 5;			fontOffsets[22].mY = 4.0f / 6;  //W
    fontOffsets[23].mX = 3.0f / 5;			fontOffsets[23].mY = 4.0f / 6;  //X
    fontOffsets[24].mX = 4.0f / 5;			fontOffsets[24].mY = 4.0f / 6;  //Y


    fontOffsets[25].mX = 0.0f;			    fontOffsets[25].mY = 5.0f / 6;   //Z  
    fontOffsets[26].mX = 1.0f / 5;		    fontOffsets[26].mY = 5.0f / 6;  //blank (1)
    fontOffsets[27].mX = 2.0f / 5;			fontOffsets[27].mY = 5.0f / 6;  //blank (2)
    fontOffsets[28].mX = 3.0f / 5;			fontOffsets[28].mY = 5.0f / 6;  //blank (3)
    fontOffsets[29].mX = 4.0f / 5;			fontOffsets[29].mY = 5.0f / 6;  //blank (4)

    /*mesh for numbers*/
    numMesh = createQuadMesh(15.0f, 15.0f, 1.0 / 3, 1.0f / 4, "numbers");

    numTexture = AEGfxTextureLoad("Assets/NookFontSheet_numbers.png");
    AE_ASSERT_MESG(numTexture, "Failed to create texture!");

    numOffsets[0].mX = 0.0f;			    numOffsets[0].mY = 0.0f / 4;  //0
    numOffsets[1].mX = 1.0f / 3;		    numOffsets[1].mY = 0.0f / 4;  //1
    numOffsets[2].mX = 2.0f / 3;			numOffsets[2].mY = 0.0f / 4;  //2
    
    numOffsets[3].mX = 0.0f;			    numOffsets[3].mY = 1.0f / 4;  //3
    numOffsets[4].mX = 1.0f / 3;			numOffsets[4].mY = 1.0f / 4;  //4
    numOffsets[5].mX = 2.0f / 3;			numOffsets[5].mY = 1.0f / 4;  //5
    
    numOffsets[6].mX = 0.0f;		        numOffsets[6].mY = 2.0f / 4;  //6
    numOffsets[7].mX = 1.0f / 3;			numOffsets[7].mY = 2.0f / 4;  //7
    numOffsets[8].mX = 2.0f / 3;			numOffsets[8].mY = 2.0f / 4;  //8
    
    numOffsets[9].mX = 0.0f / 3;			numOffsets[9].mY = 3.0f / 4;  //9
}

void LevelSelectInit()
{
	AEGfxSetBackgroundColor(1.0f, 1.0f, 1.0f);
	AEGfxSetBlendMode(AE_GFX_BM_BLEND);
}

void LevelSelectUpdate(float dt)
{
    /* Tell the compiler that the 'dt' variable is unused. */
    UNREFERENCED_PARAMETER(dt);

    /*draw background*/
    AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
    AEGfxTextureSet(bgTexture, 0, 0);
    AEGfxSetTransparency(1.0f);
    AEGfxSetPosition(-250.0f, 0.0f);
    AEGfxMeshDraw(bgMesh, AE_GFX_MDM_TRIANGLES);

    //draw menu button
    AEGfxSetPosition(menuPos.x, menuPos.y);
    AEGfxTextureSet(buttonTexture, 0, 0); // no texture
    AEGfxMeshDraw(buttonMesh, AE_GFX_MDM_TRIANGLES);

    //draw tutorial button
    AEGfxSetPosition(tutorialPos.x, tutorialPos.y);
    AEGfxTextureSet(buttonTexture, 0, 0); // no texture
    AEGfxMeshDraw(buttonMesh, AE_GFX_MDM_TRIANGLES);
    

    //draw level1 button
    AEGfxSetPosition(level1Pos.x, level1Pos.y);
    AEGfxTextureSet(buttonTexture, 0, 0); // no texture
    AEGfxMeshDraw(buttonMesh, AE_GFX_MDM_TRIANGLES);

    //draw level2 button
    AEGfxSetPosition(level2Pos.x, level2Pos.y);
    AEGfxTextureSet(buttonTexture, 0, 0); // no texture
    AEGfxMeshDraw(buttonMesh, AE_GFX_MDM_TRIANGLES);

    //draw level3 button
    AEGfxSetPosition(level3Pos.x, level3Pos.y);
    AEGfxTextureSet(buttonTexture, 0, 0); // no texture
    AEGfxMeshDraw(buttonMesh, AE_GFX_MDM_TRIANGLES);

    /*MENU*/
    AEGfxSetPosition(menuPos.x - 45.0f, menuPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[12].mX, fontOffsets[12].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(menuPos.x - 13.0f, menuPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[4].mX, fontOffsets[4].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(menuPos.x + 15.0f, menuPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[13].mX, fontOffsets[13].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(menuPos.x + 45.0f, menuPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[20].mX, fontOffsets[20].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    /*MENU - end*/

    /*TUTORIAL*/
    AEGfxSetPosition(tutorialPos.x - 86.0f, tutorialPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[19].mX, fontOffsets[19].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(tutorialPos.x - 58.0f, tutorialPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[20].mX, fontOffsets[20].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(tutorialPos.x - 30.0f, tutorialPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[19].mX, fontOffsets[19].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(tutorialPos.x, tutorialPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[14].mX, fontOffsets[14].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(tutorialPos.x + 30.0f, tutorialPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[17].mX, fontOffsets[17].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(tutorialPos.x + 46.0f, tutorialPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[8].mX, fontOffsets[8].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(tutorialPos.x + 65.0f, tutorialPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[0].mX, fontOffsets[0].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(tutorialPos.x + 90.0f, tutorialPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[11].mX, fontOffsets[11].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    /*TUTORIAL - end*/

    /*LEVEL 1*/
    AEGfxSetPosition(level1Pos.x - 85.0f, level1Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[11].mX, fontOffsets[11].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level1Pos.x - 60.0f, level1Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[4].mX, fontOffsets[4].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level1Pos.x - 34.0f, level1Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[21].mX, fontOffsets[21].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level1Pos.x - 5.0f, level1Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[4].mX, fontOffsets[4].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level1Pos.x + 17.5f, level1Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[11].mX, fontOffsets[11].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level1Pos.x + 85.0f, level1Pos.y);
    AEGfxTextureSet(numTexture, numOffsets[1].mX, numOffsets[1].mY, 0.0f); // 1
    AEGfxMeshDraw(numMesh, AE_GFX_MDM_TRIANGLES);

    /*LEVEL 1 - end*/

    /*LEVEL 2*/
    AEGfxSetPosition(level2Pos.x - 85.0f, level2Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[11].mX, fontOffsets[11].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level2Pos.x - 60.0f, level2Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[4].mX, fontOffsets[4].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level2Pos.x - 34.0f, level2Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[21].mX, fontOffsets[21].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level2Pos.x - 5.0f, level2Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[4].mX, fontOffsets[4].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level2Pos.x + 17.5f, level2Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[11].mX, fontOffsets[11].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level2Pos.x + 85.0f, level2Pos.y);
    AEGfxTextureSet(numTexture, numOffsets[2].mX, numOffsets[2].mY, 0.0f); // 2
    AEGfxMeshDraw(numMesh, AE_GFX_MDM_TRIANGLES);

    /*LEVEL 2 - end*/

    /*LEVEL 3*/
    AEGfxSetPosition(level3Pos.x - 85.0f, level3Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[11].mX, fontOffsets[11].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level3Pos.x - 60.0f, level3Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[4].mX, fontOffsets[4].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level3Pos.x - 34.0f, level3Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[21].mX, fontOffsets[21].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level3Pos.x - 5.0f, level3Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[4].mX, fontOffsets[4].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level3Pos.x + 17.5f, level3Pos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[11].mX, fontOffsets[11].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(level3Pos.x + 85.0f, level3Pos.y);
    AEGfxTextureSet(numTexture, numOffsets[3].mX, numOffsets[3].mY, 0.0f); // 3
    AEGfxMeshDraw(numMesh, AE_GFX_MDM_TRIANGLES);

    /*LEVEL 3 - end*/

    /*get the mouse position*/
    AEInputGetCursorPosition(&mouseX, &mouseY);
    AEGfxConvertScreenCoordinatesToWorld(mouseX, mouseY, &mouseInWorldX, &mouseInWorldY);

    /*if menu is hovered*/
    if ((mouseInWorldX > (menuPos.x - buttonSize.x) && mouseInWorldX < (menuPos.x + buttonSize.x)) &&
        (mouseInWorldY > (menuPos.y - buttonSize.y) && mouseInWorldY < (menuPos.y + buttonSize.y)))
    {
        // Hover texture
        AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
        AEGfxSetPosition(menuPos.x - 140.0f, menuPos.y);
        AEGfxTextureSet(iconTexture, 0.0f, 0.0f);
        AEGfxMeshDraw(iconMesh, AE_GFX_MDM_TRIANGLES);

        if (AEInputCheckTriggered(RI_MOUSE_LEFT_BUTTON_DOWN))
        {
            GameStateManagerSetNextState(Menu);
        }
    }

    /*if tutorial is hovered*/
    if ((mouseInWorldX > (tutorialPos.x - buttonSize.x) && mouseInWorldX < (tutorialPos.x + buttonSize.x)) &&
        (mouseInWorldY > (tutorialPos.y - buttonSize.y) && mouseInWorldY < (tutorialPos.y + buttonSize.y)))
    {
        // Hover texture
        AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
        AEGfxSetPosition(tutorialPos.x - 140.0f, tutorialPos.y);
        AEGfxTextureSet(iconTexture, 0.0f, 0.0f);
        AEGfxMeshDraw(iconMesh, AE_GFX_MDM_TRIANGLES);

        if (AEInputCheckTriggered(RI_MOUSE_LEFT_BUTTON_DOWN))
        {
            GameStateManagerSetNextState(Tutorial);
        }
    }

    /*if level1 is hovered*/
    if ((mouseInWorldX > (level1Pos.x - buttonSize.x) && mouseInWorldX < (level1Pos.x + buttonSize.x)) &&
        (mouseInWorldY > (level1Pos.y - buttonSize.y) && mouseInWorldY < (level1Pos.y + buttonSize.y)))
    {
        // Hover texture
        AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
        AEGfxSetPosition(level1Pos.x - 140.0f, level1Pos.y);
        AEGfxTextureSet(iconTexture, 0.0f, 0.0f);
        AEGfxMeshDraw(iconMesh, AE_GFX_MDM_TRIANGLES);

        if (AEInputCheckTriggered(RI_MOUSE_LEFT_BUTTON_DOWN))
        {
            GameStateManagerSetNextState(Demo);
        }
    }

    /*if level2 is hovered*/
    if ((mouseInWorldX > (level2Pos.x - buttonSize.x) && mouseInWorldX < (level2Pos.x + buttonSize.x)) &&
        (mouseInWorldY > (level2Pos.y - buttonSize.y) && mouseInWorldY < (level2Pos.y + buttonSize.y)))
    {
        // Hover texture
        AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
        AEGfxSetPosition(level2Pos.x - 140.0f, level2Pos.y);
        AEGfxTextureSet(iconTexture, 0.0f, 0.0f);
        AEGfxMeshDraw(iconMesh, AE_GFX_MDM_TRIANGLES);

        if (AEInputCheckTriggered(RI_MOUSE_LEFT_BUTTON_DOWN))
        {
            GameStateManagerSetNextState(Level2);
        }
    }

    /*if level3 is hovered*/
    if ((mouseInWorldX > (level3Pos.x - buttonSize.x) && mouseInWorldX < (level3Pos.x + buttonSize.x)) &&
        (mouseInWorldY > (level3Pos.y - buttonSize.y) && mouseInWorldY < (level3Pos.y + buttonSize.y)))
    {
        // Hover texture
        AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
        AEGfxSetPosition(level3Pos.x - 140.0f, level3Pos.y);
        AEGfxTextureSet(iconTexture, 0.0f, 0.0f);
        AEGfxMeshDraw(iconMesh, AE_GFX_MDM_TRIANGLES);

        if (AEInputCheckTriggered(RI_MOUSE_LEFT_BUTTON_DOWN))
        {
            GameStateManagerSetNextState(Level3);
        }
    }
}

void LevelSelectShutdown()
{
    AudioCleanup();
}

void LevelSelectUnload()
{
    // Unload all textures.
    AEGfxTextureUnload(buttonTexture);
    AEGfxTextureUnload(fontTexture);
    AEGfxTextureUnload(bgTexture);
    AEGfxTextureUnload(iconTexture);
    AEGfxTextureUnload(numTexture);

    // Free all meshes.
    AEGfxMeshFree(buttonMesh);
    AEGfxMeshFree(fontMesh);
    AEGfxMeshFree(bgMesh);
    AEGfxMeshFree(iconMesh);
    AEGfxMeshFree(numMesh);
}

//------------------------------------------------------------------------------
// Private Functions:
//------------------------------------------------------------------------------
//if the last time player moved was left
if (!AEInputCheckCurr("A") && lastPlayerDir == 1 && isWalking == 0)
{
  //flip the sprite
  AEGfxTextureSet(playerIdleTexture, 0.0f, 0.0f);
  AEGfxSetFullTransform(curr->pos.x, curr->pos.y, 0.0f, -(curr->width * tile_dim), curr->height * tile_dim);
  isWalking = 0;
}
/*get the mouse x and y position*/
AEInputGetCursorPosition(&mouseX, &mouseY);
AEGfxConvertScreenCoordinatesToWorld(mouseX, mouseY, &mouseInWorldX, &mouseInWorldY);

/*only draw line if it's the wall and left click/hold on mouse occurs*/
if ((mouseInWorldX > (wallX - xHalfSize) && mouseInWorldX < (wallX + xHalfSize)) &&
    (mouseInWorldY > (wallY - yHalfSize) && mouseInWorldY < (wallY + yHalfSize)) &&
    (AEInputCheckCurr(RI_MOUSE_LEFT_BUTTON_DOWN)))
{
  /*mesh for line, needs to be updated with loop*/
  AEGfxMeshStart();

  AEGfxVertexAdd(playerX + xHalfSize, playerY, 0xFFFF0000, 0.0f, 0.0f);
  AEGfxVertexAdd(mouseInWorldX, mouseInWorldY, 0xFFFF0000, 0.0f, 0.0f);

  meshLine = AEGfxMeshEnd();
  AE_ASSERT_MESG(meshLine, "Failed to create line!");

  /*draw line*/
  AEGfxSetRenderMode(AE_GFX_RM_COLOR);
  AEGfxSetPosition(0.0f, 0.0f);
  AEGfxMeshDraw(meshLine, AE_GFX_MDM_LINES_STRIP);
}
// ---------------------------------------------------------------------------
// Project Name		:	Nook
// File Name		:	Menu.c
// Author			:	Rey Rosario, Mary Khuu
// Creation Date	:	25 Jan 2021
// Purpose			:	Main Menu
//
// All content © 2021 DigiPen (USA) Corporation, all rights reserved.
// ---------------------------------------------------------------------------

#include "framework.h"
#include "AEEngine.h"
#include "Audio.h"
#include "GameStateManager.h"
#include "object_data.h"
#include "Sprite.h"

#include "Menu.h"

//------------------------------------------------------------------------------
// Private Constants:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Private Structures:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Public Variables:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Private Variables:
//------------------------------------------------------------------------------

static vec2 backgroundSize = { 1670.0f, 564.0f };
static vec2 buttonSize = { 100.0f, 30.0f };
static vec2 titleSize = { 150.0f, 50.0f };
static vec2 iconSize = { 30.0f, 30.0f };
static vec2 levelPos = { 0.0f, 0.0f };
static vec2 creditsPos = { 0.0f, -100.0f };
static vec2 exitPos = { 0.0f, -200.0f };
static vec2 titlePos = { 0.0f, 150.0f };

static signed long mouseX, mouseY;
static float mouseInWorldX, mouseInWorldY;

static AEGfxVertexList* buttonMesh;
static AEGfxVertexList* titleMesh;
static AEGfxVertexList* bgMesh;
static AEGfxVertexList* fontMesh;
static AEGfxVertexList* iconMesh;

static AEGfxTexture* bgTexture;
static AEGfxTexture* buttonTexture;
static AEGfxTexture* titleTexture;
static AEGfxTexture* fontTexture;
static AEGfxTexture* iconTexture;

TextureOffset titleOffsets[6];
int* currentTitleOffset = 0;
int currTitleFrame = 0;
float* titleTime;

static TextureOffset fontOffsets[30];
static int* currentfontOffset = 0;
static int currfontFrame = 0;
static float* fontTime;

static float bgMusicTimer;

//------------------------------------------------------------------------------
// Private Function Declarations:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Public Functions:
//------------------------------------------------------------------------------

void MenuLoad()
{
    /*mesh for bg*/
    AEGfxMeshStart();

    AEGfxTriAdd(
        -backgroundSize.x, -backgroundSize.y, 0xFF00FF00, 0.0f, 1.0f,
        backgroundSize.x, -backgroundSize.y, 0xFF00FF00, 1.0f, 1.0f,
        -backgroundSize.x, backgroundSize.y, 0xFF00FF00, 0.0f, 0.0f);

    AEGfxTriAdd(
        backgroundSize.x, -backgroundSize.y, 0xFF00FF00, 1.0f, 1.0f,
        backgroundSize.x, backgroundSize.y, 0xFF00FF00, 1.0f, 0.0f,
        -backgroundSize.x, backgroundSize.y, 0xFF00FF00, 0.0f, 0.0f);

    bgMesh = AEGfxMeshEnd();
    AE_ASSERT_MESG(bgMesh, "Failed to create button!");

    bgTexture = AEGfxTextureLoad("Assets/CityscapeGrey.png");
    AE_ASSERT_MESG(bgTexture, "Failed to create pTex!!");

    /*mesh for buttons: green*/
    AEGfxMeshStart();

    AEGfxTriAdd(
        -buttonSize.x, -buttonSize.y, 0xFF00FF00, 0.0f, 1.0f,
        buttonSize.x, -buttonSize.y, 0xFF00FF00, 1.0f, 1.0f,
        -buttonSize.x, buttonSize.y, 0xFF00FF00, 0.0f, 0.0f);

    AEGfxTriAdd(
        buttonSize.x, -buttonSize.y, 0xFF00FF00, 1.0f, 1.0f,
        buttonSize.x, buttonSize.y, 0xFF00FF00, 1.0f, 0.0f,
        -buttonSize.x, buttonSize.y, 0xFF00FF00, 0.0f, 0.0f);

    buttonMesh = AEGfxMeshEnd();
    AE_ASSERT_MESG(buttonMesh, "Failed to create button!");

    buttonTexture = AEGfxTextureLoad("Assets/NookButtonBright.png");
    AE_ASSERT_MESG(buttonTexture, "Failed to create texture!");

    /*mesh for text*/
    AEGfxMeshStart();

    AEGfxTriAdd(
        -titleSize.x, -titleSize.y, 0xFF00FF00, 0.0f, 1.0f / 6,
        titleSize.x, -titleSize.y, 0xFF00FF00, 1.0f, 1.0f / 6,
        -titleSize.x, titleSize.y, 0xFF00FF00, 0.0f, 0.0f);

    AEGfxTriAdd(
        titleSize.x, -titleSize.y, 0xFF00FF00, 1.0f, 1.0f / 6,
        titleSize.x, titleSize.y, 0xFF00FF00, 1.0f, 0.0f,
        -titleSize.x, titleSize.y, 0xFF00FF00, 0.0f, 0.0f);

    titleMesh = AEGfxMeshEnd();
    AE_ASSERT_MESG(titleMesh, "Failed to create button!");

    titleTexture = AEGfxTextureLoad("Assets/NookLogo.png");
    AE_ASSERT_MESG(titleTexture, "Failed to create texture!");

    titleOffsets[0].mX = 0.0f;			titleOffsets[0].mY = 0.0f;
    titleOffsets[1].mX = 0.0f;			titleOffsets[1].mY = 1.0f / 6;
    titleOffsets[2].mX = 0.0f;			titleOffsets[2].mY = 2.0f / 6;
    titleOffsets[3].mX = 0.0f;			titleOffsets[3].mY = 3.0f / 6;
    titleOffsets[4].mX = 0.0f;			titleOffsets[4].mY = 4.0f / 6;
    titleOffsets[5].mX = 0.0f;			titleOffsets[5].mY = 5.0f / 6;

    /*mesh for hover icon*/
    iconMesh = createQuadMesh(iconSize.x, iconSize.y, 1.0f, 1.0f, "yarn");
    
    iconTexture = AEGfxTextureLoad("Assets/TempHover.png");
    AE_ASSERT_MESG(iconTexture, "Failed to create texture!");

    /*mesh for text*/
    fontMesh = createQuadMesh(15.0f, 15.0f, 1.0 / 5, 1.0f / 6, "alphabets");

    fontTexture = AEGfxTextureLoad("Assets/NookFontSheet_alphabet.png");
    AE_ASSERT_MESG(fontTexture, "Failed to create texture!");
        
    fontOffsets[0].mX = 0.0f;			    fontOffsets[0].mY = 0.0f / 6;  //A
    fontOffsets[1].mX = 1.0f / 5;		    fontOffsets[1].mY = 0.0f / 6;  //B
    fontOffsets[2].mX = 2.0f / 5;			fontOffsets[2].mY = 0.0f / 6;  //C
    fontOffsets[3].mX = 3.0f / 5;			fontOffsets[3].mY = 0.0f / 6;  //D
    fontOffsets[4].mX = 4.0f / 5;			fontOffsets[4].mY = 0.0f / 6;  //E

    fontOffsets[5].mX = 0.0f;			    fontOffsets[5].mY = 1.0f / 6;  //F
    fontOffsets[6].mX = 1.0f / 5;		    fontOffsets[6].mY = 1.0f / 6;  //G
    fontOffsets[7].mX = 2.0f / 5;			fontOffsets[7].mY = 1.0f / 6;  //H
    fontOffsets[8].mX = 3.0f / 5;			fontOffsets[8].mY = 1.0f / 6;  //I
    fontOffsets[9].mX = 4.0f / 5;			fontOffsets[9].mY = 1.0f / 6;  //J

    fontOffsets[10].mX = 0.0f;			    fontOffsets[10].mY = 2.0f / 6;  //K
    fontOffsets[11].mX = 1.0f / 5;		    fontOffsets[11].mY = 2.0f / 6;  //L
    fontOffsets[12].mX = 2.0f / 5;			fontOffsets[12].mY = 2.0f / 6;  //M
    fontOffsets[13].mX = 3.0f / 5;			fontOffsets[13].mY = 2.0f / 6;  //N
    fontOffsets[14].mX = 4.0f / 5;			fontOffsets[14].mY = 2.0f / 6;  //O

    fontOffsets[15].mX = 0.0f;			    fontOffsets[15].mY = 3.0f / 6;  //P
    fontOffsets[16].mX = 1.0f / 5;		    fontOffsets[16].mY = 3.0f / 6;  //Q
    fontOffsets[17].mX = 2.0f / 5;			fontOffsets[17].mY = 3.0f / 6;  //R
    fontOffsets[18].mX = 3.0f / 5;			fontOffsets[18].mY = 3.0f / 6;  //S
    fontOffsets[19].mX = 4.0f / 5;			fontOffsets[19].mY = 3.0f / 6;  //T

    fontOffsets[20].mX = 0.0f;			    fontOffsets[20].mY = 4.0f / 6;  //U
    fontOffsets[21].mX = 1.0f / 5;		    fontOffsets[21].mY = 4.0f / 6;  //V
    fontOffsets[22].mX = 2.0f / 5;			fontOffsets[22].mY = 4.0f / 6;  //W
    fontOffsets[23].mX = 3.0f / 5;			fontOffsets[23].mY = 4.0f / 6;  //X
    fontOffsets[24].mX = 4.0f / 5;			fontOffsets[24].mY = 4.0f / 6;  //Y


    fontOffsets[25].mX = 0.0f;			    fontOffsets[25].mY = 5.0f / 6;   //Z  
    fontOffsets[26].mX = 1.0f / 5;		    fontOffsets[26].mY = 5.0f / 6;  //blank
    fontOffsets[27].mX = 2.0f / 5;			fontOffsets[27].mY = 5.0f / 6;  //blank
    fontOffsets[28].mX = 3.0f / 5;			fontOffsets[28].mY = 5.0f / 6;  //blank
    fontOffsets[29].mX = 4.0f / 5;			fontOffsets[29].mY = 5.0f / 6;  //blank
}

void MenuInit()
{
	AEGfxSetBackgroundColor(0.0f, 0.0f, 0.0f);
    AEGfxSetBlendMode(AE_GFX_BM_BLEND);

    AudioInit();
    bgMusicTimer = 1638.0f; // Roughly 27 seconds
}

void MenuUpdate(float dt)
{
	/* Tell the compiler that the 'dt' variable is unused. */
	UNREFERENCED_PARAMETER(dt);

    /*play bg music*/
    if (bgMusicTimer == 1638.0f)
    {
        playSoundAdvanced("Assets/Sounds/Level2Track.mp3", 0.1f);
    }
        
    /*reset time for bg music loop*/
    if (bgMusicTimer == 0.0f)
    {
        bgMusicTimer = 1638.0f;
    }
    else
    {
        bgMusicTimer--;
    }

    /*draw background*/
    AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
    AEGfxTextureSet(bgTexture, 0, 0);
    AEGfxSetTransparency(1.0f);
    AEGfxSetPosition(-250.0f, 0.0f);
    AEGfxMeshDraw(bgMesh, AE_GFX_MDM_TRIANGLES);
    
    //draw menu button
    AEGfxSetPosition(levelPos.x, levelPos.y);
    AEGfxTextureSet(buttonTexture, 0, 0); // no texture
    AEGfxSetTransparency(1.0f);
    AEGfxSetBlendColor(0.0f, 0.0f, 0.0, 0.0f);
    AEGfxMeshDraw(buttonMesh, AE_GFX_MDM_TRIANGLES);

    //draw replay button
    AEGfxSetPosition(creditsPos.x, creditsPos.y);
    AEGfxTextureSet(buttonTexture, 0, 0); // no texture
    AEGfxMeshDraw(buttonMesh, AE_GFX_MDM_TRIANGLES);

    //draw exit button
    AEGfxSetPosition(exitPos.x, exitPos.y);
    AEGfxTextureSet(buttonTexture, 0, 0); // no texture
    AEGfxMeshDraw(buttonMesh, AE_GFX_MDM_TRIANGLES);

    /*PLAY*/

    AEGfxSetPosition(levelPos.x - 40.0f, levelPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[15].mX, fontOffsets[15].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(levelPos.x - 15.0f, levelPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[11].mX, fontOffsets[11].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(levelPos.x + 10.0f, levelPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[0].mX, fontOffsets[0].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(levelPos.x + 35.0f, levelPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[24].mX, fontOffsets[24].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    /*PLAY - end*/

    /*CREDITS*/
    AEGfxSetPosition(creditsPos.x - 75.0f, creditsPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[2].mX, fontOffsets[2].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(creditsPos.x - 45.0f, creditsPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[17].mX, fontOffsets[17].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(creditsPos.x - 20.0f, creditsPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[4].mX, fontOffsets[4].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(creditsPos.x + 5.0f, creditsPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[3].mX, fontOffsets[3].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(creditsPos.x + 25.0f, creditsPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[8].mX, fontOffsets[8].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(creditsPos.x + 47.0f, creditsPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[19].mX, fontOffsets[19].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(creditsPos.x + 75.0f, creditsPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[18].mX, fontOffsets[18].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    /*CREDITS - end*/

    /*QUIT*/
    AEGfxSetPosition(exitPos.x - 40.0f, exitPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[16].mX, fontOffsets[16].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(exitPos.x - 7.5f, exitPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[20].mX, fontOffsets[20].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(exitPos.x + 17.5f, exitPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[8].mX, fontOffsets[8].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    AEGfxSetPosition(exitPos.x + 40.0f, exitPos.y);
    AEGfxTextureSet(fontTexture, fontOffsets[19].mX, fontOffsets[19].mY, 0.0f);
    AEGfxMeshDraw(fontMesh, AE_GFX_MDM_TRIANGLES);

    /*QUIT - end*/

    animateFrames(&currentTitleOffset, &titleTime, 0.25f, dt);
    checkEndFrames(&currentTitleOffset, 6);
    currTitleFrame = currentTitleOffset;

    /*draw player*/
    AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
    AEGfxSetPosition(titlePos.x, titlePos.y);
    AEGfxTextureSet(titleTexture, titleOffsets[currTitleFrame].mX, titleOffsets[currTitleFrame].mY);
    AEGfxSetTransparency(1.0f);
    AEGfxMeshDraw(titleMesh, AE_GFX_MDM_TRIANGLES);

    /*get the mouse position*/
    AEInputGetCursorPosition(&mouseX, &mouseY);
    AEGfxConvertScreenCoordinatesToWorld(mouseX, mouseY, &mouseInWorldX, &mouseInWorldY);

    /*if demo level is hovered*/
    if ((mouseInWorldX > (levelPos.x - buttonSize.x) && mouseInWorldX < (levelPos.x + buttonSize.x)) &&
        (mouseInWorldY > (levelPos.y - buttonSize.y) && mouseInWorldY < (levelPos.y + buttonSize.y)))
    {
        // Hover texture
        AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
        AEGfxSetPosition(levelPos.x - 140.0f, levelPos.y);
        AEGfxTextureSet(iconTexture, 0.0f, 0.0f);
        AEGfxMeshDraw(iconMesh, AE_GFX_MDM_TRIANGLES);

        if (AEInputCheckTriggered(RI_MOUSE_LEFT_BUTTON_DOWN))
        {
            GameStateManagerSetNextState(LevelSelect);
        }
    }
    /*if credits is hovered*/
    if ((mouseInWorldX > (creditsPos.x - buttonSize.x) && mouseInWorldX < (creditsPos.x + buttonSize.x)) &&
        (mouseInWorldY > (creditsPos.y - buttonSize.y) && mouseInWorldY < (creditsPos.y + buttonSize.y)))
    {
        // Hover texture
        AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
        AEGfxSetPosition(creditsPos.x - 140.0f, creditsPos.y);
        AEGfxTextureSet(iconTexture, 0.0f, 0.0f);
        AEGfxMeshDraw(iconMesh, AE_GFX_MDM_TRIANGLES);

        if (AEInputCheckTriggered(RI_MOUSE_LEFT_BUTTON_DOWN))
        {
            GameStateManagerSetNextState(Credits);
        }
    }

    /*if exit is hovered*/
    if ((mouseInWorldX > (exitPos.x - buttonSize.x) && mouseInWorldX < (exitPos.x + buttonSize.x)) &&
        (mouseInWorldY > (exitPos.y - buttonSize.y) && mouseInWorldY < (exitPos.y + buttonSize.y)))
    {
        // Hover texture
        AEGfxSetRenderMode(AE_GFX_RM_TEXTURE);
        AEGfxSetPosition(exitPos.x - 140.0f, exitPos.y);
        AEGfxTextureSet(iconTexture, 0.0f, 0.0f);
        AEGfxMeshDraw(iconMesh, AE_GFX_MDM_TRIANGLES);

        if (AEInputCheckTriggered(RI_MOUSE_LEFT_BUTTON_DOWN))
        {
            GameStateManagerSetNextState(GsQuit);
        }
    }
}

void MenuShutdown()
{
    // Do not cleanup audio so music continues into credits and level select
}

void MenuUnload()
{
	// Unload all textures.
    AEGfxTextureUnload(buttonTexture);
    AEGfxTextureUnload(titleTexture);
    AEGfxTextureUnload(bgTexture);
    AEGfxTextureUnload(fontTexture);
    AEGfxTextureUnload(iconTexture);

    // Free all meshes.
    AEGfxMeshFree(buttonMesh);
    AEGfxMeshFree(titleMesh);
    AEGfxMeshFree(bgMesh);
    AEGfxMeshFree(fontMesh);
    AEGfxMeshFree(iconMesh);
}
// ---------------------------------------------------------------------------
// Project Name		:	Nook
// File Name		:	Mesh.c
// Author			:	Mary Khuu
// Creation Date	:	19 Feb 2021
// Purpose			:	Deals with all things needed for sprites
// All content © 2021 DigiPen (USA) Corporation, all rights reserved.
// ---------------------------------------------------------------------------

#include "Sprite.h"


//function to create a quadratic mesh
AEGfxVertexList* createQuadMesh(float halfSizeX, float halfSizeY, float u, float v, const char* meshName)
{
	AEGfxVertexList* mesh;

	AEGfxMeshStart();

	AEGfxTriAdd(
		-halfSizeX, -halfSizeY, 0x00FFFFFF, 0.0f, v,
		 halfSizeX, -halfSizeY, 0x00FFFFFF, u, v,
		-halfSizeX, halfSizeY, 0x00FFFFFF, 0.0f, 0.0f);
	AEGfxTriAdd(
		 halfSizeX, -halfSizeY, 0x00FFFFFF, u, v,
		 halfSizeX, halfSizeY, 0x00FFFFFF, u, 0.0f,
		-halfSizeX, halfSizeY, 0x00FFFFFF, 0.0f, 0.0f);

	mesh = AEGfxMeshEnd();
	AE_WARNING_MESG(mesh, "Failed to create %s!", meshName);

	if (mesh != 0)
	{
		return mesh;
	}
	else
	{
		return 0;
	}
}

//same as above but less parameters, assume halfsize is the same in x and y and u = v
AEGfxVertexList* createEqualQuadMesh(float halfSize, float uv, const char* meshName)
{
	AEGfxVertexList* mesh;

	AEGfxMeshStart();

	AEGfxTriAdd(
		-halfSize, -halfSize, 0x00FFFFFF, 0.0f, uv,
		halfSize, -halfSize, 0x00FFFFFF, uv, uv,
		-halfSize, halfSize, 0x00FFFFFF, 0.0f, 0.0f);
	AEGfxTriAdd(
		halfSize, -halfSize, 0x00FFFFFF, uv, uv,
		halfSize, halfSize, 0x00FFFFFF, uv, 0.0f,
		-halfSize, halfSize, 0x00FFFFFF, 0.0f, 0.0f);

	mesh = AEGfxMeshEnd();
	AE_WARNING_MESG(mesh, "Failed to create %s!", meshName);

	if (mesh != 0)
	{
		return mesh;
	}
	else
	{
		return 0;
	}
}

int getMaxFrames(int rows, int columns)
{
	return rows * columns;
}

void animateFrames(int* currentFrame, float* time, float frameDelay, float dt)
{
	(*time) += dt;

	if (*time >= frameDelay)
	{
		(*currentFrame)++;
		*time = 0;
	}
}

void checkEndFrames(int* currentFrame, int maxFrame)
{
	if (*currentFrame >= maxFrame)
	{
		*currentFrame = 0;
	}
}
// ---------------------------------------------------------------------------
// Project Name		:	Nook
// File Name		:	Audio.c
// Author			:	Mary Khuu
// Creation Date	:	15 Mar 2021
// Purpose			:	add audio to the game
// All content © 2021 DigiPen (USA) Corporation, all rights reserved.
// ---------------------------------------------------------------------------

#include "fmod.h"
#include <stdio.h>		// printf()
#include <stdbool.h>	// FALSE
#include "AEEngine.h"

#include "Audio.h"

FMOD_SYSTEM* soundSystem;
FMOD_SOUND* sound;
FMOD_CHANNEL* channel;
FMOD_RESULT result;


// Initialize the Audio System
void AudioInit()
{
	channel = 0;

	// Create and Initialize the FMOD System
	result = FMOD_System_Create(&soundSystem);

	void* extradriverdata = 0;
	result = FMOD_System_Init(soundSystem, 32, FMOD_INIT_NORMAL, extradriverdata);
}

void playSound(bool trigger, const char* file)
{
	// Create and Play the sound
	// Note: this should be generalized for multiple sounds and
	//       be placed in a function to be used outside of init.
	result = FMOD_System_CreateStream(soundSystem, file, FMOD_LOOP_OFF | FMOD_2D, 0, &sound);

	result = FMOD_System_PlaySound(soundSystem, sound, 0, trigger, &channel);
	
}

void playSoundAdvanced(const char* file, float volume)
{
	FMOD_CHANNEL* channel;

	result = FMOD_System_CreateStream(soundSystem, file, FMOD_LOOP_OFF | FMOD_2D, 0, &sound);

	result = FMOD_System_PlaySound(soundSystem, sound, 0, true, &channel);

	result = FMOD_Channel_SetVolume(channel, volume);

	result = FMOD_Channel_SetPaused(channel, false);
}

// Update the Audio System
// Note: this should be called frequently such as every game loop or
//       every time a user enters a command depending on the engine
void AudioUpdate()
{
	result = FMOD_System_Update(soundSystem);
}

// Cleanup the Audio System
void AudioCleanup()
{
	// Release all sounds that have been created
	result = FMOD_Sound_Release(sound);

	// Close and Release the FMOD system
	result = FMOD_System_Close(soundSystem);
	result = FMOD_System_Release(soundSystem);
}

#include <pch.h>
#include "Projects/ProjectTwo.h"
#include "P2_Pathfinding.h"

#pragma region Extra Credit

std::list<AStarPather::Node*> list;
AStarPather::Node map[61][61];

bool ProjectTwo::implemented_floyd_warshall()
{
    return false;
}

bool ProjectTwo::implemented_goal_bounding()
{
    return false;
}

bool ProjectTwo::implemented_jps_plus()
{
    return false;
}
#pragma endregion

bool AStarPather::initialize()
{
    // handle any one-time setup requirements you have

    /*
        If you want to do any map-preprocessing, you'll need to listen
        for the map change message.  It'll look something like this:

        Callback cb = std::bind(&AStarPather::your_function_name, this);
        Messenger::listen_for_message(Messages::MAP_CHANGE, cb);

        There are other alternatives to using std::bind, so feel free to mix it up.
        Callback is just a typedef for std::function<void(void)>, so any std::invoke'able
        object that std::function can wrap will suffice.
    */

    return true; // return false if any errors actually occur, to stop engine initialization
}

void AStarPather::shutdown()
{
    /*
        Free any dynamically allocated memory or any other general house-
        keeping you need to do during shutdown.
    */
}
/*
    This is where you handle pathing requests, each request has several fields:

    start/goal - start and goal world positions
    path - where you will build the path upon completion, path should be
        start to goal, not goal to start
    heuristic - which heuristic calculation to use
    weight - the heuristic weight to be applied
    newRequest - whether this is the first request for this path, should generally
        be true, unless single step is on

    smoothing - whether to apply smoothing to the path
    rubberBanding - whether to apply rubber banding
    singleStep - whether to perform only a single A* step
    debugColoring - whether to color the grid based on the A* state:
        closed list nodes - yellow
        open list nodes - blue

        use terrain->set_color(row, col, Colors::YourColor);
        also it can be helpful to temporarily use other colors for specific states
        when you are testing your algorithms

    method - which algorithm to use: A*, Floyd-Warshall, JPS+, or goal bounding,
        will be A* generally, unless you implement extra credit features

    The return values are:
        PROCESSING - a path hasn't been found yet, should only be returned in
            single step mode until a path is found
        COMPLETE - a path to the goal was found and has been built in request.path
        IMPOSSIBLE - a path from start to goal does not exist, do not add start position to path
*/
PathResult AStarPather::compute_path(PathRequest &request)
{

    //start/goal - start and goal world positions
    GridPos start = terrain->get_grid_position(request.start);
    GridPos goal = terrain->get_grid_position(request.goal);

    terrain->set_color(start, Colors::Red);
    //set color to orange
    terrain->set_color(goal, Colors::Red);

    //request.path.push_back(request.start);


/***********************************A* SEARCH ALGORITHM*********************************/
    //Push Start Node onto the Open List.

    if (request.newRequest)
    {
        for (int i = 0; i <= 40; i++)
        {
            for (int j = 0; j <= 40; j++)
            {
                map[i][j].parent = NULL;
                map[i][j].pos = GridPos{j, i};
                map[i][j].onList_ = onList::NONE;
                map[i][j].cost = 0.0f;
                map[i][j].given = 0.0f;
            }
        }
        list.clear();
        list.push_back(&map[start.col][start.row]);
    }

    //While (Open List is not empty) {
    while (!list.empty())
    {
        //Pop cheapest node off Open List (parent node).
        Node* parentNode = findCheapest(list);
        
        std::list<Node*>::iterator it;
        it = list.begin();
        std::advance(it, findNodeIndex(list, parentNode));
        it = list.erase(it);

        //request.path.push_back(terrain->get_world_position(parentNode->pos));
        //If node is the Goal Node, then path found (RETURN �found�).
        if (parentNode->pos == goal)
        {
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            Node* cur = parentNode;
            while (cur) {
                //push request
                request.path.push_front(terrain->get_world_position(cur->pos));
                //go to next parent
                cur = cur->parent;
            }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

            terrain->set_color(start, Colors::Orange);
            terrain->set_color(goal, Colors::Orange);
            return PathResult::COMPLETE;
        }

        
        bool NW = true;
        bool NE = true;
        bool SE = true;
        bool SW = true;

        //For (all neighboring child nodes)
        for (int i = 1; i <= 8; i++)
        {
            //set parent to parent
            GridPos childPos = getChild(parentNode->pos, i); //get child
            //deleted line
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //Node* oldParent = map[childPos.col][childPos.row].parent;

            if (childPos != parentNode->pos)
            {
                //set map's parent to new parent after getting position
                //map[childNode->pos.col][childNode->pos.row].parent = &map[parentNode->pos.col][parentNode->pos.row];
                
                //grid is on the map and isn't a wall
                if (terrain->is_valid_grid_position(childPos) && !terrain->is_wall(childPos))
                {
                    //i is non diagonals or is a valid diagonal
                    if (i <= 4 || (i == 5 && NE) || (i == 6 && SE) || (i == 7 && SW) || (i == 8 && NW))
                    {
                        //Compute its cost, f(x) = g(x) + h(x)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        float given = parentNode->given;
                        if (i >= 4)
                        {
                            //tile is a diagonal
                            given += (float)std::sqrt(2);
                            //map[childPos.col][childPos.row].given = map[parentNode->pos.col][parentNode->pos.row].given + (float)std::sqrt(2);
                        }
                        else
                        {
                            //tile is N, S, W, E
                            given += 1;
                            //map[childPos.col][childPos.row].given = map[parentNode->pos.col][parentNode->pos.row].given + 1;
                        }

                        float h = getHeuristic(request.settings.heuristic, childPos, goal);
                        //map[childPos.col][childPos.row].cost = map[parentNode->pos.col][parentNode->pos.row].given + h * request.settings.weight;
                        float newCost = given + h * request.settings.weight;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

                        //find if child exists on curr list, and assign it
                        map[parentNode->pos.col][parentNode->pos.row].onList_ = assignList(list, map[parentNode->pos.col][parentNode->pos.row].pos);

                        //If child node isn't on Open or Closed list, put it on Open List.
                        if (map[childPos.col][childPos.row].onList_ == onList::NONE)
                        {
////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            map[childPos.col][childPos.row].parent = parentNode;
                            map[childPos.col][childPos.row].given = given;
                            map[childPos.col][childPos.row].cost = newCost;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            map[childPos.col][childPos.row].onList_ = onList::OPEN;
                            terrain->set_color(childPos, Colors::Blue);
                            list.push_back(&map[childPos.col][childPos.row]);
                        }
                        //Else if child node is on Open or Closed List,
                        else if (map[childPos.col][childPos.row].onList_ == onList::OPEN || map[childPos.col][childPos.row].onList_ == onList::CLOSE)
                        {
                            //AND this new one is cheaper,
                            //then take the old expensive one off both lists
                            //if oldCost == 0 then it's our first time setting it
                            if (map[childPos.col][childPos.row].cost > newCost)
                            {
                                //and put this new cheaper one on the Open List.
////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                map[childPos.col][childPos.row].parent = parentNode;
                                map[childPos.col][childPos.row].given = given;
                                map[childPos.col][childPos.row].cost = newCost;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                map[childPos.col][childPos.row].onList_ = onList::OPEN;
                                terrain->set_color(childPos, Colors::Blue);
                                list.push_back(&map[childPos.col][childPos.row]);
                            }
                            /*
                            else
                            {
                                map[childPos.col][childPos.row].cost = oldCost;
                                map[childPos.col][childPos.row].parent = oldParent;
                            }*/
                        }
                    }
                }
                //grid is valid but the non-diagonals is a wall, skip the diagonals
                else if (terrain->is_valid_grid_position(childPos) && terrain->is_wall(childPos) && i <= 4)
                {
                    if (i == 1) //NORTH
                    {
                        NE = false;
                        NW = false;
                    }

                    if (i == 2) //EAST
                    {
                        NE = false;
                        SE = false;
                    }

                    if (i == 3) //SOUTH
                    {
                        SE = false;
                        SW = false;
                    }

                    if (i == 4) //WEST
                    {
                        SW = false;
                        NW = false;
                    }
                }
            }
        }

/***************************************************************************************************************/
        //Place parent node on the Closed List (we're done with it).
        parentNode->onList_ = onList::CLOSE;
        map[parentNode->pos.col][parentNode->pos.row].onList_ = onList::CLOSE;
        terrain->set_color(parentNode->pos, Colors::Yellow);
        map[parentNode->pos.col][parentNode->pos.row] = *parentNode;
        //If taken too much time this frame (or in single step mode), 
        if (request.settings.singleStep == true)
        {
            //abort search for now and resume next frame (RETURN �working�).
            return PathResult::PROCESSING;
        }
    }
    //Open List empty, thus no path possible (RETURN �fail�).
    return PathResult::IMPOSSIBLE;

}

float AStarPather::getHeuristic(Heuristic method, GridPos position, GridPos goal)
{
    float dx = (float)std::fabs(position.row - goal.row);
    float dy = (float)std::fabs(position.col - goal.col);

    if (method == Heuristic::OCTILE)
    {
        return 1 * (dx + dy) + (float)(sqrt(2) - 2 * 1) * std::min(dx, dy);
    }

    if (method == Heuristic::CHEBYSHEV)
    {
        return 1 * (dx + dy) + (1 - 2 * 1) * std::min(dx, dy);
    }  

    if (method == Heuristic::MANHATTAN)
    {
        return dx + dy;
    }

    if (method == Heuristic::EUCLIDEAN)
    {
        return (float)sqrt(dx * dx + dy * dy);
    }

    return 0.0f;
}

AStarPather::onList AStarPather::assignList(std::list<Node*> list, GridPos position)
{
    //go through list
    for (const Node* node : list)
    {
        //if node exists in list
        //and is labeled as open
        if (node->pos == position && node->onList_ == onList::OPEN)
        {
            //return open
            return onList::OPEN;
        }
        //and is labeled as closed
        if (node->pos == position && node->onList_ == onList::CLOSE)
        {
            //return closed
            return onList::CLOSE;
        }
        //and is labeled as none
        if (node->pos == position && node->onList_ == onList::NONE)
        {
            return onList::NONE;
        }
    }

    //else it's not on either list
    return onList::NONE;
}

GridPos AStarPather::getChild(GridPos node, int i)
{
    GridPos pos;
    if (i == 1) //NORTH
    {
        pos = { node.row + 1, node.col};
    }
    else if (i == 5) //NE
    {
        pos = { node.row + 1, node.col + 1 };
    }
    else if (i == 2) //EAST
    {
        pos = { node.row, node.col + 1};
    }
    else if (i == 6) //SE
    {
        pos = { node.row - 1, node.col + 1 };
    }
    else if (i == 3) //SOUTH
    {
        pos = { node.row - 1, node.col };
    }
    else if (i == 7) //SW
    {
        pos = { node.row - 1, node.col - 1 };
    }
    else if (i == 4) //WEST
    {
        pos = { node.row, node.col - 1};
    }
    else if (i == 8) //NW
    {
        pos = { node.row + 1, node.col - 1};
    }

    return pos;
}

AStarPather::Node* AStarPather::findCheapest(std::list<Node*> list)
{
    Node* cheapestNode;
    float minCost = -1.0f;
    for (Node* node : list)
    {
        if ((node->cost < minCost || minCost == -1.0f) && node->onList_ != onList::CLOSE)
        {
            //is a valid node
            if (terrain->is_valid_grid_position(node->pos) && node->cost >= 0.0f)
            {
                cheapestNode = node;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
                minCost = cheapestNode->cost;
            }
        }
    }

    return cheapestNode;
}

int AStarPather::findNodeIndex(std::list<Node*> list, Node* node)
{
    int i = 0;
    int index = 0;
    for (Node* node_ : list)
    {
        if (node_->pos == node->pos)
        {
                index = i;
        }
        i++;
    }

    return index;
}
  //Challenge Solution - Part #2
  else if (digitalRead(sw2Pin) == HIGH) {
    delay(250);
    flipSwitch(sw2Pos);
  } 
  // Challenge Solution - Part #1
  // Cascading "if" statement to turn switches "ON" if they are "OFF"
  // The PULLUP configuration means that a "LOW" signal equals the switch being "ON",
  // while a "HIGH" signal equals the switch being in the "OFF" position
  if (digitalRead(sw1Pin) == HIGH) {
    delay(250);
    flipSwitch(sw1Pos);
  } 
#include<bits/stdc++.h>
using namespace std;

void solve(){
   
}

int main(){
    int t;
    cin>>t;
    while(t-->0){
        solve();
    }
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t-->0){
    
    }
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

int main(){
  
  return 0;
}
// C++ code to find count of largest consectutive subset
#include <iostream>
#include <stdlib.h>
#include <unordered_set>
using namespace std;

int main() {
    int sz, num;
    unordered_set<int> numbers;
    int maxLen = 0;
    cin>>sz;
    for (int i=0;i<sz;i++) {
        cin>>num;
        numbers.insert(num);
    }
    
    for (int i : numbers) {
        if (numbers.find(i-1) == numbers.end()) {
            int temp = i;
            while (numbers.find(temp) != numbers.end()) temp++;
            
            if (maxLen < (temp-i)) maxLen = temp-i;
        }
    }

    cout<< maxLen;
    return 0;
}
# Makefile

SRC := $(wildcard *.cpp) $(wildcard *.cc) $(wildcard *.c)
OBJ := $(SRC:.cpp=.o) $(SRC:.cc=.o) $(SRC:.c=.o)
TARGET := my_program

CXX := /opt/homebrew/opt/ccache/libexec/g++
CXXFLAGS := -fdiagnostics-color=always -g -Wall -std=c++20

$(TARGET): $(OBJ)
    $(CXX) $(CXXFLAGS) -o $@ $^

clean:
    rm -f $(OBJ) $(TARGET)
#include <iostream>
#include<cstring>
#include<memory>

using namespace std;

bool isValid (string customerNumber) {
    if (customerNumber.length() != 6)
        return false;

    for(int i = 0; i < 2; i++)
    if (!isalpha(customerNumber[i]))
        return false;

   for (int i = 2; i < customerNumber.length(); i++)
       if(!isdigit(customerNumber[i]))
           return false;

   return true;
}

int main() {

    string cust_number = "AB1234";
    cout << isValid(cust_number);
  return 0;
}
#include <iostream>


using namespace std;


int main() {

    int numbers[] = {10,20,30};
    int* ptrNumbers = &numbers[size(numbers) - 1];

    while (ptrNumbers >= &numbers[0]) {//or (ptrNumbers >= numbers)
            cout << *ptrNumbers <<endl;
            ptrNumbers--;
    }
    return 0;
}
#include <iostream>


using namespace std;

void increasePrice(double& price) {
    price *= 1.2;

}
int main() {

    double price = 100;
    increasePrice(price);
    cout << price;

    return 0;
}
#include <iostream>


using namespace std;

int main() {

    int number = 10;
    int* ptr = &number; // The address of operator
    *ptr = 20; // Indirection (de-referencing) operator
    cout << number;
    
    return 0;
}
#include <iostream>


using namespace std;

int main() {

   int firstArray[] = {10,20,30,40};
   int secondArray[] = {10,20,30,40};

   bool areEqual = true;
   for (int i = 0; i<size(firstArray); i++)
       if(firstArray[i] != secondArray[i]) {
           areEqual = false;
            break;
       }
cout << boolalpha << areEqual;
#include <iostream>


using namespace std;

int main() {

   int firstArray[] = {10,20,30,40};
   int secondArray[size(firstArray)];

   for (int i = 0; i < size(firstArray); i++)
       secondArray[i] = firstArray[i];

   for (int number: secondArray)
       cout << number << endl;


    return 0;

}
#include <iostream>
using namespace std;

int main() {

    cout << "Enter a positive number: ";
    int number;
    cin >> number;

    if (number < 0)
        cout << "Error! Number is not positive";
    else {
        int factorial = 1;
        for (int i = 1; i<=number; i++)
             factorial = factorial * i;  // factorial *= i
        cout << "The factorial of " << number << ": " << factorial;
    }


    return 0;
}
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double dl;

#define endl "\n"
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

int main()
{
   int n;
   cin>>n;
   int arr[n];int b[n];
   int max=0;
   for(int i=0;i<n;i++){
cin>>arr[i];
if(arr[i]>max)max=arr[i];
   }
int count_arr[max+1];
for(int i=0;i<=max;i++){
count_arr[i]=0;
}
for(int i=0;i<n;i++){
count_arr[arr[i]]++;
}
for(int i=1;i<=max;i++){
count_arr[i]=count_arr[i]+count_arr[i-1];
}
for(int i=n-1;i>=0;i--){
    b[--count_arr[arr[i]]]=arr[i];
}
for(int i=0;i<n;i++){
    cout<<b[i]<<" ";
}
       return 0;
}

    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char c = 'A'; c <= 'Z'; c++) {
        int first = n;
        int last = -1;
        for (int i = 0; i < n; i++) {
            if (s[i] == c) {
                first = min(first, i);
                last = max(last, i);
            }
        }
        for (int i = first; i <= last; i++) {
            if (s[i] != c) {
                cout << "NO\n";
                return;
            }
        }
    }
    cout << "YES\n";
        score = score + 10 - time_to_press/100;
        score = score + 1 + time_to_press/100;
    // Challenge Solution Part 5: Add 1 bonus point for every tenth of a second under 1.0 seconds
    // Keep in mind that 1 second is equal to 1,000 milliseconds
    if(time_to_press < 1000){
        score = score + 5;
    }
      //Challenge Solution Part 4: Calculate the difference in time between the row becoming active and the button press.
      time_to_press = millis() - time_start;
    //Challenge Solution Part 3: Start the timer for this row being active
    time_start = millis();
//{ Driver Code Starts
// C++ program to remove recurring digits from
// a given number
#include <bits/stdc++.h>
using namespace std;


// } Driver Code Ends
    

class Solution{
    //Function to find the leaders in the array.
    public:
    vector<int> leaders(int a[], int n)
    {
        vector<int>ans;
      for(int i=0 ; i<n ; i++)
      {
          int j;
          for( j=i+1 ; j<n ; j++)
          {
              if(a[i]<a[j])
              {
                  break;
              }
            
          }
           if(j==n)
              {
                  ans.push_back(a[i]);
              }
      }
    return ans;
        
    }
};

//{ Driver Code Starts.

int main()
{
   long long t;
   cin >> t;//testcases
   while (t--)
   {
       long long n;
       cin >> n;//total size of array
        
        int a[n];
        
        //inserting elements in the array
        for(long long i =0;i<n;i++){
            cin >> a[i];
        }
        Solution obj;
        //calling leaders() function
        vector<int> v = obj.leaders(a, n);
        
        //printing elements of the vector
        for(auto it = v.begin();it!=v.end();it++){
            cout << *it << " ";
        }
        
        cout << endl;

   }
}

// } Driver Code Ends



//{ Driver Code Starts
// C++ program to remove recurring digits from
// a given number
#include <bits/stdc++.h>
using namespace std;


// } Driver Code Ends
    

class Solution{
    //Function to find the leaders in the array.
    public:
   vector<int> leaders(int a[], int n)
    {
        vector<int>v;
        int maxi=INT_MIN;
        for(int i=n-1 ; i>=0 ; i--)
        {
            if(a[i]>=maxi)
            {
                maxi=a[i];
                v.push_back(maxi);
            }
        }
        reverse(v.begin(),v.end());
        return v;
    }
};

//{ Driver Code Starts.

int main()
{
   long long t;
   cin >> t;//testcases
   while (t--)
   {
       long long n;
       cin >> n;//total size of array
        
        int a[n];
        
        //inserting elements in the array
        for(long long i =0;i<n;i++){
            cin >> a[i];
        }
        Solution obj;
        //calling leaders() function
        vector<int> v = obj.leaders(a, n);
        
        //printing elements of the vector
        for(auto it = v.begin();it!=v.end();it++){
            cout << *it << " ";
        }
        
        cout << endl;

   }
}

// } Driver Code Ends
//{ Driver Code Starts
#include <iostream>
using namespace std;


// } Driver Code Ends
class Solution{
    public:
    // Function to find equilibrium point in the array.
    // a: input array
    // n: size of array
    int equilibriumPoint(long long a[], int n) 
    {
        int i=0;
        int curr=0;
        int sum=0;
        for(int i=0 ; i<n ; i++)
        {
            sum+=a[i];
        }
        while(i<n)
        {
            curr+=a[i];
            if(curr==sum)
            {
                return i+1;
            }
            else
            {
                sum-=a[i];
            }
            i++;
        }
        return -1;
    }

};

//{ Driver Code Starts.


int main() {

    long long t;
    
    //taking testcases
    cin >> t;

    while (t--) {
        long long n;
        
        //taking input n
        cin >> n;
        long long a[n];

        //adding elements to the array
        for (long long i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        Solution ob;

        //calling equilibriumPoint() function
        cout << ob.equilibriumPoint(a, n) << endl;
    }
    return 0;
}

// } Driver Code Ends
 if(n<m) return "No";
    
    map<int,int> mp;
    for(int i=0;i<n;i++)
    {
        mp[a1[i]]++;
    }
    
    for(int i=0;i<m;i++)
    {
        if(mp.find(a2[i]) != mp.end())
        {
            if(mp[a2[i]] == 0)
            {
                return "No";
            }
            
            mp[a2[i]]--;
            
            continue;
        }else{
            return "No";
        }
    }
    return "Yes";
}





string isSubset(int a1[], int a2[], int n, int m)
{
      int i=0;
      int count=0;
	int j=0;
	sort(a1,a1+n);

    sort(a2,a2+m);
	while(i<n and j<m)
		{
			if(a1[i]==a2[j])
			{
			    i++;
				j++;
				count++;
		
			}
			else if(a1[i]<a2[j])
			{
			    i++;
			}
			else
			{
			    return "No";
			}
		
		}
	if(count==m)
	{
		return "Yes";
	}
	return "No";
}
int lowestCommonAncestor(TreeNode<int> *root, 
int x, int y)
{
	if(!root)
    return -1;
    if(root->data==x or root->data==y)
    return root->data;
    int lefti=lowestCommonAncestor(root->left,x,y);
    int righti=lowestCommonAncestor(root->right,x,y);
    if(lefti==-1)
    return righti;
    if(righti==-1)
    return lefti;
    return root->data;
}
#include <bits/stdc++.h> 
vector<vector<string>>
 getGroupedAnagrams(vector<string> &input, int n)
{
    unordered_map<string,vector<string>>mp;
    vector<vector<string>>ans;
    for(int i=0 ; i<n ; i++)
    {
       string str=input[i];
       string s=str;
       sort(s.begin(),s.end());
       mp[s].push_back(str);
    }
    for(auto it:mp)
    {
        ans.push_back(it.second);
    }
    return ans;
}
int fib(int n)
{
    int a = 0, b = 1, c, i;
    if (n == 0)
        return a;
    for (i = 2; i <= n; i++) {
        c = a + b;
        a = b;
        b = c;
    }
    return b;
}


int fib(int n)
{
    if (n <= 1)
        return n;
    return fib(n - 1) + fib(n - 2);
}
  vector <int> calculateSpan(int price[], int n)
    {
       vector<int>ans;
       stack<pair<int,int>>st;
       for(int i=0 ; i<n ; i++)
       {
           
           while(!st.empty() and st.top().first<=price[i])
           {
               st.pop();
           }
           if(st.empty())
           {
               ans.push_back(-1);
           }
           else if(!st.empty() and st.top().first>price[i])
           {
                ans.push_back(st.top().second);
           }
        st.push({price[i],i});
       }
       for(int i=0 ; i<n ; i++)
       {
           ans[i]=i-ans[i];
       }
       return ans;
    }
//{ Driver Code Starts
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;

struct Node {
    int data;
    struct Node* next;
    Node(int x) {
        data = x;
        next = NULL;
    }
};


// } Driver Code Ends
/* Structure of the linked list node is as
struct Node 
{
    int data;
    struct Node* next;
    Node(int x) { data = x;  next = NULL; }
};
*/


class Solution{
  public:
    //Function to sort the given linked list using Merge Sort.
    Node* merge(Node* left,Node* right)
    {
        Node* ptr=NULL;
        if(!left)
        return right;
        if(!right)
        return left;
        if(left->data<right->data)
        {
            ptr=left;
            ptr->next=merge(left->next,right);
        }
        else
        {
            ptr=right;
            ptr->next=merge(left,right->next);
        }
        return ptr;
    }
    Node* middle(Node* head)
    {
        Node* slow=head;
        Node* fast=head->next;
        while(fast!=NULL and fast->next!=NULL)
        {
            slow=slow->next;
            fast=fast->next->next;
        }
        return slow;
    }
    Node* mergeSort(Node* head)
    {
        if(!head or !head->next)
        return head;
        Node* left=head;
        Node* mid=middle(head);
        Node* right=mid->next;
        mid->next=NULL;
        left=mergeSort(left);
        right=mergeSort(right);
        Node* ans=merge(left,right);
        return ans;
    }
};


//{ Driver Code Starts.

void printList(Node* node) {
    while (node != NULL) {
        printf("%d ", node->data);
        node = node->next;
    }
    printf("\n");
}

void push(struct Node** head_ref, int new_data) {
    Node* new_node = new Node(new_data);

    new_node->next = (*head_ref);
    (*head_ref) = new_node;
}

int main() {
    long test;
    cin >> test;
    while (test--) {
        struct Node* a = NULL;
        long n, tmp;
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> tmp;
            push(&a, tmp);
        }
        Solution obj;
        a = obj.mergeSort(a);
        printList(a);
    }
    return 0;
}
// } Driver Code Ends
void merge(vector<int>&arr,int l,int mid,int h)
{
   vector<int>temp;
   int i=l;
   int j=mid+1;
while(i<=mid and j<=h)
{
    if(arr[i]<=arr[j])
    {
        temp.push_back(arr[i]);
        i++;
    }
    else 
    {
        temp.push_back(arr[j]);
        j++;
    }
}
while(i<=mid)
{
    temp.push_back(arr[i]);
    i++;
}
while(j<=h)
{
    temp.push_back(arr[j]);
    j++;
}
for(int i=l ; i<=h ; i++)
{
    arr[i]=temp[i-l];
}
}
void me(vector<int>&arr,int l,int h)
{
   
    if(l>h)
    return;
    int mid=(l+h)/2;
    me(arr,l,mid);
    me(arr,mid+1,h);
    merge(arr,l,mid,h);
}
void mergeSort(vector < int > & arr, int n)
{
    me(arr,0,n-1);
}
#include <bits/stdc++.h> 
string encode(string &message)
{
    string ans="";
    int count=1;
    int n=message.size();
    for(int i=0 ; i<n ; i++)
    {
        if(message[i]==message[i+1])
        {
           count++;  
        }
         ans+=message[i];
    ans+=to_string(count);
    count=1;
    }
   
    return ans;
}
#include <bits/stdc++.h> 
int minimumParentheses(string pattern)
{
    int cnt=0;
    int req=0;
    for(int i=0 ; i<=pattern.length()-1 ; i++) 
    {
         if(pattern[i]=='(')
         {
             cnt++;
         }
         else if(pattern[i]==')' and cnt>0)
         {
             cnt--;
         }
         else
         {
             req++;
         }
    }  
    return cnt+req;
}
#include <bits/stdc++.h>
bool search(int arr[],int n,int num)
{
    for(int i=0 ; i<=n ; i++)
    {
        if(arr[i]==num)
        return true;
    }
    return false;
} 
int firstMissing(int arr[], int n)
{
   for(int i=1 ; i<=n ; i++)
   {
       if(search(arr,n,i)==false)
       return i;
   }
   return n+1;
}

time complexity-O(N2)
#include <bits/stdc++.h> 
int pairSum(vector<int> &arr, int n, int target)
{
	int count=0;
	unordered_map<int,int>mp;
	for(int i=0 ; i<n ; i++)
	{
       if(mp.find(target-arr[i])!=mp.end())
	   {
		   count+=mp[target-arr[i]];
	   }
	   else
	   {
		   mp[arr[i]]++;
	   }
	}
	if(count==0)
	return -1;
	else
	return count;
}
void insertionSort(int n, vector<int> &arr)
{
    for(int i=0 ; i<n ; i++)
    {
        int j=i;
        while(j>0 and arr[j]<arr[j-1])
        {
            swap(arr[j],arr[j-1]);
            j--;
        }
    }
}
class Solution {
public:
    void moveZeroes(vector<int>& arr) 
    {
        int n=arr.size();
       int pos=0;
       for(int i=0 ; i<n ; i++)
       {
           if(arr[i]!=0)
           {
               swap(arr[i],arr[pos]);
               pos++;
           }
       }    
    }
};
int length(Node *head)
{
	//Write your code here
    int c = 0;
    Node *temp = head;
    while(temp != NULL)
    {
        temp = temp->next;
        c++;
    }
    return c;
}
void insertAtTail(Node* &tail,int d)
 {
   Node* temp = new Node(d);
   tail->next = temp;
   tail = tail->next;
 }

Node* constructLL(vector<int>& arr) {
    // Write your code here
    Node* head = new Node(arr[0]);
    Node* tail = head;
    
    for(int i = 1;i<arr.size();i++)
    {
      insertAtTail(tail,arr[i]);
    }
    return head;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define placementlelo vector<int>
#define all(a) (a).begin() , (a).end()
#define sz(a) ((int)((a).size()))

const ll INF = 4e18;

vector<placementlelo> dp(1e4+1 , placementlelo(1e4+1 , -1));

int f(int i , int j , int s , int r , string &x , string &y , string &y1)
{
    if(i>j)return 0;
    if(dp[i][j] != -1)return dp[i][j];

    int mini = 1e9;
    for(int k=i; k<=j; k++)
    {
        
        if(y1.find(x.substr(i , k-i+1)) != string::npos)mini = min(mini , r+f(k+1 , j , s , r , x , y , y1));
        if(y.find(x.substr(i , k-i+1)) != string::npos)mini = min(mini , s+f(k+1 , j , s , r , x , y , y1));
    }

    return mini;
}
int solve(int s , int r , string x, string y)
{
    string y1 = y;
    reverse(all(y1));
    return f(0 , sz(x)-1 , s, r , x , y , y1);
}

int32_t main(){

    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);

    string x , y;
    cin >> x >> y;
    int s, r;
    cin >> s >> r;
    int ans = solve(s , r, x , y);
    cout << ans;

    return 0;

}
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n, m; // Replace semicolons with commas
    cin >> n >> m; // Remove the extra semicolon
   
    vector<vector<int>> cust;
    for(int i=0; i<n; i++){
        int q, p;
        cin >> q >> p;
        cust.push_back({p, q});
    }
    
    vector<vector<int>> rice;
    for(int i=0; i<m; i++){
        int q, p;
        cin >> q >> p;
        rice.push_back({p, q});
    }
    
    sort(cust.begin(), cust.end());
    sort(rice.begin(), rice.end());
    
    vector<int> placementlelo(m, 0);
    
    int ans = 0;
    
    for(int i=0; i<n; i++){
        int quan = -1;
        int index = -1;
        for(int j=0; j<m; j++){
            if(!placementlelo[j]){
               
                if(rice[j][0] > cust[i][0]) break;
                
                if(rice[j][1] > cust[i][1]){
                    if(quan == -1){
                        quan = rice[j][1];
                        index = j;
                    }
                    else{
                        if(quan > rice[j][1]){
                            index = j;
                            quan = rice[j][1];
                        }
                    }
                }
            }
        }
        
        if(index != -1){
            placementlelo[index] = 1;
            ans++;
        }
    }
    
    cout << ans;
    return 0; // Add a return statement at the end of main
}
#include <bits/stdc++.h>
using namespace std;
// calculating hamming distance
int hamdis(string& s1,string& s2) 
{
		int dis= 0;
	int n=s1.length();
		for (int i = 0; i < n ; i++) 
		{
				if (s1[i] != s2[i]) 
				{
						dis++;
				}
		}
		return dis;
}
// checking string is binary or not
bool checkbinary(string& s) {
		for (int i = 0; i <s.length() ; i++) 
	{
				if (s[i] != '0' and  s[i]!= '1') {
						return false;
				}
		}
		return true;
}
// finding min cost and distance
void findminimum(string& str, int a, int b) {
		if (!checkbinary(str))
		{
				cout << "INVALID"<<endl;
				return;
		}	
    
		string orig = str;
		sort(str.begin(), str.end());
     
		int origcost = 0;
		int count01 = 0;
		int count10 = 0;
     int m=str.length() - 1;
		for (int i = 0; i <m ; i++)
			{
				if (str[i] == '0' && str[i + 1] == '1') {
						count01++;
						origcost += a;
				} else if (str[i] == '1' && str[i + 1] == '0') {
						count10++;
						origcost += b;
				}
		}

	
		int minHammingDistance = hamdis(str, orig);

		cout << minHammingDistance << endl;
}

int main() {
		int T;
		cin >> T;

		for (int t = 0; t < T; t++) {
				string binaryStr;
				int A, B;

				cin >> binaryStr;
				cin >> A >> B;

				findminimum(binaryStr, A, B);
		}

		return 0;
}
  void reverse(int arr[],int low,int high)
    {
        while(low<=high)
        {
            int temp=arr[low];
            arr[low]=arr[high];
            arr[high]=temp;
            low++;
            high--;
        }
    }
    //Function to rotate an array by d elements in counter-clockwise direction. 
    void rotateArr(int arr[], int d, int n)
    {
        if(d>n)
        {
            d=d%n;
        }
        reverse(arr,0,d-1);
        reverse(arr,d,n-1);
        reverse(arr,0,n-1);
    }
 struct Node* reverseList(struct Node *head)
    {
        if(!head or head->next==NULL)
        {
            return head;
        }
        Node* chotahead=reverseList(head->next);
        head->next->next=head;
        head->next=NULL;
        return chotahead;
    }
class Solution{
  public:
    //Function to insert a node at the beginning of the linked list.
    Node *insertAtBegining(Node *head, int x)
    {
            
       Node* newnode=new Node(x);
       newnode->next=head;

       return newnode;
    }
    
    
    //Function to insert a node at the end of the linked list.
    Node *insertAtEnd(Node *head, int x)  
    {
        if(!head)
        {
            Node* newnode=new Node(x);
            return newnode;
        }
        Node* temp=head;
        while(temp->next!=NULL)
        {
            temp=temp->next;
        }
        Node* newnode=new Node(x);
        temp->next=newnode;
        return head;
    }
};
int isSorted(int n, vector<int> a)
{
    bool flag=false;
    for(int i=0 ; i<n-1 ; i++)
    {
      if (a[i] > a[i + 1]) {
        return 0;
      }
    }
    return 1;
}
in two traversal-
  
vector<int> getSecondOrderElements(int n, vector<int> a)
{
    int mini=INT_MAX;
    int maxi=INT_MIN;
    for(int i=0  ; i<n ; i++)
    {
        if(a[i]>maxi)
        {
            maxi=a[i];
        }
        if(a[i]<mini)
        {
            mini=a[i];
        }
    }
    vector<int>ans;
    int mi=INT_MAX;
    int ma=INT_MIN;
    for(int i=0 ; i<n ; i++)
    {
        if(a[i]>ma and a[i]!=maxi)
        {
              ma=a[i];
            
        }
        if(a[i]<mi and a[i]!=mini)
        {
            mi=a[i];
        }
    }
    ans.push_back(ma);
    ans.push_back(mi);
    return ans;
}

in single traversal-
  
int findSecondLargest(int n, vector<int> &arr)
{
    int largest=INT_MIN;
    int secondlargest=INT_MIN;
    for(int i=0 ; i<n ; i++)
    {
        if(arr[i]>largest)
        {
            secondlargest=largest;
            largest=arr[i];
        }
        if(arr[i]<largest and arr[i]>secondlargest)
        {
            secondlargest=arr[i];
        }
    }
    if(secondlargest==INT_MIN)
    {
        return -1;
    }
    return secondlargest;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
	double p,r,t;
	cin>>p>>r>>t;
	double in=(p*r*t)/100;
	cout<<fixed<<setprecision(6)<<in;
	return 0;
}
int countLeaves(Node* root)
{
   if(!root)
   return 0;
   if(root->left==NULL and root->right==NULL)
   {
       return 1;
   }
   return (countLeaves(root->left)+countLeaves(root->right));
}
#include <bits/stdc++.h>
using namespace std;

struct StackNode {
    int data;
    StackNode *next;
    StackNode(int a) {
        data = a;
        next = NULL;
    }
};

class MyStack {
  private:
    StackNode *top;

  public:
    void push(int);
    int pop();
    MyStack() { top = NULL; }
};
//Function to push an integer into the stack.
void MyStack ::push(int x) 
{
   StackNode* newnode=new StackNode(x);
   newnode->next=top;
   top=newnode;
  
}

//Function to remove an item from top of the stack.
int MyStack ::pop() 
{
    int ddata;
    if(top==NULL)
    {
        return -1;
    }
     ddata=top->data;
    top=top->next;
    return ddata;
}

Note-
#react ko single page application bolte h kyuki pure project mai ek hi html file hoti h or sara kaam ussi ke ander hota h.
#entry point -index.js
#React DOM implementation h react ka web app pr.DOM ek tree structure h.react khud ka virtual DOM bnata h.

function Chai()
{
    return(
        <>
        {/* fragment */}
        <h2>I am Nistha</h2>
        <h3>btech</h3>
        </>
       
    )
}
export default Chai;
void def(struct Node* root,vector<int>&ans,int k);
vector<int> Kdistance(struct Node *root, int k)
{
  vector<int>ans;
  def(root,ans,k);
  return ans;
}
void def(struct Node* root,vector<int>&ans,int k)
{
    if(!root)
    return;
    if(k==0)
    ans.push_back(root->data);
    def(root->left,ans,k-1);
    def(root->right,ans,k-1);
}
 bool solve(Node* root,int mini,int maxi)
    {
        if(!root)
        return true;
        if(root->data>mini and root->data<maxi)
        {
            bool lefti=solve(root->left,mini,root->data);
            bool righti=solve(root->right,root->data,maxi);
             if(lefti and righti)
        return true;
        }
       return false;
    }
    bool isBST(Node* root) 
    {
        return solve(root,INT_MIN,INT_MAX);
    }
   long long int convertEvenBitToZero(long long int n) 
    {
        return n&0xaaaaaaaa;
    }
string reverseString(string s)
{
   unordered_map<char,int>mp;
    string ans="";
    for(int i=s.length()-1 ; i>=0 ; i--)
    {
        mp[s[i]]++;
        if((mp[s[i]]==1)&&(s[i]!=' '))
        {
            ans+=s[i];
        }
    }
    return ans;
}
 pair<int, int> get(int a, int b)
    {
        a=a+b;
        b=a-b;
        a=a-b;
        return{a,b};
    }
int main()
{
    int year;

    year=2000;

    if(year % 400 == 0)
        cout << year << " is a Leap Year";
        
    else if(year % 4 == 0  && year % 100 != 0)
        cout << year << " is a Leap Year";
        
    else
        cout << year << " is not a Leap Year";
    
    return 0;
}
 double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2)
    {
       vector<int>ans;
       int l=0;
       int r=0;
       while(l<nums1.size() and r<nums2.size())
       {
           if(nums1[l]<nums2[r])
           {
               ans.push_back(nums1[l]);
               l++;
           }
           else
           {
               ans.push_back(nums2[r]);
               r++;
           }
       }
       if(l<nums1.size())
       {
           while(l<nums1.size())
           {
                ans.push_back(nums1[l]);
               l++;
           }
       }
       if(r<nums2.size())
       {
            while(r<nums2.size())
           {
                ans.push_back(nums2[r]);
               r++;
           }
       }
       int size=ans.size();
       if(size%2==1)
       {
           return ans[size/2];
       }
       else
       {
               int a = ans[size / 2 - 1];
    int b = ans[size / 2];
    return (a + b) / 2.0;
       }
       return -1;
    }
vector<int> inOrder(Node* root)
    {
         vector<int>ans;
        stack<Node *>s;
        Node *curr = root;
        while(curr != NULL || !s.empty())
        {
            while(curr != NULL)
            {
                s.push(curr);
                curr = curr -> left;
            }
            curr = s.top();
            s.pop();
            ans.push_back(curr -> data);
            curr = curr -> right;
        }
        return ans;
    }
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <iterator>
#include <algorithm>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#define endl "\n"
#define ll long long
#define all(v) v.begin(),v.end()
void swap(int arr[] , int pos1, int pos2){
    int temp;
    temp = arr[pos1];
    arr[pos1] = arr[pos2];
    arr[pos2] = temp;
}

int partition(int arr[], int low, int high, int pivot){
    int i = low;
    int j = low;
    while( i <= high){
        if(arr[i] > pivot){
            i++;
        }
        else{
            swap(arr,i,j);
            i++;
            j++;
        }
    }
    return j-1;
}

void quickSort(int arr[], int low, int high){
    if(low < high){
        int pivot = arr[high];
        int pos = partition(arr, low, high, pivot);

        quickSort(arr, low, pos-1);
        quickSort(arr, pos+1, high);
    }
}




using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

        ll N ;
        cin>>N ;
        int X[N] ;
        for(ll i=0;i<N;i++){
        cin>>X[i];}
    quickSort(X,0,N-1) ;
    for(ll i=0;i<N;i++){
        cout<<X[i]<<" ";}

}

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <iterator>
#include <algorithm>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#define endl "\n"
#define ll long long
#define all(v) v.begin(),v.end()
void merge(int array[], int const left,
           int const mid, int const right)
{
    auto const subArrayOne = mid - left + 1;
    auto const subArrayTwo = right - mid;

    // Create temp arrays
    auto *leftArray = new int[subArrayOne],
            *rightArray = new int[subArrayTwo];

    // Copy data to temp arrays leftArray[]
    // and rightArray[]
    for (auto i = 0; i < subArrayOne; i++)
        leftArray[i] = array[left + i];
    for (auto j = 0; j < subArrayTwo; j++)
        rightArray[j] = array[mid + 1 + j];

    // Initial index of first sub-array
    // Initial index of second sub-array
    auto indexOfSubArrayOne = 0,
            indexOfSubArrayTwo = 0;

    // Initial index of merged array
    int indexOfMergedArray = left;

    // Merge the temp arrays back into
    // array[left..right]
    while (indexOfSubArrayOne < subArrayOne &&
           indexOfSubArrayTwo < subArrayTwo)
    {
        if (leftArray[indexOfSubArrayOne] <=
            rightArray[indexOfSubArrayTwo])
        {
            array[indexOfMergedArray] =
                    leftArray[indexOfSubArrayOne];
            indexOfSubArrayOne++;
        }
        else
        {
            array[indexOfMergedArray] =
                    rightArray[indexOfSubArrayTwo];
            indexOfSubArrayTwo++;
        }
        indexOfMergedArray++;
    }

    // Copy the remaining elements of
    // left[], if there are any
    while (indexOfSubArrayOne < subArrayOne)
    {
        array[indexOfMergedArray] =
                leftArray[indexOfSubArrayOne];
        indexOfSubArrayOne++;
        indexOfMergedArray++;
    }

    // Copy the remaining elements of
    // right[], if there are any
    while (indexOfSubArrayTwo < subArrayTwo)
    {
        array[indexOfMergedArray] =
                rightArray[indexOfSubArrayTwo];
        indexOfSubArrayTwo++;
        indexOfMergedArray++;
    }
}

// begin is for left index and end is
// right index of the sub-array
// of arr to be sorted */
void mergeSort(int array[],
               int const begin,
               int const end)
{
    // Returns recursively
    if (begin >= end)
        return;

    auto mid = begin + (end - begin) / 2;
    mergeSort(array, begin, mid);
    mergeSort(array, mid + 1, end);
    merge(array, begin, mid, end);
}




using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

        ll N ;
        cin>>N ;
        int X[N] ;
        for(ll i=0;i<N;i++){
        cin>>X[i];}
    mergeSort(X,0,N-1) ;
    for(ll i=0;i<N;i++){
        cout<<X[i]<<" ";}

}

void insertionSort(int arr[], int n)
    {
        int i, key, j;
        for (i = 1; i < n; i++) {
            key = arr[i];
            j = i - 1;

            // Move elements of arr[0..i-1],
            // that are greater than key,
            // to one position ahead of their
            // current position
            while (j >= 0 && arr[j] > key) {
                arr[j + 1] = arr[j];
                j = j - 1;
            }
            arr[j + 1] = key;
        }
    }
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <iterator>
#include <algorithm>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#define endl "\n"
#define ll long long
#define all(v) v.begin(),v.end()



using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N ;
     cin>>N ;
     ll X[N] ;
     for(ll i=0 ;i<N ;i++){cin>>X[i];
     }
     ll k=N ;
    for(ll J=0 ;J<N ;J++) {
         for (ll i = 0; i < N-1-J; i++) {
             if (X[i] > X[i + 1]) {
                 swap(X[i], X[i +1]);
             }
         }
     }

     for(ll i=0 ;i<N ;i++){
         cout<<X[i]<<" ";
     }







}

//--intersection function--
IntersectionResult sphere::IntersectTest(ray _ray)
{
    //creating values
    IntersectionResult testResult;
    testResult.hitsphere = false;

    //p - a calucation for easier use in next calculations
    glm::vec3 delta = sphereCenter - _ray.origin;

    //calculating d
    float d = glm::length(delta - glm::dot(delta,_ray.dir) * _ray.dir);

    //--calculate intersection point--

    //calculating x
    float intersectx = glm::sqrt((radius * radius) - (d * d));

    //final intersect point calculation
    glm::vec3 Intersect_Point = _ray.origin + (glm::dot((sphereCenter - _ray.origin), _ray.dir) - intersectx) * _ray.dir;
    
    //main intersection test
    //if the ray is less than the radius of the sphere that means it hit so set hit to true
    if (d <= radius)
    {
        testResult.Intersectpoint = Intersect_Point;
        testResult.hitsphere = true;
    }

    //returns the result of the ray
    return testResult;
}
namespace myengine
{
    void load_ogg(const std::string& _path, std::vector<unsigned char>& _buffer,
        ALenum& _format, ALsizei& _freq)
    {

        int channels = 0;
        int sampleRate = 0;
        short* output = NULL;

        size_t samples = stb_vorbis_decode_filename(_path.c_str(),
            &channels, &sampleRate, &output);
        std::cout << samples << std::endl;

        if (samples == -1)
        {
            throw std::runtime_error("Failed to open file '" + _path + "' for decoding");
        }

        // Record the format required by OpenAL
        if (channels < 2)
        {
            _format = AL_FORMAT_MONO16;
        }
        else
        {
            _format = AL_FORMAT_STEREO16;
        }

        // Copy (# samples) * (1 or 2 channels) * (16 bits == 2 bytes == short)
        _buffer.resize(samples * channels * sizeof(short));
        memcpy(&_buffer.at(0), output, _buffer.size());

        // Record the sample rate required by OpenAL
        _freq = sampleRate;

        // Clean up the read data
        free(output);
    }
void DealersTurn(cards PlayerHand[], cards DealerHand[])//dealers turn function
{
	DealerTotalHandscore = 0;//sets ai hand score to 0 to reset it when they start thier turn

	for (i = 0; i < dealerCurrentHand; i++)//when dealer gets a card it adds to the value
	{
		DealerTotalHandscore += DealerHand[i].PlayerValue;
	}

	if (DealerTotalHandscore < 17)//if dealer is less than 17 they can draw a card
	{
		HitDealer(PlayerHand, DealerHand);//draws card for dealer
		Sleep(2000);//delay for immersion
		DealersTurn(PlayerHand, DealerHand);//dealers turn again since its below 17
	}

	if (DealerTotalHandscore >= 17)//if dealers hand is above 17
	{
		if (TotalHandscore > DealerTotalHandscore)//checks if players hand is bigger than the dealers hand, if player went over the game wouldve already end
		{
			Sleep(2000);//delay for suspense
			std::cout << "You win! Congrats! Your hand total is " << TotalHandscore << " The dealers was " << DealerTotalHandscore << std::endl;
			Sleep(2000);
			bank += currentbet * 2;
			std::cout << "You now have $" << bank << " in your bank" << std::endl;
			Sleep(2000);
			std::cout << "Do you want to continue playing? " << std::endl << "1.Yes " << std::endl << "2.No" << std::endl;
			Choice = 0;
			std::cin >> Choice;//player chooses to play or exit

			if (Choice == 1)
			{
				Choice = 0;
				reset();
			}

			if (Choice == 2)
			{
				Choice = 0;
				Quitgame();
			}
		}
	}
class Solution {
public:
    vector<int> duplicates(vector<int>& nums){
        unordered_set<int> uSet;
        int n = nums.size();
        vector<int> dup(n, 0);
        for(int i = 0 ; i < n ;i++){
            if(uSet.find(nums[i]) != uSet.end()){
                dup[i] = 1;
            }
            if(i != 0)
                dup[i] += dup[i-1];
            uSet.insert(nums[i]);
        }
        return dup;
    }
    int minOperations(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        int req = nums.size() - 1 , ans = nums.size() - 1, n =nums.size();
        vector<int> d = duplicates(nums);
        for(int ptr = 0; ptr < n-1 ;ptr++ ){
            int idx = lower_bound(nums.begin(), nums.end(), req + nums[ptr]) - nums.begin();
            if(idx < n ){
                int val = nums[ptr] + req;
                if(nums[idx] != val)
                    ans = min(ans, n - idx + ptr + d[idx] - d[ptr]);
                else
                    ans = min(ans, n - idx + ptr - 1 + d[idx] - d[ptr]);
            } 
            else
                ans = min(ans, d[n-1] - d[ptr]+ptr);
        }
        return ans;

    }
};
// given two strings s1 and s2 (|s1| == |s2|) make s1 same as s2 using following 2 operations 
// 1. swap any two elements at indices i and j in s1 with cost x ,
// 2. swap two adjacent elements with cost 1
// achieve this with minimum cost 

 
#define pb push_back 

class Solution {
public:
    vector<double> dp;
    double findMin(vector<int>& diff, int i, int x){
        if( i == 0)
            return x / 2.0;
        if( i == -1)
            return 0;
        if(dp[i] != -1)
            return dp[i];
        double left  = findMin(diff, i-1, x) + x/2.0;
        double right = findMin(diff, i-2 , x) + diff[i] - diff[i-1];
        return dp[i] = min(left, right);
    }
    int minOperations(string s1, string s2, int x) {
        vector<int> diffs;
        int n = s1.length();
        for(int i = 0; i < n; i++)
            if(s1[i] != s2[i])
                diffs.pb(i);
        if(diffs.size() & 1)
            return -1;
        dp.resize(diffs.size(),-1);
        return (int)findMin(diffs, diffs.size() - 1, x);
        
    }
};
// Its O(n) time and O(n) space;
/*----------------------------*/
bool isPrime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
bool isvowel(char c){return (c=='a'||c=='e'||c=='i'||c=='o'||c=='u');}
bool isperfect(long long num){int count = 0;while (num & count<11) {count += num % 10;num /= 10;}return count == 10;}
/*----------------------------*/
#define ll long long
#define dd double
#define vi  vector<int> 
#define vvi vector<vector<int>>
#define mi map<int,int>
#define pr  pair<int,int>
#define unset unordered_set<int>
#define ff first
#define ss second
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define fr(i,a,n) for(int i=a; i<n; i++)
const int MOD=1e9+7;

#include<bits/stdc++.h>
using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    return 0;
}
    // for sophon opencv, the memory is not continuous if the width of image is not 64 bytes aligned
    uint8_t continous_data[cvmat.cols * cvmat.rows * cvmat.channels()];
    if (!cvmat.isContinuous())
    {
        std::cout << "cvmat is not continuous" << std::endl;
        for (int i = 0; i < cvmat.rows; i++)
        {
            std::memcpy(continous_data + i * cvmat.cols * cvmat.channels(), cvmat.ptr(i), cvmat.cols * cvmat.channels());
        }
    }
    else
    {
        std::memcpy(continous_data, cvmat.data, cvmat.cols * cvmat.rows * cvmat.channels());
    }
bool isEven(Node* head){
            Node* fast = head;
            while(fast && fast->next) fast=fast->next->next;
            if(!fast )
                return true;
            return false;
    }
#include <iostream>
using namespace std;

int getGcd(int a, int b) {
  
  while(b!=0) {
    int rem = a%b;
    a=b;
    b=rem;
  }
  return a;
}

int main() 
{
    int a,b,gcd;
    cin>>a>>b;
    gcd = getGcd(a, b);
    cout<<gcd;
    return 0;
}
#include <iostream>
using namespace std;

void primeFactorsSieve(int n) {
  int spf[n]={0};
  
  for(int i=2;i<=n;i++) {
    spf[i]=i;
  }
  
  for(int i=2;i<=n;i++) {
    if(spf[i]==i) {
      for(int j=i*i;j<=n;j+=i) {
        if(spf[j]==j) {
          spf[j]=i;
        }
      }
    }
  }
  
  while(n!=1) {
    cout<<spf[n]<<" ";
    n=n/spf[n]; 
  }
}

int main() 
{
    int n;
    cin>>n;
    primeFactorsSieve(n);
    return 0;
}
#include <iostream>
using namespace std;

void primeSieve(int n) {
  int prime[100]={0};
  int cnt=0;
  
  for(int i=2;i<=n;i++) {
    if(prime[i]==0) {
      for(int j=i*i;j<=n;j+=i) {
        prime[j]=1;
      }
    }
  }
  cout<<"\nNumbers: ";
  for(int i=2;i<=n;i++) {
    if(prime[i]==0) {
      cout<<i<<" ";
      cnt++;
    }
  }
  cout<<"\nTotal prime numbers: "<<cnt;
  cout<<endl;
}

int main() 
{
    // cout << "Hello, World!";
    int n;
    cin>>n;
    primeSieve(n);
    return 0;
}
from collections import deque

visited_states = []
total_moves = 70
expanded = 0
count = 0

class Node:
    def __init__(self, state, parent, operator, depth, cost):
        self.state = state
        self.parent = parent
        self.operator = operator
        self.depth = depth
        self.cost = cost

def create_node(state, parent, operator, depth, cost):
    return Node(state, parent, operator, depth, cost)

def expand_node(node):
    expanded_nodes = []
    
    temp_state = move_down(node.state)
    temp_node = create_node(temp_state, node, "down", node.depth + 1, node.cost + 1)
    expanded_nodes.append(temp_node)

    temp_state1 = move_up(node.state)
    temp_node1 = create_node(temp_state1, node, "up", node.depth + 1, node.cost + 1)
    expanded_nodes.append(temp_node1)

    temp_state2 = move_left(node.state)
    temp_node2 = create_node(temp_state2, node, "left", node.depth + 1, node.cost + 1)
    expanded_nodes.append(temp_node2)

    temp_state3 = move_right(node.state)
    temp_node3 = create_node(temp_state3, node, "right", node.depth + 1, node.cost + 1)
    expanded_nodes.append(temp_node3)

    return expanded_nodes

def move_left(state):
    swap = state.copy()
    idx = swap.index(0)
    if (idx == 0 or idx == 3 or idx == 6):
        return swap
    else:
        swap[idx - 1], swap[idx] = swap[idx], swap[idx - 1]
        return swap

def move_right(state):
    swap = state.copy()
    idx = swap.index(0)
    if (idx == 2 or idx == 5 or idx == 8):
        return swap
    else:
        swap[idx + 1], swap[idx] = swap[idx], swap[idx + 1]
        return swap

def move_up(state):
    swap = state.copy()
    idx = swap.index(0)
    if (idx == 0 or idx == 1 or idx == 2):
        return swap
    else:
        swap[idx - 3], swap[idx] = swap[idx], swap[idx - 3]
        return swap

def move_down(state):
    swap = state.copy()
    idx = swap.index(0)
    if (idx == 6 or idx == 7 or idx == 8):
        return swap
    else:
        swap[idx + 3], swap[idx] = swap[idx], swap[idx + 3]
        return swap

def bfs(start, goal):
    if (start == goal):
        return [None]
    else:
        to_be_expanded = []
        current_node = create_node(start, None, None, 0, 0)
        to_be_expanded.append(current_node)

        for i in range(total_moves):
            temp_expanded = []
            size = len(to_be_expanded)

            for j in range(size):
                if (to_be_expanded[j] in visited_states):
                    continue

                node_array = expand_node(to_be_expanded[j])

                for x in range(4):
                    if (node_array[x].state == goal):
                        count = i + 1
                        return node_array[x]
                    else:
                        temp_expanded.append(node_array[x])
                        visited_states.append(node_array[x].state)

            to_be_expanded.clear()
            to_be_expanded = temp_expanded.copy()
            temp_expanded.clear()

    return None

def main():
    method = 'bfs'
    length = 0
    x = 0
    x = x + 1

    board_input = input("Enter the initial state values (comma-separated): ")
    board_split = board_input.split(',')
    starting_state = [int(i) for i in board_split]

    goal_input = input("Enter the goal state values (comma-separated): ")
    goal_split = goal_input.split(',')
    goal_state = [int(i) for i in goal_split]

    if (len(starting_state) == 9 and len(goal_state) == 9):
        result = bfs(starting_state, goal_state)
        if result == None:
            print("No solution found")
        elif result == [None]:
            print("Start node was the goal!")
        else:
            print("Total number of moves needed =", result.cost)
            path = []
            path.append(result.state)
            current = result
            flag = True

            while flag:
                parent = current.parent
                prev_state = parent.state
                path.append(prev_state)
                current = parent

                if (prev_state == starting_state):
                    flag = False

            path.reverse()
            print("Step-wise Sequence of states from start to goal is ")
            for state in path:
                print(state[0], "|", state[1], "|", state[2])
                print(state[3], "|", state[4], "|", state[5])
                print(state[6], "|", state[7], "|", state[8])
                print()
    else:
        print("Invalid input")

if __name__ == "__main__":
    main()


The introduction of computerized technology in the healthcare sector - the promised to bring a qualitative change to patient one. While in various ways there was a bump in the service they received, patients should have experienced higher value all over the board. 

Let’s see some of the examples of integration of Healthcare and blockchain technology. 

Remote Patient Monitoring (RPM)

RMP should to have allowed the shift from episodic to preventative healthcare delivery. This should have been feasible with proactive patient monitoring with "Internet of Things" (IoT) approved devices. The RMP market is predicted to reach $535 Million in united states. RMP devices collect PHI, which needs protection, therefore, a private blockchain is the right choice in this case.
Smart contracts on this private blockchain analyze patient health data.

Electronic Medical Records (EMRs)

EMRs record patient data in the format of electronical, that should have reduced the requirement of paper-based processes. This should have permitted multiple healthcare providers to seamlessly access patient data. This was supposed to significantly enhance the provision of healthcare services. To secure EMRs, Medicalchain uses Hyperledger Fabric, an enterprise blockchain.

There are many healthcare blockchain business ideas that have significant potential. However, integrating any of these ideas is a complex process. Blockchain development requires a lot of expertise and planning, so you might want to get proficient help.
#include <iostream>
using namespace std;

string ending(int sum, int cash) {
  const string s = "купюр";
  const string end1 = "a";
  const string end2 = "ы";
  string banknote;

  sum /= cash;

  if (sum > 4 && sum < 21 || sum > 24 && sum % 10 > 4 
    && sum % 10 <= 9 && sum % 10 == 0 || sum == 0) banknote = s;
  if (sum == 1 || sum % 10 == 1) banknote = s + end1;
  if (sum > 1 && sum < 5 || sum % 10 > 1 
    && sum % 10 < 5)  banknote = s + end2;
  
  return banknote;
}

int remainder(int sum, int cash) {
  sum -= 1;

  if (sum >= 100 && sum != 0 && sum / cash != 0) {
    cout << sum / cash << " - " << ending(sum, cash) << " " << cash << " руб.\n";
  }
  return sum;
}

int main() {
  system("clear");
  
  int sum;
  cout << "Введите сумму, которую хотите обналичить : ";
  cin >> sum;
  sum += 1;
  
  if (sum > 100 && sum < 150000 && sum % 100 == 1) {

    int cash = 5000;
    remainder(sum, cash);
      cash = 2000; sum = sum % 5000;
    remainder(sum, cash);
      cash = 1000; sum = sum % 2000;
    remainder(sum, cash);
      cash = 500; sum = sum % 1000;
    remainder(sum, cash);
      cash = 200; sum = sum % 500;
    remainder(sum, cash);
      cash = 100; sum = sum % 200;
    remainder(sum, cash);

  } else {
    cout << "Не корректная сумма для вывода денег.";
  }
}
#include <iostream>
using namespace std;

int main() 
{
  int mansCount;
  int barbersCount;
  int mansPerBarber = 8; // один человек в час, смена 8 часов
  int mansPerBarberPerMonth = mansPerBarber * 30;
/*
mansCount;               - КолМужчин
barbersCount;            - КолБарберов
mansPerBarber            - КолПодстриженныхЗаСмену
mansPerBarberPerMonth    - КолПодстриженныхЗаМесяц
NecessaryNumberBarbers   - НеобходимоеКолБарберов
BarbersRequired          - ТребуемыеБарберы
*/
  cout << "\n************ Барбершоп-калькулятор ************\n\n";
back:
  cout << "Введите число мужчин в городе: ";
  cin >> mansCount;
  if (mansCount <= 0) {
    cout << "\nВы не можете ввести нулевое или отрицательное значение...\n";
    cout << "Попробуйте ещё раз.\n\n";
    goto back;
  }
back1:
  cout << "Сколько уже барберов удалось нанять? ";
  cin >> barbersCount;
  if (barbersCount <= 0) {
    cout << "\nВы не можете ввести нулевое или отрицательное значение...\n";
    cout << "Попробуйте ещё раз.\n\n";
    goto back1;
  }
  
  cout << "\nОдин барбер стрижёт " << mansPerBarberPerMonth << " клиентов в месяц.\n";

  // Сколько нужно барберов, чтобы постричь mansCount человек?
  int NecessaryNumberBarbers = mansCount / mansPerBarberPerMonth;
  
  if (NecessaryNumberBarbers * mansPerBarberPerMonth % mansCount) {
    NecessaryNumberBarbers += 1;
  }
  
  cout << "Необходимое число барберов: " << NecessaryNumberBarbers << "\n\n";

    const string b = "барбер";
    const string end1 = "a";
    const string end2 = "ов";
  
    string endin;
    int n = NecessaryNumberBarbers;
    if (n == 1 || (n > 20 && n % 10 == 1)) endin = b;
    else if (n > 1 && n < 5 || n > 20 && n % 10 > 1 && n % 10 < 5) endin = b + end1;
    else endin = b + end2;

  // Сколько человек успеют посчтричь NecessaryNumberBarbers за месяц?
  cout << NecessaryNumberBarbers << " " << endin << " могут постричь " 
  << NecessaryNumberBarbers * mansPerBarberPerMonth << " мужчин за месяц.\n";

    string ending;
    int nb = NecessaryNumberBarbers - barbersCount;
    if (nb == 1 || (nb > 20 && nb % 10 == 1)) ending = b;
    else if (nb > 1 && nb < 5 || nb > 20 && nb % 10 > 1 && nb % 10 < 5) ending = b + end1;
    else ending = b + end2;

  int BarbersRequired = NecessaryNumberBarbers - barbersCount;

  if (NecessaryNumberBarbers > barbersCount) {
    cout << "Требуется ещё " << BarbersRequired << " " << ending << ".\n";
  } else if (NecessaryNumberBarbers == barbersCount) {
    cout << "Барберов ровно столько, сколько нужно!!!\n";
  } else if (barbersCount % NecessaryNumberBarbers == 0) {
    cout << "У вас работает в " << barbersCount / NecessaryNumberBarbers << " раза больше барберов, чем это нужно!!!\n";
  } else cout << "Барберов хватает!!!\n";
}
#include <iostream>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
// #include<bits/stdc++.h>
using namespace std;
#define forn(i, a, n) for (int i = a; i < n; i++)
#define MAXN 1000000
#define MOD 1000000007
#define int long long
#define tc    \
    int t;    \
    cin >> t; \
    while (t--)
#define TC size(arr) / size(arr[0])
#define mp make_pair
#define Radhe ios::sync_with_stdio(false);
#define Krishna cin.tie(NULL);

int Time = 0;
vector<pair<int, int>> br;
set<pair<int, int>> res;

vector<int> low, disc;
vector<vector<int>> adj;

void dfsBR(int u, int p)
{
    low[u] = disc[u] = ++Time;
    for (int &v : adj[u])
    {
        if (v == p)
            continue; // we don't want to go back through the same path.
                      // if we go back is because we found another way back
        if (!disc[v])
        {
            res.insert({u, v});
            // if V has not been discovered before
            dfsBR(v, u);          // recursive DFS call
            if (disc[u] < low[v]) // condition to find a bridge
                br.push_back({u, v});

            low[u] = min(low[u], low[v]); // low[v] might be an ancestor of u
        }
        else // if v was already discovered means that we found an ancestor
        {
            if (low[u] >= disc[v])
            {
                low[u] = min(low[u], disc[v]); // finds the ancestor with the least discovery time
                res.insert({u, v});

            }else{
                if(res.find({v,u})==res.end()){
                    res.insert({u,v});
                }
            }

        }
    }
}

void BR()
{
    low = disc = vector<int>(adj.size(), 0);
    Time = 0;
    for (int u = 0; u < adj.size(); u++)
    {
        if (!disc[u])
        {
            dfsBR(u, u);
        }
    }
}

void solve()
{
    int n, m;
    cin >> n >> m;
    adj.resize(n);
    forn(i, 0, m)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    BR();

    if (br.size())
    {
        cout << 0 << endl;
        return;
    }

    // cout<<br.size()<<endl;
    for (auto &x : res)
    {
        cout << x.first + 1 << " " << x.second + 1 << endl;
    }
}
int32_t main()
{
    Radhe Krishna
    {
        solve();
    }

    return 0;
}
// adj[u] = adjacent nodes of u
// ap = AP = articulation points
// p = parent
// disc[u] = discovery time of u
// low[u] = 'low' node of u

int dfsAP(int u, int p) {
  int children = 0;
  low[u] = disc[u] = ++Time;
  for (int& v : adj[u]) {
    if (v == p) continue; // we don't want to go back through the same path.
                          // if we go back is because we found another way back
    if (!disc[v]) { // if V has not been discovered before
      children++;
      dfsAP(v, u); // recursive DFS call
      if (disc[u] <= low[v]) // condition #1
        ap[u] = 1;
      low[u] = min(low[u], low[v]); // low[v] might be an ancestor of u
    } else // if v was already discovered means that we found an ancestor
      low[u] = min(low[u], disc[v]); // finds the ancestor with the least discovery time
  }
  return children;
}

void AP() {
  ap = low = disc = vector<int>(adj.size());
  Time = 0;
  for (int u = 0; u < adj.size(); u++)
    if (!disc[u])
      ap[u] = dfsAP(u, u) > 1; // condition #2
}
   for(int k=0;k<26;k++){
        for(int j=0;j<26;j++){
            for(int i=0;i<26;i++){
                if(W[i][k]!=3000 && W[k][j]!=3000)
                W[i][j]=min(W[i][j],W[i][k]+W[k][j]);
            }
        }
    }
#include <iostream>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
// #include<bits/stdc++.h>
using namespace std;
#define forn(i, a, n) for (int i = a; i < n; i++)
#define MAXN 1000000
#define MOD 1000000007
#define INT_MAX 1e12
#define int long long
#define tc    \
    int t;    \
    cin >> t; \
    while (t--)
#define TC size(arr) / size(arr[0])
#define Radhe ios::sync_with_stdio(false);
#define Krishna cin.tie(NULL);
void solve()
{
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> adj(n);
    map<pair<int, int>, int> mp;
    vector<int> par(n, -1);
    for (int i = 0; i < m; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        if (u == v)
        {
            continue;
        }
        if (v < u)
        {
            swap(u, v);
        }
        u--, v--;
        
        
        if (mp.count({u, v}))
        {
            mp[{u, v}] = min(mp[{u, v}], w);
        }
        else
        {
            mp[{u, v}] = w;
        }
    }
    
for  (auto i = mp.begin(); i != mp.end(); i++) 
    { auto x=*i;
        adj[x.first.first].push_back({x.first.second,x.second});
        adj[x.first.second].push_back({x.first.first,x.second});
    }

    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
    vector<int> dist(n, INT_MAX);
    dist[0] = 0;
    pq.push({0, {0, -1}});
    while (!pq.empty())
    {
        int u = pq.top().second.first;
        if(pq.top().first>dist[u])
        {
            pq.pop();
            continue;
        }
        par[u] = pq.top().second.second;
        pq.pop();
        for (auto it : adj[u])
        {
            int v = it.first;
            int weight = it.second;
            if (dist[u] == INT_MAX)
            {
                continue;
            }
            if (dist[v] > dist[u] + weight)
            {
                dist[v] = dist[u] + weight;
                pq.push({dist[v], {v, u}});
            }
        }
    }
   
    if(dist[n-1]==INT_MAX)
    {
        cout<<-1<<endl;
        return;
    }
    vector<int> ans;
    int i = n - 1;
    while (i != -1)
    {
        ans.push_back(i + 1);
        i = par[i];
    }
    for(int i=ans.size()-1;i>0;i--)
    {
        cout<<ans[i]<<" ";
    }
    cout<<ans[0]<<endl;
}
int32_t main()
{
    Radhe Krishna
    {
        solve();
    }

    return 0;
}
#include <iostream>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
// #include<bits/stdc++.h>
using namespace std;
#define forn(i, a, n) for (int i = a; i < n; i++)
#define MAXN 1000000
#define MOD 1000000007
#define int long long
#define tc    \
    int t;    \
    cin >> t; \
    while (t--)
#define TC size(arr) / size(arr[0])
#define mp make_pair
#define Radhe ios::sync_with_stdio(false);
#define Krishna cin.tie(NULL);

vector<vector<int>> graph;
int tot = 0;

void findComponent(int u, vector<int> &disc, vector<int> &lowLink, stack<int> &stk, vector<bool> &stkItem)
{
    static int time = 0;
    disc[u] = lowLink[u] = ++time;
    stk.push(u);
    stkItem[u] = true;

    for (auto x : graph[u])
    {
        {
            if (disc[x] == -1)
            {
                findComponent(x, disc, lowLink, stk, stkItem);
                lowLink[u] = min(lowLink[u], lowLink[x]);
            }
            else if (stkItem[x])
                lowLink[u] = min(lowLink[u], disc[x]);
        }
    }
    int poppedItem = 0;

    if (lowLink[u] == disc[u])
    {
        int co = 0;

        while (stk.top() != u)
        {
            poppedItem = stk.top();
            co++;
            stkItem[poppedItem] = false;
            stk.pop();
        }
        poppedItem = stk.top();
        co++;
        stkItem[poppedItem] = false;
        stk.pop();

        if (co > 1)
        {
            tot += co;
        }
    }
}

void strongConComponent(vector<vector<int>> &graph)
{
    int v = graph.size();
    vector<int> disc(v, -1), lowLink(v, -1);
    vector<bool> stkItem(v, false);
    stack<int> stk;

    for (int i = 0; i < v; i++)
        if (disc[i] == -1)
            findComponent(i, disc, lowLink, stk, stkItem);
}

void solve()
{

    tot = 0;
    int n;
    cin >> n;
    graph = vector<vector<int>>(n);
    forn(i, 0, n)
    {
        char x;
        cin >> x;
        if (x == '<')
        {
            graph[(i + 1) % n].push_back(i);
        }
        else if (x == '>')
        {
            graph[i].push_back((i + 1) % n);
        }
        else
        {
            graph[i].push_back((i + 1) % n);
            graph[(i + 1) % n].push_back(i);
        }
    }

    strongConComponent(graph);
    cout << tot << endl;
}
int32_t main()
{
    Radhe Krishna
        tc
    {
        solve();
    }

    return 0;
}
// br = bridges, p = parent

vector<pair<int, int>> br;

int dfsBR(int u, int p) {
  low[u] = disc[u] = ++Time;
  for (int& v : adj[u]) {
    if (v == p) continue; // we don't want to go back through the same path.
                          // if we go back is because we found another way back
    if (!disc[v]) { // if V has not been discovered before
      dfsBR(v, u);  // recursive DFS call
      if (disc[u] < low[v]) // condition to find a bridge
        br.push_back({u, v});
      low[u] = min(low[u], low[v]); // low[v] might be an ancestor of u
    } else // if v was already discovered means that we found an ancestor
      low[u] = min(low[u], disc[v]); // finds the ancestor with the least discovery time
  }
}

void BR() {
  low = disc = vector<int>(adj.size());
  Time = 0;
  for (int u = 0; u < adj.size(); u++)
    if (!disc[u])
      dfsBR(u, u)
}
Bitcoin Miner Script holding a hash algorithm that executes the mining activity in a simple and effective way. Whenever a user tries to access the data for transactions, the script verifies the ledger system automatically that matches the private key to proceed with the transactions. The Bitcoin miner script is developed with the ability to support other features that includes:

Payment gateways
Ticket system
Plan management
Genealogy
Multiple currencies
Promotional banners
E-pin generation facility
Multiple languages

It was a Good approach to move ahead based on the up-gradation of technology. The usage of cryptocurrencies are really high, so that the opportunities to create a business website are in good state to yield benefits as well. Visit Best bitcoin miner script to know more about the ideal features of the script. 

> https://maticz.com/bitcoin-mining-script
#include <bits/stdc++.h>
using namespace std;

// Main function to run the program
int main() 
{ 
    int arr[] = {10, 30, 10, 20, 10, 20, 30, 10}; 
    int n = sizeof(arr)/sizeof(arr[0]); 

    int visited[n];

    for(int i=0; i<n; i++){

        if(visited[i]!=1){
           int count = 1;
           for(int j=i+1; j<n; j++){
              if(arr[i]==arr[j]){
                 count++;
                 visited[j]=1;
              }
            }

            cout<<arr[i]<<" occurs at "<<count<<" times "<<endl;
         }
     }

    return 0; 
}
#include <stdio.h>
#include <string.h>

#define MAX_ATTEMPTS 3
#define MAX_USERS 5
#define MAX_USERNAME_LENGTH 20
#define MAX_PASSWORD_LENGTH 20

typedef struct {
    char username[MAX_USERNAME_LENGTH];
    char password[MAX_PASSWORD_LENGTH];
} User;

int main() {
    User users[MAX_USERS] = {
        {"user1", "pass1"},
        {"user2", "pass2"},
        {"user3", "pass3"},
        {"user4", "pass4"},
        {"user5", "pass5"}
    };

    int attempts = 0;
    int authenticated = 0;

    while (attempts < MAX_ATTEMPTS && !authenticated) {
        char inputUsername[MAX_USERNAME_LENGTH];
        char inputPassword[MAX_PASSWORD_LENGTH];

        printf("Enter username: ");
        scanf("%s", inputUsername);
        printf("Enter password: ");
        scanf("%s", inputPassword);

        for (int i = 0; i < MAX_USERS; i++) {
            if (strcmp(inputUsername, users[i].username) == 0 && strcmp(inputPassword, users[i].password) == 0) {
                authenticated = 1;
                break;
            }
        }

        if (!authenticated) {
            attempts++;
            printf("Authentication failed, try again.\n");
        }
    }

    if (authenticated) {
        printf("Authentication successful.\n");
    } else {
        printf("Limit exceeded. Exiting.\n");
    }

    return 0;
}
class Solution {
public:
    vector<int> countBits(int n) {
        vector<int> v(n+1, 0);
        for(int i=1;i<=n;i++)
        {
            int p=i;
            int t=32;
            int ans=0;
            
            while(p!=0)
            {
                int rsbm = p&-p;
                p-=rsbm;
                ans++;
            }
            v[i]=ans;
        }
        return v;
    }
};
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
        char *cat="/bin/cat";
    if(argc<2)
        {
                printf("Please type a file name.\n");
                return 1;
        }
     char *command =malloc(strlen(cat) + strlen(argv[1]) + 2);
        sprintf(command,"%s %s", cat,argv[1]);
        system((command));
        return 0;
}
Developing a Rummy Game can be a lucrative endeavor, But it is important to consider its various factors such as the game’s design, complexity, platform compatibility, and back-end infrastructure all crucially determine the overall expenditure. Hiring freelance rummy game developers or partnering with a proficient rummy game development company can also impact the final price tag.

A simple Rummy game with important features and minimalistic graphics could set you back anywhere from $10000 to $40000. On the other hand, if your vision includes an intricate, cross-platform game with attractive visuals, the cost will be up to $35000 to $200000 or more., Thus, before you initiate looking for rummy game developers for hire, you must first determine what you are planning to build.

https://maticz.com/rummy-game-development
#include <bits/stdc++.h>

using namespace std;

struct node {
  int data;
  struct node * left, * right;
};

vector < int > postOrderTrav(node * cur) {

  vector < int > postOrder;
  if (cur == NULL) return postOrder;

  stack < node * > st;
  while (cur != NULL || !st.empty()) {

    if (cur != NULL) {
      st.push(cur);
      cur = cur -> left;
    } else {
      node * temp = st.top() -> right;
      if (temp == NULL) {
        temp = st.top();
        st.pop();
        postOrder.push_back(temp -> data);
        while (!st.empty() && temp == st.top() -> right) {
          temp = st.top();
          st.pop();
          postOrder.push_back(temp -> data);
        }
      } else cur = temp;
    }
  }
  return postOrder;

}

struct node * newNode(int data) {
  struct node * node = (struct node * ) malloc(sizeof(struct node));
  node -> data = data;
  node -> left = NULL;
  node -> right = NULL;

  return (node);
}

int main() {

  struct node * root = newNode(1);
  root -> left = newNode(2);
  root -> right = newNode(3);
  root -> left -> left = newNode(4);
  root -> left -> right = newNode(5);
  root -> left -> right -> left = newNode(8);
  root -> right -> left = newNode(6);
  root -> right -> right = newNode(7);
  root -> right -> right -> left = newNode(9);
  root -> right -> right -> right = newNode(10);

  vector < int > postOrder;
  postOrder = postOrderTrav(root);

  cout << "The postOrder Traversal is : ";
  for (int i = 0; i < postOrder.size(); i++) {
    cout << postOrder[i] << " ";
  }
  return 0;
}
#include <vector>
#include <stack>

using namespace std;

// Definition for a binary tree node.
struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};

class Solution {
public:
    vector<int> inorderTraversal(TreeNode* root) {
        stack<TreeNode*> st;
        vector<int> inorder;

        TreeNode* node = root;

        while (true) {
            if (node != nullptr) {
                st.push(node);
                node = node->left;
            } else {
                if (st.empty())
                    break;

                node = st.top();
                st.pop();
                inorder.push_back(node->val);

                node = node->right;
            }
        }

        return inorder;
    }
};
#include <vector>
#include <stack>

using namespace std;

// Definition for a binary tree node.
struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};

class Solution {
public:
    vector<int> preorderTraversal(TreeNode* root) {
        vector<int> preorder;

        if (root == nullptr)
            return preorder;

        stack<TreeNode*> st;
        st.push(root);

        while (!st.empty()) {
            root = st.top();
            st.pop();
            preorder.push_back(root->val);

            if (root->right != nullptr) {
                st.push(root->right);
            }

            if (root->left != nullptr) {
                st.push(root->left);
            }
        }

        return preorder;
    }
};
//level order traversal ---->  lecture 8 striver 

#include <vector>
#include <queue>

using namespace std;

// Definition for a binary tree node.
struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};

class Solution {
public:
    vector<vector<int>> levelOrder(TreeNode* root) {
        vector<vector<int>> ans;

        if (root == nullptr)
            return ans;

        queue<TreeNode*> q;
        q.push(root);

        while (!q.empty()) {
            int size = q.size();
            vector<int> level;

            for (int i = 0; i < size; i++) {
                TreeNode* node = q.front();
                q.pop();

                if (node->left != nullptr)
                    q.push(node->left);
                if (node->right != nullptr)
                    q.push(node->right);

                level.push_back(node->val);
            }

            ans.push_back(level);
        }

        return ans;
    }
};

//iterative preorder traversal
Blockchain businesses have gained tremendous popularity in the upcoming years. Many companies are showing keen interest in the field of blockchain, so it is the perfect time for blockchain to rise. Because blockchain is a distributed and p2p technology, its major benefits, and application can be found in almost every sector. You can turn this blockchain use into your Blockchain business idea if you solely understand the technology.


​#include <iostream>

using namespace std;

int main()
{
    int a,b,s;
    cin >>a>>b;
    s=a+b;
    cout <<s;

    return 0;
}
Are you interested in the crypto world and want to explore new ways of trading? Do you have a knack for coding and want to develop your own crypto trading bot? If yes, you have come to the right place! Creating a crypto trading bot from scratch can sound threatening, but it is quite easier and can potentially yield great results. 

However, for the ultimate security and reliability, it is best to know how to create a trading bot for crypto if you want to make Bitcoin trading a significant portion of your revenue. Want to create your own crypto trading bot? Then Maticz can assist you to build your own trading bot in a hassle-free manner. Check out the website and get more information via >> https://maticz.com/how-to-create-a-crypto-trading-bot
Video games are a massive industry with over 59 billion USD in sales in 2015. The process of creating a video game is much more complicated than you might think, that involves a number of various disciplines and cross-generational teamwork. We have broken down the process into its component pieces so that you can see what roles each team member plays to make something like Overwatch possible.

Early Pre production:

Art Direction
Gameplay Design
Planning
Documents
Designing
Testing
Implementation
Product release

Post Production:

Marketing
Distribution
Support
Post Maintainance
End of Life

This is when the next generation of video games may be created, and when a game is retired, it is no longer eligible for future development. However, the developers may continue to work on it, but without official support.

#include <iostream>
using namespace std;

bool prompt_yes_or_no(const string& question) {
    cout << question << " (Y/N): ";
    char response;
    cin >> response;
    return (response == 'Y' || response == 'y');
}

void join_farm_out_project_teams() {
    cout << "Welcome to our Farm-out project teams!" << endl;
}

int main() {
    if (prompt_yes_or_no("Are you inspired to make the world a better place?")
        && prompt_yes_or_no("Do you want to be part of projects that cover the entire process, "
                            "from edge to cloud and from driver to (front-end) application?")
        && prompt_yes_or_no("Do you want to work on (big scaled) high-tech systems?")
        && prompt_yes_or_no("Do you enjoy responsibility and leadership roles?")
        && prompt_yes_or_no("Do you love challenges in complex architecture for distributed systems?")) {
        join_farm_out_project_teams();
    } else {
        cout << "Thank you for considering us! Keep exploring new opportunities!" << endl;
    }

    return 0;
}
for i=1 to n
   for j=1 to n    
     c[i][j]=0
     for k=1 to n
         c[i][j] = c[i][j]+a[i][k]*b[k][j]
Peer to Peer (P2) Cryptocurrency exchanges have emerged as a popularized and innovative solution for trading digitalized assets. Startups seeking to enter the crypto market can greatly benefit from investing in P2P Crypto exchange development. Let’s see the process included in P2P Exchange development:

Decentralized Trading Experience

Startups can leverage this decentralized trading experience to attract users who value privacy, security, and control over their assets. By offering a platform that facilitates direct peer-to-peer transactions, startups can differentiate themselves from traditional centralized exchanges and tap into a growing demand for decentralized trading solutions.

Enhanced Trust and Security

P2P Crypto Exchanges prioritize security by integrating features such as Multi-factor Authentication, Bitcoin escrow script services, and smart contracts, These security measures instill trust among users.

Market Access Globally

Developing a P2P Crypto exchange has a globalized reach, allowing startups to target users from various regions and countries. By supporting multi languages and local payment methods, startups can assure accessibility and inclusivity for a diverse user base. 

Revenue Generation

P2P crypto exchanges provide various avenues for revenue generation. Startups can implement transaction fees, listing fees, premium memberships, or even integrate advertisement opportunities. 

Benefits of P2P Exchange Development

Investing in P2P exchange development can provide startups with a competitive edge in the cryptocurrency industry. By offering a decentralized trading experience, enhanced security and trust, global market access, and revenue generation opportunities, startups can position themselves as innovative players in the market. However, to ensure a successful development process, it is crucial for startups to hire a reliable and experienced P2P exchange development company.

Partnering with a professional P2P exchange development company is essential for startups aiming to create a robust and feature-rich platform. These companies possess expertise in blockchain technology, security protocols, and user experience design. They can guide startups through the entire development process, from conceptualization to deployment, ensuring a seamless and efficient launch.

In conclusion, startups should seize the opportunity presented by P2P crypto exchange development. By investing in this innovative solution, startups can establish themselves as key players in the evolving cryptocurrency landscape and unlock significant growth potential in the digital asset trading industry.
vector<vector<int>> dp;
Solution(): dp(1000, vector<int>(1000,-1));
int knapSack(int W, int wt[], int val[], int n) {
  if(W==0 || n==0) return 0;
  if(dp[W][n]!=-1) return dp[W][n];
  if(wt[n-1]<=W){
    return dp[W][n]=max(
      val[n-1]+knapSack(W-wt[n-1], wt, val, n-1),
      knapSack(W, wt, val, n-1)
    );
  } else {
    return dp[W][n]=knapSack(W, wt, val, n-1);
  }
}
int knapSack(int W, int wt[], int val[], int n) 
{ 
   if(W==0 || n==0) return 0;
   if(wt[n-1]<=W){
       return max(
         val[n-1] + knapSack(W-wt[n-1], wt, val, n-1), 
         knapSack(W, wt, val, n-1)
       );
   }
   else {
       return knapSack(W, wt, val, n-1);
   }
}
The future of Binance Clone Script in the crypto industry looks promising. With the increasing popularity of cryptocurrencies, many businesses and individuals are looking to enter the market. Binance Clone script provides an effortless and cost-effective way for entrepreneurs to launch their own crypto exchange platforms. Initiating a thriving binance clone business requires careful planning and execution. Here are some of the tips that can assist entrepreneurs to launch a successful Binance clone business:

Market Research

Conduct detailed market research to identify the target audience and competition. This will assist entrepreneurs to understand the market trends and customer needs.

Choose the proper script

Prefer a highly reliable and trustworthy Binance clone script provider that renders cutting-edge security features and customizable options. 

Licensing & Jurisdictions

Make sure that the crypto exchange platform complies with the legal and regulatory needs of the country where the business operates. 

User Experience

The success of a Binance-like platform relies heavily on its user experience. It is crucial to prioritize user-friendliness and ease of navigation to assure that the platform is intuitive and easy to use.

Marketing

Develop a comprehensive marketing strategy to reach out to potential customers. Use various marketing channels, such as social media, email marketing, and advertising, to promote the platform.
class Solution {
public:
    using ll = long long;
    int countBits(ll x){
        int cnt = 0;
        while(x > 0){
            cnt += (x&1);
            x>>=1;
        }
        return cnt;
    }
    int makeTheIntegerZero(int num1, int num2) {
        if(num1 < num2)
            return -1;
        ll x = num1;
        for(int i = 0; i <= 100; i++){
            ll val = x - (ll)i*num2;
            int cnt_ones = countBits(val);
            if(cnt_ones <= i && i <= val)
                return i;
        }
        return -1;
    }
};
void print(TrieNode* root, string t,vector<string>& s ){
        int cnt_nulls = 0;
        for(int i = 0; i < 26; i++){
            if(root->v[i] != NULL){
                char c = (i + 'a');
                // cout << c << endl;
                t.push_back(c);
                print(root->v[i] , t, s);
                t.pop_back();
            }
            else cnt_nulls++;
        }
        if(cnt_nulls == 26)
            s.push_back(t);
    }
class Solution {
  public:
    map<int,int> deno{
        {5,0},
        {10,0},
        {20,0}
    };
    bool canCreateDeno(int x){
       for(auto i = deno.rbegin(); i != deno.rend();i++){
           if(i->second > 0 ){
               int times = (x / i->first);
               times = min(times, i->second);
               x -= times * i->first;
               i->second -= times;
           }
       } 
       return x == 0;
    }
    bool lemonadeChange(int N, vector<int> &bills) {
        // code here
        for(int i = 0 ; i < N; i++){
            int x = bills[i] - 5;
            if(x == 0){
                deno[bills[i]]++;
            }
            else{
                bool f = canCreateDeno(x);
                if(!f)
                    return false;
                deno[bills[i]]++;
            }
        }
        return true;
    }
};
class Solution{
    public:
    // arr: input array
    // n: size of array
    //Function to rearrange an array so that arr[i] becomes arr[arr[i]]
    //with O(1) extra space.
    void arrange(long long v[], int n) {
        // Your code here
        for(int i= 0; i < n; i++){
            if(v[i] >= 0){
                int val = -v[i], ini = i, p = i;
                while( v[p] != ini){
                    int t = v[p];
                    v[p] = v[t];
        		    if(v[p] == 0)
        			    v[p] = INT_MIN;
        		    else
        			    v[p] *= -1;
            		p = t;
                }
                v[p] = val;
            }
        }
        for(int i= 0; i <n ;i++)
            if(v[i] != INT_MIN)
                v[i] *= -1;
            else
                v[i] = 0;
    }
};
class Solution {
public:
    const int mod = 1e9 + 7;
    int m, n;
    vector<int> dx{1,0,0,-1},dy{0,1,-1,0};
    bool isValid(int x, int y){
        return x >= 0 and x < m and y >= 0 and y < n;
    }
    int dfs(int x, int y, vector<vector<int>>& grid, vector<vector<int>>& dp){
        if(dp[x][y] != -1)
            return dp[x][y];
        int ans = 1;
        for(int i = 0; i < 4; i++){
            int x_ = x + dx[i], y_ = y + dy[i];
            if(isValid(x_, y_) and grid[x_][y_] >grid[x][y])
                ans = (ans%mod + dfs(x_,y_,grid, dp)%mod)%mod;
        }
        return dp[x][y] = ans;
    }
    int countPaths(vector<vector<int>>& grid) {
        m = grid.size(), n = grid[0].size();
        vector<vector<int>> dp(m + 1, vector<int> ( n + 1, -1));
        int ans = 0;
        for(int i = 0; i < m; i++)
            for(int j = 0;j <n ;j++)
                ans = (ans%mod + dfs(i, j,grid, dp));
        return ans;
    }
};
class Solution {
public:
    int numOfWays(vector<int>& nums) {
        int m = nums.size();
        
        table.resize( m + 1);
        for(int i = 0; i < m + 1; ++i){
            table[i] = vector<long long> (i+1, 1);
            for(int j = 1; j < i ; ++j)
                table[i][j] = (table[i-1][j-1] + table[i-1][j])%mod;
        }
        return (dfs(nums) - 1) % mod;
    }
private:
    vector<vector<long long>> table;
    long long mod = 1e9+7;
    
    long long dfs(vector<int>& nums){
        int m = nums.size();
        if( m  < 3)
            return 1;
        vector<int> leftNodes, rightNodes;
        for(int i = 1; i < m ; i++){
            if( nums[i] < nums[0])
                leftNodes.push_back(nums[i]);
            else
                rightNodes.push_back(nums[i]);
        }
        long long leftWays = dfs(leftNodes) % mod;
        long long rightWays = dfs(rightNodes) % mod;
        return (((leftWays * rightWays) % mod) * table[m-1][leftNodes.size()])%mod;
    }
};
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int ARRAY_SIZE = 100;

int *R; 

void generateRandomNumbers() {
    int i;
    R = (int *)malloc(ARRAY_SIZE * sizeof(int));
    if (R == NULL) {
        printf("Memory allocation failed.\n");
        exit(1);
    }

    srand(time(NULL));
    for (i = 0; i < ARRAY_SIZE; i++) {
        R[i] = i + 1;
    }

    for (i = ARRAY_SIZE - 1; i > 0; i--) {
        int j = rand() % (i + 1);
        int temp = R[i];
        R[i] = R[j];
        R[j] = temp;
    }
}

int encrypt(int p) {
    int i, c = 0;
    for (i = 0; i < p; i++) {
        c += R[i];
    }
    return c;
}

int decrypt(int c) {
    int i, sum = 0;
    for (i = 0; i < ARRAY_SIZE; i++) {
        sum += R[i];
        if (sum >= c) {
            return i + 1;
        }
    }
    return -1;
}

int main() {
    int plainValues[] = {92, 95, 22};
    int cipher[] = {0,0,0};

    generateRandomNumbers();

    printf("Encryption:\n");
    for (int i = 0; i < 3; i++) {
        cipher[i] = encrypt(plainValues[i]);
        printf("Plain: %d\tCipher: %d\n", plainValues[i], cipher[i]);
    }

    printf("\nDecryption:\n");
    for (int i = 0; i < 3; i++) {
        int plain = decrypt(plainValues[i]);
        printf("Cipher: %d\tPlain: %d\n",cipher[i] , plainValues[i]);
    }

    free(R); // Free the allocated memory

    return 0;
}
class Solution {
public:
    typedef long long ll;
    
    int maxLevelSum(TreeNode* root) {
        vector<int> levels(1e5, 0);
        queue<pair<int,TreeNode*>> q;
        if(!root)
            return 0;
        q.push({0, root});
        int lvls_reached = 0;
        while(!q.empty()){
            auto node(q.front().second);auto lvl(q.front().first);
            q.pop();
            levels[lvl] += node->val;
            lvls_reached = max(lvls_reached, lvl);
            if(node->left)
                q.push({lvl + 1, node->left});
            if(node->right)
                q.push({lvl + 1, node->right});
        }
        ll maxi = LLONG_MIN;
        int ans = -1;
        for(int i = 0; i <=lvls_reached; i++)
            if(levels[i] > maxi)
                ans = i, maxi = levels[i];
        return ans + 1;
    }
};
class Solution {
  public:
    string longestPalin (string S) {
        // code here
        if(S.length() == 0)
            return "";
        string ans;
        pair<int,int> r{0,0};
        int len = 1, n = S.length();
        for(int i = 0 ; i < n; i++){
            int j = i, k =i;
            while(j-1 >= 0 && k+1 < n){
                if(!(S[j-1] == S[k+1]))
                    break;
                j--,k++;
            }
            int l1 = k - j + 1;
            pair<int,int> p1{j,k},p2{i,i};
            int l2 = 1;
            if( i +1 < n){
                bool f = (S[i] == S[i+1]);
                if(f){
                    j = i, k = i+1;
                    while( j-1 >=0 && k+1 < n){
                        if(!(S[j-1] == S[k+1]))
                            break;
                        j--,k++;
                    }
                    l2 = k - j + 1;
                    p2 = {j,k};
                }
            }
            if(len < max(l1,l2)){
                len = max(l1,l2);
                r = (l1 > l2)?p1:p2;
            }
        }
        for(int i = r.first; i<=r.second;i++)
            ans += S[i];
        return ans;
    }
};
class Solution{
    public:
int randomPartition(int arr[], int l, int r)
    {
        int n = r-l+1;
        int pivot = rand() % n;
        swap(arr[l + pivot], arr[r]);
        return partition(arr, l, r);
    }
    int kthSmallest(int arr[], int l, int r, int k)
    {
        // If k is smaller than number of elements in array
        if (k > 0 && k <= r - l + 1)
        {
            // find a position for random partition
            int pos = randomPartition(arr, l, r);
            
            // if this pos gives the kth smallest element, then return
            if (pos-l == k-1)
                return arr[pos];
                
            // else recurse for the left and right half accordingly
            if (pos-l > k-1)  
                return kthSmallest(arr, l, pos-1, k);
            return kthSmallest(arr, pos+1, r, k-pos+l-1);
        }
    
        return INT_MAX;
    }
     
    // partitioning the array along the pivot
    int partition(int arr[], int l, int r)
    {
        int x = arr[r], i = l;
        for (int j = l; j <= r - 1; j++)
        {
            if (arr[j] <= x)
            {
                swap(arr[i], arr[j]);
                i++;
            }
        }
        swap(arr[i], arr[r]);
        return i;
    }
};
​#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long rez;
    rez = 1LL * n * (n + 1) / 2;
    cout << rez;
    return 0;
}
class Solution
{
    public:
    //Function to find the maximum number of meetings that can
    //be performed in a meeting room.
    int maxMeetings(int start[], int end[], int n)
    {
        // Your code here
        using pi = pair<int,int> ;
        vector<pi> vp;
        for(int i = 0; i < n; i++)
            vp.push_back({start[i] , end[i]});
        sort(vp.begin(), vp.end(),[](auto a, auto b){
           return a.second < b.second; 
        });
        int ans = 0, r = INT_MIN;
        for(int  i =0 ; i < n ; i++){
            if(vp[i].first > r){
                ans++;
                r = vp[i].second;
            }
        }
        return ans;
    }
};
    void print(vector<int>& v){
        for(auto ele : v)
            cout << ele << " ";
        cout<< endl;
    }
    void backtrack(int index, vector<int> ans){
        if(index == (ans.size() - 1)){
            print(ans);
            return;
        }
        for(int i = index; i < ans.size(); i++){
            swap(ans[index], ans[i]);
            backtrack(index+1, ans);
            swap(ans[index], ans[i]);
        }
    }
class Solution {
  public:
    //Function to return a list of indexes denoting the required 
    //combinations whose sum is equal to given number.
    void solve(int indx, int target, vector<int> &A, vector<vector<int>> &ans, vector<int> ds){
        if(target==0){ 
    		ans.push_back(ds);
    		return;
    	}
    	//returning if conditions are out of bound.
    	if(target<0 || indx>=A.size()) 
    		return;
        
        ds.push_back(A[indx]);
        solve(indx, target-A[indx], A, ans, ds);
        ds.pop_back();
        solve(indx+1, target, A, ans, ds);
    }
    
    vector<vector<int> > combinationSum(vector<int> &A, int B) {
        // Your code here
        vector<int> ds;
        vector<vector<int>> ans;
        sort(A.begin(), A.end());
        solve(0, B, A, ans, ds);
    }
};
#include <iostream>
#include <vector>

class Person {
public:
    Person(int id) : id(id) {}

    int getId() const {
        return id;
    }

private:
    int id;
};

class Building {
public:
    Building(int levels) : levels(levels) {
        constructBuilding();
    }

    void constructBuilding() {
        int totalPeople = (1 << levels) - 1; // Calculate the total number of people in the building
        people.resize(totalPeople);

        // Create people with their respective IDs
        for (int i = 0; i < totalPeople; ++i) {
            people[i] = Person(i + 1);
        }
    }

    void exitOrder() {
        for (int i = levels - 1; i >= 0; --i) {
            int levelOffset = (1 << i) - 1; // Offset for each level
            int levelSize = (1 << i); // Number of people on each level

            for (int j = 0; j < levelSize; ++j) {
                int personIndex = levelOffset + j;
                std::cout << people[personIndex].getId() << " ";
            }
        }
        std::cout << std::endl;
    }

    void entryOrder() {
        for (int i = 0; i < levels; ++i) {
            int levelOffset = (1 << i) - 1; // Offset for each level
            int levelSize = (1 << i); // Number of people on each level

            for (int j = 0; j < levelSize; ++j) {
                int personIndex = levelOffset + j;
                std::cout << people[personIndex].getId() << " ";
            }
        }
        std::cout << std::endl;
    }

private:
    int levels;
    std::vector<Person> people;
};

int main() {
    int levels;
    std::cout << "Enter the number of levels in the building: ";
    std::cin >> levels;

    Building building(levels);

    std::cout << "Exit Order: ";
    building.exitOrder();

    std::cout << "Entry Order: ";
    building.entryOrder();

    return 0;
}
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;


struct Client{
    string name;
    int phoneNumber;
};

class HashTable {
public:
    static const int size=10;
    Client table[size];
    int collisions[size];
    
    int hash(int key) { return key%size; }
    
    HashTable() { for(int i=0;i<size;i++) collisions[i]=0; }
    
    //function for linear probing
    void linearprobing(Client client){
     
    int index=hash(client.phoneNumber);
    int count=0;
    
    while(collisions[index]==1){
        index=(index+1)%size;
        count++;
    }
    
    table[index]=client;
    collisions[index]=1;
    cout<<"Inserted "<<client.name<<"'s phone number after "<<count<<" collisions using linear probing."<<endl;
 }
  
//function for quadratic probing  
 void quadraticprobing(Client client){
     
    int index=hash(client.phoneNumber);
    int count=0;
    while(collisions[index]!=0 && collisions[index]!=client.phoneNumber){
        count++;
        index=(hash(client.phoneNumber)+count*count)%size;
    }
    table[index]=client;
    collisions[index]=1;
    cout<<"Inserted "<<client.name<<"'s phone number after "<<count<<" collisions using quadratic probing."<<endl;
 }
 
 bool search(int phoneNumber){
    int index=hash(phoneNumber);
    int count=0;
    while(collisions[index]!=0) {
        if(table[index].phoneNumber==phoneNumber){
            cout<<"Found "<<table[index].name<<"'s phone number after "<<count <<" comparisons using linear probing."<< endl;
            return true;
        }
        index=(index+1)%size;
        count++;
    }
    cout<<"Phone number not found."<<endl;
    return false;
}
    
};


int main()
{
    HashTable ht;
    int number;
    string name;
    int x=11, y;
    
    while(x!=0){
        cout<<"\n1.INSERT NUMBER\n2.SEARCH NUMBER\n0.EXIT\nEnter your choice:";
        cin>>x;
 
        switch(x){
            
                case 1:
                  cout<<"\nEnter name:";
                  cin>>name;
                  cout<<"Enter number:";
                  cin>>number;
                  cout<<"\n\n1.Linear probing\n2.Quadratic probing\nEnter your option:";
                  cin>>y;
            
                  if(y==1) ht.linearprobing({name, number});
                  else if(y==2) ht.quadraticprobing({name, number});
                  else cout<<"Error! invalid option\n\n";
                break;
                
                case 2:
                  cout<<"\nEnter number to search:";
                  cin>>number;
                  ht.search(number);
                break;
                
                case 0:
                  cout<<"\nExiting\n\n";
                break;
                
                default:
                  cout<<"\nInvalid choice!!\nEnter again\n\n";
                break;
                }
    }
 return 0;
}
//code heapsort

#include<iostream>
#include<algorithm>
using namespace std;

class Heap{
    int n;
    int *minheap, *maxheap;
    
    public:
    void get();
    void displaymin(){
        cout <<"minimum number is: "<<maxheap[0]<<endl;
    }
    void displaymax(){
        cout<<"maximun number is: "<<minheap[0]<<endl;
    }
    void upadjust(bool,int);
};

void Heap::get(){
    cout<<"enter the number of entries you want: ";
    cin >> n;
    minheap= new int[n];
    maxheap= new int[n];
    
    cout <<"enter numbers :"<<endl;
    for(int i=0; i<n; i++){
        int k;
        cin >>k;
        minheap[i]=k;
        upadjust(0,i);
        maxheap[i]=k;
        upadjust(1,i);
    }
}

void Heap::upadjust(bool m, int l){
    int s;
    if(!m){
        while(minheap[(l-1)/2]<minheap[l]){
            swap(minheap[l], minheap[(l-1)/2]);
            l=(l-1)/2;
            
            if(l== -1) break;
        }
      
    }else{
        while(maxheap[(l-1)/2]>maxheap[l]){
            swap(maxheap[l], maxheap[(l-1)/2]);
            l=(l-1)/2;
            
            if(l== -1) break;
        }
    }
}



int main(){
    int choice;
    cout<<"1. min heap"<<endl;
    cout<<"2. max heap"<<endl;
    cout<<"enter your choice: "<<endl;
    cin >>choice;
    
    Heap h;
    
    switch(choice){
        case 1:
            h.get();
            h.displaymax();
            break;
        case 2:
            h.get();
            h.displaymax();
            break;
        return(0);
    }
    
    return 0;
}
#include <iostream>
#include<queue>
#include <string>
using namespace std;

struct patient{
    string name;
    int priority;
};

bool operator<(const patient &a, const patient &b){return a.priority<b.priority;}

int main(){
    priority_queue<patient> q;
    
    int choice;
    do{
        cout<<"1. add patient"<<endl;
        cout<<"2. treat patient"<<endl;
        cout<<"3. exit"<<endl;
        cout<<"enter your choice: "<<endl;
        cin>>choice;
        
        switch(choice){
            case 1:
            {
                patient p;
                cout<<"enter patient name: "<<endl;
                cin>>p.name;
                cout<<"priority-> 1. serious 2. non serious 3. general checkup\n enter priority"<<endl;
                cin >>p.priority;
                q.push(p);
                cout<<"patient added successfully"<<endl;
            }
            break;
            
            case 2:
            {
                if(q.empty()){cout<<"no patient in the queue"<<endl;}
                else{cout<<"serving patient "<<q.top().name<<endl;}
                q.pop();
            }
            break;
            
            case 3:cout<<"thank you! visit again!"<<endl;
            break;
            
            default:cout<<"Enter a valid choice"<<endl;
        }
    }while(choice!=3);
    
    return 0;
}
class UnionFind 
{
    public: 
    vector<int> parent,count;
    UnionFind(int n){
        parent.resize(n, -1);
        count.resize(n, 1);
    }
    int find(int x){
        return (this->parent[x] == -1)? x : find(this->parent[x]);
    }
    void Union(int a, int b){
        int pA = find(a) , pB = find(b);
        if(pA != pB){
            this->parent[pB] = pA;
            this->count[pA] += this->count[pB];
        }
        
    }
};
#include <bits/stdc++.h>
using namespace std;

int solve(vector<vector<int>>& dp, int idx, int cw, int w, vector<int>& v)
{
   if(cw==w) return ++dp[idx][cw];
   if(cw>w||idx==v.size()) return 0;
   if(dp[idx][cw]!=0) return dp[idx][cw];
   
   return dp[idx][cw]=solve(dp, idx+1, cw+v[idx], w, v)+solve(dp, idx+1, cw, w, v);
}

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int n, w;
	        cin>>n>>w;
	        vector<int>a(n);
	        for(int i=0;i<n;i++)
	        {
	           cin>>a[i];
	        }
	        vector<vector<int>> dp(n+1, vector<int>(w+1, 0));
	        int ans = solve(dp, 0, 0, w, a);
	        cout<<ans;
	}
	return 0;
}
class Solution {
    using Index = pair<int, int>;
    vector<Index> directions =
    {
        {-1, -1},
        {-1, 0},
        {-1, 1},
        {0, -1},
        {0, 1},
        {1, -1},
        {1, 0},
        {1, 1}
    };

public:
    int shortestPathBinaryMatrix(vector<vector<int>>& grid)
    {
        const int n = grid.size();
        if (grid[0][0] == 1 || grid[n - 1][n - 1] == 1)
            return -1;

        if (n == 1)
            return 1;
        
        int distance = 1;
        Index target = {n - 1, n - 1};
        queue<Index> q;
        q.push({0, 0});
        grid[0][0] = 1;
        while (!q.empty())
        {
            const int levelSize = q.size();
            for (int i = 0; i < levelSize; i++)
            {
                Index curr = q.front();
                q.pop();
                for (const Index& diff : directions)
                {
                    Index next = {curr.first + diff.first, curr.second + diff.second};
                    if (next.first >= 0 && next.first < n && next.second >= 0 && next.second < n 
                        && grid[next.first][next.second] == 0)
                    {
                        if (next == target)
                            return distance + 1;
                        grid[next.first][next.second] = 1;
                        q.push(next);
                    }
                }
            }
            distance++;
        }
        return -1;
    }
};
	vector<int> topoSort(int V, vector<int> adj[]) 
	{
	    // code here
	    vector<int> res;
	    vector<int> indegree( V , 0);
	    
	    for(int i = 0 ; i < V ; i++)
	        for(int nbr : adj[i])
	            indegree[nbr]++;
        queue<int> q;
        for(int i = 0; i < V; i++)
            if(indegree[i] == 0)
                q.push(i);
        
        while(!q.empty()){
            int curr = q.front(); q.pop();
            res.push_back(curr);
            for(int nbr : adj[curr])
                if(--indegree[nbr] == 0)
                    q.push(nbr);
        }
        return res;
	}
 template <typename T> std::string type_name();
        const char f = 'C';
    int maxLen(vector<int>&A, int n)
    {   
        // Your code here
        unordered_map<long long ,int> uMap;
        uMap.insert({0, 1});
        int ans = 0 ;
        long long currSum = 0;
        for(int i = 0 ; i < n ; i++){
            currSum += A[i];
            if(uMap[currSum] > 0)
                ans = max(ans, i - uMap[currSum]  + 2);
            else
                uMap[currSum] = i + 2;
        }
        return ans;
    }
    int LargButMinFreq(int arr[], int n) {
        // code here
        priority_queue<int> pq;
        for(int i = 0; i < n ; i++){
            pq.push(arr[i]);
        }
        int ans = 0,minFreq = INT_MAX;
        while(!pq.empty()){
            int val = pq.top(),freq = 1;
            pq.pop();
            while(!pq.empty() && pq.top() == val){
                pq.pop() , freq++;
            }
            if(freq < minFreq)
                minFreq = freq, ans = val;
        }
        return ans;
    }
void print(vector<int>& arr){
		for(auto ele : arr)
			cout<<ele<<" ";
		cout<<endl;
		}
	void maxHeapify(int i, vector<int>& arr, int n){
		vector<int> arr = this->arr;
		int left = 2*i + 1 , right = 2*i+2;
		int largest = i;
		if( left < n && arr[left] > arr[largest])
			largest = left;
		if(right < n && arr[right] > arr[largest])
			largest = right;
		if(largest != i){
			swap(arr[largest] , arr[i]);
			maxHeapify(largest, arr , n);
		}
	}

	void formMaxHeap(vector<int>& arr){
		int n = arr.size();
		int r = (n/2) -1;
		for(int i = r; i>=0; i--){
			maxHeapify(i, arr, n);
		}
	}
	int extract_max(vector<int>& arr){
		int val = arr.front();
		swap(arr.front(), arr.back());
		arr.pop_back();
		int size= arr.size();
		maxHeapify(0, arr, size);
		return val;
	}
	void heapSort(vector<int>& arr){
		int n = arr.size() ;
		formMaxHeap(arr);
		for(int r  = n-1 ; r > 0 ; r--){
			swap(arr[0], arr[r]);
			maxHeapify(0, arr, r );
		}

	}
    int uniquePaths(int m, int n) {
        int N = m + n - 2, r = min(m, n)-1;
        long long p = 1;
        for(int i = 1 ; i <= r; i++){
            p = (p *(N - i + 1))/i;
        }
        return p;
    }
class Solution {
public:

    bool solve(vector<int>& nums, int sum, int curr, int idx, vector<vector<int>>& dp)
    {
        if(curr==sum) return true;
        if(curr>sum||idx==nums.size()) return false;
        if(dp[curr][idx]!=-1) return dp[curr][idx];
        bool ck=false;

        ck=ck|solve(nums, sum, curr+nums[idx], idx+1, dp);
        ck=ck|solve(nums, sum, curr, idx+1, dp);
        return dp[curr][idx]=ck;
    }

    bool canPartition(vector<int>& nums) {
        int s=0;
        int n=nums.size();
        
        for(int i=0;i<n;i++)
        {
            s+=nums[i];
        }
        vector<vector<int>> dp(s+1, vector<int>(nums.size(), -1));
        if(s%2==1) return false;
        
        else return solve(nums, s/2, 0, 0, dp);

    }
};
class Solution {
  public:
  class TrieNode{
    public:
        vector<TrieNode*> v;
        int indices ;
        
        TrieNode(){
            v.resize(26,NULL);
            indices = -1;
        }
        ~TrieNode(){
            v.clear();
        }
    };
    void dfs(TrieNode* curr, vector<string>& ans,vector<string>& Dictionary){
        if(curr->indices != -1)
            ans.push_back(Dictionary[curr->indices]);
        for(int i = 0 ; i < 26; i++){
            if(curr->v[i] != NULL)
                dfs(curr->v[i], ans, Dictionary);
        }
    }
    void push(string word,TrieNode* root ){
        static int i =0;
        TrieNode* currRoot = root;
        for(char letter:word){
            if(letter >='a' && letter <='z')
                continue;
            letter = tolower(letter);
            if(currRoot->v[letter - 'a'] == NULL)
                currRoot->v[letter - 'a'] = new TrieNode();
            currRoot = currRoot->v[letter-'a'];
        }
        currRoot->indices = i++;
    }

    vector<string> CamelCase(int N, vector<string> Dictionary, string Pattern) {
        // code here
        TrieNode* root = NULL;
        root = new TrieNode();
        for(auto word : Dictionary){
            push(word, root);
        }
        TrieNode* curr = root;
        for(auto chr : Pattern){
            chr = tolower(chr);
            if(curr->v[chr-'a'] == NULL)
                return {"-1"};
            curr = curr->v[chr- 'a']; 
        }
        vector<string> ans;
        dfs(curr, ans,Dictionary);
        return ans;
    }
};
class Solution{   
public:

    bool solve(vector<int>&arr, int sum, int curr, int idx, vector<vector<int>>& dp)
    {
        if(curr==sum) return true;
        if(curr>sum||idx==arr.size()) return false;
        if(dp[curr][idx]!=-1) return dp[curr][idx];
        bool ck=false;
        ck=ck|solve(arr, sum, curr+arr[idx], idx+1, dp);
        ck=ck|solve(arr, sum, curr, idx+1, dp);
        return dp[curr][idx]=ck;
        
    }
    
    bool isSubsetSum(vector<int>arr, int sum){
        // code here 
        vector<vector<int>> dp(100000, vector<int> (arr.size(), -1));
       return solve(arr, sum, 0, 0, dp);
    }
};
    int maxIncreasingCells(vector<vector<int>>& mat) {
        int n = mat.size(), m = mat[0].size();
        unordered_map<int,vector<pair<int,int>>> mp;
        set<int> st;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                mp[mat[i][j]].push_back({i,j});
                st.insert(-mat[i][j]);
            }
        }
        vector<vector<int>> val(n, vector<int>(m));
        vector<int> rowPath(n), colPath(m);
        for(auto num : st){
            num = -num;
            for(auto pos : mp[num]){
                int r = pos.first;
                int c = pos.second;
                val[r][c] = max(rowPath[r], colPath[c]) + 1;
            }
            
            for(auto pos : mp[num]){
                int r = pos.first;
                int c = pos.second;
                rowPath[r] = max(rowPath[r], val[r][c]);
                colPath[c] = max(colPath[c], val[r][c]);
            }
        }
        int ans = 0;
        for(auto len : rowPath)
            ans = max(len ,ans);
        for(auto len : colPath)
            ans = max(len , ans);
        return ans;
    }
int getNthFromLast(Node *head, int n)
{
       // Your code here
       Node* front = head; 
       while(front && n--)front = front->next;
       if(n>0)
        return -1;
       Node* rear = head;
       while(front){
           front = front->next;
           rear = rear->next;
       }
       return rear->data;
}
vector<int> sieve(int n){
    int size = sqrt(n);
    bool primes[size+1];
    memset(primes,true,size+1);
    primes[0] = primes[1] = false;
    for(int i = 2; i <= size; i++){
        if(primes[i]){
            int k = 2;
            while(i*k <= size){
                primes[i*k] = false;
                k++;
            }
        }
    }
    vector<int> ans;
    for(int i = 0 ; i<= size; i++)
        if(primes[i])
            ans.push_back(i);
    return ans;

}
    int solve(int ind ,pair<int,int> alphaBeta, vector<int>& stoneValue, bool isAlice ,pair<int,int> points ={0,0}){
        if(ind >= stoneValue.size()){
            if(points.first == points.second)
                return 0;
            return points.first > points.second ? 1 : -1;
        }
        if(isAlice){
            int maxi = INT_MIN;
            int score = points.first;
            for(int i = ind; i < ind+3 && i < stoneValue.size(); i++){
                score += stoneValue[i];
                int eva = solve(i+1,alphaBeta,stoneValue, !isAlice,{score, points.second});
                maxi = max(maxi, eva);
                alphaBeta.first = max(alphaBeta.first, maxi);
                if(alphaBeta.second <= alphaBeta.first)
                    break;
            }
            return maxi;
        }
        else{
            int mini = INT_MAX;
            int score = points.second;
            for(int i = ind; i < ind+3  && i < stoneValue.size(); i++){
                score += stoneValue[i];
                int eva = solve(i+1,alphaBeta,stoneValue, !isAlice,{points.first, score});
                mini = min(mini, eva);
                alphaBeta.second = min(mini, alphaBeta.second);
                if(alphaBeta.second <= alphaBeta.first)
                    break;
            }
            return mini;
        }
    }
        if(!head || head->next  == NULL)
            return head;
        Node* fast = head->next->next,*slow = head;
        while(fast->next && fast->next->next){
            fast = fast->next->next;
            slow = slow->next;
        }
        if(fast != NULL)
            slow = slow->next;
        Node* head2 = reverse(slow->next);
        slow->next =  NULL;
    Node* reverse(Node* head){
        if(!head || !head->next){
            return head;
        }
        Node* newHead = reverse(head->next);
        head->next->next = head;
        head->next = NULL;
        return newHead;
    }
class Solution {
public:
    int nextGreaterElement(int n) {
       string s=to_string(n);
       next_permutation(s.begin(),s.end());
       if(stoll(s)>n&&stoll(s)<=INT_MAX)
       {
          return stoll(s);
       }
       return -1;

    }
};
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int n=s.size();
        int cnt[256]={0};
        int i=0, j=0, ans=0;
        while(j<n)
        {
            cnt[s[j]]++;
            while(cnt[s[j]]>1)
            {
                cnt[s[i]]--;
                i++;
                
            }
            ans=max(ans, j-i+1);
            j++;
        }
        return ans;
    }
};
void printFibonacci(int n) {
    FILE* file = fopen("/var/www/vusers/TIFACyournameone/Fib.txt", "w");
    if (file == NULL) {
        printf("Failed to open file\n");
        return;
    }

    int fib1 = 0;
    int fib2 = 1;
    int fib;
    fprintf(file, "%d\n%d\n", fib1, fib2);

    for (int i = 2; i < n; i++) {
        fib = fib1 + fib2;
        fprintf(file, "%d\n", fib);
        fib1 = fib2;
        fib2 = fib;
    }

    fclose(file);
    printf("Fibonacci series written to Fib.txt\n");
}

int main() {
    int n;
    printf("Enter the number of Fibonacci series terms: ");
    scanf("%d", &n);
    printFibonacci(n);
    return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

int main()
{
    // Vector of integers
    std::vector<int> vecObj {11, 12, 13, 14, 15, 16, 12, 43, 12, 13, 11};

    // Sort the values in vector
    std::sort(vecObj.begin(), vecObj.end());

    // Remove duplicate values from vector
    vecObj.erase(std::unique(vecObj.begin(), vecObj.end()), vecObj.end());

    // print all elements of vector
    for(auto elem : vecObj) {
        std::cout<<elem << ", ";
    }

    return 0;
}
void RemoveDuplicate(struct Node *p){
 
  Node *q= first->next;

  while(q!=NULL){
    if(p->data != q->data){
      p=q;
      q=q->next;
    }else{
      p->next= q->next;
      delete q;
      q= p->next;
    }
  }
}
int isSorted(struct Node *p){
  
  x= INT_MIN;

  while(p!=NULL){
    if(p->data<x)
      return false;
    x=p->data;
    p=p->next;
  }
  return true;
}
#include <iostream>
#include <string>
using namespace std;

int main()

{
     int yearnow;
     int monthnow;
     int yearborn;
     int monthborn;
     int daynow;
     int dayborn;
     

     
     cout << "Enter the current year: ";
     cin >> yearnow;
     cout << "Enter the current month: ";
     cin >> monthnow;
     cout << "Enter the current day: ";
     cin >> daynow;
     cout << "Enter the year when you were born: ";
     cin >> yearborn;
     cout << "Enter the month when you were born: ";
     cin >> monthborn;
     cout << "Enter the day when you were born: ";
     cin >> dayborn;
     
     int yearactual = yearnow - yearborn;
     
     if (monthborn > monthnow){
             
             cout << "You are " << yearactual - 1 << " years old\n";
             cout << "You are " << 12 - (monthborn - monthnow) - 1 << " months old\n";
             cout << "And " << daynow << " days old";
         
     }
     if (monthborn < monthnow){
         if (daynow > dayborn){
             
             cout << "You are " << yearactual << " years old\n";
             cout << "You are " << monthnow - monthborn << " months old\n";
             cout << "And " << daynow - dayborn << " days old";
             
         }
         if (daynow < dayborn){
             
              cout << "You are " << yearactual << " years old\n";
             cout << "You are " << monthnow - monthborn - 1<< " months old\n";
             cout << "And " << daynow << " days old";
             
         }
         if (daynow == dayborn){
             
              cout << "You are " << yearactual << " years old\n";
             cout << "You are " << monthnow - monthborn << " months old\n";
             cout << "And " << "0" << " days old";
             
         }
         
     }
      if (monthborn == monthnow){
         cout << "You are " << yearactual << " years old\n";
         cout << "You are " << "0" << " months old\n";
         cout << "And " << daynow << " days old";
     }
     
     
     
     return 0;
}
int Delete(struct Node *p, int index){
  Node *q;
  int x=-1 , i;
  
  if(index < 1 || index >count(p))
    return -1;
  
  if(index==1){
    x=first->data;
    q=first;
    first=first->next;
    delete q;
    return x;
  } 
  else{
    for(i=0; i<index-1 && p; i++){
      q=p;
      p=p->next;
    }
    q->next=p->next;
    x=p->data;
    delete p;
    return x;
    }
}
void SortedInsert(struct Node *p, int x){
  
  struct Node *t, *q= NULL;
  t= (struct Node *)malloc(sizeof(struct Node));
  t->data= x;
  t->next= NULL;
  
  if (first == NULL)
    first = t;
  else{
    while(p && p->data <x){
      q=p;
      p=p->next;
      }
    if (p==first){
      t->next=first;
      first=t;
    } else {
      t->next = q->next;
      q->next= t;
    }
  }
}
void InsertLast(int x){
  Node *t = x;
  t->data= x;
  t->next= NULL;
  if(first==NULL){
    first= last= t;
  } else {
    last->next= t;
    last=t;
  }
}
void Insert(int pos, int x){
  Node *t, *p;
  if(pos==0){
    t= new Node;
    t->data= x;
    t->next= first;
    first= t;
  }
  else if(pos>0){
    p = first;
    for(i=0; i<pos-1; i++)
      p=p->next;
    if(p){
      t= new Node;
      t->data= x;
      t->next = p->next;
      p->next= t;
    }
  }
}
//inserting a new node at the first; at the head of the linked list

Node *t = new Node;
t->data=x;
t->next = first;
first= t;

//inserting a new node after a given node
Node *t= new Node;
t->data= x;
p=first;
for(i=0; i<pos-1; i++){
  p =p->next;
  t->next= p->next;
  p->next= t;
}
//move to front
//improve searching by moving the searched node to the front so that another time it is searched, it will be found in less time
//function for moving a node to the head (in search operation)

Search(Node *p, int key){
  
  Node *q= NULL;
  
  while(p!= NULL){
    if(key==p->data) {
      q-next= p->next;
      p->next= first;
      first = p;
    }
    q= p;
    p=p->next;
  }
}
//iterative
Search(Node *p, int key){
  while(p!=NULL){
    if(key==p->data)
      return p;
    p= p->next;
  }
  return NULL;
}

//recursive
Node* Search(Node *p, int key){
  if(p==NULL)
    return NULL;
  if(key==p->data)
    return p;
  return Search(p->next, key);
}
//MIN_INT= -32768

//iterative function
max(Node *p){
  int m= INT32_MIN;
  while(p){
    if(p->data > m)
      m=p->data;
    p=p->next;
  }
  return m;
}

//recursive function
max(Node *p){
  int x=0;
  if(p==0)
    return INT32_MIN;
  else
    x= max(p->next);
  
  if(x>p->data)
  	return x;
  else
    return p->data;
}
//using iteration
int Add(struct Node *p){
  int sum=0;
  while(p){
    sum= sum+ p->data;
    p= p->next;
  }
  return(sum);
}

//using recursion
int Add(struct node *p){
  if (p==0)
    return(0);
  else
    return Add(p->next) + p->data;
}

//the data will be added at the time of returning
//code for finding number of nodes in a given linked list: recursive

int count(struct Node *p){
int c=0;
	while(p!= 0) {
	c++;
	p=p->next;
	}
return c;
}
// O(n) time complexity and O(1) space complexity

//recursive function for counting number of nodes in a given linked list

int count(struct Node *p){
  if(p==0)
    return 0;
  else
    return count(p->next)+1;
}

// addition will be done at the time of returning.
// time complexity : O(n)
//space complexity : O(n) for stack as it includes recursion
//print in the given order as first the value is printed and then a call is made to the next node

void Display(struct Node *p){
  if (p!= NULL){
    printf("%d", p->data);  //first print
    Display(p->next);       //call next
  }
}

//print in reverse order as first the call is made and then the values are printed

void Display(struct Node *p){
  if (p!= NULL){
    Display(p->next);          //call next
    printf("%d", p->data);     //then print
  }
}
Cryptocurrency development is the process of creating a digital currency that is secured by cryptography and operates independently of a central authority. It involves designing and building a blockchain-based platform that allows for secure, transparent, and decentralized transactions. The cryptocurrency market is rapidly growing, and businesses are increasingly looking to integrate blockchain technology into their operations. A reputable cryptocurrency development company like Shamla Tech can provide valuable expertise and guidance to ensure a successful implementation. Shamla Tech specializes in providing comprehensive blockchain solutions to clients, including the creation of new cryptocurrencies, blockchain-based software applications, and custom smart contract development. 

Know more: https://shamlatech.com/cryptocurrency-development/
#include <stdio.h>
#include <stdlib.h>

struct Node{
    int data;
    struct Node *next;
}*first=NULL;

void create(int A[10], int n){
    int i;
    struct Node *t, *last;
    first = (struct Node *)malloc(sizeof(struct Node));
    first->data=A[0];
    first->next=NULL;
    last=first;
    
    for(i=1;i<n;i++){
        t=(struct Node*)malloc(sizeof(struct Node));
        t->data=A[i];
        t->next=NULL;
        last->next=t;
        last=t;
    }
}

void Display(struct Node *p){
    while(p!=NULL){
        printf("%d ",p->data);
        p=p->next;
    }
}

int main() {
    int A[]={3,5,7,10,15};
    create(A,5);
    Display(first);
  
    return 0;
}
class Solution{
public:
      string maxSum(string w,char x[], int b[],int n){
          // code here        
          unordered_map<char,int> mp;
          for(int i=0;i<w.size();i++)
          {
              mp[w[i]]=int(w[i]);
          }
          for(int i=0;i<n;i++)
          {
              mp[x[i]]=b[i];
          }
          vector<int> v(w.size());
          for(int i=0;i<w.size();i++)
          {
              v[i]=mp[w[i]];
          }
          
          int edx=0, mxl=0, mxg=INT_MIN;
          for(int i=0;i<w.size();i++)
          {
              mxl=max(v[i], v[i]+mxl);
              
              if(mxl>mxg)
              {
                  mxg=mxl;
                  edx=i;
              }
          }
          int sdx=edx;
          while(sdx>=0)
          {
              mxg-=v[sdx];
              if(mxg==0) break;
              if(sdx==0) break;
              sdx--;
          }
          
          
          string ans="";
          for(int i=sdx;i<=edx;i++)
          {
              ans+=w[i];
          }
          return ans;
      }
};
class Solution {
  public:
    long long countBits(long long N) {
        // code here
        long long ans = 0;
        N += 1;
        int D = log2(N) + 1;
        vector<long long> pow2(D+1,0);
        pow2[0] = 1;
        pow2[1] = 2;
        for(int i = 2; i <=D; i++){
            pow2[i] = 2*pow2[i-1];
        }
        for(int i = 1 ; i <= D ; i++){
            long long t = 0;
            int gN = (N + pow2[i] - 1)/pow2[i];
            t += (gN - 1) * pow2[i-1];
            int v = N%pow2[i];
            long long p = (v == 0) ? pow2[i] : v;
            t += max(0LL , p - pow2[i-1]);
            ans += t;
        }
        return ans;
    }
    
};
var currentTab = 0; // Current tab is set to be the first tab (0)
let inputs = []

let eye2 = 0;
var speed = 15;
var text = "";

const content = document.getElementById("content");

var socket = io.connect();

let responses = []
let questionNumber = 0
let quizID = localStorage.getItem("myID");

window.addEventListener('load', function () {

  showTab(currentTab); // Display the current tab

  let testString = "qustion| answer1| answer2| asnwer3| answer4| correct" //test
  // document.getElementById("testButton").addEventListener('click', function test() {
  //   displayQuestions(testString)
  // }) //test
})


function showTab(n) {
  // This function will display the specified tab of the form ...
  var x = document.getElementsByClassName("tab");
  x[n].style.display = "block"; //?
  // ... and fix the Previous/Next buttons:
  if (n == 0) {
    document.getElementById("prevBtn").style.display = "none";
  } else {
    document.getElementById("prevBtn").style.display = "inline";
  }
  if (n == (x.length - 1)) {
    document.getElementById("nextBtn").innerHTML = "Submit";
  } else {
    document.getElementById("nextBtn").innerHTML = "Next";
  }
  // ... and run a function that displays the correct step indicator:
  fixStepIndicator(n)
}

function nextPrev(n) {
  // This function will figure out which tab to display
  var x = document.getElementsByClassName("tab");
  // Exit the function if any field in the current tab is invalid:
  if (n == 1 && !collectResponses()) return false;
  // Hide the current tab:
  x[currentTab].style.display = "none";
  // Increase or decrease the current tab by 1:
  currentTab = currentTab + n;
  console.log("tab is: " + currentTab)
  // if you have reached the end of the form... :
  if (currentTab >= x.length) {
    //...the form gets submitted:


    // do we need to send an ID here?
    let dataToSend = {'user': quizID, 'responses': responses}

    for (let i = 0; i < responses.length; i++){
      console.log(responses[i]);
    }
    // socket.emit('quiz-response', responses)
    socket.emit('quiz-response', dataToSend)
    console.log("sent quiz response" + dataToSend)

    // location.replace("../video.html")

    document.getElementById("regForm").style.display = "none";
    document.getElementById("content").style.display = "block";

    return false;
  }
  // Otherwise, display the correct tab:
  showTab(currentTab);
  collectResponses(currentTab)
}

function collectResponses() {
  var x, y, i, valid = true;
  x = document.getElementsByClassName("tab");
  // y = x[currentTab].getElementsByTagName("button");

  let currentAnswers = "answers" + String(currentTab)

  y = document.getElementsByClassName(currentAnswers)

  let answers = document.getElementsByClassName("answers")
  console.log(answers)


  for (let i = 0; i < answers.length; i++) {
    answers[i].addEventListener("click", function () {
      responses[currentTab] = answers[i].innerHTML
      console.log('responses: ' + responses)
    });
  }

  if (valid) {
    document.getElementsByClassName("step")[currentTab].className += " finish";
  }
  return valid; // return the valid status
}

function fixStepIndicator(n) {
  // This function removes the "active" class of all steps...
  var i, x = document.getElementsByClassName("step");
  for (i = 0; i < x.length; i++) {
    x[i].className = x[i].className.replace(" active", "");
  }
  //... and adds the "active" class to the current step:
  x[n].className += " active";
}

socket.on('question', (data) => {
  console.log("reciving data: " + data.message);
  displayQuestions(data.message)
  questionNumber++
})

  socket.on('summarize', function (data) {
    if (data.id != quizID){
      console.log("wrong person");
      return;}
    console.log("we're receiving a summary!");
    console.log(data.message.length);

    eye2 = 0;
    text = data.message;

    // delete placeholder text
    document.getElementById("content").innerHTML = "";
    // document.getElementById("content").scrollTop = scrollHeight;
    typeText2();
    // </br>
  });


function displayQuestions(data) {

  console.log("data to display: " + data)
  let incomingSting = data
  quesionArray = incomingSting.split('|')

  console.log(quesionArray)

  x = document.getElementsByClassName("tab");

  x[questionNumber].innerHTML = quesionArray[0]

  for (let i = 0; i < 4; i++) {
    let answers = document.createElement("div");

    answers.setAttribute("class", "answers");
    x[questionNumber].appendChild(answers);
    answersDisplay = document.getElementsByClassName("answers")
    answersDisplay[i + questionNumber * 4].innerHTML = quesionArray[i + 1]

    console.log(answers)
  }
  collectResponses()

  responded = false
}

// worst possible implementation of this hhHAHAAH
function typeText2(){
  if (eye2 < text.length) {
    let newText = document.getElementById("content");
    let i = text.charAt(eye2); 
    if (i == '\n'){
        newText.innerHTML += '<br>'  
        newText.scrollTop = newText.scrollHeight;
    } else {
    newText.innerHTML += i;
    }  
     eye2++;

  setTimeout(typeText2, speed);
//   if (eye == text.length){
  }
  else {
    let textContent = document.getElementById("content").textContent;
    const htmlContent = linkify(textContent);
    document.getElementById("content") = htmlContent;
  }
}

// stolen from stackOverflow:
// https://stackoverflow.com/questions/1500260/detect-urls-in-text-with-javascript
function linkify(text) {
  var urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  return text.replace(urlRegex, function(url) {
      return '<a href="' + url + '">' + url + '</a>';
  });
}
.vscode/settings.json

{
  "code-runner.executorMap": {
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -I/usr/local/include -L/usr/local/lib -lglfw -framework OpenGL -lGLEW && $dir$fileNameWithoutExt",
  },
}
#include <iostream>
using namespace std;

int main() {
  int num=3;
  if(num== 1){
    cout<< "hello world 1"<< endl;
  }else if(num==2){
    cout<< "hello world 2"<< endl;
  }else if(num==3){
    cout<< "hello world 3"<< endl;
  }
    else{
    cout<< "hello world"<< endl;
  }
  return 0;
}
// C++ code
#include<iostream>
using namespace std;

int main(){
        for(int i=0 ; i<10000 ; i=i +1){

                cout<<"hello world"<<endl;

    }
    return 0;
}
#pragma once
#include "Array.h"
#include "Array.cpp"

int main() {
	COLOR_GREEN_TEXT
/*******************************************************/
	Array<double> a(5); 
	a.setSize(7, 2); 
	for (size_t i = 0; i < 7; i++)
	{
		a.addElement(rand() % 10); 
	}
	a.showArray();
/*******************************************************/
	cout << "GetElement = " << a.getAt(5) << endl;
/*******************************************************/
	a.setAt(3, 99);
	a.showArray();
	a.setAt(3, 99);
	a.setAt(1, 89);
	a.setAt(10, 59);
	a.showArray();
/*******************************************************/
	a.addElement(rand() % 10);
	a.showArray();
	a.addElement(rand() % 10);
	a.addElement(rand() % 10);
	a.showArray(); 
/*******************************************************/
	cout << "a[] = " << a[7] << endl;
/*******************************************************/
	cout << *(a.getData() + 1) << endl;
/*******************************************************/
	a.insertAt(2, 22);
	a.showArray();
/*******************************************************/
	a.freeExtra(); 
	a.showArray();
/*******************************************************/
	Array<double> b(1);
	b.setSize(3, 2); 
	b.addElement(5); 
	b.addElement(10);
	b.addElement(25);
	b.showArray(); 
/*******************************************************/
	a.Append(b);
	a.addElement(1256);
	a.addElement(854);
	cout << endl; 
	cout << endl;
	cout << endl;
	a.showArray();
/*******************************************************/
	Array<double> c(10);
	c.setSize(5, 3); 
	c = a; 
	cout << endl;
	cout << endl;
	cout << endl;
	c.showArray(); 
/*******************************************************/
	STOP
	return 0; 
}	
// Array.cpp
#pragma once
#include "Array.h"

template<class T>
Array<T>::Array(int SIZE) // CONSTRUCTOR
{
	this->grow = 1;
	this->SIZE = SIZE + grow;
	this->preSIZE = SIZE; 
	this->count = 0; 
	this->arr = new T[this->SIZE]();
}

template<class T>
Array<T>::Array(const Array & other) // CONSTRUCTOR COPY
{
	this->SIZE = other.SIZE; 
	this->arr = new T[this->SIZE]; 
	for (size_t i = 0; i < this->SIZE; i++)
	{
		this->arr[i] = other.arr[i]; 
	}
}

template<class T>
Array<T>::~Array() // DESTRUCTOR
{
	delete[] arr; 
	arr = NULL; 
}

template<class T>
int Array<T>::getSize() // GET SIZE
{
	return this->SIZE; 
}

template<class T>
void Array<T>::setSize(int SIZE, int grow) //SET SIZE
{
	if(grow > 0)
	this->grow = grow; 
	this->SIZE = SIZE + this->grow; 

	if (this->SIZE > this->preSIZE)
	{
		T * buf = new T[this->SIZE]();
		for (size_t i = 0; i < this->preSIZE; i++)
		{
			buf[i] = arr[i]; 
		}
		delete[] arr; 
		arr = new T[this->SIZE](); 
		for (size_t i = 0; i < this->SIZE; i++)
		{
			arr[i] = buf[i]; 
		}
		delete[] buf; 
		this->preSIZE = this->SIZE; 
	}
	else
	{
		T * buf = new T[this->SIZE]();
		for (size_t i = 0; i < this->SIZE - this->grow; i++)
		{
			buf[i] = arr[i];
		}
		delete[] arr;
		arr = new T[this->SIZE]();
		for (size_t i = 0; i < this->SIZE; i++)
		{
			arr[i] = buf[i];
		}
		delete[] buf;
		this->preSIZE = this->SIZE; 
		this->count = this->SIZE - this->grow;
	}
}

template<class T>
void Array<T>::addElement(T element) // ADD ELEMENT
{
	if (count < this->SIZE)
	{
		this->arr[count] = element;
		count++;
	}
	else
	{
		this->SIZE = this->SIZE + this->grow + 1; 
		T * buf = new T[this->SIZE](); 
		for (size_t i = 0; i < this->SIZE - this->grow; i++)
		{
			buf[i] = arr[i]; 
		}
		delete[] arr;
		arr = new T[this->SIZE]();
		for (size_t i = 0; i < this->SIZE; i++)
		{
			arr[i] = buf[i]; 
		}
		delete[] buf; 
		buf = NULL; 
		arr[count] = element; 
		count++;  
	}
}

template<class T>
int Array<T>::getUpperBound() //GET UPPER BOUND
{
	return count - 1;
}

template<class T>
bool Array<T>::isEmpty() // CHECK EMPTY NO YES?
{
	if (count == 0)
		return false;
	else
		return count; 
}

template<class T>
void Array<T>::freeExtra() // FREE EXTRA
{
	T * buf = new T[this->SIZE - this->grow]();
	for (size_t i = 0; i < this->SIZE - this->grow; i++)
	{
		buf[i] = arr[i];
	}
	delete[] arr;
	arr = new T[this->SIZE - this->grow]();
	for (size_t i = 0; i < this->SIZE - this->grow; i++)
	{
		arr[i] = buf[i];
	}
	this->SIZE = this->SIZE - this->grow;
}

template<class T>
void Array<T>::removeAll() // CLEAR ALL
{
	delete[] arr; 
	arr = NULL; 
	this->SIZE = 0; 
	this->preSIZE = 0; 
	this->grow = 0; 
	this->count = 0; 
}

template<class T>
T Array<T>::getAt(int index) // GET AT
{
	if (index <= count)
		return arr[index - 1];
	else
		return false; 
}

template<class T>
void Array<T>::setAt(int index, T element) // SET AT
{
	if (index <= count)
	{
		int iteration = 0; 
		bool flag = true; 
		T * buf = new T[SIZE + 1]();
		for (size_t i = 0; i < SIZE; i++)
		{
			if (i != index)
			{
				buf[iteration] = arr[i];
				iteration++; 
			}
			if(i == index && flag == true)
			{
				buf[iteration] = element; 
				iteration++; 
				buf[iteration] = arr[i]; 
				iteration++; 
				flag = false; 
			}
		}
		delete[] arr; 
		arr = new T[SIZE + 1](); 
		this->SIZE++; 
		count++; 
		for (size_t i = 0; i < this->SIZE; i++)
		{
			arr[i] = buf[i]; 
		}
		delete[] buf; 
	}
}

template<class T>
T & Array<T>::operator[](int index) // OVERLOAD OPERATOR []
{
	if (index <= count)
		return this->arr[index];
	else
		return this->arr[count];
}

template<class T>
void Array<T>::Append(Array<T> ob) // APPEND 
{
	int temp = this->SIZE + ob.getSize();
	int iteration = 0; 
	T * buf = new T[temp]();
	for (size_t i = 0; i < this->SIZE; i++)
	{
		buf[i] = arr[i];
		iteration++;
	}
	for (size_t i = 0; i < ob.SIZE; i++)
	{
		buf[iteration] = ob.arr[i]; 
		iteration++;
	}
	delete[] this->arr; 
	this->arr = new T[temp](); 
	for (size_t i = 0; i < temp; i++)
	{
		this->arr[i] = buf[i]; 
	}
	this->SIZE = temp;
	this->count = (this->SIZE - this->grow); 
	delete[] buf; 
}

template<class T>
T * Array<T>::getData() // GET POINTER ARR
{
	return arr;
}

template<class T>
void Array<T>::insertAt(int index, T element) // INSERT AT
{
	if (index <= count)
	{
		arr[index] = element; 
	}
}

template<class T>
void Array<T>::showArray()
{
	for (size_t i = 0; i < this->SIZE; i++)
	{
		cout << arr[i] << "\t"; 
	}
	cout << endl; 
}

template<class T>
Array<T> & Array<T>::operator=(const Array & ob1) // OVERLOAD OPERATOR = 
{ 
	this->SIZE = ob1.SIZE; 
	delete[] this->arr; 
	this->arr = new T[this->SIZE]; 
	for (size_t i = 0; i < this->SIZE; i++)
	{
		this->arr[i] = ob1.arr[i]; 
	}
	return *this; 
}
//Array.h	
#pragma once
#include "H.h"
template<class T>
class Array
{
public:
	Array(int SIZE);
	Array(const Array & other); 
	~Array();
	int getSize();
	void setSize(int SIZE, int grow = 1);
	void addElement(T element);
	int getUpperBound();
	bool isEmpty();
	void freeExtra();
	void removeAll();
	T getAt(int index);
	void setAt(int index, T element);
	T & operator[](int index); 
	void Append(Array ob);
	T * getData(); 
	void insertAt(int index, T element); 
	void showArray();
	Array & operator=(const Array & ob1);
private:
	T * arr;
	int SIZE;
	int preSIZE; 
	int count; 
	int grow; 
};
class Solution {
public:
    int mxlcs(string &t1, string &t2, int i, int j,  vector<vector<int>> & dp)
    {
        if(i==t1.size()||j==t2.size()) return 0;
        if(dp[i][j]!=-1) return dp[i][j];
        int p=0;
        if(t1[i]==t2[j]) 
        {
            p = 1+mxlcs(t1, t2, i+1, j+1, dp);
        }
        else p = max(mxlcs(t1, t2, i+1, j, dp), mxlcs(t1, t2, i, j+1, dp));
        return dp[i][j]=p;
    }
    
    int longestCommonSubsequence(string text1, string text2) {
        vector<vector<int>> dp(text1.size(), vector<int>(text2.size(), -1));
        int ans=mxlcs(text1, text2, 0, 0, dp);
        return ans;
    }
};
class Solution {
public:
    int rob(vector<int>& nums) {
        int n=nums.size();
        vector<int> dp(n,-1);
        if(n<1) return 0;
        if(n==1) return nums[0];
        dp[0]=nums[0];
        dp[1]=max(nums[0], nums[1]);
        for(int i=2;i<n;i++)
        {
            dp[i]=max(dp[i-2]+nums[i], dp[i-1]);
        }
        return dp[n-1];
    }
};
std::vector<float> distortion_vec = calib_handler_.getCameraDistortion(calib_handler_.getStereoLeftCameraId());

Eigen::Map<Eigen::VectorXf, Eigen::Unaligned> distortion(distortion_vec.data(), distortion_vec.size() - 2);
class Solution {
public:
    int tribonacci(int n) {
        int dp[n+4];
        for(int i=0;i<n+1;i++)
        {
            dp[i]=-1;
        }
        dp[0]=0;
        dp[1]=1;
        dp[2]=1;
        for(int i=3;i<n+1;i++)
        {
            dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
        }
        return dp[n];
    }
};
#include <iostream>
using namespace std;

struct element
{
  int i;
  int j;
  int x;
 };
 
 struct sparse
 {
     int m;
     int n;
     int num;
     struct element *ele;
 };
 
 void create(sparse *s)
 {
     cout << "Enter dimensions : ";
     cin >> s->m >> s->n;
     cout << "Enter number of non zero elements : \n";
     cin >> s->num;
     
     s->ele = new element[s->num];
     
     cout << "Enter all non zero elements : ";
     for(int i=0; i<s->num; i++)
     {
         cout << "Enter row no: ";
         cin >> s->ele[i].i;
         cout << "Enter column no: ";
         cin >> s->ele[i].j;
         cout << "Enter element: ";
         cin >> s->ele[i].x;
     }
 }
 
 void display(struct sparse s)
{
    int k;
    for (int i=0; i< s.m; i++)
    {
        for(int j=0; j< s.n; j++)
        {
            if(i==s.ele[k].i && j==s.ele[k].j)
                cout << s.ele[k++].x << " ";
            else 
                cout << " ";
        }
        cout << endl;
    }
}

int main() {
    
    struct sparse s;
    create(&s);
    display(s);
    

    return 0;
}
#include <iostream>
using namespace std;

int main()
{
    int *A,n,x, ch;
    int i,j;
    
    cout << "Enter dimension : " ;
    cin >> n;
    
    A = new int[n];
    
    do
    {
        cout << "\n\n---Diagonal matrix---" << endl;
        cout << "1. Create " << endl;
        cout << "2. Get " << endl;
        cout << "3. Set " << endl;
        cout << "4. Display " << endl;
        cout << "5. Exit " << endl;
        cout << "Enter your choice : ";
        cin >> ch;
        
        switch(ch)
        {
            case 1 :
            cout << "Enter the diagonal elements : \n";
            for (int i=1; i<=n; i++)
                cin >> A[i-1];
            break;
            
            case 2 :
            cout << "Enter indices : ";
            cin >> i >> j;
            if (i==j)
                cout << "Element is : " << A[i-1] << endl;
            else 
                cout << "Element is : 0 " << endl;
            break;
            
            case 3 : 
            cout << "Enter the element : ";
            cin >> x;
            cout << "Enter the indices : ";
            cin >> i >> j;
            if (i==j)
            {
                A[i-1] = x;
                cout << "Element is inserted "<< endl;
            }
            else 
            cout << "Element cannot be inserted at those indices!" << endl;
            break;
            
            case 4 :
            for (int i=1; i<=n; i++)
            {
                for(int j=1; j<=n; j++)
                {
                    if (i==j)
                        cout << A[i-1] << " ";
                    else
                        cout << "0 ";
                }
                cout << endl;
            }
            break;
            
        }
        
    }
    while(ch != 5);
    
    return 0;
}
#include <iostream>
using namespace std;

class LowerTri 
{
    private :
        int n; 
        int *A;
 
    public :
    
     LowerTri(int n)
        {
            this->n = n;
            A = new int[(n*(n+1))/2];
        }
 
        void set (int i, int j , int x);
        int get (int i, int j);
        void display();
         LowerTri()
        {
            delete []A;
        }
};
 
void LowerTri :: set(int i, int j, int x)
{
    if(i>=j)
        A[(i*(i-1)/2) + (j-1)] = x;
}
 
int LowerTri :: get(int i ,int j)
{
    if(i>=j)
        return A[(i*(i-1)/2) + (j-1)];
    else 
        return 0;
}
 
void LowerTri :: display()
{
//    cout << "\n\n";
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=n; j++)
        {
            if (i>=j)
                cout << A[(i*(i-1)/2) + (j-1)] << " ";
            else
                cout << "0 ";
        }
        cout << endl;
    }
}

int main() {
    
    int d ;
    cout << "Enter dimensions : " ;
    cin >> d;
    
    LowerTri lm(d);
    
    int x;
    cout << "Enter all elements : " << endl;
    for(int i=1 ; i<=d; i++)
    {
        for (int j=1; j<=d; j++)
        {
            cin >> x;
            lm.set(i,j,x);
        }
    }
    
    cout << "\n\n";
	lm.display();
    return 0;
}
class Solution {
public:
    int maximumProduct(vector<int>& nums) {
        int n=nums.size();
        sort(nums.begin(), nums.end());
        return max(nums[0]*nums[1]*nums[n-1], nums[n-1]*nums[n-2]*nums[n-3]);
    }
};
#include <iostream>
using namespace std;

class Diagonal 
{
    private :
        int n; 
        int *A;
 
    public :
    
        Diagonal(int n)
        {
            this->n = n;
            A = new int[n];
        }
 
        void set (int i, int j , int x);
        int get (int i, int j);
        void display();
        ~Diagonal()
        {
            delete []A;
        }
};
 
void Diagonal :: set(int i, int j, int x)
{
    if(i==j)
        A[i-1] = x;
}
 
int Diagonal :: get(int i ,int j)
{
    if (i==j)
        return A[i-1];
    else 
        return 0;
}
 
void Diagonal :: display()
{
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            if (i==j)
                cout << A[i] << " ";
            else
                cout << "0 ";
        }
        cout << endl;
    }
}

int main() {
    
    Diagonal m(4) ;
    
    m.set(1,1,1);
    m.set(2,2,2);
    m.set(3,3,3);
    m.set(4,4,4);
    
    m.display();

    return 0;
}
#include <iostream>
using namespace std;

class MergeSort {
private:
    int* arr; // pointer to dynamic array
    int size;

public:
    MergeSort(int size) { // constructor to initialize private array and size
        this->size = size;
        arr = new int[size];
    }

    void merge(int* arr, int l, int m, int r) {
        int i, j, k;
        int n1 = m - l + 1;
        int n2 = r - m;

        int L[n1], R[n2];

        for (i = 0; i < n1; i++)
            L[i] = arr[l + i];
        for (j = 0; j < n2; j++)
            R[j] = arr[m + 1 + j];

        i = 0;
        j = 0;
        k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            }
            else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }

        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    void mergeSort(int* arr, int l, int r) {
        if (l < r) {
            int m = l + (r - l) / 2;

            mergeSort(arr, l, m);
            mergeSort(arr, m + 1, r);

            merge(arr, l, m, r);
        }
    }

    void sort() { // public function to sort the private array
        mergeSort(arr, 0, size - 1);
    }

    void display() { // public function to display the sorted array
        cout << "Sorted array: ";
        for (int i = 0; i < size; i++) {
            cout << arr[i] << " ";
        }
        cout << endl;
    }

    ~MergeSort() { // destructor to deallocate dynamic array memory
        delete[] arr;
    }
};

int main() {
    int size;
    cout << "Enter the size of the array: ";
    cin >> size;

    int* arr = new int[size];
    cout << "Enter the elements of the array: ";
    for (int i = 0; i < size; i++) {
        cin >> arr[i];
    }

    MergeSort obj(size);
    for (int i = 0; i < size; i++) {
        obj.arr[i] = arr[i]; // copy the array to the private array in the class
    }

    obj.sort(); // sort the private array
    obj.display(); // display the sorted array

    delete[] arr; // deallocate dynamic array memory
    return 0;
}
I am currently working on a project from Willings Corp. , a renowed company in Japan, So I am currently developing an app for the organization in a team, so I have a good knowledge how things works in a real projects. And I have also maintained a good CGPA (8.23/10) in an institute of national importance. So I can assure you that I will give my best to do the required work for this role.
#include <iostream>
#include <vector>
using namespace std;

class insertionsort{
    private:
    int a[100];
    int n;

    public:

    insertionsort(int arr[], int size){
        n = size;
        int j, key;
        for (int i=0; i < n; i++) {
            a[i] = arr[i];
        }
        for(int i = 1; i<size; i++) {
          key = a[i];
          j = i;
          while( j > 0 && a[j-1]>key) {
             a[j] = a[j-1];
             j--;
          }
          a[j] = key;  
       }
    }
    
    void display() {
        cout << "Sorted array: ";
        for (int i = 0; i < n; i++) {
            cout << a[i] << " ";
        }
        cout << endl;
    }
};

int main() {
    int size;
    
    cout << "Enter the size of the 1-d array: ";
    cin >> size;
    
    int arr[size];
    
    cout << "Enter all the elemets of the array with spaces:\n";
    for(int i=0; i<size; i++){
        cin>>arr[i];
    }
    
    
    insertionsort is(arr, size);
    is.display();

    return 0;
}
#include <iostream>
#include <vector>
using namespace std;

class selectionsort{
    private:
    int a[100];
    int n;

    public:

    selectionsort(int arr[], int size){
        n = size;
        int imin, temp;
        
        for (int i=0; i < n; i++) {
            a[i] = arr[i];
        }
       for(int i = 0; i<n-1; i++) {
          imin = i;   
          for(int j = i+1; j<n; j++)
             if(a[j] < a[imin])
                imin = j;
             temp = a[i];
             a[i] = a[imin];
             a[imin] = temp;
       }
    }
    
    void display() {
        cout << "Sorted Array: ";
        for (int i = 0; i < n; i++) {
            cout << a[i] << " ";
        }
        cout << endl;
    }
};

int main() {
    int size;
    
    cout << "Enter the size of the 1-d array: ";
    cin >> size;
    
    int arr[size];
    
    cout << "Enter all the elements separated with spaces\n";
    for(int i=0; i<size; i++){
        cin>>arr[i];
    }
    
    
    selectionsort ss(arr, size);
    ss.display();

    return 0;
}
#include <iostream>
using namespace std;


class binarysearch {
    private:
        int n;
    public:
    
    void bubblesort(int arr[], int size){
        n = size;
        for (int i=0; i < n - 1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                if (arr[j] > arr[j+1]) {
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        
    }
    
    int search(int arr[], int x, int low, int high) {
        
      if (high >= low) {
        int mid = low + (high - low) / 2;
    
        // If found at mid, then return it
        if (arr[mid] == x)
          return mid;
    
        // Search the left half
        if (arr[mid] > x)
          return search(arr, x, low, mid - 1);
    
        // Search the right half
        return search(arr, x, mid + 1, high);
      }

  return -1;
}
};

int main() {
    int size, x;
    
    cout << "Enter the size of the 1-d array: ";
    cin >> size;
    int arr[size];
    
    cout << "Enter all the elements separated with spaces\n";
    for(int i=0; i<size; i++){
        cin>>arr[i];
    }
    
    cout <<"Enter the element to do binary search: ";
    cin >>x;

    binarysearch bs;
    bs.bubblesort(arr, size);
    
    cout<<"To do binary search, the array should be sorted\nThe sorted array is:\n";
    for(int i=0; i<size; i++){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
    
    int index = bs.search(arr, x, 0, size - 1);

    if (index == -1) {
        cout << "Element not found" << endl;
    } else {
        cout << "Element "<<x<<" found at index " << index << endl;
    }

    return 0;
}
// for LEDS

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#include <Keypad.h>

//
int old_color_piano;
int old_color_guitar;

// for row/col scan
bool initialized = false;
const byte ROWS = 3;
const byte COLS = 8;
char fastPressed;
int lastPressed;
char hexaKeys[ROWS][COLS] = {                
{'0','1','2','3','4','5','6','7'},
{'8','9','A','B','C','D','E','F'},
{'G','H','I','J','K','L','M','N'}
};
byte colPins[COLS] = {37,41,43,45,47,49,51,53};
byte rowPins[ROWS] = {31,33,35};

// this one im adding
int current_button;


Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);


// for the debouncer
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;
int lastButtonState = LOW;


//#define LED_PIN   8
//#define LED_COUNT 60
int LED_PIN_piano = 13;
int LED_PIN_guitar = 29;
int LED_COUNT = 60;

Adafruit_NeoPixel piano_strip(LED_COUNT, LED_PIN_piano, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel guitar_strip(LED_COUNT, LED_PIN_guitar, NEO_GRB + NEO_KHZ800);

int current_step = 0;
int old_color;

// end LEDS


// NEW AS OF 12/10
// C = 2,5 B = 6,3 A = 7,4
int g1[] = {0,0,0};
int g2[] = {0,0,0};
//int g2Pins[] = {5,6,7};
//int g1Pins[] = {2,3,4};

int g1Pins[] = {7,6,5};
int g2Pins[] = {4,3,2};

//int g1Pins[] = {5,6,7};
//int g2Pins[] = {2,3,4};

// C = 16,19 B = 15,18 A = 14,17
int p1[] = {0,0,0};
int p2[] = {0,0,0};
int p1Pins[] = {16,15,14};
int p2Pins[] = {19,18,17};

int potVal;
int potVal_speed;
int potPin_piano = A0;
int potPin_guitar = A1;
int potPin_speed = A2;

int buttonPins[] = {41,43,45,47,49,51,53,52};
int buttonCounts[] = {0,0,0,0,0,0,0,0};

//int piano_steps[] = {1,8,11,0,20,0,23,17};
int piano_steps[] = {1,0,3,0,5,0,0,7};

//int guitar_steps[] = {0,1,2,3,4,5,6};
int guitar_steps[] = {17,17,17,17,17,17,17,0};


int modeButton = 10;
// END NEW


/// FROM 12_9_PUTTINGTOGETHER
int prevStateMode = 0;
int lastDebounceTimeMode = 0;
int buttonStateMode = 0;
int lastButtonStateMode = 0;
// mode_bool must be false on init
// false -> write mode, true -> play mode
int mode_bool = true;

int just_pressed[] = {false,false,false,false,false,false,false,false};
int still_pressed[] = {false,false,false,false,false,false,false,false};
int debounced_times[] = {0,0,0,0,0,0,0,0};

int just_pressed_mode = false;
int still_pressed_mode = false;
int debounced_times_mode = 0;
int wait_time = 1000;
//



// for piano
int myArray[40][6]{
{0,0,0,0,0,0},
{0,0,0,0,0,1},
{0,0,0,0,1,0},
{0,0,0,0,1,1},
{0,0,0,1,0,0},
{0,0,0,1,0,1},
{0,0,0,1,1,0},
{0,0,0,1,1,1},
{0,0,1,0,0,0},
{0,0,1,0,0,1},
{0,0,1,0,1,0},
{0,0,1,0,1,1},
{0,0,1,1,0,0},
{0,0,1,1,0,1},
{0,0,1,1,1,1},
{0,1,0,0,0,0},
{0,1,0,0,0,1},
{0,1,0,0,1,0},
{0,1,0,0,1,1},
{0,1,0,1,0,0},
{0,1,0,1,0,1},
{0,1,0,1,1,1},
{0,1,1,0,0,0},
{0,1,1,0,0,1},
{0,1,1,0,1,0},
{0,1,1,0,1,1},
{0,1,1,1,0,0},
{0,1,1,1,0,1},
{0,1,1,1,1,0},
{0,1,1,1,1,1},
{1,0,0,0,0,0},
{1,0,0,0,0,1},
{1,0,0,0,1,0},
{1,0,0,0,1,1},
{1,0,0,1,0,0},
{1,0,0,1,0,1},
{1,0,0,1,1,0},
{1,0,0,1,1,1},
{1,0,1,0,0,0},
{1,0,1,0,0,1},
// {1,0,1,0,1,0},
//{1,0,1,0,1,1}
};

// for guitar
int myArray_guitar[8][6]{
{0,0,0,0,0,0},
{0,0,0,0,0,1},
{0,0,0,0,1,0},
{0,0,0,0,1,1},
{0,0,1,0,0,0},
{0,0,1,0,0,1},
{0,0,1,0,1,0},
{0,0,1,0,1,1}
};

void setup() {
  // for leds
  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
  #endif
  // END of Trinket-specific code.

  piano_strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  piano_strip.show();            // Turn OFF all pixels ASAP
  piano_strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)

  guitar_strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  guitar_strip.show();            // Turn OFF all pixels ASAP
  guitar_strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
  // end LEDS

 
  Serial.begin(9600);
  pinMode(potPin_piano, INPUT);
  pinMode(potPin_guitar, INPUT);
  pinMode(potPin_speed, INPUT);
 
 
  // init mx/dmx
  for (int i = 0; i < 3; i++){
    pinMode(g1Pins[i],OUTPUT);
    pinMode(g2Pins[i],OUTPUT);
    pinMode(p1Pins[i],OUTPUT);
    pinMode(p2Pins[i],OUTPUT);
  }

  // init buttons
  for (int i = 0; i < 8; i++){
    pinMode(buttonPins[i], INPUT);
   }

  for(int i=0; i<8; i++) {
      piano_strip.setPixelColor(i+3,255,0,0);
      guitar_strip.setPixelColor(i+3,255,0,0);
   }
   piano_strip.show();
   guitar_strip.show();
}


void loop() {

    Serial.print(digitalRead(12));
    //Serial.print(analogRead(A0));
    //Serial.print(analogRead(A1));
    //Serial.println(analogRead(A2));


  // put your main code here, to run repeatedly:
   //Serial.println(digitalRead(modeButton));
   if (!mode_bool) {
     new_write_mode();
   }
//     Serial.print("piano ");
//     Serial.print(piano_steps[0]);
//     Serial.print(piano_steps[1]);
//     Serial.print(piano_steps[2]);
//     Serial.print(piano_steps[3]);
//     Serial.print(piano_steps[4]);
//     Serial.print(piano_steps[5]);
//     Serial.print(piano_steps[6]);
//     Serial.println(piano_steps[7]);

     //Serial.print("guitar ");
//     Serial.print(guitar_steps[0]);
//     Serial.print(guitar_steps[1]);
//     Serial.print(guitar_steps[2]);
//     Serial.print(guitar_steps[3]);
//     Serial.print(guitar_steps[4]);
//     Serial.print(guitar_steps[5]);
//     Serial.print(guitar_steps[6]);
//     Serial.println(guitar_steps[7]);
//   }
   
   if (mode_bool) {
    play_mode();
   }

checkModeButton();

}

void checkButtons(){
Serial.println("write mode");
// iterate thru buttons
for (int i = 0; i < 8; i++){
   
    // for LEDS
    //if (steps[i] == 0) {
      //strip.setPixelColor(i,255,0,0);
  //  }

    //else if (steps[i] != 0) {
      //strip.setPixelColor(i,0,0,255);
  //  }

    // end LEDS
 
  // read button pin
  int buttonState = digitalRead(buttonPins[i]);

  if (buttonState == 1 && just_pressed[i] == false){
       buttonCounts[i]++;
       
    // NEW
    if (buttonCounts[i] % 2 != 0){
        debounced_times[i] = millis();
        potVal = map(analogRead(potPin_piano), 0,920,0,35);
        //steps[i] = potVal;
        //Serial.println(steps[i]);

        if (millis() - debounced_times[i] > wait_time) {
          if (digitalRead(buttonPins[i] == 1)) {
            buttonCounts[i]++;
          }
        }
       
        if (buttonCounts[i] % 2 != 0) {
          // is this the right place to show lights?
          //strip.show();
          break;
        }
      }  
     }
   }
 }




void play_mode() {
  Serial.println("read mode");
  //for play mode test 12/11 3pm


 
  //int piano_steps[] = {10,11,12,0,13,14,0,25};
  //int guitar_steps[] = {0,1,2,3,4,5,6,7};

  //int piano_steps[] = {0,1,2,3,4,5,6,7};
 
  for (int i = 0; i < 8; i++){
    // iterate thru all 8 steps
    //Serial.println("read mode");
    int t_piano = piano_steps[i];
    int t_guitar = guitar_steps[i];
   
    checkModeButton();
   
    // TODO IMPLEMENT FOR MULTIPLE LED STRIPS
    play_mode_leds(i);

  for (int j = 0; j < 3; j++){
    p1[j] = myArray[t_piano][j+3];
    p2[j] = myArray[t_piano][j];

    checkModeButton();

    g2[j] = myArray[t_guitar][j+3];
    g1[j] = myArray[t_guitar][j];
    }
//        for (int i = 0; i < 3; i++){
//    Serial.print(g1[i]);
//  }
//   for (int i = 0; i < 2; i++){
//    Serial.print(g2[i]);
//  }
//  Serial.println(g2[2]);
   
  //atoi()
//    Serial.print(p1[0]);
//    Serial.print(p1[1]);
//    Serial.print(p1[2]);
//    Serial.print(p2[0]);
//    Serial.print(p2[1]);
//    Serial.println(p2[2]);

    checkModeButton();

    for (int j = 0; j < 3; j++){
     digitalWrite(p1Pins[j],p1[j]);
     digitalWrite(p2Pins[j],p2[j]);
     
     digitalWrite(g1Pins[j],g1[j]);
     digitalWrite(g2Pins[j],g2[j]);
    }
   
     wait_time = map(analogRead(potPin_speed),0,1000,100,800);
     checkModeButton();
     delay(wait_time);
   }
}

void checkModeButton(){
//Serial.println("fug");
  int reading = digitalRead(modeButton);

  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH), and you've waited long enough
  // since the last press to ignore any noise:

  // If the switch changed, due to noise or pressing:
  if (reading != prevStateMode) {
   
    // reset the debouncing timer
    lastDebounceTimeMode = millis();
  }

  if ((millis() - lastDebounceTimeMode) > 50) {
    // whatever the reading is at, it's been there for longer than the debounce
    // delay, so take it as the actual current state:
    //Serial.println("I am capable of extreme violence");

    // if the button state has changed:
    if (reading != buttonStateMode) {
      buttonStateMode = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonStateMode == HIGH) {
        mode_bool = !mode_bool;
      }
    }
  }
    // save the reading. Next time through the loop, it'll be the lastButtonState:
  lastButtonState = reading;  
}

void play_mode_leds(int current_step) {
  current_step = current_step+3;
  if (current_step > 0) {
    //old_color = strip.getPixelColor(current_step-1);
    piano_strip.setPixelColor(current_step-1,old_color_piano);
    guitar_strip.setPixelColor(current_step-1,old_color_guitar);
   
    if (piano_steps[current_step-1] == 0) {
      piano_strip.setPixelColor(current_step-1,255,0,0);
    }

    else if (piano_steps[current_step-1] != 0) {
      piano_strip.setPixelColor(current_step-1,0,0,255);
    }

    if (guitar_steps[current_step-1] == 0) {
      guitar_strip.setPixelColor(current_step-1,255,0,0);
    }

    else if (guitar_steps[current_step-1] != 0) {
      guitar_strip.setPixelColor(current_step-1,0,0,255);
    }
   
  }

  else if (current_step == 0) {
    //old_color = strip.getPixelColor(7);
    //strip.setPixelColor(7,old_color);
   
    if (piano_steps[7] == 0) {
      piano_strip.setPixelColor(7+3,255,0,0);
    }
//    else if (piano_steps[7] != 0) {
      else{
      piano_strip.setPixelColor(7+3,0,0,255);
    }

    if (guitar_steps[7] == 0) {
      guitar_strip.setPixelColor(7+3,255,0,0);
    }
    else if (guitar_steps[7] != 0) {
      guitar_strip.setPixelColor(7+3,0,0,255);
    }
   
  }

  old_color_piano = piano_strip.getPixelColor(current_step);
  old_color_guitar = guitar_strip.getPixelColor(current_step);    
  piano_strip.setPixelColor(current_step,0,255,0);
  guitar_strip.setPixelColor(current_step,0,255,0);
  //old_color = strip.getPixelColor(current_step-1)
  //strip.setPixelColor(current_step-1,old_color);
  piano_strip.show();
  guitar_strip.show();
}

void new_write_mode() {
   Serial.println("write mode");
   //Serial.print("potVAL_no press ");
   //Serial.println(potVal);
  checkModeButton();
  char customKey = customKeypad.getKey();
  Serial.println(lastPressed);

  if (customKey != NO_KEY){
    initialized = true;
    decoder(customKey);
  }
 
   
  if (lastPressed < 8 && initialized == true) {
    potVal = map(analogRead(potPin_piano),20,1000,0,35);
    Serial.print("potVAL ");
    Serial.println(potVal);
    piano_steps[lastPressed] = potVal;
  }

  else if (lastPressed > 7 && lastPressed < 16) {
    potVal = map(analogRead(potPin_guitar),0,1013,0,8);
    Serial.print("potVAL ");
    Serial.println(potVal);
    guitar_steps[lastPressed-8] = potVal;
    Serial.println(lastPressed);
  }

  for(int i=0; i<8; i++) {
   
    if (piano_steps[i] == 0) {
      piano_strip.setPixelColor(i+3,255,0,0);
    }

    else if (piano_steps[i] != 0) {
      piano_strip.setPixelColor(i+3,0,0,255);
    }

    if (guitar_steps[i] == 0) {
      guitar_strip.setPixelColor(i+3,255,0,0);
    }

    else if (guitar_steps[i] != 0) {
      guitar_strip.setPixelColor(i+3,0,0,255);
    }
 
  }
 
  piano_strip.show();
  guitar_strip.show();
 
}

void decoder(char myKey){
  if (myKey == '0'){lastPressed = 7;}
  if (myKey == '1'){lastPressed = 6;}
  if (myKey == '2'){lastPressed = 5;}
  if (myKey == '3'){lastPressed = 4;}
  if (myKey == '4'){lastPressed = 3;}
  if (myKey == '5'){lastPressed = 2;}
  if (myKey == '6'){lastPressed = 1;}
  if (myKey == '7'){lastPressed = 0;}

 
  if (myKey == 'G'){lastPressed = 15;}
  if (myKey == 'H'){lastPressed = 14;}
  if (myKey == 'I'){lastPressed = 13;}
  if (myKey == 'J'){lastPressed = 12;}
  if (myKey == 'K'){lastPressed = 11;}
  if (myKey == 'L'){lastPressed = 10;}
  if (myKey == 'M'){lastPressed = 9;}
  if (myKey == 'N'){lastPressed = 8;}

  }
int LinearSearch(struct arr, int key)
{
  int i;
  for(i=0; i<arr.length; i++)
    {
      if (key == arr.A[i])
        return i;
    }
  return -1;
}

int main()
{
  struct Array arr={{2,3,4,5,6},10,5};

  printf("%d\n", LinearSearch(arr,15));
  Display(arr);

return 0;
}
#include <iostream>
#include <vector>
using namespace std;

class bubblesort{
    private:
    int a[100];
    int n;

    public:

    bubblesort(int arr[], int size){
        n = size;
        
        for (int i=0; i < n; i++) {
            a[i] = arr[i];
        }
        for (int i=0; i < n - 1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                if (a[j] > a[j+1]) {
                    int temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                }
            }
        }
    }
    
    void display() {
        cout << "Sorted Array: ";
        for (int i = 0; i < n; i++) {
            cout << a[i] << " ";
        }
        cout << endl;
    }
};

int main() {
    int size;
    
    cout << "Enter the size of the 1-d array: ";
    cin >> size;
    
    int arr[size];
    
    cout << "Enter all the elements separated with spaces\n";
    for(int i=0; i<size; i++){
        cin>>arr[i];
    }
    
    bubblesort bs(arr, size);
    bs.display();
    
    return 0;
}
int delete(struct Array *arr, int index)
{
  int x=0;
  int i;
  
  if (index >= 0 && index < arr->length)
    {
      x = arr-> A[index];
      for(i = index; i<arr->length-1; i++)
        arr ->length--;
      return x;
    }
  return 0;
}

int main()
{
  struct Array arr= {{2,3,4,5,6},10,5};

  printf("%d\n", Delete(&arr,4));

  return 0;
}
// Emilio Ordoñez

# include <iostream>
using namespace std;

	//Valores
	float DiasLaborados = 30;
	float UMA = 123.22;
	float Factor1 = .25;
	float Factor2 = .3750;
	float Factor3 = .0110;
	
	float SueldoBruto = 0;
	float SalarioDiarioIntegrado = 0;
	float CuotaObreroPatronal = 0;
	float CuotaPorPrestamo = 0;
	float GastosMedicos = 0;
	float GastosInvalidez = 0;
	float IMSS = 0;

cuotaIMSS(){
	
	//Operaciones
	SalarioDiarioIntegrado = SueldoBruto / DiasLaborados;
	CuotaObreroPatronal = (( SalarioDiarioIntegrado - UMA ) * DiasLaborados ) * Factor3;
	CuotaPorPrestamo = (( SueldoBruto * DiasLaborados ) * Factor1 ) / 100;
	GastosMedicos =  (( SueldoBruto * DiasLaborados ) * Factor2 ) / 100 ;
	GastosInvalidez = SueldoBruto * Factor1;
	
	IMSS = CuotaObreroPatronal + CuotaPorPrestamo + GastosMedicos + GastosInvalidez;
	//Valores de salida
	cout << "Salario diario integrado: " << SalarioDiarioIntegrado << endl;
	cout << "Cuota obrero patronal: " << CuotaObreroPatronal << endl;
	cout << "Cuota por prestamo: " << CuotaPorPrestamo << endl;
	cout << "Gastos medicos: " << GastosMedicos << endl;
	cout << "Gastos invalidez: " << GastosInvalidez << endl;
	cout << "\nCuota del IMSS : " << IMSS << endl;
}

int main(){
	
	cout << "Calculadora de la nomina\n Banco de Mexico\n";
	cout << "\nSueldo bruto: ";
	cin >> SueldoBruto;
	
	cout << "Ingrese una opcion: ";
	int opcion;
	
	cin >> opcion;
		
	switch(opcion) 
	{
    	case 1:
    	cuotaIMSS();
    	break;
    	case 2: 
    	break;
    	default:; 
	}

	return 0;
}
#include <iostream>
using namespace std;

class linearsearch {
    private:
        int a[100], n, x;
        
    public:
        int search(int arr[], int size, int key) {
            n = size;
            x = key;
            
            for (int i=0; i < n; i++) {
            a[i] = arr[i];
            }   
        
            for (int i = 0; i < size; i++) {
                if (arr[i] == key) {
                    return i;
                }
            }
            return -1;
        }
};

int main() {
    int size, x;
    
    cout << "Enter the size of the 1-d array: ";
    cin >> size;
    int arr[size];
    
    cout << "Enter all the elements separated with spaces\n";
    for(int i=0; i<size; i++){
        cin>>arr[i];
    }
    
    cout <<"Enter the element to do linear search: ";
    cin >>x;
    
    linearsearch ls;
    int index = ls.search(arr, size, x);

    if (index == -1) {
        cout << x <<" not found" << endl;
    } else {
        cout << x <<" found at index " << index <<" (starts from 0)." <<endl;
    }

    return 0;
}
class Solution {
public:
    char bsf(vector<char> letters, char target)
    {
        char ans=letters[0];
        int n=letters.size();
        int l=0,h=n-1;
        int mid=l+(h-l)/2;
        while(l<=h)
        {
            if(letters[mid]-'a'>target-'a') 
            {
                ans=letters[mid];
                h=mid-1;
            }
            else l=mid+1;
            mid=l+(h-l)/2;
        }
        return ans;
    }
    
    char nextGreatestLetter(vector<char>& letters, char target) {
        char result=bsf(letters, target);
        return result;
    }
};
class Solution {
public:
    bool isPerfectSquare(int num) {
        int l=1;
        int h=100000;
        long long mid=l+(h-l)/2;
        long long sq;
        while(l<=h)
        {
            sq=mid*mid;
            if(sq==num) return true;
            if(sq<num) l=mid+1;
            else h=mid-1;
            mid=l+(h-l)/2;
        }
        return false;
    }
};
class Solution {
public:
    double my_Pow(double x, long n)
    {
        if(n==0) return 1.0;
        if(n==1) return x;
        if(n<0) return my_Pow(1/x, -n);
        double result=my_Pow(x*x, n/2);
        if(n%2==1) result*=x;
        return result;
    }
    
    double myPow(double x, int n) {
        return my_Pow(x, n);
    }
};
class Solution {
public:
    int pivot(vector<int> nums)
    {
        int n=nums.size();
        int s=0, l=n-1;
        int mid=s+(l-s)/2;
        while(s<=l)
        {
            if(s==l) return s;
            if(nums[mid]>nums[n-1]) s=mid+1;
            else l=mid;
            mid=s+(l-s)/2;
        }
        return s;
    }
    
    int findMin(vector<int>& nums) {
        int ans=nums[pivot(nums)];
        return ans;
    }
};
// The API isBadVersion is defined for you.
// bool isBadVersion(int version);

class Solution {
public:
    int firstBadVersion(int n) {
        int s=0, e=n-1;
        int mid=s+(e-s)/2;
        int ans=-1;
        while(s<=e)
        {
            if(isBadVersion(mid)) 
            {
                ans=mid;
                e=mid-1;
            }
            else s=mid+1;
            mid=s+(e-s)/2;
        }
        return mid;
    }
};
class Solution {
public:
    int findPeakElement(vector<int>& nums) {
        int n=nums.size();
        if(n==1) return 0;
        if(n==2) return nums[0]>nums[1]?0:1;
        int s=1, e=n-2;
        int mid=s+(e-s)/2;
        while(s<=e)
        {
            if(nums[mid]>nums[mid-1]&&nums[mid]>nums[mid+1]) return mid;
            else if(nums[mid]<nums[mid+1]) s=mid+1;
            else if(nums[mid]<=nums[mid-1])e=mid-1;
            mid=s+(e-s)/2;
        }
        if(nums[0]>nums[1]) return 0;
        else if(nums[n-1]>nums[n-2]) return n-1;
        
        return -1;
    }
};
/** 
 * Forward declaration of guess API.
 * @param  num   your guess
 * @return 	     -1 if num is higher than the picked number
 *			      1 if num is lower than the picked number
 *               otherwise return 0
 * int guess(int num);
 */

class Solution {
public:
    // int guess(int num)
    // {
    //     if(num>)
    // }
    int guessNumber(int n) {
        int s=1, e=n;
        int mid=s+(e-s)/2;
        
        while(s<=e)
        {
            int num=guess(mid);
            if(num==0) return mid;
            if(num==-1) e=mid-1;
            else s=mid+1;
            mid=s+(e-s)/2;
        }
        return mid;
        
    }
};
class Solution {
public:
    int bs(int x)
    {
        
        int long long n=x/2;
        int long long s=0, e=n;
        int long long mid=s+(e-s)/2;
        int long long ans=0;
        while(s<=e)
        {
            int long long p=mid*mid;
            int long long p2=(mid+1)*(mid+1);
            if(p<=x&&p2>x) return mid;
            if(p<x) 
            {
                ans=
                s=mid+1;
            }
            else e=mid-1;
            mid=s+(e-s)/2;
        }
        return mid;
    }
    
    int mySqrt(int x) {
        if(x==0) return 0;
        if(x==1||x==2||x==3) return 1;
        int ans=bs(x);
        return ans;
    }
 };
        // tennis rackets
        for(int item = 0; item < 2; item++) {
            glm::mat4 world_transform_matrix = glm::mat4(1.0f);
            // global transforms
            world_transform_matrix = glm::translate(world_transform_matrix, starting_locations[item]);
            world_transform_matrix = rotate(world_transform_matrix, r[item]);
            world_transform_matrix = glm::scale(world_transform_matrix, s[item]);

            glm::mat4 arm_transform_matrix = world_transform_matrix;
            glm::mat4 racket_transform_matrix = world_transform_matrix;

            // -- arm -- // tranforms cube to create arm
            // forearm (skin)
            arm_transform_matrix =  tennis_rackets[item][0].cubeRotate(arm_transform_matrix, glm::vec3(45.0f, 0.0f, 0.0f));
            arm_transform_matrix = tennis_rackets[item][0].cubeScale(arm_transform_matrix, glm::vec3(0.5f, 2.0f, 0.5f));
            tennis_rackets[item][0].drawCube(arm_transform_matrix);
            arm_transform_matrix = tennis_rackets[item][0].cubeScale(arm_transform_matrix, glm::vec3(1/0.5f, 1/2.0f, 1/0.5f));

            // arm (skin)
            arm_transform_matrix = tennis_rackets[item][0].cubeTranslate(arm_transform_matrix, glm::vec3(0.0f, 2.0f * 0.1f, 0.0f));
            arm_transform_matrix =  tennis_rackets[item][0].cubeRotate(arm_transform_matrix, glm::vec3(-45.0f, 0.0f, 0.0f));
            arm_transform_matrix = tennis_rackets[item][0].cubeScale(arm_transform_matrix, glm::vec3(0.5f, 2.0f, 0.5f));
            tennis_rackets[item][0].drawCube(arm_transform_matrix);
            arm_transform_matrix = tennis_rackets[item][0].cubeScale(arm_transform_matrix, glm::vec3(1/0.5f, 1/2.0f, 1/0.5f));

            // -- tennis racket shape -- // transforms cube to create racket
            // handle
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f, 3.0f * 0.1f, -0.15f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.25f, 2.5f, 0.25f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.25f, 1/2.5f, 1/0.25f));
            // racket
            // racket angled bottom left
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f,  2.5f * 0.1f, 0.0f));
            racket_transform_matrix =  tennis_rackets[item][1].cubeRotate(racket_transform_matrix, glm::vec3(-70.0f, 0.0f, 0.0f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.25f, 1.5f, 0.25f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.25f, 1/1.5f, 1/0.25f));
            // racket vertical left
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f,  1.5f * 0.1f, 0.0f));
            racket_transform_matrix =  tennis_rackets[item][1].cubeRotate(racket_transform_matrix, glm::vec3(70.0f, 0.0f, 0.0f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.25f, 2.0f, 0.25f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.25f, 1/2.0f, 1/0.25f));
            // racket angled top left
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f,  2.0f * 0.1f, 0.0f));
            racket_transform_matrix =  tennis_rackets[item][1].cubeRotate(racket_transform_matrix, glm::vec3(40.0f, 0.0f, 0.0f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.25f, 1.0f, 0.25f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.25f, 1/1.0f, 1/0.25f));
            // racket horizontal top
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f,  1.0f * 0.1f, 0.0f));
            racket_transform_matrix =  tennis_rackets[item][1].cubeRotate(racket_transform_matrix, glm::vec3(50.0f, 0.0f, 0.0f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.25f, 1.5f, 0.25f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.25f, 1/1.5f, 1/0.25f));
            // racket angled top right
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f,  1.5f * 0.1f, 0.0f));
            racket_transform_matrix =  tennis_rackets[item][1].cubeRotate(racket_transform_matrix, glm::vec3(50.0f, 0.0f, 0.0f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.25f, 1.0f, 0.25f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.25f, 1/1.0f, 1/0.25f));
            // racket vertical right
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f,  1.0f * 0.1f, 0.0f));
            racket_transform_matrix =  tennis_rackets[item][1].cubeRotate(racket_transform_matrix, glm::vec3(40.0f, 0.0f, 0.0f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.25f, 2.0f, 0.25f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.25f, 1/2.0f, 1/0.25f));
            // racket horizontal bottom
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f,  2.0f * 0.1f, 0.0f));
            racket_transform_matrix =  tennis_rackets[item][1].cubeRotate(racket_transform_matrix, glm::vec3(90.0f, 0.0f, 0.0f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.25f, 2.75f, 0.25f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.25f, 1/2.75f, 1/0.25f));

            //net
            racket_transform_matrix = tennis_rackets[item][1].cubeTranslate(racket_transform_matrix, glm::vec3(0.0f, 0.0f, -2.25f * 0.1f));
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(0.1f, 2.5f, 0.1f));
            tennis_rackets[item][1].drawCube(racket_transform_matrix);
            racket_transform_matrix = tennis_rackets[item][1].cubeScale(racket_transform_matrix, glm::vec3(1/0.1f, 1/2.5f, 1/0.1f));

            for (float j = 0; j < 6; j++) { ]
class Solution {
public:
    int numRescueBoats(vector<int>& people, int limit) {
        sort(people.begin(), people.end());
        int n=people.size();
        int ptri=0;
        int ptrl=n-1;
        int boats=0;
        
        for(ptrl=n-1;ptrl>=0&&ptrl>=ptri;ptrl--)
        {
            if(people[ptrl]+people[ptri]<=limit) ptri++;
            boats++;
        }
        return boats;
    }
};
class Solution {
public:
    int pivotIndex(vector<int>& nums) {
        int n=nums.size();
        int ap[n], aa[n];
        ap[0]=0; aa[n-1]=0;
        int sum=nums[0];
        for(int i=1;i<n;i++)
        {
            ap[i]=sum;
            sum+=nums[i];
        }
        int s=nums[n-1];
        for(int i=n-2;i>=0;i--)
        {
            aa[i]=s;
            s+=nums[i];
        }
        int ans=-1;
        for(int i=0;i<n;i++)
        {
            if(ap[i]==aa[i])
            {
                ans=i;
                break;
            }
        }
        return ans;
    }
};
class Solution {
public:
    int peakIndexInMountainArray(vector<int>& arr) {
        int st=0, end=arr.size()-1;
        int mid=st+(end-st)/2;
        while(st<=end)
        {
            if(arr[mid]>arr[mid-1]&&arr[mid]>arr[mid+1]) return mid;
            if(arr[mid]<arr[mid+1]) st=mid+1;
            else if(arr[mid]<arr[mid-1]) end=mid;
            mid=st+(end-st)/2;
        }
        return mid;
    }
};
class Solution {
public:
    
    int loweridx(vector<int> nums ,int target)
    {
        int st=0, end=nums.size()-1;
        int ans=-1;
        int mid=st+(end-st)/2;
        while(st<=end)
        {
            if(nums[mid]==target) 
            {
                ans=mid;
                end=mid-1;
            }
            else if(target>nums[mid])
            {
                st=mid+1;
            }
            else if(target<nums[mid])
            {
                end=mid-1;
            }
            mid=st+(end-st)/2;
        }
        return ans;
    }
    
    int largidx(vector<int> nums ,int target)
    {
        int st=0, end=nums.size()-1;
        int ans=-1;
        int mid=st+(end-st)/2;
        while(st<=end)
        {
            if(nums[mid]==target) 
            {
                ans=mid;
                st=mid+1;
            }
            else if(target>nums[mid])
            {
                st=mid+1;
            }
            else if(target<nums[mid])
            {
                end=mid-1;
            }
            mid=st+(end-st)/2;
        }
        return ans;
    }
        
    vector<int> searchRange(vector<int>& nums, int target) {
       
        vector<int> v;
        int lowidx=loweridx(nums, target);
        int laridx=largidx(nums, target);
        v.push_back(lowidx);
        v.push_back(laridx);
        return v;
    }
};
// the following are the resources used for this project :
// https://my.eng.utah.edu/~cs5610/handouts/order_independent_transparency.pdf
// https://learnopengl.com/Getting-started/Hello-Window
// https://learning.oreilly.com/library/view/opengl-build/9781788296724/ch06s02.html

#include <iostream>
#include <glad/glad.h>
#include <GLFW/glfw3.h>

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

void processInput(GLFWwindow *window);
void initialize_framebuffers();


// settings
const unsigned int SCR_WIDTH = 900;
const unsigned int SCR_HEIGHT = 800;

// framebuffers
GLuint FBO[2], FBOcolourBlender; // frame buffer objects
GLuint colourTextureID[2], depthTextureID[2], colourBlenderTextureID; // textures for attachment to frame buffer

// store vertex data in buffer
// VAO (vertex array object) stores pointers to one or more VBOs (vertex buffer object)
GLuint VAO, VBO, EBO; // EBO (element buffer object)

//total number of depth peeling passes
const int NUM_PASSES = 4;

// basic vertex shader source code
const char* vertexShaderSource = "#version 330 core\n"
    "layout (location = 0) in vec3 aPos;\n"
    "uniform mat4 model;\n"
    "uniform mat4 view;\n"
    "uniform mat4 proj;\n"
    "void main()\n"
    "{\n"
    "   gl_Position = proj * view * model * vec4(aPos, 1.0);\n"
    "}\0";
// basic fragment shader source code
const char* fragmentShaderSource = "#version 330 core\n"
    "out vec4 FragColor;\n"
    "uniform vec4 cubecolour;\n"	//colour uniform
    "void main()\n"
    "{\n"
    "   FragColor = cubecolour;\n"
    "}\n\0";

// peeling vertex shader source code
const char* peeling_vertexShaderSource = "#version 330 core\n"
    "layout (location = 0) in vec3 aPos;\n"
    "uniform mat4 model;\n"
    "uniform mat4 view;\n"
    "uniform mat4 proj;\n"
    "void main()\n"
    "{\n"
    "   gl_Position = proj * view * model * vec4(aPos, 1.0);\n"
    "}\0";
// peeling fragment shader source code
// we compare the depth held in the depth texture of the FBO with the next depth
// if the next depth is less then or equal then we discard it
const char* peeling_fragmentShaderSource = "#version 330 core\n"
    "out vec4 FragColor;\n"
    "uniform vec4 cubecolour;\n"	//colour uniform
    "uniform sampler2DRect depthTexture;\n" // depth
    "void main()\n"
    "{\n" // in order to extract the deoth from the sampler2DRect we need to flip (x , y, z, w) (s, t, p, q)
    "   float frontDepth = texture(depthTexture, gl_FragCoord.xy).s;\n" // gl_FragCoord returns the  (x, y, z, 1/w) for the fragment
    "	if(gl_FragCoord.z <= frontDepth) discard;\n" // we want to see the back depth (equivalent to GL_GREATER)
    "   FragColor = cubecolour;\n"
    "}\n\0";

GLfloat rotation_x = 0.0f;
GLfloat rotation_y = 0.0f;

int main() {

    glfwInit();

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

    // vertice coordinates
    GLfloat vertices[] = {
        // set of vertices for each face

        -0.25f, 0.25f, 0.25f,
        -0.25f, -0.25f, 0.25f,
        0.25f, 0.25f, 0.25f,
        0.25f, -0.25f, 0.25f,

        0.25f, 0.25f, 0.25f,
        0.25f, -0.25f, 0.25f,
        0.25f, 0.25f, -0.25f,
        0.25f, -0.25f, -0.25f,

        0.25f, 0.25f, -0.25f,
        0.25f, -0.25f, -0.25f,
        -0.25f, 0.25f, -0.25f,
        -0.25f, -0.25f, -0.25f,

        -0.25f, 0.25f, -0.25f,
        -0.25f, -0.25f, -0.25f,
        -0.25f, 0.25f, 0.25f,
        -0.25f, -0.25f, 0.25f,

        0.25f, -0.25f, -0.25f,
        0.25f, -0.25f, 0.25f,
        -0.25f, -0.25f, -0.25f,
        -0.25f, -0.25f, 0.25f,

        0.25f, 0.25f, 0.25f,
        0.25f, 0.25f, -0.25f,
        -0.25f, 0.25f, 0.25f,
        -0.25f, 0.25f, -0.25f 
    };

    // indices for vertices order
    GLuint indices[] = {
        0, 1, 2,
        2, 1, 3,
                             
        4, 5, 6,
        6, 5, 7,

        8, 9, 10,
        10, 9, 11,

        12, 13, 14,
        14, 13, 15,

        16, 17, 18,
        18, 17, 19,

        20, 21, 22,
        22, 21, 23

    };
    const int num_cubes = 6;
    glm::vec3 cube_positions[6] = {
        glm::vec3( 0.0f,  0.0f,  0.0f),
        glm::vec3( 0.5f +0.2f,  0.0f,  0.0f),
        glm::vec3( -0.5f -0.2f,  0.0f,  0.0f),
        glm::vec3( 0.0f,  0.0f,  1.0f),
        glm::vec3( 0.5f +0.2f,  0.0f,  1.0f),
        glm::vec3( -0.5f -0.2f,  0.0f,  1.0f)

    };
    //constants for box colours 
    glm::vec4 box_colors[6]={
        glm::vec4(1,0,0,1), // red
		glm::vec4(0,1,0,1), // green
		glm::vec4(0,0,1,1), // blue
        glm::vec4(1,0,0,1), // red
		glm::vec4(0,1,0,1), // green
		glm::vec4(0,0,1,1) // blue
	};

    // glfw window of size SCR_WIDTH by SCR_HEIGHT 
    GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Depth Peeling with OpenGL", NULL, NULL);

    if (window == NULL) {
        
        printf("failed to create GLFW window \n");
        glfwTerminate();
        return -1;
    }
    else { printf("GLFW window creation successful ! \n");}
    glfwMakeContextCurrent(window); // tells glfw we want to use the window created

    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
    {
        printf("failed to initialize GLAD \n");
        return -1;
    }  

    // specify the viewport window goes from x = 0  to x = SCR_WIDTH and y = 0 to y = SCR_HEIGHT
    glViewport( 0, 0, SCR_WIDTH, SCR_HEIGHT);

    //-----//
    // basic shader
    // vertex shader reference
    GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1 , &vertexShaderSource, NULL);
    // compile shader into machine code
    glCompileShader(vertexShader);

    // fragment shader reference
    GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fragmentShader, 1 , &fragmentShaderSource, NULL);
    // compile shader into machine code
    glCompileShader(fragmentShader);

    GLuint shaderProgram = glCreateProgram();
    // attach shader to shader program
    glAttachShader(shaderProgram, vertexShader);
    glAttachShader(shaderProgram, fragmentShader);

    glLinkProgram(shaderProgram);

    // because the shaders are in the program we can delete
    glDeleteShader(vertexShader);
    glDeleteShader(fragmentShader);

    // shders for peeling the front layer off
    // vertex shader reference
    vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1 , &peeling_vertexShaderSource, NULL);
    // compile shader into machine code
    glCompileShader(vertexShader);

    // fragment shader reference
    fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fragmentShader, 1 , &peeling_fragmentShaderSource, NULL);
    // compile shader into machine code
    glCompileShader(fragmentShader);

    GLuint peeling_shaderProgram = glCreateProgram();
    // attach shader to shader program
    glAttachShader(peeling_shaderProgram, vertexShader);
    glAttachShader(peeling_shaderProgram, fragmentShader);

    glLinkProgram(shaderProgram);

    // because the shaders are in the program we can delete
    glDeleteShader(vertexShader);
    glDeleteShader(fragmentShader);

    //-----//

    initialize_framebuffers();    
    
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO); // because we only have one object
    glGenBuffers(1, &EBO);
    // binding object sets certain object to current object
    glBindVertexArray(VAO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); // draw mean vertices will be modified and used to draw images on the screen

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); 

    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(0);

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);


    glEnable(GL_DEPTH_TEST);

    //-----//

    while (!glfwWindowShouldClose(window)) {

        // check for keyboard input
        processInput(window);

        // set up for view and proj projections
        // view is for the view from the camera
        // proj is for clip space once the vertices are in the camera space by the view
        // model is for the objects
        glm::mat4 view = glm::mat4(1.0f);
        glm::mat4 proj = glm::mat4(1.0f);

        view = glm::translate(view, glm::vec3(0.0f, 0.0f, -4.0f)); // z is positive towards us and negative away from us

        proj = glm::perspective(glm::radians(45.0f), (float)(SCR_WIDTH/SCR_HEIGHT), 0.1f, 100.0f); // 45.0 rad = fov
                                                                                    // anything 0.1f close to camera is clipped and 100f clipped 
        view = glm::rotate(view, glm::radians(rotation_x), glm::vec3(1.0f, 0.0f, 0.0f));
        view = glm::rotate(view, glm::radians(rotation_y), glm::vec3(0.0f, 1.0f, 0.0f));

        // clear buffers prior to looping 
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        // loop through the number of passes
        for (int i = 0; i < NUM_PASSES; i++){
            int A = i % 2;
            int B = (i+1) % 2;
        }

        // point to matrix object itself  
        GLint viewLoc = glGetUniformLocation(shaderProgram, "view");
        glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));
        GLint projLoc = glGetUniformLocation(shaderProgram, "proj");
        glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(proj));

        glBindVertexArray(VAO);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
        // opengl works by having two buffers, while one is being displayed the other is being made in the backround and they swap
        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        // clear back buffer
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        
        // our first dept peeling pass
        glEnable(GL_DEPTH_TEST);

        glUseProgram(shaderProgram);

        // instancing of my cube
        for (unsigned int i = 0; i < num_cubes; i++)
        {
            // calculate the model matrix for each object and pass it to shader before drawing
            glm::mat4 model = glm::mat4(1.0f);
            model = glm::translate(model, cube_positions[i]); // translate the cubes to correct locations
            GLint modelLoc = glGetUniformLocation(shaderProgram, "model");
            glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));

            glUniform4fv(glGetUniformLocation(shaderProgram, "cubecolour"),1 , &(box_colors[i].x)); // set the uniform cube colour in the fragment shader to our colour

            glDrawElements(GL_TRIANGLES, sizeof(indices)/sizeof(int), GL_UNSIGNED_INT, 0);
        }
        /*
        for (int i = 0; i < NUM_PASSES; i++){
            glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            glClear(GL_COLOR_BUFFER_BIT);
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

            int A = i % 2;
            int B = (i+1) % 2;

            // depth buffer 1 to peel away previous fragment
            glBindFramebuffer(GL_FRAMEBUFFER, FBO[A]);
			//set the first colour attachment as draw buffer
			glDrawBuffer(GL_COLOR_ATTACHMENT0);
            
            glDisable(GL_BLEND);
            glDisable(GL_DEPTH_TEST);
            glDepthFunc(GL_GREATER); 
           
            // depth buffer 2 performs “regular” depth-buffering
            // front - back using the fragment shader
            glBindFramebuffer(GL_FRAMEBUFFER, FBO[B]);

            glEnable(GL_BLEND);
            glDisable(GL_DEPTH_TEST);
            glDepthFunc(GL_LESS);
            glBindVertexArray(VAO);
            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);

        }*/
        // swap back buffer with front buffer
        glfwSwapBuffers(window); // image gets updated at each frame
        glfwPollEvents();
    }

    glfwDestroyWindow(window);
    glfwTerminate();
    return 0;
}

void processInput(GLFWwindow *window)
{
    const GLfloat rotation_speed = 5;

    // exit
    if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
        glfwSetWindowShouldClose(window, true);
    
    // rotate scene view
    if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_UP) == GLFW_REPEAT)
        rotation_x -= rotation_speed;
    if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_REPEAT)
        rotation_x += rotation_speed;
    if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_REPEAT)
        rotation_y -= rotation_speed;
    if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_REPEAT)
        rotation_y += rotation_speed;
}


void initialize_framebuffers() {
	// set up two frame buffer objects, with a colour texture attachment and a depth textture attachment
	glGenFramebuffers(2, FBO);
	glGenTextures (2, colourTextureID);
	glGenTextures (2, depthTextureID);

	//for each attachment
	for (int i = 0; i < 2; i++) {
        // texture for depth
		glBindTexture(GL_TEXTURE_RECTANGLE, depthTextureID[i]);
		glTexImage2D(GL_TEXTURE_RECTANGLE , 0, GL_DEPTH_COMPONENT32F, SCR_WIDTH, SCR_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
        // texture for colour
		glBindTexture(GL_TEXTURE_RECTANGLE, colourTextureID[i]);
		glTexImage2D(GL_TEXTURE_RECTANGLE , 0,GL_RGBA, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);

		// bind FBO and attach the depth and colour attachments
		glBindFramebuffer(GL_FRAMEBUFFER, FBO[i]);
		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,  GL_TEXTURE_RECTANGLE, depthTextureID[i], 0);
		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, colourTextureID[i], 0);
	}

        // texture for colour blending at the end
        glGenTextures(1, &colourBlenderTextureID);
        glBindTexture(GL_TEXTURE_RECTANGLE, colourBlenderTextureID);
        glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGBA, GL_FLOAT, 0);

        //frame buffer for holding the colour blending texture and for depth (used at the end)
        glGenFramebuffers(1, &FBOcolourBlender);
        glBindFramebuffer(GL_FRAMEBUFFER, FBOcolourBlender);

        // attach the textures
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_RECTANGLE, depthTextureID[0], 0);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, colourBlenderTextureID, 0);

        GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
        if(status == GL_FRAMEBUFFER_COMPLETE )
            printf("FBO setup successful ! \n");
        else
            printf("problem with FBO setup \n");

        glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

// depth peeling is almost like shadow mapping because with shadow mapping we have to get the first z inorder to see what casts the shadow
#include <bits/stdc++.h>
using namespace std;
int binarySearch(int arr[], int size, int key)
{
   int start=0;
   int end=size-1;
   int mid=start+(start-end)/2;    //for avoiding excess memory
   while(start<=end)
   {
      if(arr[mid]==key) return mid;
      if(key>arr[mid])
      {
         start=mid+1;
      }
      else
      {
         end=mid-1;
      }
      mid=start+(start-end)/2;
   }
   return -1;
}

int main() {
	int even[6]={2,4,6,8,12,18};
	int odd[5]={3,8,11,14,17};
	
	int index=binarySearch(odd, 5, 95);
	cout<<"index of 95 is: "<<index;
	return 0;
}
        bool in_shadow(Surface* surface) {
            // check if ray from surface to light , hits light or is stopped by an object
            Eigen::Vector3f light_direction = (this->light_point - surface->point).normalized();
            Ray shadow_ray = Ray(surface->point, light_direction);
 
            float x = (this->light_point.x() - surface->point.x()) * (this->light_point.x() - surface->point.x());
            float y = (this->light_point.y() - surface->point.y()) * (this->light_point.y() - surface->point.y());
            float z = (this->light_point.z() - surface->point.z()) * (this->light_point.z() - surface->point.z());
            
            float distance_bw_light_point = std::sqrt(x + y + z);
 
            for (const auto& s : get_surfaces()) {
                if (s != surface && s->ray_intersection(shadow_ray) && ((s->point - surface->point).norm() <= distance_bw_light_point)) { return true; }
            }
            return false;
        }
// https://www.scratchapixel.com/lessons/3d-basic-rendering/global-illumination-path-tracing/global-illumination-path-tracing-practical-implementation.html
        // https://alexanderameye.github.io/notes/sampling-the-hemisphere/
        void PointLight::global_illuminate(Ray ray, Output* out, int bounces) { 
            // when using global lighting ignore specural
            if (bounces >= out->maxbounces || static_cast<float>(rand()) / static_cast<float>(RAND_MAX) < out->probterminate) {
                // diffuse calculation = surface->dc * surface->kd * NdotL;
                for (const auto& s : get_surfaces()) {
                    if (s->ray_intersection(ray)) {
                        Eigen::Vector3f light_direction = this->centre - s->point;
                        light_direction.normalize();
                        float cos_pheta = std::max(0.0f, ((s->normal).dot(light_direction)));

                        this->final_colour.x() = s->kd * s->dc.x() * cos_pheta;
                        this->final_colour.y() = s->kd * s->dc.y() * cos_pheta;
                        this->final_colour.z() = s->kd * s->dc.z() * cos_pheta;
                    }
                }
                this->final_colour = this->final_colour / bounces;
                return; // fmax(0.0f, surface->point.normal.dot(L)) * diffuse intensity * diffuse colour
            }
            else {
                for (const auto& s : get_surfaces()) {
                    if (s->ray_intersection(ray)) {
                        // cosine weighted hemisphere sampling
                        float r1 = static_cast<float>(rand()) / static_cast<float>(RAND_MAX); // between 0 and 1
                        float r2 = static_cast<float>(rand()) / static_cast<float>(RAND_MAX); // between 0 and 1

                        float theta = 2 * M_PI * r2;
                        float x = std::sqrt(r1) * cos(theta);
                        float y = std::sqrt(r1) * sin(theta);

                        Eigen::Vector3f new_direction(x, y, std::sqrt(std::max(0.0f, 1-r1)));

                        // create a new ray with out random sampling direction
                        Ray bounce_ray(s->point, new_direction);

                        // here is where we recursive and do the cosine weighted hemisphere sampling to determin direction of random ray

                        Eigen::Vector3f light_direction = this->centre - s->point;
                        light_direction.normalize();
                        float cos_pheta = std::max(0.0f, ((s->normal).dot(light_direction)));

                        this->final_colour = this->final_colour + (s->kd * s->dc * cos_pheta);
                        global_illuminate(bounce_ray,out, bounces + 1);
                    }
                    else {
                        // if we dont hitanything
                        continue;
                    }
                }
                // if our ray doesnt hit anything
                return;
            }
            // check for ray intersection with objects
            // if no we need to remove it from our samples and from our average
            // else return global_illuminate(reflection reflection_ray, bounces-1) * direct illumunation with diffuse * cospheta value (N dot L)

            // at each bounces where we intersect we calculate the light contribution which is only the diffuse value
            // and at the end these product up to the pixel colour value ( add them up and divive by num bounces )
        }
class Solution {
public:
    int fillCups(vector<int>& amount) {
        sort(amount.begin(), amount.end());
        int loww=amount[0], low=amount[1], lar=amount[2];
        int sum=low+loww+lar;
        if(lar<loww+low) return sum/2+sum%2;
        else return lar;
    }
};
#include <bits/stdc++.h> 

bool isSafe(int newx, int newy, vector<vector<bool>> &visited, vector<vector<int>> &arr, int n)
    {
        if((newx>=0&&newx<n)&&(newy>=0&&newy<n)&&visited[newx][newy]!=1&&arr[newx][newy]==1)
        {
            return true;
        }
        else return false;
    }
    
    void solve(int x, int y, int n, vector<vector<int>> &arr, vector<string> &ans, vector<vector<bool>> &visited, string path)
    {
        //base case
        if(x==n-1&&y==n-1)
        {
            ans.push_back(path);
            return;
        }
        
        visited[x][y]=1;
        
        //4 movement
        //DLRU
        //down
        if(isSafe(x+1, y, visited, arr, n))
        {
            solve(x+1, y, n, arr, ans, visited, path+'D');
        }
        
        //left
        if(isSafe(x, y-1, visited, arr, n))
        {
            solve(x, y-1, n, arr, ans, visited, path+'L');
        }
        
        //right
        if(isSafe(x, y+1, visited, arr, n))
        {
            solve(x, y+1, n, arr, ans, visited, path+'R');
        }
        
        //up
        if(isSafe(x-1, y, visited, arr, n))
        {
            solve(x-1, y, n, arr, ans, visited, path+'U');
        }
        visited[x][y]=0;
    }

vector < string > searchMaze(vector < vector < int >> & arr, int n) {
    // Write your code here.
    vector<string> ans;
    vector<vector<bool>> visited(n, vector<bool> (n, 0));
    string path="";
    if(arr[0][0]==0) return ans;
    solve(0, 0, n, arr, ans, visited, path);
    return ans;
}
//////Top-Down approach / recursion-memoization////
class Solution {
public:
    
    int solve(vector<int>& cost, int n, vector<int> &dp)
    {
        if(n==0) return cost[0];
        if(n==1) return cost[1];
        if(dp[n]!=-1) return dp[n];
        dp[n]=min(solve(cost, n-1,dp),solve(cost, n-2, dp))+cost[n];
        return dp[n];
    }
    
    int minCostClimbingStairs(vector<int>& cost) {
        int n=cost.size();
        vector<int> dp(n+1, -1);
        int ans=min(solve(cost, n-1, dp),solve(cost, n-2, dp));
        return ans;
    }
};

/////Tabulation / bottom-up approach/////
class Solution {
public:
    
    int solve(vector<int>& cost, int n)
    {
        vector<int> dp(n+1, -1);
        dp[0]=cost[0];
        dp[1]=cost[1];
        for(int i=2;i<n;i++)
        {
            dp[i]=min(dp[i-1],dp[i-2])+cost[i];
        }
        return min(dp[n-1], dp[n-2]);
    }
    
    int minCostClimbingStairs(vector<int>& cost) {
        int n=cost.size();
        
        
        return solve(cost, n);
    }
};

////////space optimization///////
class Solution {
public:
    
    int solve(vector<int>& cost, int n)
    {
        int pr1=cost[0], pr2=cost[1], curr;
        for(int i=2;i<n;i++)
        {
            curr=min(pr1,pr2)+cost[i];
            pr1=pr2;
            pr2=curr;
        }
        return min(pr1, pr2);
    }
    
    int minCostClimbingStairs(vector<int>& cost) {
        int n=cost.size();
        
        
        return solve(cost, n);
    }
};
/////////////Top-down approach ( recursion+memoization )/////////////
class Solution {
public:
    
    int solve(int n, vector<int> &dp)
    {
       if(n<=1) return n;
       if(dp[n]!=-1) return dp[n];
       dp[n]=solve(n-1, dp)+solve(n-2,dp);
       return dp[n];
    } 
    
    int fib(int n) {
        vector<int> dp(n+1, -1);
        return solve(n, dp);
    }
};

/////////////////Bottom-Top approach//////////////////////
class Solution {
public:
    int fib(int n) {
        if(n<=1) return n;
        int dp[n+1];
        for(int i=0;i<=n;i++)
        {
            dp[i]=-1;
        }
        dp[0]=0;
        dp[1]=1;
        for(int i=2;i<=n;i++)
        {
            dp[i]=dp[i-1]+dp[i-2];
        }
        return dp[n];
    }
};


///////////////////////Space optimization/////////////////
class Solution {
public:
    int fib(int n) {
        if(n<=1) return n;
        int pr1=0, pr2=1, curr;
        for(int i=2;i<=n;i++)
        {
            curr=pr1+pr2;
            pr1=pr2;
            pr2=curr;
        }
        return curr;
    }
};
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long t;
	cin>>t;
	while(t--)
	{
	   long long n, q;
	   cin>>n>>q;
	   long long a[n];
	   long long sum1=0, sum2=0;
	   for(long long i=0;i<n;i++)
	   {
	      cin>>a[i];
	   }
	   long long int prefsum[n+1];
	   prefsum[0]=0;
	   for(int i=0;i<n;i++)
	   {
	       sum1+=a[i];
	       prefsum[i+1]=sum1;
	       
	   }
	   while(q--)
	   {
	      long long l,r,k;
	      cin>>l>>r>>k;
	      long long int p=prefsum[r]-prefsum[l-1];
	      sum2=prefsum[n]+((k*(r-l+1))-p);
	      if(sum2%2==1) cout<<"YES\n";
         else cout<<"NO\n";
	   }
	}
	return 0;
}
class Solution {
public:
    vector<int> topKFrequent(vector<int>& nums, int k) {
        unordered_map<int, int> mp;
        for(int i=0;i<nums.size();i++)
        {
            mp[nums[i]]++;
        }
        priority_queue<pair<int,int>, vector<pair<int, int>>, greater<pair<int, int>>>minH;
        for(auto x:mp)
        {
            minH.push({x.second, x.first});
            if(minH.size()>k) minH.pop();
        }
        vector<int> ans;
        while(!minH.empty())
        {
            ans.push_back(minH.top().second);
            minH.pop();
        }
        return ans;
    }
};
class Solution {
public:
    vector<vector<int>> kClosest(vector<vector<int>>& points, int k) {
        int n=points.size();
        priority_queue<pair<int,pair<int, int>>> mxH;
        for(int i=0;i<n;i++)
        {
            int dis=pow(points[i][0],2)+pow(points[i][1],2);
            mxH.push({dis,{points[i][0], points[i][1]}});
            if(mxH.size()>k) mxH.pop();
        }
        vector<vector<int>> ans;
        while(!mxH.empty())
        {
            vector<int> temp;
            temp.push_back(mxH.top().second.first);
            temp.push_back(mxH.top().second.second);
            ans.push_back(temp);
            mxH.pop();
        }
        
        return ans;
    }
};
class Solution {
public:
    int c=0;
    
    void bfs(vector<vector<int>>& isConnected, vector<bool> &v, int i,  unordered_map<int, set<int>> &m)
    {
        queue<int> q;
        q.push(i);
        v[i]=true;
        while(!q.empty())
        {
            int p=q.front();
            q.pop();
            
            for(auto x:m[p])
            {
                if(!v[x])
                {
                    q.push(x);
                    v[x]=true;
                }
            }
        }
    }
    void makeadj(vector<vector<int>> &isConnected, unordered_map<int, set<int>> &m)
    {
        int n=isConnected.size();
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(isConnected[i][j]==1)
                {
                    m[i+1].insert(j+1);
                    m[j+1].insert(i+1);
                }
            }
        }
    }
    
    int findCircleNum(vector<vector<int>>& isConnected) {
        int n=isConnected.size();
        vector<bool> v(n+1,false);
        unordered_map<int, set<int>> m;
        makeadj(isConnected, m);
        for(int i=1;i<=n;i++)
        {
            if(!v[i])
            {
                c++;
                bfs(isConnected, v, i, m);
            }
        }
        return c;
    }
};
class Solution {
public:
    bool canVisitAllRooms(vector<vector<int>>& rooms) {
        int n=rooms.size();
        vector<bool> visited(n, 0);
        queue<int>q;
        q.push(0);
        visited[0]=1;
        while(!q.empty())
        {
            int p=q.front();
            q.pop();
            
            for(auto x:rooms[p])
            {
                if(!visited[x])
                {
                    q.push(x);
                    visited[x]=1;
                }
            }
        }
        bool g=true;
        for(auto x:visited)
        {
            if(!x) g=false;
        }
        return g;
    }
};
class Solution {
public:
    vector<int> findSmallestSetOfVertices(int n, vector<vector<int>>& edges) {
        vector<bool> v(n,false);
        for(int i=0;i<edges.size();i++)
        {
            v[edges[i][1]]=true;
        }
        vector<int> ans;
        for(int i=0;i<n;i++)
        {
            if(!v[i]) ans.push_back(i);
        }
        return ans;
    }
};
class Solution {
public:
    vector<vector<int>> ans;
    
    void dfs(int curr, int dest, vector<vector<int>>& graph, vector<int> &path)
    {
        path.push_back(curr);
        if(curr==dest)
        {
            ans.push_back(path);
        }
        else
        {
            for(auto x:graph[curr])
            {
                dfs(x, dest, graph, path);
            }
        }
        path.pop_back();
    }
    
    vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) {
        int n=graph.size()-1;
        
        vector<int> path;
        dfs(0, n, graph, path);
        return ans;
    }
};
class Solution {
public:
    int findJudge(int n, vector<vector<int>>& trust) {
        vector<int> v2(n+1,0);
        vector<int> v3(n+1,0);
        for(int i=0;i<trust.size();i++)
        {
            int u=trust[i][0];
            int v=trust[i][1];
            v2[v]++;
            v3[u]++;
        }
        int ans=-1;
       for(int i=1;i<=n;i++)
       {
           if(v2[i]==n-1&&v3[i]==0) ans=i;
       }
        return ans;
    }
};
class Solution {
public:
    bool validPath(int n, vector<vector<int>>& edges, int source, int destination) {
        unordered_map<int, set<int>>m;
        vector<bool> visited(n, false);
        visited[destination]=0;
        for(int i=0;i<edges.size();i++)
        {
            int u=edges[i][0];
            int v=edges[i][1];
            m[u].insert(v);
            m[v].insert(u);
        }
        queue<int>q;
        q.push(source);
        visited[source]=true;
        while(!q.empty())
        {
            int p=q.front();
            q.pop();
            
            
            for(auto x:m[p])
            {
                if(!visited[x])
                {
                    q.push(x);
                    visited[x]=true;
                }
            }
        }
        if(visited[destination]==1) return true;
        return false;
    }
};
class Solution {
public:
    int findCenter(vector<vector<int>>& edges) {
        int n=edges.size();
        unordered_map<int, int>m;
        for(int i=0;i<n;i++)
        {
            m[edges[i][0]]++;
            m[edges[i][1]]++;
        }
        int ans=0;
        for(auto x:m)
        {
            if(x.second==n)
            {
                ans=x.first;
                break;
            }
        }
        return ans;
    }
};
#include<bits/stdc++.h>

void mkadj(unordered_map<int, set<int>> &mp, vector<vector<int>> &edges)
{
    for(int i=0;i<edges.size();i++)
    {
        int u = edges[i][0];
        int v = edges[i][1];

        mp[u].insert(v);
        mp[v].insert(u);
    }
}

void dfs(unordered_map<int, set<int>> &mp, unordered_map<int, bool> &visited, vector<int> &comp, int node)
{
    comp.push_back(node);
    visited[node]=true;
    for(auto x:mp[node])
    {
        if(!visited[x]) dfs(mp, visited, comp, x);
    }
}

vector<vector<int>> depthFirstSearch(int V, int E, vector<vector<int>> &edges)
{
    unordered_map<int, set<int>> mp;
    unordered_map<int, bool> visited;
    mkadj(mp, edges);
   
    vector<vector<int>> ans;
    
    for(int i=0;i<V;i++)
    {
        if(!visited[i])
        {
            vector<int> comp;
            dfs(mp, visited, comp, i);
            ans.push_back(comp);
        }

    }
    return ans;
    // Write your code here
}
#include <bits/stdc++.h> 

void makeAdj(unordered_map<int, set<int>>&mp1, vector<pair<int, int>> &edges)
{
    for(int i=0; i<edges.size(); i++)
    {
        int u = edges[i].first;
        int v = edges[i].second;
        mp1[u].insert(v);
        mp1[v].insert(u);
    }
}

void bfstrav(vector<int> &ans, unordered_map<int, bool> &visited, unordered_map<int, set<int>>&mp1, int node)
{
    queue<int> q;
    q.push(node);
    visited[node]=1;

    while(!q.empty())
    {
        int p=q.front();
        q.pop();

        ans.push_back(p);

        for(auto x: mp1[p])
        {
            if(!visited[x]) 
            {
                q.push(x);
                visited[x]=1;
            }
        }

    }
}


vector<int> BFS(int vertex,vector<pair<int, int>> edges)
{
    vector<int> ans;
    unordered_map<int, bool> visited;
    unordered_map<int, set<int>>mp1;
    makeAdj(mp1, edges);
    for(int i=0;i<vertex;i++)
    {
        if(!visited[i]) bfstrav(ans, visited, mp1, i);
    }
    return ans;
    // Write your code here
}
class Solution {
  public:
    // Function to return the adjacency list for each vertex.
    vector<vector<int>> printGraph(int V, vector<int> adj[]) {
        vector<vector<int>> v2;
        for(int i=0;i<V;i++)
        {
            vector<int> v1;
            v1.push_back(i);
            for(int j=0;j<adj[i].size();j++)
            {
                v1.push_back(adj[i][j]);
            }
            v2.push_back(v1);
        }
        return v2;
    }
};
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    int w; // width of the building.
    int h; // height of the building.
    cin >> w >> h; cin.ignore();
    int n; // maximum number of turns before game over.
    cin >> n; cin.ignore();
    int x0;
    int y0;
    cin >> x0 >> y0; cin.ignore();
    int w0 = 0 , h0 = 0;

    // game loop
    while (1) {
        string bomb_dir; // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
        cin >> bomb_dir; cin.ignore();


        if (bomb_dir.find("U") != string::npos){
            h = y0;
            y0 = ((y0+h0)/2) ;
        }
        if (bomb_dir.find("D") != string::npos){
            h0 = y0;
            y0 = floor((y0+h)/2);
        }
        if(bomb_dir.find("R") != string::npos){
            w0 = x0;
            x0 = floor((x0+w) /2);
        }
        if(bomb_dir.find("L") != string::npos){
            w = x0;
            x0 = floor((x0+w0)/2);
        }

        cout << to_string(x0) + " " + to_string(y0) << endl;
    }
}
vector < vector < int >> printAdjacency(int n, int m, vector < vector < int >> & edges) {
    vector<int> ans[n];
    //ans array will store all adjaject nodes corresponding to indexes.
    for(int i=0;i<m;i++)
    {
        int u=edges[i][0];
        int v=edges[i][1];

        ans[u].push_back(v);
        ans[v].push_back(u);
    }

    vector<vector<int>> adj(n);
    for(int i=0;i<n;i++)
    {
        adj[i].push_back(i);

        //entering neighbours
        for(int j=0;j<ans[i].size();j++)
        {
            adj[i].push_back(ans[i][j]);
        }
    }
    return adj;
}
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */

class Solution {
public:
    TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
        if(!root) return NULL;
        if(root==p||root==q) return root;
        
        TreeNode* l=lowestCommonAncestor(root->left, p, q);
        TreeNode* r=lowestCommonAncestor(root->right, p, q);
        
        if(!l) return r;
        else if(!r) return l;
        else return root;
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */

//BFS Travesal

class Solution {
public:
    int kthSmallest(TreeNode* root, int k) {
        vector<int> v;
        queue<TreeNode*> q;
        TreeNode* p;
        q.push(root);
        
        while(!q.empty())
        {
            p=q.front();
            q.pop();
            ///int p2=p->val;
            v.push_back(p->val);
            if(p->left) q.push(p->left);
            if(p->right) q.push(p->right);
        }
        sort(v.begin(), v.end());
        return v[k-1];
    }
};

//Inorder traversal

class Solution {
public:
    int kthSmallest(TreeNode* root, int k) {
        vector<int> v;
        queue<TreeNode*> q;
        TreeNode* p;
        q.push(root);
        
        while(!q.empty())
        {
            p=q.front();
            q.pop();
            ///int p2=p->val;
            v.push_back(p->val);
            if(p->left) q.push(p->left);
            if(p->right) q.push(p->right);
        }
        sort(v.begin(), v.end());
        return v[k-1];
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    
    bool isValidBST(TreeNode* root) {
       
        return check(root, LONG_MIN, LONG_MAX);
    }
    
   bool check(TreeNode* root, long minval, long maxval)
   {
       if(!root) return true;
       if(root->val>=maxval||root->val<=minval) return false;
       
       return check(root->left, minval, root->val)&&check(root->right, root->val, maxval);
   }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
        if(!root) return NULL;
        if(root==p||root==q) return root;
        TreeNode* l=lowestCommonAncestor(root->left, p, q);
        TreeNode* r=lowestCommonAncestor(root->right, p, q);
        
        if(!l) return r;
        else if(!r) return l;
        else return root;
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    
    int largeheight(TreeNode* root)
    {
        if(!root) return 0;
        return max(largeheight(root->left), largeheight(root->right))+1;
    }

    int diameterOfBinaryTree(TreeNode* root) {
        if(!root) return 0;
        int h1=largeheight(root->left);
        int h2=largeheight(root->right);
        int p1=h1+h2;
        return max(p1, max(diameterOfBinaryTree(root->left), diameterOfBinaryTree(root->right)));
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    vector<vector<int>> v;
    void solve(TreeNode* root, vector<int> &ans, int curr, int targetSum)
    {
        if(!root) return;
        curr+=root->val;
        ans.push_back(root->val);
        if(curr==targetSum && !root->left && !root->right) v.push_back(ans);
        if(root->left) solve(root->left, ans, curr, targetSum);
        if(root->right) solve(root->right, ans, curr, targetSum);
        ans.pop_back();
    }
    
    vector<vector<int>> pathSum(TreeNode* root, int targetSum) {
        vector<int> ans;
        solve(root, ans, 0, targetSum);
        return v;
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */


class Solution {
public:
    bool hasPathSum(TreeNode* root, int targetSum) {
        if(!root) return false;
        if(!root->left&&!root->right) 
        {
            return (targetSum==root->val) ;
        }
        bool p=false;
        if(root->left) p = hasPathSum(root->left, targetSum-root->val);
        if(root->right) p=p||hasPathSum(root->right, targetSum-root->val);
        
        return p;
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    vector<vector<int>> verticalTraversal(TreeNode* root) {
        vector<vector<int>> v;
        if(!root) return v;
        map<int, map<int, vector<int>>> mp;
        queue<pair<TreeNode*, pair<int,int>>>q;
        q.push({root, {0,0}});
        while(!q.empty())
        {
            auto f=q.front();
            q.pop();
            int p8=f.first->val;
            int hdfo=f.second.first;
            int dfo=f.second.second;
            mp[hdfo][dfo].push_back(p8);
            if(f.first->left) q.push({f.first->left, {hdfo-1, dfo+1}});
            if(f.first->right) q.push({f.first->right, {hdfo+1, dfo+1}});
        }
        
        for(auto i:mp)
        {
            vector<int> v2;
            for(auto j:i.second)
            {
                sort(j.second.begin(), j.second.end());
                for(auto k:j.second)
                {
                    v2.push_back(k);
                }
            }
            v.push_back(v2);
        }
        return v;
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    vector<vector<int>> levelOrderBottom(TreeNode* root) {
        vector<vector<int>> v;
        queue<TreeNode*> q;
        q.push(root);
        if(!root) return v;
        while(!q.empty())
        {
            vector<int> v2;
            int p1=q.size();
            while(p1--)
            {
                TreeNode* temp=q.front();
                q.pop();
                v2.push_back(temp->val);
                if(temp->left) q.push(temp->left);
                if(temp->right) q.push(temp->right);
            }
            v.push_back(v2);
            
        }
        reverse(v.begin(), v.end());
        return v;
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    vector<vector<int>> zigzagLevelOrder(TreeNode* root) {
        queue<TreeNode*> q;
        q.push(root);
        vector<vector<int>> v;
        if(root==NULL) return v;
        bool p=true;
        while(!q.empty())
        {
            vector<int> v2;
            int p2=q.size();
            while(p2--)
            {
                TreeNode* temp=q.front();
                q.pop();
                v2.push_back(temp->val);
                if(temp->left) q.push(temp->left);
                if(temp->right) q.push(temp->right);
            }
            
            if(!p) 
            {
                reverse(v2.begin(), v2.end());
                p=true;
            }
            else p=false;
            v.push_back(v2);
        }
        return v;
    }
};
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    vector<vector<int>> levelOrder(TreeNode* root) {
        vector<vector<int>> v;
        if(root==NULL) return v;
        queue<TreeNode*> q;
        q.push(root);
        while(!q.empty())
        {
            vector<int> v2;
            int p=q.size();
            while(p--)
            {
                TreeNode* temp=q.front();
                q.pop();
                
                v2.push_back(temp->val);
                if(temp->left) q.push(temp->left);
                if(temp->right) q.push(temp->right);
                
            }
            v.push_back(v2);
            
        }
        
        return v;
    }
};
#include <iostream>

int main() {
    int b;
    std::cout << "Podaj ilosć liczn: ";
    std::cin >> b;
    int a[b];

    for(int i = 0; i < b; ++i){
        std::cout << "Podaj liczbe " << i +1 << ": ";
        std::cin >> a[i];
        std::cout << "\n";
    }

    int maks = a[0];
    for(int i = 0; i < b; ++i) {
        if(a[i] > maks){
            maks = a[i];
        }
    }

    for(int i = 0; i < maks; i++){
        for(int j = 0; j < b; j++) {
            if(a[j] < maks - i ){
                std::cout << " ";}
            else{
                std::cout << "*";}
        }
        std::cout << "\n";
    }
    return 0;
}
#include <stdlib.h>
#include <stdio.h>
using namespace std;

struct Array
{
    int *A;
    int size;
    int length;
};

void Display(struct Array arr)
{
  int i;
  printf("\n Elements are \n");
  for(i=0; i<arr.length; i++)
    printf("%d ", arr.A[i]);
}

void Append (struct Array *arr, int x)
{
  if(arr->length < arr->size)
    arr->A[arr->length++] = x;
}

void Insert(struct Array *arr, int index, int x)
{
  int i;
  if(index >= 0 && index <= arr->length)
    {
      for(i=arr->length; i>index; i--)
        arr->A[i] = arr->A[i-1];
      arr->A[index]=x;
      arr->length++;
    }
}

int main() 
{
    struct Array arr= {{2,3,4,5,6}, 10, 5};
	Append(&arr, 10);
	insert(&arr, 5, 10);
	Display(arr);
  
    //printf("Enter the size of an array : ") ;
    //scanf("%d", &arr.size);
    //arr.A = (int *)malloc(arr.size*sizeof(int));
    //arr.length=0;

    return 0;
}
#include <iostream>
using namespace std;
 
void TOH(int n, int a, int b, int c)
{
    if(n>0)
    {
        TOH(n-1,a,c,b);
        cout << "from " << a << " to " << c <<endl;
        TOH(n-1,b,a,c);
    }
}
int main() 
{
    TOH(6,1,2,3);
    return 0;
}
#include <iostream>
using namespace std;

int fact(int n)
{
    if (n==0) return 1;
    else return fact(n-1)*n;
}

int ncr(int n, int r)
{
    int num, den;
    num = fact(n);
    den = fact(r)*fact(n-r);
    return num/den;
}

int NCR(int n, int r)  //using recursion
{
    if (n==r || r==0)
        return 1;
    else
        return NCR(n-1, r-1) + NCR(n-1,r);
}

int main() 
{
    cout << ncr(2,0) << endl;
    cout << NCR(5,1);
    return 0;
}
#include <iostream>
using namespace std;

int F[10];     //all array elements are initialized with -1
int fib(int n)
{
    if (n<=1)
    {
        F[n] = n;
        return n;
    }
    else
    {
        if (F[n-2] == -1)
            F[n-2]= fib(n-2);
        if (F[n-1] == -1) 
            F[n-1] = fib (n-1);
        return  F[n-2] + F[n-1];
    }
}

int main() 
{
    for(int i=0; i<10; i++)
        F[i]=-1;
    cout << fib(9);
    return 0;
}
#include <iostream>
using namespace std;

int fib( int n)
{
    if (n<=1)
        return n;
    else 
        return fib(n-1) + fib(n-2);
}


int main() 
{
    cout << fib(9);
    return 0;
}
#include <iostream>
using namespace std;

int fib(int n)
{
    int t0 = 0, t1 = 1, s=0, i;
    if (n<=1)
        return n;
    else
        for(i=2;i<=n;i++)
        {
            s = t0 + t1;
            t0 = t1;
            t1 = s;
        } 
        return s;
}

int main() 
{
    cout << fib(9);
    return 0;
}
#include <iostream>
using namespace std;



double e(int x, int n)
{
    static double s;
    if (n==0)
        return s;
    else
        s = 1 + x*(s/n);
        return e(x, n-1);
}


int main() {
    double sum= e(1,10);
    cout << sum;
    return 0;
}
#include <iostream>
using namespace std;

double e (int x, int n)
{
    static double p=1, f=1;
    double r=0;
    if (n==0)
        return 1;
    else
        r = e(x,n-1);
        p=p*x;
        f=f*n;
        return r+(p/f);
}

int main() {
    double sum= e(1,10);
    cout << sum;
    return 0;
}
#include <iostream>
using namespace std;

int fun(int n)
{
    if(n>100)
        return n-10;
    else
        fun(fun(n+11));    //nested recursive call
}

int main() 
{
    cout << fun(97);
  
    return 0;
}
#include <iostream>
using namespace std;

void funB(int n);

void funA(int n)
{
    if(n>0)
    {
        cout << n << " ";
        funB(n-1);
    }
}
void funB(int n)
{
    if(n>1)
    {
        cout <<n <<" ";
        funA(n/2);
    }
}

int main() 
{
    funA(20);
    return 0;
}
#include <iostream>
using namespace std;

void fun(int n)
{
    if(n>0)
    {
        cout << n << " ";
        fun(n-1);
        fun(n-1);
    }
}

int main() 
{
    fun(3);
    return 0;
}
#include <iostream>
using namespace std;

//int x= 0;      or .....global variable
int fun(int n)
{
    static int x=0;       //local static variable
    if(n>0)
    {
        x++;
       return fun(n-1) +x;
    }
    return 0;
}
int main() 
{
    int r;
    r = fun(5);
    cout<<r;
    return 0;
}
#include <iostream>
using namespace std;

template <class T>
class Arithmetic
{
private :
    T a;
    T b;
public :
    Arithmetic(T a,T b);
    T add();
    T sub();
};

template<class T>
Arithmetic<T>::Arithmetic(T a,T b)
{
    this->a =a;
    this->b =b;
}

template <class T>
T Arithmetic<T>:: add()
{
    T c;
    c = a+b;
    return c;
}

template <class T>
T Arithmetic<T>:: sub()
{
    T c;
    c = a-b;
    return c;
}

int main() 
{
    Arithmetic<int> ar(10,5);
    cout<<ar.add()<<endl;
    cout<<ar.sub()<<endl;
    
    Arithmetic<float> ar1(1.22,1.3);
    cout<<ar1.add()<<endl;
    cout<<ar1.sub()<<endl;
    
    return 0;
}
#include <iostream>;
#include <string>;
#include <random>;
using namespace std;

class Auto
{
public:
    void Start();
    void Accelerate();
    void Break();
    string model;
    string cylinder;

    Auto(string x, string y)
    {
        model = x;
        cylinder = y;
    }
};
void Start()
{
    cout << "Start\n";
}
void Accelerate()
{
    cout << "Accelerate\n";
}
void Break()
{
    cout << "Break\n";
}

int main()
{
    srand(time(NULL));

    int randomAction;
    int randomAuto;
    randomAction = (rand() % 3) + 1;
    randomAuto = (rand() % 3) + 1;

    switch (randomAction)
    {
    case 1:
        Start();
        break;
    case 2:
        Accelerate();
        break;
    case 3:
        Break();
        break;
    }

    Auto auto1("CADILAC", "5");
    Auto auto2("Ferrari", "7");
    Auto auto3("Lamborghini", "9");

    switch (randomAuto)
    {
    case 1:
        cout << "The model is: " << auto1.model << ", and the cylinder is: " << auto1.cylinder << endl;
        break;
    case 2:
        cout << "The model is: " << auto2.model << ", and the cylinder is: " << auto2.cylinder << endl;
        break;
    case 3:
        cout << "The model is: " << auto3.model << ", and the cylinder is: " << auto3.cylinder << endl;
        break;
    }
}
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;

class nodes { //objet node
public :
    nodes() {
        next = NULL;
    }
    int element; //element dans la node
    nodes* next; //prochain element
}*front = NULL, *rear=NULL, *n, *temp, *temp1; //initialisation des variables

class circularqueue { //objet de la queue circulaire
public :
    //Fonctions des queues circulaire
    void InsertQueue(); 
    void Delete();
    void SearchQueue();
    void DisplayQueue();
};

//Fonction delete des queues circulaires
void circularqueue::Delete() {
    int x; // element à enlever
    temp = front; // temp devient la position de front
    if (front == NULL) { //Si pas de front (empty)
        cout << "The queue is empty" << endl;
    }
    else {
        if (front == rear) {//si positon de front est la meme que rear (un seul element)
            x = front->element; //x devient la valeur de front
            delete(temp); //enleve l'élément qui est à la position de temp(front)
            front = NULL; //Remet front à null
            rear = NULL;// remet rear à null
        }
        else {
            x = temp->element; //x devient la valeur de front (temp == front)
            front = front->next; //front devient le prochain élément
            rear->next = front; //la position de rear devient la position du prochain de front (rear devient l'ancien front)
            delete(temp); //eneleve l'élement temporaire
        }
        cout << "Element " << x << " has been deleted" << endl;
    }
}
void circularqueue::InsertQueue() {
    n = new nodes[sizeof(nodes)]; //crée un nouvel objet node
    cout << "Enter the element you wish to insert: ";
    cin >> n->element; //entrer l'élément de la nouvelle node
    if (front == NULL) { //si front est null
        front = n; //emplacement de front est maintenant la valeur entrée
    } else
    {
        rear->next = n; //position de rear devient le prochain
    }
    rear = n; //l'emplacement rear devient la valeur entrée
    rear->next = front; //position rear devient le prochain
}

void circularqueue::SearchQueue(){
    int search; // Valeur a chercher dans la queue
    int n = 0; //Compteur

    temp = front; // Valeur temporaire est à front;
    temp1 = NULL; // Autre valeur temp. est nulle

    if (front == NULL) { //Si front na pas d'élément
        cout << "The queue is empty..." << endl;
    }
    else {
        cout << "Enter the element you are searching for: ";
        cin >> search; //Enter l'élément à trouver

        while (temp != temp1) { //Fait pendant que la valeur temp != front
            if (search == temp->element) { //si le search est egal à l'élément de la node
                n++; //ajoute au compteur
                temp = temp->next; //change la valeur du front pour la prochaine valeur
                temp1 = front; //Deuxieme temporaire devient la valeur front
            }
        }
        cout << "The element " << search << " is in the queue " << n << " times." << endl;
    }
    return ;
}

void circularqueue::DisplayQueue() {
    temp = front; //temp devient la position de front
    temp1 = NULL; //deuxieme temp  est NULL
    if (front == NULL) { //si la front est vide
        cout << " The queue is empty..." << endl;
    }
    else { //si c'est pas vide
        cout << "The elements in the queue are: ";
        while (temp != temp1) { //pendant que temp n'est pas temp1 (le tour de la queue n'est pas complétée)
            cout << temp->element << " ";
            temp = temp->next; //temp devient la prochaine position
            temp1 = front; //temp 1 devient le front
        }
    }
 }
void OptionList() {
    cout << "1: Insert in the queue." << endl;
    cout << "2: Delete from the queue." << endl;
    cout << "3: Search the queue." << endl;
    cout << "4: Display the queue." << endl;
}
int main() {
    int opt; //option choisie
    bool whileTrue = true; //bool qui est toujours true pour options

    circularqueue Queue; //crée une nouvel object de circular queue
    
    //choisir un option
    while (whileTrue) {

        OptionList();

        cout << "Enter your desired option: ";
        cin >> opt;

        switch (opt) {
        case 1: Queue.InsertQueue();
            break;
        case 2: Queue.Delete();
            break;
        case 3:Queue.SearchQueue();
            break;
        case 4: Queue.DisplayQueue();
            break;
        }

    }
}
#include <iostream>
using namespace std;

class Rectangle
{
    public :
    int length;
    int breadth;

Rectangle(int l, int b)
{
    length = l;
    breadth = b;
}

int area()
{
    return length*breadth;
}

int perimeter()
{
    int p = 2*(length*breadth);
    return p;
}
};

int main() 
{
    int l,b;
    cout << "Enter length and breadth : ";
    cin >> l >> b;
    Rectangle r(l,b);
    
    int a = r.area();
    cout <<"Area is : "<<a << endl;
    
    int peri = r.perimeter();
    cout <<"perimeter is :"<<peri;

    return 0;
}
#include <iostream>
using namespace std;

struct rectangle
{
    int length;
    int breadth;
};

void initialize(struct rectangle *r, int l, int b)
{
    r->length = l;
    r->breadth = b;
}

int area(rectangle r)
{
    return r.length*r.breadth;
}

int perimeter(rectangle r)
{
    int p = 2*(r.length*r.breadth);
    return p;
}

int main() 
{
    rectangle r={0,0};
    int l,b;
    cout << "Enter length and breadth : ";
    cin >> l >> b;
    initialize(&r,l,b);
    
    int a = area(r);
    cout <<"Area is : "<<a << endl;
    
    int peri = perimeter(r);
    cout <<"perimeter is :"<<peri;

    return 0;
}
}
#include <iostream>
using namespace std;

int area(int length, int breadth)
{
    return length*breadth;
}

int perimeter(int length, int breadth)
{
    int p = 2*(length*breadth);
    return p;
}

int main() 
{
    int length = 0, breadth =0;
    cout << "Enter length and breadth : ";
    cin >> length >> breadth;
    
    int a = area(length,breadth);
    cout <<"Area is : "<<a << endl;
    
    int peri = perimeter(length,breadth);
    cout <<"perimeter is :"<<peri;

    return 0;
}
#include <iostream>
using namespace std;

int main() 
{
    int length = 0, breadth =0;
    cout << "Enter length and breadth : ";
    cin >> length >> breadth;
    
    int area = length*breadth;
    cout <<"Area is : "<<area << endl;
    
    int peri = 2*(length*breadth);
    cout <<"perimeter is :"<<peri;

    return 0;
}
#include <iostream>
using namespace std;

struct rectangle
{
  int length;
  int breadth;
};

struct rectangle *fun()
{
  struct rectangle *p;
  p = new rectangle;
  //p= (struct rectangle *)malloc(sizeof(struct rectangle));
  
  p->length = 15;
  p->breadth = 7;
  
  return p;
}

int main()
{
  struct rectangle *ptr = fun();
  cout << "length : "<<ptr->length<<endl<<"breadth : "<< ptr->breadth<<endl;
  
  return 0;
}
#include <iostream>
using namespace std;

int fun(int size)
{
  int *p;
  p = new int[size];
  
  for(int i=0; i<size; i++)
    p[i]=i+1;
  return p;
}

int main()
{
  int *ptr, sz = 5;
  ptr = fun(sz);
  
  for(int i=0;i<sz;i++)
    cout << ptr[i]<<endl;
  
  return 0;
}
#include <iostream>
using namespace std;

void swap(int &x, int &y)      //passing the reference
{
  int temp;
  temp = x;
  x=y;
  y = temp;
}

int main()
{
  int a, b;
  a=10;
  b=20;
  swap(a,b);
  
  cout << "a = "<<a <<", b = "<<b << endl;     //a = 10, b = 20
  
  return 0;
}
#include <iostream>
using namespace std;
 
void swap(int *x, int *y)        //getting the pointers 
{
  int temp;
  temp = *x;
  *x=*y;
  *y = temp;
}
int main()
{
  int a, b;
  a=10;
  b=20;
  swap(&a,&b);          //passing the address
  
  cout << "a = "<<a <<", b = "<<b << endl;     //a = 10, b = 20
  
  return 0;
}
#include <iostream>
using namespace std;

void swap(int x, int y)
{
  int temp;
  temp = x;
  x=y;
  y = temp;
}
int main()
{
  int a, b;
  a=10;
  b=20;
  swap(a,b);
  
  cout << "a = "<<a <<", b = "<<b << endl;     //a = 10, b = 20
  
  return 0;
}
#include<iostream>
using namespace std;
int main()
{
 int arr[10] = {0},key,c,d,ch=1;     //k = key, c = collision, d = data
 for(int i=0; i<=9 ; i++)
 {
  cout<<" "<<arr[i];
 }
 while(ch==1)
 {
  cout<<"\nEnter Key";
  cin>>key;
    c = 0;
  d = key % 10;
  for(int i=0;i<=9;i++)
  {
   if(arr[d]>0)
   {
    d++;
    c++;
   }
  }
  arr[d]  = key;
  for(int i=0;i<=9;i++)
  {
  cout<<arr[i]<<endl;;
  }
  cout<<"\nCollisions: "<<c;
  cout<<"Do you want to continue: ";
  cin>>ch;
 }

 return 0;
 }
​#include <iostream>

using namespace std;

int main()
{
    // structura repetitiva
    /// citim un numar oarecare

    for(int i = 1; i <= 5; i = i + 1)
        cout << i << ' ';

    return 0;
}
#include <iostream>
using namespace std;

struct rectangle
{
    int length;
    int breadth;
};

int main() {
    
    rectangle *p;
    // in C, struct rectangle *p;
    
    p = new rectangle;
    //in C, p = (struct rectangle *)malloc(sizeof(struct rectangle));
    
    p->length = 15;
    p->breadth= 7;
    
    cout << "length : "<<p->length<<endl;
    cout << "breadth : "<<p->breadth<<endl;
    
    
 return 0;
}
#include <iostream>
using namespace std;

struct rectangle
{
    int length;
    int breadth;
};

int main() {
   rectangle r={10,5};
   cout <<"length : "<<r.length<<endl;
   cout <<"breadth : "<<r.breadth<<endl<<endl;
   
   cout << "using pointer : " <<endl;
   rectangle *p =&r;  
   cout <<"length : "<< p->length <<endl;
   cout <<"breadth : "<< p->breadth <<endl;

    return 0;
}
#include <iostream>
using namespace std;

int main()
{
    int a= 10;
    int &r = a;
    
    cout <<"a : "<<a<<"  r : "<<r<<endl;
    
    r= 25;
    cout <<"a : "<<a<<"  r : "<<r<<endl;
    
    int b=30;
    r=b;
    cout <<"b : "<<b<<"  a : "<<a<<"  r : "<<r<<endl;
    
  return 0;
}
node* searchBST(node* root, int val)
{
   while(root!=NULL||root->data!=val)
   {
      if(root->data>val) root=root->left;
      else root=root->right;
   }
   return root;
}
int findceil(node* root, int key)
{
   int ceil=-1;
   while(root)
   {
      if(root->data==key)
      {
         ceil=key;
         return ceil;
      }
      
      if(root->data<key)
      {
         root=root->right;
      }
      else 
      {
         ceil=root->data;
         root=root->left;
      }
   }
   return ceil;
}
int mxheight(Node* root)
{
    if(root==NULL) return 0;
    return max(mxheight(root->left), mxheight(root->right))+1;
}
class Solution {
  public:
    // Function to return the diameter of a Binary Tree.
    int diameter(Node* root) {
        // Your code here
        if(root==NULL) return 0;
        int p=mxheight(root->left)+mxheight(root->right)+1;
        return max(p, max(diameter(root->left), diameter(root->right)));
    }
};
int countLeaves(Node* root)
{
    int c=0;
    queue<Node*> q;
    q.push(root);
    
    while(!q.empty())
    {
        Node* temp=q.front();
        q.pop();
        
        if(temp->left==NULL&&temp->right==NULL) c++;
        
        if(temp->left) q.push(temp->left);
        if(temp->right) q.push(temp->right);
    }
    return c;
  // Your code here
}
#include <bits/stdc++.h>
using namespace std;

class node{
   public:
   int data;
   node* left;
   node* right;
   
   node(int d)
   {
      this->data=d;
      this->left=NULL;
      this->right=NULL;
   }
};

node* buildTree(node* root)
{
   cout<<"Enter the data: "<<"\n";
   int data;
   cin>>data;
   root = new node(data);
   if(data==-1) return NULL;
   
   cout<<"please enter the data for inserting left of "<<data<<endl;
   root->left=buildTree(root->left);
   cout<<"please enter the data for inserting right of "<<data<<endl;
   root->right=buildTree(root->right);
   return root;
}

void levelordertraversal(node* root)
{
   queue<node*> q;
   q.push(root);
   
   while(!q.empty())
   {
      node* temp=new node(q.front());
      q.pop();
      
      if(temp==NULL)
      {
         q.push(NULL);
         cout<<"\n";
      }
      else
      {
         cout<<temp->data<<" ";
         if(temp->left) q.push(temp->left);
         if(temp-right) q.push(temp->right);
      }
   }
}

void preorder(node* root)
{
   if(root==NULL) return;
   cout<<root->data<<" ";
   preorder(root->left);
   preorder(root->right);
}

void Inorder(node* root)
{
   if(root==NULL) return;
   preorder(root->left);
   cout<<root->data<<" ";
   preorder(root->right);
}

void postorder(node* root)
{
   if(root==NULL) return;
   preorder(root->left);
   preorder(root->right);
   cout<<root->data<<" ";
}

void buildFromLevelorder(node* root){
   queue<node*> q;
   cout<<"Enter data for root"<<endl;
   int data;
   cin>>data;
   root=new node(data);
   q.push(root);
   
   while(!q.empty())
   {
      node* temp=q.front();
      q.pop();
      
      cout<<"Enter left node for: "<<temp->data<<endl;
      int leftData;
      cin>>leftData;
      
      if(leftData!=-1){
         temp->left=new node(leftData);
         q.push(temp->left);
      }
      
      cout<<"Enter right node for: "<<temp->data<<endl;
      int rightData;
      cin>>rightData;
      
      if(rightData!=-1)
      {
         temp->right=new node(rightData);
         q.push(temp->right);
      }
   }
}


int main() {
   node* root=NULL;
   buildFromLevelorder(root);
   
// 	root=buildTree(root);
// 	cout<<"Levelordertraversal of tree:- \n";
// 	levelOrderTravesal(root);
// 	cout<<"print preorder: "<<preorder(root)<<"\n";
// 	cout<<"print Inorder: "<<Inorder(root)<<"\n";
// 	cout<<"print preorder: "<<postorderorder(root);
	
	return 0;
}
class Solution {
public:
    bool isPowerOfTwo(int n) {
        if(n==1) return true;
        if(n==0||n%2!=0) return false;
        return isPowerOfTwo(n/2);
    }
};
class Solution {
public:
    bool isPowerOfFour(int n) {
        
        if(n==1) return true;
        if(n==0||n%4!=0) return false;
        return isPowerOfFour(n/4);
        
    }
};
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int n=nums.size();
        int l=0,r=0;
        int sum=0, ans=INT_MAX;
        while(r < n)
        {
            sum+=nums[r];
            while(sum >= target) 
            {
                //if(sum==target)
                ans = min(ans, r-l+1);
                sum -= nums[l];
                l++;
            }
            r++;
        }
        if (ans == INT_MAX) return 0;
        return ans;
    }
};
#include <iostream>
using namespace std;

class linkedlist
{
	public:
	struct node
	{
		int data;
		node *next;
	}*last, *temp, *head;
//	node *last; node *temp;  node *head;
	
	public:
		void append();
		void display();                                                                                                       
}l1;

void linkedlist :: append()
{
	node *last; node *temp;  node *head;
	int value;
	temp = new node;
	cout << "Enter data : ";
	cin >> value;
	temp->data = value;
	temp->next = NULL;
	if(head == NULL)
	{
		head = temp = last;
	}
	else
	{
		last->next = temp;
		last = temp;
	}
	cout << "New node created!"<< endl;
}

void linkedlist :: display()
{
	temp = head;
	while(temp != NULL)
	{
		cout << temp->data << endl;
		temp = temp->next;
	}
}


int main()
{
	int ch; int choice;
	do{
	cout << "-----Linked List-----\n\n";
	cout << "1. Create first node\n";
	cout << "2. Insert new node at the end\n";
	cout << "3. Display\n";
	cin >> choice;
	
	switch(choice)
	{
		case 1 : l1.append();
		break;
		case 2 : l1.append();
		break;
		case 3 : l1.display();
		break;
		default : cout << "Enter a valid choice!\n";
	}
    }
    while(ch==1);
    cout << "Do you want to continue?\nPress 1 to continue\nPress 0 to exit\n";
    cin >> ch;

	return 0;
}
#include <iostream>
using namespace std;

int main()
{
    int *p;
    p= new int[5];  
    //will allocate memory for 5 integers, so it is an array of integers and it is assigned to p
    
    //initializing the values
    p[0] = 10;
    p[1] = 20;
    p[2] = 30;
    p[3] = 40;
    p[4] = 50;

    
    for(int i=0; i<5; i++)
      cout << p[i] << endl;
   
  	delete [] p;   //to delete an array, first use square brackets and the the name of the variable 		to be deleted
  return 0;
}
#include <iostream>
using namespace std;

int main()
{
  int A[5] = {10,20,30,40,50};
  int *p , *ptr;
  p = A; 
  ptr = &A[0];
/*
no need to give the ampersand(&) when we are giving array name to the pointer, because name of an array A itself is the starting address of this array. So, p is the pointer so, it can store the address.
If we want to use ampersand(&) then we should say A of zero, A[0] means this to 10, A[0] is 2 and its address, then you should write the address.
*/
  
for (int i=0; i<5; i++)
{
    cout << A[i] << endl;
    //To access the values using pointer instead of array name:
    // cout << p[i] << endl;
}
  
  return 0;
}
#include <iostream>
using namespace std;

int main()
{
  int a = 10;
  int *p;
  p = &a;
  
  cout << "value of a : " << a << endl;
  cout << "using pointer : " << *p << endl;
  cout << "address of a : " << &a << endl;
  cout << "address of a using pointer: " << p << endl;
  
  return 0;
}
// words for digits
// in: unsigned long (ul)   
// out: string &

#include <string>
#include <vector>

typedef unsigned long ul;

std::vector<std::string> const ones{"",     "one", "two",   "three", "four", "five", "six", "seven", "eight", "nine"};
std::vector<std::string> const teens{"ten",     "eleven",  "twelve",    "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
    std::vector<std::string> const tens{"",       "",      "twenty", "thirty", "forty",  "fifty", "sixty",  "seventy", "eighty", "ninety"};
   
   std::string wordsForDigits(ul digits) {
    if (digits < 10) {
    return ones[digits];
    } else if (digits < 20) {
    return teens[digits - 10];
    } else if (digits < 100) {
    return tens[digits / 10] +
     ((digits % 10 != 0) ? " " + wordsForDigits(digits % 10) : "");
   } else if (digits < 1'000) {
   return wordsForDigits(digits / 100) + " hundred" +
     ((digits % 100 != 0) ? " " + wordsForDigits(digits % 100) : "");
   } else if (digits < 1'000'000) {
   return wordsForDigits(digits / 1'000) + " thousand" +
   ((digits % 1000 != 0) ? " " + wordsForDigits(digits % 1000) : "");
  } else if (digits < 1'000'000'000) {
  return wordsForDigits(digits / 1'000'000) + " million" +
  ((digits % 1'000'000 != 0) ? " " + wordsForDigits(digits % 1'000'000)
  ▏ : "");
  } else if (digits < 1'000'000'000'000) {
   return wordsForDigits(digits / 1'000'000'000) + " billion" +
   ((digits % 1'000'000'000 != 0)
  ? " " + wordsForDigits(digits % 1'000'000'000)
   : "");
  }
  return "error";
}

void wordsForDigitsHelper(std::string &text, ul digits) {
▏ text = wordsForDigits(digits);
}
class Solution {
public:
    int minSwaps(string s) {
        int n=s.size();
        stack<char> st;
        for(int i=0;i<n;i++)
        {
            if(!st.empty()&&st.top()=='['&&s[i]==']')
            {
                st.pop();
            }
            else st.push(s[i]);
        }
        int n2=st.size()/2;
        if(n2%2==1) return (n2/2)+1;
        else return n2/2;
    }
};
class Solution {
public:
    vector<int> numOfBurgers(int ts, int cs) {
        vector<int> a;
        if(ts%2==1||ts>4*cs||ts<2*cs) 
        {
            return a;
        }
        int p=ts/2;
        int tu=p-cs;
        int du=cs-tu;
        a.push_back(tu);
        a.push_back(du);
        return a;
    }
};
class Solution {
public:
    int findContentChildren(vector<int>& g, vector<int>& s) {
        int n1=g.size();
        int n2=s.size();
        int i=0, j=0,res=0;
        sort(g.begin(),g.end());
        sort(s.begin(),s.end());
        while(i<n1 && j<n2)
        {
            if(g[i]<=s[j])
            {
                i++;j++;res++;
            }
            else
            {
                j++;
            }
        }
        return res;
    }
};
bool comp(vector<int>&x, vector<int>&y) //Custom comparator
{
    return x[1]<y[1];
}
class Solution {
public:
    int findMinArrowShots(vector<vector<int>>& points) {
        int n=points.size();
        if(n==0) return 0;
        if(n==1) return 1;
        
        sort(points.begin(),points.end(), comp);
        int prev=points[0][1];
        int no_ballon=1;
        for(int i=1;i<n;i++)
        {
            if(points[i][0]<=prev) continue;
            prev=points[i][1];
            no_ballon++;
        }
        return no_ballon;
    }
};
class Solution {
public:
    int jump(vector<int>& nums) {
        int n=nums.size();
        int cr=0, cmx=0, j=0;
        for(int i=0;i<n-1;i++)
        {
            if(i+nums[i]>cmx) cmx=i+nums[i];
            
            if(i==cr)
            {
                j++;
                cr=cmx;
            }
        }
        return j;
    }
};
​#include <iostream>

using namespace std;

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(a <= x && x <=b)
        cout << "DA";
    else
        cout << "NU";


    return 0;
}
class Solution {
public:
    bool canJump(vector<int>& nums) {
        int n=nums.size();
        int mxReach=0;
        for(int i=0;i<n;i++)
        {
            if(i>mxReach) return false;
            mxReach=max(mxReach, i+nums[i]);
            
        }
        return true;
    }
};
class Solution {
public:
    int canCompleteCircuit(vector<int>& gas, vector<int>& cost) {
        int n=gas.size();
        int tg=0, cg=0, s=0;
        for(int i=0;i<n;i++)
        {
            tg+=(gas[i]-cost[i]);
            cg+=(gas[i]-cost[i]);
            if(cg<0)
            {
                s=i+1;
                cg=0;
            }
            
        }
        if(tg>=0) return s;
        else return -1;
    }
};
class Solution {
public:
    vector<vector<int>> merge(vector<vector<int>>& intervals) {
        sort(intervals.begin(),intervals.end());
        
        int n=intervals.size();
         vector<vector<int>> vns;
        vector<int> v1=intervals[0];
        for(int i=1;i<n;i++)
        {
            if(v1[1]<intervals[i][0])
            {
                vns.push_back(v1);
                v1=intervals[i];
            }
            else 
            {
                v1[1]=max(v1[1],intervals[i][1]);
            }
        }
        vns.push_back(v1);
        return vns;
    }
};
class Solution
{
    public:
    //Function to find the next greater element for each element of the array.
    vector<long long> nextLargerElement(vector<long long> arr, int n){
        
        vector<long long> v;
        
        stack<long long> s;
        for(int i=n-1;i>=0;i--)
        {
            while((!s.empty() && s.top()<=arr[i]))
            {
                s.pop();
            }
            if(s.empty()) v.push_back(-1);
            else 
            {
                v.push_back(s.top());
                
            }
            s.push(arr[i]);
        }
        reverse(v.begin(),v.end());
        return v;
    }
};
class Solution
{
    public:
    //Function to check if brackets are balanced or not.
    bool ispar(string x)
    {
        stack<char> s;
        int n=x.size();
        for(int i=0;i<n;i++)
        {
            if( !s.empty()&&((s.top()=='[' && x[i]==']')||(s.top()=='{' && x[i]=='}')||(s.top() == '(' && x[i]==')' ))) 
            {
                s.pop();
            }
                
            else s.push(x[i]);
        }
        if(s.empty()) return true;
        else return false;
        // Your code here
    }

};
#include<bits/stdc++.h>

using namespace std;
class Stack {
  int size;
  int * arr;
  int top;
  public:
    Stack() {
      top = -1;
      size = 1000;
      arr = new int[size];
    }
  void push(int x) {
    top++;
    arr[top] = x;
  }
  int pop() {
    int x = arr[top];
    top--;
    return x;
  }
  int Top() {
    return arr[top];
  }
  int Size() {
    return top + 1;
  }
};
int main() {

  Stack s;
  s.push(6);
  s.push(3);
  s.push(7);
  cout << "Top of stack is before deleting any element " << s.Top() << endl;
  cout << "Size of stack before deleting any element " << s.Size() << endl;
  cout << "The element deleted is " << s.pop() << endl;
  cout << "Size of stack after deleting an element " << s.Size() << endl;
  cout << "Top of stack after deleting an element " << s.Top() << endl;
  return 0;
}
// C++ program to implement a stack using
// single queue
#include<bits/stdc++.h>
using namespace std;

// User defined stack that uses a queue
class Stack
{
	queue<int>q;
public:
	void push(int val);
	void pop();
	int top();
	bool empty();
};

// Push operation
void Stack::push(int val)
{
	// Get previous size of queue
	int s = q.size();

	// Push current element
	q.push(val);

	// Pop (or Dequeue) all previous
	// elements and put them after current
	// element
	for (int i=0; i<s; i++)
	{
		// this will add front element into
		// rear of queue
		q.push(q.front());

		// this will delete front element
		q.pop();
	}
}

// Removes the top element
void Stack::pop()
{
	if (q.empty())
		cout << "No elements\n";
	else
		q.pop();
}

// Returns top of stack
int Stack::top()
{
	return (q.empty())? -1 : q.front();
}

// Returns true if Stack is empty else false
bool Stack::empty()
{
	return (q.empty());
}

// Driver code
int main()
{
	Stack s;
	s.push(10);
	s.push(20);
	cout << s.top() << endl;
	s.pop();
	s.push(30);
	s.pop();
	cout << s.top() << endl;
	return 0;
}
class StockSpanner {
public:
    stack<pair<int,int>> s;
    StockSpanner() {
        
    }
    
    int next(int price) {
        int span=1;
        while(!s.empty()&&s.top().first<=price)
        {
            span+=s.top().second;
            s.pop();
        }
        s.push({price, span});
        return span;
    }
};

/**
 * Your StockSpanner object will be instantiated and called as such:
 * StockSpanner* obj = new StockSpanner();
 * int param_1 = obj->next(price);
 */
​#include <iostream>
using namespace std;
#include <iomanip>

int main ()
{
    int a, b, c;
    float medie;
    cin >> a >> b >> c;
    medie = (a + b + c) / 3.;
    medie = (int) (medie * 100)/100.;
    cout << fixed << setprecision(2) << medie;


    return 0;
}
class Solution {
public:
    string removeKdigits(string num, int k) {
        int n=num.size();
        if(k>=n) return "0";
        if(k==0) return num;
        string res="";
        stack<char> s;
        
        s.push(num[0]);
        for(int i=1;i<n;i++)
        {
            while(k>0&&!s.empty()&&num[i]<s.top())
            {
                k--;
                s.pop();
            }
            s.push(num[i]);
            
            if(s.size()==1&&num[i]=='0')
            {
                s.pop();
            }
        }
        while(k&&!s.empty())
        {
            k--;
            s.pop();
        }
        while(!s.empty())
        {
            res.push_back(s.top());
            s.pop();
        }
        reverse(res.begin(),res.end());
        if(res.length()==0) return "0";
        return res;
    }
};
class Solution {
public:
    int trap(vector<int>& height) {
        int n=height.size();
        int Pmax[n], Bmax[n];
        int p=0,b=0;
        for(int i=0;i<n;i++)
        {
            Pmax[i]=p;
            if(height[i]>=p) p=height[i];
        }
        for(int i=n-1;i>=0;i--)
        {
            Bmax[i]=b;
            if(height[i]>=b) b=height[i];
        }
        int ans=0;
        for(int i=0;i<n;i++)
        {
            int Lmin=min(Pmax[i],Bmax[i]);
            if((Lmin==0)||(height[i]>=Lmin)) 
            {
                continue;
            }
            else
            {
                ans+=(Lmin-height[i]);
            }
        }
        return ans;
        
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* rotateRight(ListNode* head, int long long k) {
        if(head==NULL||k==0) return head;
        int long long c=0;
        ListNode* p=head;
        while(p!=NULL)
        {
            c++;
            p=p->next;
        }
        if(c==1||k%c==0) return head;
        int r=k%c;
        int t=(c-r)-1;
        ListNode* i1=head;
        ListNode* i2;
        while(t--)
        {
            i1=i1->next;
        }
        
        if(i1) i2=i1->next;
        
        ListNode* p5=head;
        while(p5->next!=NULL)
        {
            p5=p5->next;
        }
        p5->next=head;
        if(i1) i1->next=NULL;
        
        head=i2;
        return head;
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */


void makell(ListNode* head, int value)
{
    ListNode* p=new ListNode();
    p->val=value;
    p->next=NULL;
    ListNode* l=head;
    while((l->next!=NULL)&&(l!=NULL))
    {
        l=l->next;
    }
    l->next=p;
}
class Solution {
public:
    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
        
        ListNode* head=new ListNode();
        head->val=0;
        head->next=NULL;
        ListNode* i1 = l1;
        ListNode* i2 = l2;
        int c=0;
        while(i1!=NULL||i2!=NULL)
        {
            int d1,d2;
            if(i1==NULL&&i2==NULL) break;
            if(i1==NULL) d1=0;
            else 
            {
                d1=i1->val;
                i1=i1->next;
            }
            if(i2==NULL) d2=0;
            else
            {
                d2=i2->val;
                i2=i2->next;
            }
            int p=d1+d2+c;
            int r=p%10;
            makell(head,r);
            c=p/10;
        }
        if(c!=0)
        {
            makell(head,c);
        }
        return head->next;
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
void makell(ListNode* &head, int value)
{
    ListNode* p=new ListNode();
    p->val=value;
    p->next=NULL;
    ListNode* l=head;
    while(l->next!=NULL)
    {
        l=l->next;
    }
    
    l->next=p;
    
    
}
class Solution {
public:
    ListNode* mergeKLists(vector<ListNode*>& lists) {
        int n1=lists.size();
        multiset<int> s;
        for(int i=0;i<n1;i++)
        {
            ListNode* a=lists[i];
            
            while(a!=NULL)
            {
                s.insert(a->val);
                a=a->next;
            }
        }
        ListNode* head;
        head=new ListNode();
        head->val=0;
        head->next=NULL;
        for(auto it:s)
        {
            makell(head,it);
        }
        return head->next;
    }
};
#include<iostream>
using namespace std;
int main(){
    int n;
    cout<<"Enter the range\n";
    cin>>n;
    int sum=0;
    for(int i=0;i<=n;i++){
        cout<<i<<" ";
        sum+=i;
    }cout<<endl;
    cout<<"The sum between given range is-> "<<sum<<endl;
    return 0;
}
#include<iostream>
using namespace std;
template<class t>
class absolute{
    
    public:
    void check(int a){
        if(a<0){
            a=-(a);
            cout<<"Value is-> "<<a<<endl;
        }
        else{
            cout<<"Value is-> "<<a<<endl;
        }
    }
};
int main(){
    absolute<int>a;
    int n;
    cout<<"Enter the number\n";
    cin>>n;
    a.check(n);
    return 0;
}
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cout<<"Enter the age of three person\n";
    cin>>a>>b>>c;
    if(a>b&&a>c){
        cout<<a<<" is greatest among them"<<endl;
    }
    if(b>c){
        cout<<c<<" is younger among them"<<endl;
    }
    return 0;
}
#include<iostream>
#include<algorithm>
using namespace std;
template<class t>
class total{
    public:
    void discount(int quantity){
        int cost=quantity*100;
        int discount=(cost/100)*10;
        int new_cost=0;
        if(cost>1000){
            new_cost=cost-discount;
            cout<<"Your new cost after discount is-> "<<new_cost<<endl;
        }
        else{
            cout<<"Your cost is-> "<<cost<<endl;
        }
    }   
};

int main(){
    int q;
    cout<<"Enter the quantity how much you want"<<endl;
    cin>>q;
    total<int>t;
    t.discount(q);
    return 0;
}
#include<iostream>
#include<algorithm>
using namespace std;
template<class t>
class greatest{
private:
int a,b;
public:
void check(int a,int b){
    cout<<"Enter two no.\n";
    cin>>a>>b;
    if(a>b){
        cout<<a<<" is greater than "<<b<<endl;
    }
    else if(a==b){
        cout<<a<<" is equal with "<<b<<endl;
    }
    else{
        cout<<b<<" is greater than "<<a<<endl;
    }
}
};

int main(){
    int a,b;
    greatest<int>g;
    g.check(a,b);
    return 0;
}
#include<iostream>
using namespace std;
template<class t>
    class check{
        public:
        int a,b;
        void sqcheck(int a,int b){
            cout<<"Enter two values\n";
            cin>>a>>b;
            if(a==b){
                cout<<"It is square"<<endl;
            }
            else{
                cout<<"It is a rectangle\n";
            }
        }
    };

    int main(){
        check<int>c;
        int a,b;
        c.sqcheck(a,b);
        return 0;
    }
#include<iostream>
using namespace std;
void prime(int n){
    bool flag=true;
    for(int i=2;i<n;i++){
        if(n%i==0){
            flag=false;
            break;
        }
    }
    if(flag==false){
        cout<<"No it is not a prime no.\n";
    }
    else{
        cout<<"Yes it is a prime no.\n";
    }
}
int main(){
    int a;
    cout<<"Enter the no.\n";
    cin>>a;
    prime(a);
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

void solve(string str, string output, int index, vector<string>& ans)
{
   //base case
   if(index >= str.length())
   {
      if(output.length()>0) ans.push_back(output);
      return;
   }
   //exclude
   solve(str, output, index+1, ans);
   
   //include
   char element = str[index];
   output.push_back(element);
   solve(str, output, index+1, ans);
}
vector<string> subsequences(string str)
{
   vector<string> ans;
   string output = "";
   int index = 0;
   solve(str, output, index, ans);
   return ans;
}
int main() {
	string s="abcd";
	vector<string> v=subsequences(s);
	for(int i=0;i<v.size();i++)
	{
	   cout<<v[i]<<" ";
	}
	return 0;
}
class Solution {
public:
    
    void solve(vector<int> nums, vector<int> output, int index, vector<vector<int>> &ans)
    {
        //base case
        if(index>=nums.size())
        {
            ans.push_back(output);
            return;
        }
        
        //eclude
        solve(nums, output, index+1, ans);
        
        //include
        int element = nums[index];
        output.push_back(element);
        solve(nums, output, index+1, ans);
    }
    vector<vector<int>> subsets(vector<int>& nums) {
        
        vector<vector<int>>ans;
        vector<int> output;
        int index=0;
        solve(nums,output,index,ans);
        return ans;
    }
};
#include <bits/stdc++.h>
using namespace std;

int partition(int arr[],int s,int e)
{
   int pivot=arr[s];
   int cnt=0;
   for(int i=s+1;i<=e;i++)
   {
      if(arr[i]<=pivot)
      {
         cnt++;
      }
   }
   
   //place pivot at right position
   int pivotindex = s+cnt;
   swap(arr[pivotindex],arr[s]);
   
   //left and right wala part sambhal lete sambhal
   int i=s, j=e;
   while(i < pivotindex && j > pivotindex)
   {
      while(arr[i]<pivot)
      {
         i++;
      }
      while(arr[j]>pivot)
      {
         j--;
      }
      if(i < pivotindex && j > pivotindex)
      {
         swap(arr[i++],arr[j--]);
      }
   }
   return pivotindex;
}
void quicksort(int arr[], int s,int e)
{
   //base case
   if(s>=e) return;
   
   //partition
   int p=partition(arr,s,e);
   //recursion
   //left part ko sort karo
   quicksort(arr,s,p-1);
   //right part ko sort karo
   quicksort(arr,p+1,e);
}


int main() {
	int a[8]={9,78,6,23,14,2,8,1};
	int n=8;
	quicksort(a,0,n-1);
	for(int i=0;i<n;i++)
	{
	   cout<<a[i]<<" ";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

void merge(int *arr, int s, int e)
{
   int mid = (s+e)/2;
   int len1=mid-s+1;
   int len2=e-mid;
   
   int *first = new int[len1];
   int *second=new int[len2];
   
   //copy value
   int mainArrayIndex = s;
   for(int i=0;i<len1;i++)
   {
      first[i]=arr[mainArrayIndex++];
   }
   mainArrayIndex=mid+1;
   for(int i=0;i<len2;i++)
   {
      second[i]=arr[mainArrayIndex++];
   }
   
   //merge 2 sorted arrays
   int index1=0;
   int index2=0;
   mainArrayIndex=s;
   
   while(index1<len1&&index2<len2)
   {
      if(first[index1]<second[index2])
      {
         arr[mainArrayIndex++]=first[index1++];
      }
      else 
      {
         arr[mainArrayIndex++]=second[index2++];
      }
   }
   while(index1<len1)
   {
      arr[mainArrayIndex++]=first[index1++];
   }
   while(index2<len2)
   {
      arr[mainArrayIndex++]=second[index2++];
   }
   delete []first;
   delete []second;
  
}
void mergesort(int *arr,int s,int e)
{
   //base case
   if(s>=e)
   {
      return;
   }
   
   int mid=(s+e)/2;
   //left part sort karna h
   mergesort(arr, s, mid);
   //right part sort karna right
   mergesort(arr, mid+1, e);
   
   //merge
   merge(arr,s,e);
   
}
int main() {
   
	int a[5]={5,6,1,4,3};
   int n=5;
   mergesort(a,0,n-1);
	for(int i=0;i<5;i++)
	{
	   cout<<a[i]<<" ";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

void bubblesrt(int a[],int n)
{
   if(n==0||n==1) return;
   for(int i=0;i<n-1;i++)
   {
      if(a[i]>a[i+1]) swap(a[i],a[i+1]);
   }
   bubblesrt(a,n-1);
}
int main() {
   
	int a[5]={5,6,1,4,3};
   bubblesrt(a,5);
	for(int i=0;i<5;i++)
	{
	   cout<<a[i]<<" ";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD= 1e9+7;
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	  ll fact=1;
	  ll n;
	  cin>>n;
	   for(ll i=1;i<=n;i++)
	   {    
      fact=(fact*i)%MOD;    
      }
      ll ans=(fact*n)%MOD;
      ll ans2=(ans*(n-1))%MOD;
	 cout<<ans2<<"\n"; 
	 
	}
	return 0;
}
class Solution{
  public:
    //Function to check whether the list is palindrome.
    bool isPalindrome(Node *head)
    {
        //Your code here
        stack<int> s;
        Node *t;
        t=head;
        while(t)
        {
            s.push(t->data);
            t=t->next;
        }
        t=head;
        while(t)
        {
            if(s.top()==t->data)
            {
                s.pop();
            }
            t=t->next;
        }
        if(s.empty()) return true;
        else return false;
        
    }
};
#include <bits/stdc++.h> 
int countDistinctWays(long long nStairs) {
    //  Write your code here.
    //Base case 
    if(nStairs<0) return 0;
    if(nStairs==0) return 1;
    int ans=countDistinctWays(nStairs-1) + countDistinctWays(nStairs-2);
    return ans;
}
//Factorial
#include <bits/stdc++.h>
using namespace std;

int fac(int n)
{
   //Base call and return must be there
   if(n==0) return 1;
   return n*fac(n-1);
}
int main() {
   int t;
   cin>>t;
   while(t--)
   {
      int n;
      cin>>n;
      int ans = fac(n);
      cout<<ans<<"\n";
   }
	return 0;
}

//Power 2
#include <bits/stdc++.h>
using namespace std;

long long powerofto(long long n)
{
   if(n==0) return 1;
   return 2*powerofto(n-1);
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	     long long n;
	     cin>>n;
	     long long ans=powerofto(n);
	     cout<<ans<<"\n";
	}
	return 0;
}

//print count
#include <bits/stdc++.h>
using namespace std;

void printcnt(int n)
{
   if(n==0) return;
   
   //cout<<n<<" ";
   printcnt(n-1);
   cout<<n<<" ";
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int n;
	        cin>>n;
	        printcnt(n);
	        cout<<"\n";
	}
	return 0;
}

//Reach destination
#include <bits/stdc++.h>
using namespace std;

void reachome(int dest, int src)
{
   if(src==dest)
   {
      cout<<src<<" Pahunchh gya: ";
      return;
      
   }
   cout<<src<<" ";
   src++;
   reachome(dest, src);
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	      int dest;
	      int src;
	      cin>>dest;
	      cin>>src;
	      reachome(dest,src);
	      cout<<"\n";
	}
	return 0;
}

//Fabinascii series
#include <bits/stdc++.h>
using namespace std;

int fab(int n)
{
   if(n==1) return 1;
   if(n==0) return 0;
   return fab(n-1)+fab(n-2);
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int n;
	        cin>>n;
	        int ans=fab(n);
	        cout<<ans<<"\n";
	}
	return 0;
}

//Print digits in string
#include <bits/stdc++.h>
using namespace std;

void print(int n, string arr[])
{
   if(n==0) return;
   int digit = n%10;
   n=n/10;
   
   print(n,arr);
   cout<<arr[digit]<<" ";
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        string arr[10]={"zero", "one","two","three","four","five","six","seven","eight","nine"};
	        int n;
	        cin>>n;
	        print(n,arr);
	        cout<<"\n";
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	       int n;
	       cin>>n;
	       char a[n][10];
	       for(int i=0;i<n;i++)
	       {
	           for(int j=0;j<10;j++)
	           {
	               cin>>a[i][j];
	           }
	       }
	       int ans=0;
	       for(int i=0;i<10;i++)
	       {
	           int cnt=0;
	           for(int j=0;j<n;j++)
	           {
	               if(a[j][i]=='1') cnt++;
	           }
	           if(cnt%2==1) ans++;
	       }
	       cout<<ans<<"\n";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        long long x;
	        cin>>x;
	        cout<<x<<" "<<0<<"\n";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int n;
	        cin>>n;
	        int a[n];
	        for(int i=0;i<n;i++)
	        {
	            cin>>a[i];
	        }
	        int ans=0;
	        for(int i=0;i<n-1;i++)
	        {
	            for(int j=i+1;j<n;j++)
	            {
	                if((a[i]==1&&a[j]==1)||(a[i]==0)) ans++;
	            }
	        }
	        cout<<ans<<"\n";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int p;
	        cin>>p;
	        int itemprice=2048;
	        int ans=0;
	        while(p>0)
	        {
	            ans+=p/itemprice;
	            p%=itemprice;
	            itemprice/=2;
	        }
	        cout<<ans<<"\n";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	int n,y;
	cin>>t;
	while(t--)
	{
	      cin>>n>>y;
	      long a[n];
	      bool u=false;
	      for(int i=0;i<n;i++)
	      {
	          cin>>a[i];
	      }
	      long p=0;
	      for(int i=0;i<n;i++)
	      {
	          p=p | a[i];
	      }
	      for(int i=0;i<=y;i++)
	      {
	          if((p|i)==y)
	          {
	              cout<<i<<"\n";
	              u=true;
	              break;
	          }
	      }
	      if(u==false) cout<<"-1\n";
	}
	return 0;
}

METHOD 2:-

#include <iostream>
#include<string>
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
	int t,n,y;
	cin>>t;
	while(t--)
	{
	    cin>>n>>y;
	    int a[n];
	    string required, current;
	    int orans=0;
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	        orans|=a[i];
	    }
	    current=bitset<32>(orans).to_string();
	    required=bitset<32>(y).to_string();
	    int flag=0, answer=0;
	    for(int i=31; i>=0; i--)
	    {
	        if(current[i]=='1' && required[i]=='0')
	        {
	            flag=1;
	            break;
	        }
	        if(current[i]=='0' && required[i]=='1')
	        {
	            answer+=pow(2,31-i);
	        }
	    }
	    if(flag){cout<<-1<<endl;}
	    else {cout<<answer<<endl;}
	}
	return 0;
}
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    
    double gr1, gr2, gr3, gr4, gr5, gr6, gr7, gr8, gr9, gr10, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, aggregate_grade, gwa;
    int un1, un2, un3, un4, un5, un6, un7, un8, un9, un10, numsub, total_units;
    string sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10;
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    cout << "------------------------\n"
        << "IT 202D FINAL OUTPUT\n" 
        << "GWA CALCULATOR\n"
        << "------------------------\n"
        << "Please enter the number of subjects that " << endl
        << "you took this semester (excluding NSTP and subjects \n"
        << "with non-numeric ratings): ";
    cin >> numsub;
    
    if (numsub == 2)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    aggregate_grade = p1 + p2;
    total_units = un1 + un2;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 3)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    aggregate_grade = p1 + p2 + p3;
    total_units = un1 + un2 + un3;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 4)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    aggregate_grade = p1 + p2 + p3 + p4;
    total_units = un1 + un2 + un3 + un4;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 5)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5;
    total_units = un1 + un2 + un3 + un4 + un5;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 6)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6;
    total_units = un1 + un2 + un3 + un4 + un5 + un6;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 7)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub7;
    cout << "Number of Credited Units: ";
    cin >> un7;
    cout << "Grade: ";
    cin >> gr7;
    p7 = un7 * gr7;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7;
    total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 8)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub7;
    cout << "Number of Credited Units: ";
    cin >> un7;
    cout << "Grade: ";
    cin >> gr7;
    p7 = un7 * gr7;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub8;
    cout << "Number of Credited Units: ";
    cin >> un8;
    cout << "Grade: ";
    cin >> gr8;
    p8 = un8 * gr8;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8;
    total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 9)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub7;
    cout << "Number of Credited Units: ";
    cin >> un7;
    cout << "Grade: ";
    cin >> gr7;
    p7 = un7 * gr7;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub8;
    cout << "Number of Credited Units: ";
    cin >> un8;
    cout << "Grade: ";
    cin >> gr8;
    p8 = un8 * gr8;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub9;
    cout << "Number of Credited Units: ";
    cin >> un9;
    cout << "Grade: ";
    cin >> gr9;
    p8 = un9 * gr9;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
    total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8 + un9;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 10)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub7;
    cout << "Number of Credited Units: ";
    cin >> un7;
    cout << "Grade: ";
    cin >> gr7;
    p7 = un7 * gr7;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub8;
    cout << "Number of Credited Units: ";
    cin >> un8;
    cout << "Grade: ";
    cin >> gr8;
    p8 = un8 * gr8;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub9;
    cout << "Number of Credited Units: ";
    cin >> un9;
    cout << "Grade: ";
    cin >> gr9;
    p8 = un9 * gr9;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub10;
    cout << "Number of Credited Units: ";
    cin >> un10;
    cout << "Grade: ";
    cin >> gr10;
    p8 = un10 * gr10;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
    total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8 + un9 + un10;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n"; 
    }
    
    else
    {
        cout << "\n------------------------\n"
        << "Invalid entry";
    }
    return 0;
    }
#include <fstream>
#include <iostream>
using namespace std;


int main() {

    // Part 1: Write on a file.
    ofstream oFile;
    oFile.open("my-bio.txt");

    string name;
    int age;

    // User input. 
    cout << "Enter name: ";
    getline(cin, name);

    cout << "Enter age: ";
    cin >> age;

    oFile << "My name is " << name << ". \n";
    oFile << "I am " << age << " years old. \n";

    oFile.close();

    // Part 2: Read from a file.
    string str;

    ifstream iFile;
    iFile.open("my-bio.txt");

    cout << "\nReading data from the file: \n\n";

    while(!iFile.eof()) {
        getline(iFile, str);
        cout << str << endl;
    }

    iFile.close();

    return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		File Handling
*/

#include <fstream>
#include <iostream>
using namespace std;


int main() {

	// The string will hold the text present in each line on the file.
	string str;

	// Create ifstream (Input File Stream) object.
	ifstream iFile;

	// Open the file.
	iFile.open("my-note.txt");

	// Use a while loop together with the getline() function to read the file line by line.
	while(!iFile.eof()) {
		getline(iFile, str);		// Reads a line.
		cout << str << endl;		// Prints the line.
	}

	// Close the opened file.
	iFile.close();

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		File Handling
*/

#include <fstream>
#include <iostream>
using namespace std;


int main() {

	// Create an ofstream (Output File Stream) object.
	ofstream oFile;

	// Create a file (if it doesn't exist) and open it.
	oFile.open("my-note.txt");

	// Write on the file.
	oFile << "Hi! \n";
	oFile << "I love to travel. \n";
	oFile << "I am " << 25 << " years old. \n";

	// Close the opened file.
	oFile.close();

	return 0;
}
#include <iostream>
#include <cmath>
using namespace std;

void findSquareRoot(float n);


int main() {

    // Find the square root of 'n' entered by the user.
    cout << "Program starts -->" << endl << endl;

    float n;

    cout << "Enter n: ";
    cin >> n;

    findSquareRoot(n);

    cout << "<-- Program ends" << endl;

    return 0;
}

void findSquareRoot(float n) {

    try {
        if (n < 0) {
            throw "The value of 'n' must be greater than or equal to 0. Please try again.";
        }

        float result = sqrt(n);
        cout << "Result: " << result << endl << endl;
    } catch (const char *msg) {
        cout << msg << endl << endl;
    }
}
#include <iostream> 
#include <cmath> 
using namespace std; 


int main() {

    // Find the square root of 'n' entered by the user.
    cout << "Program starts -->" << endl << endl;

    float n;

    cout << "Enter n: ";
    cin >> n;

    try {
        if (n < 0) {
            throw "The value of 'n' must be greater than or equal to 0. Please try again.";
        }

        float result = sqrt(n);
        cout << "Result: " << result << endl << endl;
    } catch (const char *msg) {
        cout << msg << endl << endl;
    }

    cout << "<-- Program ends" << endl;

    return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Exception Handling
*/

#include <iostream>
using namespace std;


int main() {

	// Divide two integers: a divided by b.
	cout << "Program starts -->" << endl << endl;

	int a, b;

	cout << "Enter a: ";
	cin >> a;

	cout << "Enter b: ";
	cin >> b;

	try {
		if (b == 0) {
			throw "The value of 'b' must not be 0. Please try again.";
		}

		int result = a / b;
		cout << "Result: " << result << endl << endl;
	} catch (const char *msg) {
		cout << msg << endl << endl;
	}

	cout << "<-- Program ends" << endl;

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Preprocessor Directives
*/

#include <iostream>
using namespace std;

#define UPPER_LIMIT 10		// Macro definition
#define AREA(r) (3.14 * r * r)	// Macro with parameter


int main() {

	// Find even numbers from 1 to 10.
	for (int i = 1; i <= UPPER_LIMIT; i++) {

		if (i % 2 == 0)
			cout << i << endl;
	}

	// Find the area of a circle.
	cout << "Area: " << AREA(5);		// 3.14 * 5 * 5

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Standard Libraries
*/

#include <iostream>
#include <vector>
using namespace std;

class Employee {
	// Your code 
};

int main() {

	/* C++ <vector> Header
	   Vectors are similar to arrays, but it can change its size. */

	Employee emp1, emp2, emp3, emp4;
	vector<Employee> employeeList;
	employeeList.push_back(emp1);
	employeeList.push_back(emp2);
	employeeList.push_back(emp3);
	employeeList.push_back(emp4);
	
	vector<string> names;
	names.push_back("Rahul");		// Adds element at the end
	names.push_back("Peter");
	names.push_back("Ravi");

	// Check the size.
	cout << "Size: " << names.size() << endl;		// 3

	// Accessing an element.
	cout << "Element at index 0: " << names[0] << endl;		// Rahul

	// Remove element from the end.
	names.pop_back();		// Removes "Ravi"
	cout << "Size: " << names.size() << endl;		// 2

	// Modify element.
	names[0] = "Aditya";
	cout << "Element at index 0: " << names[0] << endl;		// Aditya

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Standard Libraries
*/

#include <iostream>
#include <cmath>
using namespace std;


int main() {

	/* C++ <cmath> Header */

	int x = 4, y = 9;

	cout << "The greater number: " << fmax(x, y) << endl;		// 9
	cout << "The smaller number: " << fmin(x, y) << endl;		// 4
	cout << "The difference: " << fdim(y, x) << endl;			// 5

	cout << "2 to the power 4: " << pow(2, 4) << endl;	// 2 * 2 * 2 * 2 = 16

	cout << sqrt(64) << endl;		// 8
	cout << round(2.5) << endl;		// 3
	cout << round(2.4) << endl;		// 2
	cout << floor(4.9) << endl;		// 4
	cout << log(2) << endl;			// 0.693

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Standard Libraries
*/

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <unistd.h>
using namespace std;


int main() {

	/* WAP to roll a dice.*/

	int randomValue;

	srand(time(NULL));

	randomValue = (rand() % 6) + 1;		// 1, 2, 3, 4, 5, 6

	cout << "Rolling the dice...\n\n";
	usleep(2000000);

	cout << "You got: " << randomValue;

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Namespaces
*/

#include <iostream>
using namespace std;

namespace jp {

	float dollarValue = 108;	// 1 USD = 108 Japanese Yen

	double toDollars(float currencyUnits) {
		return currencyUnits / dollarValue;
	}
}

namespace cn {

	float dollarValue = 7;		// 1 USD = 7 Chinese Yuan

	double toDollars(float currencyUnits) {
		return currencyUnits / dollarValue;
	}
}


int main() {

	cout << "1 USD = " << jp::dollarValue << " Yen" << endl;
	cout << "1 USD = " << cn::dollarValue << " Yuan" << endl;

	cout << "8960 Yen = " << jp::toDollars(8960) << " USD" << endl;
	cout << "610 Yuan = " << cn::toDollars(610) << " USD" << endl;

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Friend Class and Friend Function
*/

#include <iostream>
#include <string>
using namespace std;

class Employee {

	private:
		string phNo;

	public:
		string name;

		void setPhoneNumber(string phoneNumber) {
			this->phNo = phoneNumber;
		}

		friend void display(Employee);		// Function declaration
};

void display(Employee emp) {	// Function definition
	cout << "Employee name: " << emp.name << ", Phone: " << emp.phNo << endl;
}


int main() {

	Employee employee;
	employee.setPhoneNumber("+91-8093");
	employee.name = "Rishi Raj";

	display(employee);

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Friend Class and Friend Function
*/

#include <iostream>
#include <string>
using namespace std;

class Employee {

	private:
		string phNo;

	public:
		string name;

		void setPhoneNumber(string phoneNumber) {
			this->phNo = phoneNumber;
		}

		friend class Car;
};

class Car {			// Friend class of class Employee

	public:
		string carName;

		void display(Employee emp) {
			cout << "Employee name: " << emp.name << ", Phone: " << emp.phNo << ", Car name: " << carName << endl;
		}
};


int main() {

	Employee employee;
	employee.setPhoneNumber("+91-8093");
	employee.name = "Rishi Raj";

	Car car;
	car.carName = "Ferrari 488";
	car.display(employee);

	return 0;
}
#include <iostream>
using namespace std;

class Shape {

    public:
        virtual double getArea() = 0;
        virtual double getPerimeter() = 0;
};

class Square : public Shape {

    public:
        float side;

        virtual double getArea() {
            return side * side;
        }

        virtual double getPerimeter() {
            return 4 * side;
        }
};

class Rectangle : public Shape {

    public:
        float length;
        float breadth;

        virtual double getArea() {
            return length * breadth;
        }

        virtual double getPerimeter() {
            return 2 * (length + breadth);
        }
};

class Circle : public Shape {

    public:
        float radius;

        virtual double getArea() {
            return 3.14 * radius * radius;
        }

        virtual double getPerimeter() {
            return 2 * 3.14 * radius;
        }
};

class Triangle : public Shape {

    public:
        float base;
        float height;
        float side1;
        float side2;

        virtual double getArea() {
            return (base * height) / 2;
        }

        virtual double getPerimeter() {
            return base + side1 + side2;
        }
};


int main() {

Circle circle;
    circle.radius = 10;
    double area = circle.getArea();
    double perimeter = circle.getPerimeter();

    cout << "The area and the perimeter of the circle is " << area << " square units and " << perimeter << " units respectively." << endl;

    return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Abstract Class
*/

#include <iostream>
#include <new>
using namespace std;

class Animal {		// Abstract class

	public:
		virtual void sound() = 0;		// Pure virtual function

		virtual void sleep() {
			cout << "Animal class: sleeping" << endl;
		}
};

class Dog : public Animal {		// Concrete class

	public:
		virtual void sound() {
			cout << "Dog class: bow-bow" << endl;
		}

		virtual void sleep() {
			cout << "Dog class: sleeping" << endl;
		}
};


int main() {

//	Animal a;	 // a --> Animal object	 // Error. Cannot create an object of an abstract class. 
	
	Dog dog;		// dog --> Dog object
	dog.sound();
	dog.sleep();

	Animal *animal = new Dog();		// animal --> Dog object
	animal->sound();
	animal->sleep();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Polymorphism
*/

#include <iostream>
#include <new>
using namespace std;

class Animal {

	public:
		virtual void sound() {
			cout << "Animal class: making sound" << endl;
		}

		virtual void sleep() {
			cout << "Animal class: sleeping" << endl;
		}
};

class Dog : public Animal {

	public:
		virtual void sound() {
			cout << "Dog class: bow-bow" << endl;
		}

		virtual void sleep() {
			cout << "Dog class: sleeping" << endl;
		}
};


int main() {

	Dog dog;		// dog --> Dog object
	dog.sound();
	dog.sleep();

	Animal *animal = new Dog();		// animal --> Dog object
	animal->sound();
	animal->sleep();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Polymorphism
*/

#include <iostream>
using namespace std;

class Animal {

	public:
		void sound() {
			cout << "Animal class: making sound" << endl;
		}

		void sleep() {
			cout << "Animal class: sleeping" << endl;
		}
};

class Dog : public Animal {

	public:
		void sound() {
			cout << "Dog class: bow-bow" << endl;
		}

		void sleep() {
			cout << "Dog class: sleeping" << endl;
		}
};


int main() {

	Animal animal;
	animal.sound();
	animal.sleep();

	Dog dog;
	dog.sound();
	dog.sleep();

	return 0;
}
#include <iostream>
#include <string>
using namespace std;

class Person {

    private:
        string phoneNumber;

    public:
        string fullName;

        void setPhoneNumber(string phoneNumber) {
            this->phoneNumber = phoneNumber;
        }
};

class Employee : public Person {

    private:
        float salary;

    public:
        int id;

        void setSalary(float salary) {

            this->salary = salary;
        }

        void addBonus(float bonus) {
            this->salary = this->salary + bonus;
        }

        void displaySalary() {
            cout << "Current salary: " << salary;
        }
};


int main() {

    Employee employee;
    employee.id = 1;
    employee.fullName = "Aditya Sharma";
    employee.setPhoneNumber("+91-887700132");
    employee.setSalary(35000);
    employee.addBonus(4000);
    employee.displaySalary();

    return 0;
}

/*
The function ‘addBonus’ in the class Employee should be present under the public section so that it can be accessed from outside the class i.e. from the ‘main’ function. Therefore, the protected section in class Employee was not required. 
*/
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Access Specifiers
*/

#include <iostream>
#include <string>
using namespace std;

class Person {

	protected:
		string phoneNumber;

	public:
		string fullName;

		void setPhoneNumber(string phoneNumber) {
			this->phoneNumber = phoneNumber;
		}

		void displayPersonDetails() {
			cout << "Name: " << fullName << ", Phone: " << phoneNumber << endl;
		}
};

class Student : public Person {

	public:
		int id;

		void displayStudentDetails() {
			cout << "Id: " << id << ", Name: " << fullName << ", Phone: " << phoneNumber << endl;
		}

};


int main() {

	Person person;
	person.fullName = "Rahul Kamal";
	person.setPhoneNumber("+91-9431");
//	string phone = person.phoneNumber;		// protected: Cannot be accessed. Error. 
	person.displayPersonDetails();

	Student student;
	student.id = 1;
	student.fullName = "Aditya Sharma";
	student.setPhoneNumber("+91-8877");
//	string phNo = student.phoneNumber;		// protected: Cannot be accessed. Error. 
	student.displayStudentDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Access Specifiers
*/

#include <iostream>
using namespace std;

class Circle {

	private:		// Access Specifier
		float radius;

	public:
		void setRadius(float radius) {
			this->radius = radius;
		}

		double getArea() {
			return 3.14 * radius * radius;
		}
};


int main() {

	Circle circle;
	circle.setRadius(5);
	double area = circle.getArea();
	cout << "Area of the circle is " << area << " square units." << endl;

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Inheritance
*/

#include <iostream>
#include <string>
using namespace std;

class Animal {

	public:
		int age;
		string color;

		void run() {
			cout << "Running" << endl;
		}
};

class Dog : public Animal {

	public:
		string petName;

		void bark() {
			cout << "Barking" << endl;
		}
};

class Lion : public Animal {

	public:
		void roar() {
			cout << "Roaring" << endl;
		}
};


int main() {

	Dog dog;
	dog.age = 5;
	dog.color = "Black";
	dog.petName = "Jackie";
	dog.bark();
	dog.run();

	Lion lion;
	lion.age = 10;
	lion.color = "Brown";
	lion.roar();
	lion.run();

	Animal animal;
	animal.age = 7;
	animal.color = "White";
	animal.run();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Constructors and Destructors
*/

#include <iostream>
#include <string>
using namespace std;

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		Employee();			// Default constructor declaration
		Employee(int, string, string);	// Parameterized constructor declaration
		
		~Employee();		// Destructor declaration 
		
		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

Employee :: ~Employee() {	// Destructor definition
	cout << "Employee object being deleted";
}

Employee :: Employee(int id, string firstName, string lastName) {	// Parameterized constructor
	this->id = id;
	this->firstName = firstName;
	this->lastName = lastName;
}

Employee :: Employee() {	// Default constructor definition
	cout << "Employee object created\n";
}

void Employee :: displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {
	
	// Create an object of Employee class
	Employee emp1(1, "Rahul", "Sharma");

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	Employee emp3 = emp2;		// Executes copy constructor
	emp3.id = 3;
	emp3.displayDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Constructors and Destructors
*/

#include <iostream>
#include <string>
using namespace std;

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		Employee();			// Default constructor declaration
		Employee(int, string, string);	// Parameterized constructor declaration

		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

Employee :: Employee(int id, string firstName, string lastName) {	// Parameterized constructor
	this->id = id;
	this->firstName = firstName;
	this->lastName = lastName;
}

Employee :: Employee() {	// Default constructor definition
	cout << "Employee object created\n";
}

void Employee :: displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {

	// Create an object of Employee class
	Employee emp1(1, "Rahul", "Sharma");

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	Employee emp3 = emp2;		// Executes copy constructor
	emp3.id = 3;
	emp3.displayDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Constructors and Destructors
*/

#include <iostream>
#include <string>
using namespace std;

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		Employee();			// Default constructor declaration
		Employee(int, string, string);	// Parameterized constructor declaration

		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

Employee :: Employee(int id, string firstName, string lastName) {	// Parameterized constructor
	this->id = id;
	this->firstName = firstName;
	this->lastName = lastName;
}

Employee :: Employee() {	// Default constructor definition
	cout << "Employee object created\n";
}

void Employee :: displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {

	// Create an object of Employee class
	Employee emp1(1, "Rahul", "Sharma");

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Constructors and Destructors
*/

#include <iostream>
#include <string>
using namespace std;

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		Employee();			// Default constructor declaration

		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

Employee :: Employee() {	// Default constructor definition
	cout << "Employee object created\n";
}

void Employee :: displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {

	// Create an object of Employee class
	Employee emp1;

	// Access attributes and set values
	emp1.id = 1;
	emp1.firstName = "Rahul";
	emp1.lastName = "Sharma";

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	return 0;
}
#include <iostream>
using namespace std;

int main() {
    int x = 1;
    
    while (x <= 30)
    {
        cout << x << endl;
        x += 3;
    }
    
    return 0;
    
}
// Online C++ compiler to run C++ program online
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main() {
    string a[] = {"apple" , "a", "ap", "al", "ae", "app", "apl", "ape", "ale", "appl", "appe", "aple", "apple", "p", "pp", "pl", "pe", "ppl", "ppe", "ple", "pple", "l", "le", "e"} ; 
    cout << sizeof(a)/sizeof(a[0])  ; 
    

    return 0;
}
#include <iostream>
#include <string>
using namespace std;

class Dog {    // Defining class

    public:    // public section 
        string breed;
        int age;
        string color;
        string petName;

        void displayDetails();    // Method declaration 
};

void Dog :: displayDetails() {    // Method definition
    cout << "Dog's Pet Name: " << petName << endl << "Breed: " << breed << endl << "Age: " << age << endl << "Color: " << color <<"\n\n";
}


int main() {

    // Creating dog object 
    Dog dog1;
    dog1.breed = "Dalmatian";
    dog1.age = 7;
    dog1.color = "White-black";
    dog1.petName = "Jackie";
    dog1.displayDetails();

    // Creating dog object 
    Dog dog2;
    dog2.breed = "Beagle";
    dog2.age = 4;
    dog2.color = "Brown";
    dog2.petName = "Pluto";
    dog2.displayDetails();

    return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Class and Object
*/

#include <iostream>
#include <string>
using namespace std;

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

void Employee::displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {

	// Create an object of Employee class
	Employee emp1;

	// Access attributes and set values
	emp1.id = 1;
	emp1.firstName = "Rahul";
	emp1.lastName = "Sharma";

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Class and Object
*/

#include <iostream>
#include <string>
using namespace std;

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member
};


int main() {

	// Create an object of Employee class
	Employee emp1;

	// Access attributes and set values
	emp1.id = 1;
	emp1.firstName = "Rahul";
	emp1.lastName = "Sharma";

	// Print attribute values
	cout << "ID: " << emp1.id << endl << "Name: " << emp1.firstName << " " << emp1.lastName  << "\n\n";

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	cout << "ID: " << emp2.id << endl << "Name: " << emp2.firstName << " " << emp2.lastName  << "\n\n";

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Migrating from C to C++
*/

#include <iostream>
using namespace std;

void add(int, int);
void add(string, string);
void add(int, int, int);


int main() {

	// Function Overloading
	add(10, 20);
	add("Hello ", "World");
	add(91, 85, 74);

	return 0;
}

void add(int num1, int num2) {

	cout << num1 + num2 << endl;
}

void add(string str1, string str2) {

	cout << str1 + str2 << endl;
}

void add(int num1, int num2, int num3) {

	cout << num1 + num2 + num3 << endl;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Migrating from C to C++
*/

#include <iostream>
using namespace std;

void display(int, float, string message = "Welcome!");


int main() {

	// Functions: Default parameters
	display(2, 40.8, "Welcome! Hope you are doing great.");

	display(10, 7.8);

	return 0;
}

void display(int num1, float num2, string message) {

	cout << "num1: " << num1 << endl;
	cout << "num2: " << num2 << endl;
	cout << "message: " << message << endl << endl;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Migrating from C to C++
*/

#include <iostream>
using namespace std;


int main() {

	// Boolean values: true or false.
	bool isCodingFun = true;	// 1 means true and 0 means false.
	if (isCodingFun) {
		cout << "Let's code more.\n";
	} else {
		cout << "Find another job.\n";
	}

	int x = 9, y = 20;
	bool b1 = x > y;		// false
	bool b2 = x < y;		// true
	bool b3 = x == y;		// false
	cout << "b1: " << b1 << endl;
	cout << "b2: " << b2 << endl;
	cout << "b3: " << b3 << endl;

	cout << true + 7;		// 1 + 7 = 8

	return 0;
}
void printReverse(Node* head)
{
    // Base case
    if (head == NULL)
    return;
 
    // print the list after head node
    printReverse(head->next);
 
    // After everything else is printed, print head
    cout << head->data << " ";
}
class Solution
{
    public:
    //Function to reverse a linked list.
    struct Node* reverseList(struct Node *head)
    {
        if(head->next==NULL) return head;
        Node *l,*t,*f;
        l=head,t=head->next,f=head->next->next;
        head->next=NULL;
        while(t->next)
        {
            t->next=l;
            l=t;
            t=f;
            f=f->next;
        }
        t->next=l;
        head=t;
        return head;
        // code here
        // return head of reversed list
    }
    
};
#include <iostream>
#include <string>
using namespace std;


int main() {

    string name = "India";
    char dollar = '$';
    float gdp = 2.2;
    int year = 2015;

    cout << "Enter country name:";
    getline(cin, name);

    cout << "Enter dollar symbol:";
    cin >> dollar;

    cout << "Enter GDP:";
    cin >> gdp;

    cout << "Enter year:";
    cin >> year;

    cout << "As economic reforms picked up the pace, " << name << "'s GDP grew five-fold to reach US" << dollar << gdp <<" trillion in " << year << " (as per IMF estimates).";

    return 0;
}
#include <iostream>
#include <string>
using namespace std;


int main() {

    string name = "India";
    char dollar = '$';
    float gdp = 2.2;
    int year = 2015;

    cout << "As economic reforms picked up the pace, " << name << "'s GDP grew five-fold to reach US" << dollar << gdp <<" trillion in " << year << " (as per IMF estimates).";

    return 0;
}
#include <iostream>
using namespace std;

int main() {
    int Choice, option;
    
    cout << "1.Caesar Cipher \n 2.Vernam Cipher \n 3.Vigenere Cipher \n 4.Transposition Cipher \n 5.RSA \n";
    cout << "Choose one of the options above: ";
    
    cin >> Choice;
    
    switch(Choice) {
        case 1:
            cout <<"1.Encrypt a message \n";
            cout <<"2.Decrypt a message \n";
            cout <<"Choose one option from above: ";
            cin >>option;
            
            if(option == 1) {
                string message, cipher;
                char chr;
                int shift, x;
                
                cout <<"Enter your message: ";
                cin >> message;
                
                cout <<"Enter the shift value: ";
                cin >> shift;
        
                for(int i=0; i<message.length(); i++) {
                    chr = message[i];
        
                    if (int(chr) <= 90){
                        x = ((int(chr) + shift - 65) % 26 + 65);
                        cipher[i] = char(x);
                    }
            
                    else {
                        
                        x = ((int(chr) + shift - 97) % 26 + 97);
                        cipher[i] = char(x);
                    }
                }
                cout<<"Your cipher text is: ";
                for(int i=0; i<message.length(); i++) {
                    cout<<cipher[i];
                }
            }
            else if(option == 2) {
                string message, cipher;
                char chr;
                int shift, x;
                
                cout<<"Enter your cipher text: ";
                cin>>cipher;
                
                cout<<"Enter the shift value: ";
                cin>>shift;
                
                for(int i=0; i<cipher.length(); i++) {
                    chr = cipher[i];
                    
                    if(int(chr) < 90) {
                         x = ((int(chr) - shift - 65) % 26 + 65);
                         message[i] = char(x);
                    }
                    else {
                         x = ((int(chr) - shift - 97) % 26 + 97);
                         message[i] = char(x);
                    }
                }
                cout<<"Your decrypted message is: ";
                for(int i=0; i<cipher.length(); i++) {
                    cout<<message[i];
                }
            }
        break;
        case 2:
            cout <<"1.Encrypt a message \n";
            cout <<"2.Decrypt a message \n";
            cout <<"Choose one option from above: ";
            cin >>option;
            
            if(option == 1) {
                string message, cipher, key;
                char chr, keychar;
                int x;
                
                cout <<"Enter your message: ";
                cin >> message;
                
                cout <<"Enter the key: ";
                cin >>key;
                
                for(int i=0; i<message.length(); i++){
                    char chr = message[i];
                    char keychar = key[i];
            
                    if (int(chr) < 90){
                        x = ((int(chr) + int(keychar) - 130) % 26 + 65);
                        cipher[i] = char(x);
                    }
                
                    else{
                       x = ((int(chr) + int(keychar) - 194) % 26 + 97);
                       cipher[i] = char(x);
                    }
                }     
                cout<<"Your cipher text is: ";
                for(int i=0; i<message.length(); i++) {
                    cout<<cipher[i];
                }
            }
            if(option == 2) {
                string cipher, message, key;
                char chr, keychar;
                int x;
                
                cout <<"Enter the cipher text: ";
                cin >> cipher;
                
                cout <<"Enter the key: ";
                cin >>key;
                
                for(int i=0; i<cipher.length(); i++){
                    chr = cipher[i];
                    keychar = key[i];
            
                    if (int(chr) < 90){
                        x = ((int(chr) - int(keychar) - 130) % 26 + 65);
                        message[i] = char(x);
                    }
                    else{
                       x = ((int(chr) - int(keychar)) % 26 + 97);
                       message[i] = char(x);
                    }
                }
                cout<<"Your decrypted message is: ";
                for(int i=0; i<cipher.length(); i++) {
                    cout<<message[i];
                }
            }
        break;
        case 3:
            cout <<"1.Encrypt a message \n";
            cout <<"2.Decrypt a message \n";
            cout <<"Choose one option from above: ";
            cin >>option;
            
            if(option == 1) {
                string message, cipher, key;
                char chr, keychar;
                int x;
                
                cout <<"Enter your message: ";
                cin >> message;
                
                cout <<"Enter the key: ";
                cin >>key;
                
                char newkey[message.length()];
                int length = 0;
                
                
                while(length < message.length()) {
                    for(int i=0; i<key.length(); i++) {
                        if(length <= message.length()) {
                            newkey[length] = key[i];
                            length += 1;
                        }
                        else
                            break;
                    }
                }
                
                for(int i=0; i<message.length(); i++){
                    chr = message[i];
                    keychar = newkey[i];
            
                    if (int(chr) < 90){
                        x = ((int(chr) + int(keychar) - 130) % 26 + 65);
                        cipher[i] = char(x);
                    }
                
                    else{
                       x = ((int(chr) + int(keychar) - 194) % 26 + 97);
                       cipher[i] = char(x);
                    }
                }     
                cout<<"Your cipher text is: ";
                for(int i=0; i<message.length(); i++) {
                    cout<<cipher[i];
                }
            }
            if(option == 2) {
                string cipher, message, key;
                char chr, keychar;
                int x;
                
                cout <<"Enter the cipher text: ";
                cin >> cipher;
                
                cout <<"Enter the key: ";
                cin >>key;
                
                char newkey[cipher.length()];
                int length = 0;
                
                
                while(length < cipher.length()) {
                    for(int i=0; i<key.length(); i++) {
                        if(length <= cipher.length()) {
                            newkey[length] = key[i];
                            length += 1;
                        }
                        else
                            break;
                    }
                }
                
                for(int i=0; i<cipher.length(); i++){
                    chr = cipher[i];
                    keychar = newkey[i];
            
                    if (int(chr) < 90){
                        x = ((int(chr) - int(keychar) - 130) % 26);
                        if(x<0){
                           x += 91;
                       }
                       else{
                           x += 65;
                       }
                        message[i] = char(x);
                    }
                    else{
                       x = ((int(chr) - int(keychar)) %26);
                       if(x<0){
                           x += 123;
                       }
                       else{
                           x += 97;
                       }
                       message[i] = char(x);
                    }
                }
                cout<<"Your decrypted message is: ";
                for(int i=0; i<cipher.length(); i++) {
                    cout<<message[i];
                }
            }
        break;
    }
    return 0;
}
class Solution {
public:
    vector<int> dailyTemperatures(vector<int>& t) {
        vector<int> ans;
        stack<int> s;
        int n=t.size();
        for(int i=n-1;i>=0;i--)
        {
            if(s.empty())
            {
                s.push(i);
                ans.push_back(0);
            }
            else 
            {
                while(!s.empty() && t[s.top()]<=t[i])
                {
                    s.pop();
                }
                if(s.empty())
                { 
                    s.push(i);
                    ans.push_back(0);
                }
                else if(!s.empty()&&t[s.top()]>t[i])
                {
                    ans.push_back(s.top()-i);
                    s.push(i);
                }
            }
        }
        reverse(ans.begin(),ans.end());
        return ans;
    }
};
# Define the grid
grid = initialize_grid()

# Set up the initial conditions for the fields and particles
fields = initialize_fields(grid)
particles = initialize_particles(grid)

# Loop over timesteps
while (time < end_time):
  
  # Advance the particles using the Lorentz force
  particles = push_particles(particles, fields, dt)

  # Update the fields based on the current particle positions and velocities
  fields = solve_fields(fields, particles, dt)

  # Deposit the particle currents onto the grid
  fields = deposit_currents(fields, particles)

  # Interpolate the fields at the particle positions
  fields_at_particles = interpolate_fields(fields, particles)

  # Compute the Lorentz force on the particles
  particles = compute_lorentz_force(particles, fields_at_particles)

  # Increment time
  time += dt
void powell_eyink(double* B, double divB) {
  double alpha = -divB / (2 * dot_product(B, B));
  for (int i = 0; i < 3; i++) {
    B[i] += alpha * B[i];
  }
}
def div_clean(grid, B, tolerance):
  # Compute the divergence of the magnetic field
  divB = compute_divergence(B)

  # Identify points where the divergence exceeds the tolerance
  error_points = [i for i in range(len(grid)) if abs(divB[i]) > tolerance]

  # Adjust the magnetic field at these points using the Powell-Eyink scheme
  for i in error_points:
    B[i] = powell_eyink(B[i], divB[i])
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

// physical parameters
const double gamma = 5./3.; // gas adiabatic index
const double pressure = 1.0; // gas pressure

// simulation parameters
const int nx = 100; // number of cells
const double dx = 0.01; // cell size
const double dt = 0.001; // time step
const double tmax = 1.0; // maximum time

// arrays for storing cell values
double density[nx];
double velocity[nx];
double energy[nx];

// helper function for computing the pressure
double pressure_func(double density, double energy)
{
  return (gamma-1)*density*energy;
}

// main simulation loop
int main(int argc, char **argv)
{
  // initialize density, velocity, and energy
  for (int i = 0; i < nx; i++)
  {
    density[i] = 1.0;
    velocity[i] = 0.0;
    energy[i] = pressure/(gamma-1);
  }

  // time stepping loop
  for (double t = 0; t < tmax; t += dt)
  {
    // compute fluxes at cell interfaces
    double flux_density[nx+1], flux_momentum[nx+1], flux_energy[nx+1];
    for (int i = 0; i < nx+1; i++)
    {
      // left and right cell values
      double density_l = density[i];
      double velocity_l = velocity[i];
      double energy_l = energy[i];
      double pressure_l = pressure_func(density_l, energy_l);

      double density_r = density[i+1];
      double velocity_r = velocity[i+1];
      double energy_r = energy[i+1];
      double pressure_r = pressure_func(density_r, energy_r);

      // Roe average values
      double rho_avg = sqrt(density_l*density_r);
      double vel_avg = (sqrt(density_l)*velocity_l + sqrt(density_r)*velocity_r)/(sqrt(density_l)+sqrt(density_r));
      double h_avg = (sqrt(density_l)*(energy_l+pressure_l/density_l) + sqrt(density_r)*(energy_r+pressure_r/density_r))/(sqrt(density_l)+sqrt(density_r));
      double a_avg = sqrt((gamma-1)*(h_avg-0.5*vel_avg*vel_avg));

      // left and right wave speeds
      double lambda_l = vel_avg - a_avg;
      double lambda_r = vel_avg + a_avg;

      // compute fluxes
      flux_density[i] = rho_avg*vel_avg;
      flux_momentum[i] = rho_avg*vel_avg*vel_avg
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

// A struct to represent a 3D vector
typedef struct Vector {
  double x;
  double y;
  double z;
} Vector;

// A struct to represent a sphere in 3D space
typedef struct Sphere {
  Vector center;
  double radius;
} Sphere;

// A struct to represent a ray in 3D space
typedef struct Ray {
  Vector origin;
  Vector direction;
} Ray;

// Returns the distance from the ray's origin to the point where it intersects
// the sphere, or -1 if the ray does not intersect the sphere.
double intersects(Ray ray, Sphere sphere) {
  Vector oc = {
    .x = ray.origin.x - sphere.center.x,
    .y = ray.origin.y - sphere.center.y,
    .z = ray.origin.z - sphere.center.z
  };

  double b = 2 * (oc.x * ray.direction.x + oc.y * ray.direction.y + oc.z * ray.direction.z);
  double c = oc.x * oc.x + oc.y * oc.y + oc.z * oc.z - sphere.radius * sphere.radius;

  double discriminant = b * b - 4 * c;
  if (discriminant < 0) {
    return -1;
  }

  double t1 = (-b - sqrt(discriminant)) / 2;
  double t2 = (-b + sqrt(discriminant)) / 2;

  // Return the smallest non-negative value of t
  if (t1 >= 0 && t2 >= 0) {
    return fmin(t1, t2);
  } else if (t1 >= 0) {
    return t1;
  } else if (t2 >= 0) {
    return t2;
  } else {
    return -1;
  }
}

int main() {
  // Create a sphere at the origin with radius 1
  Sphere sphere = {
    .center = {
      .x = 0,
      .y = 0,
      .z = 0
    },
    .radius = 1
  };

  // Create a ray that starts at the origin and points in the direction of the
  // positive x-axis
  Ray ray = {
    .origin = {
      .x = 0,
      .y = 0,
      .z = 0
    },
    .direction = {
      .x = 1,
      .y = 0,
      .z = 0
    }
  };

  double distance = intersects(ray, sphere);

  printf("The ray intersects the sphere at a distance of %f\n", distance);

  return 0;
}
/ Function to refine the mesh at a given level of refinement
void refine_mesh(int level) {
    // Loop over all cells in the mesh
    for (int i = 0; i < num_cells; i++) {
        // Check if the cell needs to be refined
        if (cell_needs_refinement(i, level)) {
            // Split the cell into subcells
            split_cell(i);
        }
    }
}

// Function to check if a cell needs to be refined
bool cell_needs_refinement(int cell_index, int level) {
    // Implement the criteria for deciding if a cell needs to be refined here
    // For example, you could check if the error estimate for the cell exceeds a certain threshold
    // or if the cell is near a region of interest (e.g. near a boundary or singularity)
}

// Function to split a cell into subcells
void split_cell(int cell_index) {
    // Create the subcells and update the data structures that store the mesh
    // For example, you could create 4 new subcells by dividing the cell into quadrants
    // and then update the arrays that store the vertices and connectivity of the mesh
}
#include <iostream>
#include <iomanip>
#include <string.h>
using namespace std;

int main() {
    
    double gr1, gr2, gr3, gr4, gr5, gr6, gr7, gr8, gr9, gr10, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, aggregate_grade, gwa;
    int un1, un2, un3, un4, un5, un6, un7, un8, un9, un10, numsub, total_units;
    string id, sec, sec2, sem, sy, sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10;
    char stringarray[50];
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    cout << "------------------------\n"
        << "IT 202D FINAL OUTPUT\n" 
        << "GWA CALCULATOR\n"
        << "------------------------\n";
    
    cout << "Name of Student: ";
    cin.getline(stringarray,30);
    cout << "Student ID: ";
    cin >> id;
    cout << "Year & Section (e.g. BSIT 2B): ";
    cin >> sec >> sec2;
    cout << "Academic Year: ";
    cin >> sy;
    cout << "Semester (e.g. First): ";
    cin >> sem;
    
    cout << "------------------------\n"
        << "Please enter the number of subjects that " << endl
        << "you took this semester (excluding NSTP and subjects \n"
        << "with non-numeric ratings): ";
    cin >> numsub;
    
    if (numsub == 2)
    {
        cout << "------------------------\n"
        << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
    
        cout << "\n-\n"
        << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        total_units = un1 + un2;
    
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
    
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
    
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
    
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
    
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 3)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
    
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
        << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        total_units = un1 + un2 + un3;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        aggregate_grade = p1 + p2 + p3;
        gwa = aggregate_grade / total_units;
        cout << "\n------------------------\n"
            << "Academic Year "<< sy << endl
            << sem << " Semester \n"
            << endl << "GWA = " << gwa 
            << "\n------------------------\n";
    }
    
    else if (numsub == 4)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        total_units = un1 + un2 + un3 + un4;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
    aggregate_grade = p1 + p2 + p3 + p4;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 5)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        total_units = un1 + un2 + un3 + un4 + un5;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
       << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 6)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        total_units = un1 + un2 + un3 + un4 + un5 + un6;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 7)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub7;
        cout << "Number of Credited Units: ";
        cin >> un7;
        cout << "Grade: ";
        cin >> gr7;
        p7 = un7 * gr7;
        total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr7 >= 3.00)
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 8)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub7;
        cout << "Number of Credited Units: ";
        cin >> un7;
        cout << "Grade: ";
        cin >> gr7;
        p7 = un7 * gr7;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub8;
        cout << "Number of Credited Units: ";
        cin >> un8;
        cout << "Grade: ";
        cin >> gr8;
        p8 = un8 * gr8;
        total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr7 >= 3.00)
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr8 >= 3.00)
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 9)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub7;
        cout << "Number of Credited Units: ";
        cin >> un7;
        cout << "Grade: ";
        cin >> gr7;
        p7 = un7 * gr7;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub8;
        cout << "Number of Credited Units: ";
        cin >> un8;
        cout << "Grade: ";
        cin >> gr8;
        p8 = un8 * gr8;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub9;
        cout << "Number of Credited Units: ";
        cin >> un9;
        cout << "Grade: ";
        cin >> gr9;
        p8 = un9 * gr9;
        total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8 + un9;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr7 >= 3.00)
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr8 >= 3.00)
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr9 >= 3.00)
        {
            cout << setw(7) << left << sub9
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub9
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 10)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub7;
        cout << "Number of Credited Units: ";
        cin >> un7;
        cout << "Grade: ";
        cin >> gr7;
        p7 = un7 * gr7;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub8;
        cout << "Number of Credited Units: ";
        cin >> un8;
        cout << "Grade: ";
        cin >> gr8;
        p8 = un8 * gr8;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub9;
        cout << "Number of Credited Units: ";
        cin >> un9;
        cout << "Grade: ";
        cin >> gr9;
        p8 = un9 * gr9;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub10;
        cout << "Number of Credited Units: ";
        cin >> un10;
        cout << "Grade: ";
        cin >> gr10;
        p8 = un10 * gr10;
        total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8 + un9 + un10;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr7 >= 3.00)
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr8 >= 3.00)
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr9 >= 3.00)
        {
            cout << setw(7) << left << sub9
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub9
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr10 >= 3.00)
        {
            cout << setw(7) << left << sub10
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub10
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else
    {
        cout << "\n------------------------\n"
        << "Invalid entry";
    }
    
    return 0;
    }
<a href="https://www.iubenda.com/privacy-policy/34674803" class="iubenda-white iubenda-noiframe iubenda-embed iubenda-noiframe " title="Privacy Policy ">Privacy Policy</a><script type="text/javascript">(function (w,d) {var loader = function () {var s = d.createElement("script"), tag = d.getElementsByTagName("script")[0]; s.src="https://cdn.iubenda.com/iubenda.js"; tag.parentNode.insertBefore(s,tag);}; if(w.addEventListener){w.addEventListener("load", loader, false);}else if(w.attachEvent){w.attachEvent("onload", loader);}else{w.onload = loader;}})(window, document);</script>
struct ScatteredBullet
		{
			DoubleBullet *pBullet1;
			DoubleBullet *pBullet2;
			DoubleBullet *pBullet3;
		};
	ScatteredBullet *pScatteredBullet = (struct ScatteredBullet*)malloc(sizeof(struct ScatteredBullet));
		DoubleBullet *pBullet1 = new DoubleBullet;
		DoubleBullet *pBullet2 = new DoubleBullet;
		DoubleBullet *pBullet3 = new DoubleBullet;
		pScatteredBullet->pBullet1 = pBullet1;
		pScatteredBullet->pBullet2 = pBullet2;
		pScatteredBullet->pBullet3 = pBullet3;
Grab up to 30% off on our blockchain fork development Services limited time Offer ends in November 25.

For the development of many business sectors, blockchain forks are essential. However, depending on the position, the process requires the use of technology. This is why we're going to look at some of the ways that cryptocurrencies can be developed, including forking existing blockchains to create new ones.

Hivelance, a leading blockchain fork development company, creates a customizable Blockchain Fork Development on various blockchain networks such as Ethereum, Tron, and Binance Smart Chain (BSC), allowing innovators to launch their businesses faster.

visit our site for know more-

https://www.hivelance.com/blockchain-forking
Black Friday sale : Grab up to 30% off on our NFT Token development Services limited time Offer ends in November 25.

Hivelance is a reputable NFT Token development business that works with clients from all over the world and across many industry sectors. We have developed secure, efficient, and revenue-generating NFT development solutions. Hivelance is a leading NFT token development company that offering a  top-notch innovative NFT token development solutions for various businesses across multiple industries. Being the best token development company we create and launch the different types of tokens according to the client’s requirement. We make engaging non-fungible token with transparency, high-end security, and faster delivery.

visit our website for more info-

https://www.hivelance.com/nft-token-development
Grab up to 30% off on our ERC20 Token development Services limited time Offer ends in November 25.

The ERC20 Token contract is the smart contract code logic that executes the fungible token activity. When a contract is put into practise on Ethereum, it can be exchanged for any tokens with a similar value. The ERC20 token standard is used for crypto staking, voting, and the exchange of digital cash as a result. Anyone can generate ERC20 tokens and import them into Ethereum virtual machines.

Hivelance provides ERC20 token development service.  We offer an alot of options as part of our ERC20 Token development package, such as code generation, logo design, an audit of the ERC token contract, deployment to the EVM, ongoing development, security audits at regular intervals, and more. We have supported various ICO projects and helped them scale up their fundraising efforts.

https://www.hivelance.com/erc20-token-development
class TrieNode{
    vector<TrieNode*> v;
    public:
    TrieNode(){
        v.resize(26,NULL);
    }
};

void push(string word,TrieNode* root){
    TrieNode* currRoot = root;
    for(char letter:word){
        if(currRoot->v[letter - 'a'] == NULL)
            currRoot->v[letter - 'a'] = new TrieNode();
        currRoot = currRoot->v[letter-'a'];
    }
}
#include <bits/stdc++.h>
using namespace std;
 

int main() {
    int t;
    cin>>t;
    vector<long long int> v1;
      vector<long long int> v2;
      v1.push_back(1);
      v2.push_back(1);
      long long int mod = 1e9 + 7;
      for(long long int i=1;i<1e6;i++)
      {
        //  v1.push_back(v1[i-1]+1);
          v2.push_back((v2[i-1]*(i+1))%mod);
      }
    while(t--)
    {
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
      }
      sort(a,a+n);
       long long int ans=0;
      
      
      for(int long long i=0;i<n;i++)
      {
          ans+=(v2[a[i]-1]%1000000007);
      }
      ans=ans%1000000007;
      cout<<ans<<"\n";
    }
	return 0;
}
class Solution{
	public:
	vector<int> downwardDigonal(int n, vector<vector<int>> a)
	{
	    vector<int> v;
		for(int j=0;j<n;j++)
		{
		    int i=0,k=j;
		    while(i<n && k>=0)
		    {
		        v.push_back(a[i][k]);
		        i++;
		        k--;
		    }
		}
		for(int i=1;i<n;i++)
		{
		    int j=i,k=n-1;
		    while(j<n && k>=0)
		    {
		        v.push_back(a[j][k]);
		        j++;
		        k--;
		    }
		}
		return v;
	}
};
#include <iostream>
using namespace std;

void write_vertical(int n);

int main()
{
    int n;
    
    cout << "Recursion" << endl
        << "Enter a number with one or more digits: ";
    cin >> n;
    cout << "--------------------------------------" << endl;
    write_vertical(n);
    
    return 0;
}

void write_vertical(int n)
{
    if (n < 10)
    {
        cout << n << endl;
    }
    else
    {
        write_vertical(n / 10);
        cout << (n % 10) << endl;
    }
}
class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        int n1=strs.size();
        int ans=strs[0].length();
        for(int i=1;i<n1;i++)
        {
            int j=0;
            while(j<strs[i].size() && strs[i][j]==strs[0][j])
            {
                j++;
                
            }
            ans=min(ans,j);
        }
        return strs[0].substr(0,ans);
    }
};
class Solution {
public:
    int romanToInt(string s) {
        
        map<char,int>mp;
        mp['I']=1;
        mp['V']=5;
        mp['X']=10;
        mp['L']=50;
        mp['C']=100;
        mp['D']=500;
        mp['M']=1000;
       
        int n=s.size(),num,sum=0;
        for(int i=0;i<n;i++)
        {
            if(mp[s[i]]<mp[s[i+1]])
            {
                sum-=mp[s[i]];
            }
            else 
            {
                sum+=mp[s[i]];
            }
        }
        
        return sum;
    }
};
class Solution
{   
    public:
    //Function to modify the matrix such that if a matrix cell matrix[i][j]
    //is 1 then all the cells in its ith row and jth column will become 1.
    void booleanMatrix(vector<vector<int> > &matrix)
    {
       
        int n1=matrix.size();
        int n2=matrix[0].size();
        vector<pair<int,int>> v;
        for(int i=0;i<n1;i++)
        {
            for(int j=0;j<n2;j++)
            {
                if(matrix[i][j]==1) 
                {
                    v.push_back({i,j});
                    
                }
            }
        }
        int n3=v.size();
        for(int i=0;i<n3;i++)
        {
            for(int j=0;j<n2;j++)
            {
                matrix[v[i].first][j]=1;
            }
            for(int j=0;j<n1;j++)
            {
                matrix[j][v[i].second]=1;
            }
        }
    }
};
class Solution
{   
    public: 
    //Function to return a list of integers denoting spiral traversal of matrix.
    vector<int> spirallyTraverse(vector<vector<int> > matrix, int r, int c) 
    {
        
        int l=0;
        int ri=c-1;
        int u=0;
        int d=r-1;
        
        vector<int>v;
        while(l<=ri && u<=d)
        {
            for(int i=l;i<=ri;i++)
            {
                v.push_back(matrix[u][i]);
            }
            u++;
            
            for(int i=u;i<=d;i++)
            {
                v.push_back(matrix[i][ri]);
            }
            ri--;
            
            if(u<=d)
            {
                for(int i=ri;i>=l;i--)
                {
                    v.push_back(matrix[d][i]);
                }
                
                d--;
            }
            
            if(l<=ri)
            {
                for(int i=d;i>=u;i--)
                {
                    v.push_back(matrix[i][l]);
                }
                l++;
            }
        }
        return v;
    }
};
class Solution
{
    public:
    //Function to search a given number in row-column sorted matrix.
    bool search(vector<vector<int> > matrix, int n, int m, int x) 
    {
        int long long i=0,j=m-1;
        while(i<n && j>=0&& j<n&&i>=0)
        {
            if(matrix[i][j]==x) return 1;
            else if(matrix[i][j]>=x) j--;
            else i++;
        }
        return 0;
    }
};
#include <bits/stdc++.h>
using namespace std;

int main() 
{
    int t;
    cin>>t;
    while(t--)
    {
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++)
      {
         cin>>a[i];
      }
      unordered_map<int,int> m1;
      for(int i=0;i<n;i++)
      {
         m1[a[i]]++;
      }
      priority_queue<pair<int,int>> maxH;
      for(auto x:m1)
      {
         maxH.push({x.second,-1*(x.first)});
      }
      while(!maxH.empty())
      {
         int freq=maxH.top().first;
         int ele=-1*(maxH.top().second);
         for(int i=0;i<freq;i++)
         {
            cout<<ele<<" ";
         }
         maxH.pop();
      }
      cout<<"\n";
    }
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
     int n;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++)
     {
        cin>>a[i];
     }
     srand(time(0));
     for(int i=n-1;i>=0;i--)
     {
        int j=rand()%(i+1);
        swap(a[j],a[i]);
     }
     for(int i=0;i<n;i++)
     {
        cout<<a[i]<<" ";
     }
	return 0;
}
public:
    // Function to find equilibrium point in the array.
    // a: input array
    // n: size of array
    int equilibriumPoint(long long a[], int n) {
    long long p=0;
    for(int i=0;i<n;i++)
    {
        p+=a[i];
    }
    long long a1[n];
    long long a2[n];
    a1[0]=-1;
    a2[n-1]=-1;
    int p1=0;
    int p2=0;
    for(int i=1;i<n;i++)
    {
        p1+=a[i-1];
        a1[i]=p1;
    }
    for(int i=n-2;i>=0;i--)
    {
        p2+=a[i+1];
        a2[i]=p2;
    }
    for(int i=0;i<n;i++)
    {
        if(a1[i]==a2[i])
        {
            return i+1;
        }
    }
    return -1;
xargs rm < install_manifest.txt
#include<iostream>

class A1{
    void f1() { std::cout << "print f1" << std::endl; }
    public:
    void f2() { std::cout << "print f2" << std::endl; }
    void f5() { f1(); }
    protected:
    void f3() { std::cout << "print f3" << std::endl; }
};

class A2 : public A1{
    public:
    void f4() { f3(); }
};

int main(){
    A1 obj;
    A2 obj1;
    obj1.f4();
    obj1.f2();
    obj1.f5();
    obj.f2();
    obj.f5();
    return 0;
}
class Solution {
public:
    vector<string> twoEditWords(vector<string>& q, vector<string>& d) {
        int n1=d.size();
        int n2=q.size();
        int k=q[0].size();
        vector<string>v;
        set<int> idx;
        for(int i=0;i<n2;i++)
        {
            for(int j=0;j<n1;j++)
            {
                int c=0;
                for(int h=0;h<k;h++)
                {
                    if(d[j][h]!=q[i][h]) c++;
                }
                if(c<=2) idx.insert(i);
            }
        }
        for(auto x:idx)
        {
           v.push_back(q[x]) ;
        }
        return v;
    }
};
class Solution {
public:
    string oddString(vector<string>& words) {
        int n1=words.size();
        int k = words[0].size();
        map<vector<int>, int> m;
        vector<vector<int>> v;
        for(int i=0;i<n1;i++)
        {
            //int n2=words[i].length();
            vector<int> a(k-1,0);
            //a[k-1]=i;
            for(int j=0;j<k-1;j++)
            {
                a[j]=words[i][j+1]-words[i][j];
                
            }
            v.push_back(a);
            m[a]++;
        }
        vector<int>v2;
        string s;
        for(auto x:m)
        {
            if(x.second==1)
            {
                for(int i=0;i<x.first.size();i++)
                {
                    v2.push_back(x.first[i]);
                }
                break;
            }
        }
        for(int i=0;i<n1;i++)
        {
            if(v[i]==v2)
            {
                s=words[i];
            }
        }
        
        return s;
    }
};
class Solution{
    public:
    //Complete this function
    //Function to check whether there is a subarray present with 0-sum or not.
    bool subArrayExists(int arr[], int n)
    {
        int pref_sum=0;
        unordered_set<int> s;
        for(int i=0;i<n;i++)
        {
            pref_sum+=arr[i];
            if(pref_sum==0) return true;
            if(s.find(pref_sum)!=s.end()) return true;
            s.insert(pref_sum);
        }
        return false;
        //Your code here
    }
};
#include <iostream>

void initialize_screen();
double celsius(double fahrenheit);
void show_results(double f_degrees, double c_degrees);

int main()
{
    using namespace std;
    double f_temperature, c_temperature;
    
    initialize_screen();
    cout << "I will convert a Fahrenheit temperature "
        << "to Celsius.\n"
        << "Enter a temperature in  Fahrenheit: ";
    cin >> f_temperature;
    
    c_temperature = celsius(f_temperature);
    
    show_results(f_temperature, c_temperature);
    return 0;
}

void initialize_screen()
{
    using namespace std;
    cout << endl;
    return;
}

double celsius(double fahrenheit)
{
    return ((5.0/9.0)*(fahrenheit - 32));
    
}

void show_results(double f_degrees, double c_degrees)
{
    using namespace std;
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    cout << f_degrees
        << " degrees Fahrenheit is equivalent to\n"
        << c_degrees << " degrees Celsius.\n";
    return;
}
class Solution{
  public:
  
    vector<int> find3Numbers(vector<int> arr, int n) {
        // Your code here
        vector<int>v;
        int min=0;
        int max=n-1;
        int* smaller=new int[n];
        int* greater=new int[n];
        smaller[0]=-1;
        greater[n-1]=-1;
        for(int i=1;i<n;i++)
        {
            if(arr[i]<=arr[min])
            {
                min=i;
                smaller[i]=-1;
            }
            else smaller[i]=min;
        }
        for(int i=n-2;i>=0;i--)
        {
            if(arr[i]>=arr[max])
            {
                max=i;
                greater[i]=-1;
            }
            else greater[i]=max;
        }
        for(int i=0;i<n;i++)
        {
            if(smaller[i]!=-1 && greater[i]!=-1)
            {
                v.push_back(arr[smaller[i]]);
                v.push_back(arr[i]);
                v.push_back(arr[greater[i]]);
                break;
            }
        }
        delete[] greater;
        delete[] smaller;
        return v;
    }
};
#include<iostream>

class baseClass{
    public:
    void a() {std::cout << "Base class atau Parent class" << std::endl;}
};

class derivedClass : public baseClass{
    public:
    void b() {std::cout << "Derived class atau Child class" << std::endl;}
};

int main(){
    derivedClass obj;
    obj.a();
    obj.b();
    return 0;
}
#include<iostream>

struct A {
    void a();
};

void A::a() {std::cout << "Fungsi dari struct A" << std::endl;}

class B {
    public:
    void b();
    struct A c;
};

void B::b() {std::cout << "Fungsi dari class B" << std::endl;}

int main(){
    B obj;
    obj.b();
    obj.c.a();
    return 0;
}
#include<iostream>
// mendeklarasikan class
class A;
// mendefinisikan class
class A{
    public:
    int a;
    void b() {std::cout << "nilai a = " << a << std::endl;}
};

int main(){
    A obj;
    obj.a = 5;
    obj.b();
    return 0;
}
#include<iostream>
// mendeklarasikan struct
struct A;
// mendefinisikan struct 
struct A {
    int a;
    void b() { std::cout << "nilai a = " << a << std::endl;}
};

int main(){
    struct A test;
    test.a = 5;
    test.b();
    return 0;
}
class Solution {
public:
    int countPairs(vector<int>& nums, int k) {
        int n=nums.size();
        int c=0;
        for(int i=0;i<n-1;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                int p=i*j;
                if(nums[i]==nums[j]&&p%k==0) c++;
            }
        }
        return c;
    }
};
class Solution {
public:
    vector<vector<int>> flipAndInvertImage(vector<vector<int>>& a) {
        int n=a.size();
        for(int i=0;i<n;i++)
        {
           reverse(a[i].begin(),a[i].end());
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]==0) a[i][j]=1;
                else a[i][j]=0;
            }
        }
        return a;
    }
};
class Solution {
public:
    int countGoodTriplets(vector<int>& arr, int a, int b, int c) {
         int ans=0;
        int n=arr.size();
        for(int i=0;i<n-2;i++)
        {
            for(int j=i+1;j<n-1;j++)
            {
                for(int k=j+1;k<n;k++)
                {                                                                                                       if(abs(arr[i]-arr[j])<=a && abs(arr[j]-arr[k])<=b && abs(arr[i]-arr[k])<=c)
                    {
                        ans++;
                    }
                }
            }
        }
        return ans;
    }
};
class Solution{
  public:
    vector<int> find3Numbers(vector<int> arr, int N) {
        // Your code here
        vector<int>v;
        int left=INT_MAX;
        int mn=left;
        int mid=INT_MAX;
        if(N<3) 
        {
            return {};
        }
        for(int i=0;i<N;i++)
        {
            if(arr[i]<left) 
            {
                left=arr[i];
            }
            else if(arr[i]>left&&arr[i]<mid)
            {
                mid=arr[i];
                mn=left;
            }
            else if(arr[i]>mid) 
            {
                v.push_back(mn);
                v.push_back(mid);
                v.push_back(arr[i]);
                return v;
            }
        }
        return {};
    
    }
};
#include <iostream>
using namespace std;

const int MAX_SIZE = 20;

void readNumber(int number[], int &count)
{
	char ch;

	cin.get(ch);
	while (ch != '\n' && count < MAX_SIZE)
	{
		number[count] = ch - '0';
		count++;

		cin.get(ch);
	}
}

void reverseDigits(int number[], int count)
{
	int i = 0;
	int j = count - 1;

	while (i < j)
	{
		int temp = number[i];
		number[i] = number[j];
		number[j] = temp;

		i++;
		j--;
	}
}

bool addNumbers(int number1[], int count1, int number2[], int count2,
		int result[], int &size)
{
	int sum = 0;
	int carry = 0;
	int i = 0;
	int j = 0;

	while (i < count1 && j < count2 && size < MAX_SIZE)
	{
		sum = number1[i] + number2[j] + carry;

		if (sum > 9)
		{
			carry = sum / 10;
			sum = sum % 10;
		}
		else
		{
			carry = 0;
		}

		result[size] = sum;
		size++;
		i++;
		j++;

		if(carry != 0 && size == MAX_SIZE)
			return false;
	}

	while (i < count1 && size < MAX_SIZE)
	{
		sum = number1[i] + carry;

		if (sum > 9)
		{
			carry = sum / 10;
			sum = sum % 10;
		}
		else
		{
			carry = 0;
		}

		result[size] = sum;
		size++;
		i++;

		if(carry != 0 && size == MAX_SIZE)
			return false;
	}

	while (j < count2 && size < MAX_SIZE)
	{
		sum = number2[j] + carry;

		if (sum > 9)
		{
			carry = sum / 10;
			sum = sum % 10;
		}
		else
		{
			carry = 0;
		}

		result[size] = sum;
		size++;
		j++;

		if(carry != 0 && size == MAX_SIZE)
			return false;
	}

	if (carry > 0)
	{
		result[size] = carry;
		size++;
	}

	return true;
}

void printNumber(int number[], int count)
{
	for (int i = count - 1; i >= 0; i--)
	{
		cout << number[i];
	}
}

int main()
{
	int number1[MAX_SIZE];
	int number2[MAX_SIZE];
	int result[MAX_SIZE];
	int count1 = 0;
	int count2 = 0;
	int size = 0;

	cout << "Enter the first number:  ";
	readNumber(number1, count1);

	cout << "Enter the second number: ";
	readNumber(number2, count2);

	reverseDigits(number1, count1);
	reverseDigits(number2, count2);

	bool success = addNumbers(number1, count1, number2, count2, result, size);

	if(success)
	{
		cout << endl;
		printNumber(number1, count1);
		cout << " + ";
		printNumber(number2, count2);
		cout << " = ";
		printNumber(result, size);
		cout << endl;
	}
	else
	{
		cout << "integer overflow" << endl;
	}

	return 0;
}
#include<bits/stdc++.h>
using namespace std;

string IntToString(int arr[], int k){
	string ans;

	for(int i = 0;i<k;i++){
		ans+= to_string(arr[i]);
	}
	return ans;
}

void StringToInt(string s){
	vector<int>v;
	map<int, int> mp;
	for(int i = 0;i<s.length();i++){
		v.push_back(s[i]-'0');
	}
	sort(v.begin(), v.end());
	for(int i = 0;i<v.size();i++){
		mp[v[i]]++;
	}
	cout<<"counting the frequency : \n";
	for(auto i:mp){
			cout<<i.first<<" "<<i.second<<endl;
	}
}

int main(){
	string s = "123343233434435";
	int brr[] = {2,3,4,5,6,7};
	int n = sizeof(brr)/sizeof(brr[0]);
	cout<<IntToString(brr, n)<<endl;
	StringToInt(s);
	return 0;
}
class Solution
{
    public:
    long long countKdivPairs(int A[], int n, int K)
    {
        //code here
        long ans=0;
        unordered_map<int,int>m;
        for(int i=0;i<n;i++)
        {
            int rem=A[i]%K;
            if(rem!=0)
            {
                ans+=m[K-rem];
            }
            else ans+=m[0];
            m[rem]++;
        }
        return ans;
    }
};
class Solution
{
    public:
    //Function to return the lowest common ancestor in a Binary Tree.
    Node* lca(Node* root,int n1,int n2 )
    {
        if(root==NULL) return NULL;
        if(root->data==n1 || root->data==n2) return root;
        
        Node* left=lca(root->left,n1,n2);
        Node* right=lca(root->right,n1,n2);
         
         if(left==NULL) return right;
         if(right==NULL) return left;
         return root;
        
       //Your code here 
    }
};
class Solution {
  public:
    // Function to return the count of the number of elements in
    // the intersection of two arrays.
    int NumberofElementsInIntersection(int a[], int b[], int n, int m) {
        // Your code goes here
        unordered_map<int,int> s,t;
        int ans=0;
        for(int i=0;i<n;i++)
        {
            s[a[i]]++;
        }
        for(int i=0;i<m;i++)
        {
            t[b[i]]++;
        }
        for(auto x:s)
        {
            if(t.count(x.first)>0)
            {ans++;}
        }
        return ans;
    }
};
class Solution {
public:
    int arithmeticTriplets(vector<int>& nums, int diff) {
        int n=nums.size();
        set<int> s(nums.begin(),nums.end());
        int ans=0;
        for(int i=0;i<n;i++)
        {
            if(s.find(nums[i]-diff)!=s.end() && s.find(nums[i]-2*diff)!=s.end())
            {
                ans++;
            }
        }
        return ans;
    }
};
class Solution {
public:
    int maxfind(vector<vector<int>>& grid, int i, int j)
    {
        int maxa=INT_MIN;
        for(int x=i;x<i+3;x++)
        {
            for(int y=j;y<j+3;y++)
            {
                maxa = max(grid[x][y],maxa);
            }
        }
        return maxa;
    }
    vector<vector<int>> largestLocal(vector<vector<int>>& grid) {
        int n=grid.size();
        vector<vector<int>> v(n-2, vector<int>(n-2));
        for(int i=0;i<n-2;i++)
        {
            for(int j=0;j<n-2;j++)
            {
                v[i][j]=maxfind(grid, i ,j);
            }
        }
        return v;
    }
};
class Solution {
public:
    string reversePrefix(string word, char ch) {
        int n=word.size();
        int r=0;
        for(int i=0;i<n;i++)
        {
            if(word[i]!=ch)
            {
                r++;
            }
            else break;
        }
        if(r==n) return word;                                                                               reverse(word.begin(),word.begin()+r+1);
        return word;
    }
};
class Solution {
public:
    string firstPalindrome(vector<string>& words) {
        int n=words.size();
        
        string temp="";
        for(int i=0;i<n;i++)
        {
            temp="";
            int n1=words[i].size();
            temp=words[i];
            for(int j=0;j<n1/2;j++)
            {
                swap(temp[j],temp[n1-j-1]);
            }
            if(temp==words[i])
            {
               return words[i];
            }
            else temp="";
        }
    return temp;
    }
};
class Solution
{
    public:
    //Function to reverse words in a given string.
    string reverseWords(string S) 
    { 
       int n=S.size();
       stack<string>st;
       string si="";
       for(int i=0;i<n;i++)
       {
           if(S[i]=='.')
           {
               st.push(si);
               st.push(".");
               si="";
           }
           else { si+=S[i];}
       }
       st.push(si);
       string an="";
       int t=st.size();
       for(int i=0;i<t;i++)
       {
           an.append(st.top());
           st.pop();
       }
       return an;
    } 
};
class Solution {
public:
    string replaceDigits(string s) {
        int n=s.size();
        string p="";
        for(int i=0;i<n;i++)
        {
            if((s[i]-'0')>=0 && (s[i]-'0')<=9)
            {
                p+=(s[i-1]+(s[i]-'0'));
                
            }
            else 
            {
                p+=s[i];
            }
        }
        return p;
    }
};
class Solution {
public:
    int numOfStrings(vector<string>& patterns, string word) {
        int c=0;
        for(int i=0;i<patterns.size();i++)
        {
            if(word.find(patterns[i])!=-1) c++;
        }
        return c;
    }
};
class Solution {
public:
    string removeOuterParentheses(string s) 
    {
        int n=s.size();
        int j=0;
        string p="";
        for(int i=0;i<n;i++)
        {
            if(s[i]==41)
            {
                j--;
            }
            if(j!=0) 
            {
                p+=s[i];
            }
            if(s[i]==40)
            {
                j++;
            }
            
        }
        return p;
    }
};
class Solution {
public:
    bool checkIfPangram(string s) {
        int n=s.size();
        vector<bool> v(26,false);
        if(n<26) return false;
        else if(n>=26)
        {
            for(int i=0;i<n;i++)
            {
                v[s[i]-'a']=true;
            }
        }
        for(int i=0;i<26;i++)
        {
            if(v[i]==false) return false;
        }
        return true;
    }
};
class Solution {
public:
    string reverseWords(string s) {
        int n=s.size();
        int l=0,r=0;
        while(l<n)
        {
            while(r<n && s[r]!=' ')
            {
               r++;
            }
            reverse(s.begin()+l,s.begin()+r);
            l=r+1;
            r=l;
        }
        return s;
    }
};
class Solution {
public:
    int countPoints(string ri) {
        int n=ri.size();
        vector<bool> r(10,false);
        vector<bool> g(10,false);
        vector<bool> b(10,false);
        for(int i=1;i<n;i=i+2)
        {
            if(ri[i-1]=='R')
            {
                r[ri[i]-'0']=true;
            }
            else if(ri[i-1]=='G')
            {
                g[ri[i]-'0']=true;
            }
            else  if(ri[i-1]=='B')
            {
                b[ri[i]-'0']=true;
            }
        }
        int c=0;
        for(int i=0;i<10;i++)
        {
            if(r[i]==true && g[i]==true && b[i]==true)
            {
                c++;
            }
        }
        return c;
    }
};
class Solution {
public:
    int countConsistentStrings(string allowed, vector<string>& words) {
        int n1=allowed.size();
        int n2=words.size();
        int ans=0;
        for(int i=0;i<n2;i++)
        {
            int n3=words[i].size();
            int ci=0;
            for(int j=0;j<n3;j++)
            {
                bool f=false;
                for(int k=0;k<n1;k++)
                {
                    if(words[i][j]==allowed[k])
                    {
                        f=true;
                        break;
                    }
                }
                if(f==true) ci++;
            }
            if(ci==n3) ans++;
            
        }
        return ans;
    }
};
class Solution {
public:
    string toLowerCase(string s) {
        int n=s.size();
        string s1="";
        for(int i=0;i<n;i++)
        {
            if(int(s[i])>=65 && int(s[i])<=90)
            {
                s1+=s[i]+32;
                continue;
            }
            s1+=s[i];
        }
        return s1;
    }
};
class Solution {
public:
    int uniqueMorseRepresentations(vector<string>& words) {
        unordered_map<char,string> mp;
        mp['a']=".-";
        mp['b']="-...";
        mp['c']="-.-.";
        mp['d']="-..";
        mp['e']=".";
        mp['f']="..-.";
        mp['g']="--.";
        mp['h']="....";
        mp['i']="..";
        mp['j']=".---";
        mp['k']="-.-";
        mp['l']=".-..";
        mp['m']="--";
        mp['n']="-.";
        mp['o']="---";
        mp['p']=".--.";
        mp['q']="--.-";
        mp['r']=".-.";
        mp['s']="...";
        mp['t']="-";
        mp['u']="..-";
        mp['v']="...-";mp['w']=".--";mp['x']="-..-";mp['y']="-.--";mp['z']="--..";
        set<string> s;
        int n=words.size();
        for(int i=0;i<n;i++)
        {
            int n1=words[i].size();
            string s1="";
            for(int j=0;j<n1;j++)
            {
                s1.append(mp[words[i][j]]);
            }
            s.insert(s1);
            
        }
        return s.size();
        
        
        
    }
};
class Solution {
public:
    vector<string> sortPeople(vector<string>& names, vector<int>& heights) {
        int n=names.size();
        map<int,string> mp;
        for(int i=0;i<n;i++)
        {
            mp[heights[i]]=names[i];
        }
        vector<string> v;
        map<int,string>::iterator i;
        for(auto i=mp.begin();i!=mp.end();i++)
        {
            v.push_back(i->second);
            
        }
        reverse(v.begin(),v.end());
        return v;
    }
};
class Solution {
public:
    int countMatches(vector<vector<string>>& items, string ruleKey, string ruleValue) {
        int n=items.size();
        int p=3;
        int i;
        int c=0;
        if(ruleKey=="type")
        {
            i=0;
            for(int j=0;j<n;j++)
            {
                if(items[j][i]==ruleValue)
                {c++;}
            }
        }
        else if(ruleKey=="color")
        {
            i=1;
            for(int j=0;j<n;j++)
            {
                if(items[j][i]==ruleValue) {c++;}
            }
        }
        else if(ruleKey=="name")
        {
            i=2;
            for(int j=0;j<n;j++)
            {
                if(items[j][i]==ruleValue) {c++;}
            }
        }
        return c;
    }
};
class Solution {
public:
    vector<string> cellsInRange(string s) {
        char c1=s[0], r1=s[1], c2=s[3], r2=s[4];
        vector<string> v;
        for(int i=0;i+c1<=c2;i++)
        {
            for(int j=0;j+r1<=r2;j++)
            {
                string p;
                p+=(c1+i);
                p+=(r1+j);
                v.push_back(p);
            }
        }
        return v;
    }
};
for(int i=0;i<n;i++){
  //do something
}
#include <Windows.h>
#include <TlHelp32.h>
#include <tchar.h>
#include <vector>
#include <stdlib.h>
#include <iostream>

using namespace std;

DWORD GetModuleBaseAddress(TCHAR* lpszModuleName, DWORD pID) {
    DWORD dwModuleBaseAddress = 0;
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pID); // make snapshot of all modules within process
    MODULEENTRY32 ModuleEntry32 = { 0 };
    ModuleEntry32.dwSize = sizeof(MODULEENTRY32);

    if (Module32First(hSnapshot, &ModuleEntry32)) //store first Module in ModuleEntry32
    {
        do {
            if (_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0) // if Found Module matches Module we look for -> done!
            {
                dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
                break;
            }
        } while (Module32Next(hSnapshot, &ModuleEntry32)); // go through Module entries in Snapshot and store in ModuleEntry32


    }
    CloseHandle(hSnapshot);
    return dwModuleBaseAddress;
}

DWORD GetPointerAddress(HWND hwnd, DWORD gameBaseAddr, DWORD address, vector<DWORD> offsets)
{
    DWORD pID = NULL; // Game process ID
    GetWindowThreadProcessId(hwnd, &pID);
    HANDLE phandle = NULL;
    phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
    if (phandle == INVALID_HANDLE_VALUE || phandle == NULL);

    DWORD offset_null = NULL;
    ReadProcessMemory(phandle, (LPVOID*)(gameBaseAddr + address), &offset_null, sizeof(offset_null), 0);
    DWORD pointeraddress = offset_null; // the address we need
    for (int i = 0; i < offsets.size() - 1; i++) // we dont want to change the last offset value so we do -1
    {
        ReadProcessMemory(phandle, (LPVOID*)(pointeraddress + offsets.at(i)), &pointeraddress, sizeof(pointeraddress), 0);
    }
    return pointeraddress += offsets.at(offsets.size() - 1); // adding the last offset
}

int main()
{
    HWND hwnd_Chaos = FindWindowA(NULL, "Chaos");
    if (hwnd_Chaos != FALSE);
    DWORD pID = NULL;
    GetWindowThreadProcessId(hwnd_Chaos, &pID);
    HANDLE phandle = NULL;
    phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
    if (phandle == INVALID_HANDLE_VALUE || phandle == NULL);

    char gamemodule1[] = "ChaosGame424-Win64-Shipping.exe";
    DWORD gamebaseadress1 = GetModuleBaseAddress(_T(gamemodule1), pID);

    //Ammo
    DWORD ammoAddr = 0x035CC570;
    vector<DWORD> ammoOffsets{ 0x10, 0x20, 0x50, 0x298, 0xE0, 0x248, 0x974 };
    DWORD ammoPtrAddr = GetPointerAddress(hwnd_Chaos, gamebaseadress1, ammoAddr, ammoOffsets);

    //Write the memory finally 
    while (true)
    {
        int ammo = 1000;
        WriteProcessMemory(phandle, (LPVOID*)(ammoPtrAddr), &ammo, 4, 0);
        cout << "test";

    }
}

class Solution {
  public:
    int findTime(string S1, string S2) {
        // code here
        int n=S1.size();
        int m=S2.size();
        unordered_map<char,int>mp;
        for(int i=0;i<n;i++)
        {
            mp[S1[i]]=i;
        }
        int ans=0;
        int temp=0;
        for(int j=0;j<m;j++)
        {
            int b=mp[S2[j]];
            ans+=abs(b-temp);
            temp=b;
        }
        return ans;
    }
};
class Solution {
public:
    string restoreString(string s, vector<int>& indices) {
        int n=s.size();
        vector<char> S(n);
        for(int i=0;i<n;i++)
        {
            S[indices[i]]=s[i];
        }
        string s1="";
        for(int i=0;i<n;i++)
        {
           s1=s1+S[i] ;
        }
        return s1;
    }
};
class Solution {
public:
    vector<int> decode(vector<int>& encoded, int first) {
        vector<int>v;
        int n=encoded.size();
        v.push_back(first);
        for(int i=0;i<n;i++)
        {
            int x=encoded[i]^v[i];
            v.push_back(x);
        }
        return v;
    }
};
class Solution {
public:
    int countWords(string str)
{
    // Breaking input into word
    // using string stream
   
    // Used for breaking words
    stringstream s(str);
   
    // To store individual words
    string word;
 
    int count = 0;
    while (s >> word)
        count++;
    return count;
}
    int mostWordsFound(vector<string>& sen) {
        int n=sen.size();
        int maxi=INT_MIN;
        for(int i=0;i<n;i++)
        {
            maxi=max(maxi,countWords(sen[i]));
        }
       return maxi;
    }
};
#include<bits/stdc++.h>
#include <fstream>
#include <sstream>
#include <sys/stat.h>
#include <sys/time.h>
#include <vector>
#include <cstdio>
#include<time.h>
#include<stdio.h>
#define ll long long int

using namespace std;

struct Node
{
	ll data;
	ll  index;
};

class PriorityQueue
{
public:
	int size;
	Node * pq = new Node [1000000];
	PriorityQueue()
	{
		size = 0;
	}

	bool isEmpty()
	{
		return size == 0;
	}

	int getSize()
	{
		return size;
	}
	Node getMin()
	{
		if (isEmpty())
		{
			return {0, 0};
		}
		return pq[0];
	}
	Node top()
	{
		return pq[0];
	}

	void display()
	{
		for (int i = 0; i < size; ++i)
		{
			cout << pq[i].data << " ";
		}
		cout << endl;
	}


	void insert(Node element)
	{
		pq[size] = element;
		size++;
		int childIndex = size - 1;
		while (childIndex > 0)
		{
			int parentIndex = (childIndex - 1) / 2;
			if (pq[childIndex].data < pq[parentIndex].data)
			{
				swap(pq[childIndex] , pq[parentIndex]);
			}
			else
			{
				break;
			}
			childIndex = parentIndex;
		}
	}

	Node  removeMin()
	{
		if (isEmpty())
			return { -1, -1};
		Node min = pq[0];
		pq[0] = pq[size - 1];
		size = size - 1;

		//down-heapify
		int parentIndex = 0;
		int leftChildIndex = 2 * parentIndex + 1;
		int rightChildIndex = 2 * parentIndex + 2;

		while (leftChildIndex <  size)
		{
			int minIndex = parentIndex;
			if (pq[minIndex].data > pq[leftChildIndex].data)
			{
				minIndex = leftChildIndex;
			}
			if (rightChildIndex < size && pq[rightChildIndex].data < pq[minIndex].data)
			{
				minIndex = rightChildIndex;
			}
			if (minIndex == parentIndex)
			{
				break;
			}
			swap(pq[minIndex], pq[parentIndex]);

			parentIndex = minIndex;
			leftChildIndex = 2 * parentIndex + 1;
			rightChildIndex = 2 * parentIndex + 2;
		}
		return min;
	}
};



void chunk_division(string inputFile, string outputFile, vector<string>&store_temp_file_names)
{
	long long int chunk_size = 255; //1000000;
	ll max_num_of_elements = 0;
	cout << "Number of integers in a temporary file : " << chunk_size << endl;

	ifstream in(inputFile);
	ll inp;
	while (!in.eof())
	{
		in >> inp;
		max_num_of_elements++;
	}
	in.close();

	cout << "maximum number of elements :" << max_num_of_elements << endl;

	ll num_of_chunks = max_num_of_elements / chunk_size;
	ll last_chunk_size =  max_num_of_elements % chunk_size;

	if (last_chunk_size != 0)
		num_of_chunks++;
	else
		last_chunk_size = chunk_size;
	cout << "Number of temporary files created : " << num_of_chunks << endl;

	in.open(inputFile);

	for (ll chunk = 0; chunk < num_of_chunks; ++chunk)
	{
		vector<int>data;
		long long int  value;
		for (ll i = 0; i < chunk_size; ++i)
		{
			if (!in.eof()) //until reaches end of file
			{
				in >> value;
				data.push_back(value); //endl lagana padega to get similar to file
			}
		}
		sort(data.begin(), data.end());

		string fileName = "./q2/a/chunk" + to_string(chunk) + ".txt";
		store_temp_file_names.push_back(fileName);

		ofstream out;
		out.open(fileName);

		for (ll x = 0; x < data.size(); x++)
		{
			out << data[x] << endl;
		}
		out.close();
	}
	in.close();


	ofstream out2;
	out2.open(outputFile);

	ifstream file[store_temp_file_names.size()];
	for (int i = 0; i < store_temp_file_names.size(); ++i)
		file[i].open(store_temp_file_names[i]);


	int flag = 1;
	ll value;
	PriorityQueue p;
	for (ll x = 0; x < max_num_of_elements; ++x)
	{
		if (flag == 1)
		{
			for (ll i = 0; i < store_temp_file_names.size(); ++i)
			{
				file[i] >> value;
				ifstream *file1;
				file1 = new ifstream(store_temp_file_names[i].c_str(), std::ios::in);
				p.insert({value , i});
			}
			flag = 0;
		}
		// cout << "before insert\n";
		// p.display();
		if (!p.isEmpty())
		{
			Node ele = p.removeMin();

			out2 << ele.data << endl;
			// cout << "mindata: " << ele.data << endl;

			ll k;
			if (file[ele.index] >> k)
			{
				p.insert({k, ele.index});
				// cout << "chuck" << ele.index << "->  data :" << k << endl;
			}
		}
		// cout << "after insert\n ";
		// p.display();
		// cout << "\n\n";
	}
	for (int i = 0; i < store_temp_file_names.size(); ++i)
		file[i].close();
	out2.close();
}

void delete_temp_chunks(vector<string>store_temp_file_names)
{
	for (int i = 0; i < store_temp_file_names.size(); ++i)
		remove(store_temp_file_names[i].c_str());
}

int main(int argv , char**argc)
{
#ifdef ONLINE_JUDGE
	freeopen("input.txt", "r", stdin);
	freeopen("output.txt", "r", stdin);
#endif
	ll tick1 = clock();

	// if (argv != 3)
	// {
	// 	cout << "wrong cmd , do again like:\n ./a.out ./data/input.txt ./data/output.txt";
	// }



	// string inputFile = "./q2/input.txt" ;
	// string outputFile = "./q2/output.txt" ;


	string inputFile =   argc[1];
	string outputFile =   argc[2] ;



	vector<string>store_temp_file_names;

	chunk_division(inputFile, outputFile, store_temp_file_names );

	delete_temp_chunks(store_temp_file_names);

	ll tick2 = clock();
	ll elapsed = tick2 - tick1;
	double elapsed_time = (double) elapsed / CLOCKS_PER_SEC;
	cout << elapsed_time   << " sec" << endl;
	return 0;
}
#include <iostream>
#include <cmath>
using namespace std;

double unitprice(int diameter, double price) {
    const double PI = 3.14159;
    double radius, area;
    
    radius = diameter / static_cast <double> (2);
    area = PI * radius * radius;
    return (price/area);
}

double unitprice(int length, int width, double price) {
    double area = length * width;
    return (price/area);
}

int main() {
    
    int diameter, length, width;
    double price_round, unitprice_round,
        price_rectangular, unitprice_rectangular;
    
    cout << "Please enter the diameter of the round cake: ";
    cin >> diameter;
    cout << "Please enter the price of the round piza: $";
    cin >> price_round;
    cout << "Please enter the length and width of the rectangular\n"
        << "cake in inches: ";
    cin >> length >> width;
    cout << "Please enter the price of the rectangular cake: $";
    cin >> price_rectangular;
    
    unitprice_rectangular = unitprice(length, width, price_rectangular);
    unitprice_round = unitprice(diameter, price_round);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    cout << "-------------------------------------\n"
        << "I see... \n";
    
    if (unitprice_round < unitprice_rectangular) {
        cout << "Seems like the round cake is the better option,\n";
        cout << "I suggest you buy it.\n";
    }
    
    else 
    {
        cout << "Seems like the rectangular one is the better option,\n";
        cout << "I suggest you buy it.\n";
    }
    
    return 0;
}
class Solution
{
  public:
    /*You are required to complete this method */
    int atoi(string A)
    {
        //Your code here
    int res=0;
    int cnt=0;
    for(int i=0; i<A.size();i++)
      {
        int c=(A[i]-'0');
        if(c==-3)
        {
            cnt++;
            
        }
        else if(c>=0 && c<=9)
        {
            res=res*10+(A[i]-'0');
        }
        else return -1;
      }
      if(cnt>1)
            {
            return -1;
            }
      if(cnt==1)
            {
            cout<<"-";
            }
    return res;
    }
    
    
};
class Solution {
public:
   int strStr(string s1,string s2)
   {
   int l1=s1.length();
   int l2=s2.length();
   if(s1==s2) return 0;
   if(l1<l2) return -1;
   for(int i=0;i<=l1-l2;i++)
   {
      int j=0;
      while(j<l2)
      {
         if(s1[i]==s2[j])
         {
            i++;
            j++;
         }
         else break;
      }
      if(j==l2) return i-j;
      else i=i-j;
   }
   return -1;
   }
};
#include <bits/stdc++.h>

using namespace std;

int main()
{
   string s="a1b2c3d4e5f6g7h8i9j1k2l3m4";
   string w1="";
   string w2="";
   int n=s.size();
   for(int i=0;i<n;i++)
   {
       if(i%2==0) {w1+=s[i];}
       else w2+=s[i];
   }
   cout<<w1+w2<<"\n";
   cout<<w1.append(w2);
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s="geeksforgeeks";
    unordered_map<char,int>mp;
    for(auto x:s)
    {
        mp[x]++;
    }
    for(auto x:mp)
    {
        cout<<x.first<<", "<<"count"<<"["<<x.second<<"]"<<"\n";
    }
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

class TrieNode
{
public:
	char data;
	TrieNode ** children;
	bool isEndOfString = false;
	TrieNode(char data)
	{
		this->data = data;
		children = new TrieNode*[26];
		for (int i = 0; i < 26; ++i)
		{
			children[i] = NULL;
		}
		isEndOfString = false;
	}
};


class Trie
{
	TrieNode *root;
public:
	Trie()
	{
		root = new TrieNode ('\0');
	}
private:
	void insertWord(TrieNode *root , string word)
	{
		//base case
		if (word.size() == 0)
		{
			root->isEndOfString = true;
			return;
		}

		//small calculation
		int index = word[0] - 'a'; //for 0th letter
		// a-0 b-1 c-2 d-3 e-4 f-5 g-6---y-24 z-25
		//now check at that particular index
		TrieNode * child;
		if (root->children[index] == NULL)
		{
			//make new node and put its address childern ptr
			child = new TrieNode(word[0]);
			root-> children[index] = child;
		}
		else
		{
			child = root->children[index];
			//child will take address  for recursive call
		}
		//recursion from index one
		insertWord(child , word.substr(1));
	}

public:
	void insertWord(string word)
	{
		return insertWord(this->root , word);
	}

private:
	bool search(TrieNode*root , string word)
	{
		if (word.size() == 0)
		{
			return 	root->isEndOfString;
		}
		TrieNode *child;
		int index = word[0] - 'a';
		if ( root->children[index] != NULL)
		{
			child = root->children[index];
		}
		else
			return false;

		return search(child , word.substr(1));

	}

public:
	bool search(string word)
	{
		return search(this->root, word);
	}

	void display(TrieNode* node , string word, vector<string> & v)
	{
		if (node->isEndOfString == true)
		{
			// cout << word << endl;
			v.push_back(word);
		}

		TrieNode * child;
		for (int i = 0; i < 26; ++i)
		{
			if (node->children[i] != NULL )
			{
				child = node->children[i];
				display(child , word + node->children[i]->data, v);
			}
		}
	}

	void display()
	{
		string word = "";
		vector <string> v;
		display(root, word , v);
	}

private:
	TrieNode* autoComplete(TrieNode*node , string word)
	{
		if ( word.length() == 0)
			return node;
		TrieNode *child;
		int index = word[0] - 'a';
		if ( node->children[index] != NULL)
		{
			child = node->children[index];
		}
		else
			return NULL;
		TrieNode * n =  autoComplete(child , word.substr(1));
		return n;
	}

public:
	void autoComplete(string word)
	{
		string a = word;
		TrieNode*node =  autoComplete(root, word);
		// cout << node->data << endl;
		if (node)
		{

			vector<string>v;
			display(node , word, v );
			cout << v.size() << endl;
			for (int i = 0; i < v.size(); ++i)
			{
				cout << v[i] << endl;
			}
		}
		else
		{
			cout << "\n Not a valid word to autoComplete:" << endl;
		}
	}

	int  distance(string str1 , string str2)
	{

		int cost = 0;

		int m = str1.length();
		int n = str2.length();

		int lev[m + 1][n + 1];
		for (int i = 0; i <= m; ++i)
		{
			for (int j = 0; j <= n; ++j)
			{
				lev[i][j] = 0;
			}
		}

		for (int i = 0; i <= m; i++)
			lev[i][0] =  i;

		for (int j = 0; j <= n; j++)
			lev[0][j] = j;

		for (int j = 1; j <= n; ++j)
		{
			for (int i = 1; i <= m; ++i)
			{
				if (str1[i] == str2[j])
					cost = 0 ;
				else
					cost = 1;
				lev[i][j] =  min(lev[i - 1][j - 1] + cost,  min(1 + lev[i - 1][j], 1 + lev[i][j - 1]));

			}
		}

		return lev[m][n];
	}

	void edit_dis_word(TrieNode*node, string word , string lev_word , vector<string>&v)
	{
		if (node->isEndOfString == true)
		{
			int k = distance(word , lev_word);
			if (k <= 3)
				v.push_back(word);
		}

		TrieNode * child;
		for (int i = 0; i < 26; ++i)
		{
			if (node->children[i] != NULL )
			{
				child = node->children[i];
				edit_dis_word(child , word + node->children[i]->data, lev_word, v);
			}
		}
	}


	void autoCorrect(string lev_word)
	{

		vector<string>matching;
		//for storing the lev_distance owrd
		edit_dis_word(root , "" , lev_word, matching);
		cout << matching.size() << endl;

		for (int i = matching.size() - 1; i >= 0 ; i--)
		{
			cout << matching[i] << endl;
		}

	}
};


int main()
{
#ifdef ONLINE_JUDGE
	freeopen("input.txt", "r", stdin);
	freeopen("output.txt", "r", stdin);
#endif
	int num_words;
	int q;
	cin >> num_words >> q;
	Trie t;
	string word;
	while (num_words--)
	{
		cin >> word;
		t.insertWord(word);
	}

	int choice;
	while (q--)
	{
		cin >> choice;
		if (choice == 1) // spell check
		{
			cin >> word;
			cout << (t.search(word) ? "1\n" : "0\n");
		}
		else if (choice == 2) //auto complete
		{
			cin >> word;
			t.autoComplete(word);
		}
		else if (choice == 3)
		{
			cin >> word;
			t.autoCorrect(word);// autoCorrect
		}

	}

	// t.display();



	return 0;
}
#include <iostream>
#include <cmath>
using namespace std;

double unitprice(int diameter, double price) {
    const double PI = 3.14159;
    double radius, area;
    
    radius = diameter / static_cast <double> (2);
    area = PI * radius * radius;
    return (price/area);
}

int main() {
    
    int diameter_small, diameter_large;
    double price_small, unitprice_small,
        price_large, unitprice_large;
    
    cout << "Please enter the diameter of the small pizza: ";
    cin >> diameter_small;
    cout << "Please enter the price of the small piza: $";
    cin >> price_small;
    cout << "Please enter the diameter of the large pizza: ";
    cin >> diameter_large;
    cout << "Please enter the price of the large piza: $";
    cin >> price_large;
    
    unitprice_small = unitprice(diameter_small, price_small);
    unitprice_large = unitprice(diameter_large, price_large);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    cout << "-------------------------------------\n"
        << "I see... \n";
    
    if (unitprice_large < unitprice_small) {
        cout << "Seems like the larger pizza is the better option,\n";
        cout << "I suggest you buy it.\n";
    }
    
    else 
    {
        cout << "Seems like the smaller one is the better option,\n";
        cout << "I suggest you buy it.\n";
    }
    
    return 0;
}
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;

int main() {
    double w, x, y, b, c, d, expo, sr, absolute_double, ceiling, fl;
    int a, z, absolute;
    long abs_long;
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    
    cout << "Enter the values of the following : \n"
        << "-------------------------------\n"
        << "pow(x, y)\n"
        << "x: ";
    cin >> x;
    cout << "y: ";
    cin >> y;
    cout << "sqrt(w)\n"
        << "w: ";
    cin >> w;
    cout << "abs(z)\n"
        << "z: ";
    cin >> z;
    cout << "labs(a)\n"
        << "a: ";
    cin >> a;
    cout << "fabs(b)\n"
        << "b: ";
    cin >> b;
    cout << "ceil(c)\n"
        << "c: ";
    cin >> c;
    cout << "floor(d)\n"
        << "d: ";
    cin >> d;
    
    expo = pow(x, y);
    cout << "___________________________\n"
    << "pow(x, y) = pow(" << x << ", " 
    << y << ") "<< " = " << expo << endl;
    
    sr = sqrt(w);
    cout << "sqrt(w) = sqrt(" << w
    << ") "<< " = " << sr << endl;
    
    absolute = abs(z);
    cout << "abs(z) = abs(" << z
    << ") "<< " = " << absolute << endl;
    
    abs_long = labs(a);
    cout << "labs(a) = labs(" << a
    << ") "<< " = " << abs_long << endl;
    
    absolute_double = fabs(b);
    cout << "fabs(b) = fabs(" << b
    << ") "<< " = " << absolute_double << endl;
    
    ceiling = ceil(c);
    cout << "ceil(c) = ceil(" << c
    << ") "<< " = " << ceiling << endl;
    
    fl = floor(d);
    cout << "floor(d) = floor(" << d
    << ") "<< " = " << fl << endl;
    
    return 0;
}
#include <iostream>
using namespace std;

double var(int x, double y) {
    return ((x + y)/2);
}

int main()
{
    double y, ave;
    int x;
    
    cout << "Average of two arguements\n"
        << "----------------------------\n"
        << "Please enter arguement x: ";
    cin >> x;
    cout << "Please enter arguement y: ";
    cin >> y;
    
    ave = var(x, y);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    cout << "____________________________\n"
        << "The average of these two numbers are "
        << ave << endl;
    
    return 0;
}
#include<iostream>
using namespace std;

class Element
{
public:
	int row;
	int col;
	int data;

};

class List
{
public:
	int row;
	int col;
	int data;
	List*next;
};



class  Sparse
{

public:
	int countElements;
	Element * elementArr = new Element[10000];
	Sparse()
	{
		countElements = 0;
	}


	void insert(int row	, int col, int data)
	{
		Element newElem;
		newElem.row = row;
		newElem.col = col;
		newElem.data = data;
		elementArr[countElements] = newElem;
		elementArr[0].data = countElements;
		countElements++;
	}

	// void add()


};

void display(Sparse* sp)
{
	for (int i = 0; i <= sp->elementArr[0].data  ; ++i)
	{
		cout << sp->elementArr[i].row << " " << sp->elementArr[i].col << "  " << sp->elementArr[i].data;
		cout  << endl;

	}

}

void add ( Sparse *s1 , Sparse *s2 , Sparse *s3)
{
	s3->elementArr[0].row = s1->elementArr[0].row;
	s3->elementArr[0].col = s1->elementArr[0].col;

	int i = 1; //points to sp1
	int j = 1; //points to sp2
	int k = 1; //points to sp3
	while (i <= s1->elementArr[0].data && j <= s2->elementArr[0].data )
	{
		if (s1->elementArr[i].row < s2->elementArr[j].row)
		{
			s3->elementArr[i].row = s1->elementArr[j].row;
			s3->elementArr[i].col = s1->elementArr[j].col;
			s3->elementArr[k++] = s1->elementArr[i++];
			s3->elementArr[0].data ++;
			s3->countElements++;
		}
		else if (s1->elementArr[i].row > s2->elementArr[j].row)
		{
			s3->elementArr[k].row = s2->elementArr[j].row;
			s3->elementArr[k].col = s2->elementArr[j].col;
			s3->elementArr[k++] = s2->elementArr[j++];
			s3->elementArr[0].data ++;
			s3->countElements++;
		}
		else if (s1->elementArr[i].row == s2->elementArr[j].row)
		{
			if (s1->elementArr[i].col < s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s1->elementArr[j].row;
				s3->elementArr[k].col = s1->elementArr[j].col;
				s3->elementArr[k++] = s1->elementArr[i++];
				s3->elementArr[0].data ++;
				s3->countElements++;
			}
			else if (s1->elementArr[i].col > s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s2->elementArr[j].row;
				s3->elementArr[k].col = s2->elementArr[j].col;
				s3->elementArr[k++] = s2->elementArr[j++];
				s3->elementArr[0].data ++;
				s3->countElements++;
			}
			else if (s1->elementArr[i].col == s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s2->elementArr[j].row;
				s3->elementArr[k].col = s2->elementArr[j].col;
				s3->elementArr[k++].data = s2->elementArr[j++].data + s1->elementArr[i++].data;
				s3->elementArr[0].data ++;
				s3->countElements++;
			}

		}
		cout << "hi" << endl;
		display(s3);
		cout << endl;
	}



}
// void display(Sparse* sp)
// {
// 	for (int i = 0; i <= sp->elementArr[0].data  ; ++i)
// 	{
// 		cout << sp->elementArr[i].row << " " << sp->elementArr[i].col << "  " << sp->elementArr[i].data;
// 		cout  << endl;

// 	}

// }

void transpose(Sparse *s1, Sparse*s3)
{
	//no. of elements in each col of s1
	int col_count_s1 = s1->elementArr[0].col + 1;
	int *col_s1 = new int [col_count_s1] {0};
	col_s1[0] = s1->elementArr[0].col;
	for (int i = 1; i <= s1->elementArr[0].data; ++i)
	{
		col_s1[s1->elementArr[i].col]++;
		//it will act as row element for s2
	}

	// for (int i = 0; i < col_count_s1; ++i)
	// {
	// 	cout << col_s1[i] << " ";
	// 	//it will act as row element for s2
	// }
	cout << endl;
	int *row_index = new int [col_count_s1 + 1];
	//one size greater than col_s1;
	row_index[1] = 1;
	for (int i = 2; i <= col_count_s1   ; ++i)
	{
		row_index[i] = row_index[i - 1] + col_s1[i - 1];
	}
	// for (int i = 0 ; i <= col_count_s1; ++i)
	// {
	// 	cout << row_index[i] << " ";
	// 	//it will act as row element for s2
	// }
	cout << endl;
	cout << endl;


	for (int i = 0; i <= s1->elementArr[0].data; ++i)
	{
		if (i == 0)
		{
			s3->elementArr[i].row = s1->elementArr[i].col;
			s3->elementArr[i].col = s1->elementArr[i].row;
			s3->elementArr[i].data = s1->elementArr[i].data;
		}
		else
		{
			int r_index  = s1->elementArr[i].col;
			int index = row_index[r_index];
			s3->elementArr[index].row = s1->elementArr[i].col;
			s3->elementArr[index].col = s1->elementArr[i].row;
			s3->elementArr[index].data = s1->elementArr[i].data;
			row_index[r_index]++;
		}
	}
}

void matrix(Sparse *s)
{
	int k = 1;
	for (int i = 1; i <= s->elementArr[0].row; ++i)
	{
		for (int j = 1; j <= s->elementArr[0].col; j++)
		{
			if (i == s->elementArr[k].row && j == s->elementArr[k].col)
				cout << s->elementArr[k++].data << " ";
			else
				cout << "0 ";
		}
		cout << endl;
	}
}


void multiply ( Sparse *s1 , Sparse *s2 , Sparse *s3)
{
	Sparse *s4 = new Sparse();
	display(s1); cout << endl;
	display(s2); cout << endl;
	s3->insert(s1->elementArr[0].row , s2->elementArr[0].col , 0 );
	for (int i = 1; i <= s1->elementArr[0].data; i++ )
	{

		int sum = 0;

		for (int j = 1; j <= s2->elementArr[0].data; j++)
		{
			int sum = 0;
			if (s1->elementArr[i].col == s2->elementArr[j].row)
			{
				sum = s1->elementArr[i].data * s2->elementArr[j].data;
				s3->insert(s1->elementArr[i].row , s2->elementArr[j].col , sum);
			}
		}
	}


	display(s3);


	cout << endl;
	cout << endl;
	transpose (s3, s4);//saved in new transpose matrix s4
	transpose (s4, s3);//saved in new transpose matrix s3
	//now s3 is in sorted order
	Sparse *s5 = new Sparse();
	for (int i = 0; i <= s3->elementArr[0].data; ++i)
	{
		if (i == 0)
		{
			s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, 0);
		}
		else if (i == 1)
		{
			s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, s3->elementArr[i].data);
		}
		else
		{
			int flag = 0;
			for (int k = 1; k <= s5->elementArr[0].data; k++)
			{
				if (s3->elementArr[i].row == s5->elementArr[k].row && s3->elementArr[i].col == s5->elementArr[k].col)
				{
					s5->elementArr[k].data += s3->elementArr[i].data;
					flag = 1;
					break;
				}
			}
			if (flag == 0)
			{
				s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, s3->elementArr[i].data);

			}
		}

	}





	display(s3);
	cout << endl;
	s3 = s5;
	display(s3);
	cout << endl;
	matrix(s3);
	cout << s3->elementArr[0].row ;

}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int type;
	int op;
	int R1, R2, C1, C2;
	// do {
	cout << "What operation do you want to perform? " <<
	     " Select Option number. Enter 0 to exit." << endl;
	cout << "1. Array" << endl;
	cout << "2. Link list" << endl;
	cout << "Enter datastructure to use :\n";
	cin >> type;
	cout << "Type of operation :\n";
	cout << "1. Addition" << endl;
	cout << "2. Transpose " << endl;
	cout << "3. Multiplication  " << endl;
	cin >> op;
	int data;


	Sparse *sp1 = new Sparse();
	Sparse *sp2 = new Sparse();

	int n = 0;
	if (type == 1 )
	{
		//MATRIX 1
		cin >> R1 >> C1;
		sp1->insert(R1, C1, 0);// FOR Checking #r , #c , #elements
		for (int i = 1; i <= R1; ++i)
		{
			for (int j = 1; j <= C1; ++j)
			{
				cin >> data;
				if (data != 0)
					sp1->insert(i, j, data);
			}
		}
		if (op == 2)//transpose
		{
			Sparse*sp3 = new Sparse();
			transpose(sp1 , sp3);
			display(sp1);
			cout << endl;
			display(sp3);
			cout << endl;
			// sp1 = sp3; //after transpose just change the pointer
			matrix(sp1);
			cout << endl;
			matrix(sp3);
			cout << endl;
		}

		if (op == 1 || op == 3)//addition or mul
		{
			//MATRIX 2
			cin >> R2 >> C2;
			sp2->insert(R2, C2, 0);
			for (int i = 1; i <= R2; ++i)
				for (int j = 1; j <= C2; ++j)
				{
					cin >> data;
					if (data != 0)
						sp2->insert(i, j, data);
				}
			Sparse *sp3 = new Sparse();;
			if (op == 1) //add
			{
				if (R1 != R2 || C1 != C2)
				{
					cout << " wrong matrix sizes: \n";
					return 0;
				}
				add(sp1, sp2, sp3);
				cout << endl;
				display(sp1);
				cout << endl;
				display(sp2);
				cout << endl;
				display(sp3);
				cout << endl;
				cout << sp1->elementArr[0].data << endl;
				cout << sp2->elementArr[0].data << endl ;
				cout << sp3->elementArr[0].data << endl ;
				matrix(sp1);
				cout << endl;
				matrix(sp2);
				cout << endl;
				matrix(sp3);
				cout << endl;
			}
			else if (op == 3) //multiplication
			{
				if (C1 != R2)
				{
					cout << " wrong matrix sizes: \n";
					return 0;
				}
				multiply(sp1, sp2, sp3);
				cout << endl;
				// 	display(sp1);
				// 	cout << endl;
				// 	display(sp2);
				// 	cout << endl;
				// 	display(sp3);
				// 	cout << endl;
				// 	matrix(sp1);
				// 	cout << endl;
				// 	matrix(sp2);
				// 	cout << endl;
				// 	matrix(sp3);
				// 	cout << endl;
			}





			// for (int i = 0; i < 5 ; ++i)
			// {
			// 	cout << sp3->elementArr[i].row << " " << sp3->elementArr[i].col << "  " << sp3->elementArr[i].data;
			// 	cout  << endl;
			// }
			// cout << sp3->elementArr[0].row << " " << sp3->elementArr[0].col << "  " << sp3->elementArr[0].data;


		}
	}





// 	switch (option) {
// 	case 0:
// 		break;
// 	case 1:
// 		cout << "Enter VALUE of TREE sp to INSERT in AVL Tree: ";
// 		cin >> val;

// 		obj_avl.root = obj_avl.insert(val);
// 		cout << endl;
// 		break;

// 	case 2:
// 		cout << "Enter VALUE of TREE sp to delete in AVL Tree: ";
// 		cin >> val;
// 		obj_avl.root = obj_avl.deleteData(val);
// 		break;


// 	case 3:
// 		cout << "Enter VALUE of TREE sp to search in AVL: ";
// 		cin >> val;
// 		cout << obj_avl.search(val);
// 		break;

// 	default:
// 		cout << "Enter Proper Option number " << endl;
// 	}

// } while (option != 0);



	return 0;
}
#include <iostream>
using namespace std;

int add(int x, int y, int z) {
    return (x + y + z);
}

int main()
{
    int x, y, z, sum;
    
    cout << "Sum of three arguements\n"
        << "----------------------------\n"
        << "Please enter three arguements: ";
    cin >> x >> y >> z;
    
    sum = add(x, y,z);
 
    cout << "____________________________\n"
        << x << " + " << y << " + "
        << z << endl
        << "The sum these three arguements are: " << sum;

    return 0;
    
}
#include <iostream>
using namespace std;

double total_cost(int number_par, double price_par) {
}

int main()
{
    double price, bill;
    int number;
    
    cout << "Enter the number of items purchased: ";
    cin >> number;
    cout << "Enter the price per item $";
    cin >> price;
    
    bill = total_cost(number, price);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    cout << number << " items at "
    << "$" << price << " each.\n"
    << "Final bill, including tax, is $" << bill
    << endl;
    
    return 0;
}
#include<iostream>
using namespace std;

class Element
{
public:
	int row;
	int col;
	int data;

};



class  Sparse
{

public:
	int countElements;
	Element * elementArr = new Element[10000];
	Sparse()
	{
		countElements = 0;
	}


	void insert(int row	, int col, int data)
	{
		Element newElem;
		newElem.row = row;
		newElem.col = col;
		newElem.data = data;
		elementArr[countElements] = newElem;
		elementArr[0].data = countElements;
		countElements++;
	}

	// void add()


};

void display(Sparse* sp)
{
	for (int i = 0; i <= sp->elementArr[0].data  ; ++i)
	{
		cout << sp->elementArr[i].row << " " << sp->elementArr[i].col << "  " << sp->elementArr[i].data;
		cout  << endl;

	}

}

void add ( Sparse *s1 , Sparse *s2 , Sparse *s3)
{
	s3->elementArr[0].row = s1->elementArr[0].row;
	s3->elementArr[0].col = s1->elementArr[0].col;

	int i = 1; //points to sp1
	int j = 1; //points to sp2
	int k = 1; //points to sp3
	while (i <= s1->elementArr[0].data && j <= s2->elementArr[0].data )
	{
		if (s1->elementArr[i].row < s2->elementArr[j].row)
		{
			s3->elementArr[i].row = s1->elementArr[j].row;
			s3->elementArr[i].col = s1->elementArr[j].col;
			s3->elementArr[k++] = s1->elementArr[i++];
			s3->elementArr[0].data ++;
			s3->countElements++;
		}
		else if (s1->elementArr[i].row > s2->elementArr[j].row)
		{
			s3->elementArr[k].row = s2->elementArr[j].row;
			s3->elementArr[k].col = s2->elementArr[j].col;
			s3->elementArr[k++] = s2->elementArr[j++];
			s3->elementArr[0].data ++;
			s3->countElements++;
		}
		else if (s1->elementArr[i].row == s2->elementArr[j].row)
		{
			if (s1->elementArr[i].col < s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s1->elementArr[j].row;
				s3->elementArr[k].col = s1->elementArr[j].col;
				s3->elementArr[k++] = s1->elementArr[i++];
				s3->elementArr[0].data ++;
				s3->countElements++;
			}
			else if (s1->elementArr[i].col > s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s2->elementArr[j].row;
				s3->elementArr[k].col = s2->elementArr[j].col;
				s3->elementArr[k++] = s2->elementArr[j++];
				s3->elementArr[0].data ++;
				s3->countElements++;
			}
			else if (s1->elementArr[i].col == s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s2->elementArr[j].row;
				s3->elementArr[k].col = s2->elementArr[j].col;
				s3->elementArr[k++].data = s2->elementArr[j++].data + s1->elementArr[i++].data;
				s3->elementArr[0].data ++;
				s3->countElements++;
			}

		}
		cout << "hi" << endl;
		display(s3);
		cout << endl;
	}



}
// void display(Sparse* sp)
// {
// 	for (int i = 0; i <= sp->elementArr[0].data  ; ++i)
// 	{
// 		cout << sp->elementArr[i].row << " " << sp->elementArr[i].col << "  " << sp->elementArr[i].data;
// 		cout  << endl;

// 	}

// }

void transpose(Sparse *s1, Sparse*s3)
{
	//no. of elements in each col of s1
	int col_count_s1 = s1->elementArr[0].col + 1;
	int *col_s1 = new int [col_count_s1] {0};
	col_s1[0] = s1->elementArr[0].col;
	for (int i = 1; i <= s1->elementArr[0].data; ++i)
	{
		col_s1[s1->elementArr[i].col]++;
		//it will act as row element for s2
	}

	// for (int i = 0; i < col_count_s1; ++i)
	// {
	// 	cout << col_s1[i] << " ";
	// 	//it will act as row element for s2
	// }
	cout << endl;
	int *row_index = new int [col_count_s1 + 1];
	//one size greater than col_s1;
	row_index[1] = 1;
	for (int i = 2; i <= col_count_s1   ; ++i)
	{
		row_index[i] = row_index[i - 1] + col_s1[i - 1];
	}
	// for (int i = 0 ; i <= col_count_s1; ++i)
	// {
	// 	cout << row_index[i] << " ";
	// 	//it will act as row element for s2
	// }
	cout << endl;
	cout << endl;


	for (int i = 0; i <= s1->elementArr[0].data; ++i)
	{
		if (i == 0)
		{
			s3->elementArr[i].row = s1->elementArr[i].col;
			s3->elementArr[i].col = s1->elementArr[i].row;
			s3->elementArr[i].data = s1->elementArr[i].data;
		}
		else
		{
			int r_index  = s1->elementArr[i].col;
			int index = row_index[r_index];
			s3->elementArr[index].row = s1->elementArr[i].col;
			s3->elementArr[index].col = s1->elementArr[i].row;
			s3->elementArr[index].data = s1->elementArr[i].data;
			row_index[r_index]++;
		}
	}
}

void matrix(Sparse *s)
{
	int k = 1;
	for (int i = 1; i <= s->elementArr[0].row; ++i)
	{
		for (int j = 1; j <= s->elementArr[0].col; j++)
		{
			if (i == s->elementArr[k].row && j == s->elementArr[k].col)
				cout << s->elementArr[k++].data << " ";
			else
				cout << "0 ";
		}
		cout << endl;
	}
}


void multiply ( Sparse *s1 , Sparse *s2 , Sparse *s3)
{
	Sparse *s4 = new Sparse();
	display(s1); cout << endl;
	display(s2); cout << endl;
	s3->insert(s1->elementArr[0].row , s2->elementArr[0].col , 0 );
	for (int i = 1; i <= s1->elementArr[0].data; i++ )
	{

		int sum = 0;

		for (int j = 1; j <= s2->elementArr[0].data; j++)
		{
			int sum = 0;
			if (s1->elementArr[i].col == s2->elementArr[j].row)
			{
				sum = s1->elementArr[i].data * s2->elementArr[j].data;
				s3->insert(s1->elementArr[i].row , s2->elementArr[j].col , sum);
			}
		}
	}


	display(s3);


	cout << endl;
	cout << endl;
	transpose (s3, s4);//saved in new transpose matrix s4
	transpose (s4, s3);//saved in new transpose matrix s3
	//now s3 is in sorted order
	Sparse *s5 = new Sparse();
	for (int i = 0; i <= s3->elementArr[0].data; ++i)
	{
		if (i == 0)
		{
			s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, 0);
		}
		else if (i == 1)
		{
			s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, s3->elementArr[i].data);
		}
		else
		{
			int flag = 0;
			for (int k = 1; k <= s5->elementArr[0].data; k++)
			{
				if (s3->elementArr[i].row == s5->elementArr[k].row && s3->elementArr[i].col == s5->elementArr[k].col)
				{
					s5->elementArr[k].data += s3->elementArr[i].data;
					flag = 1;
					break;
				}
			}
			if (flag == 0)
			{
				s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, s3->elementArr[i].data);

			}
		}

	}





	display(s3);
	cout << endl;
	s3 = s5;
	display(s3);
	cout << endl;
	matrix(s3);
	cout << s3->elementArr[0].row ;

}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int type;
	int op;
	int R1, R2, C1, C2;
	// do {
	cout << "What operation do you want to perform? " <<
	     " Select Option number. Enter 0 to exit." << endl;
	cout << "1. Array" << endl;
	cout << "2. Link list" << endl;
	cout << "Enter datastructure to use :\n";
	cin >> type;
	cout << "Type of operation :\n";
	cout << "1. Addition" << endl;
	cout << "2. Transpose " << endl;
	cout << "3. Multiplication  " << endl;
	cin >> op;
	int data;


	Sparse *sp1 = new Sparse();
	Sparse *sp2 = new Sparse();

	int n = 0;
	if (type == 1 )
	{
		//MATRIX 1
		cin >> R1 >> C1;
		sp1->insert(R1, C1, 0);// FOR Checking #r , #c , #elements
		for (int i = 1; i <= R1; ++i)
		{
			for (int j = 1; j <= C1; ++j)
			{
				cin >> data;
				if (data != 0)
					sp1->insert(i, j, data);
			}
		}
		if (op == 2)//transpose
		{
			Sparse*sp3 = new Sparse();
			transpose(sp1 , sp3);
			display(sp1);
			cout << endl;
			display(sp3);
			cout << endl;
			// sp1 = sp3; //after transpose just change the pointer
			matrix(sp1);
			cout << endl;
			matrix(sp3);
			cout << endl;
		}

		if (op == 1 || op == 3)//addition or mul
		{
			//MATRIX 2
			cin >> R2 >> C2;
			sp2->insert(R2, C2, 0);
			for (int i = 1; i <= R2; ++i)
				for (int j = 1; j <= C2; ++j)
				{
					cin >> data;
					if (data != 0)
						sp2->insert(i, j, data);
				}
			Sparse *sp3 = new Sparse();;
			if (op == 1) //add
			{
				if (R1 != R2 || C1 != C2)
				{
					cout << " wrong matrix sizes: \n";
					return 0;
				}
				add(sp1, sp2, sp3);
				cout << endl;
				display(sp1);
				cout << endl;
				display(sp2);
				cout << endl;
				display(sp3);
				cout << endl;
				cout << sp1->elementArr[0].data << endl;
				cout << sp2->elementArr[0].data << endl ;
				cout << sp3->elementArr[0].data << endl ;
				matrix(sp1);
				cout << endl;
				matrix(sp2);
				cout << endl;
				matrix(sp3);
				cout << endl;
			}
			else if (op == 3) //multiplication
			{
				if (C1 != R2)
				{
					cout << " wrong matrix sizes: \n";
					return 0;
				}
				multiply(sp1, sp2, sp3);
				cout << endl;
				// 	display(sp1);
				// 	cout << endl;
				// 	display(sp2);
				// 	cout << endl;
				// 	display(sp3);
				// 	cout << endl;
				// 	matrix(sp1);
				// 	cout << endl;
				// 	matrix(sp2);
				// 	cout << endl;
				// 	matrix(sp3);
				// 	cout << endl;
			}





			// for (int i = 0; i < 5 ; ++i)
			// {
			// 	cout << sp3->elementArr[i].row << " " << sp3->elementArr[i].col << "  " << sp3->elementArr[i].data;
			// 	cout  << endl;
			// }
			// cout << sp3->elementArr[0].row << " " << sp3->elementArr[0].col << "  " << sp3->elementArr[0].data;


		}
	}





// 	switch (option) {
// 	case 0:
// 		break;
// 	case 1:
// 		cout << "Enter VALUE of TREE sp to INSERT in AVL Tree: ";
// 		cin >> val;

// 		obj_avl.root = obj_avl.insert(val);
// 		cout << endl;
// 		break;

// 	case 2:
// 		cout << "Enter VALUE of TREE sp to delete in AVL Tree: ";
// 		cin >> val;
// 		obj_avl.root = obj_avl.deleteData(val);
// 		break;


// 	case 3:
// 		cout << "Enter VALUE of TREE sp to search in AVL: ";
// 		cin >> val;
// 		cout << obj_avl.search(val);
// 		break;

// 	default:
// 		cout << "Enter Proper Option number " << endl;
// 	}

// } while (option != 0);



	return 0;
}
#include <iostream>
#include <cmath>
using namespace std;

int main() {
    double a, b, c, ex, bac, sum1, sr, sum2, prod, quo;
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    
    cout << "Using the Quadratic Formula.\n"
    << "Please enter the value of a: ";
    cin >> a;
    cout << "Please enter the value of b: ";
    cin >> b;
    cout << "Please enter the value of c: ";
    cin >> c;
    
    ex = pow(b,2);
    bac = -4 * a * c;
    sum1 = ex + bac;
    sr = sqrt(sum1);
   
    if (sr > 0) { 
        sum2 = -b + sr;
        prod = 2 * a;
        quo = sum2 / prod;
        cout << "x = " << quo << endl;
    }
    
    else {
    cout << " - Undefined -" << endl 
        << "The square root of a negative number does not exist" << endl 
        << "in the set of real numbers." << endl;
    }
    
    return 0;
}
#include <iostream>
#include <cmath>
using namespace std;

int main() {
    double a, b, c, ex, bac, sum1, sr, sum2, prod, quo;
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    
    cout << "Using the Quadratic Formula.\n"
    << "-----------------------------------\n" 
    << "Please enter the value of a: ";
    cin >> a;
    cout << "Please enter the value of b: ";
    cin >> b;
    cout << "Please enter the value of c: ";
    cin >> c;
    
    ex = pow(b,2);
    cout << "-----------------------------------\n" 
    << "Evaluate the power of b,\n"
    << b << " ^ 2 = " << ex << endl;
    
    bac = -4 * a * c;
    cout << "Calculate the product of -4(a)(c), \n"
    << "-4(a)(c) = -4(" << a << ")("
    << c << ") = " << bac << endl;
    
    sum1 = ex + bac;
    cout << "Add the product of b and -4(a)(c), \n"
    << ex << " + " << bac << " = " << sum1 << endl;
    
    sr = sqrt(sum1);
    cout << "Evaluate the square root of " << sum1 << "," <<endl
    << "√" << sum1 << " = " << sr << endl;
   
    if (sr > 0) { 
        sum2 = -b + sr;
        cout << "Calculate the sum of -" << b << " and " << sr << "," << endl
        << "-" << b << " + " << sr << " = " << sum2 << endl;
    
        prod = 2 * a;
        cout << "Multiply for the product of 2 and (a), \n"
        << "2(" << a << ") = " << prod << endl;
    
        quo = sum2 / prod;
        cout << "Calculate the quotient of " << sum2 << " and "<< prod << "," << endl
        << sum2 << " / " << prod << " = " << quo << endl
        << "-----------------------------------\n"
        << "x = " << quo << endl 
        << "-----------------------------------\n";
    }
    
    else {
        cout << "-----------------------------------\n" 
        << " - Undefined -" << endl 
        << "The square root of a negative number does not exist" << endl 
        << "in the set of real numbers." << endl 
        << "-----------------------------------\n";
    }
    
    return 0;
}
#include<iostream>
using namespace std;
void getMinMax(int arr[], int arrSize, int *minVal, int *maxVal)
{
  for (int i = 1; i < arrSize; i++)
  {
    if (arr[i] > *maxVal)
    {
      *maxVal = arr[i];
    }
    if (arr[i] < *minVal)
    {
      *minVal = arr[i];
    }

  }
}
int main()
{
  int arr[5] = { 1, 2, -9, 45, 0};
  int max = arr[0];
  int min = arr[0];
  getMinMax(arr, 5, &min, &max);
  cout << min << " " << max << endl;
  return 0;
}
#include<iostream>
using namespace std;
int main(){
  int arr[5] = { 1,2,3,4,5 };
  cout << arr << endl;
  return 0;
}
#include<iostream>
using namespace std;
void printData(void *ptr, char dataType){
  switch (dataType)
  {
    case 'i':
      cout << *((int *)ptr) << endl;
      break;

    case 'c':
      cout << *(static_cast<char *>(ptr)) << endl;
      break;
  }
}
int main(){
  int n = 7;
  char b = 'b';
  printData(&n, 'i');
  printData(&b, 'c');
  return 0;
}
#include<iostream>
using namespace std;
int main(){
  int *ptr;
  *ptr = 6;
  cout << *ptr << endl;
  return 0;
}
#include<iostream>
using namespace std;
int main(){
  int n = 6;
  float *ptr = &n;
  *ptr = 10;
  cout << *ptr << " " << n << endl;
  return 0;
}
#include<iostream>
using namespace std;
int main(){
  int n = 6;
  int *ptr = &n;
  *ptr = 10;
  cout << *ptr << " " << n << endl;
  return 0;
}
#include<bits/stdc++.h>
using namespace std;

class BinaryTreeNode
{
public:
	int data;
	BinaryTreeNode * left;
	BinaryTreeNode *right;
	int height;

	// BinaryTreeNode()
	// {
	// 	data = 0;
	// 	left = NULL;
	// 	right = NULL;
	// }
	BinaryTreeNode(int data)
	{
		this->data = data;
		left = NULL;
		right = NULL;
	}
	~BinaryTreeNode()
	{
		delete left;
		delete right;
	}

};


class AVL
{
public:
	BinaryTreeNode *root;
	AVL()
	{
		this->root = NULL;
	}


	int getheight(BinaryTreeNode* root)
	{
		if (root == NULL)
			return 0;

		return 1 + max(getheight(root->left) , getheight(root->right));
	}

	int getbalanceFactor(BinaryTreeNode* node)
	{
		if ( node == NULL)
			return 0;
		return getheight(node->left) - getheight(node->right);
	}

	BinaryTreeNode* rightRotate(BinaryTreeNode* y)
	{


		/*

			 	y           x
			   / \		   / \
			  x   T3 ---->T1  y
			 / \			 / \
			T1  T2			T2  T3
			*/
		BinaryTreeNode* x = y->left;
		BinaryTreeNode *T2 = x->right;
		// T1 & T3 not required because their ptr not changes
		x->right = y;
		y->left = T2;
		//updation to heights
		// y->height = 1 + max(getHeight(y->left) , getHeight(y->right));
		// X->height = 1 + max(getHeight(x > left) , getHeight(x->right));
		return x;
		//as now x is root node
	}
	BinaryTreeNode* leftRotate(BinaryTreeNode* x)
	{
		/*  	y           x
			   / \		   / \
			  x   T3 <--- T1  y
			 / \			 / \
			T1  T2			T2  T3
			*/
		//before rotation
		BinaryTreeNode* y = x->right;
		BinaryTreeNode *T2 = y->left;
		// T1 & T3 not required because their ptr not changes
		//changes to rotation
		y->left = x;
		x->right = T2;
		//updation to heights
		// y->height = 1 + max(getHeight(y->left) , getHeight(y->right));
		// X->height = 1 + max(getHeight(x > left) , getHeight(x->right));
		return y;
		//as now y is root node
	}


// 1. insert
private:
	BinaryTreeNode * insert(BinaryTreeNode* node, int data)
	{
		if ( node == NULL)
		{
			BinaryTreeNode* newnode = new BinaryTreeNode (data);
			return newnode;
		}

		if (data <= node->data)
			node->left = this->insert( node->left , data);
		else if (data > node->data)
			node->right = this->insert(node->right , data);
		else
			return node;

		// node->height = 1 + max(getHeight(node > left) , getHeight(node->right));
		// //height update krni padegi as it is req in balfac

		int balfac =  getbalanceFactor(node) ;
		// left left case ..bf= leftH -rightH >1
		if (balfac > 1 && data < node->left->data)
		{	//insertion takes place at LST
			return this->rightRotate(node);
		}

		//right right case , bf= leftH -rightH < -1
		if (balfac < -1 && node->right->data < data)
		{
			return this->leftRotate(node);
		}

		//left rightcase,bf= leftH -rightH >1
		if (balfac > 1 && node->left->data < data)//bf>1 tabhi root k left me imbal
		{
			/*
				 r= 30          30     25
				   /   			/	  /	  \
				 20	   	   	  25     20	  30
				  \			 /
			  data=25		20
			*/

			node->left = leftRotate(node->left); //
			return this->rightRotate(node);
		}


		//right left case bf= leftH -rightH <-1
		if (balfac > 1 && node->left->data < data)//bf>1 tabhi root k left me imbal
		{
			/*
				 r= 20           20         25
				      \   		   \       /  \
				 	  30	   	    25    20   30
					 /	             \
			  data=25		          30
			*/

			node->right = rightRotate(node->right); //
			//now RR imbalance
			return this->leftRotate(node);
		}
		return node;
	}




public:
	BinaryTreeNode* insert ( int data)
	{
		// BinaryTreeNode *node = new BinaryTreeNode(data);
		this->root = insert(this->root , data);
		return  root;
	}



	//2. delete : trick think node as leaf or any internal node
private:
	BinaryTreeNode * deleteData(BinaryTreeNode* node , int data)
	{
		if (node == NULL)
			return NULL;
		if (data < node->data)
		{
			node ->left = deleteData(node->left , data);
			return node;
		}
		else if (node->data < data)
		{
			node->right = deleteData(node -> right , data);
			return node;
		}
		else // if value matche
		{
			if (node->left == NULL && node->right == NULL) //a leaf
			{
				delete node;
				return NULL;
			}
			else if (node->left == NULL)
			{
				BinaryTreeNode *rightsubtree = node->right;
				node ->right = NULL;
				delete node;
				return rightsubtree;
			}
			else if (node->right == NULL)
			{
				BinaryTreeNode *leftsubtree = node->left;
				node->left = NULL;
				delete node;
				return leftsubtree;
			}
			else // both rst and lst exists
			{
				BinaryTreeNode * minNode = node ->right;
				while (minNode->left != NULL)
				{
					minNode = minNode->left;
				}
				int minFromRST = minNode->data;
				node->data = minFromRST;
				node->right = deleteData(node->right, minFromRST);
				return node;
			}
		}


		int balfac = getbalanceFactor(node);

		if (balfac == 2 && getbalanceFactor(node->left ) >= 0)
		{
			/*
				 r= 30         			 30                 30      20
				   / \  				/ \	                /	   /  \
				 20	  40**del 	or    20   40 **del =     20	  10   30
				 /\					 /					 /
			   10  25				10					10
			*/
			// 25 case will be taken care by rightrotate

			BinaryTreeNode*newnode = rightRotate(node);
			return newnode;
		}
		else if (balfac == 2 && getbalanceFactor(node->left) == -1)
		{
			/*
				 r= 30         			 30                        25
				   / \  				/ 	                 	  /  \
			(-1) 20	  40**del or (-1) 20  	lr imbalance	=    20	  30
				  \					 	\
			      25					 25
			*/
			// 25 case will be taken care by rightrotate

			node->left = leftRotate(node->left);
			BinaryTreeNode*newnode = rightRotate(node);
			return newnode;
		}
		else if (balfac == -2 && getbalanceFactor(node->right) <= 0)
		{
			/*
			 20			20		   	 30
			/ \			/ \		     / \
			del 10  30  del(10) 30        20  40
			   /\			 \
			  25 40 		 40

			  // 25 case will be taken care by leftrotate
			*/
			BinaryTreeNode * newnode = leftRotate(node);
			return newnode;
		}
		else if (balfac == -2 && getbalanceFactor(node->right) == 1)
		{
			/*
			 20			 	 20                25
			/ \			 	   \			   / \
			del 10  30 (1)          30	rl imbal  20  30
			   / 			 	/
			  25 		  	  25
			  	*/
			node->right  =  leftRotate(node->right);
			BinaryTreeNode * newnode = leftRotate(node);
			return newnode;
		}
	}
public:
	BinaryTreeNode* deleteData( int data)
	{
		this->root = deleteData(this->root , data);
		return root;
	}


	//3.search
private:
	bool search(BinaryTreeNode* node , int data)
	{
		if (node == NULL)
			return false;
		if (node->data == data)
			return true;
		else if (node->data < data)
			return search (node->right , data);
		else
			return search(node->left , data);
	}
public:
	bool search(int data)
	{
		return search(root, data);
	}



	//4. occurences
private :
	int count_occurence(BinaryTreeNode*node , int data)
	{
		if (node == NULL)
			return 0;

		if (node ->data == data)
			return 1 + count_occurence(node->left, data) + count_occurence(node->right, data);
		else if (node->data < data)
			return count_occurence(node->right, data);
		else if (data < node->data )
			return count_occurence(node->left, data);
		return 0;
	}

public:
	int count_occurence(int data)
	{
		return count_occurence(this->root , data);
	}

private:
	int upper_bound(BinaryTreeNode*node, int data)
	{
		if (node == NULL)
			return 0;

		//leaf data=15  leaf=14(node->data)(rightmost)
		if (node->left == NULL && node->right == NULL && node->data <= data)
		{
			return 0;
		}

		//data=12 ex=  null (12) 13(root)  or   11 (12) 13(root) or 12 (12) 13(root)
		if ((data < node->data && node->left == NULL) || (node->left->data <= data && data < node->data))
		{
			return node->data;
		}
		//data=12  11(root) (12)  or   12(root) (12)
		if (node->data <= data)
		{	//node->left->data se compare wali cond already checked above
			return upper_bound(node->right, data);
		}
		else if (data < node->data)
		{
			//data=12  14(root->left)  15(root)
			return upper_bound(node->left , data);
		}
		return 0;
	}
public:
	int upper_bound(int data)
	{
		return upper_bound(this->root , data);
	}


private:
	int lower_bound(BinaryTreeNode*node, int data)
	{
		if (node == NULL)
			return 0;

		//reachd to leaf data =14 leaf=15(node->data) leftmost node
		if (node->left == NULL && node->right == NULL &&  data < node->data )
		{
			return 0;
		}
		//itsef a leaf
		if (node->left == NULL  && node->right == NULL &&  data == node->data)
			return node->data;

		//data=12  11(root) null or   11(root) 13  or  12(root)   13
		if ((node->data < data   && node->right == NULL) || (node->data < data && data < node->right->data))
		{
			return node->data;
		}
		//data=12  12 13(root)  or   (12)   12(root)
		if ( data <= node->data)
		{
			return lower_bound(node->left, data);
		}
		else if ( node->data < data)
		{	//node->right->data se compare wali cond already checked above
			//data=12  10(root)  11(root->right) 12
			return lower_bound(node->right, data);
		}
		return 0;
	}
public:
	int lower_bound(int data)
	{
		return lower_bound(this->root , data);
	}

public:
	int lesser_bound(BinaryTreeNode*node , int data)
	{
		if (node == NULL)
			return 0;

		//reachd to leaf data =14 leaf=15(node->data) leftmost node
		if (node->left == NULL && node->right == NULL &&  data < node->data )
		{
			return 0;
		}
		//itsef a leaf
		if (node->left == NULL  && node->right == NULL &&  data == node->data)
			return 0;

		//data=12  11(root) null or   11(root) 13  or  12(root)   13
		if ((node->data < data   && node->right == NULL) || (node->data < data && data < node->right->data))
		{
			return node->data;
		}
		//data=12  12 13(root)  or   (12)   12(root)
		if ( data <= node->data)
		{
			return lesser_bound(node->left, data);
		}
		else if ( node->data < data)
		{	//node->right->data se compare wali cond already checked above
			//data=12  10(root)  11(root->right) 12
			return lesser_bound(node->right, data);
		}
		return 0;
	}



private:
	int closest_element(BinaryTreeNode*node , int data)
	{
		if (node == NULL)
			return -1;
		if (node->data == data)
			return node->data;
		int x = upper_bound(node, data);
		int y = lesser_bound(node, data);
		//y----------data ---------x
		if (y != 0 && x != 0)
			return (data - y) > (x - data) ? x : y;
		else if (y == 0 && x != 0)
			return x;
		else
			return y;

	}
public:
	int closest_element(int data)
	{
		return closest_element(this->root , data);
	}


private:
	BinaryTreeNode* Element_Kth_largest(BinaryTreeNode*node , int &k)
	{
		// if (node == NULL || c > k )
		// 	return -1;
		// //reverse inorder traversal
		// Element_Kth_largest(node->right, k, c );
		// c++;
		// if (k == c)
		// 	return node->data;
		// Element_Kth_largest(node->left, k , c);
		// return -1;
		if (node == NULL)
			return NULL;

		BinaryTreeNode* newnode = Element_Kth_largest(node->right, k);
		if (newnode  != NULL)
			return newnode;
		k--;

		if (k == 0)
			return node;

		return Element_Kth_largest(node->left, k);
	}
public:
	int Element_Kth_largest(int k)
	{

		BinaryTreeNode*newnode = Element_Kth_largest(this->root, k );
		int c = -1;
		if (newnode == NULL)
			return c;
		else
			c = newnode->data;
		return c;
	}

private:
	int count_range(BinaryTreeNode*node, int eLeft, int eRight)
	{
		if (node == NULL)
			return 0;
		// if (node->data == eLeft && node->data == eRight)
		// 	return 1;

		int count = 0;
		// Special Optional case for improving efficiency
		// if (eLeft <= node->data  && node->data <= eRight)
		// 	return 1 + count_range(node->left , eLeft, eRight) + count_range(root->right , eLeft, eRight);

		if (eLeft <= node->data  && node->data <= eRight)
			count += 1;
		count += count_range(node->left , eLeft, eRight);

		return count + count_range(node->right , eLeft, eRight);
		// else if (node->data < eLeft )
		// 	return count_range(node->right, eLeft, eRight)	;
		// else
		// 	return count_range(root->left , eLeft, eRight);
	}
public:
	int count_range(int eLeft , int eRight)
	{
		return count_range(this->root, eLeft, eRight);
	}


};



void preorder(BinaryTreeNode * root)
{
	if (root == NULL)
		return;
	cout << root->data << " ";
	preorder(root->left);
	preorder(root->right);
}
void inorder(BinaryTreeNode * root)
{
	if (root == NULL)
		return;
	inorder(root->left);
	cout << root->data << " ";
	inorder(root->right);
}



int main()
{
#ifdef ONLINE_JUDGE
	freeopen("input.txt", "r", stdin);
	freeopen("output.txt", "r", stdin);
#endif


	AVL obj_avl;


	//segmentationfault state
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(31);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(60);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(40);


	// int option;
	// do {
	// 	cout << "What operation do you want to perform? " <<
	// 	     " Select Option number. Enter 0 to exit." << endl;
	// 	cout << "1. Insert Node" << endl;
	// 	cout << "2. Delete Node" << endl;
	// 	cout << "3. Search Node" << endl;
	// 	cout << "4.  " << endl;
	// 	cout << "5.  " << endl;
	// 	cout << "6.  " << endl;
	// 	cout << "0. Exit Program" << endl;
	// 	cin >> option;
	// 	//Node n1;
	// 	int val;

	// 	switch (option) {
	// 	case 0:
	// 		break;
	// 	case 1:
	// 		cout << "Enter VALUE of TREE NODE to INSERT in AVL Tree: ";
	// 		cin >> val;

	// 		obj_avl.root = obj_avl.insert(val);
	// 		cout << endl;
	// 		break;

	// 	case 2:
	// 		cout << "Enter VALUE of TREE NODE to delete in AVL Tree: ";
	// 		cin >> val;
	// 		obj_avl.root = obj_avl.deleteData(val);
	// 		break;


	// 	case 3:
	// 		cout << "Enter VALUE of TREE NODE to search in AVL: ";
	// 		cin >> val;
	// 		cout << obj_avl.search(val);
	// 		break;

	// 	default:
	// 		cout << "Enter Proper Option number " << endl;
	// 	}

	// } while (option != 0);




	int n = 5;
	int ins[11] = {1, 12, 23, 34, 45, 63, 67, 30, 89, 39, 4};
	for (int i = 0; i < n; ++i)
	{
		obj_avl.root = obj_avl.insert(ins[i]);
	}


	cout << endl;
	cout << "\npreorder :";
	preorder(obj_avl.root);
	cout << "\ninorder  :";
	inorder(obj_avl.root);
	cout << endl;

	int arr[10] = { -1, 9, 20, 23 , 44 , 5, 6 , 40, 50, 67 };
	int k = 7;
	int lar[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
	// for (int i = 0; i < k; ++i)
	// {
	// 	int u;
	// 	int e = lar[i];
	// 	cout << "\nkth largest element : " << e  ;
	// 	u = obj_avl.Element_Kth_largest(e);
	// 	cout << " is:" << u;
	// }
	cout << endl;

	for (int i = 2; i < 8; ++i)
	{
		int l = arr[i];
		int h = arr[i + 1];
		if (l > h)
			swap(l, h);
		cout << "Count of nodes between [" << l << ", " << h << "] is " << obj_avl.count_range(l, h) << endl;
	}

	// for (int i = 0; i < k; ++i)
	// {
	// 	int u;
	// 	int e = arr[i];
	// 	cout << "\nclosest element to : " << e  ;
	// 	u = obj_avl.closest_element(e);
	// 	cout << " is:" << u;
	// }
	// cout << endl;

	// for (int i = 0; i < k; ++i)
	// {
	// 	int u;
	// 	int e = arr[i];
	// 	cout << "\nlower bound of : " << e  ;
	// 	u = obj_avl.lower_bound(e);
	// 	cout << " is:" << u;
	// }
	// cout << endl;
	// for (int i = 0; i < k; ++i)
	// {
	// 	int u;
	// 	int e = arr[i];
	// 	cout << "\nupper bound of :" << e  ;
	// 	u = obj_avl.upper_bound(e);
	// 	cout << ":" << u;
	// }


	// int count_o[10] = {30, 55, 38, 40, 60, 89, 31, 35, 47, 69};
	// for (int i = 0; i < 10; ++i)
	// {
	// 	int s = count_o[i];
	// 	int r  ;

	// 	cout << "\n\ncount:" << s;
	// 	r = obj_avl.count_occurence(s);
	// 	cout << "\nnumber of  " << s << " are :" << r  ;
	// }



	// int find[10] = {30, 55, 38, 40, 60, 89, 31, 35, 47, 69};
	// for (int i = 0; i < 10; ++i)
	// {
	// 	int s = find[i];
	// 	int r = 0;
	// 	cout << "\n\nsearch:" << s;
	// 	r = obj_avl.search(s);
	// 	if (r)
	// 		cout << "\nyes " << s << " is found";
	// 	else
	// 		cout << "\nno. :" << s << " is not found";
	// }


	// cout << endl;
	// cout << "\npreorder :";
	// preorder(obj_avl.root);
	// cout << "\ninorder  :";
	// inorder(obj_avl.root);

	// int del[10] = {50, 38, 60, 56, 3, 30, 60};
	// for (int i = 0; i < 10; ++i)
	// {
	// 	int v = find[i];
	// 	int r = 0;
	// 	cout << "\n\ndelete :" << v << endl;
	// 	r = obj_avl.search(v);
	// 	if (!r)
	// 	{

	// 		cout << "no.    :" << v << " is not found";
	// 	}
	// 	else
	// 	{
	// 		obj_avl.root = obj_avl.deleteData(v);
	// 		cout << "sucessfully deleted :" << v << endl;
	// 		cout << "preorder :";
	// 		preorder(obj_avl.root);
	// 		cout << "\ninorder  :";
	// 		inorder(obj_avl.root);
	// 	}

	// }





	return 0;
}
#include <iostream>
using namespace std;
int main()
{
  int array[] = {10, 20, 30};
  cout << -2[array];
  return 0;
}
#include<iostream>
using namespace std;
int main()
{
  int a = 5, b = 10, c = 15;
  int arr[3] = {&a, &b, &c};
  cout << *arr[*arr[1] - 8];
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  char *ptr;
  char Str[] = "abcdefg";
  ptr = Str;
  ptr += 4;
  cout << ptr;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  char arr[20];
  int i;
  for(i = 0; i < 10; i++)
    *(arr + i) = 65 + i;
  cout << arr;
  return(0);
}
#include <iostream>
using namespace std;
int main()
{
  int a = 5, b = 10, c = 15;
  int *arr[ ] = {&a, &b, &c};
  cout << arr[1];
  return 0;
}
string* x, y;
int (*fp)(char*)
#include <iostream>
using namespace std;
enum channel {star, sony, zee};
enum symbol {hash, star};
int main()
{
  int i = 0;
  for (i = star; i <= zee; i++) 
  {
    printf("%d ", i);
  }
  return 0;
}
#include <iostream>
using namespace std;
enum colour 
{
  green, red, blue, white, yellow, pink
};
int main()
{
  cout << green << " " <<
  red << " " << blue << " " << 
  white << " " << yellow << " " << pink;
  return 0;
}
#include <iostream>
using namespace std;
enum test 
{
  A = 12, B, C
};
int main()
{
  cout << A << " " << B << " " << C;
  return 0;
}
#include <iostream>
using namespace std;
enum  cat 
{
  temp = 6
};
int main()
{
  int age = 12;
  age /= temp;
  cout << "If you were cat, you would be " << age << endl;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  void a = 10, b = 10;
  int c;
  c = a + b;
  cout << c;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  void a;
  a = 5;
  cout << a << endl;
  return 0;
}
// program 1
#include <iostream>
using namespace std;
int main()
{
  register int i = 1;
  int ptr = i;
  cout << ptr;
  return 0;
}

// program 2
#include <iostream>
using namespace std;
int main()
{
  register int i = 1;
  int *ptr = &i;
  cout << *ptr;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  int i = 6;
  int l = i / -5;
  int k = i % -5;
  cout << l << " " << k;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  int a = 8;
  cout << "AND integer 'a' with 'true' :" << (a && true);
  cout << endl;
  cout << "AND integer 'a' with 'true' :" << a && true;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  unsigned int x = 1;
  int y = -2;

  if(x > y) 
  {
    cout << "x is greater";
  }
  else 
  {
    cout << "y is greater";
  }      
}
#include <iostream>
using namespace std;
int main()
{
  int p;
  bool a = true;
  bool b = false;
  int x = 10;
  int y = 5;
  p = ((x | y) + (a + b));
  cout << p << endl;
  return 0;
}
#include <iostream>
using namespace std;
int f(int p, int q)
{
  if (p > q)
    return p;
  else
    return q;
}
main()
{
  int a = 5, b = 10;
  int k;
  bool x = true;
  bool y = f(a, b);
  k =((a * b) + (x + y));
  cout << k;
}
#include <iostream>
using namespace std;
class Point
{
    int x, y;
  public:
   Point(int i = 0, int j =0)
   { x = i; y = j;  }
   int getX() const { return x; }
   int getY() {return y;}
};
 
int main()
{
    const Point t;
    cout << t.getX() << " ";
    cout << t.getY();
    return 0;
}
#include <iostream>
class Test
{
   public:
     void fun();
};
static void Test::fun()   
{
    std::cout<<"fun() is static";
}
int main()
{
    Test::fun();   
    return 0;
}
#include<iostream>
using namespace std;
class Test
{
   private:
     static int count;
   public:
     Test& fun(); 
};
int Test::count = 0;
Test& Test::fun()
{
    Test::count++;
    cout << Test::count << " ";
    return *this;
}
int main()
{
    Test t;
    t.fun().fun().fun().fun();
    return 0;
}
#include <iostream>
using namespace std;
​
int main() {
  int myAge = 35;
  cout << "I am " << myAge << " years old.";
  return 0;
}
​
#include <iostream>
using namespace std;
class A
{
   private:
     int x;
   public:
     A(int _x)  {  x = _x; }
     int get()  { return x; }
};
class B
{
    static A a;
  public:
   static int get()
   {  return a.get(); }
}; 
int main(void)
{
    B b;
    cout << b.get();
    return 0;
}
#include <iostream>
using namespace std;
class Player
{
  private:
    int id;
    static int next_id;
  public:
    int getID() { return id; }
    Player()  {  id = next_id++; }
};
int Player::next_id = 1;
int main()
{
  Player p1;
  Player p2;
  Player p3;
  cout << p1.getID() << " ";
  cout << p2.getID() << " ";
  cout << p3.getID();
  return 0;
}
#include <iostream>
using namespace std;
class Test
{
    static int x;
  public:
    Test() { x++; }
    static int getX() {return x;}
};
int Test::x = 0;
int main()
{
    cout << Test::getX() << " ";
    Test t[5];
    cout << Test::getX();
}
// Program 1
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}

// Program 2
#include <iostream>
int main(int argc, char const *argv[])
{
	std::cout<<"Hello World";
	return 0;
}
#include<stdio.h>
struct STRUCT
{
  int static a;
};
int main()
{
  struct STRUCT s;
  return 0;
}
#include<stdio.h>
struct STRUCT
{
  int a;
  int func()
  {
      printf("HELLO THIS IS STRUCTURE\n");
  }
};
int main()
{
  struct STRUCT s;
  s.func();
  return 0;
}
#include<iostream>
using namespace std;
int main ()
{
   int cin;
   cin >> cin;
   cout << "cin: " << cin;
   return 0;
}
#include<iostream>
using namespace std;
int x[100];
int main()
{
    cout << x[99] << endl;
}
#include<iostream>
using namespace std;
class A
{
  ~A(){
     cout<<"Destructor called\n";
   }
};
int main()
{
    A *a1 = new A();
    A *a2 = new A();
    return 0;
}
#include<iostream>
using namespace std;
class A
{
  ~A(){
    cout<<"Destructor called\n";
  }
};
int main()
{
    A a;
    return 0;
}
#include<iostream>
using namespace std;
int x = 1;
int main()
{
    int x = 2;
    {
        int x = 3;
        cout << ::x << endl;
    }
    return 0;
}
// First program
#include<stdio.h>
int main(int argc, char const *argv[])
{
	printf("%d\n", (int)sizeof('a'));
	return 0;
}

// Second program
#include<stdio.h>
int main(int argc, char const *argv[])
{
	char a = 'a';
	printf("%d\n", (int)sizeof(a));
	return 0;
}
#include <stdio.h> 
void func()
{
	printf("Hello");
}
void main() 
{ 
	func();
	func(2);
}
#include <stdio.h> 
void func(void)
{
	printf("Hello");
}
void main() 
{ 
	func();
	func(2);
}
#include <stdio.h> 
void main() 
{ 
	printf("Hello World"); 
}
#include <stdio.h> 
int main(void) 
{ 
         int new = 5;
         printf("%d", new); 
}
int *p = malloc(10);
#include <stdio.h> 
int main(void) 
{
	const int j = 20; 
	int *ptr = &j;
	printf("*ptr: %d\n", *ptr); 
	return 0; 
}
#include<stdio.h> 
int main() 
{ 
   foo();
}  
int foo() 
{ 
   printf("Hello"); 
   return 0;  
}
int *ptr = new int;
delete ptr;
delete ptr;
int *ptr = NULL;
delete ptr;
#include <iostream>
using namespace std;
 
class A 
{
  int a;
  A() {
    a = 5;
  }
};
 
int main()
{
  A *obj = new A;
  cout << obj->a;
}
#include<iostream> 
using namespace std; 
class Base { 
public: 
  Base() {
    cout << "Constructing Base \n";
  } 
  virtual~Base() {
    cout << "Destructing Base \n";
  }	 
}; 
class Derived: public Base { 
public:
  Derived() {
    cout << "Constructing Derived \n";
  } 
  ~Derived() {
    cout << "Destructing Derived \n";
  } 
}; 
 
int main(void) 
{ 
	Derived *d = new Derived(); 
	Base *b = d; 
	delete b; 
	return 0; 
}
#include<iostream> 
using namespace std; 
class Base { 
public: 
  Base() { 
    cout<<"Constructing Base \n"; 
  } 
  ~Base() { 
    cout<<"Destructing Base \n"; 
  }	 
}; 
class Derived: public Base { 
public: 
  Derived() {
    cout<<"Constructing Derived \n"; 
  } 
  ~Derived() {
    cout<<"Destructing Derived \n"; 
  } 
}; 
 
int main(void) 
{ 
	Derived *d = new Derived(); 
	Base *b = d; 
	delete b; 
	return 0; 
}
#include <iostream>
using namespace std;
class A{
public:
	A(){
		cout<<"Constructor called\n";
	   }
	~A(){
		cout<<"Destructor called\n";
	    } 
};
int main(int argc, char const *argv[])
{
	A *a = new A[5];
	delete[] a;
	return 0;
}
		SHOW DATABASES;
		USE ssd_assignment_2;

					CREATE TABLE PERSON (
							EmpID int NOT NULL PRIMARY KEY,
							NamePrefix varchar(10),
							FirstName varchar(255),
							MiddleInitial varchar(10),
							LastName varchar(255),
							Gender varchar(10),
							Email varchar(255),
							FatherName varchar(255),
							MotherName varchar(255),
							MotherMaidenName varchar(255),
							DOB varchar(12),
							TimeOfBirth varchar(12),
							WeightInKgs int,
							DateOfJoining varchar(12),TimeOfBirth
							Salary int,
							LastHike varchar(10),  
							PlaceName varchar(255),
							Country varchar(255),
							City varchar(255),
							State varchar(255),
							Region varchar(255)
						);
    -- SELECTING PERSON TABLE    
    select * from PERSON;
    
    
    
    --   1.A-----------------------------------
   -- CREATING  hike2022 table   
						   CREATE TABLE hike2022 (
							HikePK int AUTO_INCREMENT PRIMARY KEY,
							EmpIDFK INT ,
							FirstName varchar(255),
							LastName varchar(255),
							Gender varchar(255),
							WeightInKg INT,
							LastHike varchar(10),
							LastSalary INT,
							NewHike varchar(10),
							NewSalary INT ,
							FOREIGN KEY ( EmpIDFK) REFERENCES PERSON ( EmpID) 	
							);
    
 -- drop hike2022 table   
    drop table hike2022;
    
 -- INSERTING FROM TABLE PERSON 
				INSERT INTO hike2022 ( EmpIDFK, FirstName, LastName, Gender, WeightInKg,  LastHike, LastSalary )
								select EmpID,   FirstName, LastName, Gender, WeightInKgs, LastHike, Salary from  PERSON
                                       WHERE WeightInKgs < 50;
                  
   -- SELECTING FROM hike2022 table 
				SELECT * FROM hike2022;
    
 
  -- PROCEDURE FOR UPDATE_HIKE ---------
					drop PROCEDURE UPDATE_HIKE;
				DELIMITER //
					CREATE PROCEDURE UPDATE_HIKE()
					BEGIN
						UPDATE hike2022 
							SET NewHike = CONCAT(cast(CAST(substring(LastHike, 1, length(LastHike)-1) AS unsigned) + 2 as char) , "%" )
								where HikePK != 0 ;
					
						UPDATE hike2022
							SET Newsalary = LastSalary  + (LastSalary * CAST(substring(NewHike, 1, length(NewHike)-1) AS unsigned)) / 100 
								where HikePK != 0 ;
					END  //
				DELIMITER ;					
-- PROCEDURE ENDED

-- EXECUTE AND PRINT HIKE TABLE 
			call `UPDATE_HIKE`();
			select * from hike2022;
            
            -- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
            
            
            drop table PersonJoining;
    --  1.B.---------------------------------------------------------------------
    
					CREATE TABLE PersonJoining (
                       PJoinPK  int AUTO_INCREMENT PRIMARY KEY,
                       EmpIDFK INT ,
                       FirstName varchar(255),
                       LastName varchar(255),
                       DateofBirth varchar(12),
                       Age INT ,
                       DateofJoining varchar(255),
                       DayofJoining varchar(255),
                       MonthofJoining varchar(255),
                       YearofJoining varchar(255),
                       WorkExpinDays varchar(255) ,
                       FOREIGN KEY ( EmpIDFK) REFERENCES PERSON ( EmpID)
                       );
                       
     -- INSERTING FROM TABLE PERSON  TO PERSON JOINING
				INSERT INTO PersonJoining ( EmpIDFK, FirstName, LastName, DateofBirth, DateofJoining )
								     select EmpID,   FirstName, LastName, DOB, 		   DateofJoining
                                          from  PERSON ;
                                       
      -- SELECT FROM PERSONJIONING
              SELECT * FROM PersonJoining ;
              
   -- PROCEDURE FOR UPDATE_DATES ---------
					drop PROCEDURE UPDATE_DATES;
				DELIMITER //
					CREATE PROCEDURE UPDATE_DATES()
					BEGIN
						UPDATE PersonJoining
                         SET AGE =(DATEDIFF(CURRENT_DATE, STR_TO_DATE(DateofBirth, '%m/%d/%Y'))/365.25)							
								where PJoinPK != 0 ;  
                                
                       UPDATE PersonJoining
                         SET   DayofJoining =  substring(DateofJoining,length(DateofJoining)-6, 2) 
                          where PJoinPK != 0 ;
                         
					  UPDATE PersonJoining
                         SET    MonthofJoining =  monthname(STR_TO_DATE(DateofJoining, '%m/%d/%Y'))
                          where PJoinPK != 0 ;
                           
					  UPDATE PersonJoining
                         SET   YearofJoining = substring(DateofJoining,length(DateofJoining)-3, length(DateofJoining) )    
                          where PJoinPK != 0 ;
                          
                      UPDATE PersonJoining
                         SET   WorkExpinDays = (DATEDIFF(CURRENT_DATE, STR_TO_DATE(DateofJoining, '%m/%d/%Y')))							
								where PJoinPK != 0 ;    
					
					END  //
				DELIMITER ;					
-- PROCEDURE ENDED

-- EXECUTE AND PRINT HIKE TABLE 
			call `UPDATE_DATES`();
			select * from PersonJoining;
        
                            
                            
                            
                            
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
 
 DESC PERSON;
 
drop TABLE PersonTransfer ;
 -- 1.c ------------>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
				CREATE TABLE PersonTransfer  (
                       PTPK int AUTO_INCREMENT PRIMARY KEY,
                       EmpIDFK INT,
                       FirstName varchar(255),
                       LastName varchar(255),
                       Gender varchar(10),
                       DateofJoining varchar(12),
                       CurrentRegion varchar(255),
                       NewRegion varchar(255), 
                       WorkExpinYear int ,
                       FOREIGN KEY ( EmpIDFK) REFERENCES PERSON ( EmpID)
                       );
						 
	  -- INSERTING FROM TABLE PERSON  TO PERSON JOINING
				INSERT INTO PersonTransfer ( EmpIDFK, FirstName, LastName, Gender, DateofJoining, CurrentRegion )
								      select EmpID,   FirstName, LastName, Gender, DateofJoining, Region
                                          from  PERSON ;
                                          
                                          
                                                                                 
      -- SELECT FROM PERSONJIONING
              SELECT * FROM PersonTransfer ;
    --           Populate NewRegion column to “DC” using your stored procedure
-- for employees with Gender “F” whose Work Experience is more than 10 years. Populate
-- the NewRegion column to “Capitol” using the same stored procedure for employees with
-- Gender “M” whose Work Experience is more than 20 years. Re-running the storedprocedure should delete the data from existing PersonTransfer table and should
-- repopulate the PersonTransfer tabl
   -- PROCEDURE FOR UPDATE_DATES ---------
					drop PROCEDURE UPDATE_Transfer_city;
				DELIMITER //
					CREATE PROCEDURE UPDATE_Transfer_city()
					BEGIN
						UPDATE PersonTransfer
                         SET WorkExpinYear = (DATEDIFF(CURRENT_DATE, STR_TO_DATE(DateofJoining, '%m/%d/%Y'))/365.25)
                         where PTPK != 0 ;
                        
                        UPDATE PersonTransfer
                         SET NewRegion = "DC"						
								where PTPK != 0 AND Gender ="F" AND WorkExpinYear >10   ;
                                
                         UPDATE PersonTransfer
                         SET NewRegion = "Capitol"						
								where PTPK != 0 AND Gender ="M" AND WorkExpinYear > 20  ;         
					
					END  //
				DELIMITER ;					
-- PROCEDURE ENDED

-- EXECUTE AND PRINT HIKE TABLE 
			call `UPDATE_Transfer_city`();
			select * from PersonTransfer;
            
            
            
            
            
            
            
                            
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
 Q3--->


 SELECT REGION ,TIME_A
   FROM PERSON
    
 
 
 
 
 -- dummy
 
 DROP PROCEDURE IF EXISTS Person_T;
DELIMITER //
CREATE PROCEDURE Person_T()
BEGIN
-- Drop Table IF exists PersonTransfer;
CREATE TABLE PersonTransfer1(
			PT int PRIMARY KEY AUTO_INCREMENT,
            emp_ID int,
            FOREIGN KEY (emp_ID) REFERENCES PERSON(EmpID),
            FirstName varchar(200),
            LastName varchar(200),
            Gender varchar(10),
            DateofJoining date,
            CurrentRegion varchar(200),
            NewRegion varchar (200)
            );
            
INSERT INTO PersonTransfer1(emp_ID, FirstName,LastName,Gender,	DateofJoining,				    CurrentRegion)
					SELECT EmpID,  FirstName,LastName,Gender,STR_TO_DATE(DateofJoining, "%m/%d/%Y"),Region
									FROM PERSON;
UPDATE PersonTransfer1 set NewRegion="DC"
WHERE PT!=0 AND Gender="F" AND (DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),DateofJoining)), '%Y') + 0)>10;

END //
DELIMITER ;

CALL Person_T();
select * from PersonTransfer1 ;


UPDATE   PERSON 
 SET TimeOfBirth =  STR_TO_DATE( TimeofBirth , ' %h:%i:%s %p' )
	where EmpID != 0;
    
    
SELECT Region, 
   COUNT(case when time_format(TimeOfBirth,"%T") between '00:00:00' and '08:00:00' then 1 else 0 end) as daystart,
   COUNT(case when time_format(TimeOfBirth,"%T") between '08:01:00' and '15:00:00' then 1 else 0 end) as midday,
   COUNT(case when time_format(TimeOfBirth,"%T") between '15:01:00' and '23:59:00' then 1 else 0 end) as lastday   
  FROM PERSON
  --  where TimeofBirth between 00: 
  GROUP BY Region;
  
  
  
  				 
						 
	  
                                          
                                                                                 
    
		 
            
            
            
            
            
            
            


#include <iostream>
using namespace std;
class A{
public:
	A(){
		cout<<"Constructor called\n";
	   }
	~A(){
		cout<<"Destructor called\n";
	    }
};
int main(int argc, char const *argv[])
{
	A *a = new A[5];
	delete a;
	return 0;
}
class A
{
    int i;
    public:
    void print(){
      cout<<"hello"<<i;
    }
}
 
class B: public A
{
    int j;
    public:
    void assign(int a){
      j = a;
    }
}
int func(float);
float func(int, int, char);
void test(int arg); //arg is a formal parameter

int main()
{
    int val = 1;
    test(val);  //val is an actual parameter
}
// this is comment

/* 
this 
is
also
comment
*/
// this is comment

/* 
this 
is
also
comment
*/
// case i
var_name
VARNAME
VAR_1234
var_Name

// case ii
1var_name
22VARNAME
987VAR_1234
23var_Name

// case iii
@var_name
+VARNAME
%VAR_1234
!var_Name
// case i
int var_name
VARNAME
VAR_1234
var_Name

// case ii
1var_name
22VARNAME
987VAR_1234
23var_Name

// case iii
@var_name
#VARNAME
%VAR_1234
!var_Name
// case i
var_name
VARNAME
VAR_1234
var_Name

// case ii
1var_name
22VARNAME
987VAR_1234
23var_Name

// case iii
@var_name
#VARNAME
%VAR_1234
!var_Name
#include "header1"
#include "fileHeader"
#include "libraryKita"
#include <iostream>
using namespace std;
​
int main() {
  cout << "Hello World! \n";
  cout << "I am learning C++";
  return 0;
}
​
#include <iostream>
using namespace std;
​
int main() {
  cout << "Hello World!";
  return 0;
}
​
class LRUCache
{
public:
	struct  Node
	{
		int key;
		int value;
		Node *prev;
		Node *next;
	};

	Node *head;
	Node *tail;
	int size , capacity;
	unordered_map<int , Node*>mapi;
	LRUCache(int capacity)
	{
		this->capacity = capacity;
		head = new Node();
		tail = new Node();
		head->next = tail;
		tail->prev = head;
		size =0;
	}

	Node* insertNode(int k , int v)
	{
		Node*newnode = new Node();
		newnode ->key = k;
		newnode->value=v;
		newnode->prev =head;
		newnode->next = head->next;
		newnode->next->prev = newnode;
		head->next = newnode;
		// // unordered_map<int , Node*>mapi
		// pair<int , int> p(k,v);
		mapi.erase(k);
		mapi[k] = newnode; 
		return newnode;
	}

	void pushtowardsHead(Node * newnode)
	{
		if(head->next == newnode)
			return;
		newnode->prev->next = newnode->next;
		newnode->next->prev = newnode->prev;
		newnode->prev =head;
		newnode->next = head->next;
		newnode->next->prev = newnode;
		head->next = newnode;
	}

	void removeTail()
	{
		Node*newnode = tail ->prev;
		tail->prev = newnode ->prev;
		newnode->prev->next= tail;
		mapi.erase(newnode->key);
	}

	int get(int k)
	{
		if(mapi.find(k) == mapi.end())
			return -1;
		Node* newnode =mapi[k];
		pushtowardsHead(newnode);
		return newnode->value;
	}

	void put(int k ,int v)
	{
		if(mapi.find(k)!=mapi.end())
		{//already present
			Node*newnode = mapi[k];
			newnode->value = v;
			pushtowardsHead(newnode);
			return;
		}

		insertNode(k,v);
		if(size <capacity)
		{
			size++;
			return;
		}
		else
		{
			removeTail();
		}
	}
};	
#include <bits/stdc++.h>
using namespace std;
class Solution
{
    public:
    vector<int> subarraySum(int arr[], int n, long long s)
    {
    
        long long sum=0;
        for(long long int i=0;i<n;i++){
            sum=arr[i];
            if(sum==s) return {i+1,i+1};
            for(long long int j=i+1;j<n;j++){
                sum+=arr[j];
                if(sum==s) return {i+1 , j+1};
                else if(sum>s) break;
            }
        }
        return {-1};
       
    }
};

int main()
 {
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        long long s;
        cin>>n>>s;
        int arr[n];
        const int mx = 1e9;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        Solution ob;
        vector<int>res;
        res = ob.subarraySum(arr, n, s);
        
        for(int i = 0;i<res.size();i++)
            cout<<res[i]<<" ";
        cout<<endl;
        
    }
	return 0;
}
#include<bits/stdc++.h>
using namespace std;


struct Node{
    int data;
    struct Node *next;
    Node(int data){
        this->data = data;
        next = NULL;
    }
};
    
    
struct LinkedList {
    
    Node *head;
    LinkedList() { head = NULL;}
    
    
    void reverse()
    {
        Node *current = head;
        Node *prev = NULL;
        Node *next = NULL;
        
        while(current != NULL) {
            next = current->next;
            current-> next = prev;
            prev = current;
            current = next;
        }
        head = prev;
    }
    
    
    void print()
    {
        struct Node* temp = head;
        while(temp != NULL){
            cout << temp->data << " ";
            temp = temp->next;
        }
    }
    
    
    void push(int data)
    {
        Node *temp = new Node(data);
        temp -> next = head;
        head = temp;
    }
};
    
int main()
{
    LinkedList ll;
    ll.push(1);
    ll.push(2);
    ll.push(3);
    ll.push(4);
    
    
    ll.print();
    cout << endl;
    
    ll.reverse();
    ll.print();
    
    return 0;
}
//----------------------------header files------------
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<termios.h>
#include<unistd.h>
#include<ctype.h>
#include<limits.h>
#include<dirent.h>
#include<sys/stat.h>
#include<algorithm>
#include<iomanip>
#include<sys/ioctl.h>
#include<stack>
#include<pwd.h>
#include<grp.h>
#include<signal.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<fstream>
#include<fcntl.h>
#include <cmath>
#include<iomanip>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include<cstring>
#include<dirent.h>
using namespace std;

//--------------------user defined--------
#define UP 65
#define DOWN 66
#define RIGHT 67
#define LEFT 68
#define ENTER 10
#define MODE 0777
#define BUF_SIZE 8192


//---------global items-----------------

vector<string>vec_dir_list;
int directory_position = 1;
stack<string>back_stack;
stack<string>forward_stack;
string curr_dir ;
int LIST_SIZE ;
stack <string>st;



//---------stat------------------

static struct termios term, oterm;
struct termios raw;
struct termios raw_out;
struct termios orig_termios;


//----------------FUNCTION PROTOTYPES------------

void keys(string  );
void enableRawMode() ;
void disableRawMode();
void enableRawMode2() ;
void createdir(string , string);
int search(string , string);
vector<string> getcommand();
void create_file(string , string);
void create_dir(string , string);
void delete_dir(string );
void keys(string);
void copy_file(string , string );
void copy_dir(string , string );
void move_file(string , string );
void move_dir(string , string );
void delete_file( string );
void delete_dir(string );
string name_of_folder(string );//get path from back upto 1st '/'
void rename(string, int , vector<string>);

//-----------------RAW MODE ----------------
void disableRawMode();
void enableRawMode();
void editorRefreshScreen()
{
	write(STDOUT_FILENO, "\x1b[2J", 4);
}

string cwd()
{
	// string a = get_current_dir_name();
	// return a;
	char cwd[100];
	getcwd(cwd, sizeof(cwd));
	string a = cwd;
	return a;
}
string prnt = cwd();

int isfolder(string fileName)
{
	struct stat path;

	stat(fileName.c_str(), &path);

	return S_ISREG(path.st_mode);
}


int isDir(const char* fileName)
{
	struct stat path;

	stat(fileName, &path);

	return S_ISREG(path.st_mode);
}

void clear()
{
	cout << "\033[2J\033[1;1H";
	// printf(" \033[%d;%dH", 4, 0);
}

string output_permissions(mode_t st)
{
	string s = "";

	s += ( st & S_IRUSR ? "r" : "-" );
	s += ( st & S_IWUSR ? "w" : "-" );
	s += ( st & S_IXUSR ? "x" : "-" );
	s += ( st & S_IRGRP ? "r" : "-" );
	s += ( st & S_IWGRP ? "w" : "-" );
	s += ( st & S_IXGRP ? "x" : "-" );
	s += ( st & S_IROTH ? "r" : "-" );
	s += ( st & S_IWOTH ? "w" : "-" );
	s += ( st & S_IXOTH ? "x" : "-" );
	return s;
}
string check_tilda(string s)
{
	string t = "";
	t += s[0];
	if (t == "~")
	{
		t = s.substr(1, s.length() - 1);
		const char *homedir;
		if ((homedir = getenv("HOME")) == NULL)
		{
			homedir = getpwuid(getuid())->pw_dir;
		}
		t = homedir + t;
		return t;
	}
	else if (t == "/")
	{
		return s;
	}
	return "";
}


//---PRINT DATA OF A PARTICULAR FILE
void print ()
{
	struct group *grp;
	struct passwd *pwd;
	struct stat st;
	for (int i = 0; i < vec_dir_list.size(); i++)
	{
		stat(vec_dir_list[i].c_str(), &st);
		string perm = output_permissions(st.st_mode);

		cout << setw(2) << perm << "\t";

		//2.links
		string link =  to_string(st.st_nlink);
		cout << setw(2) << link << "\t";

		//3.group id
		grp = getgrgid(st.st_uid );
		//printf(" %s", grp->gr_name);
		//temp.push_back(grp->gr_name);
		cout << setw(2) << grp->gr_name << "\t";

		//4.person id
		pwd = getpwuid(st.st_gid);
		//printf(" %s", pwd->pw_name);
		cout << setw(2) << pwd->pw_name << "\t  ";

		//5.size
		int size = st.st_size;
		float a = size / 1024.0;
		cout << setw(6) << fixed << setprecision(2) << a << " KB\t  ";


		//6.modified time
		string time = ctime(&st.st_mtime) ;
		string t2 = time.substr(0, time.length() - 1);
		cout << setw(2) << t2 << "\t";

		cout << left << setw(10) << vec_dir_list[i];
		cout << endl;
	}
}

//-------------Push all files of Current dir to vector------------------
void listFiles(string dir_name)
{
	clear();

	vec_dir_list.clear();
	DIR * dir = opendir(dir_name.c_str());
	if (dir == NULL)
		return ;

	dirent *entity;
	entity = readdir(dir);

	struct stat st;

	while ( entity != NULL)
	{
		stat(entity->d_name, &st);
		vec_dir_list.push_back(entity->d_name);
		entity = readdir(dir);
	}

	//Sort on basis of name
	sort(vec_dir_list.begin(), vec_dir_list.end());
	// sort(file_name.begin(), file_name.end());

	closedir(dir);
	print();
}



//------------********keys -*****-(most important)--------------

void keys(string pwd)
{
	LIST_SIZE = vec_dir_list.size();
	cout << LIST_SIZE << endl;
	int pos = 0;
	char ch;
	curr_dir = cwd();
	printf(" \e[H");
	while (1)
	{
		ch = cin.get();
		if (ch == DOWN)
		{
			if (pos < LIST_SIZE)
			{

				pos++;
				directory_position = pos;

				printf("%c[%d;%df", 0x1B, pos, 1);
				// cout << pos;
			}
		}
		else if (ch == UP)
		{
			if (pos >= 0)
			{
				pos--;
				directory_position = pos;


				printf("%c[%d;%df", 0x1B, pos, 1);
				// cout << pos;
			}
		}
		else if (ch == ENTER)
		{
			struct stat st;


			string s = pwd;
			s += "/" + vec_dir_list[directory_position - 1];

			stat(s.c_str(), &st);


			if ((st.st_mode & S_IFMT) == S_IFDIR)
			{

				back_stack.push(pwd);
				pwd = s;
				curr_dir = pwd;
				cout << "curr_dir :" << curr_dir << endl;
				clear();
				vec_dir_list.clear();
				// cout << s << "-----------------" << endl;
				directory_position = 1;
				listFiles(s);
				keys(s);
			}
			else if ((st.st_mode & S_IFMT) == S_IFREG)
			{
				pid_t pid = fork();
				if (pid == 0)
				{
					execlp("xdg-open", "xdg-open", s.c_str(), NULL);
					exit(0);
				}

			}


		}
		else if (ch == LEFT)
		{
			if (!back_stack.empty())
			{
				clear();
				string s = back_stack.top();
				forward_stack.push(s);//current push to forward
				back_stack.pop();
				listFiles(s);
				keys(s);

			}
		}
		else if (ch == RIGHT)
		{

			if (!forward_stack.empty())
			{
				clear();
				string s = forward_stack.top();
				forward_stack.pop();
				back_stack.push(pwd);
				listFiles(s);
				keys(s);
			}
		}
		else if ( ch ==  127) //backspace
		{
			clear();

			// int i;
			// for (i = prnt.length() - 1; prnt[i] != '/' && i >= 0; i--);
			// prnt = prnt.substr(0, i);
			back_stack.push(curr_dir);
			// pwd = prnt;
			curr_dir += "/";
			curr_dir += "..";
			listFiles(curr_dir);
		}
		else if (ch == 104) //home directrotry
		{
			clear();
			const char *homedir;

			if ((homedir = getenv("HOME")) == NULL)
			{
				homedir = getpwuid(getuid())->pw_dir;
			}
			back_stack.push(curr_dir);
			pwd = string(homedir);

			curr_dir = string(homedir);
			listFiles(pwd);
			keys(pwd);
		}
		else if (ch == 'q')
		{
			printf("\033c");
			return;
		}
		else if (ch == ':')
		{
			// clear();
			disableRawMode();
			enableRawMode2();
			// editorRefreshScreen();
			// cout << "YOU ARE IN COMMAND MODE : \n";
			// char c = cin.get();

			struct winsize w;
			ioctl(0, TIOCGWINSZ, &w);
			int rows = w.ws_row;
			int a = rows - 12;


			printf("\033[%d;1H", a);
			printf("\033[0;36m""COMMAND MODE STARTED:\n ");
			cout << "CURRENT PATH IS :" << curr_dir << endl;
			cout << "$ ";

			while (1)
			{
				char c;
				vector <string> v;
				v = getcommand();

				if (v[0] == "rename")
				{
					if (v.size() != 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG FILE NAME :\n";
						break;
					}
					rename(pwd, a, v);
				}
				else if (v[0] == "27")//to escape
				{

					enableRawMode();
					clear();
					listFiles(curr_dir);
					keys(curr_dir);
				}
				else if (v[0] == "quit")
				{	//write quit then space then enter to quit

					printf("\033c");
					return;
				}
				else if (v[0] == "goto")
				{

					if (v.size() != 2)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}

					curr_dir = check_tilda(v[1]);
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";
				}
				else if (v[0] == "create_file")
				{
					if (v.size() != 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					string path = check_tilda(v[2]);

					create_file(v[1] , path);
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";
				}
				else if ( v[0] == "create_dir")//create_dir
				{

					if (v.size() != 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					string path = check_tilda(v[2]);
					create_dir(v[1], path);
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";
				}
				else if (v[0] == "search") //search file or folder
				{
					if (v.size() != 2)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					int t = search(v[1] , ".");
					if (t == 1)
						cout << "TRUE";
					else
						cout << "FALSE";
				}
				else if (v[0] == "delete_file")
				{
					if (v.size() != 2)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					string s = check_tilda(v[1]);
					s += "/" + v[1];
					if (remove(v[1].c_str()))
						cout << "fail";
					else
						cout << "success";

					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string st = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << st << endl;
					cout << "$ ";
				}
				else if (v[0] == "delete_dir")
				{
					if (v.size() != 2)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					// string s = check_tilda(v[1]);
					// s += "/" + v[1];
					delete_dir(v[1]);//complete path name pr hi kaam karega


					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string st = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << st << endl;
					cout << "$ ";
				}
				else if (v[0] == "copy")
				{
					if (v.size() < 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					for (int i = 1; i <= v.size() - 2; i++)
					{
						string des_path = check_tilda(v[v.size() - 1]);
						
						
						
						if (!isfolder(v[i])) //opposite return true k liye 0
						{
							des_path += "/" + v[i];
							mkdir( des_path.c_str(), 0777 );

							string sa = get_current_dir_name();
							string source_foldr = sa + "/" + v[i];

							copy_dir(source_foldr, des_path );
						}
						else
						{
							string s = curr_dir + "/" + v[i];
							cout << "\n\n\n\n\n\n\n:::::: " << curr_dir << "  \n:::\n\n\n\n\n";
							copy_file(s, des_path);
						}
					}
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";

				}
				else if (v[0] == "move")
				{
					if (v.size() < 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					for (int i = 1; i <= v.size() - 2; i++)
					{
						string des_path = check_tilda(v[v.size() - 1]);
						if (!isfolder(des_path)) //opposite return true k liye 0
						{
							string folder_n = curr_dir + "/" + v[i];
							des_path += "/" + v[i];
							move_dir(folder_n , des_path );
						}
						else
						{
							string s = curr_dir + "/" + v[i];
							move_file(s, des_path);
						}
					}
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";
				}

			}
		}

	}
}

void rename(string pwd, int a, vector<string>v)
{
	string s = curr_dir;
	cout << "curr_dir: " << curr_dir << endl;
	string aa = "";
	string b = "";
	aa += s + "/" + v[1];
	b += s + "/" + v[2];
	int result = rename(aa.c_str() , b.c_str() );
	clear();
	pwd = curr_dir;
	listFiles(pwd);
	printf("\033[%d;1H", a);
	printf("\033[0;36m""COMMAND MODE STARTED:\n ");
	string ss = realpath(curr_dir.c_str(), NULL);
	if (result == 0)
		cout << "successful rename\n";
	else
		cout << "Write file name carefully\n";
	cout << "CURRENT PATH IS :" << ss << endl;
	cout << "$ ";
}
void move_file(string fileName, string destination)
{
	copy_file(fileName , destination);


	if (remove(fileName.c_str()))
		cout << "fail";
	else
		cout << "success";
	return;
}

void move_dir(string source , string destination)
{

	int result = rename(source.c_str() , destination.c_str() );
	if (result == 0)
		cout << "success";
	else
		cout << "something went wrong";
}

void copy_file(string sr, string dt)
{


  int src, dst, in, out;
  char buf[BUF_SIZE];
  // if (argc != 3) exit(1);

  src = open(sr.c_str(), O_RDONLY);
  if (src < 0)
    exit(2);
  // dt += "/" + sr;//complete path +name
  dst = creat(dt.c_str(), MODE);
  if (dst < 0)
    exit(3);
  while (1) {
    in = read(src, buf, BUF_SIZE);
    if (in <= 0) break;
    out = write(dst, buf, in);
    if (out <= 0) break;
  }
  close(src); close(dst); return;
}



void copy_dir(string folderName, string destination)
{

	DIR* dir = opendir(folderName.c_str());
	if (dir == NULL)
	{
		printf("no such source directory found\n");
		return;
	}
	// cout << folderName << endl;

	struct dirent* entity;
	while ((entity = readdir(dir)) != NULL )
	{
		// printf("%hhd  %s\n", entity->d_type,   entity->d_name);
		if ( string(entity->d_name) == "." || string(entity->d_name) == "..")
		{
			// cout << string(entity->d_name) << endl;
			continue;
		}
		else
		{
			string s = string(entity->d_name);
			string source_path = folderName + "/" + entity->d_name;
			struct stat tmp;
			if (stat(source_path.c_str(), &tmp) == -1)
			{
				printf(" cannot get souurce  stat\n");
				continue;
			}
			if (!isfolder(source_path))
			{
				string dest_path = destination + "/" + entity->d_name;
				mkdir( dest_path.c_str(), 0777 );
				copy_dir(source_path, dest_path );
			}
			else
			{
				string dest_path = destination + "/" + entity->d_name;
				copy_file(source_path, dest_path);
			}

			// cout << "entity name: " << s << endl;
			// cout << "source_path:" << source_path << endl;
			// cout << "destination_path" << dest_path << endl;
		}


	}
	closedir(dir);

	return;
}


void create_file(string  Name , string folder)//create_file
{
	string s = folder;
	s += "/" + Name;
	FILE* file = fopen(s.c_str(), "w+");
	fclose(file);

}


void create_dir(string Name , string folder)
{

	string s = folder;
	s += "/" + Name;
	mkdir( s.c_str(), 0775 );
}


string name_of_folder(string path)//last piche se folder 
{
	string a = "";
	for (int i = path.length() - 1; i >= 0 ; -- i)
	{
		string m = "";
		m += path[i];
		if (m != "/")
			a += m;
		else
			break;
	}

	path = "";
	for (int i = a.length() - 1; i >= 0; i--)
	{
		path += a[i];
	}
	return path;

}


int  search(string Name , string folder)
{
	DIR* dir = opendir(folder.c_str());
	if (dir == NULL) {
		return 0;
	}
	struct dirent* entity;
	entity = readdir(dir);
	while (entity != NULL)
	{
		if (entity->d_type == DT_DIR && strcmp(entity->d_name, ".") != 0 && strcmp(entity->d_name, "..") != 0)
		{
			string folder_name = name_of_folder(folder);
			if (Name == entity->d_name)
			{
				return 1;
			}


			char path[100] = { 0 };
			strcat(path, folder.c_str());
			strcat(path, "/");
			strcat(path, entity->d_name);
			if ((search(Name , path)))
				return 1;
		}
		else
		{
			if (entity->d_name == Name)
			{
				return 1;
			}
		}
		entity = readdir(dir);
	}
	closedir(dir);
	return 0;
}

void delete_dir(string dirname)
{
	DIR* dir = opendir(dirname.c_str());
	if (dir == NULL) {
		return;
	}

	int count = 5;
	// printf("Reading files in: %s\n", dirname);

	struct dirent* entity;
	while ((entity = readdir(dir)) != NULL && (count-- > 0))
	{
		if (entity->d_name == "."  || entity->d_name == "..")
			continue;
		else if (entity->d_type == DT_DIR && strcmp(entity->d_name, ".") != 0 && strcmp(entity->d_name, "..") != 0)
		{
			string path = dirname + "/" + entity->d_name;
			// cout << "foldr_name: " << entity->d_name << endl;
			delete_dir(path);
		}
		else
		{
			string path = dirname + "/" + entity->d_name;
			// cout << "\n--fiile:  " << entity->d_name << endl;
			// cout << "file_path: " << path << endl;
			if (strcmp(entity->d_name, ".") != 0 && strcmp(entity->d_name, "..") != 0)
			{
				int status = remove(path.c_str());
				if (status == 0)
					cout << "\nFile Deleted Successfully!\n";
				else
					cout << "\nIN FILE Error Occurred!\n";
			}
		}

	}
	closedir(dir);

	// string path = dirname + "/" + entity->d_name;
	// cout << "foldr_name: " << dirname << endl;
	int status = remove(dirname.c_str());

	if (status == 0)
		cout << "\nFOLDER Deleted Successfully!\n";
	else
		cout << "\nIN FOLDER Error Occurred!\n";
	return;
}










void enableRawMode2() {
	tcgetattr(STDIN_FILENO, &orig_termios);
	atexit(disableRawMode);
	struct termios raw = orig_termios;
	raw.c_lflag &= ~(ICANON);
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}


void disableRawMode() {
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}


void enableRawMode() {
	tcgetattr(STDIN_FILENO, &orig_termios);
	atexit(disableRawMode);
	struct termios raw = orig_termios;
	raw.c_lflag &= ~(ECHO | ICANON);
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}

vector<string> getcommand()
{

	char ch;
	string s ;

	getline (cin , s);

	//-------------------------------------------------
	// string s = "";
	// char c;
	// c = cin.get();
	// while (c != 10)
	// {
	// 	if (c != 127)
	// 	{
	// 		s += c;
	// 	}
	// 	else if (c == 127)
	// 	{
	// 		printf ("\033[0K");
	// 		s = s.substr(0, s.length() - 1);
	// 		cout << s;
	// 	}
	// 	c = cin.get();
	// }
	//---------------------------------------------------------
	vector<string> v;
	string input = "";
	for (int i = 0; i < s.length() ; ++i)
	{
		string m = "";
		m += s[i];
		if (m != " ")
		{
			input += m;

		}
		else if (m == " ")
		{
			v.push_back(input);
			input = "";
		}


	}
	v.push_back(input);
	return v;

}



int main()
{
	clear();
	enableRawMode();//enable to get into canonicall mode
	// /get_current_dir_name()
	curr_dir = get_current_dir_name(); //global path
	back_stack.push(curr_dir);
	listFiles(curr_dir);
	keys(curr_dir);
	return 0;
}
// if you want to know a distance between the number and divisor of other number
int n,m;
n = 3, m = 17;
int mod = 17 % 3;     //3 is a divisor of 15 and distance between 15 and 18 is 2 
cout<<mod;            // 2
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;

int Partition(int *A, int start, int end)
{
    int pivot = A[end];
    int partitionIndex = start;
    for(int i =start; i < end; i++)
    {
        if(A[i]<= pivot)
        {
            swap(A[i], A[partitionIndex]);
            partitionIndex++;
        }
    }
    swap(A[partitionIndex], A[end]);
    return partitionIndex;
}

void QuickSort(int *A, int start, int end)
{
    if(start < end)
    {
        int pertitionIndex = Partition(A, start, end);
        QuickSort(A, start, pertitionIndex-1);
        QuickSort(A, pertitionIndex+1, end);
    }
}

int main() {
    int A[] = {7,6,5,4,3,2,1,0};
    QuickSort(A, 0, 7);
    for (int i = 0; i<8; i++) cout<<A[i]<<" ";
    return 0;
}
void ABolter::BeginPlay()
{
	Super::BeginPlay();
	
	CurrentAmmoWithYou = FMath::DivideAndRoundUp(MaxAmmoCarry, 2);
	CurrentAmmoInMagazine = MaxAmmoMagazine;
	CurrentAmmoWithYou -= CurrentAmmoInMagazine;
}

void ABolter::Fire()
{
	if (CurrentAmmoInMagazine <= 0)
	{
		UGameplayStatics::PlaySoundAtLocation(SkeletalMesh, EmptyMagazineSound, 
        this->GetActorLocation(), 
        this->GetActorRotation());
		return;
	}
  
	--CurrentAmmoInMagazine;
}

void ABolter::StopFireRate()
{
	if (!GetWorldTimerManager().IsTimerActive(FireRateTimerHandle)) { return; }

	GetWorldTimerManager().ClearTimer(FireRateTimerHandle);
}

bool ABolter::IsShooting()
{
	return GetWorldTimerManager().IsTimerActive(FireRateTimerHandle);
}

void ABolter::Reload()
{
	OwnerCharacterSpaceMarine = Cast<ASpaceMarineCharacter>(GetOwner());

	if (CurrentAmmoWithYou > 0 && CurrentAmmoInMagazine != MaxAmmoMagazine && !IsShooting())
	{
		if (!OwnerCharacterSpaceMarine) { return; }

		OwnerCharacterSpaceMarine->SetIsReloading(true);
		OwnerCharacterSpaceMarine->GetCharacterMovement()->MaxWalkSpeed = 300.f;

		UGameplayStatics::PlaySoundAtLocation(SkeletalMesh, ReloadSound, this->GetActorLocation(), this->GetActorRotation());
		GetWorldTimerManager().SetTimer(ReloadTimer, this, &ABolter::CalculateBulletsAmountToReload, ReloadTime);
	}
}

void ABolter::CalculateBulletsAmountToReload()
{
	OwnerCharacterSpaceMarine->SetIsReloading(false);
	OwnerCharacterSpaceMarine->GetCharacterMovement()->MaxWalkSpeed = 600.f;

	int32 AmmoToReload = MaxAmmoMagazine - CurrentAmmoInMagazine;

	if (CurrentAmmoWithYou < AmmoToReload)
	{
		CurrentAmmoInMagazine += CurrentAmmoWithYou;
		CurrentAmmoWithYou = 0;
	}
	else
	{
		CurrentAmmoInMagazine += AmmoToReload;
		CurrentAmmoWithYou -= AmmoToReload;

		if (CurrentAmmoWithYou < 0)
		{
			CurrentAmmoWithYou = 0;
		}
	}
}

int32 ABolter::GetAmmoInMagazineValue()
{
	return CurrentAmmoInMagazine;
}

int32 ABolter::GetAmmoWithYouValue()
{
	return CurrentAmmoWithYou;
}

void ABolter::ReplenishAmmo()
{
	if (CurrentAmmoWithYou < MaxAmmoCarry)
	{
		UGameplayStatics::PlaySoundAtLocation(SkeletalMesh, TakeAmmo, this->GetActorLocation(), this->GetActorRotation());

		CurrentAmmoWithYou = MaxAmmoCarry;
	}
}
private:
	int32 CurrentAmmoWithYou;
	int32 CurrentAmmoInMagazine;

	UPROPERTY(EditAnywhere, Category = "Statistics")
	float ReloadTime = 1.6f;
	UPROPERTY(EditAnywhere, Category="Statistics")
	float MaxDistance = 100.f;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	float Damage = 10.f;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	int32 MaxAmmoCarry = 360;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	int32 MaxAmmoMagazine = 15;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	float AccuracyMin = 0;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	float AccuracyMax = 0;

	FTimerHandle ReloadTimer;

	void CalculateBulletsAmountToReload();

public:	
	bool IsShooting();
	void ReplenishAmmo();

	int32 GetAmmoInMagazineValue();
	int32 GetAmmoWithYouValue();
//general approach Template
void Backtrack(int start)
{
    //Base case 

// loop for all possible values
{
    //include the current element at this position if possible in the ans 
	//More generally, make a choice 

    Backtrack(start+1) 

    //backtrack by removing current element 
}
                            ------------------------------------------------

//Generate all subsets (non dublicated)
int n;
void GenerateSubs(vector<int> &a, int s, vector<int> &subset, vector<vector<int>> &ans) {
    for (int i = s; i < n; i++) {
        subset.push_back(a[i]); //include element at ith position
        GenerateSubs(a, i + 1, subset, ans); //generate all subsets including ith element
        subset.pop_back(); //backtrack
    }
    ans.push_back(subset);
}

vector<vector<int>> subsets(vector<int> &a) {
    vector<vector<int>> ans;
    vector<int> subset;
    n = a.size();

    GenerateSubs(a, 0, subset, ans);
    return ans;
}

int main() {
    fast;
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> ans(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ans = subsets(a);
    for (vector<int> i: ans) {
        for (int j: i) {
            cout << j;
        }
        cout << '\n';
    }
}
// i/p :
  //3
  //1,2,3
// o/p : 
                              ------------------------------------------------

//Generate all subsets (dublicated)
int n;
void GenerateSubs(vector<int>&a,int s,vector<int>&subset,vector<vector<int>>&ans)
{
    for(int i=s;i<n;i++)
    {
        if(i==s||a[i]!=a[i-1])
        {
            subset.push_back(a[i]); //include element at ith position
            GenerateSubs(a,i+1,subset,ans); //generate all subsets including ith element
            subset.pop_back(); //backtrack
        }
    }
    ans.push_back(subset);
}
vector<vector<int>> subsetsWithDup(vector<int> &a) {
    vector<vector<int>> ans;
    vector<int> subset;
    n = a.size();

    sort(a.begin(), a.end()); //sort the elements so that we can keep track of duplicates
    GenerateSubs(a, 0, subset, ans);
    return ans;
}

int main() {
    fast;
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
#endif
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> ans(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ans = subsetsWithDup(a);
    for (vector<int> i: ans) {
        for (int j: i) {
            cout << j;
        }
        cout << '\n';
    }
}
// i/p :
  //4
  //1 2 3 2
/* o/p :
1223
122
123
12
13
1
223
22
23
2
3
  */
                              ------------------------------------------------
                              ------------------------------------------------

//---------------------------------------Examples--------------------------------------------------
//Generate all subset instead '?'
string s;
string o;

void solve(int i) {
    //base case
    if (i == s.length()) {
        for (int j = 0; j < s.length(); ++j) {
            cout << o[j];
        }
        cout << '\n';
        return;
    }
    if (s[i] != '?') {
        o[i] = s[i];
        solve(i + 1);
    } else {
        for (int j = 'a'; j <= 'z'; ++j) {
            o[i] = j;
            solve(i + 1);
        }
    }
}


int main() {
    cin >> s;
    solve(0);
}
---------------------------------------------------------------------------------------------------
//Generating Permutations Using next_permutation

int n;
int const N = 11;
bool taken[N];
int stk[N];

void prm(int i) {
    //base case
    if (i == n) {
        for (int j = 0; j < n; ++j) {
            cout << stk[j] << ' ';
        }
        cout << el;
        return;
    }
    for (int j = 1; j <= n; ++j) {
        if (!taken[j]) {
            taken[j] = true;
            stk[i] = j;
            prm(i + 1);
            taken[j] = false;
        }
    }
}


int main() {

    fast;
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
#endif
    cin >> n;
    prm(0);
}
---------------------------------------------------------------------------------------------------
//  
// Left shift ---> Multiplying by 2 
int x = 6;
x <<= 1;
cout << x;   // 12
--------------------------------------------------------------------------------------------------
//Right shift ---> Divide by 2 
int x = 12;
x >>= 1;
cout << x;   // 6
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
//  Checking if given 32 bit integer is power of 2 
// if true return 1 else return 0
int isPowerof2(int x)
{
    return (x && !(x & x-1));
}
--------------------------------------------------------------------------------------------------
// Find log base 2 of 32 bit integer
// log2(8)=3 when 2^3 = 8
int log2(int x)
{
    int res = 0;
    while (x >>= 1)
        res++;
    return res;
}
--------------------------------------------------------------------------------------------------
#include<iostream>
using namespace std;

int main(){

//finding the length of the string

    string para = "I am Rishi";
    cout << para.length() << endl;

//finding according to the index of the string

    cout << para[2] << endl;

// replacing a string

    para[0] = 'G';
    cout << para << endl;

//substring

    cout  << para.substr(3, 4);

// creating another variable for the substring

    string parasub = para.substr(3, 4);
    cout << parasub << endl;

    return 0;
}

//1- (string) ---> (int)
stoi("String name");
 
//2- (int) ---> (string)
int n;
cin>>n;
String s = to_string(n);
cout<<s;
 
//3- (char) ---> (int)
String str;
cin>>str;
for(int i; str[i], i++){
  char ch = str[i]-'0';   //note:(str[i]-'0') to convert str[i] character to integer
  cout<<ch;
}
  
//3- (int) ---> (char)
int n;
cin>>n;
char ch = (char) n;
cout<<ch;
 
//4- (int) ---> (long long)
int a;
a = a*1LL;
 
//5- (double) ---> (int) && flooring number
double n = 7.99999999;
n = (int) n;
//Binary Search implementation //Time Complexity: O (log n) //return int {-1 , mid index}
int binarySearch(int tar, vector<int>& arr){
int lo=0, md, hi=arr.size()-1;
while(hi>=lo){
md = lo + (hi - lo) / 2;
if(arr[md]==tar) return md;
else if(arr[md]<tar) lo=md+1;
   		else hi=md-1;
}
return -1;
}
---------------------------------------------------------------------------------------------------
//Binary Search by using Stls //Time Complexity: O (log n)
// for binary search in containers like vector (let target element=6)
binary_search(v.begin(), v.end(), 6); 
// return 1 or 0 as present or not
---------------------------------------------------------------------------------------------------
//binary search with lower and upper bound by using stls
int x, ans; //x is passing value, ans is a value you want, v --> vector or any container
ans = lower_bound(v.begin(), v.end(), x) - v.begin(); //ans >= x (equal number or first number after x)
ans = upper_bound(v.begin(), v.end(), x) - v.begin(); // ans > x (first number after x)

//implementation
int lower_bound(vector<int> nums, int target){
        int l = 0, r = nums.size()-1, m = 0;
        while(l < r) {
            m = (l+r)/2;
            if(nums[m] < target)
                l = m+1;
            else 
                r = m;
        }
        return r;
    }

    int upper_bound(vector<int> nums, int target){
        int l = 0, r = nums.size()-1, m = 0;
        while(l < r) {
            m = (l+r)/2;
            if(nums[m] <= target)
                l = m+1;
            else 
                r = m;
        }
        return r;
    }
---------------------------------------------------------------------------------------------------
// Two Pointer implementation
// Two pointer technique based solution to find
// if there is a pair in A[0..N-1] with a given sum.
int isPairSum(int A[], int N, int X)
{
    // represents first pointer
    int i = 0;
  
    // represents second pointer
    int j = N - 1;
  
    while (i < j) {
      
        int curSum = A[i]+arr[j];
      
        // If we find a pair
        if curSum == X)
            return 1;
  
        // If sum of elements at current
        // pointers is less, we move towards
        // higher values by doing i++
        else if (curSum < X)
            i++;
  
        // If sum of elements at current
        // pointers is more, we move towards
        // lower values by doing j--
        else
            j--;
    }
    return 0;
}
//Sum of numbers from 1 ---> n
int n, sum;
sum = (n*(n+1))/2;
 
//flooring integer number (int)        "floor أرضيه"
int a=5, b=2;
int n = a/b; // n= 2
 
//Ceiling integer number (int)          "ceil سقف"
int a=5, b=2;
int ans = (a+(b-1))/b; //n=3
 
//Division Theory 
int a=10, b=3;     // a ---> numerator البسط / b ---> denominator المقام
int ans = a/b;     // n= 3
//meaning:
//1- you can give everyone of b ans
//2- ans is a number of numbers from 1--> a which is divisible by b (find multiple in Range)
 
//Number of Steps
//Power function //Complexity: O(exponent).
double x = 6.1, y = 4.8;
double result = pow(x, y);
--------------------------------------------------------------------------------------------------- 
// modulous a floating number types (n % dn)
double n = fmod(num , denum);
---------------------------------------------------------------------------------------------------
//limits of integer types and help you when you handle (min/max)
int n1 =INT_MAX;  //+2147483647 //== 2*1e9 
int n2 =INT_MIN;  //-2147483647 //== -2*1e9
---------------------------------------------------------------------------------------------------
//Ceiling and flooring with double numbers
//1- Flooring
double a = 2.3;  a = floor(a);  //2
double b = -2.3; b = floor(b);  //-3
//2- ceiling
double a = 2.3;  a = ceil(a);  //3
double b = -2.3; b = ceil(b);  //-2
---------------------------------------------------------------------------------------------------
// Square Root //Time Complexity: θ(log(N))
int x = 24;
double answer;
answer = sqrt(x);
---------------------------------------------------------------------------------------------------
// max/min of three numbers //Time Complexity: O(1)
ans = max(a,max(b,c));
ans = min(a, min(b,c));
---------------------------------------------------------------------------------------------------
//GCD //Library: 'algorithm' //Time Complexity: O(log(max(value1, value2))))
int a = 6, b = 20;
int ans = __gcd(a, b); //gcd(6, 20) = 2
---------------------------------------------------------------------------------------------------
//Lowercase and Uppercase handle  //Time Complexity: O(1)
// convert 'a' to uppercase
char ch = toupper('a');  //A
// convert 'A' to lowercase
char ch = tolower('A');  //a
---------------------------------------------------------------------------------------------------
//Rounding numbers // return double type
double dUp = round(2.6);
double dDown = round(2.4);
cout << dUp;   //3
cout << dDown;   //2
---------------------------------------------------------------------------------------------------
//search for x
find(vect.begin(), vect.end(),x);
//note 
// find() returns iterator to last address if element not present
find(vect.begin(), vect.end(),5) != vect.end()?
                         cout << "\nElement found": cout << "\nElement not found";
---------------------------------------------------------------------------------------------------
// for binary search in containers like vector (let target element=6)
binary_search(v.begin(), v.end(), 6); 
// return 1 or 0 as present or not
---------------------------------------------------------------------------------------------------
//binary search with lower and upper bound
int x, ans; //x is passing value, ans is a value you want, v --> vector or any container
ans = lower_bound(v.begin(), v.end(), x) - v.begin(); //>= x (equal number or first number after x)
ans = upper_bound(v.begin(), v.end(), x) - v.begin(); // > x (first number after x)
---------------------------------------------------------------------------------------------------
//Example on Binary Search() , lower_bound() and upper_bound
  
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    // Initializing vector with array values
    int arr[] = {5, 10, 15, 20, 20, 23, 42, 45};
    int n = sizeof(arr)/sizeof(arr[0]);
    vector<int> vect(arr, arr+n);
 
    // Sort the array to make sure that lower_bound()
    // and upper_bound() work.
    sort(vect.begin(), vect.end());
 
    // Returns the first occurrence of 20
    auto q = lower_bound(vect.begin(), vect.end(), 20);  //3
 
    // Returns the last occurrence of 20
    auto p = upper_bound(vect.begin(), vect.end(), 20);  //5
 
    //The lower bound is at index
    cout << q-vect.begin() << endl;  // O/P : 3
 
    // upper bound is at index
    cout << p-vect.begin() << endl;  // O/P : 5
 
    return 0;
}
--------------------------------------------------------------------------------------------------
// swap two numbers //Time Complexity: O(1)
swap(a,b);
---------------------------------------------------------------------------------------------------
// rotate containers like vector, strings by n position
rotate(v.begin(), v.begin()+n, v.end());
---------------------------------------------------------------------------------------------------
// sort arrays of size n
sort(arr, arr+n);
---------------------------------------------------------------------------------------------------
// sort containers like vector, strings(based on intro sort)
sort(v.begin(), v.end());
---------------------------------------------------------------------------------------------------
// reverse containers like vectors, strings
reverse(v.begin(), v.end());
---------------------------------------------------------------------------------------------------
//find the maximum element of a vector.
*max_element(v.begin(), v.end());
---------------------------------------------------------------------------------------------------
//find the minimum element of a vector.
*min_element(v.begin(), v.end());
---------------------------------------------------------------------------------------------------
//Does the summation of vector elements
accumulate(vect.begin(), vect.end(), 0);
---------------------------------------------------------------------------------------------------
//Example on sort(), reverse(), *max_element(), *min_element() and accumulate()
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric> //For accumulate operation
using namespace std;

int main()
{
	// Initializing vector with array values
	int arr[] = {10, 20, 5, 23 ,42 , 15};
	int n = sizeof(arr)/sizeof(arr[0]);
	vector<int> vect(arr, arr+n);

	//print Vector 
	for (int i=0; i<n; i++)
		cout << vect[i] << " ";   // O/P: 10 20 5 23 42 15

	// Sorting the Vector in Ascending order
	sort(vect.begin(), vect.end());

  	// Print Vector after sorting
	for (int i=0; i<n; i++)
	cout << vect[i] << " ";       // O/P: 10 20 5 23 42 15

	// Reversing the Vector
	reverse(vect.begin(), vect.end());

	// Print Vector after reversing
	for (int i=0; i<n; i++)
		cout << vect[i] << " ";             // O/P : 42 23 20 15 10 5 

	//Maximum element of vector
	cout << *max_element(vect.begin(), vect.end());  //42

	//Minimum element of vector
	cout << *min_element(vect.begin(), vect.end());  //5

	// Starting the summation from 0
	//The summation of vector elements
	cout << accumulate(vect.begin(), vect.end(), 0);  //115

	return 0;
}
---------------------------------------------------------------------------------------------------
// Count from first to end
count (begin(v),end(v),true);  // true or any boolean
---------------------------------------------------------------------------------------------------
// Remove all elments
v.clear();
---------------------------------------------------------------------------------------------------
//erase() in vector
//Time Complexity: O(N)
//erases selected element in vector and shifts and resizes the vector elements accordingly.
v.erase();

// Example 1: working of erase() function
#include <iostream>
#include <vector>
using namespace std;

int main()
{
	vector<int> myvector{ 1, 2, 3, 4, 5 };
	vector<int>::iterator it;

	it = myvector.begin();
	myvector.erase(it);

	// Printing the Vector
	for (auto it = myvector.begin(); it != myvector.end(); ++it)
		cout << ' ' << *it;   // O/P : 2 3 4 5
	return 0;
}
                            -----------------------------------------
                              
//Example 2: removing elements within a range
#include <iostream>
#include <vector>
using namespace std;
  
int main()
{
    vector<int> myvector{ 1, 2, 3, 4, 5 };
    vector<int>::iterator it1, it2;
  
    it1 = myvector.begin();
    it2 = myvector.end();
    it2--;
    it2--;
  
    myvector.erase(it1, it2);
  
    // Printing the Vector
    for (auto it = myvector.begin(); it != myvector.end(); ++it)
        cout << ' ' << *it;    //4 5
    return 0;
}
                            -----------------------------------------
// Example 3:  remove all the even elements from the vector and print the vector. 
#include <iostream>
#include <vector>
using namespace std;
  
int main()
{
    vector<int> myvector{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  
    for (auto i = myvector.begin(); i != myvector.end(); ++i) {
        if (*i % 2 == 0) {
            myvector.erase(i);
            i--;
        }
    }
  
    // Printing the vector
    for (auto it = myvector.begin(); it != myvector.end(); ++it)
        cout << ' ' << *it;                     // O/P : 1 3 5 7 9
    return 0;
}

---------------------------------------------------------------------------------------------------
// erase in map
#include<iostream>
#include<map> // for map operations
using namespace std;
  
int main()
{
    // declaring map
    // of char and int
    map< char, int > mp;
      
    // declaring iterators
    map<char, int>::iterator it ;
    map<char, int>::iterator it1;
    map<char, int>::iterator it2;
      
    // inserting values 
    mp['a']=5;
    mp['b']=10;
    mp['c']=15;
    mp['d']=20;
    mp['e']=30;
  
    it = mp.begin();
  
    // erasing element using iterator
    // erases 2nd element
    // 'b'
    ++it;
    mp.erase(it);
      
    // printing map elements after deletion      
    for (it1 = mp.begin(); it1!=mp.end(); ++it1)
        cout << "(" << it1->first << " : " << it1->second <<") ";
    // O/P : (a : 5) (c : 15) (d : 20) (e : 30) 
      
    // erasing element using value 
    int c = mp.erase('c');
      
    // printing map elements after deletion
    for (it1 = mp.begin(); it1!=mp.end(); ++it1)
        cout << it1->first << "->" << it1->second << endl;
    // O/P : (a : 5) (d : 20) (e : 30)
      
    //The number of elements deleted in 2nd deletion are
    cout << c << endl; // O/P : 1
      
    // erasing element using not present value 
    int d = mp.erase('w');
      
    // printing map elements after deletion      
    for (it1 = mp.begin(); it1!=mp.end(); ++it1)
        cout << it1->first << "->" << it1->second << endl;
    // O/P : (a : 5) (d : 20) (e : 30)
  
    //The number of elements deleted in 3rd deletion are
    cout << d << endl; // O/P : 0
      
    ++it;
    ++it;
      
    // erasing element using range iterator
    // deletes "d" and "e" keys
    mp.erase(it, mp.end());
      
    // printing map elements 4th deletion
    for (it1 = mp.begin(); it1!=mp.end(); ++it1)
        cout << it1->first << "->" << it1->second << endl;
    // O/P : (a : 5)  
    cout << endl;
      
}
---------------------------------------------------------------------------------------------------
//unique 
//erase (uniqe()) 
//next_permutation() 
// prev_permutation() 
// distance()
// intialize frequency container
void countFreq(int a[], int n, unordered_map<int, int> &hm) {
    // Insert elements and their
    // frequencies in hash map.
    for (int i = 0; i < n; i++)
        hm[a[i]]++;
}//O(n)

// return frequency number
int freqQuery(int x, unordered_map<int, int> hm) {
    return hm[x];
}//O(1)


int main() {
    int a[] = {1, 3, 2, 4, 2, 1};
    unordered_map<int, int> hm;  //create frequency container
    countFreq(a, 6, hm);         // intialize frequency container

    cout << freqQuery(2, hm) << endl;  // 2
    cout << freqQuery(3, hm) << endl;  // 1
    cout << freqQuery(5, hm) << endl;  // 0
}
//prefix Sum 
void pSum(ll a[], ll n, ll pSum[]) {
    pSum[0] = 0;
    for (int i = 0; i < n; i++)
        pSum[i + 1] = pSum[i] + a[i];

}//Time Complexity: O(n)

int main() {
    int n;
    cin >> n;
    ll a[n], p[n + 1];

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
  
    pSum(a, n, p);
}
---------------------------------------------------------------------------------------------------
 //to sum part of array 
 //1- choose left index (L) and right (R); 
 //2- use prefix Sum array
 prefix[R]−prefix[L−1] //prefixSum(L-1 --> R) if array based 1
prefix[R]−prefix[L] //prefixSum(L --> R)  if orginal array based 0
---------------------------------------------------------------------------------------------------  
// c++ program to create a linked list insert element at head, at tail and delete element from
// tail, head and specific key
#include <iostream>
using namespace std;
struct Node
{
public:
    int data;
    Node *next;
    Node(int data)
    {
        this->data = data;
        this->next = NULL;
    }
};
void insertAtHead(Node *&head, int data)
{
    Node *NewNode = new Node(data);
    NewNode->next = head;
    head = NewNode;
}
void insertAtTail(Node *&head, int data)
{
    Node *NewNode = new Node(data);
    if (head == NULL)
    {
        NewNode->next = head;
        head = NewNode;
        return;
    }
    Node *temp = head;
    while (temp->next != NULL)
    {
        temp = temp->next;
    }
    temp->next = NewNode;

    cout << "the value of temp next is " << temp->data << endl;
}
void insertAtKey(Node *&head, int key, int data)
{
    Node *NewNode = new Node(data);
    if (head->data == key)
    {

        NewNode->next = head->next;
        head->next = NewNode;
        return;
    }
    Node *temp = head;
    while (temp->data != key)
    {
        temp = temp->next;
        if (temp == NULL)
            return;
    }
    NewNode->next = temp->next;
    temp->next = NewNode;
}
void print(Node *&head)
{
    if (head == NULL)
    {
        cout << head->data << " ->  ";
    }
    Node *temp = head;
    while (temp != NULL)
    {
        /* code */
        cout << temp->data << " -> ";
        temp = temp->next;
    }
}

void deleteNode(Node *&head, int key)
{
    if (head == NULL)
        return;

    if (head->data == key)
    {
        Node *temp = head;
        head = head->next;
        delete temp;
    }
    deleteNode(head->next, key);
}
// recursive approach to reverse the linked list
Node *Reverse(Node *&head)
{
    if (head == NULL || head->next == NULL)
        return head;
    Node *NewHead = Reverse(head->next);
    head->next->next = head;
    head->next = NULL;
    return NewHead;
}
//this function reverse the k nodes in linked list
Node*Reversek(Node*&head,int k){
//first we have to make three node pointers

Node *prevPtr = NULL;//the prev ptr points to Null
Node *currPtr = head;//the next ptr should points toward the prev ptr because we have to reverse 
//the nodes this is possible if we point the next node towards the prev node
Node *nextptr=NULL;//we will assign the value to nextptr in the loop 
int count = 0;
while(currPtr!=NULL && count<k)
{
    nextptr = currPtr->next;
    currPtr->next = prevPtr;
    prevPtr = currPtr;
    currPtr = nextptr;
    count++;
}
if(nextptr!=NULL){
head->next = Reversek(nextptr, k);
}
return prevPtr;
}
int main()
{
    Node *head = NULL;
    cout << "insert At head" << endl;
    insertAtHead(head, 3);
    insertAtHead(head, 2);
    print(head);
    cout << endl;
    cout << "Insert at Tail " << endl;
    insertAtTail(head, 4);
    insertAtTail(head, 5);
    insertAtTail(head, 6);
    insertAtTail(head, 10);
    insertAtTail(head, 9);
    insertAtKey(head, 10, 45);
    print(head);

    deleteNode(head, 2);
    cout << "deleting the head" << endl;
    print(head);
    cout << endl;
    cout << "reversing the linked list " << endl;
    Node *NewHead = Reverse(head);
    print(NewHead);
    cout << endl;
    cout << "reversing the k nodes in linked list " << endl;
    Node *NewRev = Reversek(NewHead,2);
    print(NewRev);
}
Node*Reversek(Node*&head,int k){
//first we have to make three node pointers

Node *prevPtr = NULL;//the prev ptr points to Null
Node *currPtr = head;//the next ptr should points toward the prev ptr because we have to reverse 
//the nodes this is possible if we point the next node towards the prev node
Node *nextptr=NULL;//we will assign the value to nextptr in the loop 
int count = 0;
while(currPtr!=NULL && count<k)
{
    nextptr = currPtr->next;
    currPtr->next = prevPtr;
    prevPtr = currPtr;
    currPtr = nextptr;
    count++;
}
if(nextptr!=NULL){
head->next = Reversek(nextptr, k);
}
return prevPtr;
}
// c++ program to create a linked list insert element at head, at tail and delete element from
// tail, head and specific key
#include <iostream>
using namespace std;
struct Node
{
public:
    int data;
    Node *next;
    Node(int data)
    {
        this->data = data;
        this->next = NULL;
    }
};
void insertAtHead(Node *&head, int data)
{
    Node *NewNode = new Node(data);
    NewNode->next = head;
    head = NewNode;
}
void insertAtTail(Node *&head, int data)
{
    Node *NewNode = new Node(data);
    if (head == NULL)
    {
        NewNode->next = head;
        head = NewNode;
        return;
    }
    Node *temp = head;
    while (temp->next != NULL)
    {
        temp = temp->next;
    }
    temp->next = NewNode;

    cout << "the value of temp next is " << temp->data << endl;
}
void insertAtKey(Node *&head, int key, int data)
{
    Node *NewNode = new Node(data);
    if (head->data == key)
    {

        NewNode->next = head->next;
        head->next = NewNode;
        return;
    }
    Node *temp = head;
    while (temp->data != key)
    {
        temp = temp->next;
        if (temp == NULL)
            return;
    }
    NewNode->next = temp->next;
    temp->next = NewNode;
}
void print(Node *&head)
{
    if (head == NULL)
    {
        cout << head->data << " ->  ";
    }
    Node *temp = head;
    while (temp != NULL)
    {
        /* code */
        cout << temp->data << " -> ";
        temp = temp->next;
    }
}

void deleteNode(Node *&head, int key)
{
    if (head == NULL)
        return;

    if (head->data == key)
    {
        Node *temp = head;
        head = head->next;
        delete temp;
    }
    deleteNode(head->next, key);
}
// recursive approach to reverse the linked list
Node *Reverse(Node *&head)
{
    if (head == NULL || head->next == NULL)
        return head;
    Node *NewHead = Reverse(head->next);
    head->next->next = head;
    head->next = NULL;
    return NewHead;
}
int main()
{
    Node *head = NULL;
    cout << "insert At head" << endl;
    insertAtHead(head, 3);
    insertAtHead(head, 2);
    print(head);
    cout << endl;
    cout << "Insert at Tail " << endl;
    insertAtTail(head, 4);
    insertAtTail(head, 5);
    insertAtTail(head, 6);
    insertAtTail(head, 10);
    insertAtTail(head, 9);
    insertAtKey(head, 10, 45);
    print(head);

    deleteNode(head, 2);
    cout << "deleting the head" << endl;
    print(head);
    cout << endl;
    cout << "reversing the linked list " << endl;
    Node *NewHead = Reverse(head);

    print(NewHead);
}
Node *Reverse(Node *&head)
{
    if (head == NULL || head->next == NULL)
        return head;
    Node *NewHead = Reverse(head->next);
    head->next->next = head;
    head->next = NULL;
    return NewHead;
}
//in main the previous head becomes the last node
int main(){
  Node*newHead=Reverse(head);
  print(newhead);
}
// c++ program to create a linked list insert element at head, at tail and delete element from
// tail, head and specific key
#include <iostream>
using namespace std;
struct Node
{
public:
    int data;
    Node *next;
    Node(int data)
    {
        this->data = data;
        this->next = NULL;
    }
};
void insertAtHead(Node *&head, int data)
{
    Node *NewNode = new Node(data);
    NewNode->next = head;
    head = NewNode;
}
void insertAtTail(Node *&head, int data)
{
    Node *NewNode = new Node(data);
    if (head == NULL)
    {
        NewNode->next = head;
        head = NewNode;
        return;
    }
    Node *temp = head;
    while (temp->next != NULL)
    {
        temp = temp->next;
    }
    temp->next = NewNode;

    cout << "the value of temp next is " << temp->data << endl;
}
void insertAtKey(Node *&head, int key, int data)
{
    Node *NewNode = new Node(data);
    if (head->data == key)
    {

        NewNode->next = head->next;
        head->next = NewNode;
        return;
    }
    Node *temp = head;
    while (temp->data != key)
    {
        temp = temp->next;
        if (temp == NULL)
            return;
    }
    NewNode->next = temp->next;
    temp->next = NewNode;
}
void print(Node *&head)
{
    if (head == NULL)
    {
        cout << head->data << " ->  ";
    }
    Node *temp = head;
    while (temp != NULL)
    {
        /* code */
        cout << temp->data << " -> ";
        temp = temp->next;
    }
}

void deleteNode(Node *&head, int key)
{
    if (head == NULL)
        return;

    if (head->data == key)
    {
        Node *temp = head;
        head = head->next;
        delete temp;
    }
    deleteNode(head->next, key);
}
int main()
{
    Node *head = NULL;
    cout << "insert At head" << endl;
    insertAtHead(head, 3);
    insertAtHead(head, 2);
    print(head);
    cout << endl;
    cout << "Insert at Tail " << endl;
    insertAtTail(head, 4);
    insertAtTail(head, 5);
    insertAtTail(head, 6);
    insertAtTail(head, 10);
    insertAtTail(head, 9);
    insertAtKey(head, 10, 45);
    print(head);

    deleteNode(head, 2);
    cout << "deleting the head" << endl;
    print(head);
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a=0b101;
   int b=0b10110;
   b<<=4;        //means b=101100000 shifting of b by 4
   int c=a|b;
   int d=a&b;
   int e=a^b;
   cout<<bitset<9>(c)<<"\n";
   cout<<bitset<9>(d)<<"\n";
   cout<<bitset<10>(e)<<"\n";
   return 0;
}
class Solution {
public:
    int equalPairs(vector<vector<int>>& grid) {
        int c=0;
        int k=grid.size()-1;
        while(k>=0)
        {
       
            vector<int>vr;
            vr=grid[k];
            for(int i=0;i<grid.size();i++)
            {
                vector<int>vc;
                for(int j=0;j<grid.size();j++)
                {
                    vc.push_back(grid[j][i]);
                }
                if(vr==vc) c++;
            }
        
            k--;
        }
        return c;
    }
};
class Solution {
public:
    vector<vector<int>> fourSum(vector<int>& nums, long long int target) {
        int n=nums.size();
        set<vector<int>>s;
        sort(nums.begin(),nums.end());
        for(int i=0;i<n-3;i++)
        {
            
           for(int j=i+1;j<n-2;j++)
           {
              
               int k=j+1;
               int l=n-1;
               while(k<l)
               {
                   long long int t=0LL+nums[i]+nums[j]+nums[k]+nums[l];
                   if(t==target)
                   {
                       vector<int>v;
                       v.push_back(nums[i]);
                       v.push_back(nums[j]);
                       v.push_back(nums[k]);
                       v.push_back(nums[l]);
                       s.insert(v);
                      
                       
                   }
                   if(t>target) l--;
                   else k++;
               }
           }
        }
        vector<vector<int>>v1;
        set<vector<int>>::iterator it;
        for(it=s.begin();it!=s.end();it++)
        {
            v1.push_back(*it);
        }
        return v1;
    }
};
class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
        priority_queue<int,vector<int>,greater<int>>minH;
        for(int i=0;i<nums.size();i++)
        {
            minH.push(nums[i]);
            if(minH.size()>k)
            {
                minH.pop();
            }
        }
    return minH.top();
    }
};
class Solution{
    public:
    // arr : given array
    // l : starting index of the array i.e 0
    // r : ending index of the array i.e size-1
    // k : find kth smallest element and return using this function
    int kthSmallest(int arr[], int l, int r, int k) {
       priority_queue<int>maxpq;
       for(int i=l;i<=r;i++)
       {
           maxpq.push(arr[i]);
           if(maxpq.size()>k)
           {
              maxpq.pop();
           }
           
       }
       return maxpq.top();
        
    }
};
int flipBits(int* arr, int n) 
{  int count = 0;
   for(int i = 0; i<n; i++){
       if(arr[i] == 1){
           count++;
       }
   }
 int sum = 0;
 int max = 0;
   for(int i = 0; i<n; i++){
       if(arr[i] == 0){
         sum++;
           
       }else{
           sum--;
       }
    
       if(sum < 0){
           sum = 0;
       }
       if(sum > max){
          max = sum;
       }
   }
 
 return count + max;
}
  int e,v;
    cin>>v>>e;
    int** arr = new int*[v];
    for(int i = 0; i<v; i++){
        arr[i] = new int [v];
        for(int j = 0; j<v; j++){
            arr[i][j] = 0;
        }
    }
    int x, y;
     for(int i = 0; i<e; i++){
         cin>>x>>y;
         arr[x][y] = 1;
         arr[y][x] = 1;
     }
    
#include<iostream>
using namespace std;
struct Node {
public:
	int data;
	Node* next;
	Node(int data=0)
	{
		this->data = data;
		this->next = NULL;
	}
};
void push(Node** head_ref, int data) {
	//creating the new node and by using constructor we 
	//are storing the value of the data
	//firstly the next pointer of this new node points to NULL
	//as declared in the constructor
	//then we are pointing the pointer of this node to the new node
	//and lastly we are equating the new insert node to the previous 
	//node to connect it to the list
	Node* new_node = new Node(data);
	new_node->next =(* head_ref);
	*(head_ref) = new_node;

}
void print(Node*& head) {

	Node* temp =  head;
	while (temp != NULL)
	{
		cout << "the value of the data is " << temp->data << endl;
		temp = temp->next;
	}

}

int main() {
	Node* node;
	node = NULL;
	push(&node, 5);
	push(&node, 6);
	push(&node, 7);
	print(node);
	return 0;


}
#include<iostream>
using namespace std;
void sort(int* array, int size) {
	int key = 0, j = 0;
	for (int i = 1; i < size; i++)
	{
		key = array[i];
		j = i - 1;
		while (j >= 0 && array[j] > key)
		{
			array[j + 1] = array[j];
			j = j - 1;
		}
		array[j + 1] = key;
	}
	for (int i = 0; i < size; i++)
		cout << array[i] << "  ";
}
int main() {
	int size = 0;
	cout << "Enter size of the array " << endl;
	cin >> size;
	int* array = new int[size];
	cout << "Enter elements of the array " << endl;
	for (int i = 0; i < size; i++)
		cin >> array[i];
	sort(array, size);
}
#include<iostream>
using namespace std;
template<typename T>
T* addArray(T* array, int size);
template<typename T>
T primeNumber(T number);
template<typename T>
T Factorial(T number);
 
 
int main() {
 
	int IntNum, Size;
	float FloatNum;
	
	cout << "Enter an integer " << endl;
	cin >> IntNum;
	cout << "Enter a float number " << endl;
	cin >> FloatNum;
	cout << "Enter size of the array " << endl;
	cin >> Size;
	int* Array = new int[Size];
	cout << "Enter elements of the array " << endl;
	for (int i = 0; i < Size; i++)
		cin >> Array[i];
	addArray<>(Array, Size);
	if (primeNumber<int>(IntNum) == true);
	cout << IntNum << " is a prime number " << endl;
	if(primeNumber<int>(IntNum) == false)
		cout << IntNum << " is not  a prime number " << endl;
	cout<<"Factorial of the "<<IntNum<<" is "<<Factorial<int>(IntNum);
	
	return 0;
}
template<typename T>
T primeNumber(T number) {
	bool flag = false;
	for (int i = 2; i < number; i++)
		if (number % i == 0)
			return flag;
	flag = true;
	return true;
}
 
template<typename T>
T Factorial(T number) {
	if (number >=1)
		return number * Factorial(number - 1);
	else {
		return 1;
		
	}
		
}
 
template<typename T>
T* addArray(T* array, int size) {
	T* newarray = new int[size];
	for (int i = 0; i < size; i++)
		newarray[i] = array[i] + array[i];
	return newarray;
}
 
#include<iostream>
using namespace std;
void sets(int* array, int size);
int main() {
	int size = 0;
	cout << "Enter size of the array" << endl;
	cin >> size;
	int* array = new int[size];
	cout << "Enter elements of the array " << endl;
	for (int i = 0; i < size; i++)
		cin >> array[i];
	sets(array, size);
	return 0;
}
void sets(int* array, int size) {
	int* newarray1 = nullptr;
	int* newarray2 = nullptr;
	int median = size / 2;
	if (size % 2 == 0) {
		 newarray1 = new int[median];
		 newarray2 = new int[median];
	}
	else if (size % 2 != 0)
	{
		 newarray1 = new int[median+1];
		 newarray2 = new int[median];
	}
	//applying the insertion sort to sort the elements in ascending order
	int key;
	for (int i = 1; i < size; i++)
	{
		key = array[i];
		int j = i - 1;
		while (j>=0&&array[j]>key)
		{
			array[j + 1] = array[j];
			j = j - 1;
		}
		array[j + 1] = key;
		
	}
	for (int i = 0; i < size; i++)
				cout << array[i] << "  ";
	
	if (size % 2 == 0) {
		for (int i = 0; i < median; i++)
		{
			newarray1[i] = array[i];
		}
		for (int i = median; i < size; i++)

			newarray2[i-median] = array[i];
	}

	if (size % 2 != 0)
	{
		for (int i = 0; i < median + 1; i++)
			newarray1[i] = array[i];

		for (int j = median + 1; j < size; j++)
			newarray2[j - median + 1] = array[j];
	}

	cout << endl;
	if (size % 2 == 0) {
		for (int i = 0; i < median; i++)
		{
			cout << newarray1[i] <<  "  " << endl;
		}
		cout << endl;
		for (int i = median; i < size; i++)

			cout << newarray2[i - median] <<"  " << endl;

		cout << endl;
	}

	if (size % 2 != 0)
	{
		for (int i = 0; i < median + 1; i++)
			cout << newarray1[i] << "  "  << "  " << endl;
		cout << endl;
		for (int j = median + 1; j < size; j++)
			cout << newarray2[j - median + 1] << "   "  << endl;
	}
	


}
#include<iostream>
using namespace std;
template<typename T>
T* addArray(T* array, int size);
template<typename T>
T primeNumber(T number);
template<typename T>
T Factorial(T number);


int main() {

	int IntNum, Size;
	float FloatNum;
	
	cout << "Enter an integer " << endl;
	cin >> IntNum;
	cout << "Enter a float number " << endl;
	cin >> FloatNum;
	cout << "Enter size of the array " << endl;
	cin >> Size;
	int* Array = new int[Size];
	cout << "Enter elements of the array " << endl;
	for (int i = 0; i < Size; i++)
		cin >> Array[i];
	addArray<>(Array, Size);
	if (primeNumber<int>(IntNum) == true);
	cout << IntNum << " is a prime number " << endl;
	if(primeNumber<int>(IntNum) == false)
		cout << IntNum << " is not  a prime number " << endl;
	cout<<"Factorial of the "<<IntNum<<" is "<<Factorial<int>(IntNum);
	
	return 0;
}
template<typename T>
T primeNumber(T number) {
	bool flag = false;
	for (int i = 2; i < number; i++)
		if (number % i == 0)
			return flag;
	flag = true;
	return true;
}

template<typename T>
T Factorial(T number) {
	if (number >=1)
		return number * Factorial(number - 1);
	else {
		return 1;
		
	}
		
}

template<typename T>
T* addArray(T* array, int size) {
	T* newarray = new int[size];
	for (int i = 0; i < size; i++)
		newarray[i] = array[i] + array[i];
	return newarray;
}

#include<iostream>
using namespace std;
template<typename T>
void swap(T* xp, T* yp);
template<typename T>
void sort(T* array, int size);
template<typename T>
void print(T* array, int size);
int main() {
	int size;//for taking size of the array 
	cout << "enter size of the array " << endl;
	cin >> size;
	int* array = new int[size];
	//taking input
	cout << "Enter values of the array " << endl;
	for (int i = 0; i < size; i++)
		cin >> array[i];
	//calling sort function
	sort<int>(array, size);
	//calling print function
	print<int>(array, size);
	return 0;
}

template<typename T>
void swap(T* xp, T*yp) {
	T temp;
	temp = *xp;
	*xp = *yp;
	*yp = temp;
}
template<typename T>
void sort(T* array, int size) {

	for (int i = 0; i < size-1; i++)
	{
		for (int j = i + 1; j < size; j++) {
			if (array[i] > array[j])
				swap(&array[j], &array[i]);
			
		}
	}


}
template<typename T>
void print(T* array, int size) {
	for (int i = 0; i < size; i++)
		cout << array[i] << "  ";
}

#include<iostream>
using namespace std;
template<typename T>
void sort(T* array, int size);
template<typename T>
void swap(T* xp, T* yp);
template<typename T>
void print(T* array, int size);
int main() {
	int size;
	cout << "enter size of the array " << endl;
	cin >> size;
	int* array = new int[size];
	cout << "enter elements of the array " << endl;
	for (int i = 0; i < size; i++)
		cin >> array[i];
	sort<int>(array, size);
	print<int>(array, size);
	return 0;
}
template<typename T>
void swap(T* xp, T* yp) {
	T temp;
	temp = *xp;
	*xp = *yp;
	*yp = temp;
}
template<typename T>
void sort(T* array, int size) {
	int min_index;
	for (int i = 0; i < size-1; i++)

	{
		min_index = i;
		for (int j = i + 1; j < size; j++)
			if (array[j] < array[min_index])
				min_index = j;
		swap(&array[min_index], &array[i]);
				

	}

}
template<typename T>
void print(T* array, int size) {
	for (int i = 0; i < size; i++)
		cout << array[i] << "  ";

}
#include <iostream>
using namespace std;
int main(){
  cout << "Print data" << endl;
  cerr << "Print error" << endl;
  clog << "Print log" << endl;
  int nilai;
  cin >> nilai;
  cout << "Nilai: " << nilai << endl;
  return 0;
}
/* Ini adalah program C++
untuk menampilkan Hello World di layar */

#include<iostream> 		// File header yang berisi fungsi untuk operasi i/o (input/output)
using namespace std; 		// Namespace
int main(){ 			// Eksekusi program dimulai dari sini
  cout << "Hello World" << endl;// Ini akan mencetak Hello World di layar
  int nilai = 97;		// variabel
  cout << nilai << endl;	// Ini akan mencetak 97 di layar
  return 0; 			// Eksekusi program berhasil
}
class Solution
{
    public:
    //Function to check if two trees are identical.
    bool isIdentical(Node *r1, Node *r2)
    {
        if(r1==NULL && r2==NULL) return 1;
        if(r1!=NULL && r2!=NULL)
        { return
          (r1->data==r2->data 
          && isIdentical(r1->left,r2->left) 
          && isIdentical(r1->right,r2->right));
        }
        return 0;
        //Your Code here
    }
};
class Solution {
  public:
  int height(Node* temp)
  {
      if(temp==NULL)
      return 0;
      int lh= height(temp->left);
      int rh=height(temp->right);
      
      return 1+max(lh,rh);
  }
    // Function to return the diameter of a Binary Tree.
    int diameter(Node* root) {
        if(root==NULL) return 0;
        int lh=height(root->left);
        int rh=height(root->right);
        
        int ld=diameter(root->left);
        int rd=diameter(root->right);
        
        return max(lh+rh+1,max(ld,rd));
        // Your code here
    }
};
class Solution{
    public:
    int height(Node * temp)
    {
        if(temp==NULL) return 0;
        int lh=height(temp->left);
        int rh=height(temp->right);
        return 1+max(lh,rh);
    }
    //Function to check whether a binary tree is balanced or not.
    bool isBalanced(Node *root)
    {
        
        if(root==NULL) return 1;
        int lh=height(root->left);
        int rh=height(root->right);
        if(abs(lh-rh)<=1 && isBalanced(root->left) && isBalanced(root->right)) return 1;
        return 0;
        //  Your Code here
    }
};
class Solution{
    public:
    //Function to find the height of a binary tree.
    int depth(Node* temp)
    {
        if(temp==NULL) return 0;
        int lh=depth(temp->left);
        int rh=depth(temp->right);
        return 1+max(lh,rh);
    }
    int height(struct Node* node){
         int ans=depth(node);
         return ans;
        // code here 
    }
};
#include <bits/stdc++.h>
using namespace std;

class node
{
    public:
    int data;
    node *left,*right;
    
    node(int d)
    {
        this->data=d;
        this->left=NULL;
        this->left=NULL;
    }
};

void deletetree(node* temp)
{
    if(temp==NULL)
    return;
    deletetree(temp->left);
    deletetree(temp->right);
    cout << "\n Deleting node: " << temp->data;
    delete temp;
}
int main() {
    node *root=new node(6);
    root->left=new node(8);
    root->right=new node(7);
    root->left->left=new node(5);
    root->left->right=new node(2);
    root->right->left=new node(8);
    root->right->right=new node(3);
    deletetree(root);
    root=NULL;
    
    cout << "\n Tree deleted ";
	return 0;
}
// Balanced Bracket Problem Method2.

#include<bits/stdc++.h>
using namespace std ;


bool isBalanced(string str)
{
    map<char, int> m ;
    m['('] = -1 ; m['{'] = -2 ; m['['] = -3 ; m[')'] = 1 ; m['}'] = 2 ; m[']'] = 3 ; 
    stack<int> s; 
    for(int i=0; i<str.length(); i++){
        if(m[str[i]] < 0) s.push(m[str[i]]) ;
        else {
            if(s.empty()) return false ;
            else if(m[str[i]]+s.top() != 0) return false ;
            else s.pop() ;
        }
    }
    return (s.empty()) ;
}

int main()
{
    string s ; cin >> s ;
    cout << isBalanced(s) << endl ;
    
    
    return 0 ;
}
// Balanced Bracket Problem 

#include<bits/stdc++.h>
using namespace std ;

bool matching(char a, char b)
{
    return ((a == '(' and b == ')') ||
            (a == '{' and b == '}') ||
            (a == '[' and b == ']')  ) ;
}

bool isBalanced(string str)
{
    stack<int> s; 
    for(int i=0; i<str.length(); i++){
        if(str[i] == '(' or str[i] == '{' or str[i] == '[')
        s.push(str[i]) ;
        else {
            if(s.empty()) return false ;
            else if(!matching(s.top(), str[i])) return false ;
            else s.pop() ;
        }
    }
    return (s.empty()) ;
}

int main()
{
    string s ; cin >> s ;
    cout << isBalanced(s) << endl ;
    
    
    return 0 ;
}
// [ 1 0 1 1 1 0 0 ]  => [ 1 -1 1 1 1 -1 -1 ]
// Longest Subarray for sum = 0  
// longest Subarray with equal number of zeros and one 

#include<bits/stdc++.h>
using namespace std ;

int marLen(int a[], int n)
{
    unordered_map<int, int> m ; vector <int> v ; 
    int pre_sum = 0 ; int res = 0 ; cout << "res = " ;
    for(int i=0; i<n; i++){
        pre_sum += a[i] ; v.push_back(pre_sum) ; 
        if(pre_sum == 0) res = i+1 ;
        
        if(m.find(pre_sum) == m.end())
        m.insert(make_pair(pre_sum, i)) ;
        
        if(m.find(pre_sum) != m.end())
        res = max(res, i-m[pre_sum]) ;
        
        cout << res << " " ;
    } cout << endl ;
    for(int x : v) cout << x << "  " ;
    cout << endl ;
    return res ;
}

int main()
{
    
    int n ; cin >> n ; int a[n] = {0} ;
    for(int i=0; i<n; i++) cin >> a[i] ;
    for(int i=0; i<n; i++){
        if(!a[i]) a[i] = -1 ;
    }
    cout << marLen(a, n) << endl ;
    
    return 0 ;
}

/* Input -- 7
            1 0 1 1 1 0 0
            
            res = 0 2 2 2 2 2 6 
            1  0  1  2  3  2  1  
            6
*/

// Longest Subarray with equal number of 0s and 1s
// Naive Solution 

#include<bits/stdc++.h>
using namespace std ;

int longestSub(int a[], int n)
{
    int res = 0 ; //cout << "max = " ; //int x = 0 ; int y = 0 ;
    for(int i=0; i<n; i++){
        int c0 = 0 ; int c1 = 0 ;
        for(int j=i; j<n; j++){
            if(a[j] == 0) c0++ ;
            else c1++ ;
            
            if(c0 == c1) res = max(res, j-i+1) ;
        }
        //x = c0 ; y = c1 ;
        //cout << res << " " ;
    }
    //cout << endl ; cout << "c0 = " << x << " c1 = " << y << endl ;
    return res ;
}

int main()
{
    int n ; cin >> n ; int a[n] = {0} ;
    for(int i=0; i<n; i++) cin >> a[i] ;
    
    cout << longestSub(a, n) << endl ;
    
    return 0 ;
}
// Longest Subarray for given sum   

#include<bits/stdc++.h>
using namespace std ;

int marLen(int a[], int n, int sum)
{
    unordered_map<int, int> m ; vector <int> v ; vector <int> v1 ;
    int pre_sum = 0 ; int res = 0 ; cout << "res = " ;
    for(int i=0; i<n; i++){
        pre_sum += a[i] ; v.push_back(pre_sum) ; v1.push_back(pre_sum - sum) ; 
        if(pre_sum == sum) res = i+1 ;
        
        if(m.find(pre_sum) == m.end())
        m.insert(make_pair(pre_sum, i)) ;
        
        if(m.find(pre_sum-sum) != m.end())
        res = max(res, i-m[pre_sum-sum]) ;
        
        cout << res << " " ;
    } cout << endl ;
    for(int x : v) cout << x << "  " ;
    cout << endl ;
    for(int x : v1) cout << x << "  " ;
    cout << endl ;
    return res ;
}

int main()
{
    
    int n ; cin >> n ; int a[n] = {0} ;
    int sum ; cin >> sum ;
    for(int i=0; i<n; i++) cin >> a[i] ;
    
    cout << marLen(a, n, sum) << endl ;
    
    return 0 ;
}

/* Input -- 8 4
            8 3 1 5 -6 6 2 2
            
    Output -- 
    res = 0 0 2 2 2 2 2 4 
    8  11  12  17  11  17  19  21  
    4  7  8  13  7  13  15  17  
    4
    
*/

// Subarray sum Problem  

#include<bits/stdc++.h>
using namespace std ;

bool isSumSubarray(int a[], int n, int sum)
{
    unordered_set<int> s ; //cout << "sum = " << sum << endl ;
    int pre_sum = 0 ;
    for(int i=0; i<n; i++){
        
        pre_sum += a[i] ;
        if(pre_sum == sum) return true ;
        if(s.find(pre_sum - sum) != s.end()) return true ;
        s.insert(pre_sum) ;
    }
    return false ;
}

int main()
{
    
    int n ; cin >> n ; int a[n] = {0} ;
    int sum ; cin >> sum ;
    for(int i=0; i<n; i++) cin >> a[i] ;
    
    bool ans = isSumSubarray(a, n, sum) ;
    cout << ans << endl ;
    
    return 0 ;
}
// Subarray with zero sum array (distinct) 
// [ -3,  4,  -3,  -1,  1  ]
//    a0, a1, .... ai-1,  ai, ai+1  .....  aj 
//    <-PreSum1.....->    <-....Sum[i:j]...->
//    <-............PreSum2................->   
// if Sum[i:j] = 0 , PreSum1 = PreSum2  

#include<bits/stdc++.h>
using namespace std ;

bool isZeroSubarray(int a[], int n)
{
    bool ans = false ;   vector<int> pre ;
    unordered_set<int> h ;
    int pre_sum = 0 ;  int x = 0 ; int y = 0 ;
    for(int i=0; i<n; i++){
        pre_sum += a[i] ;  pre.push_back(pre_sum) ;
        //cout << pre_sum << "  " ;
        if(h.find(pre_sum) != h.end()){
            auto it = h.find(pre_sum) ; x = *it ; y = i ;
            ans = true ; break ;
        }
        if(pre_sum == 0) {
            ans = true ; break ;
        } 
        h.insert(pre_sum) ;
    }
    cout << "x = " << x << "y = " << y << endl ;
    for(auto a : pre) cout << a << "  " ;
    cout << endl ;
    for(int i =x; i<=y; i++) cout << a[i] << "  " ;
    //cout << endl ;
    return ans ;
    
}

int main()
{
    
    int n ; cin >> n ; int a[n] = {0} ;
    for(int i=0; i<n; i++) cin >> a[i] ;
    
    bool ans = isZeroSubarray(a, n) ;
    cout << endl << ans << endl ;
    
    return 0 ;
}
// { Driver Code Starts
// C program to find n'th Node in linked list
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
using namespace std;

/* Link list Node */
struct Node {
  int data;
  struct Node *next;
  Node(int x) {
    data = x;
    next = NULL;
  }
};


/* Function to get the nth node from the last of a linked list*/
int getNthFromLast(struct Node* head, int n);



/* Driver program to test above function*/
int main()
{
  int T,i,n,l,k;

    cin>>T;

    while(T--){
    struct Node *head = NULL,  *tail = NULL;

        cin>>n>>k;
        int firstdata;
        cin>>firstdata;
        head = new Node(firstdata);
        tail = head;
        for(i=1;i<n;i++)
        {
            cin>>l;
            tail->next = new Node(l);
            tail = tail->next;
        }

    cout<<getNthFromLast(head, k)<<endl;
    }
    return 0;
}// } Driver Code Ends


/* struct Node {
  int data;
  struct Node *next;
  Node(int x) {
    data = x;
    next = NULL;
  }
};
*/

//Function to find the data of nth node from the end of a linked list.
int getNthFromLast(Node *head, int n)
{
       // Your code here
    int count=0;
    Node* i=head;
    Node* t=head;
    while(i!=NULL)
    {
        count++;
        i=i->next;
    }
    int c=1;
    if(n>count ) return -1;
    count = count-n;
    for(int k=0;k<count;k++)
    t=t->next;
    return t->data;
  
}

data_type *var_name = 
       reinterpret_cast <data_type *>(pointer_variable);
class Solution{
    public:
    //Function to find if there exists a triplet in the 
    //array A[] which sums up to X.
    bool find3Numbers(int A[], int n, int X)
    {
        //Your Code Here
         int j;
    int k;
    //Your Code Here
    sort(A,A+n);
    for(int i=0;i<n-2;i++)
    {
       j=i+1;
       k=n-1;
       while(j<k)
       {
         if(A[i]+A[j]+A[k]==X) return 1;
         if(A[i]+A[j]+A[k]>X) k--;
         else j++;
       }
    }
    return 0;
    }

};
vector<vector<int> > Solution::threeSum(vector<int> &A) {
    vector<int>v1;
    set<vector<int>>s;
    int n=A.size();
    sort(A.begin(),A.end());
    for(int i=0;i<n-2;i++)
    {
        int j=i+1;
        int k=n-1;
        while(j<k)
        {  
            long long sum = 0LL+A[i]+A[j]+A[k];
            if(sum==0)
            {
            v1.push_back(A[i]);
            v1.push_back(A[j]);
            v1.push_back(A[k]);
            s.insert(v1);
            v1.clear();
            }
            if(A[i]+A[j]+A[k]<0) j++;
            else k--; 
        }
        
    }
    vector<vector<int>>v2(s.begin(),s.end());
    return v2;
}
#include <bits/stdc++.h>
using namespace std;

class base
{
   public:
   int x;
   void show()
   {
      cout<<x<<"\n";
   }
};

class derived:public base       //Inheritance
{
   public:
   int y;
   
   void display()
   {
      cout<<x<<" "<<y<<"\n";
   }
};
int main()
{
	base b;
	b.x=4;
	b.show();
	derived d;
	d.x=10;
	d.y=5;
	d.show();
	d.display();
	
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

class Complex
{
   public:
    int real;
    int img;
   
   Complex(int r=0,int i=0)
   {
      real=r;
      img=i;
   }
   friend Complex operator+(Complex c1,Complex c2);  //friend 
   void display()                          //operator overloading
   {
      
   }
};
Complex operator+(Complex c1,Complex c2)  //operator overloading
    {
      Complex temp;
      temp.real=c1.real+c2.real;
      temp.img=c1.img+c2.img;
      return temp;
    }
int main()
{
   Complex c1(2,5),c2(3,5),c3;
   
   c3=c1+c2;
   cout<<c3.real<<"+i"<<c3.img<<endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

class Complex
{
   public:
    int real;
    int img;
   
   Complex(int r=0,int i=0)
   {
      real=r;
      img=i;
   }
   Complex operator+(Complex c)  //operator overloading or
    {                            //(Complex add(Complex c)
      Complex temp;
      temp.real=real+c.real;
      temp.img=img+c.img;
      return temp;
    }
};
int main()
{
   Complex c1(2,5),c2(3,5),c3;
   
   c3=c1+c2;                     // or c3=c1.add(c2);
   cout<<c3.real<<"+i"<<c3.img<<endl;
	return 0;
}
//There have 3 constructors with same name called overloading
                  

#include <bits/stdc++.h>
using namespace std;
class rectangle             //class
{
   private:
   int length;
   int breadth;
   public:
   
   rectangle()              //non-parameterised constructor
   {
      length=5;
      breadth=4;
   }
   rectagle(int l=5,int b)        //parameterised constructor
   {
      setLength(l);
      setBreadth(b);
   }
   rectangle(rectangle &r)       //copy constructor
   {
      length=r.length;
      breadth=r.breadth;
   }
   void setLength(int l)
   {
      if(l>0) length=l;
      else length=1;
   }
   void setBreadth(int b)
   {
      if(b>0) breadth=b;
      else breadth=1;
   }
   int getLength()
   {
      return length;
   }
   int getBreadth();     //Define outside class with scope resolution

   int area()
   {
      return length*breadth;
   }
   int perimeter();      //Define outside class with scope resolution
};

int rectangle::perimeter()   //Define outside class with scope            {                                    // resolution
      return 2*(length+breadth);
     }
                            
  
int rectangle::getBreadth()   //Define outside class with scope          {                                  //resolution
      return breadth;
   }

int main()
{
rectangle r1;                 //object r1
r1.setLength(15);
r1.setBreadth(2);
rectangle r2(r1);             //object r2
cout<<r1.area()<<"\n";
cout<<r1.perimeter()<<"\n";
cout<<r2.perimeter()<<"\n";
	return 0;
}
class Solution {
public:
    string convertToTitle(int n) {
        string result="";
        while(n){
            char c='A'+(n-1)%26;
            result=c+result;
            n=(n-1)/26;
        }
        return result;
    }
};
class Solution {
public:
    int titleToNumber(string columnTitle) {
        int sum=0;
        
        int n=columnTitle.size();
        for(int i=0;i<n-1;i++)
        {
            sum=sum+pow(26,(n-i-1))*(columnTitle[i]-'A'+1);
        }
        sum=sum+(columnTitle[n-1]-'A'+1);
        return sum;
    }
};
class Solution {
public:
    bool isPalindrome(int x) {
        string s1=to_string(x);
      string s=to_string(x);
        int n=s.length();
        for(int i=0;i<n/2;i++)
        {
            swap(s[i],s[n-1-i]);
        }
        if(s1==s) return true;
        else return false;
    }
};
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int j=0;
        for(int i=0;i<nums.size();i++)
        {
            if(nums[i]!=0) 
            {
                nums[j]=nums[i];
                j++;
            }
        }
        for(int i=j+1;j<nums.size();j++)
        {
            nums[j]=0;
        }
    }
};
int mxl[size];
int mxr[size];
mxl[0]=arr[0];
for(int i=1;i<size;i++)
  {
    mxl[i]=max(mal[i-1],arr[i]);
  }
mxr[size-1]=arr[size-1];
for(int i=size-2;i>=0;i--)
  {
    mxr[i]=max(mxr[i+1],arr[i])
  }
int water[size];
for(int i=0;i<size;i++)
  water[i]=min(mxl[i],mxr[i])-arr[i];
int sum=0;
for(int i=0;i<size;i++)
  sum=sum+water[i];
return sum;
//input arr[n][m];

vector<int>v;
for(int j=0;j<m;j++)
  v.push_back(arr[0][j])
int max=MAH(v);

for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
      {
        if(arr[i][j]==0)
          v[j]=0;
        else v[j]=v[j]+arr[i][j];
      }
    max=max(max,MAH(V));
  }
return max;            //final answer

            //MAH FUNCTION
vector<int>left;
stack<pair<int,int>>s;
int pseudo_index=-1;
for(int i=0;i<n;i++)
  {
    if(s.size()==0)
      {
        left.push_back(pseudo_index);
      }
    else if(s.size()>0 && s.top().first<arr[i])
      {
        left.push_back(s.top());
      }
    else if(s.size()>0 && s.top().first>=arr[i])
      {
        while(s.size()>0 && s.top().fisrt>=arr[i])
          {
            s.pop();
          }
        if(s.size()==0)
          left.push_back(s.top().second);
      }
    s.push(arr[i];)
  }
return left;               //NSL completed

vector<int>right;          //NSR doing
stack<pair<int,int>>s2;
int pseudo_index=7;
for(int i=size-1;i>=0;i--)
  {
    if(s2.size()==0)
      {
        right.push_back(pseudo_index);
      }
    else if(s2.size()>0 && s2.top().first<arr[i])
      {
        right.push_back(s.top());
      }
    else if(s2.size()>0 && s2.top().first>=arr[i])
      {
        while(s2.size()>0 && s2.top().fisrt>=arr[i])
          {
            s2.pop();
          }
        if(s2.size()==0)
          right.push_back(s2.top().second);
      }
    s2.push(arr[i];)
  }
reverse (right.begin(),right.end());
return right;           //NSR completed
 

for(int i=0;i<size;i++)
  {
    width[i]=right[i]-left[i]-1;
  }
for(int i=0;i<size;i++){
  area[i]=arr[i]*width[i];
}
return max of area[i];       //MAH FINAL VALUE
vector<int>left;
stack<pair<int,int>>s;
int pseudo_index=-1;
for(int i=0;i<n;i++)
  {
    if(s.size()==0)
      {
        left.push_back(pseudo_index);
      }
    else if(s.size()>0 && s.top().first<arr[i])
      {
        left.push_back(s.top());
      }
    else if(s.size()>0 && s.top().first>=arr[i])
      {
        while(s.size()>0 && s.top().fisrt>=arr[i])
          {
            s.pop();
          }
        if(s.size()==0)
          left.push_back(s.top().second);
      }
    s.push(arr[i];)
  }
return left;               //NSL completed

vector<int>right;          //NSR doing
stack<pair<int,int>>s2;
int pseudo_index=7;
for(int i=size-1;i>=0;i--)
  {
    if(s2.size()==0)
      {
        right.push_back(pseudo_index);
      }
    else if(s2.size()>0 && s2.top().first<arr[i])
      {
        right.push_back(s.top());
      }
    else if(s2.size()>0 && s2.top().first>=arr[i])
      {
        while(s2.size()>0 && s2.top().fisrt>=arr[i])
          {
            s2.pop();
          }
        if(s2.size()==0)
          right.push_back(s2.top().second);
      }
    s2.push(arr[i];)
  }
reverse (right.begin(),right.end());
return right;           //NSR completed
 

for(int i=0;i<size;i++)
  {
    width[i]=right[i]-left[i]-1;
  }
for(int i=0;i<size;i++){
  area[i]=arr[i]*width[i];
}
return max of area[i];       //final answer
vector<int> v;
stack<pair<int,int>> s;        //first is ngl and second is its index
for(int i=0;i<size;i++)
  {
    if(s.size()==0)
      {
        v.push_back(-1);
      }
    else if(s.size()>0 && s.top().first<=arr[i])
      {
        v.push_back(s.top().second)
      }
    else if(s.size()>0 && s.top().first<=arr[i])
      {
        while(s.size()>0 && s.top().first<=arr[i])
          {
            s.pop();
          }
        if(s.size()==0)
          v.push_back(-1);
        else v.push_back(s.top().second)
      }
    s.push({arr[i],i});
  }
  return v;                         //NGL we got

for(int i=0;i<v.size();i++)
  {
    v[i]=i-v[i];
  }
return v;                           //final answer
vector<int>v;
stack<int>s;

for(int i=size-1;i>=0;i--)
{
   if(s.size()==0)
   {
      v.push_back(-1);
   }
   else if(s.size()>0&&s.top()<arr[i])
   {
      v.push_back(s.top())
   }
   else if(s.size()>0&&s.top()>=arr[i])
   {
      while(s.size()>0&&s.top>=arr[i])
      {
         s.pop();
      }
      if(s.size()==0)
      {
         v.push_back(-1);
      }
      else{
         v.push_back(s.top());
      }
   }
   s.push(arr[i]);
}
reverse(v.begin(),v.end());
vector<int>v;
stack<int>s;

for(int i=0;i<n;i++)
{
   if(s.size()==0)
   {
      v.push_back(-1);
   }
   else if(s.size()>0&&s.top()<arr[i])
   {
      v.push_back(s.top())
   }
   else if(s.size()>0&&s.top()>=arr[i])
   {
      while(s.size()>0&&s.top>=arr[i])
      {
         s.pop();
      }
      if(s.size()==0)
      {
         v.push_back(-1);
      }
      else{
         v.push_back(s.top());
      }
   }
   s.push(arr[i]);
}
vector<int>v;
stack<int>s;

for(int i=0;i<n;i++)
{
   if(s.size()==0)
   {
      v.push_back(-1);
   }
   else if(s.size()>0&&s.top()>arr[i])
   {
      v.push_back(s.top())
   }
   else if(s.size()>0&&s.top()<=arr[i])
   {
      while(s.size()>0&&s.top<=arr[i])
      {
         s.pop();
      }
      if(s.size()==0)
      {
         v.push_back(-1);
      }
      else{
         v.push_back(s.top());
      }
   }
   s.push(arr[i]);
}
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    void deleteNode(ListNode* node) {
       ListNode* temp;
        node->val=node->next->val;
        temp=node->next->next;
        delete(node->next);
        node->next=temp;
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* middleNode(ListNode* head) {
        int count=0;
        ListNode *i=head;
        
        while(i!=NULL)
        {
            count++;
            i=i->next;
        }
        for(int i=0;i<count/2;i++)
        {
            head=head->next;
        }
        return head;
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    int getDecimalValue(ListNode* head) 
    {
Method 1;
       int count=0;
       int sum=0;
       ListNode *temp=head;
       while(temp!=NULL)
       {
           count++;
               temp=temp->next;
       }
        ListNode *temp2=head;
        while(temp2!=NULL)
        {
            sum+= temp2->val*pow(2,(count-1));
            temp2=temp2->next;
            count--;
        }
        return sum;
Method 2;
        int ans = 0;
        while(head)
        {
            ans = ans*2+head->val;
            head = head->next;
        }
        return ans;
    }
};
class Solution {
public:
    int getDecimalValue(ListNode* head) {
      ListNode* temp=head;
        int sum=0;
        int count =0;
        while(temp!=NULL)
        {
          count++;
          temp=temp->next;
        }
         ListNode* temp2=head;
        while(temp2!=NULL)
        {
            if(temp2->val==1)
            {
              sum+=(pow(2,count-1));
            }
            temp2=temp2->next;
            count--;
        }   
          return sum;
    }
};
vector<int>v;
stack<int>s;

for(int i=size-1;i>=0;i--)
{
   if(s.size()==0)
   {
      v.push_back(-1);
   }
   else if(s.size()>0&&s.top()>arr[i])
   {
      v.push_back(s.top())
   }
   else if(s.size()>0&&s.top()<=arr[i])
   {
      while(s.size()>0&&s.top<=arr[i])
      {
         s.pop();
      }
      if(s.size()==0)
      {
         v.push_back(-1);
      }
      else{
         v.push_back(s.top());
      }
   }
   s.push(arr[i]);
}
reverse(v.begin(),v.end());
class Solution
{
public:
void f(int i, vector<int> &a,
       int n,int sum,
       vector<int> &v,vector<int> &vv)
{
    if(i == n)
    {
        vv.push_back(sum);
        return;
    }
    f(i+1,a,n,sum+a[i],v,vv);
    f(i+1,a,n,sum,v,vv);
}
    vector<int> subsetSums(vector<int> arr, int n)
    {
        vector<int> v;
        vector<int> vv;
        f(0,arr,n,0,v,vv);
        sort(vv.begin(),vv.end());
        return vv;
    }
};
class Solution {
public:
    
    void f(int i,vector<int>&c, int k, 
           vector<int> &v,int sum,
           vector<vector<int>> &m)
    {
        if(i == c.size())
        {
            if(k == 0)
                m.push_back(v);
            return;
        }
        if(c[i] <= k)
        {
            v.push_back(c[i]);
            f(i,c,k-c[i],v,sum,m);
            v.pop_back();
        }
        f(i+1,c,k,v,sum,m);
    }
    vector<vector<int>> 
    combinationSum(vector<int>& c, int k)
    {
        vector<int> v;
        vector<vector<int>> m;
        f(0,c,k,v,0,m);
        return m;
    }
};
#include <bits/stdc++.h>
using namespace std;

struct node
{
   struct node* prev;
   int data;
   struct node* next;
   
}*first=NULL;
void create(int a[],int n)
{
   struct node *t,*last;
   int i;
   first=new node;
   first->data=a[0];
   first->prev=first->next=NULL;
   last=first;
   
   for(i=0;i<n;i++)
   {
      t=new node;
      t->data=a[i];
      t->next=last->next;
      t->prev=last;
      last->next=t;
      last=t;
   }
}

int lenth(struct node *p)
{
   int len=0;
   
   while(p)
   {
      len++;
      p=p->next;
   }
   return len;
}
int main()
{
	int a[]={10,20,30,40,50};
	create(a,5);
	cout<<length(first);
	display(first);
	return 0;
}
class Solution{
public:	
	// Function to check if array has 2 elements
	// whose sum is equal to the given value
	bool hasArrayTwoCandidates(int arr[], int n, int x) {
	    sort(arr,arr+n);
	    int i=0,j=n-1;
	    while(i<j)
	    {
	      if(arr[i]+arr[j]==x)
	      return 1;
	      if(arr[i]+arr[j]>x)
	      j--;
	      if(arr[i]+arr[j]<x)
	      i++;
	    }
	    return 0;
	    
	    // code here
	}
};
void deleteNode(Node *ptr)
{
 //creating temporary pointer
 Node *temp;
  //Pointing temp to link part of current node i.e. next node
 temp=ptr->next;
 //copy data and link part of next node to current node
 ptr->data=temp->data;
 //point current node to link part of next node
 ptr->next=temp->next;
 //Delete current node
 free(temp);

}
int findLoop (Node *head)
{
Node *slow, *fast;
slow=head;
fast=head;
 while (fast!=NULL && fast->next!=NULL )
 {
 fast= fast->next->next;
 slow = slow->next;
  if (slow ==  fast)
  {
  return 1;   //loop found
  }
 }
return 0;      //No loop, reached end of list
#include <iostream>
using namespace std;

//Creating Node Structure
struct Node{
 int data;
 Node *link;
};

Node *head=NULL;

//Function to reverse linked list
void reverseList()
{
Node *p,*c,*n;
p=NULL;
c=head;
while(c!=NULL)
{

 n=c->link;
 c->link=p;
 p=c;
 c=n;
}
head=p;
}

//Function to insert at the end of linked list
void insertEnd (int d)
{

 Node *ptr = new Node();
 ptr->data=d;
 ptr->link=NULL;

 if(head==NULL)
 head=ptr;
 else
 {
  Node *temp = head;
  while(temp->link != NULL)
  {
   temp=temp->link;
  }
  temp->link=ptr;

 }

}

//Function to display linked list
void displayList()
{
 Node *ptr=head;
 while(ptr!=NULL)
 {
  cout<<ptr->data<<" ";
  ptr=ptr->link;
 }
 cout<<"\n";
}

//Main Function
int main()
{
 insertEnd(1);
 insertEnd(2);
 insertEnd(3);
 insertEnd(4);
 insertEnd(5);

 displayList();
 reverseList();
 displayList();
 return 0;
}
#include <iostream>
using namespace std;

//Creating Node Structure
struct Node{
 int data;
 Node *link;
};
//creating head pointer and equating to NULL
Node *head=NULL;

//Function to Display middle element
void showMid()
{
  Node *slow=head;
  Node *fast=head;

  if(head==NULL)
   cout<<"List is Empty";
  else
  {
   while(fast!=NULL && fast->link!=NULL)
   {
    slow=slow->link;
    fast=fast->link->link;
   }
   cout<<"Middle element is:"<<slow->data;
  }

}

//Function to insert at the end of linked list
void insertEnd (int d)
{

 Node *ptr = new Node();
 ptr->data=d;
 ptr->link=NULL;

 if(head==NULL)
 head=ptr;
 else
 {
  Node *temp = head;
  while(temp->link != NULL)
  {
   temp=temp->link;
  }
  temp->link=ptr;

 }

}

//Main Function
int main()
{
 insertEnd(2);
 insertEnd(9);
 insertEnd(1);
 insertEnd(3);
 insertEnd(7);

 showMid();
 return 0;
}
struct node
{
    int data;
    node* next;
};
node* head=NULL;

void deleteend()
{
    node *ptr,*prev;
    if(head==NULL)                 //empty list
    cout<<"list empty";
    else
    if(head->next==NULL)          //only one node in list
    {
        ptr=head;
        head=NULL;
        free(ptr);
    }
    else{                            //more than one node
        ptr=head;
        while(ptr->next!=NULL)
        {
            prev=ptr;
            ptr=ptr->next;
        }
        prev->next=NULL;
        free(ptr);
    }
}
struct node
{
    int data;
    node* next;
};
node* head=NULL;

void deleteheadnode()
{
    if(head==NULL)
    cout<<"List Empty";
    else
    {
        node* ptr=head;
        head=head->next;
        free(ptr);
    }
}
#include "SteamLibrary.h";

string userName;
string passWord;

string userA = "";
string userB = "";
string userC = "";
string userD = "";
string userE = "";

string passA = "";
string passB = "";
string passC = "";
string passD = "";
string passE = "";

string loginUserInfo[5] = { userA, userB, userC, userD, userE };
string loginPassInfo[5] = { passA, passB, passC, passD, passE };

steamLibrary sl;

int main()
{
	sl.loginPage();
}

void steamLibrary :: loginPage()
{
	string loginInput;

	cout << "Login page\nA) Login\nB) Signup\n";
	cin >> loginInput;

	if (loginInput == "A")
	{
		sl.login();
	}
	if (loginInput == "B")
	{
		sl.signup();
	}
	else if (loginInput != "A" || loginInput != "B")
	{
		cout << "Please answer with either A or B\n";
		sl.loginPage();
	}
}

void steamLibrary :: login()
{
	cout << "Please enter your Username\n";
	cin >> userName;
	cout << "Please enter your Password\n";
	cin >> passWord;

	for (int i = 0; i < 5; i++)
	{
		if (userName == loginUserInfo[i])
		{
			if (passWord == loginPassInfo[i])
			{
				sl.libraryInput();
			}
			else
			{
				cout << "Please try again\n";
				sl.loginPage();
			}
		}
		else
		{
			cout << "Please try again\n";
			sl.loginPage();
		}
	}
}

void steamLibrary :: signup()
{
	if (loginUserInfo[4] != "")
	{
		cout << "There are too many accounts at this time, please try again later or login\n";
		sl.loginPage();
	}

	cout << "Please create a new Username\n";
	cin >> userName;
	for (int i = 0; i < 5; i++)
	{
		if (userName == loginUserInfo[i])
		{
			cout << "Sorry but that is taken\n";
			sl.login();
		}
	}

	for (int o = 0; o < 5; o++)
	{
		if (loginUserInfo[o] == "")
		{
			loginUserInfo[o] = userName;

			cout << "Please create a Password\n";
			cin >> loginPassInfo[o];

			sl.loginPage();
			o = 6;
		}
	}
}

void steamLibrary :: libraryInput()
{
	string libraryInput;

	cout << "Welocme to the your Game Library\nWould you like to A)Sign out or B)Go to your Game Library?\n";
	cin >> libraryInput;

	if (libraryInput == "A")
	{
		sl.loginPage();
	}
	if (libraryInput == "B")
	{
		sl.gameLibrary();
	}
	else if (libraryInput != "A" || libraryInput != "B")
	{
		cout << "Please answer with either A or B\n";
		sl.libraryInput();
	}
}

void steamLibrary :: gameLibrary()
{
	string gameChoice;

	cout << "Game Library\nWould you like to view...\nA)Buba-G\nB)Two weeks\nor C)SUWI\n...and if you are done here type D to leave.";
	cin >> gameChoice;

	if (gameChoice == "A")
	{
		sl.bubaG();
	}
	if (gameChoice == "B")
	{
		sl.twoWeeks();
	}
	if (gameChoice == "C")
	{
		sl.suwi();
	}
	if (gameChoice == "D")
	{
		sl.libraryInput();
	}
	else if (gameChoice != "A" || gameChoice != "B" || gameChoice != "C" || gameChoice != "D")
	{
		cout << "Please answer with either A, B or C\n";
		sl.gameLibrary();
	}
}

void steamLibrary :: bubaG()
{
	string libraryReturn;

	cout << "Buba-G:\n	-This all new Battleroyal released by Mysterious People, is a realistic shooter in a Player vs Player environment where the only objective is to win\n	-The age rating of this game is 18\n	-Currently the only two playable characters are Jack the crack and Lord Lynham, but we all know who is the best...\n If you want to return to the Library please type A";
	cin >> libraryReturn;

	if (libraryReturn == "A")
	{
		sl.gameLibrary();
	}
	else
	{
		cout << "If you wish to return to the Library please type A";
		sl.bubaG();
	}
}

void steamLibrary::twoWeeks()
{
	string libraryReturn;

	cout << "Two Weeks:\n	-This game is about how zombies have taken over the world and the most physically fit man must survive two weeks in this world and wait till rescue, who are these men? Dan Lynham a.k.a 'Lyndog'\n	-The age rating of this game is 15\n	-Currently the game will recieve it's first DLC soon\n	If you want to return to the Library please type A";
	cin >> libraryReturn;

	if (libraryReturn == "A")
	{
		sl.gameLibrary();
	}
	else
	{
		cout << "If you wish to return to the Library please type A";
		sl.twoWeeks();
	}
}

void steamLibrary::suwi()
{
	string libraryReturn;

	cout << "SUWI:\n	-D-Street, humanities last hope against the vegan crisis and must ultimately kill his only rival, Dan Lynham\n	-The age rating for this is 12\n	The total game time for this game is 3 minutes as a fight between these two wouldn't last that long\n	If you want to return to the Library please type A";
	cin >> libraryReturn;

	if (libraryReturn == "A")
	{
		sl.gameLibrary();
	}
	else
	{
		cout << "If you wish to return to the Library please type A";
		sl.suwi();
	}
}
Calculate sum of two numbers by taking input from user
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> adj[n+1];
  for(int i=0;i<m;i++)
    {
      int u,v;
      cin>>u>>v;
      
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
  return 0;
}
priority_queue<int> maxH;
for(int i=0;i<size;i++)
  {
    maxH.push(arr[i]);
    if(maxH.size()>k)
      {
        maxH.pop();
      }
  }
return maxH.top();
/* C++ program to print level
	order traversal using STL */
#include <bits/stdc++.h>
using namespace std;

// A Binary Tree Node
struct Node {
	int data;
	struct Node *left, *right;
};

// Iterative method to find height of Binary Tree
void printLevelOrder(Node* root)
{
	// Base Case
	if (root == NULL)
		return;

	// Create an empty queue for level order traversal
	queue<Node*> q;

	// Enqueue Root and initialize height
	q.push(root);

	while (q.empty() == false) {
		// Print front of queue and remove it from queue
		Node* node = q.front();
		cout << node->data << " ";
		q.pop();

		/* Enqueue left child */
		if (node->left != NULL)
			q.push(node->left);

		/*Enqueue right child */
		if (node->right != NULL)
			q.push(node->right);
	}
}

// Utility function to create a new tree node
Node* newNode(int data)
{
	Node* temp = new Node;
	temp->data = data;
	temp->left = temp->right = NULL;
	return temp;
}

// Driver program to test above functions
int main()
{
	// Let us create binary tree shown in above diagram
	Node* root = newNode(1);
	root->left = newNode(2);
	root->right = newNode(3);
	root->left->left = newNode(4);
	root->left->right = newNode(5);

	cout << "Level Order traversal of binary tree is \n";
	printLevelOrder(root);
	return 0;
}
// C++ program for different tree traversals
#include <iostream>
using namespace std;

/* A binary tree node has data, pointer to left child
and a pointer to right child */
struct Node {
	int data;
	struct Node *left, *right;
};

//Utility function to create a new tree node
Node* newNode(int data)
{
	Node* temp = new Node;
	temp->data = data;
	temp->left = temp->right = NULL;
	return temp;
}

/* Given a binary tree, print its nodes according to the
"bottom-up" postorder traversal. */
void printPostorder(struct Node* node)
{
	if (node == NULL)
		return;

	// first recur on left subtree
	printPostorder(node->left);

	// then recur on right subtree
	printPostorder(node->right);

	// now deal with the node
	cout << node->data << " ";
}

/* Given a binary tree, print its nodes in inorder*/
void printInorder(struct Node* node)
{
	if (node == NULL)
		return;

	/* first recur on left child */
	printInorder(node->left);

	/* then print the data of node */
	cout << node->data << " ";

	/* now recur on right child */
	printInorder(node->right);
}

/* Given a binary tree, print its nodes in preorder*/
void printPreorder(struct Node* node)
{
	if (node == NULL)
		return;

	/* first print data of node */
	cout << node->data << " ";

	/* then recur on left subtree */
	printPreorder(node->left);

	/* now recur on right subtree */
	printPreorder(node->right);
}

/* Driver program to test above functions*/
int main()
{
	struct Node* root = newNode(1);
	root->left = newNode(2);
	root->right = newNode(3);
	root->left->left = newNode(4);
	root->left->right = newNode(5);

	cout << "\nPreorder traversal of binary tree is \n";
	printPreorder(root);

	cout << "\nInorder traversal of binary tree is \n";
	printInorder(root);

	cout << "\nPostorder traversal of binary tree is \n";
	printPostorder(root);

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
struct node{
   int data;
   struct node* left;
   struct node* right;
   node(int val)
   {
      data=val;
      left=right=NULL;
   }
};

int main()
{
struct node* root=new node(1);
root->left=new node(5);
root->right=new node(8);
root->left->right=new node(9);
cout<<root->left->right->data;
	return 0;
}
	void segregateEvenOdd(int arr[], int n) {
	    vector<int>v;
	   multiset<int>s1;
	    multiset<int>s2;
	    for(int i=0;i<n;i++)
	    {
	        if(arr[i]%2==0) s1.insert(arr[i]);
	        else s2.insert(arr[i]);
	    }
	   for(auto x:s1)
	    {
	    v.push_back(x);
	    }
	    for(auto x:s2)
	    {
	      v.push_back(x);   
	    }
	     for(int i=0;i<n;i++)
	     arr[i]=v[i];
	}
	
};
class Solution{
public:	

	void segregateEvenOdd(int arr[], int n) {
	    // code here
	    multiset<int>s1;
	    multiset<int>s2;
	    vector<int>v;
	    for(int i=0;i<n;i++)
	    {
	        if(arr[i]%2==0) s1.insert(arr[i]);
	        else s2.insert(arr[i]);
	    }
	   
	    for(auto i:s1)
	    {
	        v.push_back(i);
	    }
	    for(auto i:s2)
	    {
	        v.push_back(i);
	    }
	    
	    for(int i=0;i<n;i++)
	    {
	        arr[i]=v[i];
	    }
	    
	}
};
#include<bits/stdc++.h>
using namespace std;

class node{
   public:
   int data;
   node* next;
   
   node(int val){
      data=val;
      next=NULL;
   }
};

void nodeathead(node* &head, int val)
{
   node* p=new node(val);
   p->next=head;
   head=p;
}
void nodeatlast(node* &head,int val)
{
   node* l=new node(val);
   if(head==NULL)
   {
      head=l;
      return;
   }
   
   node* temp=head;
   while(temp->next!=NULL)
   {
      temp=temp->next;
   }
   temp->next=l;
}

void nodeafter(node* &head,int key,int val)
{
   node* l=new node(val);
   node* temp=head;
   while(temp->data!=key)
   {
      temp=temp->next;
      if(temp==NULL)
      {
         return;
      }
   }
   l->next=temp->next;
   temp->next=l;
}

void print(node* &head)
{
   node* l=head;
   while(l!=NULL)
   {
      cout<<l->data<<" ";
      l=l->next;
      
   }
}
int main()
{
   node* head = new node(45);
   nodeathead(head,9);
   nodeathead(head,8);
   nodeathead(head,6);
   nodeathead(head,3);
   nodeatlast(head,98);
   nodeatlast(head,977);
   nodeafter(head,6,7);
   nodeafter(head,977,988);
   print(head);
   return 0;
}
#include <bits/stdc++.h>

using namespace std;
class node{
    public:
    int d;
    node* next;
};
void printlinkedelements(node* i)
{
    while(i!=NULL)
    {
        cout<<i->d<<" "<<i<<"\n";
        i=i->next;
        
    }
}
void takeinput(node* i)
{
    while(i!=NULL)
    {
        cin>>i->d;
        i=i->next;
    }
}
int main()
{
    node* head=NULL;
    node* second=NULL;
    node* third=NULL;
     
    head=new node();
    second=new node();
    third=new node();
    
  
    head->next=second;

   second->next=third;
   
   third->next=NULL;
   takeinput(head);
   printlinkedelements(head);
    return 0;
}
pair<long long, long long> getMinMax(long long a[], int n) {
    int long long max=INT_MIN;
    int  long long  min=INT_MAX;
    for(int i=0;i<n;i++)
    {
        if(a[i]>max) max=a[i];
        if(a[i]<min) min=a[i];
    }
    pair<int long long,int long long>pair1;
    pair1.first=min;
    pair1.second=max;
    return pair1;
    
    
}
pair<long long, long long> getMinMax(long long a[], int n) {
    int long long min=INT_MAX;
    int long long max=INT_MIN;
    for(int long long i=0;i<n;i++)
    {
        if(a[i]>max) max=a[i];
        if(a[i]<min) min=a[i];
        
    }
    pair<int long long,int long long>pair1={min,max};
   
    return pair1;
Method 1
string reverseWord(string str)
{
    int n=str.size();
    for(int i=0;i<n/2;i++)
    {
        swap(str[i],str[n-1-i]);
    }
    return str;
}


Method 2

string reverseWord(string str)
{
   reverse(str.begin(),str.end());
    return str;
}
class Solution
{
public:
    vector<int> singleNumber(vector<int> nums) 
    {
        // Code here.
        
        map<int,int>mp;
        for(int i=0;i<nums.size();i++)
        {
            mp[nums[i]]++;
        }
        vector<int>v;
        map<int,int>::iterator it;
        for(auto it:mp)
        {
            if(it.second==1) v.push_back(it.first);
        }
        return v;
    }
};
class Solution{
    public:
    vector<int> twoOddNum(int Arr[], int N)  
    {
        set<int>s;
        for(int i=0;i<N;i++)
        {
            s.insert(Arr[i]);
        }
        vector<int>v;
        set<int>::iterator i;
        for(i=s.begin();i!=s.end();i++)
        {
            v.push_back(*i);
        }
        vector<int>ans;
        for(int i=0;i<v.size();i++)
        {
            int count=0;
            for(int j=0;j<N;j++)
            {
                if(v[i]==Arr[j]) count++;
                
            }
            if(count%2==1) 
            {
                ans.push_back(v[i]);
            }
        }
        sort(ans.rbegin(),ans.rend());
        return ans;
        // code here
    }
};
#include <iostream>

int main () {
  int number;
  int lastNumber;
  std :: cout << "Введите число: ";
  std :: cin >> number;

  while (number != 0) {
    lastNumber = number % 10;
    if (lastNumber != 1 && lastNumber != 0) break;
    number /= 10;
  }

  if (lastNumber == 1 || lastNumber == 0) {
    std :: cout << "Робот все понял!\n";
  } else {
    std :: cout << "Машинный код состоит не только из 0 и 1. Ошибка!\n";
  }
}
#include <iostream>

int main() {
  int pin;
  std::cout<<"Введите число-пинкод\n";
  std::cin >> pin;
  int sum;
  while(pin !=42 ){
    std::cout << "Error try again:";
    std::cin >> pin;
    }
  if (sum==42){
  std::cout<<"пинкод верный работаем дальше";
    }
  }
#include <iostream>

using namespace std;

int main() {

int square;
  
  cout << "Введите площадь:\n";
  cin >> square;

  if (square > 1000000) cout << "Нет такого участка";
  else {

    int iteration = 0;
  
      while (iteration * iteration < square) {
      ++iteration;
      }

      if (iteration * iteration == square) cout << "Является точным квадратом";
        else cout << "Не является точным квадратом";
}


}
#include<iostream>
using namespace std;
class DATE{
    int day;
    int month;
    int year;
    public:
    DATE(){}
    DATE(char*);
    int operator-(DATE);
    DATE operator+(int);
    bool operator<(DATE);
    friend ostream& operator<<(ostream &,DATE&);
    ~DATE();
};
int main(){

    cout<<"Enter the first date in dd/mm/yyyy format: ";
    char input[20];
    cin>>input;
    DATE d1(input);
    cout<<d1<<endl;
    cout<<"Enter the second date in dd/mm/yyyy format: ";
    cin>>input;
    DATE d2(input);
    cout<<d2<<endl;
    int num_days = d2-d1;
    
    cout<<"Number of days in between is: "<<num_days<<endl;
    cout<<"Enter the number of days\n";
    int num;
    cin>>num;
    DATE d3 = d1 + num;
    cout<<d1<<" + "<<num<<" = "<<d3;
    return 0;
}
int my_stoi(char *input,int start,int len){
    int output =0;
    for(int i=start;i<start+len;i++){
        output = output*10 + input[i]-'0';
    }
    return output;
}
DATE::DATE(char *input){
    day = my_stoi(input,0,2);
    month = my_stoi(input,3,2);
    year = my_stoi(input,6,4);
}
inline bool is_leap_year(int yy){
    if(yy%400==0) return 0;
    return yy%4 ? 0: 1;
}
inline int days_in_year(int yy){
    return is_leap_year(yy) ? 366 : 365;
}
int days_in_month(int mo,int yy){
    switch(mo){
        case 1:case 3:case 5: case 7: case 8: case 10: case 12:
            return 31;
        case 4: case 6: case 9: case 11:
            return 30;
        case 2: 
            if(is_leap_year(yy)) return 29;
            else return 28;
    }
    return -1;
}
bool DATE::operator<(DATE d2){
    if(year<d2.year) return true;
    else if(year>d2.year) return false;
    if(month<d2.month) return true;
    else if(month>d2.month) return false;
    return day<d2.day;
}
int DATE::operator-(DATE d2){
    if(*this<d2) return d2-*this;

    int prefix_days_d1 =0;
    for(int i=1;i<month;i++) prefix_days_d1 += days_in_month(i,year);
    prefix_days_d1 += day;

    int suffix_days_d2=0;
    suffix_days_d2 += days_in_month(d2.month,d2.year)-d2.day;
    for(int i = d2.month+1;i<=12;i++) suffix_days_d2 += days_in_month(i,d2.year);

    int difference = suffix_days_d2 + prefix_days_d1;

    for(int i = d2.year+1 ; i<year ; i++){
        difference += days_in_year(i);
    }
    if(year==d2.year) difference -= days_in_year(year);   // overlap
    return difference;
}
ostream& operator<<(ostream &print,DATE &obj){
    if(obj.day/10 ==0) print<<"0";
    print<<obj.day;
    print<<"/";
    if(obj.month/10 ==0) print<<"0";
    print<<obj.month<<"/";
    print<<obj.year;
    return print;
}
DATE DATE::operator+(int add_days){
    DATE output;
    int dd = day;
    int mm = month;
    int yy = year;
    int current_days = days_in_month(mm,yy) - dd;
    if(add_days > current_days){  
                                    // rounding up the month
        add_days-=current_days;
        mm++;
        if(mm==13) {
            mm=1;
            yy++;
        }
    }
    else{
        dd +=add_days;
        add_days=0;
    }
    while(days_in_month(mm,yy)<add_days){
                                        // rounding up the year
        add_days-=days_in_month(mm,yy);
        mm++;
        if(mm==13) {
            mm=1;
            yy++;
            break;
        }
    }
    while(days_in_year(yy)<add_days){   //locating to the year
        add_days-=days_in_year(yy);
        yy++;
    }
    while(days_in_month(mm,yy)<add_days){ // locating to the month
        add_days-=days_in_month(mm,yy);
        mm++;
    }
    if(add_days!=0) dd = add_days;  // locating to the date
    output.day = dd;
    output.month = mm;
    output.year = yy;

    return output;
}
DATE::~DATE(){
    
}
#include<iostream>
using namespace std;

typedef struct NODE{
    int data;
    NODE *next;
}NODE;
class LIST{
    NODE *head;
    public:
    LIST();
    LIST& operator+(int);
    LIST& operator-(int);
    bool operator==(LIST&);
    LIST& operator++(int);
    LIST& operator--(int);
    friend ostream& operator<<(ostream&,LIST&);
    ~LIST();
};
int main(){
    LIST l;
    int choice,ele;
    while(1){
        cout<<"1. L = L + ele\n";
        cout<<"2. L = L - ele\n";
        cout<<"3. L = L++ \n";
        cout<<"4. L = L--\n";
        cout<<"-1: Exit\n";
        cin>>choice;
        switch(choice){
            case 1: 
                    cout<<"Enter the value of the element\n";
                    cin>>ele;
                    l = l + ele;
            break;
            case 2:
                    cout<<"Enter the value of the element\n";
                    cin>>ele;
                    l = l - ele;
            break;
            case 3:
                    l = l++;
            break;
            case 4: 
                    l = l--;
            break;
            case -1:
                    goto out;
            default:
                    cout<<"Invalid entry\n";
        }
        cout<<"List: "<<l;
    }
    out:
    return 0;
}

LIST::LIST(){
    head=NULL;
}
bool ispresent(NODE* chain,NODE *end,int key){
    NODE *temp = chain;
    while(temp!=end){
        if(temp->data==key) return true;
        temp = temp->next;
    }
    if(end!=NULL) return end->data == key ? 1:0;
    return false;
}
LIST& LIST::operator--(int){
    NODE *distinct_head = NULL;
    NODE *distinct_connect = NULL;
    NODE *duplicate_head=NULL;
    NODE *duplicate_connect = NULL;
    NODE *temp = head;
    while(temp){
        if(ispresent(distinct_head,distinct_connect,temp->data)){
            if(!duplicate_connect) duplicate_head = temp;
            else duplicate_connect->next = temp;
            duplicate_connect = temp;
        }
        else{
            if(!distinct_connect) distinct_head = temp;
            else distinct_connect->next = temp;
            distinct_connect = temp;
        }
        NODE *store = temp->next;
        temp->next = NULL;
        temp = store;
    }
    distinct_connect->next  = duplicate_head;
    head = distinct_head;
    return *this;
}
LIST& LIST::operator++(int){
    NODE *temp = head;
    while(temp){
        temp->data = temp->data +1;
        temp=temp->next;
    }
    return *this;
}
bool LIST::operator==(LIST &l2){
    NODE *temp1 = head;
    NODE *temp2 = l2.head;
    if(temp1 == NULL && temp2 == NULL) return true;
    if(temp1==NULL || temp2==NULL) return false;
    while(temp1 && temp2){
        if(temp1->data!=temp2->data) return false;
        temp1 = temp1->next;
        temp2 = temp2->next;
    }
    return temp1 || temp2 ? 0:1;
}
LIST& LIST::operator-(int element){
    NODE *temp = head;
    NODE *prev= NULL;
    while(temp){
        if(temp->data==element){
            if(!prev) head=head->next;
            else prev->next = temp->next;
            delete temp;
            return *this;
        }
        prev=temp;
        temp=temp->next;
    }
    return *this;
}
LIST& LIST::operator+(int element){
    NODE *current = new NODE;
    current->data = element;
    current->next = NULL;
    NODE *temp = head;
    if(!temp){
        head = current;
        return *this;
    }
    while(temp->next){
        temp = temp->next;
    }
    temp->next = current;
    return *this;
}
ostream& operator<<(ostream& print,LIST &l){
    NODE *temp= l.head;
    while(temp){
        print<<temp->data<<" ";
        temp = temp->next;
    }
    print<<endl;
    return print;
}
LIST::~LIST(){
    NODE *temp = head;
    while(temp){
        NODE *store = temp->next;
        delete temp;
        temp = store;
    }
}
#include<iostream>
using namespace std;

class MATRIX{
    int row;
    int col;
    int **array;
    public:
    MATRIX();
    MATRIX(const MATRIX&);
    MATRIX(int,int);
    void takeinput();
    MATRIX operator+(MATRIX);
    MATRIX operator-(MATRIX);
    bool operator==(MATRIX);
    friend ostream& operator<<(ostream&,MATRIX);
    ~MATRIX();
};
int main(){

    int r,c;
    cout<<"Enter number of rows for matrix m1: ";
    cin>>r;
    cout<<"Enter number of columns for matrix m1: ";
    cin>>c;
    MATRIX m1(r,c);
    m1.takeinput();
    cout<<"Enter number of rows for matrix m2: ";
    cin>>r;
    cout<<"Enter number of columns for matrix m2: ";
    cin>>c;
    MATRIX m2(r,c);
    m2.takeinput();
    cout<<"Matrix m1 :-"<<endl<<m1;
    cout<<"Matrix m2 :-"<<endl<<m2;
    MATRIX m3,m4;
    if(m1==m2){
        MATRIX m3 = m1 + m2;
        cout<<"Matrix m3 :-"<<endl;
        cout<<m3;
        MATRIX m4 = m1 - m2;
        cout<<"Matrix m4 :-"<<endl;
        cout<<m4;
    }
    else{
        cout<<"Error! The dimensions of both the operand matrices are not same\n";
    }
    return 0;
}

MATRIX::MATRIX(int r,int c){
    row = r;
    col = c;
    array = new int*[r];
    for(int i=0;i<r;i++){
        array[i] = new int[c];
        for(int j=0;j<c;j++) {
            array[i][j] = 0;
        }
    }
}
MATRIX::MATRIX(const MATRIX& obj){
    row = obj.row;
    col = obj.col;
    array = new int*[row];
    for(int i=0;i<row;i++){
        array[i] = new int[col];
        for(int j=0;j<col;j++){
            array[i][j] = obj.array[i][j];
        }
    }
}
void MATRIX::takeinput(){
    for(int i=1;i<=row;i++){
        for(int j=1;j<=col;j++){
            cout<<"Enter ("<<i<<", "<<j<<") element: ";
            cin>>array[i-1][j-1];
        }
    }
}
MATRIX::MATRIX(){
    row=0;
    col=0;
    array=NULL;
}
MATRIX MATRIX::operator+(MATRIX m2){
    MATRIX output(row,col);
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            output.array[i][j] = array[i][j] + m2.array[i][j];
        }
    }
    return output;
}
MATRIX MATRIX::operator-(MATRIX m2){
    MATRIX output(row,col);
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            output.array[i][j] = array[i][j] - m2.array[i][j];
        }
    }
    return output;
}
ostream& operator<<(ostream &print, MATRIX m){
    for(int i=0;i<m.row;i++){
        for(int j=0;j<m.col;j++){
            print<<m.array[i][j]<<" ";
        }
        print<<endl;
    }
    return print;
}
bool MATRIX::operator==(MATRIX m2){
    return (row==m2.row && col==m2.col) ? true:false;
}

MATRIX::~MATRIX(){
    for(int i=0;i<row;i++){
        delete []array[i];
    }
    delete []array;
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
int DayoftheWeek;

cout << "Введите День недели: ";
cin >> DayoftheWeek;
  
if(DayoftheWeek == 1)
	{
		cout << "***Понедельник***" << endl;
    cout << "Борщ" << endl;
    cout << "Салат с помидорами и огурцами" << endl;
    cout << "Чай" << endl;
	}
else if(DayoftheWeek == 2)
	{
		cout << "***Вторник***" << endl;
    cout << "Суп Щи" << endl;
    cout << "Пюрешка с котлетками" << endl;
    cout << "Компот с клюквой" << endl;
	}
else if(DayoftheWeek == 3)
	{
	  cout << "***Среда***" << endl;
    cout << "Суп Сырный" << endl;
    cout << "Гречневая каша" << endl;
    cout << "Сок яблочный" << endl;
	}
else if (DayoftheWeek == 4)
	{
		cout << "***Четверг***" << endl;
    cout << "ПЕЛЬМЕНИ" << endl;
    cout << "Салат Греческий" << endl;
    cout << "Компот вишнёвый" << endl;
	}
else if(DayoftheWeek == 5)
	{
		cout << "***Пятниц***" << endl;
    cout << "Сборня солянка" << endl;
    cout << "Макароны с тушёнкой" << endl;
    cout << "Чай" << endl;
	}
else if(DayoftheWeek == 6)
	{
	  cout << "***Суббота***" << endl;
    cout << "Суп Сырный" << endl;
    cout << "Компот с клюквой" << endl;
    cout << "Макароны с котлетами" << endl;
	}
else if (DayoftheWeek == 7)
	{
		cout << "***Восресенье***" << endl;
    cout << "ПЕЛЬМЕНИ" << endl;
    cout << "Салат с помидорами и огурцами" << endl;
    cout << "Чай" << endl;
  }
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{

int a;
int b;

cout << "Введите целое число: ";
cin >> a;
 
cout << "Введите второе целое число: ";
cin >> b;
 
cout << "Остаток: " << a % b << endl;
 
if ((a % b) == 0)
	cout << a << " Делится на " << b << endl;
else
	cout << a << " Не делится на " << b << endl;
}
#include <iostream>

using std::cout;
using std::cin;

int main() 
{
  
int skill;

cout << "Введите скил пресонажа: ";
cin >> skill;
  
if (skill < 1000) {
  cout << "Lvl 1";
} 
else if (skill < 2500) {
  cout << "Lvl 2";
} 
else if(skill < 5000) {
  cout << "Lvl 3";
} 
 if (skill >= 5000) {
  cout << "Максимальный скил";
}
}
#include <iostream> 

using std::cout;
using std::cin;
using std::endl;
 
int main() 
{   
  int number; 
 
  cout << "Введите число " << endl; 
  cin >> number; 
 
  if( number % 2 == 0) 
    cout << "Чётное " << endl; 
  else 
    cout << "Нечётное " << endl; 
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
 int a = 0;
 int b = 0;
 int result;

 cout << "Введите пример: ";
 cin >> a >> b >> result;

  if(a + b == result)
  {
    cout << "Ответ верный";
  }
  else if( a + b != result)
  {
    cout << "Ответ не верный";
  }
} 
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{

int a = 0;
int b = 0;
int min = 0;
int equal;

  
cout << "Введите число a: ";
cin >> a;
cout<<"Введите число b: ";
cin >> b;
  
  
if (a < b){

    cout << "Наименьшим числом является " << a <<".";

  } else if (a > b){

    cout << "Наименьшим числом является " << b <<".";

  } else {
      cout << "Числа равны";
  }
}
#include <iostream>

using std::cout;
using std::cin;

int main() 
{
  int speed;
  int height;

  cout << "Введиите допустимую скорость в самолёта ";
  cin >> speed;
  cout << "Введите дрпустимую высоту(в тыс. метрах) ";
  cin >> height;

  if(speed < 750 && height < 9000){

    cout << "Данной скорости и высоты не достаточно для самолёта";
    
  }else if(speed > 850 && height > 9500){

    cout << "Данная скорость и высота превышает установленнную норму полёта ";
    
  }else{

    cout << "Данной скорости и высоты достаточно ";
  }
}
#include <iostream>

using std::cout;
using std::cin;

int main() 
{

int day;
int month;
  
  
cout << "Введите день месяца: ";
cin >> day;
cout <<"Введите день, с которого началаcя месяц ";
cin >> month;
 
if ((day >= 1 && day <=5 ) || (day >= 8 && day <=10)) {
  cout << "Праздничный день ";
} else if ( day <= 0 ||  day > 31 ||  month > 7){
 cout << "Некоректное значение";
} else if (((day + 1) % 7) == 0 || ((day + month - 1) % 7) == 0){
  cout << "Выходной день";
} else {
  cout << "Рабочий день";}
}
#include <iostream>

using std::cout;
using std::cin;

int main() 
{
  int maydate;
  int weekday;
  
  cout << "Введите дату \n";
  cin >> maydate;
  
  cout << "Введите день недели \n";
  cin >> weekday;
  
  if (((maydate>=1) && (maydate<=5)) || ((maydate>=8) && (maydate<=10))){
  cout << "Праздничный день";
  }else if ((maydate+weekday)%6==0 || (maydate+weekday)%7==0){
      cout << "Выходной день";
  }else {
      cout << "Рабочий день";
  }
}
#include <iostream>

using std::cout;
using std::cin;

int main()
{
  int Ruble = 0;
  
  cout << "Введите количество денег: ";
  cin >> Ruble;
  
  if (Ruble % 10 == 0 || Ruble % 10 >= 5 || (Ruble / 10) % 10 == 1){
    cout << Ruble << " рублей";
    }else if (Ruble % 10 == 1){
    cout << Ruble << " рубль";
    }else {
    cout << Ruble << " рубля";
    }
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
  int a;
  int b;
  int c;
  
  cout << "Введите размеры первой коробки(которую надо пеместить в другую): ";
  cin >> a >> b >> c;

  int m;
  int n;
  int k;
  
  cout << "Введите размеры второй коробки(в которую надо засунуть): ";
  cin >> m >> n >> k;

  if (a <= m && b <= n && c <= k || a <= n && b <= m && c <= k) {
    cout << "Можно";
    }else if(a <= n && b <= m && c <= k || a <= m && b <= n && c <= k){
    cout << "Можно";
    }else if(c <= a && a <= c && k <= b || k <= c && n <= b && k <= a){
    cout << "Можно";
  } else {
    cout << "Нельзя";
  }
  
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
  int day;
  int month;
  int year;

  cout << "Введите день месяц и год рождения клиента: ";
  cin >> day >> month >> year;

  int dayCurrent;
  int monthCurrent;
  int yearCurrent;

  cout << "Введите текущий день, месяц, год: ";
  cin >> dayCurrent >> monthCurrent >> yearCurrent;

  if(yearCurrent - year < 18){
    cout << "Нельзя продавать. ";
  }else if(yearCurrent - year > 18){
    cout << "Можно продать. ";
  }else if(monthCurrent > month || (monthCurrent == month && dayCurrent > day)){
    cout << "Можно продать. ";
  }else{
    cout << "Нельзя продавать. ";
  }
}
#include <iostream>

using std:: cout;
using std:: cin;
using std:: endl;

int main() {
    int nominals[] = {5000, 2000, 1000, 500, 200, 100};
    int requested;
  
    cin >> requested; 
    cout << "Запрашиваемая сумма: " << requested << endl;
  
    if (requested % 100 != 0) {
        cout << " - Невозможно предоставить " << requested << ". Не должно быть меньше 100." << endl;
    } else if (requested > 150000) {
        cout << " - Невозможно предоставить " << requested << ". Не должно превышать 150000" << endl;
    } else {
        for (auto nominal : nominals) {
            cout << " - " << nominal << " x " << (requested / nominal) << endl;
            requested %= nominal;
          }
      }
}
#include <iostream>h>

using namespace std;
 
void checkTriangle(int x1, int y1, int x2,
                   int y2, int x3, int y3)
{
 
    int a = x1 * (y2 - y3)
            + x2 * (y3 - y1)
            + x3 * (y1 - y2);
 
    if (a == 0)
        cout << "No";
    else
        cout << "Yes";
}
 
int main()
{
    int x1 = 1, x2 = 1, x3 = 2,
        y1 = 1, y2 = 6, y3 = 5;
    checkTriangle(x1, y1, x2,
                  y2, x3, y3);
    
}
#include <iostream>

using namespace std;

int main()
{
  int count;

  cout << "Сколько чисел вы хотите суммировать" << endl;
  cin >> count;

  cout << "Вводите " << count << " чисел: " << endl;

  int interations = 0;
  int sum = 0;

      while(interations < count){

      int number;

      cin >> number;
      sum += number;
      interations += 1;
    
  }
  cout << "Сумма равна" << sum;
  
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{
  int spirt;
  int aptechka;

  cout << "Введите нужное количечество спирта в миллитрах ";
  cin >> spirt;
  cout << "Введите нужное количество аптечек ";
  cin >> aptechka;

  if(spirt < 2000 && aptechka < 5){
    cout << "Не достаточно ";
    }
  else{
    cout << "Достаточно";
  }
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main ()
{
int god;
  
printf("введите Год ");
scanf("%d",&god);
  
if (god%100 != 0 && god%400 == 0){
    printf("невисокосный год\n");
  }else
    if (god%4 == 0)
        printf("високосный Год\n");
    else printf("невисокосный Г,од\n");
    return 0;
}
#include <iostream>

int main() {
  int sum;

  std::cout << "Введите сумму, которую хотите обналичить : ";
  std::cin >> sum;

  if (sum > 150000) {
    std::cout << "Превышено максимальное число для вывода денег.";
  } else if ((sum % 5000 == 0) || ((sum - 5000) != 0)) {
    int remainder;
    remainder = sum - 5000;
    std::cout << sum / 5000 << " купюр по 5000";       //нужно как то поместить в if
  if (remainder == 0) {
    std::cout << "1 купюра по 5000";
  } else if (remainder % 2000 == 0) {
    std::cout << " и " << remainder / 2000 << " купюр по 2000";       //еще склонения купюр надо сделать
  } else if (remainder % 1000 == 0) {
    std::cout << " и " << remainder / 1000 << " купюр по 1000";
  } else if (remainder % 500 == 0) {
    std::cout << " и " << remainder / 500 << " купюр по 500";
  } else if (remainder % 200 == 0) {
    std::cout << " и " << remainder / 200 << " купюр по 200";
  } else if (remainder % 100 == 0) {
    std::cout << " и " << remainder / 100 << " купюр по 100";
  }

  
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl; 
int main()
{
    int x, y;
    while (true)
    {
        cin >> x >> y;
        if (y <= 2 - x * x && (y >= x || y >= 0)) cout << "Yes ";
        else cout << "No  ";
        if (x <= 0 && y >= 0 && y <= 2 - x * x) cout << "A";
        if (x >= 0 && y >= x && y <= 2 - x * x) cout << "B";
        if (x >= 0 && y >= 0 && y <= x && y <= 2 - x * x) cout << "C";
        if (x <= 0 && y <= 0 && y >= x && y <= 2 - x * x) cout << "D";
        if (y >= 0 && y >= x && y >= 2 - x * x) cout << "E";
        if (x <= 0 && y <= 0 && y >= x && y >= 2 - x * x) cout << "F";
        if (x <= 0 && y <= x && y >= 2 - x * x) cout << "G";
        if (y <= 0 && y <= x && y <= 2 - x * x) cout << "H";
        if (x >= 0 && y >= 0 && y <= x && y >= 2 - x * x) cout << "J";
        if (x >= 0 && y <= 0 && y >= 2 - x * x) cout << "K";
        cout << endl;
    }
}
#include <iostream>

using namespace std;

int main() {
  
 int a, b, c, d;
  cout<< "Введите 4 пин кода\n";
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  
   while (a+b+c+d !=42){std::cout << " Ввод некорректный, попробуйте еще раз\n";
     
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
     
   }
   std::cout << " Ввод коректный\n"; 
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
  int mansCount;
  int barbersCount;
  int mansPerBarber = 8; // один человек в час, смена 8 часов
  int mansPerBarberPerMonth = mansPerBarber * 30;    //подстрич за месяц

  cout << "Введите число мужчин в городе: ";
  cin >> mansCount;
  cout << "Сколько уже барберов удалось нанять?";
  cin >> barbersCount;
  cout << "Один барбер стрижет столько клиентов в месяц " << mansPerBarberPerMonth << "\n";

    // Сколько нужно барберов, чтобы постричь mansCount человек?
    int requiredBarbersCount = mansCount / mansPerBarberPerMonth;
    if (requiredBarbersCount * mansPerBarberPerMonth % mansCount) {
        requiredBarbersCount += 1;
    }

    cout << "Необходимое число барберов: " << requiredBarbersCount << "\n";

    // Сколько человек успеют посчтричь requiredBarbersCount за месяц?
    cout << requiredBarbersCount << " барбера могут постричь " << requiredBarbersCount * mansPerBarberPerMonth << " мужчин за месяц.\n";

  
  if (requiredBarbersCount > barbersCount) 
  {
    cout << "Нужно больше барберов!!!\n";
  } 
    else if (requiredBarbersCount == barbersCount) 
    {
      cout << "Барберов ровно столько, сколько нужно!!!\n";
    }   
      else 
      {
        cout << "Барберов хватает!!!\n";
      }

  if (barbersCount > requiredBarbersCount * 2) 
  {
    cout << "У вас работает в два раза больше барберов, чем это нужно!!!\n";
  }

  
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
int AmountofIncome; 
int taxrate = 0;
  
cout << "Введите размер дохода: ";
cin >> AmountofIncome;

if (AmountofIncome > 50000) {
  taxrate += (AmountofIncome - 50000) * 30 / 100;
  AmountofIncome = 50000;
  } 
  if (AmountofIncome > 10000) {
  taxrate += (AmountofIncome - 10000) * 20 / 100;
  AmountofIncome = 10000;
  }
  taxrate += AmountofIncome * 13 / 100;

  cout << "Размер налога будет составлять " << taxrate << " рублей" << endl;
}
#include <iostream>
#include <algorithm>

using std::cout;
using std::cin;
using std::endl;
 
int main() 
{
  int a;
  int b;
  int c;
  int calculate = 1;
  int ArithmeticMean;
  int difference;

  cout << "Зарплата " << calculate << "-го сотрудника: ";
  calculate++;
  cin >>a;
  cout << "Зарплата " << calculate << "-го сотрудника: ";
  calculate++;
  cin >>b;
  cout << "Зарплата " << calculate << "-го сотрудника: ";
  calculate++;
  cin >>c;
  ArithmeticMean = (a+b+c)/3;
  
  int high = 0;
  if(a > b ) 
  {
    cout << "Самая высокая зарплата у 1-го сотрудника: "  << a << endl;
    high = a;
  } 
  else if(b < a) 
  {
    cout << "Самая высокая зарплата у 2-го сотрудника: "  << b << endl;
    high = b;
  }
  else if(c > b)
  {
    cout << "Самая высокая зарплата у 3-го сотрудника: "  << c << endl;
    high = c;
  }

  
  int low = 0;
  if(a < b ) 
  {
    cout << "Самая низкая зарплата у 1-го сотрудника: "  << a << endl;
    low = a;
  } 
  else if(b > a ) 
  {
    cout << "Самая низкая зарплата у 2-го сотрудника: "  << b << endl;
    low = b;
  }
  else if(c < b)
  {
    cout << "Самая низкая зарплата у 3-го сотрудника: "  << c << endl;
    low = c;
  } 
 
  difference = high - low;
  
  cout << "Разница между высокой и низкой зарплаты составляет: " << difference << endl;
  cout << "Средняя зарплата отдела является: " << ArithmeticMean;
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
int DayoftheWeek;

cout << "Введите День недели: ";
cin >> DayoftheWeek;
  
if(DayoftheWeek == 1)
	{
		cout << "***Понедельник***" << endl;
    cout << "Борщ" << endl;
    cout << "Салат с помидорами и огурцами" << endl;
    cout << "Чай" << endl;
	}
else if(DayoftheWeek == 2)
	{
		cout << "***Вторник***" << endl;
    cout << "Суп Щи" << endl;
    cout << "Пюрешка с котлетками" << endl;
    cout << "Компот с клюквой" << endl;
	}
else if(DayoftheWeek == 3)
	{
	  cout << "***Среда***" << endl;
    cout << "Суп Сырный" << endl;
    cout << "Гречневая каша" << endl;
    cout << "Сок яблочный" << endl;
	}
else if (DayoftheWeek == 4)
	{
		cout << "***Четверг***" << endl;
    cout << "ПЕЛЬМЕНИ" << endl;
    cout << "Салат Греческий" << endl;
    cout << "Компот вишнёвый" << endl;
	}
else if(DayoftheWeek == 5)
	{
		cout << "***Пятниц***" << endl;
    cout << "Сборня солянка" << endl;
    cout << "Макароны с тушёнкой" << endl;
    cout << "Чай" << endl;
	}
else if(DayoftheWeek == 6)
	{
	  cout << "***Суббота***" << endl;
    cout << "Суп Сырный" << endl;
    cout << "Компот с клюквой" << endl;
    cout << "Макароны с котлетами" << endl;
	}
else if (DayoftheWeek == 7)
	{
		cout << "***Восресенье***" << endl;
    cout << "ПЕЛЬМЕНИ" << endl;
    cout << "Салат с помидорами и огурцами" << endl;
    cout << "Чай" << endl;
  }
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{

int a;
int b;

cout << "Введите целое число: ";
cin >> a;
 
cout << "Введите второе целое число: ";
cin >> b;
 
cout << "Остаток: " << a % b << endl;
 
if ((a % b) == 0)
	cout << a << " Делится на " << b << endl;
else
	cout << a << " Не делится на " << b << endl;
}
#include <iostream>

using std::cout;
using std::cin;

int main() 
{
  
int skill;

cout << "Введите скил пресонажа: ";
cin >> skill;
  
if (skill < 1000) {
  cout << "Lvl 1";
} 
else if (skill < 2500) {
  cout << "Lvl 2";
} 
else if(skill < 5000) {
  cout << "Lvl 3";
} 
 if (skill >= 5000) {
  cout << "Максимальный скил";
}
}
#include <iostream> 

using std::cout;
using std::cin;
using std::endl;
 
int main() 
{   
  int number; 
 
  cout << "Введите число " << endl; 
  cin >> number; 
 
  if( number % 2 == 0) 
    cout << "Чётное " << endl; 
  else 
    cout << "Нечётное " << endl; 
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
 int a = 0;
 int b = 0;
 int result;

 cout << "Введите пример: ";
 cin >> a >> b >> result;

  if(a + b == result)
  {
    cout << "Ответ верный";
  }
  else if( a + b != result)
  {
    cout << "Ответ не верный";
  }
} 
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{

int a = 0;
int b = 0;
int min = 0;
int equal;

  
cout << "Введите число a: ";
cin >> a;
cout<<"Введите число b: ";
cin >> b;
  
  
if (a < b){

    cout << "Наименьшим числом является " << a <<".";

  } else if (a > b){

    cout << "Наименьшим числом является " << b <<".";

  } else {
      cout << "Числа равны";
  }
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{

  int Men;
  int HireBarriers;
  
  cout << "Ввести число мужчин в городе: " << endl;
  cin >> Men;

  cout << "Вести число нанятых барберов: " << endl;
  cin >> HireBarriers;

  int MenaDaytoCut = 8; //мужчин в день может подстрич, рабочая смена 8  часов.
  int MenPerDay = Men / 30; //подстрич за день
  int RequiredBarriers = MenPerDay /  MenaDaytoCut;

  cout << "Необходимое число барберов: " << RequiredBarriers << endl;

  if(RequiredBarriers > HireBarriers)
  {
    cout << "Не хватает барберов" << endl;
  }
    if(RequiredBarriers <= HireBarriers)
    {
      cout << "Барберов хватает" << endl;
    }
  
} 
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
  int  x;
  cout << "Введите ваше число ";
  cin >> x;
    
  if(x < 0)
  {
    x = -x;  
  }

    cout << " Модуль числа равен: " << x;
  
} 
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{
  int speed;        //скорость автомобиля
  int distance;     //растояние 
  int time;         //время
  
  cout << "Введите скорость автомобиля: " << endl;
  cin >> speed;
  cout << "Введите растояние: " << endl;
  cin >> distance;
  cout << "Введите время: " << endl;
  cin >> time;


  distance = speed * time;
  speed = distance / time;
  time = distance / speed;
  
  if (speed < 90)
        cout << "Вы приехали : " << endl;

    if (speed > 60)
          cout << "Скорости не достаточно: " << endl;
}
#include <iostream>
using namespace std;
int main()
{
    int s,n,mas[100];
    cout << "Enter number = ";cin >> n;
    for(int i=0;i<n;i++)
    {
        cout << "Enter " << i+1 << " = ";
        cin >> mas[i];
    }
    cout << "Suma = ";cin >> s;
    cout << "Bankomat = ";
    for(int i=0;i<n;i++)
    {
        cout << mas[i] << " ";
    }
    cout << "\n";
    system("pause");
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::getline;

int main() {
  
  bool b = true;
  
  while (b) {
    
    int N;
    cout << "Сколько раз вам напомнить? ";
    cin >> N;
    
      if (N == -1) b = false;

      string str;
    
      cout << "Введите фразу напоминалку: ";
    
      getline(std::cin >> std::ws, str);
    
      int i = 0;
    
        while (i <= N) {
            i += 1;
          
            cout << "[" << i << "] " << str << endl;
        }
    }
}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() {

  int k;
  int n;
  int j;
  int t = 1;

  cout << "Введи число у которого хочешь узнать степени: " << endl;
  cin >> k;
  cout << "Введи количество степеней, которые ты хочешь узнать: " << endl;
  cin >> n;
  
  j = k;
  cout << "---------------------" << endl;
  cout << "Cтепень: " << t << " = " << k << endl;

  do {
    k *= j;
    cout << "Cтепень: " << t+1 << " = " << k << endl;
    t += 1;
  } while (n != t);

}
#include <iostream>

using std::cout;
using std::cin;
using std::string;
using std::getline;


int main() {
  
  string text;
  
  do {
  getline (cin, text);
  cout << "Все говорят " << text << ", а ты купи слона!\n";
  } while(text != " ");
}
#include<iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{

setlocale(LC_ALL, "RUS");
   
int productCostOne;
int productCostTwo;
int productCostThree;
int deliveryCost;
int discount;
  

cout<<"Введите стоймость первого товара: ";
cin>> productCostOne;
cout<<"Введите стоймость второго товара: ";
cin>> productCostTwo;
cout<<"Введите стоймость третьего товара: ";
cin>> productCostThree;
cout << "Введите стоимость доставки: ";
cin >> deliveryCost;
cout << "Скидка: ";
cin >> discount;

   
 
if (productCostOne + productCostTwo + productCostThree > 10000) 
{
        
  deliveCost = price * 10 \ 100;
  std::cout << "Стоимость товаров превышает 10000 рублей, вам будет сделана скидка 10%." << endl;
  std::cout << "Поэтому вы получаете скидку на доставку!" << endl;
}
    
int price = productCostOne + productCostTwo + productCostThree + deliveryCost - discount;
    
std::cout << "--------------" << endl;
std::cout << "Полная стоимость товара: " << price << endl;
    
  return 0;
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{ 
int a = 5;
int b = 10; 

cout << "a = " << a << ", b = " << b << endl; 
a = a + b; b = a - b; a = a - b; 
cout << "a = " << a << ", b = " << b << endl; 

}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{
  int startHeight = 100;    //стартовая высота
	int growth = 50;         //рост бамбука в день
	int losses = 20;         //съедение бамбука

	
  int currentHeight = startHeight;


  int bambooHeight = 300;
  int day = (bambooHeight - startHeight) / (growth - losses);
  
  cout << "Высота бамбука будет составлять 3 метра на "  << day * 3 << " день " << endl;
  
} 
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() 
{

int a = 5;
int b = 10;
int temp; 

cout << "a = " << a << ", b = " << b << endl; 
temp = a; a = b; b = temp; 
cout << "a = " << a << ", b = " << b << endl; 

}
#include <iostream>

using std::cout;
using std::cin;
using std::endl;


int main()
{
    setlocale(LC_ALL, "rus");

    int total = 0;
    int mony = 0;
    int Passenger;

    cout << "Прибываем на остаановку Програмистов. В салоне пассажиров: " << total  << endl;
    cout << "Cколько пассажиров зашло на остановке? ";
    cin >> Passenger;
    total += Passenger;
    mony += Passenger;

    cout << "Отправляемся с остановки Улица Программистов. В салоне  " << total << endl;

    cout << "-----------Едем-----------" << endl;
    cout << "Прибываем на остановку Проспект Алгоритмов. В салоне  " << total << endl;
    cout << "===============================================================================" << endl;
    cout << "Прибываем на остаановку 1. В салоне пассажиров: " << total << "\n";

    cout << "Сколько пассажиров вышло на остановке? ";
    cin >> Passenger;
    total -= Passenger;
    cout << "Cколько пассажиров зашло на остановке? ";
    cin >> Passenger;
    total += Passenger;
    mony += Passenger;

    cout << "Отправляемся с остановки 1. В салоне  " << total << endl;
    cout << "-----------Едем-----------" << endl;
    cout << "Прибываем на остановку 2. В салоне  " << total << endl;
    cout << "===============================================================================" << endl;
    cout << "Прибываем на остаановку 3. В салоне пассажиров: " << total << "\n";

    cout << "Сколько пассажиров вышло на остановке? ";
    cin >> Passenger;
    total -= Passenger;
    cout << "Cколько пассажиров зашло на остановке? ";
    cin >> Passenger;
    total += Passenger;
    mony += Passenger;

    cout << "Отправляемся с остановки 3. В салоне  " << total << endl;
    cout << "-----------Едем-----------" << endl;
    cout << "Прибываем на остановку 4. В салоне  " << total << endl;
    cout << "===============================================================================" << endl;
    cout << "Прибываем на остаановку 5. В салоне пассажиров: " << total << "\n";

    cout << "Сколько пассажиров вышло на остановке? ";
    cin >> Passenger;
    total -= Passenger;
    cout << "Cколько пассажиров зашло на остановке? ";
    cin >> Passenger;
    total += Passenger;
    mony += Passenger;

    cout << "Отправляемся с остановки 5. В салоне  " << total << endl;
    cout << "-----------Едем-----------" << endl;
    cout << "Прибываем на остановку 6. В салоне  " << total << endl;
    cout << "===============================================================================" << endl;
    cout << "Прибываем на остаановку 7. В салоне пассажиров: " << total << "\n";

    cout << "Сколько пассажиров вышло на остановке? ";
    cin >> Passenger;
    total -= Passenger;
    cout << "Cколько пассажиров зашло на остановке? ";
    cin >> Passenger;
    total += Passenger;
    mony += Passenger;

    cout << "Отправляемся с остановки 7. В салоне  " << total << endl;
    cout << "-----------Едем-----------" << endl;
    cout << "Прибываем на остановку 8. В салоне  " << total << endl;
    cout << "===============================================================================" << endl;

    
    mony *= 20; // Подсчитываем общую сумму

    cout << "Всего заработали: " << mony << endl;
    cout << "Зарплата водителя: " << mony / 4 << endl;
    cout << "Расходы на топливо: " << mony / 5 << endl;
    cout << "Налоги: " << mony / 5 << endl;
    cout << "Расходы на ремонт машины: " << mony / 5 << endl;
    cout << "Итого доход: " << mony * 3 / 20 << endl;
    
}

/*Для  подсчёта общей платы необходимо сначала посчитать пассажиров:
mony += Passanger ...
А только затем умножить на плату 
mony*= 20
Чтобы получить mony = (Passanger + Passanger + ...) * 20
А иначе сейчас мы получаем:
mony = 20*Passanger*Passanger*Passanger...*/
#include <iostream>

using std::cout;
using std::cin;
using std::string;

int main()
{
	setlocale(LC_ALL, "rus");

	string Planet;
	cout << "Введите название планеты: ";
	cin >> Planet;

	string Star;
	cout << "Введите название зввёздной системы: ";
	cin >> Star;

	string Species;
	cout << "Введите Рассу: ";
	cin >> Species;

	string Ranger;
	cout << "Введите Имя Героя: ";
	cin >> Ranger;

	string Money;
	cout << "Введите Вознаграждение: ";
	cin >> Money;

	cout << "\n\n\n";

	cout << "Как вам, " << Ranger << " известно, мы — раса " << Species << " мирная,";
	cout << "поэтому на наших военных кораблях" "\n";
	cout << "используются наемники с других планет Система набора отработана давным-давно.";
	cout << "Обычно мы приглашаем на наши корабли людей с планеты " << Planet << " системы " << Star << "\n";
	cout << "Но случилась неприятность — в связи с большими потерями в последнее время престиж\n";
	cout << "профессии сильно упал, и теперь не так-то просто завербовать призывников.\n";
	cout << "Главный комиссар планеты " << Planet << ", впрочем, отлично справлялся,\n";
	cout << "но недавно его наградили орденом Сутулого с закруткой на спине, и его на радостях парализовало! Призыв под угрозой срыва!\n";
	cout << Ranger << " вы должны прибыть на планету " << Planet << " системы " << Star << " и помочь выполнить план призыва.";
	cout << "Мы готовы выплатить вам премию в размере " << Money << " кредитов за эту маленькую услугу.\n";
}
#include "iostream"
#include "string"
#define Answer "Да"

using namespace std;
 
int main()
{
    
    string Question;
  
    cout << "Выполнили ли Вы задание, которое задал вчера?\n";
    string variant;
  
    while(getline(cin, variant), variant != Answer)
    {
        cout << "Введите ответ:    " << endl;
    }
    cout << "Задача выполнена!!!";

}
// You Can Add more than condition at the same for loop
int j{};
string arr[] = { "Yes", "Yes", "Yes", "No", "Yes" };
for(j = 1; arr[j] == "Yes" && j < 5; j++);
cout << j <<endl;
unsigned long startMillis;  //some global variables available anywhere in the program
unsigned long currentMillis;
const unsigned long period = 1000;  //the value is a number of milliseconds
const byte ledPin = 13;    //using the built in LED

void setup()
{
  Serial.begin(115200);  //start Serial in case we need to print debugging info
  pinMode(ledPin, OUTPUT);
  startMillis = millis();  //initial start time
}

void loop()
{
  currentMillis = millis();  //get the current "time" (actually the number of milliseconds since the program started)
  if (currentMillis - startMillis >= period)  //test whether the period has elapsed
  {
    digitalWrite(ledPin, !digitalRead(ledPin));  //if so, change the state of the LED.  Uses a neat trick to change the state
    startMillis = currentMillis;  //IMPORTANT to save the start time of the current LED state.
  }
}
int period = 1000;
unsigned long time_now = 0;

void setup() {
    Serial.begin(115200);
}

void loop() {
    if(millis() > time_now + period){
        time_now = millis();
        Serial.println("Hello");
    }

    //Run other code
}
#define INTERVAL_MESSAGE1 5000
#define INTERVAL_MESSAGE2 7000
#define INTERVAL_MESSAGE3 11000
#define INTERVAL_MESSAGE4 13000

unsigned long time_1 = 0;
unsigned long time_2 = 0;
unsigned long time_3 = 0;
unsigned long time_4 = 0;

void print_time(unsigned long time_millis);

void setup() {
    Serial.begin(115200);
}

void loop() {
    if(millis() > time_1 + INTERVAL_MESSAGE1){
        time_1 = millis();
        print_time(time_1);
        Serial.println("I'm message number one!");
    }

    if(millis() > time_2 + INTERVAL_MESSAGE2){
        time_2 = millis();
        print_time(time_2);
        Serial.println("Hello, I'm the second message.");
    }

    if(millis() > time_3 + INTERVAL_MESSAGE3){
        time_3 = millis();
        print_time(time_3);
        Serial.println("My name is Message the third.");
    }

    if(millis() > time_4 + INTERVAL_MESSAGE4){
        time_4 = millis();
        print_time(time_4);
        Serial.println("Message four is in the house!");
    }
}

void print_time(unsigned long time_millis){
    Serial.print("Time: ");
    Serial.print(time_millis/1000);
    Serial.print("s - ");
}
#include<bits/stdc++.h>
using namespace std;

int mountainblue(int a[], int n)
{
sort(b,b+n);
  int k=0,m=0;
  vector<int> v;
  int mx = b[n-1];
  int mn = b[0];
  
  for(int i=0;i<n;i++)
  {
      if(a[i] == mx || a[i] == mn)
      {
          if(a[i] == mx)
          {
              int j;
              for(j=i;j<n;j++)
              {
              k++;
              if(a[j] == mn)
              break;
              }
          }
           if(a[i] == mn)
          {
              int j;
              for(j=i;j<n;j++)
              {
              k++;
              if(a[j] == mx)
              break;
              }
          }
      }
    //   cout << k <<" ";
      v.push_back(k);
    // s.insert(k);
      k=0;
  }
  
  sort(v.begin(),v.end());
//   cout << v[];
  for(int i=0;i<v.size();i++)
  if(v[i] > 1)
  {
  return v[i];
  }
  
  return -1;
}

int main()
{
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)
    cin >> a[i];
  
  cout << mountainblue(a,n);
}
#include<bits/stdc++.h>
using namespace std;
int mountainblue(string s)
{
string s = string;
   
   int ln = s.length();
   
   string ss="";
   string sr = s;
  
 int t = 1,k=0;
 
 string sb = sr.substr(ln-m, m);
     sr.erase(ln-m,m);
    sr = sb + sr;
       k++;
  
  while(sr != s)
  {
      if(t == 1)
      {
      string sb = sr.substr(ln-n, n);
     sr.erase(ln-n,n);
   
    sr = sb + sr;
       k++;
       t=0;
      }
      else
      {
          string sb = sr.substr(ln-m, m);
     sr.erase(ln-m,m);
   
    sr = sb + sr;
       k++;
       t=1; 
      }
  }
  return k;
}
int main()
{
  string s;
  cin >> s;
  cout << mountainblue(s);
}
#include <bits/stdc++.h>

using namespace std;
bool isp(long double x)
{
    
    if (x >= 0) {
 
        long long sr = sqrt(x);
         
        
        return (sr * sr == x);
    }
    
    return false;
}

int main()
{
    long long int n;
    cin >> n;
    long long int a[n];
    for(long long int i=0;i<n;i++)
    {
    cin >> a[i];
    if(isp(a[i]))
    cout <<a[i]<<" ";
    }
}
#include <iostream>
using namespace std;
  
int main() {
  
    int x = 19 ;
    (x & 1) ? cout<<"Odd" : cout<< "Even" ;
        
    return 0;
}
int maxSubArray(vector<int>& nums) {
        int cs = nums[0], ms = nums[0];
        for(int i=1; i<nums.size(); i++)
        {
            cs = max(nums[i], cs+nums[i]);
            ms = max(cs,ms);
        }
        return ms;
    } 
#include <limits>

file.ignore( std::numeric_limits<std::streamsize>::max() );
std::streamsize length = file.gcount();
file.clear();   //  Since ignore will have set eof.
file.seekg( 0, std::ios_base::beg );
#include <iostream>
#include <string>

void printValue(std::string& y) // type changed to std::string&
{
    std::cout << y << '\n';
} // y is destroyed here

int main()
{
    std::string x { "Hello, world!" };

    printValue(x); // x is now passed by reference into reference parameter y (inexpensive)

    return 0;
}
int var{};
int& ref1{ var };  // an lvalue reference bound to var
int& ref2{ ref1 }; // an lvalue reference bound to var
int main()
{
    int x { 5 };
    int& ref { x }; // valid: lvalue reference bound to a modifiable lvalue

    const int y { 5 };
    int& invalidRef { y };  // invalid: can't bind to a non-modifiable lvalue
    int& invalidRef2 { 0 }; // invalid: can't bind to an r-value

    return 0;
}
int main()
{
    int& invalidRef;   // error: references must be initialized

    int x { 5 };
    int& ref { x }; // okay: reference to int is bound to int variable

    return 0;
}
template <typename T> // this is the template parameter declaration
T max(T x, T y) // this is the function template definition for max<T>
{
    return (x > y) ? x : y;
}
if (std::cin.fail()) // has a previous extraction failed or overflowed?
{
    // yep, so let's handle the failure
    std::cin.clear(); // put us back in 'normal' operation mode
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // and remove the bad input
}
#include <iostream>
#include <utility>

int y(int &) { return 1; }
int y(int &&) { return 2; }

template <class T> int f(T &&x) { return y(x); }
template <class T> int g(T &&x) { return y(std::move(x)); }
template <class T> int h(T &&x) { return y(std::forward<T>(x)); }

int main() {
  int i = 10;
  std::cout << f(i) << f(20);
  std::cout << g(i) << g(20);
  std::cout << h(i) << h(20);
  return 0;
}
#include <iostream>
#include <limits>

int main() {
  unsigned int i = std::numeric_limits<unsigned int>::max();
  std::cout << ++i;
}
#include <iostream>

void f(int a = []() { static int b = 1; return b++; }())
{
   std::cout << a;
}

int main()
{
   f();
   f();
}
#include <iostream>

class A {
public:
  void f() { std::cout << "A"; }
};

class B : public A {
public:
  void f() { std::cout << "B"; }
};

void g(A &a) { a.f(); }

int main() {
  B b;
  g(b);
}
#include <iostream>

int main() {
  static int a;
  std::cout << a;
}
#include <iostream>
struct X {
  X() { std::cout << "X"; }
};

int main() { X x(); }
#include <iostream>
#include <type_traits>

using namespace std;

template<typename T, typename U>
void f(T, U) {
    cout << is_same_v<T, U>;
}

int main() {
    int i = 0;
    double d = 0.0;
    f(i, d); 
    f<int>(i, d); 
    f<double>(i, d); 
}
#include <iostream>

void f(char*&&) { std::cout << 1; }
void f(char*&) { std::cout << 2; }

int main() {
   char c = 'a';
   f(&c);
}
#include <iostream>
using namespace std;

size_t get_size_1(int* arr)
{
  return sizeof arr;
}

size_t get_size_2(int arr[])
{
  return sizeof arr;
}

size_t get_size_3(int (&arr)[10])
{
  return sizeof arr;
}

int main()
{
  int array[10];
  //Assume sizeof(int*) != sizeof(int[10])
  cout << (sizeof(array) == get_size_1(array));
  cout << (sizeof(array) == get_size_2(array));
  cout << (sizeof(array) == get_size_3(array));
}
#include <iostream>
#include <type_traits>

void g(int&) { std::cout << 'L'; }
void g(int&&) { std::cout << 'R'; }

template<typename T>
void f(T&& t) {
    if (std::is_same_v<T, int>) { std::cout << 1; } 
    if (std::is_same_v<T, int&>) { std::cout << 2; } 
    if (std::is_same_v<T, int&&>) { std::cout << 3; } 
    g(std::forward<T>(t));
}

int main() {
    f(42);
    int i = 0;
    f(i);
}
#include <iostream>

struct GeneralException {
  virtual void print() { std::cout << "G"; }
};

struct SpecialException : public GeneralException {
  void print() override { std::cout << "S"; }
};

void f() { throw SpecialException(); }

int main() {
  try {
    f();
  }
  catch (GeneralException e) {
    e.print();
  }
}
#include<iostream>

int foo()
{
  return 10;
}

struct foobar
{
  static int x;
  static int foo()
  {
    return 11;
  }
};

int foobar::x = foo();

int main()
{
    std::cout << foobar::x;
}
#include <iostream>
#include <vector>

int f() { std::cout << "f"; return 0;}
int g() { std::cout << "g"; return 0;}

void h(std::vector<int> v) {}

int main() {
    h({f(), g()});
}
#include <iostream>

void print(int x, int y)
{
    std::cout << x << y;
}

int main() {
    int i = 0;
    print(++i, ++i);
    return 0;
}
#include <iostream>
#include <vector>

int main() {
  std::vector<int> v1(1, 2);
  std::vector<int> v2{ 1, 2 };
  std::cout << v1.size() << v2.size();
}
#include <iostream>

struct X {
  X() { std::cout << "a"; }
  X(const X &x) { std::cout << "b"; }
  const X &operator=(const X &x) {
    std::cout << "c";
    return *this;
  }
};

int main() {
  X x;
  X y(x);
  X z = y;
  z = x;
}
#include <iostream>
#include <map>
using namespace std;

int main()
{
  map<bool,int> mb = {{1,2},{3,4},{5,0}};
  cout << mb.size(); 
  map<int,int> mi = {{1,2},{3,4},{5,0}};
  cout << mi.size();
}
#include <iostream>

struct S {
    int one;
    int two;
    int three;
};

int main() {
    S s{1,2};
    std::cout << s.one;
}
#include <iostream>

struct X {
    X() { std::cout << "1"; }
    X(const X &) { std::cout << "3"; }
    ~X() { std::cout << "2"; }

    void f() { std::cout << "4"; }

} object;

int main() {
    X(object);
    object.f();
}
#include <iostream>

template<class T>
void f(T) { std::cout << 1; }

template<>
void f<>(int*) { std::cout << 2; }

template<class T>
void f(T*) { std::cout << 3; }

int main() {
    int *p = nullptr; 
    f( p );
}
using namespace std;

template <class T> void f(T) {
  static int i = 0;
  cout << ++i;
}

int main() {
  f(1);
  f(1.0);
  f(1);
}
#include <bits/stdc++.h>
using namespace std;  

int uniquestring(string s)
{
      int a[26];
for(int i=0;i<26;i++)
a[i]=0;
for(int i =0;i<s.length();i++)
{
    int m = s[i];
    a[m - 97]++;
}

for(int i =0;i<s.length();i++)
{
    int t = s[i];
    if(a[t-97] == 1)
    {
   return i+1;
    }
}
return -1;
}
int main()  
{  
   map<char, int> wordFreq;
    string s, t;
    cin >> s;
 cout << uniquestring(s);
}  
// Binary Search in C++

#include <iostream>
using namespace std;

int binarySearch(int array[], int x, int low, int high) {
  
	// Repeat until the pointers low and high meet each other
  while (low <= high) {
    int mid = low + (high - low) / 2;

    if (array[mid] == x)
      return mid;

    if (array[mid] < x)
      low = mid + 1;

    else
      high = mid - 1;
  }

  return -1;
}

int main(void) {
  int array[] = {3, 4, 5, 6, 7, 8, 9};
  int x = 4;
  int n = sizeof(array) / sizeof(array[0]);
  int result = binarySearch(array, x, 0, n - 1);
  if (result == -1)
    printf("Not found");
  else
    printf("Element is found at index %d", result);
}
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int a , b;
    cin>>a>>b;
    
    for(int i =a; a<=b ; a++){
        string word[10] = {"" , "one", "two", "three" , "four" , "five" , "six" , "seven", "eight" , "nine"};
        
        if(a>=1 && a<=9){
            cout<<word[a]<<endl;
            
        }
        if(a>9){
            for(;a<=b;a++){
                if(a % 2 ==0){
                    cout<<"even"<<endl;
                    
                }
                if(a % 2 ==1){
                    cout<<"odd"<<endl;
                }
            }
        }
    }
    // Complete the code.
    return 0;
}
float rstoc(x) {
  float decimal = abs(x - trunc(x));

  float random_selector = (float)rand() / RAND_MAX;

  float adjustor;
  if (random_selector < decimal) adjustor = 1;
  else adjustor = 0;

  // consider sign
  if(x < 0) adjustor = -1 * adjustor;

  return trunc(x) + adjustor;
}
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define ull unsigned ll
#define take(n) ll int n;cin>>n
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define pp pop_back()
#define array(n,name) ll int *name=new ll int[n]
#define takearray(n,name) rep(i,0,n) cin>>name[i];
#define Zubin ios::sync_with_stdio(false);
#define Shah cin.tie(NULL);cout.tie(0);
#define nl cout<<endl;
using namespace std;

int xcor[4]={-1,0,0,+1};
int ycor[4]={0,-1,1,0};

ull int power(ull n,int x){
    if(x==0) return 1;
    return n * power(n,x-1);
}

int main(){

    Zubin Shah

    take(n);
    array(n,numbers);
    takearray(n,numbers);
    int maxcount=0;
    int count=0;
    int currmax=0;
    rep(i,0,n){
        if(numbers[i]>currmax){  //continuing the streak
            currmax = numbers[i];    // updating the max of current streak
            count++;   
        }
        else {  //streak broken
            count=1;
            currmax=numbers[i];
        }
        maxcount = max(maxcount,count);
    }
    cout<<maxcount<<endl;


return 0;
}
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(arr[j]<arr[i]){
                int temp=arr[j];
                arr[j]=arr[i];
                arr[i]=temp;
            }
        }
    }
    
    for(int i=0;i<n;i++)
    {
        cout<<arr[i]<<" ";
    }cout<<endl;
    
    return 0;
    
}
char a = 'a';
int ia = (int)a; 
/* note that the int cast is not necessary -- int ia = a would suffice */
void insertionsort(int A[], int size){
  int i, j;
  for(i=1; i<size; i++){
    key= A[i];
    j=i-1;
    
    while(j>=0 && A[j]> key){
      A[j+1]= A[j];
      j=j-1;
    }
    A[j+1]= key;
  }
}
#include<bits/stdc++.c>

int binarysearch(int arr[], int l, int r, int x){
  if(r>=l){
     int mid= l+(r-1)/2;
     if(arr[mid]== x){
       return mid;
     }
    if(x<arr[mid]){
      return binarysearch(arr, l ,mid-1, x);
    }
    if(x>arr[mid]){
      return binarysearch(arr, mid+1, r, x);
    }
  }
  return -1;
  
}

int main(){
  int arr[]= {10, 20, 30, 40, 50};
  int x= 30;
  int n= sizeof(arr)/ sizeof(arr[0]);
  int result= binarysearch(arr, 0, 1, n-1m, x);
  (result==-1)? cout<<"Element is not present" : cout<<"Element is present at"<<result;
  return 0;
  
}
#include <string>
using namespace std; 
std::string even_or_odd(int number) 
{
  string EvenOrOdd;
  if (number %2 == 0){
  EvenOrOdd = "Even"; 
  }else{
  EvenOrOdd = "Odd"; 
  }
  return EvenOrOdd;
}
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int d; 
    long ld; 
    char ch; 
    float f; 
    double lf; 
    
    
    scanf("%d %ld %c %f %lf",&d,&ld,&ch,&f,&lf);
    printf("%d\n%ld\n%c\n%f\n%lf",d,ld,ch,f,lf);
    return 0;
}
#include <stdio.h>

void update(int *a,int *b) {
     
    
    int ans = *a; 
    *a = *a + *b;
    *b = ans - *b; 
    if (*b <0){
        *b = -(*b);
    }
    
    //printf("*pb %d\n", *pb);
    //printf("*a %d\n",*a);
    //printf("*b %d\n",*b);
    //printf("*pa %d\n",*pa);
    //printf("\n"); 
    //    
}

int main() {
    int a, b;
    int *pa = &a, *pb = &b;
    
    scanf("%d %d", &a, &b);
    update(pa, pb);
    printf("%d\n%d", a, b);

    return 0;
}
// Online C++ compiler to run C++ program online
#include <iostream>
//#include <cstdio>
//#include <vector>
//#include <iostream>
//#include <algorithm>
#include <list> // for arra list list<foodIdeams>....
using namespace std;

class Maths {
public:
    int oneQty; 
    int twoQty;
    int sumTotal; 
    
    int width;
    int height; 
    int length;
    int areaTotal; 
    Maths(int Width, int Height, int Length, int OneQty, int TwoQty){
        width = Width; 
        height = Height; 
        length = Length;
        oneQty = OneQty; 
        twoQty = TwoQty; 
    }
    int MakeArea(int width, int height, int length) {
        areaTotal = width * height * length;
        return areaTotal;
    }
    void printArea() {
        cout << "Wigth: " << width << endl; 
        cout << "Height: " << height << endl; 
        cout << "length: " << length << endl; 
        cout << "" << endl;
        cout << "Total: "<< areaTotal << endl;
    }
    int subtraction(int oneQty, int twoQty) {
        sumTotal = oneQty - twoQty;
        return sumTotal; 
    }
    void printSum() {
        cout << "First Qty: " << oneQty << endl; 
        cout << "Second Qty: " << twoQty << endl; 
        cout << "" << endl; 
        cout << "Subtarction Totle: " << sumTotal << endl; 
    }

};

int main() {
    Maths One(4, 10, 13,3,4);
    One.MakeArea(3,1,1);
    One.subtraction(10, 7);
    One.printArea(); 
    
    One.printSum(); 
    
    return 0;
}
#include <iostream>
//#include <cstdio>
//#include <vector>
//#include <iostream>
//#include <algorithm>
#include <list> // for arra list list<foodIdeams>....
//using namespace std;
//std:: not using namespace exsample 
namespace Happy {
    int num = 32; 
    std::string name = "Jarod";
    
}
namespace Sad {
    int num = 42; 
    std::string name = "Sid"; 
}
int main() {
    std::cout << Happy::name << std::endl;
    std::cout << Happy::num << std::endl; 
    std::cout << "" << std::endl; 
    std::cout << Sad::name << std::endl; 
    std::cout << Sad::num << std::endl;
    return 0;
}
// Online C++ compiler to run C++ program online
#include <iostream>
//#include <cstdio>
//#include <vector>
//#include <iostream>
//#include <algorithm>
#include <list> // for arra list list<foodIdeams>....
using namespace std;

class foodList{
  public:
  string recipe;
  list<string> ingredient; 
  
  foodList(string Recipe){
      recipe = Recipe; 
  }
  
  void listMaker(){
      cout << "Recipe Name: "<< recipe << endl;
      cout << "" << endl; 
      cout << "Ingredients: " << endl; 
      for (string e : ingredient){
          cout << e << endl; 
      }
  }
};


int main() {
   
foodList recipe1("spaghetti"); 
recipe1.ingredient.push_back("1 pound lean ground meat like beef, turkey, chicken or lamb");
recipe1.ingredient.push_back("3 tablespoons olive oil");
recipe1.ingredient.push_back("1 cup (130 grams) chopped onion");
recipe1.ingredient.push_back("3 garlic cloves, minced (1 tablespoon)");
recipe1.ingredient.push_back("2 tablespoons tomato paste");
recipe1.ingredient.push_back("1/2 teaspoon dried oregano");
recipe1.ingredient.push_back("Pinch crushed red pepper flakes");
recipe1.ingredient.push_back("1 cup water, broth or dry red wine");
recipe1.ingredient.push_back("1 (28-ounce) can crushed tomatoes");
recipe1.ingredient.push_back("Salt and fresh ground black pepper");
recipe1.ingredient.push_back("Handful fresh basil leaves, plus more for serving");
recipe1.ingredient.push_back("12 ounces dried spaghetti or favorite pasta shape");
recipe1.ingredient.push_back("1/2 cup shredded parmesan cheese");
recipe1.listMaker();

    return 0;
}
#include <iostream>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
   int N; 
   cin >> N; 
   int arr[N]; 
   for (int i = 0; i < N; i++) {
        cin >> arr[i];        
    }
    for (int j = N - 1; j >= 0; j--) {
        cout << arr[j] << " ";
    }

    return 0;
}
#include <iostream>
using namespace std;

int main() {
    cout << "Hello World!" << endl;
    return 0;
}
#include <iostream>
#include <string>
using namespace std;
using std::string;


string restWord(string str);

int main()
{	
	string str;
	cout << "Enter the string: " << endl;
	getline(cin, str);
	
	
	cout << restWord(str) << endl;

	return 0;
}

string  restWord(string str)
{
	int cnt=0;
	string result ="";

	for (int i = 0; !isspace(str[i]) && str.size(); i++)
	{
		++cnt ;
	}

	for (int j = cnt + 1; j < str.size(); j++)
	{
		result += str[j];
	}


	return result;
}
#include <iostream>
#include <string>
using namespace std;
using std::string;


string firstWord(string str);

int main()
{	
	string str;
	cout << "Enter the string: " << endl;
	getline(cin, str);
	
	
	cout << firstWord(str) << endl;

	return 0;
}

string firstWord(string str)
{
	string result = "";

	for (int i = 0; !isspace(str[i]) && str.size(); i++)
	{
		result += str[i];
	}
	return result;
}
#include <iostream>
#include <string>
using namespace std;
using std::string;



int main()
{	
	string str;
	cout << "Enter the string: " << endl;
	getline(cin, str);
	unsigned int len = str.size();  // intitilize len by its original size
	
	for (int i = 0; i < len ; i++) // keeps incrementing if there is no punctutation
	{
		if (ispunct(str[i]))
		{	
			str.erase(i, 1);   // erase the element i to one place.
			i--;   // new character takes place of the erased one. We are neglecting the effect of loop increment
			len = str.size(); // removing the punctutation shrinks the string size
		}						// length size changes with every iteration and we give new len value
	}
	
	cout << "The word without punctutation is " << str << endl;

	return 0;
}
string str;
	cout << "Enter the string: " << endl;
	getline(cin, str);
	
	
	for (auto & ind : str)
	{
		if (ispunct(ind))
			ind = ' ';
	}
	
	cout << str;
#include <iostream>
#include <string>
using namespace std;
using std::string;
const string hexdigits = "0123456789ABCDEF"; // possible hex digits


int main()
{
	
	cout << "Enter a series of numbers between 0 and 15"
		<< " separated by spaces. Hit ENTER when finished: "
		<< endl;
	string result = ""; // will hold the resulting hexify’d string
	unsigned int n; // hold numbers from the input
	

	while (cin >> n )
	{
		if (n < 16) // ignore invalid input
			result += hexdigits[n]; // fetch the indicated hex digit
		else if (n == 17)
			break;
	}

	cout << "Your hex number is: " << result << endl;

	return 0;
}

#include <iostream>
#include <string>
using namespace std;
using std::string;



int main()
{
	string str("helloWorld ");
	/*
	the for loop terminates at that very time when the condition is not met. 
	In our case for loop works until the whitespace is met or we go beyond str size
	decltype is the almost the same auto, find data type automatically of the expression!!!
	*/

	for (decltype(str.size()) i = 0; i != str.size() && !isspace(str[i]); i++)
	{
		str[i] = toupper(str[i]);
	}
	

	cout <<"The new string is " << str<< endl;
	return 0;
}
#include <iostream>
#include <string>
using namespace std;
using std::string;

/*
Remember that a reference is just
another name for a given object. When we use a reference as our control variable,
that variable is bound to each element in the sequence in turn. Using the reference,
we can change the character to which the reference is bound.

*/

int main()
{
	string str("HeLLo World");
	
	
	for (auto &n : str)
	{
		if (isupper(n))
			n=tolower(n);
		else
			n = toupper(n);
	}
	cout <<"The new string is " << str<< endl;
	return 0;
}
#include <iostream>
#include <string>
using namespace std;
using std::string;



int main()
{
	string str("AbZal NUrgAzy");
	
	
	for (auto n : str)
	{
		if (isupper(n))
			cout << (char)(tolower(n));
		else
			cout << (char)(toupper(n));
	}
	cout << endl;
	return 0;
}
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string name, name1;
	char ch;

	cout << "Enter any sentence" << endl;    // printing the middle letter 
	getline(cin, name);
	ch = name[name.length()/2];
	cout << "The middle letter in the sentence is " << ch << endl;

	for (int i = 0; i <= (name.length() / 2)-1; i++)    // printing the first half of the sentence
	{
		cout << name[i];
	}
	cout << "\nThe second half " << endl;

	for (int i = (name.length() / 2 )+1; i <= name.length(); i++)    // printing the second half of the sentence
	{
		cout << name[i];
	}


	return 0;
}
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;


int main()
{
    string day;
    int startTime, minutes;
    double cost, rate; 
    char ch ;

    cout << fixed << showpoint << setprecision(2);

    do {
        cout << "Enter start time of the call(For example, 2:30 = 2330):  " << endl;
        cin >> startTime;

        while (startTime<0 || startTime>2400) {

            cout << "\nInvalid time.";          // keep asking for time input until it is valid
            cout << "Enter start time of the call(For example, 2:30 = 2330): ";
            cin >> startTime;
        }

        cout << "Enter length of the call in minutes: ";
        cin >> minutes;
        cout << "Enter the day of the week: ";
        cin >> day;

        if (day == "monday" || day == "MONDAY" || day == "tuesday" || day == "TUESDAY" || day == "wednesday" || day == "WEDNESDAY"
            || day == "THURSDAY" || day == "thursday" || day == "friday" || day == "FRIDAY") {

            if (startTime >= 800 && startTime <= 1800)
                rate = 0.4;
            else
                rate = 0.25;
            cost = minutes * rate;

            cout << "\nRate for the call was " << "$" << rate << " a minute" << endl
                 << "Your total cost: " << "$" << cost << endl;
        }

        else if (day == "saturday" || day == "SATURDAY" || day == "sunday" || day == "SUNDAY")
        {
            rate = 0.15;
            cost = minutes * rate;
            cout << "\Rate for the call was " << "$" << rate << " a minute" << endl
                 << "Your total cost: " << "$" << cost;

        }

        else
            cout << "\nInvalid.";

        cout << "\nWould you like to calculate  your bill again ? (y / n) : ";
        cin >> ch;
        cout << endl;
        
        

    }


    while (ch == 'Y' || ch == 'y');
    cout << "End of programm" <<endl;

    return 0;
}
 do {
        :
        :
        :
		:
        else
        {
            cout << "\nInvalid.";
            cout << "\nWould you like to calculate  your bill again ? (y / n) : ";
            cin >> ch;
            cout << endl;
        }
        

    }


    while (ch == 'Y' || ch == 'y');
    cout << "End of programm" <<endl;
while (startTime<0 || startTime>2400) {

            cout << "\nInvalid time.";          // keep asking for time input until it is valid
            cout << "Enter start time of the call(For example, 2:30 = 2330): ";
            cin >> startTime;
        }
#include <iostream>
#include <string>
using namespace std;


int main()
{
    string userName;
    cout << "Enter the user name" << endl;
    getline(cin, userName);

    for (int ind = userName.length()-1; ind >= 0; ind--) {
        cout << userName[ind];
    }
    cout << endl;

    return 0;
}
#include <iostream>
using namespace std;
int const MAX = 60;
int maxinlst(int arr[], int sizeofArr); 

int main()
{
    int arr[MAX];
    int sizeofArr, currNum, maximum;

    cout << "Enter the size of the array " << endl;
    cin >> sizeofArr;
    cout << "Enter the list of numbers" << endl;
    for (int i = 0; i < sizeofArr; i++) {
        cin >> currNum;
        arr[i] = currNum;
    }

    maximum = maxinlst( arr,sizeofArr);
    cout << "The maximum is " << maximum << endl;


    return 0;
}

int maxinlst(int arr[], int sizeofArr) {

    int max = arr[0];
    for (int i = 1; i < sizeofArr; i++) {
        if (arr[i] > max) {
            max = arr[i];
        }
    }
    return max;
}
#include <iostream>
using namespace std;
const int MAX_ARRAY = 60;

int main()
{
    int numberofStudents, currGrade,sum;
    double average;
    int grades[MAX_ARRAY];

    cout << "Enter the number of students" << endl;
    cin >> numberofStudents;
    cout << "Enter the grades separated by a space" << endl;
    
    // Reading the grades one by one and uploading it inside the array
    for (int i = 0; i < numberofStudents; i++) {
        cin >> currGrade;
        grades[i] = currGrade;
    }
    // calculating the sum and average

    sum = 0;
    for (int i = 0; i < numberofStudents; i++) {
        sum += grades[i];
    }
    average = (double)sum / (double)numberofStudents;

    cout << "the average grade is " << average << endl;
    for (int i = 0; i < numberofStudents; i++) {
        if (grades[i] > average) {
            cout << "The grades that is more than the average is " << grades[i] << endl;
        }
    }
    
    return 0;
}
#include <iostream>
#include <cmath>
using namespace std;

const int NO_SOLUTION = 0;
const int ONE_REAL_SOLUTION = 1;
const int TWO_REAL_SOLUTIONS = 2;
const int ALL_REALS = 3;
const int NO_REAL_SOLUTIONS = 4;


int linear(double a, double b, double& outX);
int quadratic(double a, double b, double c, double& outX1, double& outX2);

int main()
{
	double a, b, c,x1,x2;
	cout << "Enter the quadratic equation coefficients" << endl;
	cin >> a >> b >> c;

	switch (quadratic(a,b,c,x1,x2)) {

		case NO_SOLUTION: 
			cout << "No solutions" << endl;
			break;

		case ONE_REAL_SOLUTION:
			cout << "One solution: " << x1 << endl;
			break;

		case TWO_REAL_SOLUTIONS:
			cout << "Two real solutions: " << x1 << " and " << x2 << endl;
			break;

		case ALL_REALS:
			cout << "All real number are solutions" << endl;
			break;

		case NO_REAL_SOLUTIONS:
			cout << "No real solutions" << endl;
			break;
	}


	return 0;
}

int quadratic(double a, double b, double c, double& outX1, double& outX2) {

	double delta, x1, x2;
	delta = b * b - 4 * a * c;

	if (delta != 0.0) {
		

		if (delta > 0) {
			x1 = (-b + sqrt(delta)) / (2 * a);
			x2 = (-b - sqrt(delta)) / (2 * a);
			outX1 = x1;
			outX2 = x2;
			return TWO_REAL_SOLUTIONS;
		}

		else if (delta == 0.0) {
			x1 = -b / (2 * a);
			return ONE_REAL_SOLUTION;
		}
		else
			return NO_REAL_SOLUTIONS;
	}
	else
		return linear(b, c, outX1);

	
}

int linear(double a, double b, double& outX) {
	double x;
		
	if (a != 0) {
		x = -b / a;
		outX = x;
		return ONE_REAL_SOLUTION;
	}
	else if ((a == 0) && (b == 0)) {
		x = 0;
		outX = x;
		return ALL_REALS;
	}
	else
		return NO_SOLUTION;

}
#include <iostream>
using namespace std;

int analyzeDigits(int num, int& outSum);

int main()
{

	int num;
	int sumDigits, countDigits;

	cout << "Enter any nymber to get its sum and number of digits" << endl;
	cin >> num;

	countDigits = analyzeDigits(num, sumDigits);

	cout << num << " has " << countDigits << " digits and their sum is " << sumDigits << endl;

	return 0;
}

int analyzeDigits(int num, int& outSum) {

	int count = 0, sum = 0;
	int currDig;

	while (num > 0) {
		currDig = num % 10;
		sum += currDig;
		count++;
		num = num / 10;

	}

	outSum = sum;    // directly changes main variable by reference while one of outputs is returned
	return count;

}
#include <iostream>
using namespace std;

int factorial(int num); // <-- remember to include semicolon  

// we use prototype of the function to hold the function itself after the main function and show that there is a function with similar name and fuctionality when come across first time.


int main()
{
	int n, k, result;

	cout << "Please enter the n and k by space" << endl;
	cin >> n >> k;


	result =  factorial(n) / (factorial(k)*factorial(n-k));

	cout << "The result is " << result << endl;

	return 0;
}

int factorial(int num) {
	int i, factRes;
	factRes = 1;

	for (i = 1; i <= num;i++) {
		factRes *= i;
	}

	return factRes;
#include <iostream>
using namespace std;

// n choose k, combination method using factorials

int main()
{
	int n, k, k_Fact, n_Fact, result, k_nFact;

	cout << "Please enter the n and k by space" << endl;
	cin >> n >> k;

	n_Fact = 1;
	for (int i = 1; i <= n; i++) {
		n_Fact *= i;
	}

	k_Fact = 1;
	for (int i = 1; i <= k; i++) {
		k_Fact *= i;
	}
	
	k_nFact = 1;
	for (int i = 1; i <= (n-k); i++) {
		k_nFact *= i;
	}

	result = n_Fact / (k_Fact* k_nFact);

	cout << "The result is " << result << endl;

	return 0;
}
#include <iostream>
using namespace std;

// Fibonacci sequence 

int main()
{

	int first = 0, second = 1;
	int next, num;

	cout << "Enter the number of Fibonacci sequence" << endl;
	cin >> num;

	cout << "Fibonacci series is " << endl;

	for (int i = 1; i <= num; ++i) {

		cout << first << endl;
		next = first + second;
		first = second;
		second = next;

	}

	return 0;
}
#include <iostream>
using namespace std;

// here we use flag method to count the average grade

int main()
{
	bool seenEndofInput;
	int numofStudents, sum;
	int curr;
	double average;

	cout << "Write grades by separated space" << endl;
	cout << "End of grades by typing -1" << endl;

	numofStudents = 0;
	sum = 0;

	seenEndofInput = false;

	while (seenEndofInput == false) {
		cin >> curr;

		if (curr == -1) {
			seenEndofInput == true;
		}
		else {
			sum += curr;
			numofStudents++;
		}
	}

	average = (double)sum / (double)numofStudents;


	cout << "The class average grade is " << average << endl;

	return 0;
}
#include <iostream>
#include <string>
using namespace std;



int main()
{
    int numofStudents;
    int curr, sum=0;
    double average;

    cout << "Please enter number of students" << endl;
    cin >> numofStudents;
    cout << "Write grades" << endl;
    
    for (int count = 1; count <= numofStudents;++count) {
        cin >> curr;
        sum += curr;
    }
    average = (double)(sum / numofStudents);


    cout << "The average grade is "<<average << endl;

    return 0;
}
#include <iostream>
#include <string>
using namespace std;

/*
375 / 10 = 37;
375 % 10 = 5 ;
So here you are separating one number in one loop from the main number

*/

int main()
{
    int countDigits = 0, countSum = 0;
    int num,currDigit;

    cout << "Enter any number" << endl;
    cin >> num;
    while (num>0) {
        currDigit = (num % 10);
        countSum += currDigit;
        countDigits++;
        num = num / 10;
    }

    cout << "The sum of digits is: " << countSum << " and the count of digits is: " << countDigits << endl;


    return 0;
}

#include <iostream>
#include <string>
using namespace std;


int main()
{
    int num;
    int even_cnt = 0, odd_cnt=0;
    cout << "Write any 4 numbers" << endl;;
    
    for (int i=1; i <= 4; ++i) {
        cin >> num;

        if (num % 2 == 0) {
            ++even_cnt;
        }
        else
            ++odd_cnt;
    }
    
    if (even_cnt > odd_cnt) {
        cout << "even numbers are more";
    }
    else if (even_cnt < odd_cnt) {
        cout << "odd numbers are more";
    }
    else 
        cout << "they are equal";
    return 0;
}

#include <iostream>
#include <string>
using namespace std;


int main()
{
    
    int hour24, minutes24;
    int hour12, minutes12;
    string period;
    char value;

    cout << "Enter the time in a 24-hour format \n";
    cin >> hour24 >> value >> minutes24;

    minutes12 = minutes24;

    if (hour24 >= 0 && hour24 <= 11) {
        period = "AM";
        if (hour24 == 0) {
            hour12 = 12;
        }
        else
            hour12 = hour24;
    }
    else
    {
        period = "PM";
        if (hour24 == 12) {
            hour12 = hour24;
        }
        else
            hour12 = hour24 - 12;
    }

    cout << hour24 << value << minutes24 << " is " << hour12 << value << minutes12<<" " << period << endl;

    return 0;
}
#include <iostream>
using namespace std;


int main()
{
    
    char charVal;
    cout << "Enter the character"<< endl;
    cin >> charVal;
    if (charVal >= 'a' && charVal <= 'z') {

        cout << "The lowercase character";
    }
    else if (charVal >= 'A' && charVal <= 'Z') {
        cout << "The uppercase character";
    }
    else if (charVal >= '1' && charVal <= '9') {
        cout << "The numeric character";
    }
    else 
        cout << "The non alpha-numeric character";

    return 0;
}
#include <iostream>
using namespace std;


int main()
{
    int dollar, cent, amount, leftover;
    int quarter, dime, nickel, penny;

    cout << "Write please amount of dollar through space";
    cin >> dollar >> cent;

    amount = 100 * dollar + cent;
    quarter = amount / 25;
    leftover = amount % 25;

    dime = leftover / 10;
    leftover = leftover % 10;

    nickel = leftover / 5;
    leftover = leftover % 5;

    penny = leftover; 

    cout << "Quarter: " << quarter << endl;
    cout << "Dime: " << dime << endl;
    cout << "Nickel: " << nickel << endl;
    cout << "Penny: " << penny << endl;

    return 0;
}

#include <iostream>
using namespace std;


int main()
{
    
    char lowerCase, upperCase;
    int offset;

    cout << "Enter lowercase letter \n";
    cin >> lowerCase;

    offset = (int)(lowerCase-'a');
    upperCase = (char)('A' + offset);
    cout << "Uppercase letter is " << upperCase << endl;


    return 0;
}
#include<bits/stdc++.h>
 
using namespace std;
 
struct node {
    int data;
    struct node *next;
};
 
// To create a demo we have to construct a linked list and this 
// function is to push the elements to the list. 
void push(struct node **head_ref, int data) {
    struct node *node;
    node = (struct node*)malloc(sizeof(struct node));
    node->data = data;
    node->next = (*head_ref);
    (*head_ref) = node;
}
 
// Function to reverse the list
void reverse(struct node **head_ref) {
    struct node *temp = NULL;
    struct node *prev = NULL;
    struct node *current = (*head_ref);
    while(current != NULL) {
        temp = current->next;
        current->next = prev;
        prev = current;
        current = temp;
    }
    (*head_ref) = prev;
}
 
// To check our program 
void printnodes(struct node *head) {
    while(head != NULL) {
        cout<<head->data<<" ";
        head = head->next;
    }
}
 
// Driver function
int main() {
    struct node *head = NULL;
    push(&head, 0);
    push(&head, 1);
    push(&head, 8);
    push(&head, 0);
    push(&head, 4);
    push(&head, 10);
    cout << "Linked List Before Reversing" << endl;
    printnodes(head);
    reverse(&head);
    cout << endl;
    cout << "Linked List After Reversing"<<endl;
    printnodes(head);
    return 0;
}
// rdtsc.cpp
// processor: x86, x64
#include <stdio.h>
#include <intrin.h>

#pragma intrinsic(__rdtsc)

int main()
{
    unsigned __int64 i;
    i = __rdtsc();
    printf_s("%I64d ticks\n", i);
}
{
	// Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	"Print to console": {
		"prefix": "cpp boilerplate",
		"body": [
			"#include<bits/stdc++.h>",
			"#define rep(i,a,b) for(int i=a;i<b;i++)",
			"#define rrep(i,a,b) for(int i=a;i>=b;i--)",
			"#define ll long long",
			"#define take(n) ll int n;cin>>n",
			"#define mod 1000000007",
			"#define mp(a,b) make_pair(a,b)",
			"#define pb(a) push_back(a)",
			"#define pp pop_back()",
			"#define array(n,name) ll int *name=new ll int[n]",
			"#define Zubin ios::sync_with_stdio(false);",
			"#define Shah cin.tie(NULL);cout.tie(0);",
			"using namespace std;\n",
			"int main(){\n",
			"\tZubin Shah\n",
			"\tint N;",
			"\tcin>>N;",
			"\twhile(N--){",

			"\t\t$1",
			"\t}\n",
			"return 0;",
			"}",
		],
		"description": "Log output to console",
	}
}
	public:
	int findK(vector<vector<int>> &a, int n, int m, int k)
    {
        // 1 2 3 4 5 
        // 6 7 8 9 10
        //11 12 13 14 15
        //16 17 18 19 20
        //21 22 23 24 25
        // k=4
        // 1 2 3
        // 4 5 6
        // 7 8 9
        // Your code goes here
        // if(k==1) return a[0][0];
        int lrow=0;
        int lcol=0;
        int urow=n-1;
        int ucol=m-1;
        int count=0;
        int i=0,j=0;
        while(count!=k){
            //iterating from left to right
            for(j=lcol;j<=ucol;j++){
                // cout<<"i:"<<i<<"j:"<<j<<endl;
                count++;
                if(count==k) {
                    goto x;
                }
            }
            ucol--;
            j--;
            //iterating from up to down
            for(i=lrow+1;i<=urow;i++){
                // cout<<"i:"<<i<<"j:"<<j<<endl;
                count++;
                if(count==k) {
                    goto x;
                }
                
            }
            urow--;
            i--;
            //iterating from right to left
            for(j=ucol;j>=lcol;j--){
                // cout<<"i:"<<i<<"j:"<<j<<endl;
                count++;
                if(count==k) {
                    goto x;
                }
                
            }
            lcol++;
            j++;
            //iterating from down to up
             for(i=urow;i>=lrow+1;i--){
                //  cout<<"i:"<<i<<"j:"<<j<<endl;
                count++;
                if(count==k) {
            // cout<<"lrow:"<<lrow<<" urow:"<<urow<<" lcol:"<<lcol<<" ucol:"<<ucol<<endl;
                    goto x;
                }
                
            }
            lrow++;
            i++;
            
        }
        x:
        return a[i][j];
        
    }
class Solution {
public:
    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {
        vector<vector<int>>ans(r,vector<int>(c));
        int n = mat.size(), m = mat[0].size();
        if(n*m != r*c)  return mat;
        int p = 0, q = 0;
        for(int i = 0; i < r; ++i) {
            for(int j = 0; j < c; ++j) {
                ans[i][j] = mat[p][q];
                q = (q + 1) % m;
                if(q == 0)  p = p + 1;
            }
        }
        return ans;
    }
};
// TC - O(n) || SC - O(1)
class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int n = prices.size() - 1, ans = 0, minSoFar = INT_MAX;
        for(int i = 0; i < n; ++i)  {
            minSoFar = min(minSoFar, prices[i]);
            ans = max(ans, (prices[i] - minSoFar));
        }
        return ans;
    }
};

// we can use auxilary array and store maxSoFar value
class Solution {
public:
    vector<int> intersect(vector<int>& nums1, vector<int>& nums2) {
        unordered_map<int,int>mp;
        vector<int> ans;
        for(int i = 0; i < nums2.size(); ++i)   mp[nums2[i]]++;
    
        for(int i = 0; i < nums1.size(); ++i)   { 
            if(mp[nums1[i]] > 0)    {
                mp[nums1[i]]--;
                ans.push_back(nums1[i]);
            }
        }
        return ans;
    }
};
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        int i = 0, j = numbers.size() - 1;
        while(i < j) {
            int sum = numbers[i] + numbers[j];
            if(sum == target) return {i + 1, j + 1};
            else if(sum > target)  j--;
            else    i++;
        }
        return {};
    }
};
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        for(int i = 0, j = 0; i < nums.size(); i++) {
            if(nums[i]) {
                swap(nums[i],nums[j++]);
            }
        }
    }
};


//2nd approach
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int zero = 0, one = 0, n = nums.size()-1;
        while(zero < n && one < n)  {
            while(zero < n && nums[zero] != 0)  {
                zero++;
            }
            one = zero;
            while(one < n && nums[one] == 0)    {
                one++;
            }
            swap(nums[zero],nums[one]);
            zero++; 

        }
    }
};
class Solution {
public:
    void myReverse(vector<int> &nums,int start, int end)   {
        while(start < end)  {
            swap(nums[start++], nums[end--]);
        }
    }
    void rotate(vector<int>& nums, int k) {
        if(nums.size()<2)   return;
        k = k % nums.size();
        myReverse(nums, 0, nums.size() - k - 1);
        myReverse(nums, nums.size()-k, nums.size() - 1);
        myReverse(nums, 0 , nums.size() - 1);
    }
};
class Solution {
public:
    vector<int> sortedSquares(vector<int>& nums) {
        vector<int>ans(nums.size());
        int first = 0, second = nums.size() - 1;
        for(int ind = nums.size() - 1; ind >= 0; ind--)  {
            if(abs(nums[first]) < nums[second]) 
                ans[ind] = nums[second] * nums[second--];
            else    ans[ind] = nums[first] * nums[first++];
        }
        return ans;
        
    }
}


//2nd approch
class Solution {
public:
    vector<int> sortedSquares(vector<int>& nums) {
        vector<int>ans;
        int first = 0,second = 0;
        while(first<nums.size() && nums[first]<0  ) {
            first++;
        }
        second = first;
        first -= 1;
        while(first>=0 && second<nums.size())   {
            if(abs(nums[first] * nums[first]) < (nums[second] * nums[second]))  {
                ans.push_back(nums[first] * nums[first]);
                first--;
            }
            else {
                ans.push_back(nums[second] * nums[second]);
                second++;
            }
        }
        while(first>=0) {
            ans.push_back(nums[first] * nums[first]);
            first--;
        }
        while(second<nums.size())   {
            ans.push_back(nums[second] * nums[second]);
            second++;
        }
        return ans;

    }
};
class Solution {
public:
    bool containsDuplicate(vector<int>& nums) {
        unordered_set<int>st(nums.begin(), nums.end());
        cout<<nums.size()<<"  "<<st.size()<<endl;
        return (nums.size() == st.size()) ? false : true; 
    }
};
class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        int p = m-1, q = n-1, ind = nums1.size()-1;
        while(p>=0 && q>=0) {
            if(nums2[q] > nums1[p]) {
                nums1[ind--] = nums2[q];
                q--;
            }
            else    {
                nums1[ind--] = nums1[p];
                p--;
            }
        }
        while(q >= 0)    {
            nums1[ind--] = nums2[q--];
        }
    }
};
class Solution {
public:
    vector<int> plusOne(vector<int>& digits) {
        int n = digits.size();
        for(int i = n-1; i >=0 ; --i)   {
            if((digits[i] + 1) > 9) {
                digits[i] = 0;
            }
            else    {
                digits[i] += 1;
                return digits;
            }
        }
        digits.push_back(0);
        digits[0] = 1;
        return digits;
    }
};
class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int n = nums.size(), lMax = 0, gMax = nums[0];
        for(int i = 0; i < n; ++i)    {
            lMax += nums[i];
            gMax = max(gMax, lMax);
            if(lMax<0)  
                lMax = 0;
        }
        return gMax;
    }
};
// Using While Loop
class Solution {
public:
    int searchInsert(vector<int>& nums, int target) {
        int start = 0, end = nums.size()-1;
        while(start<=end)    {
            int mid = (start+end)/2;
            if(nums[mid] == target) return mid;
            else if(nums[mid] < target)    
                start = mid+1;
            else 
                end = mid-1;
        }
        return start;
    }
};


//Using Recursion
class Solution {
public:
    int BinSearch(vector<int>nums,int start, int end, int target) {
        if(end < start) {
            return start;
        }
        int mid = (start + end) / 2;
        if(nums[mid] == target) {
            return mid;
        }
        else if(nums[mid] < target) {
            return BinSearch(nums, mid+1, end, target);   
        }
        else {
            return BinSearch(nums, start, mid-1,target);
        }
    }
    int searchInsert(vector<int>& nums, int target) {
        return BinSearch(nums,0,nums.size()-1,target);  
    }
};
class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int start = 0, end = nums.size(),ans=0;
        while(start < end)  {
            if(nums[start] == val)  {
                swap(nums[start],nums[end-1]);
                end--;
            }    
            else start++;
        }
        return end;
    }
};
SDL_Rect rsc{}, dst{};
	for (const Tile& tile : m_pTiles)
	{
		rsc.x = static_cast<int>((m_LevelNumber * m_TileSize.x * 3) + m_TileSize.x * int(tile.tileState));
		rsc.y = 0;
		rsc.w = static_cast<int>(m_TileSize.x);
		rsc.h = static_cast<int>(m_TileSize.y);

		dst.x = static_cast<int>(tile.pos.x);
		dst.y = static_cast<int>(tile.pos.y);
		dst.w = static_cast<int>(m_TileSize.x);
		dst.h = static_cast<int>(m_TileSize.y);

		kaas::Renderer::GetInstance().RenderTexture(*m_pTexture, dst, rsc);
	}

	for (const Disc& disc : m_pPossibleDiscLocations)
	{
		if (disc.level == m_LevelNumber)
		{
			kaas::Renderer::GetInstance().RenderTexture(*m_pDiscTexture, disc.pos.x, disc.pos.y);
		}
	}
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define take(n) ll int n;cin>>n
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;

int main()
{
    // Zubin Shah
    int N;
    cin>>N;
    while(N--)
    {
        take(n);
        vector<int> vect;
        vect.pb(1);
        ll carry=0;
        int number_of_digits=1;
        rep(i,2,n+1){
            rep(j,0,number_of_digits){
                ll temp=(vect[j]*i)+carry;
                vect[j]=temp%10;
                carry=temp/10;
            }
            while(carry>0){
                ll temp=carry%10;
                vect.pb(temp);
                carry/=10;
                number_of_digits++;
            }
        }
        rrep(i,number_of_digits-1,0){
            cout<<vect[i];
        }
        cout<<endl;
    }


return 0;
}
vector* sum( vector* v, int n ) {
    vector* r = ( vector* )( malloc( sizeof( vector ) ) );
    for( i = 0; i < n; i++ ) {
        r = add( r, v + i );
    }
    
    return r;
}
typedef struct __vector {
    int x;
    int y;
} vector;

vector* add( vector* a, vector* b ) {
    vector* r = ( vector* )( malloc( sizeof( vector ) ) );
    r->x = a->x + b->x;
    r->y = a->y + b->y;
    
    return r;
}
a = a ^ b;
b = a ^ b;
a = a ^ b;
#include <iostream>

using namespace std;

int main()
{
    cout<<"Hello World";

    return 0;
}
// O(n) Linear search
void MinMaxValue(vector<int>arr)  {
    int mini = arr[0], maxi = arr[0];
    for(int i=1;i<arr.size();i++)   {
        if(arr[i]<mini) 
          mini = arr[i];
        if(arr[i]>maxi) 
          maxi = arr[i];
    }
    cout<<mini<<" "<<maxi;
}
// TWO POINTER APPROCH
void reverseString(vector<char>& s) {
  int start=0,end=s.size()-1;
  while(start<end)
    swap(s[start++],s[end--]);
}
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ull unsigned long long
using namespace std;
void merge(int *arr1,int *arr2,int n, int m){
    int i=0,j=0,k=0;
    int maxi=INT_MIN;
    rep(i,0,n) maxi=max(arr1[i],maxi);
    rep(i,0,m) maxi=max(arr2[i],maxi);
    maxi++;
    while(i<n && j<m){
        int x=arr1[i]%maxi;
        int y=arr2[j]%maxi;
        if(x<y){
            if(k<n)  arr1[k]+=x*maxi;
            else  arr2[k-n]+=x*maxi;
            k++;
            i++;
        }
        else{
            if(k<n)  arr1[k]+=y*maxi;
            else arr2[k-n]+=y*maxi;
            k++;
            j++;
        }
    }
    while(i<n){
        int x=arr1[i]%maxi;
        if(k<n) arr1[k]+=x*maxi;
        else arr2[k-n]+=x*maxi;
        k++;
        i++;
    }
    while(j<m){
        int x=arr2[j]%maxi;
        if(k<n) arr1[k]+=x*maxi;
        else  arr2[k-n]+=x*maxi;
        k++;
        j++;
    }
    rep(i,0,n) arr1[i]=arr1[i]/maxi;
    rep(i,0,m) arr2[i]=arr2[i]/maxi;
}
int main()
{
    int N;
    cin>>N;
    while(N--)
    {
        int n,m;
        cin>>n>>m;
        int *arr1=new int[n];
        int *arr2=new int[m];
        rep(i,0,n) cin>>arr1[i];
        rep(i,0,m) cin>>arr2[i];
        merge(arr1,arr2,n,m);
        rep(i,0,n) cout<<arr1[i]<<" ";
        rep(i,0,m) cout<<arr2[i]<<" ";
        cout<<endl;
    }


return 0;
}
uint64_t rdtsc() {
  uint32_t hi, lo;
  __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
 
  return ( (uint64_t)lo)|( ((uint64_t)hi)<<32 );
 }
#include<iostream>
using namespace std;

int main(){
  int n;
  cin >> n;
  cout << "Hello!" << n;
  return 0;
}
class Solution {
public:
    bool isSubsequence(string s, string t) {
        int i = t.length()-1;
        int j = s.length() - 1;
        while(i>=0 & j>=0){
            if(t[i]==s[j]){
                i--;
                j--; 
            }
            else{
                i--;
            }
                       
        }
        if(j==-1){
            return true;
        }
        return false;
    }
};
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ull unsigned long long
using namespace std;
bool check(pair<ull,ull> timing1,pair<ull,ull> timing2){
    return timing1.first>timing2.first ? false:true;
}
int waiting_time(pair<ull,ull> *timing,ull time,int n){
    int s=0,e=n-1;
    while(s<=e){
        ull mid=(s+e)/2;
        if(timing[mid].first>time){
            if(mid==0 || timing[mid-1].second<=time){
            return timing[mid].first-time;
            }
            e=mid-1;
        }
        else if(timing[mid].first<time){
            if(timing[mid].second>time) return 0;
            s=mid+1;
        }
        else return 0;
    }
    return -1;
}
int main()
{
    int N;
    cin>>N;
    while(N--)
    {
        int n,m;
        cin>>n>>m;
        pair<ull,ull> *timing=new pair<ull,ull>[n];
        rep(i,0,n) cin>>timing[i].first>>timing[i].second;
        sort(timing,timing+n,check);
        ull *people=new ull[m];
        rep(i,0,m)  {
          cin>>people[i];
          cout<<waiting_time(timing,people[i],n)<<endl;
       }
    }


return 0;
}
int ref = x;
        int y;
        int rev =0;
        if(x<0) return 0;
        if(x==0) return 1;
        if(x>INT_MIN || x<INT_MAX)
        {
            while(x)
        {
            y=x%10;
            x=x/10;
            if(rev > INT_MAX/10 || (rev == INT_MAX / 10 && y>7)) return 0;
            if(rev < INT_MIN/10 || (rev == INT_MIN / 10 && y<-8)) return 0;
            rev=rev*10+y;
        }
        
        }
        cout <<rev<<"\n";
        if(ref == rev)
        return rev;
        else 
            return 0;
class Solution {
public:
    int reverse(int x) {
        int y;
        int rev =0;
        if(x>INT_MIN || x<INT_MAX)
        {
            while(x)
        {
            y=x%10;
            x=x/10;
            if(rev > INT_MAX/10 || (rev == INT_MAX / 10 && y>7)) return 0;
            if(rev < INT_MIN/10 || (rev == INT_MIN / 10 && y<-8)) return 0;
            rev=rev*10+y;
        }
        
        }
        return rev;
    }
};
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        vector<int> I;
        
        int y;
        for (int x=0; x<nums.size(); x++)
        {
            y=0;
            for (int z=x+1; z<nums.size(); z++)
            {
                y=nums[x]+nums[z];
            if(y==target)
            {
                I.push_back(x);
                I.push_back(z);
                break;
            }
            }
               
            
                
        }
        
        return I;
    }
};
/**
 * Definition for singly-linked list.
 * class ListNode {
 *     val: number
 *     next: ListNode | null
 *     constructor(val?: number, next?: ListNode | null) {
 *         this.val = (val===undefined ? 0 : val)
 *         this.next = (next===undefined ? null : next)
 *     }
 * }
 */
 
function reverseBetween(head: ListNode | null, left: number, right: number): ListNode | null {
    
    if (head === null)
        return null;
    
    let currPtr = head, prevPtr = null;
    
    while (left > 1) {
        prevPtr = currPtr;
        currPtr = currPtr.next;
        
        left--;
        right--;
    }
    
    let tailPtr = currPtr, connPtr = prevPtr, thirdPtr: ListNode | null = null;
    
    while (right > 0) {
        thirdPtr = currPtr.next;
        currPtr.next = prevPtr;
        prevPtr = currPtr;
        currPtr = thirdPtr;
        
        right--;
    }
    
    if (connPtr)
        connPtr.next = prevPtr;
    else
        head = prevPtr;
    
    tailPtr.next = currPtr;
    
    return head;
};
#include<iostream>
using namespace std;
bool issafe(int** arr,int x,int y,int n){
    for(int row=0;row<x;row++){
        if(arr[row][y]==1) return false;
    }
    int row=x-1;
    int col=y-1;
    while(row>=0 && col>=0){
        if(arr[row][col]==1)return false;
        row--;
        col--;
    }
     row=x-1;
     col=y+1;
    while(row>=0 && col<n){
        if(arr[row][col]==1)  return false;
        row--;
        col++;
    }
    return true ;
}
bool nqueen(int** arr,int n,int x=0){
    if(x>=n) return true;
    for(int col=0;col<n;col++){
        if(issafe(arr,x,col,n)){
            arr[x][col]=1;
            if(nqueen(arr,n,x+1)) return true;
            arr[x][col]=0;  //backtracking
        }
    }
    return false;
}
int main(){
    int n;
    cin>>n;
    int **arr=new int*[n];
    for(int i=0;i<n;i++){
        arr[i]=new int[n];
        for(int j=0;j<n;j++) arr[i][j]=0;
    }
    if(nqueen(arr,n)){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++) cout<<arr[i][j]<<" ";
            cout<<endl;
        }
    }
    return 0;
}
#include<iostream>
using namespace std;
bool issafe(int** arr,int x,int y,int n){
    for(int row=0;row<=x;row++){
        if(arr[x][y]==1){
            return false;
        }
    }
    int row=x;
    int col=y;
    while(row>=0 && col>=0){
        if(arr[row][col]==1){
            return false;
        }
        row--;
        col--;
    }
     row=x;
     col=y;
    while(row>=0 && col<n){
        if(arr[row][col]==1){
            return false;
        }
        row--;
        col++;
    }
    return true ;
}
bool nqueen(int** arr,int x,int n){
    if(x>=n){
        return true;
    }
    for(int col=0;col<=n;col++){
        if(issafe(arr,x,col,n)){
            arr[x][col]==1;
            if(nqueen(arr,x+1,n)){
                return true;
            }
            arr[x][col]=0;  //backtracking
            
        }
    }
    return false;
}
int main(){
    int n;
    cin>>n;
    int** arr=new int*[n];
    for(int i=0;i<n;i++){
        arr[i]=new int[n];
        for(int j=0;j<n;j++){
            arr[i][j]=0;

        }
    }
    if(nqueen(arr,0,n)){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cout<<arr[i][j]<<"";
            }cout<<endl;
        }
    }


    return 0;
}
#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
	int search(vector<int> arr,int n,int x){
		int low=0,high=n-1;
		while(low<=high){
			int mid=low+(high-low)/2;
			if(arr[mid]>x){
				high=mid-1;
			}
			else if(arr[mid]<x){
				low=mid+1;
			}
			else{
				return mid;
			}
		}
		return low;
	}
    vector<int> findClosestElements(vector<int>& arr, int k, int x) {
		vector<int> ans;
		int n=arr.size();
        int i=search(arr,n,x);
		int l=i-1,r=i;
		while(k>0){
			if(l<0 || (r<n && abs(arr[l]-x)>abs(arr[r]-x))){
				r++;
			}
			else{
				l--;
			}
			k--;
		}
		l++;
		while(l<r){
			ans.push_back(arr[l]);
			l++;
		}
		return ans;
    }
};
int main(){
	Solution s;
	vector<int> a={1,2,3,4,5};
	int k=3,x=2;
	vector<int> ans=s.findClosestElements(a,k,x);
	for(auto i:ans){
		cout<<i<<" ";
	}cout<<endl;
	return 0;
}
#include<iostream>
#include<unordered_map>
#include<queue>
#define rep(i,a,b) for(long int i=a;i<b;i++)
#define ull unsigned long long
using namespace std;

int main()
{
    long int a,b,c;
    cin>>a>>b>>c;
    unordered_map<int,int> um;
    // int *array1=new int[a];
    int *array1=new int[a];
    int *array2=new int[b];
    int *array3=new int[c];
    rep(i,0,a) {
        cin>>array1[i];
         um[array1[i]]++;
    }
    rep(i,0,b) {
        cin>>array2[i];
    }
    rep(i,0,c) {
        cin>>array3[i];
    }
    queue<int> output;
    long int count=0;
    long  int i=0,j=0;
    while(i<b && j<c){
        if(array2[i]>array3[j]){
            if(um.find(array3[j])!=um.end()){
                count++;
                output.push(array3[j]);
            } 
                j++;
        }
        else if(array2[i]<array3[j]){
            if(um.find(array2[i])!=um.end()){
                count++;
                output.push(array2[i]);
            } 
                i++;
        }
        else{
            count++;
            output.push(array2[i]);
            i++;
            j++;
        }
    }
    while(i<b){
        if(um.find(array2[i])!=um.end()) {
        count++;
        output.push(array2[i]);
        }
        i++;
    }
    while(j<c){
        if(um.find(array3[j])!=um.end()) {
        count++;
        output.push(array3[j]);
        }
        j++;
    }
    cout<<count<<endl;
   while(!output.empty())
   {
       cout<<output.front()<<endl;
       output.pop();
   }

return 0;
}
// python
def isbright(image, dim=10, thresh=0.5):
    # Resize image to 10x10
    image = cv2.resize(image, (dim, dim))
    # Convert color space to LAB format and extract L channel
    L, A, B = cv2.split(cv2.cvtColor(image, cv2.COLOR_BGR2LAB))
    # Normalize L channel by dividing all pixel values with maximum pixel value
    L = L/np.max(L)
    # Return True if mean is greater than thresh else False
    return np.mean(L) > thresh

// c++
bool rockface_image_is_bright(cv::Mat img_mat, int dim, float threshold)
{
	// Resize image to 10x10
	cv::resize(img_mat, img_mat, { dim, dim });

	// Convert color space to LAB format and extract L channel
	cv::cvtColor(img_mat, img_mat, cv::COLOR_RGB2Lab);
	cv::Mat labchannel[3];
	cv::split(img_mat, labchannel);

	cv::imshow("L", labchannel[0]);
	cv::waitKey(0);

	// Normalize L channel by dividing all pixel values with maximum pixel value
	cv::Mat L;
	cv::normalize(labchannel[0], L, 0, 1, cv::NORM_MINMAX);

	// Return True if mean is greater than thresh else False
	float brightness = cv::mean(L).val[0];
	std::cout << "brightness: " << brightness << std::endl;
	return brightness > threshold;
}
void reverseStr(string& str)
{
    int n = str.length();
 
    // Swap character starting from two
    // corners
    for (int i = 0; i < n / 2; i++)
        swap(str[i], str[n - i - 1]);
}
 
class Solution
{
    public:
    void merge(int arr[], int l, int m, int r)
    {
         int n1=m-l+1; 
         int n2=r-m;
         // Initialization of temp arrays
         int L[n1],R[n2];
         // Initialization of first subarray
         for(int i=0;i<n1;i++)
         L[i]=arr[l+i];
         // Initialization of second subarray
         for(int j=0;j<n2;j++)
         R[j]=arr[m+1+j];
         int i=0,j=0,k=l;
         //Sorting the array using subarrays
         while(i<n1&&j<n2){
             if(L[i]<R[j]){
                 arr[k]=L[i];
                 i++;
             }
             else {
                 arr[k]=R[j];
                 j++;
             }
             k++;
         }
         //Remaining elements added to the array
         while(i<n1){
             arr[k]=L[i];
             i++;k++;
         }
         while(j<n2){
             arr[k]=R[j];
             j++;k++;
         }
    }
    public:
    void mergeSort(int arr[], int l, int r)
    {
        if(l>=r)
        return; //returns recursively
        int m=l+(r-l)/2;
        mergeSort(arr,l,m);
        mergeSort(arr,m+1,r);
        merge(arr,l,m,r);
    }
};
class Solution
{
    public:
    void insertionSort(int arr[], int n)
    {
        int value,hole;
        for(int i=0;i<n;i++){
            value=arr[i];hole=i;
        while(hole>0&&arr[hole-1]>value){
            arr[hole]=arr[hole-1];
            hole--;
        }
        arr[hole]=value;
        }
    }
};
class Solution
{
    public:
    int select(int arr[], int i)
    {
        int max = arr[0], ind = 0;
    int j;
    for ( j=1; j<=i; j++)
    {
        if (arr[j] > max)
        {
           ind = j;
           max = arr[j];
        }
    }
    return ind;
    }
     
    void selectionSort(int arr[], int n)
    {
       int i, j;
   for (i = n-1; i >=0; i--)      
   {
        int j = select(arr, i);
        swap(&arr[i], &arr[j]);
   }
    }
};
class Solution
{
    public:
    //Function to sort the array using bubble sort algorithm.
    void bubbleSort(int arr[], int n)
    {
      int flag=0;
    for(int k=1;k<=n-1;k++){
        for(int j=0;j<=n-k-1;j++){
            if(arr[j]>arr[j+1]){
                swap(&arr[j],&arr[j+1]);
              flag=1;
            }
        }
      if(flag==0)
        break;
    }
    }
    void swap(int *xp,int *yp){
        int temp=*xp;
        *xp=*yp;
        *yp=temp;
    }
};
class int_ptr_wrapper
{
public:
    int_ptr_wrapper(int value = 0) :
    mInt(new int(value))
    {}

    // note! needs copy-constructor and copy-assignment operator!

    ~int_ptr_wrapper()
    {
        delete mInt;
    }

private:
    int* mInt;
};
class Wrapper
{
 private:
  CLib *lib;

 public:
  Wrapper() { lib = lib_init(); } // Lib initialisieren
  ~Wrapper() { lib_cleanup(&init); } // Lib freigeben

  std::string DoSomething() 
  { 
    char *cstr = lib_get_str(); // String anfordern (malloc!)

    std::string s = str;  // in std::string kopieren

    lib_free_str(cstr); // String freigeben (free)

    return s; // std::string zurückgeben. Alles easy.
  }
};
///LIBRARIES & SPECIFIC PARAMETERS
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <U8g2lib.h>

Adafruit_PWMServoDriver servo = Adafruit_PWMServoDriver(0x40);  //ServoMotor Driver Controller I2C Address
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //OLED Constructor

//- - - - VARIABLES & METHODS - - - -//

#define jky 13              //Joystick button pin
#define emgPin A0           //EMG signal pin
#define emgThreshold 500    //EMG signal detection threshold   

/*----OLED Display & Driver----*/
void u8g2_prepare(void) {
  u8g2.setFontMode(1);              //Enable Transparent Font
  u8g2.setFont(u8g2_font_6x13_tf);  //Set font Width: 6px / Height: 13px
  u8g2.setFontRefHeightExtendedText();    
  u8g2.setFontPosTop();             //Origin Position of Text
  u8g2.setFontDirection(0);         //Font direction 0º
}
//Custom Drawn Symbols
static const unsigned char back[] U8X8_PROGMEM  = {
  0x04, 0x06, 0x7F, 0x86, 0x84, 0x60, };

/*---- Servo Driver Variables ----*/
#define Freq (uint8_t) 50     //Servo working frequency

#define posMin 102
#define posMax 512

//Finger Number Assignation for Servo Control
#define thumb (uint8_t) 0
#define index (uint8_t) 1
#define middle (uint8_t) 2 
#define ring (uint8_t) 3
#define pinky (uint8_t) 4
#define wrist (uint8_t) 5

//Method to map servo position from pulses to degrees
void setServo(uint8_t n_servo, uint8_t angulo){
  int duty;
  duty=map(angulo, 0, 180, posMin, posMax);
  servo.setPWM(n_servo, 0, duty);
}

//Method for EMG signal detection and actuation
void emg(void (*pointer)()){
  if((analogRead(A0))>emgThreshold){
    pointer();    
  }
  else{
    openHand();
  }
}

/*---- Hand Movements Methods ----*/
void closeHand(void){
    setServo(thumb,170);
    setServo(index,170);
    setServo(middle,175);
    setServo(ring,151);
    setServo(pinky,161);
    setServo(wrist,180);
}
void openHand(void){
    setServo(thumb,13);
    setServo(index,10 );
    setServo(middle,13);
    setServo(ring,13);
    setServo(pinky,13);
    setServo(wrist,180);
}
void rock_servo(void){
    setServo(thumb,170);
    setServo(index,13);
    setServo(middle,175);
    setServo(ring,151);
    setServo(pinky,13);
    setServo(wrist,180);
}
void ronaldinho_servo(){
    setServo(thumb,13);
    setServo(index,156);
    setServo(middle,145);
    setServo(ring,151);
    setServo(pinky,13);
    while(analogRead(A0)>emgThreshold){
      setServo(wrist,150);
      delay(400);
      setServo(wrist,180);
      delay(500);
    }
}
void point_servo(void){
    setServo(thumb,170);
    setServo(index,13);
    setServo(middle,145);
    setServo(ring,151);
    setServo(pinky,161);
    setServo(wrist,180);
}
void thumbsUp_servo(void){
    setServo(thumb,13);
    setServo(index,156);
    setServo(middle,145);
    setServo(ring,151);
    setServo(pinky,161);
    setServo(wrist,180);
}

/*---- Joystick Button----*/
#define jkyX A1
#define jkyY A2

uint8_t swbtn_state=0;    // Memory Storage Byte
bool btn_val=0;           // Current state of the button
bool btn_oldVal=1;        // Previous state of the button  

//Joystick Button Method
void btn_Jky(uint8_t x){
  btn_val=digitalRead(jky);   // read pin button
  if (btn_val == LOW && btn_oldVal == HIGH){
      swbtn_state=x;    
      delay(10);   
  }
  btn_oldVal=btn_val;
}

/*- *- *- *- - MENU SYSTEM - -* -* -* -*/
uint8_t M1 = 0; //Memory variable to determine menu state
uint8_t F1 = 0; //Memory variable to determine menu state
uint8_t C1 = 0; //Memory variable to determine menu state

//Mode_options
#define openClose (uint8_t) 1
#define figures (uint8_t)   2
#define custom  (uint8_t)   3

//Figures_options
#define rock (uint8_t)       1
#define ronaldinho (uint8_t) 2
#define point (uint8_t)      3
#define thumbUp (uint8_t)    4
#define goBackF1 (uint8_t)   5

//Custom_options
#define thumb (uint8_t)    1
#define index (uint8_t)    2
#define middle (uint8_t)   3
#define ring (uint8_t)     4
#define pinky (uint8_t)    5
#define wrist (uint8_t)    6
#define goBackC1 (uint8_t) 7

/*---- 1.MODES Menu Methods / All Menu Systems ----*/
/*-- Read Joystic M1 Method --*/
void jkyM1(void){
  if (analogRead(jkyX)<=341 && analogRead(jkyY)>=1010){
    M1 = openClose;
  }
  else if (analogRead(jkyX)>=342 && analogRead(jkyX)<=682 && analogRead(jkyY)>=990){
    M1 = figures;
  }
  else if (analogRead(jkyX)>=683 && analogRead(jkyX)<=1023 && analogRead(jkyY)>=980){
    M1 = custom;
  } 
}

/*---- Modes Screen Methods ----*/
void M1_openClose(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(32, 45, "OPEN/CLOSE");
  
  u8g2.drawBox(8,0,31,31);   //Selected box
  u8g2.drawStr(21,9, "1");   //Selected string
  
  u8g2.drawFrame(47,0,31,31);
  u8g2.drawStr(60,9, "2");
  
  u8g2.drawFrame(86,0,31,31);
  u8g2.drawStr(99,9, "3");
  
  u8g2.sendBuffer();
}
void M1_openClose_in(){
  emg(closeHand); 
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(32, 16, "Squeeze to");
  u8g2.drawStr(32, 32, "CLOSE HAND");
  
  u8g2.sendBuffer();
}
void M1_figures(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(42, 45, "FIGURES");
  
  u8g2.drawFrame(8,0,31,31);   
  u8g2.drawStr(21,9, "1");
  
  u8g2.drawBox(47,0,31,31);   //Selected box
  u8g2.drawStr(60,9, "2");    //Selected string
  
  u8g2.drawFrame(86,0,31,31);
  u8g2.drawStr(99,9, "3");
  
  u8g2.sendBuffer();
}
void M1_custom(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(19, 45, "CUSTOM MOVEMENT");
  
  u8g2.drawFrame(8,0,31,31);   
  u8g2.drawStr(21,9, "1");
  
  u8g2.drawFrame(47,0,31,31);   
  u8g2.drawStr(60,9, "2");
  
  u8g2.drawBox(86,0,31,31);   //Selected box
  u8g2.drawStr(99,9, "3");    //Selected string
  
  u8g2.sendBuffer();
}

//MAIN MENU SYSTEM(MODES) METHOD
void modes_M1(){  
  switch (M1){
    case openClose:
      if(swbtn_state==1){
        M1_openClose_in();
        btn_Jky(0);
      }
      else{
        jkyM1();
        openHand();
        M1_openClose();
        btn_Jky(1);
      }
      break;

    case figures:
      if(swbtn_state==2 || swbtn_state==3){
        figures_F1();
      }
      else{
        jkyM1();
        openHand();
        M1_figures();
        btn_Jky(2);
      }
      break;

    case custom:
      if(swbtn_state==4 || swbtn_state==5){
        custom_C1();
      }
      else{
        jkyM1();
        openHand();
        M1_custom();
        btn_Jky(4);
      }
      break;
  }
}

/*---- 2.FIGURES Menu Methods ----*/
/*-- Read Joystic F1 Method --*/
void jkyF1(void){
  if (analogRead(jkyX)<=150 && analogRead(jkyY)>=1022){
    F1 = rock;
  }
  else if (analogRead(jkyX)>=151 && analogRead(jkyX)<=540 && analogRead(jkyY)>=1022){
    F1 = ronaldinho;
  }
  else if (analogRead(jkyX)>=541 && analogRead(jkyX)<=767 && analogRead(jkyY)>=1022){
    F1 = point;
  }
  else if (analogRead(jkyX)>=768 && analogRead(jkyX)<=1023 && analogRead(jkyY)>=1022){
    F1 = thumbUp;
  }
  else if (analogRead(jkyX)>=400 && analogRead(jkyX)<=1023 && analogRead(jkyY)<=400){
    F1 = goBackF1;
  } 
}

/*---- Figures Screen Methods ----*/
void F1_rock(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(32, 32, "ROCK'N ROLL");
  
  u8g2.drawBox(11,0,17,17);   //Selected box
  u8g2.drawStr(17,2, "1");    //Selected string 
  
  u8g2.drawFrame(39,0,17,17);
  u8g2.drawStr(45,2, "2");
  
  u8g2.drawFrame(67,0,17,17);
  u8g2.drawStr(73,2, "3");
  
  u8g2.drawFrame(95,0,17,17);
  u8g2.drawStr(101,2, "4");

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();

}
void F1_rock_in(void){
  emg(rock_servo);
  btn_Jky(2);
  u8g2.clearBuffer();
  
  u8g2.drawStr(32, 16, "Squeeze to");
  u8g2.drawStr(32, 32, "ROCK'N ROLL");
  
  u8g2.sendBuffer();
}
void F1_ronaldinho(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(34, 32, "RONALDINHO");
  
  u8g2.drawFrame(11,0,17,17);
  u8g2.drawStr(17,2, "1");
  
  u8g2.drawBox(39,0,17,17);   //Selected box
  u8g2.drawStr(45,2, "2");    //Selected string
  
  u8g2.drawFrame(67,0,17,17);
  u8g2.drawStr(73,2, "3");
  
  u8g2.drawFrame(95,0,17,17);
  u8g2.drawStr(101,2, "4");

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}
void F1_ronaldinho_in(void){
  emg(ronaldinho_servo);
  btn_Jky(2);
  u8g2.clearBuffer();
  
  u8g2.drawStr(32, 32, "RONALDINHO!");
  
  u8g2.sendBuffer();
}
void F1_point(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(49, 32, "POINT");
  
  u8g2.drawFrame(11,0,17,17);
  u8g2.drawStr(17,2, "1");
  
  u8g2.drawFrame(39,0,17,17);     
  u8g2.drawStr(45,2, "2");
  
  u8g2.drawBox(67,0,17,17);   //Selected box
  u8g2.drawStr(73,2, "3");    //Selected string
  
  u8g2.drawFrame(95,0,17,17);
  u8g2.drawStr(101,2, "4");

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}
void F1_point_in(void){
  emg(point_servo);
  btn_Jky(2);
  u8g2.clearBuffer();
  
  u8g2.drawStr(32, 16, "Squeeze to");
  u8g2.drawStr(49, 32, "POINT");
  
  u8g2.sendBuffer();
}
void F1_thumbUp(){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(39, 32, "THUMBS UP");
  
  u8g2.drawFrame(11,0,17,17);
  u8g2.drawStr(17,2, "1");
  
  u8g2.drawFrame(39,0,17,17);     
  u8g2.drawStr(45,2, "2");
  
  u8g2.drawFrame(67,0,17,17);     
  u8g2.drawStr(73,2, "3");
  
  u8g2.drawBox(95,0,17,17);     //Selected box
  u8g2.drawStr(101,2, "4");     //Selected string
  
  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}
void F1_thumbUp_in(void){
  emg(thumbsUp_servo);
  btn_Jky(2);
  u8g2.clearBuffer();
  
  u8g2.drawStr(20, 16, "Squeeze to give");
  u8g2.drawStr(32, 30, "a THUMBS UP");
  
  u8g2.sendBuffer();
}
void F1_goBack(void){
  btn_Jky(0);  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(42, 32, "GO BACK");
  
  u8g2.drawFrame(11,0,17,17);
  u8g2.drawStr(17,2, "1");
  
  u8g2.drawFrame(39,0,17,17);     
  u8g2.drawStr(45,2, "2");
  
  u8g2.drawFrame(67,0,17,17);     
  u8g2.drawStr(73,2, "3");
  
  u8g2.drawFrame(95,0,17,17);
  u8g2.drawStr(101,2, "4");    

  u8g2.drawBox(115,51,12,10);   //Selected box
  
  u8g2.setDrawColor(0);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}

//MAIN FIGURES METHOD
void figures_F1(){
  switch (F1){
    case rock:
      if(swbtn_state==3){ //s'ha de canviar!!
        F1_rock_in();
      }
      else{
        btn_Jky(3);
        jkyF1();
        F1_rock();  //print on display F1_rock
      }
      break;
    
    case ronaldinho: 
      if(swbtn_state==3){ //s'ha de canviar!!
        F1_ronaldinho_in(); 
      }
      else{
        btn_Jky(3);
        jkyF1();
        F1_ronaldinho(); //print on display F1_ronaldinho
      }
      break;
    
    case point:
      if(swbtn_state==3){ //s'ha de canviar!!
        F1_point_in(); 
      }
      else{
        btn_Jky(3);
        jkyF1();
        F1_point(); //print on display F1_ronaldinho
      }
      break;

     case thumbUp:
      if(swbtn_state==3){ //s'ha de canviar!!
        F1_thumbUp_in(); 
      }
      else{
        btn_Jky(3);
        jkyF1();
        F1_thumbUp(); //print on display F1_ronaldinho
      }
      break;

     case goBackF1:
        jkyF1();
        F1_goBack(); //print on display F1_ronaldinho
      break;
  }
}

/*---- 3.CUSTOM Menu Methods ----*/
/*-- Read Joystic C1 Method --*/
void jkyC1(void){
  if (analogRead(jkyX)<=170 && analogRead(jkyY)>=1023){
    C1 = thumb;
  }
  else if (analogRead(jkyX)>=171 && analogRead(jkyX)<=341 && analogRead(jkyY)>=1023){
    C1 = index;
  }
  else if (analogRead(jkyX)>=342 && analogRead(jkyX)<=511 && analogRead(jkyY)>=1023){
    C1 = middle;
  }
  else if (analogRead(jkyX)>=512 && analogRead(jkyX)<=682 && analogRead(jkyY)>=1023){
    C1 = ring;
  }
  else if (analogRead(jkyX)>=683 && analogRead(jkyX)<=853 && analogRead(jkyY)>=1023){
    C1 = pinky;
  }
  else if (analogRead(jkyX)>=854 && analogRead(jkyX)<=1023 && analogRead(jkyY)>=1023){
    C1 = wrist;
  }
  else if (analogRead(jkyX)>=512 && analogRead(jkyX)<=1023 && analogRead(jkyY)<=450){
    C1 = goBackC1;
  }
}
/*-- Movement State for Individual Fingers Method --*/
uint8_t movement=0;
void jky_servo_movement(void){
    if(analogRead(jkyY)>=600){
        movement=1;
    }
    else if(analogRead(jkyY)<=400){
        movement=2;
    }
    else if(analogRead(jkyY)>=401 && analogRead(jkyY)<=599){
        movement=0;
    }
}

/*---- Custom Screen Methods ----*/
void C1_thumb(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(49, 32, "THUMB");
  
  u8g2.drawBox(2,0,17,17);   //Selected box
  u8g2.drawStr(8,2, "1");    //Selected string
  
  u8g2.drawFrame(23,0,17,17);
  u8g2.drawStr(29,2, "2");
  
  u8g2.drawFrame(44,0,17,17);
  u8g2.drawStr(50,2, "3");
  
  u8g2.drawFrame(65,0,17,17);
  u8g2.drawStr(71,2, "4");

  u8g2.drawFrame(86,0,17,17);
  u8g2.drawStr(92,2, "5");

  u8g2.drawFrame(107,0,17,17);
  u8g2.drawStr(113,2, "6");

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}

#define thumbMin 13
#define thumbMax 170
uint8_t thumb_angle=13;
uint8_t thumb_percentage=0;

void C1_thumb_in(void){
    jky_servo_movement();
    btn_Jky(4);
    if(movement==1 && thumb_angle<thumbMax){
        thumb_angle++;
    }
    else if(movement==2 && thumb_angle>thumbMin){
        thumb_angle--;
    }
    setServo(0,thumb_angle);
    thumb_percentage=map(thumb_angle, thumbMin, thumbMax, 0, 100);
    String percentage = String(thumb_percentage);
  
    u8g2.clearBuffer();
    u8g2.setDrawColor(2);
  
    u8g2.drawStr(16, 0, "Adjust Position");

    u8g2.drawStr(12,24, "Thumb:");
    u8g2.drawStr(64,24, percentage.c_str());   //map variable for %
    u8g2.drawStr(82,24, "%");
    
    u8g2.drawFrame(12,40,102,17);
    u8g2.drawBox(13,41,thumb_percentage,15);   //x is percentage of map
    
    u8g2.sendBuffer();
  
}
void C1_index(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(49, 32, "INDEX");
  
  u8g2.drawFrame(2,0,17,17);   
  u8g2.drawStr(8,2, "1");
  
  u8g2.drawBox(23,0,17,17);   //Selected box
  u8g2.drawStr(29,2, "2");     //Selected string
  
  u8g2.drawFrame(44,0,17,17);
  u8g2.drawStr(50,2, "3");
  
  u8g2.drawFrame(65,0,17,17);
  u8g2.drawStr(71,2, "4");

  u8g2.drawFrame(86,0,17,17);
  u8g2.drawStr(92,2, "5");

  u8g2.drawFrame(107,0,17,17);
  u8g2.drawStr(113,2, "6");

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);

  u8g2.sendBuffer();
}

#define indexMin 10
#define indexMax 170
uint8_t index_angle=10;
uint8_t index_percentage=0;

void C1_index_in(){
  jky_servo_movement();
  btn_Jky(4);
  if(movement==1 && index_angle<indexMax){
      index_angle++;
  }
  else if(movement==2 && index_angle>indexMin){
      index_angle--;
  }
  setServo(1,index_angle);
  index_percentage=map(index_angle, indexMin, indexMax, 0, 100);
  String percentage = String(index_percentage);
  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(16, 0, "Adjust Position");

  u8g2.drawStr(12,24, "Index:");
  u8g2.drawStr(64,24, percentage.c_str());   //map variable for %
  u8g2.drawStr(82,24, "%");
    
  u8g2.drawFrame(12,40,102,17);
  u8g2.drawBox(13,41,index_percentage,15);   //x is percentage of map
    
  u8g2.sendBuffer();
}
void C1_middle(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(47, 32, "MIDDLE");
  
  u8g2.drawFrame(2,0,17,17);   
  u8g2.drawStr(8,2, "1");
  
  u8g2.drawFrame(23,0,17,17);   
  u8g2.drawStr(29,2, "2");
  
  u8g2.drawBox(44,0,17,17);   //Selected box
  u8g2.drawStr(50,2, "3");    //Selected string
  
  u8g2.drawFrame(65,0,17,17);
  u8g2.drawStr(71,2, "4");

  u8g2.drawFrame(86,0,17,17);
  u8g2.drawStr(92,2, "5");

  u8g2.drawFrame(107,0,17,17);
  u8g2.drawStr(113,2, "6");

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}

#define middleMin 13
#define middleMax 175
uint8_t middle_angle=13;
uint8_t middle_percentage=0;

void C1_middle_in(void){
  jky_servo_movement();
  btn_Jky(4);
  if(movement==1 && middle_angle<middleMax){
      middle_angle++;
  }
  else if(movement==2 && middle_angle>middleMin){
      middle_angle--;
  }
  setServo(2,middle_angle);
  middle_percentage=map(middle_angle, middleMin, middleMax, 0, 100);
  String percentage = String(middle_percentage);
  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(16, 0, "Adjust Position");

  u8g2.drawStr(12,24, "Middle:");
  u8g2.drawStr(64,24, percentage.c_str());   //map variable for %
  u8g2.drawStr(82,24, "%");
    
  u8g2.drawFrame(12,40,102,17);
  u8g2.drawBox(13,41,middle_percentage,15);   //x is percentage of map
    
  u8g2.sendBuffer();
}
void C1_ring(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(52, 32, "RING");
  
  u8g2.drawFrame(2,0,17,17);   
  u8g2.drawStr(8,2, "1");
  
  u8g2.drawFrame(23,0,17,17);   
  u8g2.drawStr(29,2, "2");
  
  u8g2.drawFrame(44,0,17,17);
  u8g2.drawStr(50,2, "3");
  
  u8g2.drawBox(65,0,17,17);   //Selected box
  u8g2.drawStr(71,2, "4");    //Selected string
  
  u8g2.drawFrame(86,0,17,17);
  u8g2.drawStr(92,2, "5");

  u8g2.drawFrame(107,0,17,17);
  u8g2.drawStr(113,2, "6");

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}

#define ringMin 13
#define ringMax 151
uint8_t ring_angle=13;
uint8_t ring_percentage=0;

void C1_ring_in(void){
  jky_servo_movement();
  btn_Jky(4);
  if(movement==1 && ring_angle<ringMax){
      ring_angle++;
  }
  else if(movement==2 && ring_angle>ringMin){
      ring_angle--;
  }
  setServo(3,ring_angle);
  ring_percentage=map(ring_angle, ringMin, ringMax, 0, 100);
  String percentage = String(ring_percentage);
  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(16, 0, "Adjust Position");

  u8g2.drawStr(12,24, "Ring:");
  u8g2.drawStr(64,24, percentage.c_str());   //map variable for %
  u8g2.drawStr(82,24, "%");
    
  u8g2.drawFrame(12,40,102,17);
  u8g2.drawBox(13,41,ring_percentage,15);   //x is percentage of map
    
  u8g2.sendBuffer();
}
void C1_pinky(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(49, 32, "PINKY");
  
  u8g2.drawFrame(2,0,17,17);   
  u8g2.drawStr(8,2, "1");
  
  u8g2.drawFrame(23,0,17,17);   
  u8g2.drawStr(29,2, "2");
  
  u8g2.drawFrame(44,0,17,17);   
  u8g2.drawStr(50,2, "3");
  
  u8g2.drawFrame(65,0,17,17);
  u8g2.drawStr(71,2, "4");

  u8g2.drawBox(86,0,17,17);   //Selected box
  u8g2.drawStr(92,2, "5");    //Selected string

  u8g2.drawFrame(107,0,17,17);
  u8g2.drawStr(113,2, "6");

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}

#define pinkyMin 13
#define pinkyMax 161
uint8_t pinky_angle=13;
uint8_t pinky_percentage=0;

void C1_pinky_in(void){
  jky_servo_movement();
  btn_Jky(4);
  if(movement==1 && pinky_angle<pinkyMax){
      pinky_angle++;
  }
  else if(movement==2 && pinky_angle>pinkyMin){
      pinky_angle--;
  }
  setServo(4,pinky_angle);
  pinky_percentage=map(pinky_angle, pinkyMin, pinkyMax, 0, 100);
  String percentage = String(pinky_percentage);
  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(16, 0, "Adjust Position");

  u8g2.drawStr(12,24, "Pinky:");
  u8g2.drawStr(64,24, percentage.c_str());   //map variable for %
  u8g2.drawStr(82,24, "%");
    
  u8g2.drawFrame(12,40,102,17);
  u8g2.drawBox(13,41,middle_percentage,15);   //x is percentage of map
    
  u8g2.sendBuffer();
}
void C1_wrist(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(49, 32, "WRIST");
  
  u8g2.drawFrame(2,0,17,17);   
  u8g2.drawStr(8,2, "1");
  
  u8g2.drawFrame(23,0,17,17);   
  u8g2.drawStr(29,2, "2");
  
  u8g2.drawFrame(44,0,17,17);   
  u8g2.drawStr(50,2, "3");
  
  u8g2.drawFrame(65,0,17,17);
  u8g2.drawStr(71,2, "4");

  u8g2.drawFrame(86,0,17,17);
  u8g2.drawStr(92,2, "5");

  u8g2.drawBox(107,0,17,17);    //Selected box
  u8g2.drawStr(113,2, "6");     //Selected string

  u8g2.drawFrame(115,51,12,10);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  
  u8g2.sendBuffer();
}

#define wristMin 180
#define wristMax 150
uint8_t wrist_angle=180;
uint8_t wrist_percentage=0;

void C1_wrist_in(void){
  jky_servo_movement();
  btn_Jky(4);
  if(movement==1 && wrist_angle>wristMax){
      wrist_angle--;
  }
  else if(movement==2 && wrist_angle<wristMin){
      wrist_angle++;
  }
  setServo(5,wrist_angle);
  wrist_percentage=map(wrist_angle, wristMin, wristMax, 0, 100);
  String percentage = String(wrist_percentage);
  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(16, 0, "Adjust Position");

  u8g2.drawStr(12,24, "Wrist:");
  u8g2.drawStr(64,24, percentage.c_str());   //map variable for %
  u8g2.drawStr(82,24, "%");
    
  u8g2.drawFrame(12,40,102,17);
  u8g2.drawBox(13,41,wrist_percentage,15);   //x is percentage of map
    
  u8g2.sendBuffer();
}
void C1_goBack(void){  
  u8g2.clearBuffer();
  u8g2.setDrawColor(2);
  
  u8g2.drawStr(43, 32, "GO BACK");
  
  u8g2.drawFrame(2,0,17,17);   
  u8g2.drawStr(8,2, "1");
  
  u8g2.drawFrame(23,0,17,17);   
  u8g2.drawStr(29,2, "2");
  
  u8g2.drawFrame(44,0,17,17);   
  u8g2.drawStr(50,2, "3");
  
  u8g2.drawFrame(65,0,17,17);
  u8g2.drawStr(71,2, "4");

  u8g2.drawFrame(86,0,17,17);
  u8g2.drawStr(92,2, "5");

  u8g2.drawFrame(107,0,17,17);
  u8g2.drawStr(113,2, "6");
  
  u8g2.drawBox(115,51,12,10);   //Selected box
  
  u8g2.setDrawColor(0);
  u8g2.drawXBMP(117, 53, 8, 6, back);
  u8g2.sendBuffer();
}

//MAIN CUSTOM METHOD
void custom_C1(void){
  switch(C1){
    case thumb:
      if(swbtn_state==5){
        jky_servo_movement();
        C1_thumb_in();
      }
      else{
        btn_Jky(5);
        jkyC1();
        C1_thumb();  //print on display F1_rock
      }
      break;
    
    case index:
      if(swbtn_state==5){ //s'ha de canviar!!
        C1_index_in();
      }
      else{
        btn_Jky(5);
        jkyC1();
        C1_index();  //print on display F1_rock
      }
      break;
    
    case middle:
      if(swbtn_state==5){ //s'ha de canviar!!
        C1_middle_in();
      }
      else{
        btn_Jky(5);
        jkyC1();
        C1_middle();  //print on display F1_rock
      }
      break;

    case ring:
      if(swbtn_state==5){ //s'ha de canviar!!
        C1_ring_in();
      }
      else{
        btn_Jky(5);
        jkyC1();
        C1_ring();  //print on display F1_rock
      }
      break;
    
    case pinky:
      if(swbtn_state==5){ //s'ha de canviar!!
        C1_pinky_in();
      }
      else{
        btn_Jky(5);
        jkyC1();
        C1_pinky();  //print on display F1_rock
      }
      break;

    case wrist:
      if(swbtn_state==5){ //s'ha de canviar!!
        C1_wrist_in();
      }
      else{
        btn_Jky(5);
        jkyC1();
        C1_wrist();  //print on display F1_rock
      }
      break;

    case goBackC1:
        btn_Jky(0);
        jkyC1();
        C1_goBack();  //print on display F1_rock
      break;
  }
}

void setup(){
  u8g2.begin();
  u8g2_prepare();
  servo.begin();
  servo.setPWMFreq(Freq);
  pinMode(jky, INPUT_PULLUP);
  F1=rock;
  C1=thumb;
  M1=openClose;
  swbtn_state=0;
}

void loop(){ 
  modes_M1();
}
import numpy as np
p = np.array([1/2, 1/2])
ex = np.array([1, 2])
dot_prod = ex @ p
#ifdef __APPLE__
freopen("inputFilename.txt", "r", stdin);
freopen("outputFilename.txt", "w", stdout);
#endif
Part 1:

// Header.h
void func(); // Declares func()
 
// File1.cc
#include "Header.h"
void func() {   // Defines func()
   ...
}
 
// File2.cc
#include "Header.h"
...  // Do something else
func(); // Calls func()
  
  
  
  
  
  
Part 2:

// Header.h
inline void func() { // Defines func()
   ...
}
 
// File2.cc
#include "Header.h"
... // Do something else
... // Code for func()
bool operator<(const Person &other) const {
 if (name == other.name) { 
    return age < other.age;
 } else { 
        return name < other.name; 
    }
} 
 
//This fixes the problem: In template: invalid operands to binary     expression ('const Person' and 'const Person')
std::string test1 = "Baked";
std::string test2 = "Bake";  
bool compare = test1 < test2;
 
// Output: 0
/* Reason: There is no difference until the last letter so then it will compare the last letter with the blank space. 
Since blank space comes first before the letter d, this means that test1 is not less than test2 and that is why it returns false.*/
 
std::string test1 = "Baker";
std::string test2 = "Bdke";  
bool compare = test1 < test2;
 
// Output: 1
/* Reason: There is no difference until the second letter so then it will compare the second letter with the second letter of the other word.
Since the letter a comes first before the letter d, this means that test1 is less than test2 and that is why it returns true.*/
Example:

    people[0] = Person(3, "Bob");
    people[1] = Person(4, "Joe");
    people[2] = Person(5, "Sue");

Example 2:

	people.insert(std::pair <int, Person> (0, Person(3, "Bob")));
	people.insert(std::pair <int, Person> (1, Person(4, "Joe")));
	people.insert(std::pair <int, Person> (2, Person(5, "Sue")));
#include <iostream>

using namespace std;

struct student
{
	int age;
};

int main() {
	student steve;		//variable
	student *ken;		//ken is a pointer.  It points to the memory address which holds the ken struct.

	steve.age = 7;
	ken->age = 9;

	return;
}
#include <iostream>

using namespace std;

int main(){
  	
	cout << "Hello World";
  
  	return 0;
}
std::exception <exception> interface (debatable if you should catch this)
    std::bad_alloc <new> failure to allocate storage
        std::bad_array_new_length <new> invalid array length
    std::bad_cast <typeinfo> execution of an invalid dynamic-cast
    std::bad_exception <exception> signifies an incorrect exception was thrown
    std::bad_function_call <functional> thrown by "null" std::function
    std::bad_typeid <typeinfo> using typeinfo on a null pointer
    std::bad_weak_ptr <memory> constructing a shared_ptr from a bad weak_ptr
    std::logic_error <stdexcept> errors detectable before the program executes
        std::domain_error <stdexcept> parameter outside the valid range
        std::future_error <future> violated a std::promise/std::future condition
        std::invalid_argument <stdexcept> invalid argument
        std::length_error <stdexcept> length exceeds its maximum allowable size
        std::out_of_range <stdexcept> argument value not in its expected range
    std::runtime_error <stdexcept> errors detectable when the program executes
        std::overflow_error <stdexcept> arithmetic overflow error.
        std::underflow_error <stdexcept> arithmetic underflow error.
        std::range_error <stdexcept> range errors in internal computations
        std::regex_error <regex> errors from the regular expression library.
        std::system_error <system_error> from operating system or other C API
            std::ios_base::failure <ios> Input or output error
 int gcdYisLargerThanX(int x, int y)
{
  return x==0 ? y : gcd(y%x, x);
}
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop
	// any integer can be expressed as (6k + i), where i = -1, 0, 1, 2, 3, 4
	// (6k + 0), (6k + 2), (6k + 4) covered by n%2
	// (6k + 3) covered by n%3
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
	
	// Check for 6K + 1 and 6K - 1
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
 
    return true; 
}
int maxSubArray(vector<int>& nums) {
        int maxSum = nums[0], currSum = nums[0];
        
        for(int i=1; i < nums.size(); i++)
        {
            currSum += nums[i];
            if(nums[i] > currSum) currSum = nums[i];
            maxSum = (currSum > maxSum) ? currSum : maxSum;
        }
        return maxSum;
    }
int maxProduct(vector<int>& nums) {
        int32_t res=nums[0];
        
        for(int32_t i=1, min=res, max = res; i < nums.size(); i++)
        {
            if(nums[i] < 0)
                swap(min, max);
            max = std::max(nums[i] * max, nums[i]);
            min = std::min(nums[i] * min, nums[i]);
            res = std::max(res, max);
        }
        return res;
    }
#include<bits/stdc++.h>

using namespace std;
//Implement the class Box  
//l,b,h are integers representing the dimensions of the box

// The class should have the following functions : 

// Constructors: 
// Box();
// Box(int,int,int);
// Box(Box);


// int getLength(); // Return box's length
// int getBreadth (); // Return box's breadth
// int getHeight ();  //Return box's height
// long long CalculateVolume(); // Return the volume of the box

//Overload operator < as specified
//bool operator<(Box& b)

//Overload operator << as specified
//ostream& operator<<(ostream& out, Box& B)
class Box {
    private:
        int length;
        int breadth;
        int height;
    
    public:
        Box() {
            this->length = 0;
            this->breadth = 0;
            this->height = 0;
        }
        
        Box(int l, int b, int h) {
            this->length = l;
            this->breadth = b;
            this->height = h;
        }
};


void check2()
{
	int n;
	cin>>n;
	Box temp;
	for(int i=0;i<n;i++)
	{
		int type;
		cin>>type;
		if(type ==1)
		{
			cout<<temp<<endl;
		}
		if(type == 2)
		{
			int l,b,h;
			cin>>l>>b>>h;
			Box NewBox(l,b,h);
			temp=NewBox;
			cout<<temp<<endl;
		}
		if(type==3)
		{
			int l,b,h;
			cin>>l>>b>>h;
			Box NewBox(l,b,h);
			if(NewBox<temp)
			{
				cout<<"Lesser\n";
			}
			else
			{
				cout<<"Greater\n";
			}
		}
		if(type==4)
		{
			cout<<temp.CalculateVolume()<<endl;
		}
		if(type==5)
		{
			Box NewBox(temp);
			cout<<NewBox<<endl;
		}

	}
}

int main()
{
	check2();
}
int main(){
		// Initialization of list
	    std::list<int> demo_list;

	    // Assigning the value 100, 5 times
	    // to the list, list_demo.
	    demo_list.assign(5, 100);

	    // Displaying the list
	    for (int itr : demo_list) {
	        std::cout << itr << " ";
	    }

	    return 0;
	}
#pragma once
#ifndef MYVEC_H
#define MYVEC_H
#include <iostream>
#include<algorithm>

template <typename T>
class Myvec
{
public:
	Myvec();
	Myvec(int& size);
	Myvec(int& size, T& value);
	~Myvec();
	void push_back(T& value);
	void pop();
	unsigned int get_size()const;
	T at(int& index)const;
	bool empty()const;
	void clear();
	void swap(Myvec& v);
	void print();
private:
	T* elements;
	int size;
	int capacity;
	void ensureCapacity();
};
template<typename T>
Myvec<T>::Myvec():size(0),capacity(16)
{
	elements = new T[capacity];
}
template<typename T>
Myvec<T>::Myvec(int& size)
{
	size = size;
}
template<typename T>
Myvec<T>::Myvec(int& size, T& vlaue)
{
	size = size;
	elements[0] = vlaue;
}
template<typename T>
Myvec<T>::~Myvec()
{
	delete[] elements;
}
template<typename T>
void Myvec<T>::push_back(T& value)
{
	ensureCapacity();
	elements[size++] = value;
}
template < typename T>
void Myvec<T>::ensureCapacity()
{
	if (size >= capacity)
	{
		T* old = elements;
		capacity = 2 * size;
		elements = new T[size * 2];

		for (int i = 0; i < size; i++)
			elements[i] = old[i];

		delete[] old;
	}
}
template <typename T>
void Myvec<T>::pop()
{
	--size;
}
template <typename T>
unsigned int Myvec<T>::get_size()const
{
	return size;
}
template <typename T >
T Myvec<T>::at(int& index)const
{
	if(index < size)
		return elements[index];
}
template <typename T>
bool Myvec<T>::empty()const
{
	return size == 0;
}
template <typename T>
void Myvec<T>::clear()
{
	size = 0;
}
template <typename T>
void Myvec<T>::swap(Myvec& v)
{
	
	T* temp = new T[size];
	int s = this->size;
	for (int i = 0; i < s; i++)
	{
		temp[i] =this->elements[i];
	}
	
	this->clear();
	for (int i = 0; i < v.get_size(); i++)
	{
		this->push_back(v.elements[i]);
	}
	v.clear();
	for (int i = 0; i < s; i++)
	{
		v.push_back(temp[i]);
	}
	

	delete[]temp;
}
template<typename T>
void Myvec<T>::print()
{
	for (int i = 0; i < size; i++)
	{
		std::cout << this->at(i)<<" ";
	}
	std::cout << std::endl;
}
#endif // !MYVEC_H


#include <iostream>
#include <vector>
#include <string>
#include"Stack.h"
#include<algorithm>
#include "Myvec.h"

using namespace std;



int main()
{
	Myvec<int> v1;
	Myvec<int> v2;
	for (int i = 1; i < 50; i++)
	{
		v2.push_back(i);
	}
	for (int i = 0; i < 20; i++)
	{
		v1.push_back(i);
	}
	

	v1.print();
	cout << endl;
}
#include <iostream>
#include <string>
using namespace std;
#define ll long long



int main()
{
	srand(time(0));
	const int SIZE = 10;
	string words[SIZE] = { "skinny","skinny","three","arrange",
	"discussion", "squeeze" ,"flowers","credit","matter","visit"};
	int random = rand() % SIZE;
	string s = words[random];
	string astrid_word("");
	
		astrid_word = s;
		for (int i = 0; i < astrid_word.length(); i++)
		{
			astrid_word[i] = '*';
		}
		char guess;
		int tries = 1;
		bool youWin = false;
		int miss = 0;
		while ( tries <= 20)
		{
			int flag = 0;
			cout << tries<<" enter your guess " << astrid_word<<" ";
			cin >> guess;
			for (int i = 0; i < astrid_word.length(); i++)
					{
				if (s.at(i) == guess)
				{
					if (s.at(i) == astrid_word.at(i))
					{
					cout <<"   "<< guess << " is already in the word\n";
					}
					else
					{
						astrid_word.at(i) = guess;
						flag = 1;
					}
				}
			}
			if (flag == 0)
				miss++;
			if (astrid_word == s)
			{
				youWin = true;
				cout << "the word is " << astrid_word<<endl;
				break;
			}
			tries++;
		}
		if (youWin == true)
		{
			cout << " -------------------------------- \n";
			cout << "|                                |\n";
			cout << "|                                |\n";
			cout << "|   (:CONGRATULATIONS YOU WIN(:  |\n";
			cout << "|                                |\n";
			cout << "|                                |\n";
			cout << " -------------------------------- \n";
			cout << "you tried " << tries << " times \n";
			cout << "you miss " << miss << " time\n";

		}
		else
		{
			cout << "the word is " << s << "): you loose ):";
		}
		
		
	
}




#include <iostream>

#include <string>
using namespace std;
#define ll long long



int intOfEnd(string& s)
{
	int start = s.find("ATG");
	int end1 = s.find("TAG", start);
	int end2 = s.find("TAA", start);
	int end3 = s.find("TGA", start);

	int list[3] = { end1,end2,end3 };
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (list[i] < list[j] && list[i] != string::npos)
				return list[i];
		}
	}
	
	for (int i = 0; i < 3; i++)
	{
		if (list[i] != string::npos)
			return list[i];
	}
	return 0;
	

}
int main()
{
	string s;
	cin >> s;
	
	
	string ans("");
	int l = 0;
	
	for (int j = 0; j < s.length(); j++)
	{
			int start = s.find("ATG");
			if ((start != string::npos && intOfEnd(s) != 0))
			{
				for (int i = start + 3; i < intOfEnd(s); i++)
				{
					ans += s[i];
				}
				cout << "gene "<<ans << endl;

				s.erase(start, 6);
				ans.clear();
				l++;
			}
			
	}
	if (l == 0)
		cout << "no gene found ";
}




#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>
#include <vector>

using namespace std;

bool  isConsecutiveFour(char grid[][7]) {

    // checking rows
    for (int i = 0; i < 6; i++)
    {
        char current = grid[i][0];
        int rowCnsec = 0;
        for (int j = 0; j < 7; j++)
        {
            if (current == grid[i][j] && grid[i][j] != ' ')
            {
                rowCnsec++;
                if (rowCnsec == 4) return true;
            }
            else
            {
                current = grid[i][j];
                rowCnsec = 1;
            }
        }
    }
    // check columns
    for (int j = 0; j < 7; j++)
    {
        char current = grid[0][j];
        int colConsec = 0;
        for (int i = 0; i < 6; i++)
        {
            if (current == grid[i][j] && grid[i][j] != ' ')
            {
                colConsec++;
                if (colConsec == 4) return true;
            }
            else
            {
                current = grid[i][j];
                colConsec = 1;
            }
        }
    }

    // check top Left side: going upright
    for (int i = 5; i >= 0 ; i--)
    {
        int consecutive = 0;
        int y = i;
        int x = 0;
        char current = grid[y][x];
        while (y >= 0)
        {
            if (grid[y][x] == current && grid[y][x] != ' ')
            {
                consecutive++;
                if (consecutive == 4) return true;
            }
            else
            {
                consecutive = 1;
                current = grid[y][x];
            }
            x++;
            y--;
        }

    }
    // check bottom right side: going upright
    for (int j = 0; j < 7; j++) {
        int y = 6 - 1;
        int x = j;
        int consecutive = 0;
        int current = grid[y][x];

        while (x < 6 && y >= 0) {

            if (grid[y][x] == current && grid[y][x] != ' ') {
                consecutive++;
                if (consecutive == 4) return true;
            }
            else {
                consecutive = 1;
                current = grid[y][x];
            }
            x++;
            y--;
        }

    }

    // check bottom left side going up-left
    for (int j = 7 - 1; j > 0; j--) {

        int x = j;
        int y = 6 - 1;
        int current = grid[y][x];
        int consecutiveCount = 0;

        while (x >= 0 && y >= 0) {

            if (grid[y][x] == current && grid[y][x] != ' ') {
                consecutiveCount++;
                if (consecutiveCount == 4) return true;
            }
            else {
                consecutiveCount = 1;
                current = grid[y][x];
            }

            x--;
            y--;
        }
    }
    // check bottom right side going up-left
    for (int row = 1; row < 6; row++) {
        int x = 7 - 1;
        int y = row;
        int consecutive = 0;
        int current = grid[y][x];

        while (y >= 0) {

            if (grid[y][x] == current && grid[y][x] != ' ') {
                consecutive++;
                if (consecutive == 4) return true;
            }
            else {
                consecutive = 1;
                current = grid[y][x];
            }
            x--;
            y--;
        }
    }
    return false;
}
// a function to show the grid
void show_grid(char grid[][7])
{
   
    for (int i = 0; i < 6; i++)
    {
        for (int j = 0; j < 7; j++)
        {
            cout << "|" << grid[i][j];
        }
        cout << "|" << endl;
    }
}

void player1(char grid[][7], int x, int y)
{
    show_grid(grid);
    
    cout << "Drop a red disk at column (0–6): ";
    cin >> y;
    if (grid[x][y] == ' ')
        grid[x][y] = 'R';
    else {
        //make sure not to target the same row
        while (grid[x][y] != ' ')x--;
        grid[x][y] = 'R';
    }
}

void player2(char grid[][7],int x,int y)
{
    show_grid(grid);

    cout << "Drop a yellow disk at column (0–6): ";
    cin >> y;
    if (grid[x][y] == ' ')
        grid[x][y] = 'Y';
    else {
        //make sure not to target the same row
        while (grid[x][y] != ' ')x--;
        grid[x][y] = 'Y';
    }
       
}
//check if it's a draw
bool is_draw(char grid[][7])
{
    for (int i = 0; i < 7; i++)
    {
      int count{0};
        if (grid[0][i] != ' ' && grid[1][i] != ' ' && grid[2][i] != ' '
            && grid[3][i] != ' ' && grid[4][i] != ' ' && grid[5][i] != ' ')
            count++;
      if(count == 6)
        return true;
        return false;
    }
}
int main()
{
	char grid[6][7];	
    //fill the grid with blank space
    for (int i = 0; i < 6; i++)
    {
        for (int j = 0; j < 7; j++)
        {
            grid[i][j] = ' ';
        }
    }
    //to check the winner
    bool winner1 = false;
    bool winner2 = false;

    while (!is_draw(grid))
    {
        int x{ 5 };
        int y{ 0 };
        player1(grid, x, y);
        if (isConsecutiveFour(grid))
        {
            winner1 = true;
            break;
        }
        player2(grid, x, y);
        if (isConsecutiveFour(grid))
        {
            winner2 = true;
            break;
        }
    }
    show_grid(grid);
    if (winner1 == true)
        cout << "player 1 wins ";
    else if (winner2 == true)
        cout << "player 2 wins ";
    else
        cout << "It's a draw ";

    
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;


bool  isConsecutiveFour(int values[][7]) {

    // checking rows
    for (int i = 0; i < 6; i++) {
       
        int current = values[i][0];
        int consecutiveCount = 0; // values[i][0] starts count

        for (int j = 0; j < 7; j++) {
            
            if (values[i][j] == current) {
                consecutiveCount++;
                if (consecutiveCount == 4) return true;
            }
            else {
                current = values[i][j];
                consecutiveCount = 1;
            }
        }
    }
    // check columns
    for (int j = 0; j < 7; j++) {
        
        int consecutiveCount = 0; // values[0][j] starts count
        int current = values[0][j];

        for (int i = 0; i < 6; i++) {

            if (values[i][j] == current) {
                consecutiveCount++;
                if (consecutiveCount == 4) return true;
            }
            else {
                current = values[i][j];
                consecutiveCount = 1;
            }

        }
    }

    // check topLeft side: going upright
    for (int i = 6 - 1; i > 0; i--) {
        int y = i;
        int x = 0;
        int consecutive = 0;
        int current = values[y][x];

        while (y >= 0) {
           
            if (values[y][x] == current) {
                consecutive++;
                if (consecutive == 4) return true;
            }
            else {
                consecutive = 1;
                current = values[y][x];
            }
            x++;
            y--;
        }
    }

    // check bottom right side: going upright
    for (int j = 0; j < 7; j++) {
        int y = 6 - 1;
        int x = j;
        int consecutive = 0;
        int current = values[y][x];

        while (x < 6 && y >= 0) {
            
            if (values[y][x] == current) {
                consecutive++;
                if (consecutive == 4) return true;
            }
            else {
                consecutive = 1;
                current = values[y][x];
            }
            x++;
            y--;
        }

    }

    // check bottom left side going up-left
    for (int j = 7 - 1; j > 0; j--) {

        int x = j;
        int y = 6 - 1;
        int current = values[y][x];
        int consecutiveCount = 0;

        while (x >= 0 && y >= 0) {

            if (values[y][x] == current) {
                consecutiveCount++;
                if (consecutiveCount == 4) return true;
            }
            else {
                consecutiveCount = 1;
                current = values[y][x];
            }

            x--;
            y--;
        }
    }
    // check bottom right side going up-left
    for (int row = 1; row < 6; row++) {
        int x = 7 - 1;
        int y = row;
        int consecutive = 0;
        int current = values[y][x];

        while (y >= 0) {
            
            if (values[y][x] == current) {
                consecutive++;
                if (consecutive == 4) return true;
            }
            else {
                consecutive = 1;
                current = values[y][x];
            }
            x--;
            y--;
        }

    }
    return false;
}






// Driver code
int main()
{
    int m[6][7];
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 7; j++)
            cin >> m[i][j];
    if (isConsecutiveFour(m) == true)
        cout << "true";
    else 
        cout << "false";
  
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;




void decToBinary(int n)
{
    // array to store binary number 
    int binaryNum[3][3];
    
    //converting to binary 
    for (int i = 0; i < 3; i++) 
    {
        for (int j = 0; j < 3; j++)
        {
            binaryNum[i][j] = n % 2;
            n = n / 2;

        }
     }       

    // printing binary> array in reverse order 
    for (int i = 3-1; i >= 0; i--){
        for (int j = 3 - 1; j >= 0; j--)
        {
            if (binaryNum[i][j] == 0)
                cout << "H" << " ";
            else
                cout << "T" << " ";
        }
        cout << endl;
    }
    
 }

int main()
{
    int n;
    cout << "Enter a decimal number between 1 and 512 ";
    cin >> n;

    decToBinary(n);
    return 0;
}



//(Financial application: compute tax) Rewrite Listing 3.3, ComputeTax.cpp,
//using arrays. For each filing status, there are six tax rates. Each rate is applied
//to a certain amount of taxable income. For example, from the taxable income
//of $400,000 for a single filer, $8,350 is taxed at 10%, (33,950–8,350) at 15%,
//(82,250–33,950) at 25%, (171,550–82,550) at 28%, (372,550–82,250) at
//33%, and (400,000–372,950) at 36%. The six rates are the same for all filing
//statuses, which can be represented in the following array:
//double rates[] = {0.10, 0.15, 0.25, 0.28, 0.33, 0.36};
//The brackets for each rate for all the filing statuses can be represented in a twodimensional array as follows:
//i//nt brackets[4][5] =
//{
// {8350, 33950, 82250, 171550, 372950}, // Single filer
// //{16700, 67900, 137050, 20885, 372950}, // Married jointly
 // or qualifying
 // widow(er)
// {8350, 33950, 68525, 104425, 186475}, // Married separately
// {11950, 45500, 117450, 190200, 372950} // Head of household
//};
//Suppose the taxable income is $400,000 for single filers. The tax can be computed
//as follows:
//tax = brackets[0][0] * rates[0] +
// (brackets[0][1] – brackets[0][0]) * rates[1] +
 //(brackets[0][2] – brackets[0][1]) * rates[2] +
// (brackets[0][3] – brackets[0][2]) * rates[3] +
// (brackets[0][4] – brackets[0][3]) * rates[4] +
// (400000 – brackets[0][4]) * rates[5]


#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

double computeTax(int brackets[][5], double rates[],
    int status, double income);
int getStatus();


// Driver code
int main()
{
    double rates[] = { 0.10, 0.15, 0.25, 0.28, 0.33, 0.36 };

    int brackets[4][5] =
    {
     {8350, 33950, 82250, 171550, 372950}, // Single filer
     {16700, 67900, 137050, 20885, 372950}, // Married jointly
     // or qualifying
     // widow(er)
     {8350, 33950, 68525, 104425, 186475}, // Married separately
     {11950, 45500, 117450, 190200, 372950} // Head of household
    };
    
     cout << "(1-single filer, 2-married jointly, "
         << "or qualifying widow(er), " << endl
         << "3-married separately, 4-head of household)" << endl
         << "Enter the filing status: ";
     int status = getStatus();
 cout<< "Enter the taxable income: ";
 double income;
 cin >> income;
    cout << "The tax for your income " << income << " is " << computeTax(brackets, rates, status, income);
}

double computeTax(int brackets[][5], double rates[],
    int status, double income) {
    double tax = 0, incomeTaxed = 0;
    for (int i = 4; i >= 0; i--) {
        if (income > brackets[status][i])
            tax += (incomeTaxed = income - brackets[status][i]) * rates[i + 1];
        income -= incomeTaxed;
    }
    return tax += brackets[status][0] * rates[0];
}
int getStatus() {
   
    int status;
    do {
        cin >> status;
        if (status < 0 || status > 3)
            cout<<"Error: invalid status";
    } while (status < 0 || status > 3);
    return status;
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;


void sortRowWise(int m[][4],
    int r, int c)
{
    // loop for rows of matrix
    for (int i = 0; i < r; i++)
    {
        // loop for column of matrix
        for (int j = 0; j < c; j++)
        {
            // loop for comparison and swapping
            for (int k = 0; k < c - j - 1; k++)
            {
                if (m[i][k] > m[i][k + 1])
                {
                    // swapping of elements
                    swap(m[i][k], m[i][k + 1]);
                }
            }
        }
    }

    // printing the sorted matrix
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
            cout << m[i][j] << " ";
        cout << endl;
    }
}

// Driver code
int main()
{
    int m[4][4];
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            cin >> m[i][j];
        }
    }
    int r = sizeof(m[0]) / sizeof(m[0][0]);
    int c = sizeof(m) / sizeof(m[0]);
    sortRowWise(m, r, c);
    return 0;
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int octal2Dec(string& octal);
bool validity(int number);
int stringToNum(string number);
int bin2Dec(int binNumber);
int dec2octal(const string& number);



void readASolution(int grid[][9]);
 bool isValid(const int grid[][9]);
 bool isValid(int i, int j, const int grid[][9]);

 int main()
{
	 // Read a Sudoku puzzle
		 int grid[9][9];
	 readASolution(grid);
	
		 cout << (isValid(grid) ? "Valid solution" : "Invalid solution");
	
		 return 0;
		 system("pause");
 }

 // Read a Sudoku puzzle from the keyboard
 void readASolution(int grid[][9])
 {
	 cout << "Enter a Sudoku puzzle:" << endl;
	 for (int i = 0; i < 9; i++)
		 for (int j = 0; j < 9; j++)
		 cin >> grid[i][j];
 }
 bool isValid(const int grid[][9])
	 {
	  for (int i = 0; i < 9; i++) 
		  for (int j = 0; j < 9; j++)
		  if (grid[i][j] < 1 || grid[i][j] > 9 ||
			  !isValid(i, j, grid))
		  return false;
	 
		  return true; // The fixed cells are valid
 }
 
	  // Check whether grid[i][j] is valid in the grid
 bool isValid(int i, int j, const int grid[][9])
 {
	 // Check whether grid[i][j] is valid at the i's row
	 for (int column = 0; column < 9; column++)
		 if (column != j && grid[i][column] == grid[i][j])
			 return false;

	 // Check whether grid[i][j] is valid at the j's column
	 for (int row = 0; row < 9; row++)
		 if (row != i && grid[row][j] == grid[i][j])
			 return false;

	 // Check whether grid[i][j] is valid in the 3-by-3 box
	 for (int row = (i / 3) * 3; row < (i / 3) * 3 + 3; row++)
		 for (int col = (j / 3) * 3; col < (j / 3) * 3 + 3; col++)
			 if (row != i && col != j && grid[row][col] == grid[i][j])
				 return false;

	 return true; // The current value at grid[i][j] is valid
 }
USTRUCT()
struct FMapRow {
	GENERATED_BODY()

		UPROPERTY()
		TArray<int8> Columns;

	FORCEINLINE int8& operator[] (int32 j)
	{
		return Columns[j];
	}

	void SetGridBase(int8 Block, int32 y)
	{
		Columns[y] = Block;
	}

	void AddNewColumn()
	{
		Columns.Add(0);
	}

	FMapRow()
	{

	}
};

USTRUCT() 
struct FMapLayer {
	GENERATED_BODY()

		UPROPERTY()
		TArray<FMapRow> Rows;

	FORCEINLINE FMapRow& operator[] (int32 i)
	{
		return Rows[i];
	}

	void AddNewRow()
	{
		Rows.Add(FMapRow());
	}

	void AddUninitialized(const int32 RowCount, const int32 ColCount)
	{
		Clear();
		//Add Rows
		for (int32 v = 0; v < RowCount; v++)
		{
			AddNewRow();
		}

		//Add Columns
		for (int32 v = 0; v < RowCount; v++)
		{
			for (int32 b = 0; b < ColCount; b++)
			{
				Rows[v].AddNewColumn();
			}
		}
	}

	void Clear()
	{
		if (Rows.Num() <= 0) return;
		//~~~~~~~~~~~~~~~

		//Destroy any Actors
		const int32 RowTotal = Rows.Num();
		const int32 ColTotal = Rows[0].Columns.Num();

		//Empty
		for (int32 v = 0; v < Rows.Num(); v++)
		{
			Rows[v].Columns.Empty();
		}
		Rows.Empty();
	}

	TTuple<int32, int32> NumLayerDimensions()
	{
		return TTuple<int32, int32>(Rows.Num(), Rows[0].Columns.Num());
	}

	//default properties
	FMapLayer()
	{

	}

	FMapLayer(int32 Rows, int32 Cols) 
	{
		AddUninitialized(Rows, Cols);
	}
};

USTRUCT()
struct FMapSector {
	GENERATED_BODY()

	UPROPERTY()
	TArray<FMapLayer> Layers;

	FORCEINLINE FMapLayer& operator[] (int32 i)
	{
		return Layers[i];
	}

	void AddNewLayer()
	{
		Layers.Add(FMapLayer());
	}

	void AddUnitialized(int32 LayerCount, int32 RowCount, int32 ColCount)
	{
		Clear();
		// Add Layers
		for (int32 l = 0; l < LayerCount; l++)
		{
			AddNewLayer();
		}

		// Add Rows
		for (int32 l = 0; l < LayerCount; l++)
		{
			for (int32 r = 0; r < RowCount; r++)
			{
				Layers[l].AddNewRow();
			}
		}

		// Add Rows
		for (int32 l = 0; l < LayerCount; l++)
		{
			for (int32 r = 0; r < RowCount; r++)
			{
				for (int32 c = 0; c < ColCount; c++)
				{
					Layers[l].Rows[r].AddNewColumn();
				}
			}
		}
	}

	void Clear()
	{
		if (Layers.Num() <= 0) return;
		//~~~~~~~~~~~~~~~

		//Destroy any Actors
		const int32 LayerTotal = Layers.Num();
		const int32 RowTotal = Layers[0].Rows.Num();
		const int32 ColTotal = Layers[0].Rows[0].Columns.Num();


		//Empty
		for (int32 l = 0; l < LayerTotal; l++)
		{
			for (int32 r = 0; r < RowTotal; r++)
			{
				Layers[l].Rows[r].Columns.Empty();
			}
		}
		for (int32 l = 0; l < LayerTotal; l++)
		{
			Layers[l].Rows.Empty();
		}

		Layers.Empty();
	}

	FMapSector()
	{
		AddUnitialized(3, 3, 3);
	}

	FMapSector(int32 size)
	{
		AddUnitialized(size, size, size);
	}

	FMapSector(int32 Layers, int32 Rows, int32 Cols)
	{
		AddUnitialized(Layers, Rows, Cols);
	}
};
#include <iostream>
#include<iomanip>
#include <string>

using namespace std;

void partisons(int list[], int listSize);


int main() 
{
	const int size1 = 6;
	
	
	int list1[size1];
	for (int i = 0; i <size1 ; i++)
	{
		cin >> list1[i];
	}
	 selectionSort(list1, size1);

	
	for (int i = 0; i < size1; i++)
	{
		cout << list1[i] << " ";
	}

	
}

void partisons(int list[], int listSize)
{
    int first = 0;
    int low = first + 1;
    int high = listSize - 1;
    int pivot = list[first];

    while (high > low) {

        while (low <= high && list[low] <= pivot)
        {
            low++;
        }
        while (low <= high && list[high] > pivot)
        {
            high--;
        }
        if (high > low) {
            int temp = list[high];
            list[high] = list[low];
            list[low] = temp;
        }
    }

    while (high >= low && list[high] >= pivot) high--;

    if (high > first) {
        int temp = list[high];
        list[high] = list[first];
        list[first] = temp;
        
    }
    
	 }
	
	


#include<iostream>
using namespace std;

int sum(int arr[], int a);

int main() {
    int arr[1000], n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        cout << sum(arr, n);
    }
}
int sum(int arr[], int a) {
    int i;
    sum = 0;
    for (i=0; i<n; ++i) {
        sum += arr[i];
    }
    return sum;
}#include<iostream>
using namespace std;

int sum(int arr[], int a);

int main() {
    int arr[1000], n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        cout << sum(arr, n);
    }
}
int sum(int arr[], int a) {
    int i;
    sum = 0;
    for (i=0; i<n; ++i) {
        sum += arr[i];
    }
    return sum;
}
"For Loop": {
    "prefix": "for",
    "body": [
        "for (var ${index} = 0; ${index} < ${array}.length; ${index}++) {",
        "\tvar ${element} = ${array}[${index}];",
        "\t$0",
        "}"
    ],
    "description": "For Loop"
},
#include <iostream>
#include<iomanip>

using namespace std;
void eightQueens(char board[], int size);
void shuffle(char list[], int size);
int linearSearch(char list[], char key, int arraySize);
int linearSearchInt(int list[], int key, int arraySize);




const int SIZE = 8;
int main()
{	char board[SIZE];

	srand(unsigned( time(0)));
	int x = rand()%SIZE;
	for (int i = 0; i < SIZE; i++)
	{
		if (i == x)
			board[i] = 'Q';
		else
			board[i] = ' ';
	}
		eightQueens(board, SIZE);
}
void eightQueens(char board[],int size)
{
	int count = 0, vale, test[SIZE];
	for (int i = 0; i < size ; i++)
	{
		 vale = linearSearch(board, 'Q', size);
		 bool flage = true;
		 
		for (int j = 0; j < count;j++)
		{
			if (test[j] == vale)
				flage = false;
		}
		if (flage == true)
		{
			for (int j = 0; j < size; j++)
			{
				cout  << "|";
				cout << board[j];
			}
			test[count] = vale;
			count++;
			shuffle(board, size);
		}
		else
		{
			int n = 0;
			for (int j = 0; j < 100; j++)
			{
				shuffle(board, size);
				if (linearSearchInt(test, linearSearch(board, 'Q', size), size) == -1)
				{
					n = linearSearch(board, 'Q', size);
					test[count] = n;
					count++;
					break;
				}
			}
			for (int j = 0; j < SIZE; j++)
			{
				if (j == n)
					board[j] = 'Q';
				else
					board[j] = ' ';
			}
			for (int j = 0; j < size; j++)
			{
				cout << "|";
				cout << board[j] ;
			}
			

		}
		cout <<'|'<< endl;
	}
	
}

int linearSearch( char list[], char key, int arraySize)
{
	for (int i = 0; i < arraySize; i++)
	{
			if (key == list[i])
				return i;
	}
	return -1;
}
int linearSearchInt(int list[], int key, int arraySize)
{
	for (int i = 0; i < arraySize; i++)
	{
		if (key == list[i])
			return i;
	}
	return -1;
}
void shuffle(char list[], int size)
{
	
	for (int i = size - 1; i > 0; i--)
	{
		// Generate an index j randomly with 0 <= j <=i
		int j = rand() % (i + 1);
		// Swap myList[i] with myList[j]
		char temp = list[i];
		list[i] = list[j];
			list[j] = temp;
	}
}



	
	


 int list[LIMIT], i, j, val, count, flag, test[LIMIT], c = 0;
    //enter the values
    for (i = 0; i < LIMIT; i++)
    {
        cout << "Enter The Elements : ";
        cin >> list[i];
        if (list[i] == 0)
            break;
    }
    //count the occurence of each value
    for (j = 0; j < LIMIT; j++)
    {
        count = 0;
        flag = 1;
        val = list[j];
        //counts each value's occurence and if the value is 0 break
        for (i = 0; i < LIMIT; i++)
        {
            if (val == list[i])
                count++;
            else if (list[i] == 0)
                break;
        }
        //checks whether the value has been already counted (flag = 0) or not (flag stays 1)
        for (i = 0; i < c; i++)
        {
            if (test[i] == val)
                flag = 0;
        }
        //if the value has not been counted print 
        if (flag == 1)
        {

            cout << "The Occurence Of The Number " << val << " is " << count << endl;
            test[c] = val;
            c++;
        }

    }
#include<iostream>
#include <fstream>
#include <cctype>
#include<ctffunc.h>
using namespace std;

void enterLetters(char list[], int limit);
void countVandCLetters(char list[], int limit);



const int LIMIT = 100;


int main()
{
	char letters[LIMIT];

	enterLetters(letters, LIMIT);
	countVandCLetters(letters, LIMIT);
    
}
void enterLetters(char list[], int limit)
{
	
	for (int i = 0; i < limit; i++)
	{
		cin >> list[i];
		if (list[i] == '0')
			break;
	}
}
void countVandCLetters(char list[], int limit)
{
	int vowel = 0;
	int Consonant = 0;
	char vowels[] = { 'a','e','o','u','i' };
	char Consonants[] = { 'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z' };
	
	for (int i = 0; i < limit; i++)
	{
		if (IsCharUpperA(list[i]))
			list[i] = list[i] + 32;
		
		for (int j = 0; j < 5; j++)
		{
			if (list[i] == vowels[j])
				vowel++;
		}
		for (int j = 0; j < 21; j++)
		{
			
			if (list[i] == Consonants[j])
				Consonant++;
		}
		
		
	}
	
		cout << "Number Of vowels Letters is " << vowel << endl;
		cout << "Number Of Consonants Letters is " << Consonant << endl;
	
}
 
#include<iostream>
#include <fstream>
using namespace std;
void selectionSort(double list[], int listSize);
int main()
{
    double list[] = { 3.4, 5, 3, 3.5, 2.2, 1.9, 2 };

    selectionSort(list, 7);
    for (int i = 0; i < 7; i++)
    {
        cout << list[i]<<" ";
    }
}
//decreasing order
void selectionSort(double list[], int listSize)
{
    for (int i = listSize-1; i >= 0 ; i--)
    {
        double currentMax = list[i];
        int currentMaxIndex = i;
        for (int j = i - 1; j >= 0; j--)
        {
            if (currentMax < list[j])
            {
                currentMax = list[j];
                currentMaxIndex = j;
            }
        }
            if (currentMaxIndex != i)
            {
                list[currentMaxIndex] = list[i];
                list[i] = currentMax;
            }
   
    }
}
//increasing order
void selectionSort(double list[], int listSize)
{
    for (int i = 0; i < listSize - 1; i++)
    {
        double currentMin = list[i];
        int currentMinIndex = i;
        for (int j = i + 1; j < listSize; j++)
        {
            if (currentMin > list[j])
            {
                currentMin = list[j];
                currentMinIndex = j;
            }
        }
            if (currentMinIndex != i)
            {
                list[currentMinIndex] = list[i];
                list[i] = currentMin;
            }
        
    }
}
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
ll cs=0;
ll tab[500000][20];
void spar(ll a[],ll n)
{
    ll i,j;
    for(i=0;i<n;i++)
        tab[i][0]=a[i];
    for(j=1;(1<<j)<=n;j++)
    {
        for(i=0;i+(1<<(j-1))-1<n;i++)
            tab[i][j]=__gcd(tab[i][j-1],tab[i+(1<<(j-1))][j-1]);
    }
}
ll qry(ll a,ll b)
{
    ll j=log2(b-a+1);
    return __gcd(tab[a][j],tab[b-(1<<j)+1][j]);
}
void sol()
{
    ll n,m,i,sum=0;
    cin>>n>>m;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    spar(a,n);
    for(i=0;i+m-1<n;i++)
        sum+=qry(i,i+m-1);
    cout<<sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ll t;
    //cin>>t;
    //while(t--)
    sol();
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
ll cs=0;
struct duo
{
    ld x,F,S;
};
bool sim(duo a,duo b)
{
    if(a.F==b.F||a.F==b.S||a.S==b.F||a.S==b.S)
        return 1;
    return 0;
}
void sol()
{
    cout.precision(11);
    cout<<fixed;
    ll n,i,k;
    cin>>n;
    ld a[n],vl,ans=0;
    duo low[3],h[3];
    for(i=0; i<3; i++)
        low[i].x=INT_MAX;
    for(i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0; i<3; i++)
    {
        h[i].F=a[n-1-i];
        h[i].S=a[n-2-i];
    }
    for(i=0; i<n-1; i++)
    {
        vl=abs(a[i]-a[i+1]);
        for(k=0; k<3; k++)
        {
            if(vl<low[k].x)
            {
                ll j=k;
                for(j=2; j>=k+1; j--)
                {
                    low[j].x=low[j-1].x;
                    low[j].F=low[j-1].F;
                    low[j].S=low[j-1].S;
                }
                low[k].x=vl;
                low[k].F=a[i];
                low[k].S=a[i+1];
                break;
            }
        }
    }
    for(i=0;i<3;i++)
    {
        for(k=0;k<3;k++)
        {
            if(!sim(h[i],low[k]))
                ans=fmax(ans,(h[i].F+h[i].S)/low[k].x);
        }
    }
    cout<<ans;

}
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //ll t;
    //cin>>t;
    //while(t--)
    sol();
    return 0;
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>
// CPP program to check if a string is 
// substring of other. 

using namespace std;

// Returns true if s1 is substring of s2 
int isSubstring(string s1, string s2)
{
	int M = s1.length();
	int N = s2.length();

	/* A loop to slide pat[] one by one */
	for (int i = 0; i <= N - M; i++) {
		int j;

		/* For current index i, check for
pattern match */
		for (j = 0; j < M; j++)
			if (s2[i + j] != s1[j])
				break;

		if (j == M)
			return i;
	}

	return -1;
}

/* Driver program to test above function */
int main()
{
	string s1 ,s2 ;
	getline(cin, s1);
	getline(cin, s2);
	int res = isSubstring(s1, s2);
	if (res == -1)
		cout << "Not present";
	else
		cout << "Present at index " << res;
	return 0;
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int octal2Dec(string& octal);
bool validity(int number);
int stringToNum(string number);
int bin2Dec(int binNumber);
int dec2octal(const string& number);




int main()
{
	string binNumber;
	getline(cin, binNumber);
	cout << dec2octal(binNumber);
	return 0;
}
int dec2octal(const string& number)
{
	int binNumber = stringToNum(number);
	int decimalNumber = bin2Dec(binNumber);
	int octal = 0, placeValue = 1;
	while (decimalNumber != 0)
	{
		octal += (decimalNumber % 8) * placeValue;
		decimalNumber /= 8;
		placeValue *= 10;
	}
	return octal;
}

int bin2Dec(int binNumber)
{
	int digits, decimal = 0, count = 0, bin = binNumber;
	while (bin != 0)
	{
		digits = bin % 10;
		  decimal += digits* pow(2,count);

		  bin /= 10;
		count++;
		
	}
	return decimal;
}
int stringToNum(string binNumber)
{
	int convertedNumber = 0;
	for (int i = 0; i < binNumber.length(); i++)
	{
		
		convertedNumber = (convertedNumber * 10) + static_cast<int>(binNumber[i] - '0');
	}
	return convertedNumber;
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int octal2Dec(string& octal);
bool validity(int number);
int stringToNum(string number);


int main()
{
	string number;
	getline (cin , number);

	
	cout << octal2Dec(number);
	return 0;
}

int octal2Dec(string& octal)
{
	int digits, decimal = 0, count = 0,oct = stringToNum(octal);
	while (oct != 0)
	{
	
		digits = oct % 10;
		if(validity(digits) == true)
		  decimal += digits* pow(8,count);
		else
		{
			return NAN;
		}
		oct /= 10;
		count++;
		
	}
	return decimal;
}
bool validity(int number)
{
	return number % 8 == 0 || number % 9 == 0? false : true;
		
}
int stringToNum(string number)
{
	int convertedNumber = 0;
	for (int i = 0; i < number.length(); i++)
	{
		convertedNumber = (convertedNumber * 10) + static_cast<int>(number[i] - '0');
	}
	return convertedNumber;
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;




string format(int number, int width);
int numberWidthF(int number);

int main()
{

	
	int number,width;
	cin >> number >> width;
	cout << format(number, width);
	
}
string format(int number, int width)
{
	string zeros = " ";
	string num = to_string(number);
	
	int numberWidth = numberWidthF(number);
	
	for (int  i = 1; i <= width-numberWidth; i++)
	{
		zeros += "0";
	}
	return zeros+num;
}
int numberWidthF(int number)
{
	int digits, numberWidth = 0;
	while (number != 0)
	{
		digits = number % 10;
		number /= 10;
		numberWidth++;
	}
	return numberWidth;
}
cout << "Machine ID: ";
	//WHILE LOOP: check whether Machine ID is in numeric
	while(!(cin >> machineID)){
		//display error message
		cout << "ERROR! Invalid Machine ID! Please try again..." << endl;
		cout << "Machine ID: ";
		
		cin.clear(); //clear previous user input
		cin.ignore(INT_MAX, '\n'); //discard previous user input
	}
//	optionMenu = getMenuOption();
//	
//	while(optionMenu > -1){
//		switch(optionMenu){
//			case 1:
//				addJob(h, j);
//				break;
//			
//			case 2:
//				retrieveJob(h, j);
//				break;
//				
//			case 3:
//				cout << "Option 3..." << endl;
//				break;
//				
//			case 4:
//				cout << "Option 4..." << endl;
//				break;
//			
//			case 5:
//				cout << "Bye!";
//				exit(0); //terminate program
//				break;
//				
//			default:
//				cout << "ERROR! Invalid option! Please try again..." << endl;
//				break;
//		}
//		
//		optionMenu = getMenuOption();
//	}


int getMenuOption(){
	int menuOption=0;
		
	cout << "Please enter number to select: ";
	cin >> menuOption;
	
	//error check
	while(!cin.good()){
		//report problem when user input in not numeric
		cout << "ERROR! Faulty input! Please try again..." << endl;
		
		//clear stream
		cin.clear();
		cin.ignore(INT_MAX, '\n');
		
		//get input again
		cout << "Please enter number to select: ";
		cin >> menuOption;
	}
	
	//clear stream
	cin.clear();
	cin.ignore(INT_MAX, '\n');
		
	return menuOption;
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;



double avgOfEvenPlaces(int number);
int reversal(int n);


int main()
{
	
	int number;
	cin >> number;
	cout << fixed<<setprecision(3)<<avgOfEvenPlaces(reversal(number));
}
double  avgOfEvenPlaces(int n)
{
	
	int digit, count = 1.0, countOfEven = 0.0;
	double sumOfEven = 0.0;
	while (n != 0)
	{
		digit = n % 10;
		n /= 10;
		
		if (count % 2 == 0)
		{
		  
			sumOfEven += digit; 
			countOfEven++;
		}
			count++;
	}
	
		return  sumOfEven / countOfEven;
	
}
int reversal(int n)
{
	int digits, revers = 0.0;
	while (n != 0)
	{
		digits = n % 10;
		revers = revers * 10 + digits;
		n /= 10;
	}
	return revers;
 }


#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;



double sqrt(int n);


int main()
{
	
	long n;
	cin >> n;
	cout << "the approximated sqrt of the number " << n << " is " << sqrt(n);
}
double sqrt(long n)
{
	double lastGuess = 1;
	double nextGuess = (lastGuess + n / lastGuess) / 2;

	while (nextGuess - lastGuess > 0.0001)
	{
		nextGuess = lastGuess;
		(lastGuess + (n / lastGuess)) / 2;
	}
	lastGuess = nextGuess;
	return nextGuess = (lastGuess + n / lastGuess) / 2;

}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;


bool primeNumber(int n);
bool additivePrime(int n);
int sumOfDigits(int n);



int main()
{
	
	int count = 0;
	int number = 13;
	cout << setw(3) << "Prime number" << setw(20) << "Sum of its digits" << endl;
	for (int i = 2; i <= 70; i++)
	{
		if (primeNumber(i) && additivePrime(i))
			cout <<setw(1)<< i<<setw(15)<<sumOfDigits(i)<<endl;
	}
		

}
bool primeNumber(int n) {
	
		for (int i = 2; i <= n / 2; i++) {
			
			if (n % i == 0) {

				return false;
			}
		}
		return true;
}

bool additivePrime(int n)
{
	
	if (primeNumber(sumOfDigits(n)))
		return true;
	else
		return false;
}
int sumOfDigits(int n)
{
	int sum = 0, digit = 0;
	while (n != 0)
	{
		digit = n % 10;
		sum += digit;
		n /= 10;
	}
	return sum;
}






	
   




#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;


bool primeNumber(int n);
bool Emirp(int n);
int reversal(int n);
int recursive(int a, int b);

int main()
{
	
	int count = 0;
	int number = 13;
	while (count <= 100)
	{
		if (Emirp(number))
		{
			count++;
			if (count % 10 == 0)
				cout << setw(7) << number << endl;
			else
				cout << setw(7) << number;
		}
		number++;
	}
		

}
bool primeNumber(int n) {
	
		for (int i = 2; i <= n / 2; i++) {
			
			if (n % i == 0) {

				return false;
			}
		}
		return true;
}

bool Emirp(int n) {
	

	return primeNumber(n) && primeNumber(reversal(n));
	
}

int reversal(int n) {
	
		if (n < 10) {
			
				return n;
			
		}
		return recursive(n % 10, n / 10);
	
}

int recursive(int a, int b) {

	if (b < 1) {

		return a;

	}
	return recursive(a * 10 + b % 10, b / 10);
	
}



	
   




#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;
bool isEven(int number);
bool isPalindrom(int number);

int main()
{
	
	int count = 0, number = 1;
	
	while (count <= 50)
	{

		if(isEven(number) == true && isPalindrom(number) == true)
		{
			count++;
			if (count % 5 == 0)
				cout << setw(8) << number << endl;
			else
				cout << setw(8) << number;
		}
		number++;
	}
	
		
	

}

bool isEven(int number)
{
	if (number % 2 == 0)
		return true;
	else
		return false;
	
}
bool isPalindrom(int number)
{
	int reverse = 0, rem = 0;
	int num = number;
	while (number != 0)
	{
		rem = number % 10;
		reverse = reverse * 10 + rem;
		number /= 10;
	}
	if (reverse == num)
		return true;
	else
		return false;
}


	
   




#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

bool isArmstrong(int n);
int reversNumber(int n);
void isReversedArmstrong(int n);

int main()
{
	cout << "Enter first integer: ";
	int n1;
	cin >> n1;
	isReversedArmstrong(n1);
	

}

bool isArmstrong(int n)
{
	int temp = 0,armstrong, total = 0;
	armstrong = n;
	while (armstrong != 0)
	{
		temp = armstrong % 10;
		total += pow(temp, 3);
		armstrong /= 10;
	}
	if (total == n)
		return true;
	else
		return false;
 }
int reversNumber(int n)
{
	int reverse = 0, rem = 0;
	while (n != 0)
	{
		rem = n % 10;
		reverse = reverse * 10 + rem;
		n /= 10;
	}
	return reverse;
}
void isReversedArmstrong(int n)
{
	if (isArmstrong(n))
	{
		if(isArmstrong(reversNumber(n)))
			cout << "the Reversed "<< reversNumber(n)<<" number IS an Armstrong number ";
		else
			cout << "the Reversed " << reversNumber(n) << " number is NOT Armstrong number ";
	}
	else
		cout << "the number entered is NOT Armstrong number ";

}


	
   




#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int LCM(int n1, int n2);

int main()
{
	cout << "Enter first integer: ";
	 int n1;
	 cin >> n1;
	
		 cout << "Enter second integer: ";
	 int n2;
	 cin >> n2;
	
	
	
		cout << "Least Common Multiple for " << n1 <<
			" and " << n2 << " is " << LCM(n1,n2)<< endl;
}

 int LCM(int n1, int n2)
 {
	 int lcm = 1; 
	 int max = (n1 > n2) ? n1 : n2;
	
		 while (true)
		 {
			 if (max % n1 ==0 && max % n2 == 0)
			 {
				 lcm = max;
				 break;
			 }
			 else
				 max++;

		 }
	
		return lcm; // Return gcd
	 }




	
   




#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;


int compute_profit(int quantity);

int main()
{
	int quantity = 1000;
	cout << "Quantity " << setw(9) << "Profit-per-item (in $)"<<endl;
    for ( ; quantity <= 10000; quantity+=1000)
    {
            cout<<quantity<< setw(9)<<compute_profit(quantity)<<endl;
    }
   
}
int compute_profit(int quantity)
{
    int profit = 0;
   

   
    if (quantity < 1000)
        profit += quantity; // * 1
    else
    {
        profit += 1000;
        quantity -= 1000;
        if (quantity < 4000)
            profit += quantity * 2;
        else
        {
            profit += 8000; // 4000 * 2
            quantity -= 4000;
            profit += quantity * 5;
        }
    }
    
    return profit;
}


// access v1 by copy 
[v1]() { 
	for (auto p = v1.begin(); p != v1.end(); p++) { 
		cout << *p << " "; 
	} 
}; 
/**
   SHAMI AL BASHAR PROTHOY
   PRESIDENCY INTERNATIONAL SCHOOL
**/

#include <bits/stdc++.h>
using namespace std;
#define csee "Case "<<cs<<": "
typedef long long ll;
typedef long double ld;
#define B begin()
#define E end()
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ins insert
#define vi vector
#define ins insert
const ld pi=2*acos(0.0);
ll T,cs=1;
vi<ll>coins;
struct tim
{
    ll s,f;
};
bool cmp(tim a,tim b)
{
    if(a.s!=b.s)return a.s<b.s;
    return a.f<b.f;
}
/**
THINK TWICE,
      CODE ONCE
**/

void sol(ll cs)
{
   ll n,i,sum=1,j;
   cin>>n;
   tim t;
   vector<tim>v;
   for(i=0;i<n;i++)
    cin>>t.f>>t.s,v.pb(t);
   sort(v.B,v.E,cmp);//if time ain't sorted
   j=0;
   for(ll i=1;i<n;i++)
   {
       if(v[i].f>=v[j].s)sum++,j=i;
   }
   cout<<sum<<"\n";
}
//CODE
int main()
{
    //freopen("inp.txt","r",stdin)
    scanf("%lld",&T);
    while(T--)
        sol(cs++);
    return 0;
}
/**
   SHAMI AL BASHAR PROTHOY
   PRESIDENCY INTERNATIONAL SCHOOL
**/

#include <bits/stdc++.h>
using namespace std;
#define csee "Case "<<cs<<": "
typedef long long ll;
typedef long double ld;
#define B begin()
#define E end()
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ins insert
#define vi vector
#define ins insert
const ld pi=2*acos(0.0);
ll T,cs=1;
struct pt
{
    ll x,y,t;
};
/**
THINK TWICE,
      CODE ONCE
**/
void show(vi<ll>&v)
{
    for(auto it:v)cout<<it<<' ';
    cout<<"\n";
}
vi<ll> filsub(vi<ll>v)
{
    vi<ll>temp;
    ll i,j,n=v.size(),sum;
    for(i=0;i<(1<<n);i++)
    {
        sum=0;
        for(j=0;j<n;j++)
        {
            if(i&(1<<j))
                sum+=v[j];
        }
        temp.pb(sum);
    }
    return temp;
}
void sol(ll cs)
{
    vi<ll>v,va,vb;
    ll n,i,a,k;
    cin>>n>>k;
    for(i=0;i<n;i++)cin>>a,v.pb(a);
    va.assign(v.B,v.E-n/2);
    vb.assign(v.B+(n+1)/2,v.E);
    sort(va.B,va.E);
    sort(vb.B,vb.E);
    va=filsub(va);
    vb=filsub(vb);
    bool bl=false;
    for(i=0;i<va.size();i++)
    {
        if(binary_search(vb.B,vb.E,k-va[i]))
        {
            bl=true;
            break;
        }
    }
    cout<<csee<<((bl)?"Yes":"No")<<"\n";
}
//CODE
int main()
{
    //freopen("inp.txt","r",stdin)
    scanf("%lld",&T);
    while(T--)
        sol(cs++);
    return 0;
}
/**
   SHAMI AL BASHAR PROTHOY
   PRESIDENCY INTERNATIONAL SCHOOL
**/

#include <bits/stdc++.h>
using namespace std;
#define csee "Case "<<cs<<": "
typedef long long ll;
typedef long double ld;
#define B begin()
#define E end()
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ins insert
#define vi vector
#define ins insert
const ld pi=2*acos(0.0);
ll T,cs=1;
struct pt
{
    ll x,y,t;
};
/**
THINK TWICE,
      CODE ONCE
**/
void show(vi<ll>&v)
{
    for(auto it:v)cout<<it<<' ';
    cout<<"\n";
}
set<ll> filsub(vi<ll>v)
{
    set<ll>temp;
    ll i,j,n=v.size(),sum;
    for(i=0;i<(1<<n);i++)
    {
        sum=0;
        for(j=0;j<n;j++)
        {
            if(i&(1<<j))
                sum+=v[j];
        }
        temp.ins(sum);
    }
    return temp;
}
void sol(ll cs)
{
    set<ll>sa,sb;
    vi<ll>v,va,vb;
    ll n,i,a,k;
    cin>>n>>k;
    for(i=0;i<n;i++)cin>>a,v.pb(a);
    va.assign(v.B,v.E-n/2);
    vb.assign(v.B+(n+1)/2,v.E);
    sort(va.B,va.E);
    sort(vb.B,vb.E);
    sa=filsub(va);
    sb=filsub(vb);
    bool bl=false;
    for(auto it=sa.B;it!=sa.E;it++)
    {
        if(sb.count(k-*it))
        {
            bl=true;
            break;
        }
    }
    cout<<csee<<((bl)?"Yes":"No")<<"\n";
}
//CODE
int main()
{
    //freopen("inp.txt","r",stdin)
    scanf("%lld",&T);
    while(T--)
        sol(cs++);
    return 0;
}
/**
   SHAMI AL BASHAR PROTHOY
   PRESIDENCY INTERNATIONAL SCHOOL
**/

#include <bits/stdc++.h>
using namespace std;
#define csee "Case "<<cs<<": "
typedef long long ll;
typedef long double ld;
#define B begin()
#define E end()
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ins insert
#define vi vector
const ld pi=2*acos(0.0);
ll T,N;
ll cs=1;
ll soln=0;
/**
THINK TWICE,
      CODE ONCE
**/
bool ok(vi<vi<ll>>&v,ll row,ll col)
{
    if(row>=0&&row<N&&col>=0&&col<N&&!v[row][col])
        return true;
    return false;
}
void go(vi<vi<ll>>&v,ll row,ll col,ll tp)
{
    if(row==N-1&&col==N-1)
    {
        if(N*N==tp)
            soln++;
        return;
    }
    v[row][col]=1;
    if(row==0&&col==0)
        go(v,row+1,col,tp+1);
    else
    {
        v[row][col]=0;
        bool l=false,r=false,u=false,d=false;
        if(ok(v,row,col+1))
            r=true;
        if(ok(v,row,col-1))
            l=true;
        if(ok(v,row+1,col))
            d=true;
        if(ok(v,row-1,col))
            u=true;
        if(!u&&!d&&r&&l)
            return;
        if(u&&d&&!r&&!l)
            return;
        v[row][col]=1;
        if(r)
            go(v,row,col+1,tp+1);
        if(l)
            go(v,row,col-1,tp+1);
        if(d)
            go(v,row+1,col,tp+1);
        if(u)
            go(v,row-1,col,tp+1);
    }
    v[row][col]=0;
}
void sol(ll cs)
{
    soln=0;
    cin>>N;
    vi<ll>temp(N,0);
    vi<vi<ll>>v(N,temp);
    go(v,0,0,1);
    cout<<csee<<2*soln<<"\n";
}
//CODE
int main()
{
    //freopen("inp.txt","r",stdin)
    scanf("%lld",&T);
    while(T--)
        sol(cs++);
    return 0;
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

void printMonth(int year, int month);
void printMonthTitle(int year, int month);
void ptintMonthName(int month);
void printMonthBody(int year, int month);
int getStartDay(int year, int month);
int getTotalNumberOfDays(int year, int month);
int getNumberOfDaysInMonth(int year, int month);
bool isLeapYear(int year);

int main()
{
	cout << "Enter full year ";
	int year;
	cin >> year;
	cout << " Enter month in number between 1 and 12: ";
	int month;
	cin >> month;
	printMonth(year, month);

}
void printMonth(int year, int month)
{
	printMonthTitle(year, month);

	printMonthBody(year, month);
}


void printMonthTitle(int year, int month)

{
	ptintMonthName(month);
	cout << " " << year << endl;
	cout << "-----------------------------" << endl;
	cout << " Sun Mon Tue Wed Thu Fri Sat" << endl;
	

}



void ptintMonthName(int month)

{
	switch (month)
	{
	case 1:
		cout << "January";
		break;
	case 2:
		cout << "February";
		break;
	case 3:
		cout << "March";
		break;
	case 4:
		cout << "April";
		break;
	case 5:
		cout << "May";
		break;
	case 6:
		cout << "June";
		break;
	case 7:
		cout << "July";
		break;
	case 8:
		cout << "August";
		break;
	case 9:
		cout << "September";
		break;
	case 10:
		cout << "October";
		break;
	case 11:
		cout << "November";
		break;
	case 12:
		cout << "December";
	}
}
void printMonthBody(int year, int month)
{
	int startDay = getStartDay(year, month);
	int numberOfDaysInMonth = getNumberOfDaysInMonth(year, month);

	for (int i = 0; i < startDay; i++)
		cout << "    ";
	for (int i = 1; i <=  numberOfDaysInMonth; i++)
	{
		cout << setw(4) << i;
		if ((i + startDay) % 7 == 0)
			cout << endl;
	}
}
int getStartDay(int year, int month)
{
	int startDay1800 = 3;
	int totalNumberOfDays = getTotalNumberOfDays(year, month);


	return (totalNumberOfDays + startDay1800) % 7;

}
int getTotalNumberOfDays(int year, int month)
{
	int total = 0;
	for (int i = 1800; i < year; i++)
	{
		if (isLeapYear(i))
			total += 366;
		else
			total += 365;
	}
	for (int i = 1; i < month; i++)
	{
		total += getNumberOfDaysInMonth(year, i);
	}
	return total;
}
int getNumberOfDaysInMonth(int year, int month)
{
	if (month == 1 || month == 3 || month == 5 || month == 7 ||
		month == 8 || month == 10 || month == 12)
		return 31;
	if (month == 4 || month == 6 || month == 9 || month == 11)
		return 30;
	
		if (month == 2) return isLeapYear(year) ? 29 : 28;
	
		 return 0;
}
bool  isLeapYear(int year)
{
	return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int hexDec(const string& hex);
int hexCharToDecimal(char ch);
int main()
{
	cout << "enter a hex Number ";
	string hex;
	cin >> hex;

	cout << "The Decimal Number For Hex Is  " << hex
		<< " is " << hexDec(hex) << endl;
}
int hexDec(const string&  hex)
{
	int decimalValue = 0;
	for (unsigned i = 0; i < hex.length(); i++)
	{
		decimalValue = decimalValue * 16 + hexCharToDecimal(hex[i]);
	}
	return decimalValue;
	
}
int hexCharToDecimal(char ch)
{
	ch = toupper(ch);
	if (ch >= 'A' && ch <= 'F')
		return 10 + ch - 'A';
	else
		return ch - '0';
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
    int counter = 1;
    int number = 0;
    int largest = 0;
    int n;
    cin >> n;
    int occurrence = 0;

    cout << "Please enter up to 10 numbers and I will print the largest one on the screen.\n\n";

    while (counter <= n)
    {
        cout << "Number: ";
        cin >> number;
        
        if (largest < number)
        {
            largest = number;
            occurrence = 1;
            
        }
        else if (number == largest)
        {
            occurrence++;
        }
        if (number == 0)
        {
            break;

        }
            counter++;
    }

    cout << "the largest number is "<<largest << endl;
    cout << "  the occurrence count " << largest << " is " << occurrence << " time";


	

}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{

	int firstprofit = 0;
	int quantity = 0;
	int q3 = 1;

	//the targeted profit >> 50000
	cout << "Enter the profit ";
	int endProfit;
	cin >> endProfit;

	//first five quantity 1 * 1000+2 * 4000
	firstprofit += 9000;
	do
	{
		//the remaining quantity(q3) which is 50000(endProfit) - 9000(firstProfit) / 5
		if (q3 == (endProfit - 9000) / 5)

			firstprofit += q3 * 5;
		else
			q3++;

	} while (firstprofit <= endProfit);

	//the whole quantity
	quantity += 1000 + 4000 + q3;

	cout << quantity;






}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	int num, reversedInteger = 0, remainder, originalInteger;
	cin >> num;
	originalInteger = num;
	for (; num != 0; num /= 10)
	{
		remainder = num % 10;
		reversedInteger = reversedInteger * 10 + remainder;
	}


	if (originalInteger == reversedInteger)
		cout << originalInteger << " is a palindrome.";
	else
		cout << originalInteger << " is not a palindrome.";


	
	

	
	
}

	
	

#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{

	int f1 = 0, f2 = 1;
	int nextTerm = 0;
	for (int i = 1; i < 10; i++)
	{
		//print first 2 numbers
		if (i == 1)
		{
			cout <<  f1<<" ";
			continue;
		}
		if (i == 2)
		{
			cout << f2 << " ";
			continue;
		}
		
		nextTerm = f1 + f2;
		f1 = f2;
		//make f2 = the next term
		f2 = nextTerm;
		cout << nextTerm<<" ";

	}

	
	

	
	
}

	
	

#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	cout << "enter the year ";
	int year;
	cin >> year;
	
	cout << "Enter The First Day Of The year ";
	int FirstDay;
	cin >> FirstDay;
	int count = 1;
	int days = 1;
	for (int month = 1; month <= 12; month++)
	{
		cout << "             ";
		switch (month)
		{
		case 1: cout << "January " << year<<endl;
			break;
		case 2: cout << "February " << year << endl;
			break;
		case 3: cout << "March  " << year << endl;
			break;
		case 4: cout << "April  " << year << endl;
			break;
		case 5: cout << "May " << year << endl;
			break;
		case 6: cout << "June  " << year << endl;
			break;
		case 7: cout << "July  " << year << endl;
			break;
		case 8: cout << "August " << year << endl;
			break;
		case 9: cout << "September " << year << endl;
			break;
		case 10: cout << "October " << year << endl;
			break;
		case 11: cout << "November " << year << endl;
			break;
		case 12: cout << "December " << year << endl;
			break;
		}
		cout << " --------------------------------------------------------- "<<endl;
		cout << "  Sun Mon Tue Wed Thu Fri Sat"<<endl;
		for (int i = 0; i < FirstDay; i++)
		{
			cout << "    ";
		}
		for (int i = 1; i < 31; i++)
		{
			if (i < 10) {
				cout<<"   " <<i;
			}
			else {
				cout<<"  " << i;
			}
			if ((i + FirstDay) % 7 == 0) {
				cout << endl;
			}
		}
		cout << endl;

		FirstDay = (FirstDay + 31) % 7;
		
	}
	
	
}

	
	

#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	cout << "enter the month ";
	int month;
	cin >> month;
	cout << "Enter The First Day Of The Month ";
	int firstDay;
	cin >> firstDay;
	int nextSunday = 1;
	
		switch (firstDay)
		{
			
		case 1: nextSunday += 7;
			cout << "The first day of this month is sunday "<<endl;
			while (nextSunday < 30)
			{
					cout << "Next Sunday of this month is on " << nextSunday << endl;
									nextSunday += 7 ;
			}
			break;

		case 2: nextSunday += 6;
			cout << "The first day of this month is monday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 3: nextSunday += 5;
			cout << "The first day of this month is tuesday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 4: nextSunday += 4;
			cout << "The first day of this month is wednesday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 5: nextSunday += 3;
			cout << "The first dayof this month is thursday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 6: nextSunday += 2;
			cout << "The first day of this month is friday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 7: nextSunday += 1;
			cout << "The first day of this month is saturday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;

		}
		
}

	
	

#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	int number;
	cin >> number;
	for (int i = 0; i <=number; i++)
	{
		for (int j = 0; j <= number; j++)
		{
			if
				(
					i == 0 || i == number ||
					i == number/2|| j == number/2||
					j == 0 || j == number ||
					i == j || j == (number - i + 0)
					)
				cout <<" "<< "*";
			else
				cout << "  ";
			int h = (number - i + 1);
		}
	
			cout << "\n";
	}
		


		
	


}

	
	

	
	

#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	for (int i = 0; i < 8; i++)
	{
		for (int k = 0; k <= i; k++)
		{
			cout << "  ";
		}
		for (int j = i; j < 8; j++)
		{
			cout <<" "<< static_cast<char>(j+97-i);

		}
		for (int j = 7; j >= i; j--)
		{
			cout << " " << static_cast<char>(j + 97 - i);
		}
			cout << "\n";
	}
		

}

	
	

	
	

#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	
	cout << " ##############";
	cout << endl;
	for (int  i = 0; i <=5; i++)
	{
		
		for (int j = 0;  j < 1;  j++)
		{
			cout << " " << "#";
		}
		for (int j = 1;  j <= i;  j++)
		{
                cout << " ";
		}
		for (int j = 0; j <1; j++)
		{
			cout << "#";
		}
		for (int j = i; j < 5; j++)
		{
			cout << " ";
		}
		for (int j = i; j < 5; j++)
		{
			cout << " ";

		}
		for (int j = 0; j <1 ; j++)
		{
			cout << "#";
		}
		for (int j = 0; j < i; j++)
		{
			cout << " ";
		}
		for (int i = 0; i < 1; i++)
		{
			cout << "#";
		}
		cout << endl;
	}

	for (int i = 0; i <=5; i++)
	{
		for (int j = 0; j < 1; j++)
		{
			cout << " " << "#";
		}
		for (int j = 5; j >i; j--)
		{
			cout << " ";
		}
		for (int j = 0;  j< 1; j++)
		{
			cout << "#";
		}
		for (int j = 0; j < i; j++)
		{
			cout << " ";
		}
		for (int j = 0; j < i; j++)
		{
			cout << " ";
		}
		for (int j = 0; j < 1; j++)
		{
			cout << "#";
		}
		for (int j = 5; j > i ; j--)
		{
			cout << " ";
		}
		for (int i = 0; i < 1; i++)
		{
			cout << "#";
		}
		cout << endl;
		
	}
	cout << " ##############";
	cout << endl;


}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{



    int rows;
    cin >> rows;

    for (int i = 1; i <= rows; i++)
    {
        for (int k = 1; k <= (rows -i); k++)
        {
            cout << "   ";
           
        }
        for (int d = i; d > 1; d--)
            {
            cout << d << "  ";
                
            }
        for (int  v = 1; v <= i; v++)
        {
            cout << v<<"  ";
        }
        cout << endl;

        
    }


}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	int firstLetter = 65;
	int count = 0;

	for (int i = 65; i <= 90; i++)
	{
		count++;
		if (count%5 == 0)
			cout << setw(3) << static_cast<char>(i) << endl;
		else
			cout << setw(3) << static_cast<char>(i);

		
		
	}

	
	
		

	
	
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{

	cout << "Enter two positive numbers ";
	int n1,n2;
	cin >> n1>>n2;
	int d = 1;
	int gcd = 1;
	
	if (n1 < n2)
		d = n1;
	else
		d = n2;
	while (true)
	{
		if (n1 % d == 0 && n2 % d == 0) {
				gcd = d;
				break;
		}
			
		d--;
	}
	
	cout << "the CGD of " << n1 << " and " << n2 << " is " << gcd;

	
	
		

	
	
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	
	int n = 1;
	int largest = 0;
	while (n*n<30000)
	{
		if (n > largest)
		{
			largest = n;
		}
		n++;
	}
	cout << "the largest number is " << largest;
	
	
		

	
	
}
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	
	int count = 0;
	
	// iterate from 0 to N 
	for (int num = 300,count = 0; num <=400; num++)
	{
		// Short-circuit operator is used  
		if (num % 3 == 0 || num % 6 == 0)
		{
			cout << setw(5) << num;
			count++;
			if (count % 5 == 0)
				cout << setw(5) << num << endl;
		
		}
		
		
			
	}
		

	
	
}
#include <iostream>  
using namespace std;  
int main() 
{  
  int n1=0,n2=1,n3,i,number;    
 cout<<"Enter the number of elements: ";    
 cin>>number;    
 cout<<n1<<" "<<n2<<" "; //printing 0 and 1    
 for(i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed    
 {    
  n3=n1+n2;    
  cout<<n3<<" ";    
  n1=n2;    
  n2=n3;    
 }    
   return 0;  
}  
#include<iostream>
using namespace std;

int main()
{
  cout<<"Enter the integers: "<
}
include <FirebaseArduino.h>

#define FIREBASE_HOST "example.firebaseio.com"
#define FIREBASE_AUTH "token_or_secret"


void setup() {
  Serial.begin(9600);
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}

int n = 0;

void loop() {

  // set value
  Firebase.setFloat("number", 42.0);
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /number failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(1000);
  
  // update value
  Firebase.setFloat("number", 43.0);
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /number failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(1000);

  // get value 
  Serial.print("number: ");
  Serial.println(Firebase.getFloat("number"));
  delay(1000);

  // remove value
  Firebase.remove("number");
  delay(1000);

  // set string value
  Firebase.setString("message", "hello world");
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /message failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(1000);
  
  // set bool value
  Firebase.setBool("truth", false);
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /truth failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(1000);

  // append a new value to /logs
  String name = Firebase.pushInt("logs", n++);
  // handle error
  if (Firebase.failed()) {
      Serial.print("pushing /logs failed:");
      Serial.println(Firebase.error());  
      return;
  }
  Serial.print("pushed: /logs/");
  Serial.println(name);
  delay(1000);
}
  
#include <ESP8266WiFi.h>


// Set these to run example.
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "PASSWORD"

  // connect to wifi.
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());
#include <stdio.h>
 
class Node
{
public:
    Node( int v )
    {
        data = v;
        left = 0;
        right = 0;
    }
 
    int data;
    Node* left;
    Node* right;
};
 
void Add( Node** root, Node* n )
{
    if ( !*root  )
    {
        *root = n;
        return;
    }
 
    if ( (*root)->data < n->data )
    {
        Add( &(*root)->right, n );
    }
    else
    {
        Add( &(*root)->left, n );
    }
}
 
void Print( Node* node )
{
    if ( !node )  return;   
    Print( node->left );
    printf( "value = %i\n", node->data );
    Print( node->right );
}
 
int main()
{
    Node* root = 0;
 
    Add( &root, new Node( 1 ) );
    Add( &root, new Node( 2 ) );
    Add( &root, new Node( -1 ) );
    Add( &root, new Node( 12 ) );
 
    Print( root );
    return 0;
}
int maxSubArraySum(int a[], int size) 
{ 
int max_so_far = 0, max_ending_here = 0; 
for (int i = 0; i < size; i++) 
{ 
	max_ending_here = max_ending_here + a[i]; 
	if (max_ending_here < 0) 
		max_ending_here = 0; 

	/* Do not compare for all elements. Compare only 
		when max_ending_here > 0 */
	else if (max_so_far < max_ending_here) 
		max_so_far = max_ending_here; 
} 
return max_so_far; 
} 
#include<iostream>                //including input/output libarary
using namespace std;
int main(){                               //starting main function
int array_name[5];                   //defining a variable array of type integer with name "array_name" and size 5.
array_name[0]=2;                   //assigning value of 2 to  first element of array "array_name"
array_name[1]=3;                   
array_name[2]=4                      // assinging values to other elements of array using their index number
array_name[3]=12;
array_name[4]=33;

return 0;
}
> More steps
// Define macros for inlining x86 assembly in a compiler-independent way
#ifdef _MSC_VER
	#define ASM1(asm_literal) \
		__asm asm_literal
	#define ASM2(asm_literal1, asm_literal2) \
		__asm asm_literal1, asm_literal2
	#define ASM3(asm_literal1, asm_literal2, asm_literal3) \
		__asm asm_literal1, asm_literal2, asm_literal3

	#define ASM_MOV_REG_VAR(register, variable) \
		ASM(mov register, variable)

	#define ASM_MOV_VAR_REG(variable, register) \
		ASM(mov variable, register)

#elif __GNUC__ || __clang__
	#define ASM1(asm_literal) \
		ASM_GCC(#asm_literal)
	#define ASM2(asm_literal1, asm_literal2) \
		ASM_GCC(#asm_literal1 ", " #asm_literal2)
	#define ASM3(asm_literal1, asm_literal2, asm_literal3) \
		ASM_GCC(#asm_literal1 ", " #asm_literal2 ", " #asm_literal3)
	
	#ifdef __x86_64__
		#define ASM_MOV_REG_VAR(register, variable) \
			__asm__ __volatile__("movq %0, %%" EXPAND_AND_QUOTE(register)  : /* no outputs */ : "m"(variable) : )

		#define ASM_MOV_VAR_REG(variable, register) \
			__asm__ __volatile__("movq %%" EXPAND_AND_QUOTE(register) ", %0"  : "=m"(variable) : /* no inputs */ : )
	#else
		#define ASM_MOV_REG_VAR(register, variable) \
			__asm__ __volatile__("mov %0, %%" EXPAND_AND_QUOTE(register)  : /* no outputs */ : "m"(variable) : )

		#define ASM_MOV_VAR_REG(variable, register) \
			__asm__ __volatile__("mov %%" EXPAND_AND_QUOTE(register) ", %0"  : "=m"(variable) : /* no inputs */ : )
	#endif

	#define ASM_GCC(asm_string) \
		__asm__ __volatile__(".intel_syntax noprefix;" asm_string ";.att_syntax prefix"); \
	
#endif
star

Thu May 22 2025 03:35:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu May 22 2025 03:30:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu May 22 2025 03:24:50 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jan 10 2025 01:02:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jan 10 2025 01:01:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jan 10 2025 00:59:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jan 03 2025 20:18:56 GMT+0000 (Coordinated Universal Time)

#loop #c++ #vector #pointers #binarysearch #array
star

Fri Jan 03 2025 18:59:47 GMT+0000 (Coordinated Universal Time)

#loop #c++ #vector #pointers #binarysearch
star

Fri Jan 03 2025 10:56:21 GMT+0000 (Coordinated Universal Time)

#loop #c++ #vector #pointers
star

Fri Dec 27 2024 18:18:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 27 2024 18:17:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 27 2024 18:16:44 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Dec 23 2024 01:37:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Dec 17 2024 21:31:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 06:21:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 06:20:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 06:19:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 06:18:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 06:17:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 06:15:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 06:10:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 04:10:59 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 04:09:30 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 03:22:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 03:21:34 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 03:20:37 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 03:18:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 03:17:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 02:13:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 02:12:44 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 15 2024 02:10:49 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 12 2024 16:36:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Dec 07 2024 11:45:20 GMT+0000 (Coordinated Universal Time)

#loop #c++ #vector
star

Fri Dec 06 2024 12:13:48 GMT+0000 (Coordinated Universal Time)

#loop #array #c++
star

Sat Nov 30 2024 14:52:14 GMT+0000 (Coordinated Universal Time) https://catalog.viva-scim.ro/

#c# #c++ #nodejs
star

Tue Nov 12 2024 03:11:26 GMT+0000 (Coordinated Universal Time)

#c++ #function #loop
star

Mon Nov 11 2024 16:09:30 GMT+0000 (Coordinated Universal Time)

#c++ #function #loop
star

Mon Nov 11 2024 15:58:45 GMT+0000 (Coordinated Universal Time)

#loop #c++
star

Sat Nov 09 2024 16:19:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Nov 09 2024 16:11:00 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Nov 06 2024 10:52:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Nov 05 2024 23:34:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Nov 05 2024 20:14:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Nov 05 2024 18:46:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Nov 05 2024 18:33:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Oct 21 2024 07:38:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Oct 20 2024 07:11:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Oct 20 2024 06:48:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Oct 20 2024 06:26:53 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Oct 20 2024 06:24:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Oct 15 2024 14:37:49 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Oct 14 2024 11:28:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Sep 12 2024 17:38:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Sep 12 2024 17:36:47 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Sep 12 2024 16:00:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Sep 12 2024 15:59:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 03 2024 20:18:41 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 03 2024 20:17:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 03 2024 20:15:47 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 03 2024 19:47:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Aug 30 2024 11:51:17 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Aug 29 2024 20:01:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Aug 29 2024 19:57:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Aug 27 2024 17:00:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Aug 27 2024 15:59:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Aug 27 2024 15:57:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Aug 27 2024 15:42:36 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Aug 25 2024 20:24:50 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Fri Aug 23 2024 08:04:56 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Wed Aug 21 2024 23:34:09 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Wed Aug 21 2024 23:33:51 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Tue Aug 06 2024 06:35:19 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/detect-cycle-in-an-undirected-graph/1

#c++
star

Mon Aug 05 2024 17:05:19 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/problems/SQING

#c++
star

Fri Jul 19 2024 06:27:21 GMT+0000 (Coordinated Universal Time) https://youtu.be/fi2vh0nQLi0?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #reverselinkedlist #recursion #circular
star

Fri Jul 19 2024 06:09:29 GMT+0000 (Coordinated Universal Time) https://youtu.be/fi2vh0nQLi0?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #reverselinkedlist #recursion
star

Fri Jul 19 2024 04:14:41 GMT+0000 (Coordinated Universal Time) https://youtu.be/vqS1nVQdCJM

#c++ #dsa #linkedlist #reverselinkedlist #recursion
star

Fri Jul 19 2024 04:13:46 GMT+0000 (Coordinated Universal Time) https://youtu.be/vqS1nVQdCJM

#c++ #dsa #linkedlist #reverselinkedlist #recursion
star

Thu Jul 18 2024 17:17:04 GMT+0000 (Coordinated Universal Time) https://youtu.be/vqS1nVQdCJM

#c++ #dsa #linkedlist #reverselinkedlist
star

Wed Jul 17 2024 16:14:41 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast #print #insertinbetween #insertatposition #insertinmiddle #doublylinkedlist #insertathead
star

Wed Jul 17 2024 16:12:30 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast #print #insertinbetween #insertatposition #insertinmiddle #doublylinkedlist #insertathead
star

Wed Jul 17 2024 16:11:36 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast #print #insertinbetween #insertatposition #insertinmiddle #doublylinkedlist #insertathead
star

Wed Jul 17 2024 16:10:45 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast #print #insertinbetween #insertatposition #insertinmiddle #doublylinkedlist #insertathead
star

Wed Jul 17 2024 16:09:39 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast #print #insertinbetween #insertatposition #insertinmiddle #doublylinkedlist
star

Wed Jul 17 2024 16:08:58 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast #print #insertinbetween #insertatposition #insertinmiddle #doublylinkedlist
star

Wed Jul 17 2024 12:02:21 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast #print #insertinbetween #insertatposition #insertinmiddle
star

Wed Jul 17 2024 12:00:47 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast #print
star

Wed Jul 17 2024 11:57:55 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #insertinlast
star

Wed Jul 17 2024 11:56:35 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #deletenode
star

Wed Jul 17 2024 11:55:01 GMT+0000 (Coordinated Universal Time) https://youtu.be/q8gdBn9RPeI?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #linkedlist #deletenode
star

Sun Jul 14 2024 14:05:37 GMT+0000 (Coordinated Universal Time) https://youtu.be/cdHEpbBVjRM?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #recursion #string #mergesort
star

Sun Jul 14 2024 07:55:58 GMT+0000 (Coordinated Universal Time) https://youtu.be/WyY2Af3k1xI

#c++ #dsa #recursion #string #palindrome #checkpalindrome
star

Thu Jul 11 2024 02:51:16 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jul 06 2024 12:35:10 GMT+0000 (Coordinated Universal Time) https://youtu.be/GqtyVD-x_jY?list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA

#c++ #dsa #recursion #sorting #string #ratinamazeproblem
star

Sun Jun 30 2024 12:12:51 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #recursion #math
star

Sun Jun 30 2024 09:06:00 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #recursion #array #binarysearch
star

Sun Jun 30 2024 08:47:07 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #recursion #array #linearsearch
star

Sun Jun 30 2024 08:15:40 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #recursion #array
star

Sun Jun 30 2024 06:50:19 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #fibonacci #recursion
star

Sun Jun 30 2024 06:48:41 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #2darray #spiralprint
star

Fri Jun 28 2024 06:07:11 GMT+0000 (Coordinated Universal Time) https://youtu.be/1CdolnvxLs0

#c++ #dsa #2darray #spiralprint
star

Fri Jun 28 2024 05:16:11 GMT+0000 (Coordinated Universal Time) https://youtu.be/1CdolnvxLs0

#c++ #dsa #2darray #waveprint
star

Thu Jun 27 2024 11:32:01 GMT+0000 (Coordinated Universal Time) https://youtu.be/Wdjr6uoZ0e0

#c++ #dsa #string
star

Thu Jun 27 2024 11:08:26 GMT+0000 (Coordinated Universal Time) https://youtu.be/Wdjr6uoZ0e0

#c++ #dsa #string
star

Wed Jun 26 2024 15:03:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 26 2024 14:55:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Jun 25 2024 13:45:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Jun 24 2024 18:47:17 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Jun 24 2024 18:06:02 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=MPvr-LmaZmA&list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA&index=21

#c++ #dsa #array
star

Mon Jun 24 2024 17:15:07 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #array
star

Mon Jun 24 2024 13:03:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Jun 24 2024 11:09:55 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #bubblesorting #sorting
star

Mon Jun 24 2024 10:32:33 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=UdO2NeHB46c

#c++ #dsa #binarysearch
star

Mon Jun 24 2024 10:05:05 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=6z2HK4o8qcU&list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA&index=14

#c++ #dsa #binarysearch
star

Mon Jun 24 2024 10:05:04 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=6z2HK4o8qcU&list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA&index=14

#c++ #dsa #binarysearch
star

Sun Jun 23 2024 19:01:32 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 23 2024 18:01:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 23 2024 17:53:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 23 2024 17:53:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 23 2024 14:10:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 23 2024 13:43:15 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/minimum-spanning-tree/1

#c++
star

Sun Jun 23 2024 13:02:41 GMT+0000 (Coordinated Universal Time) Buy & Sell Stock II & III are important for Stock DP

#c++
star

Sun Jun 23 2024 12:22:13 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 23 2024 10:39:23 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=6z2HK4o8qcU&list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA&index=14

#c++ #dsa
star

Sun Jun 23 2024 10:18:46 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=6z2HK4o8qcU&list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA&index=14

#c++ #dsa
star

Sun Jun 23 2024 10:07:22 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/distance-from-the-source-bellman-ford-algorithm/1

#c++
star

Sun Jun 23 2024 08:27:08 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=6z2HK4o8qcU&list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA&index=14

#c++ #dsa
star

Sun Jun 23 2024 07:49:57 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=6z2HK4o8qcU&list=PLDzeHZWIZsTryvtXdMr6rPh4IDexB5NIA&index=14

#c++ #dsa
star

Sat Jun 22 2024 15:19:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jun 22 2024 14:53:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jun 22 2024 14:20:00 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jun 22 2024 06:58:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 20 2024 23:24:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 20 2024 23:21:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 19 2024 15:38:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 19 2024 13:09:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 19 2024 08:38:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 19 2024 08:17:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 19 2024 06:32:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 19 2024 03:05:02 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Jun 17 2024 13:00:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jun 15 2024 08:01:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 14 2024 13:28:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 12 2024 20:48:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 12 2024 20:43:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 12 2024 07:15:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Jun 11 2024 07:16:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Jun 10 2024 13:47:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Jun 10 2024 12:57:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 09 2024 13:17:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jun 08 2024 00:45:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 07 2024 22:54:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 07 2024 21:53:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 07 2024 14:18:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 07 2024 13:13:50 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 07 2024 12:56:59 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 06 2024 14:01:13 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 06 2024 08:48:50 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 29 2024 16:19:35 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 29 2024 09:02:16 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 28 2024 22:54:02 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 28 2024 22:21:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 28 2024 21:55:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 28 2024 15:24:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 28 2024 14:58:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon May 27 2024 23:33:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon May 27 2024 00:04:28 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 14:12:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 13:44:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 12:58:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 11:59:17 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 11:56:56 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 11:53:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 10:43:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 00:35:07 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 00:34:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 00:33:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 00:29:30 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 00:22:35 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 00:21:30 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 26 2024 00:21:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat May 25 2024 22:50:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat May 25 2024 22:50:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat May 25 2024 21:26:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat May 25 2024 18:36:09 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat May 25 2024 11:57:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri May 24 2024 22:47:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri May 24 2024 14:13:44 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri May 24 2024 12:41:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu May 23 2024 21:06:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu May 23 2024 21:05:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 22 2024 12:21:03 GMT+0000 (Coordinated Universal Time) https://www.alphacodez.com/paxful-clone-script

#c #c++
star

Wed May 22 2024 11:48:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 22 2024 08:23:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 22 2024 07:51:02 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 21 2024 12:59:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 21 2024 09:04:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 21 2024 07:51:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 21 2024 07:50:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 21 2024 07:50:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon May 20 2024 10:37:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 15 2024 17:32:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 15 2024 17:30:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri May 10 2024 19:58:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu May 09 2024 00:57:14 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 08 2024 21:58:49 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 08 2024 20:58:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 08 2024 20:20:56 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 01 2024 20:19:49 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Apr 28 2024 18:18:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Apr 28 2024 18:04:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Apr 28 2024 17:35:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Apr 28 2024 17:21:22 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 04 2024 20:18:47 GMT+0000 (Coordinated Universal Time)

#c++ #c #forgottenwoods #camera #parallax
star

Thu Apr 04 2024 20:15:25 GMT+0000 (Coordinated Universal Time)

#c++ #c #forgottenwoods #camera
star

Thu Apr 04 2024 19:03:21 GMT+0000 (Coordinated Universal Time)

#c++ #c #nook #ui #levelselect #menu
star

Thu Apr 04 2024 19:01:17 GMT+0000 (Coordinated Universal Time)

#c++ #c #nook #sprite
star

Thu Apr 04 2024 18:55:58 GMT+0000 (Coordinated Universal Time)

#c++ #c #nook #gameplay
star

Thu Apr 04 2024 18:50:23 GMT+0000 (Coordinated Universal Time)

#c++ #c #nook #ui #menu
star

Thu Apr 04 2024 18:44:13 GMT+0000 (Coordinated Universal Time)

#c++ #c #mesh #sprite #nook
star

Thu Apr 04 2024 18:39:31 GMT+0000 (Coordinated Universal Time)

#c++ #c #audio
star

Thu Apr 04 2024 01:13:32 GMT+0000 (Coordinated Universal Time)

#c++ #c
star

Fri Mar 22 2024 05:46:49 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Wed Mar 20 2024 20:56:14 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Mar 20 2024 20:55:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Mar 15 2024 14:31:30 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Mar 15 2024 14:30:37 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Mar 15 2024 09:11:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Mar 04 2024 07:23:11 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Sun Mar 03 2024 07:45:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Feb 21 2024 16:09:03 GMT+0000 (Coordinated Universal Time)

#c++ #makefile #make
star

Mon Feb 19 2024 16:23:28 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Feb 12 2024 15:39:17 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Feb 12 2024 14:50:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Feb 12 2024 14:37:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Feb 11 2024 16:50:47 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Feb 11 2024 16:15:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Feb 03 2024 23:06:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Feb 03 2024 17:59:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jan 11 2024 20:11:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jan 11 2024 20:07:49 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jan 11 2024 19:53:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jan 11 2024 19:42:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jan 11 2024 19:36:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 22 2023 04:05:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 21 2023 06:24:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 21 2023 05:59:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Dec 18 2023 05:27:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Dec 18 2023 05:06:53 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/studio/problems/group-anagrams_800285?utm_source=youtube&utm_medium=affiliate&utm_campaign=parikh_youtube&leftPanelTabValue=PROBLEM

#c++
star

Sun Dec 17 2023 14:16:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 17 2023 05:15:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 17 2023 04:02:13 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/sort-a-linked-list/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=bottom_sticky_on_article

#c++
star

Sat Dec 16 2023 16:47:21 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/studio/problems/merge-sort_920442?utm_source=youtube&utm_medium=affiliate&utm_campaign=parikh_youtube&leftPanelTabValue=PROBLEM

#c++
star

Sat Dec 16 2023 11:54:12 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/studio/problems/encode-the-message_699836?utm_source=youtube&utm_medium=affiliate&utm_campaign=parikh_youtube&leftPanelTabValue=PROBLEM

#c++
star

Sat Dec 16 2023 04:49:29 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/studio/problems/mnfrj_1075018?utm_source=youtube&utm_medium=affiliate&utm_campaign=parikh_youtube&leftPanelTabValue=PROBLEM

#c++
star

Sat Dec 16 2023 04:22:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 14 2023 06:46:00 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 14 2023 06:32:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 14 2023 06:23:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Dec 13 2023 04:29:22 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Dec 13 2023 04:27:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 08 2023 12:23:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 08 2023 12:10:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 08 2023 11:13:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 08 2023 06:39:55 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/rotate-array-by-n-elements-1587115621/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=bottom_sticky_on_article

#c++
star

Fri Dec 08 2023 04:20:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 07 2023 18:08:42 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/linked-list-insertion-1587115620/1?page=1&category=Linked%20List&sortBy=submissions

#c++
star

Thu Dec 07 2023 16:37:05 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/studio/problems/ninja-and-the-sorted-check_6581957?utm_source=youtube&utm_medium=affiliate&utm_campaign=striver_Arrayproblems&leftPanelTabValue=PROBLEM

#c++
star

Thu Dec 07 2023 12:36:50 GMT+0000 (Coordinated Universal Time) https://codingninjas.com/studio/problems/ninja-and-the-second-order-elements_6581960?utm_source=youtube&utm_medium=affiliate&utm_campaign=striver_Arrayproblems&leftPanelTabValue=PROBLEM

#c++
star

Sun Dec 03 2023 06:45:00 GMT+0000 (Coordinated Universal Time) https://workat.tech/problem-solving/practice/simple-interest

#c++
star

Sat Dec 02 2023 18:26:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Dec 02 2023 18:17:00 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Dec 02 2023 07:33:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 01 2023 12:17:31 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/k-distance-from-root/1?page=3&company=Samsung&difficulty=School,Basic,Easy&sortBy=latest

#c++
star

Fri Dec 01 2023 11:55:43 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/check-for-bst/1?page=3&company=Samsung&difficulty=School,Basic,Easy&sortBy=latest

#c++
star

Fri Dec 01 2023 06:11:41 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/change-all-even-bits-in-a-number-to-03253/1?page=1&company=Samsung&sortBy=difficulty

#c++
star

Fri Dec 01 2023 05:54:49 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/string-reversalunpublished-for-now5324/1?page=1&company=Samsung&sortBy=difficulty

#c++
star

Fri Dec 01 2023 05:27:45 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/swap-two-numbers3844/1?page=1&company=Samsung&sortBy=difficulty

#c++
star

Thu Nov 30 2023 17:55:01 GMT+0000 (Coordinated Universal Time) https://prepinsta.com/cpp-program/cpp-program-to-check-whether-a-year-is-a-leap-year-or-not/

#c++
star

Wed Nov 29 2023 12:06:23 GMT+0000 (Coordinated Universal Time) https://www.dappfort.com/blog/create-an-order-book-exchange-using-binance-clone-script/

#objectivec #react.js #c# #c++
star

Fri Nov 24 2023 05:34:24 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/median-of-two-sorted-arrays/

#c++
star

Fri Nov 24 2023 05:04:30 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/inorder-traversal-iterative/1

#c++
star

Tue Nov 07 2023 14:51:16 GMT+0000 (Coordinated Universal Time) https://www.onlinegdb.com/online_c++_compiler

#c++
star

Tue Nov 07 2023 14:39:00 GMT+0000 (Coordinated Universal Time) https://www.onlinegdb.com/online_c++_compiler

#c++
star

Tue Nov 07 2023 13:45:31 GMT+0000 (Coordinated Universal Time) https://www.onlinegdb.com/online_c++_compiler

#c++
star

Mon Nov 06 2023 22:41:07 GMT+0000 (Coordinated Universal Time) https://www.onlinegdb.com/online_c++_compiler

#c++
star

Sat Oct 28 2023 05:35:01 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Fri Oct 20 2023 16:01:53 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Oct 20 2023 15:47:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Oct 20 2023 14:58:32 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Oct 09 2023 08:32:16 GMT+0000 (Coordinated Universal Time) https://leetcode.com/contest/weekly-contest-366/problems/apply-operations-to-make-two-strings-equal/

#c++ #dp #two_string_equal
star

Sun Oct 08 2023 13:00:17 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Oct 08 2023 02:09:44 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Oct 06 2023 12:11:23 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/given-a-linked-list-reverse-alternate-nodes-and-append-at-the-end/1

#linkedlists #evenlength #o(n) #c++
star

Mon Oct 02 2023 17:14:27 GMT+0000 (Coordinated Universal Time) https://onecompiler.com/cpp/3zpabzndg

#c++
star

Mon Oct 02 2023 16:52:25 GMT+0000 (Coordinated Universal Time) https://onecompiler.com/cpp/3zpabzndg

#c++
star

Mon Oct 02 2023 16:01:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 26 2023 07:23:35 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Sep 25 2023 07:57:33 GMT+0000 (Coordinated Universal Time) https://maticz.com/blockchain-business-ideas

#c++
star

Mon Sep 18 2023 22:35:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Sep 13 2023 14:00:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 10 2023 09:38:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 10 2023 08:50:46 GMT+0000 (Coordinated Universal Time) https://codeforces.com/blog/entry/71146

#c++
star

Thu Sep 07 2023 13:59:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Sep 07 2023 13:58:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Sep 06 2023 13:46:08 GMT+0000 (Coordinated Universal Time) https://www.topcoder.com/thrive/articles/tarjans-algorithm-for-strongly-connected-components

#c++
star

Wed Sep 06 2023 13:30:38 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/critical-connections-in-a-network/solutions/782661/c-tarjan-algorithm/

#c++
star

Tue Aug 29 2023 10:20:28 GMT+0000 (Coordinated Universal Time) https://maticz.com/bitcoin-mining-script

#c++
star

Sun Aug 20 2023 14:13:19 GMT+0000 (Coordinated Universal Time) https://prepinsta.com/cpp-program/to-find-the-frequency-of-elements-in-an-array/

#c++
star

Thu Aug 17 2023 15:51:03 GMT+0000 (Coordinated Universal Time) https://www.codinguru.online

#compiler #javascript #php #c++ #python #html
star

Thu Aug 17 2023 15:46:37 GMT+0000 (Coordinated Universal Time) https://www.codinguru.online/compiler/cpp

#codinguru #cpp #c++ #c++
star

Tue Aug 08 2023 03:05:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Aug 04 2023 05:28:40 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/counting-bits/description/

#c++
star

Thu Aug 03 2023 08:47:34 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Aug 01 2023 12:53:43 GMT+0000 (Coordinated Universal Time) https://maticz.com/rummy-game-development

#c++
star

Sat Jul 29 2023 06:11:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jul 29 2023 06:08:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jul 29 2023 05:02:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jul 29 2023 04:32:09 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jul 27 2023 13:20:44 GMT+0000 (Coordinated Universal Time) https://maticz.com/blockchain-business-ideas

#c++
star

Thu Jul 27 2023 09:57:11 GMT+0000 (Coordinated Universal Time) https://www.pbinfo.ro/probleme/939/sum00

#c++
star

Fri Jul 21 2023 12:21:39 GMT+0000 (Coordinated Universal Time) https://maticz.com/how-to-create-a-crypto-trading-bot

#c++
star

Mon Jul 17 2023 11:55:04 GMT+0000 (Coordinated Universal Time) https://maticz.com/video-game-development

#c++
star

Mon Jul 17 2023 11:39:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jul 13 2023 15:21:49 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/8546756/matrix-multiplication-algorithm-time-complexity

#c++
star

Tue Jul 11 2023 09:55:33 GMT+0000 (Coordinated Universal Time) https://maticz.com/p2p-cryptocurrency-exchange-development

#c++
star

Sun Jul 02 2023 13:39:34 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jul 02 2023 12:23:06 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem0945/1

#c++
star

Fri Jun 30 2023 10:38:32 GMT+0000 (Coordinated Universal Time) https://maticz.com/binance-clone-script

#c++
star

Mon Jun 26 2023 09:56:59 GMT+0000 (Coordinated Universal Time) https://maticz.com/trust-wallet-clone-app

#c++
star

Sun Jun 25 2023 04:54:02 GMT+0000 (Coordinated Universal Time) https://leetcode.com/contest/weekly-contest-351/problems/minimum-operations-to-make-the-integer-zero/

#c++ #greedy
star

Sat Jun 24 2023 05:07:28 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/prefix-match-with-other-strings/1

#dfs #c++ #print_trie
star

Thu Jun 22 2023 05:31:24 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/lemonade-change/1

#c++ #lemonade_change #greedy #maps
star

Mon Jun 19 2023 06:59:26 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/rearrange-an-array-with-o1-extra-space3142/1

#c++ #cyclic_rotation #rearrangement #array #o(1)_space
star

Mon Jun 19 2023 03:26:01 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/number-of-increasing-paths-in-a-grid/submissions/

#c++ #dynamic_programming #increasing_paths_grid
star

Fri Jun 16 2023 07:57:40 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst/

#c++ #dfs #bst #dynamic_programming #combinatorics
star

Fri Jun 16 2023 04:24:30 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 15 2023 01:57:50 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/

#c++ #binary_tree #maximum_level_sum
star

Thu Jun 15 2023 01:35:49 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/longest-palindrome-in-a-string3411/1

#c++ #dynamic_programming #longest_palindrome
star

Wed Jun 14 2023 03:15:43 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/kth-smallest-element5635/1?page

#c++ #order_statistics #kth_smallest_element #o(n) #randomized
star

Tue Jun 13 2023 17:25:41 GMT+0000 (Coordinated Universal Time) https://www.pbinfo.ro/probleme/1360/suma-gauss

#c++
star

Thu Jun 08 2023 07:52:02 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/n-meetings-in-one-room-1587115620/1

#n_meetings #greedy #gfg #c++
star

Thu Jun 08 2023 02:58:31 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/find-kth-permutation-0932/1

#c++ #permutations #backtracking
star

Wed Jun 07 2023 12:15:56 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/combination-sum-1587115620/1

#c++
star

Tue Jun 06 2023 09:03:41 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Jun 06 2023 08:15:49 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 04 2023 19:23:56 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 04 2023 12:29:16 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 04 2023 12:27:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 02 2023 06:16:54 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/detonate-the-maximum-bombs/

#c++ #union-find-class
star

Thu Jun 01 2023 12:48:15 GMT+0000 (Coordinated Universal Time) https://youtu.be/F7wqWbqYn9g

#c++
star

Thu Jun 01 2023 08:35:21 GMT+0000 (Coordinated Universal Time) https://leetcode.com/submissions/detail/961503088/

#c++ #bfs #shortest_path_binmat
star

Thu Jun 01 2023 08:04:01 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/topological-sort/1

#c++ #kahns
star

Wed May 31 2023 21:03:07 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/topological-sort/1

#c++ #find_ds
star

Wed May 31 2023 17:07:21 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/largest-subarray-with-0-sum/1

#c++ #largest_sub_sum_0 #sde_sheet
star

Wed May 31 2023 08:14:47 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/frequency-game/1

#c++ #largest_min_freq
star

Tue May 30 2023 18:03:14 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/two-sum/submissions/

#c++ #max_heap
star

Tue May 30 2023 14:27:01 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/unique-paths/

#c++ #unique_paths #combinatorics
star

Mon May 29 2023 07:31:46 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/partition-equal-subset-sum/description/

#c++
star

Mon May 29 2023 06:46:41 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/camelcase-pattern-matching2259/1

#c++ #trie #incomplete
star

Mon May 29 2023 06:08:32 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/subset-sum-problem-1611555638/1

#c++
star

Sun May 28 2023 11:06:04 GMT+0000 (Coordinated Universal Time) https://leetcode.com/contest/weekly-contest-347/problems/maximum-strictly-increasing-cells-in-a-matrix/

#c++ #dynammic_programming
star

Sat May 27 2023 19:54:44 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/nth-node-from-end-of-linked-list/1

#c++ #linked_list #nth_node_from_end
star

Sat May 27 2023 19:40:55 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/greatest-common-divisor-traversal/

#c++ #primes_generator #sieve
star

Sat May 27 2023 14:21:04 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/stone-game-iii/

#c++ #stone_game_3 #tle
star

Sat May 27 2023 13:12:19 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/modify-linked-list-1-0546/1

#c++ #halve_the_ll
star

Sat May 27 2023 13:10:15 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/modify-linked-list-1-0546/1

#c++ #reverse_linked_list
star

Sat May 27 2023 10:30:08 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/next-greater-element-iii/description/

#c++
star

Fri May 26 2023 07:10:39 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/longest-substring-without-repeating-characters/

#c++
star

Fri May 26 2023 04:28:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu May 25 2023 17:34:22 GMT+0000 (Coordinated Universal Time) https://devptr.com/how-to-remove-duplicates-from-a-vector-in-c/

#c++ #remove_duplicates #vector
star

Wed May 24 2023 07:29:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 24 2023 07:20:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 24 2023 03:16:15 GMT+0000 (Coordinated Universal Time) https://vednikol-sturdy-palm-tree-445qgv4qx6g3q95.github.dev/

#c++
star

Tue May 23 2023 18:55:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 18:30:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 18:24:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 17:33:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 17:28:53 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 16:59:50 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 16:52:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 15:39:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 15:21:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 15:17:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 14:56:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 23 2023 10:37:50 GMT+0000 (Coordinated Universal Time) https://shamlatech.com/cryptocurrency-development/

#flutter #c# #c++
star

Sun May 21 2023 13:49:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat May 20 2023 10:32:07 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/save-your-life4601/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Fri May 19 2023 06:16:50 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/1132bd8ee92072cd31441858402641d6800fa6b3/1

#c++ #count_set_bits_till_n
star

Mon May 08 2023 16:11:45 GMT+0000 (Coordinated Universal Time)

#arduino #c++ #synthesizer
star

Mon May 08 2023 10:35:05 GMT+0000 (Coordinated Universal Time) https://shamlatech.com/paxful-clone-script/

#flutter #c# #c++
star

Mon May 08 2023 10:33:46 GMT+0000 (Coordinated Universal Time) https://shamlatech.com/coinbase-clone/

#c# #c++ #typescript
star

Sat Apr 29 2023 18:27:47 GMT+0000 (Coordinated Universal Time)

#vscode #c++ #settings
star

Thu Apr 27 2023 17:07:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 27 2023 17:02:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Apr 23 2023 17:33:36 GMT+0000 (Coordinated Universal Time) http://n96032fn.beget.tech/html/solution/c/arr.php

#c++
star

Sun Apr 23 2023 17:33:30 GMT+0000 (Coordinated Universal Time) http://n96032fn.beget.tech/html/solution/c/arr.php

#c++
star

Sun Apr 23 2023 17:33:19 GMT+0000 (Coordinated Universal Time) http://n96032fn.beget.tech/html/solution/c/arr.php

#c++
star

Sun Apr 23 2023 07:04:14 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/longest-common-subsequence/

#c++
star

Sat Apr 22 2023 05:33:52 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/house-robber/

#c++
star

Fri Apr 21 2023 22:14:12 GMT+0000 (Coordinated Universal Time)

#c++ #make #cmake
star

Fri Apr 21 2023 08:27:04 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/n-th-tribonacci-number/

#c++
star

Wed Apr 19 2023 07:30:36 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Apr 19 2023 06:20:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 18 2023 06:05:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Apr 17 2023 19:19:13 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/maximum-product-of-three-numbers/

#c++
star

Mon Apr 17 2023 14:45:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 13 2023 03:52:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Apr 12 2023 18:34:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Apr 12 2023 15:07:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Apr 12 2023 14:53:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Apr 12 2023 13:49:09 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Apr 12 2023 05:58:32 GMT+0000 (Coordinated Universal Time)

#arduino #c++ #synthesizer
star

Wed Apr 12 2023 03:37:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 11 2023 16:29:34 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 11 2023 15:03:07 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 11 2023 07:20:17 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 11 2023 03:50:02 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Apr 09 2023 10:23:44 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-smallest-letter-greater-than-target/

#c++
star

Sun Apr 09 2023 08:32:45 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/valid-perfect-square/

#c++
star

Sun Apr 09 2023 07:46:35 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/powx-n/

#c++
star

Sat Apr 08 2023 07:09:49 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/

#c++
star

Sat Apr 08 2023 06:42:34 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/first-bad-version/

#c++
star

Sat Apr 08 2023 06:41:17 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-peak-element/

#c++
star

Thu Apr 06 2023 03:27:28 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/guess-number-higher-or-lower/

#c++
star

Thu Apr 06 2023 03:01:48 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/sqrtx/

#c++
star

Tue Apr 04 2023 23:51:10 GMT+0000 (Coordinated Universal Time)

#opengl #c++
star

Mon Apr 03 2023 18:28:01 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/boats-to-save-people/

#c++
star

Mon Apr 03 2023 14:01:03 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-pivot-index/

#c++
star

Sun Apr 02 2023 05:45:48 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/peak-index-in-a-mountain-array/

#c++
star

Sun Apr 02 2023 04:04:56 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/

#c++
star

Sat Apr 01 2023 21:52:05 GMT+0000 (Coordinated Universal Time)

#opengl #c++
star

Sat Apr 01 2023 19:27:55 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/@CodeHelp

#c++
star

Fri Mar 31 2023 19:37:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Mar 31 2023 19:03:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Mar 22 2023 06:42:39 GMT+0000 (Coordinated Universal Time) https://leetcode.com/contest/weekly-contest-301/problems/minimum-amount-of-time-to-fill-cups/

#c++
star

Tue Mar 21 2023 13:22:54 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/codestudio/problems/rat-in-a-maze_1215030?leftPanelTab=0

#c++
star

Mon Mar 20 2023 20:13:44 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/min-cost-climbing-stairs/

#c++
star

Mon Mar 20 2023 18:50:55 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/fibonacci-number/

#c++
star

Sun Mar 19 2023 17:53:23 GMT+0000 (Coordinated Universal Time) https://codeforces.com/contest/1807/problem/D

#c++
star

Sun Mar 19 2023 13:52:13 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/top-k-frequent-elements/

#c++
star

Sun Mar 19 2023 13:39:41 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/k-closest-points-to-origin/

#c++
star

Sun Mar 19 2023 09:43:36 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/number-of-provinces/

#c++
star

Sun Mar 19 2023 08:02:15 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/keys-and-rooms/

#c++
star

Sun Mar 19 2023 07:52:45 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes/

#c++
star

Sun Mar 19 2023 07:17:52 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/all-paths-from-source-to-target/

#c++
star

Sun Mar 19 2023 06:20:48 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-the-town-judge/

#c++
star

Sat Mar 18 2023 17:10:34 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-if-path-exists-in-graph/

#c++
star

Sat Mar 18 2023 15:13:58 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-center-of-star-graph/

#c++
star

Fri Mar 17 2023 16:41:33 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/codestudio/problems/dfs-traversal_630462?leftPanelTab=0

#c++
star

Fri Mar 17 2023 14:11:38 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/codestudio/problems/bfs-in-graph_973002

#c++
star

Fri Mar 17 2023 07:34:27 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/print-adjacency-list-1587115620/1

#c++
star

Thu Mar 16 2023 23:21:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Mar 16 2023 14:44:12 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/codestudio/problems/create-a-graph-and-print-it_1214551?leftPanelTab=0

#c++
star

Thu Mar 16 2023 12:08:03 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/

#c++
star

Thu Mar 16 2023 11:41:32 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/kth-smallest-element-in-a-bst/

#c++
star

Thu Mar 16 2023 10:01:05 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/validate-binary-search-tree/

#c++
star

Thu Mar 16 2023 02:50:50 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/

#c++
star

Wed Mar 15 2023 19:52:28 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/diameter-of-binary-tree/

#c++
star

Wed Mar 15 2023 12:15:06 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/path-sum-ii/

#c++
star

Wed Mar 15 2023 11:32:08 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/path-sum/

#c++
star

Tue Mar 14 2023 15:26:01 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/

#c++
star

Tue Mar 14 2023 12:55:01 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/binary-tree-level-order-traversal-ii/

#c++
star

Tue Mar 14 2023 12:44:01 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/

#c++
star

Tue Mar 14 2023 12:21:00 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/binary-tree-level-order-traversal/

#c++
star

Tue Mar 14 2023 00:39:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Mar 13 2023 04:38:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 11 2023 18:05:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 11 2023 16:05:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 11 2023 15:34:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 11 2023 15:25:28 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 11 2023 15:19:40 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 11 2023 14:19:17 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 11 2023 09:21:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 11 2023 06:59:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Mar 10 2023 07:46:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Mar 10 2023 07:28:02 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Mar 09 2023 05:08:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Mar 08 2023 05:50:17 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 17:07:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 16:30:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 15:57:53 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 15:32:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 15:22:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 15:11:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 13:52:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 09:23:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 08:40:22 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 08:04:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 07 2023 07:53:14 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Mar 06 2023 08:33:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Mar 05 2023 20:00:23 GMT+0000 (Coordinated Universal Time) https://www.pbinfo.ro/probleme/3978/sabc

#c++
star

Sun Mar 05 2023 17:37:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Mar 05 2023 15:35:04 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Mar 05 2023 10:28:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 04 2023 10:53:56 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Mar 04 2023 10:49:20 GMT+0000 (Coordinated Universal Time) https://youtu.be/KSsk8AhdOZA

#c++
star

Sat Mar 04 2023 06:25:48 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/diameter-of-binary-tree/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Fri Mar 03 2023 18:44:10 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/count-leaves-in-binary-tree/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Fri Mar 03 2023 14:01:20 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=5NiXlPrLslg&list=PLDzeHZWIZsTo87y1ytEAqp7wYlEP3nner

#c++
star

Thu Mar 02 2023 11:35:40 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/power-of-two/

#c++
star

Thu Mar 02 2023 11:31:45 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/power-of-four/

#c++
star

Tue Feb 28 2023 18:51:46 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/minimum-size-subarray-sum/

#c++
star

Tue Feb 28 2023 05:04:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Feb 27 2023 13:46:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Feb 27 2023 13:31:40 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Feb 27 2023 13:14:04 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Feb 25 2023 21:46:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Feb 24 2023 12:20:11 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced/

#c++
star

Thu Feb 23 2023 18:42:53 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients/

#c++
star

Thu Feb 23 2023 14:19:50 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/assign-cookies/

#c++
star

Thu Feb 23 2023 13:37:47 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/

#c++
star

Thu Feb 23 2023 11:21:41 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/jump-game-ii/

#c++
star

Thu Feb 23 2023 08:47:28 GMT+0000 (Coordinated Universal Time) https://www.pbinfo.ro/probleme/469/interval2

#c++
star

Thu Feb 23 2023 08:13:00 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/jump-game/

#c++
star

Thu Feb 23 2023 04:15:09 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/gas-station/

#c++
star

Mon Feb 20 2023 19:14:08 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/merge-intervals/

#c++
star

Fri Feb 17 2023 10:17:52 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/next-larger-element-1587115620/1

#c++
star

Fri Feb 17 2023 09:48:31 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/parenthesis-checker2744/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Fri Feb 17 2023 08:55:05 GMT+0000 (Coordinated Universal Time) https://takeuforward.org/data-structure/implement-stack-using-array/

#c++
star

Fri Feb 17 2023 08:41:14 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/implement-a-stack-using-single-queue/

#c++
star

Fri Feb 17 2023 07:45:23 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/online-stock-span/

#c++
star

Wed Feb 15 2023 16:18:59 GMT+0000 (Coordinated Universal Time) https://www.pbinfo.ro/probleme/173/medie1

#c++
star

Mon Feb 13 2023 12:23:20 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/remove-k-digits/

#c++
star

Mon Feb 13 2023 07:52:56 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/trapping-rain-water/

#c++
star

Sun Feb 12 2023 06:09:31 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/rotate-list/

#c++
star

Sat Feb 11 2023 14:34:32 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/add-two-numbers/

#c++
star

Sat Feb 11 2023 11:58:50 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/merge-k-sorted-lists/

#c++
star

Fri Feb 10 2023 08:30:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Feb 10 2023 08:11:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Feb 10 2023 07:57:13 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Feb 10 2023 07:12:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Feb 10 2023 06:57:04 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Feb 09 2023 16:11:35 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jan 29 2023 07:42:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jan 29 2023 07:18:29 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/subsets/submissions/

#c++
star

Sun Jan 29 2023 06:19:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jan 28 2023 13:56:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jan 28 2023 11:21:09 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jan 21 2023 16:01:20 GMT+0000 (Coordinated Universal Time) https://codeforces.com/contest/1777/problem/B

#c++
star

Fri Jan 20 2023 17:35:27 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/check-if-linked-list-is-pallindrome/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Sun Jan 15 2023 22:01:39 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/codestudio/problems/count-ways-to-reach-the-n-th-stairs_798650

#c++
star

Sun Jan 15 2023 22:00:03 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=zg8Y1oE4qYQ&list=PLDzeHZWIZsTqBmRGnsCOGNDG5FY0G04Td&index=2

#c++
star

Sat Jan 14 2023 06:14:04 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/problems/SC31?tab=statement

#c++
star

Fri Jan 13 2023 11:45:26 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/problems/ANDOR?tab=statement

#c++
star

Fri Jan 13 2023 09:00:55 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/problems/CENS20D

#c++
star

Fri Jan 13 2023 07:09:04 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/problems/CIELRCPT?tab=statement

#c++
star

Thu Jan 12 2023 06:38:05 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/problems/APPENDOR?tab=submissions

#c++
star

Fri Jan 06 2023 13:07:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Jan 03 2023 05:41:44 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/m4-code challenges - solution/m4-t7-e4.cpp

#c++
star

Tue Jan 03 2023 05:40:47 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/t7-file-handling/read-from-file.cpp

#c++
star

Tue Jan 03 2023 05:16:49 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/t7-file-handling/create-write-file.cpp

#c++
star

Tue Jan 03 2023 05:00:07 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/m4-code challenges - solution/m4-t6-e5.cpp

#c++
star

Tue Jan 03 2023 02:50:10 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/m4-code challenges - solution/m4-t5-e3.cpp

#c++
star

Tue Jan 03 2023 02:39:07 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/t5-exception-handling/handling-exception.cpp

#c++
star

Tue Jan 03 2023 01:30:20 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/t4-preprocessor-directives/macro.cpp

#c++
star

Tue Jan 03 2023 01:13:23 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/t3-standard-libraries/vector-library.cpp

#c++
star

Sun Jan 01 2023 07:02:56 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/t3-standard-libraries/math-library.cpp

#c++
star

Sun Jan 01 2023 06:40:15 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/t3-standard-libraries/exploring-standard-libraries.cpp

#c++
star

Sun Jan 01 2023 05:50:30 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m4-diving-into-cpp-programming/t2-namespaces/implementing-namespace.cpp

#c++
star

Sun Jan 01 2023 02:06:34 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t10-friend-class-and-friend-function/friend-function.cpp

#c++
star

Sun Jan 01 2023 01:47:43 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t10-friend-class-and-friend-function/friend-class.cpp

#c++
star

Sun Jan 01 2023 01:11:33 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/m3-code challenges - solution/m3-t9-e3.cpp

#c++
star

Sun Jan 01 2023 00:48:24 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t9-abstract-class/introduction-implementation.cpp

#c++
star

Sat Dec 31 2022 16:57:11 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t8-polymorphism/virtual-function.cpp

#c++
star

Sat Dec 31 2022 16:35:47 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t8-polymorphism/function-overriding.cpp

#c++
star

Sat Dec 31 2022 14:46:02 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/m3-code challenges - solution/m3-t7-e4.cpp

#c++
star

Sat Dec 31 2022 14:11:37 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t7-access-specifiers/protected-access-specifier.cpp

#c++
star

Sat Dec 31 2022 13:41:06 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t7-access-specifiers/private-public-access-specifiers.cpp

#c++
star

Sat Dec 31 2022 12:35:04 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t6-inheritance/implementing-inheritance.cpp

#c++
star

Sat Dec 31 2022 06:15:43 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t5-constructors-and-destructors/destructor.cpp

#c++
star

Sat Dec 31 2022 05:54:00 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t5-constructors-and-destructors/copy-constructor.cpp

#c++
star

Sat Dec 31 2022 05:19:47 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t5-constructors-and-destructors/parameterized-constructor.cpp

#c++
star

Sat Dec 31 2022 04:54:25 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t5-constructors-and-destructors/introduction-constructor.cpp

#c++
star

Wed Dec 28 2022 09:57:15 GMT+0000 (Coordinated Universal Time) https://codeforces.com/contest/1736/problem/C2

#c++
star

Wed Dec 28 2022 04:05:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 25 2022 18:29:06 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Sun Dec 25 2022 02:17:38 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/m3-code challenges - solution/m3-t4-e5.cpp

#c++
star

Sun Dec 25 2022 01:45:14 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t4-class-and-object/defining-methods.cpp

#c++
star

Sun Dec 25 2022 01:14:15 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t4-class-and-object/creating-objects.cpp

#c++
star

Sun Dec 25 2022 00:49:49 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t3-migrating-from-c-to-cpp/function-overloading.cpp

#c++
star

Sun Dec 25 2022 00:43:23 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t3-migrating-from-c-to-cpp/default-parameters.cpp

#c++
star

Sun Dec 25 2022 00:34:21 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/t3-migrating-from-c-to-cpp/bool-data-type.cpp

#c++
star

Sat Dec 24 2022 07:29:03 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/print-reverse-of-a-linked-list-without-actually-reversing/

#c++
star

Sat Dec 24 2022 07:17:29 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/reverse-a-linked-list/1

#c++
star

Sat Dec 24 2022 05:28:41 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/m3-code challenges - solution/m3-t3-e4.cpp

#c++
star

Sat Dec 24 2022 05:08:58 GMT+0000 (Coordinated Universal Time) https://github.com/Internshala-Online-Trainings/programming-with-c-and-cpp-v2/blob/master/m3-oops-fundamentals-using-cpp/m3-code challenges - solution/m3-t3-e2.cpp

#c++
star

Wed Dec 21 2022 19:18:53 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 18 2022 06:20:46 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/daily-temperatures/description/

#c++
star

Thu Dec 15 2022 22:08:09 GMT+0000 (Coordinated Universal Time) https://chat.openai.com/chat

#c++
star

Fri Dec 09 2022 11:29:07 GMT+0000 (Coordinated Universal Time) https://chat.openai.com/chat

#c++
star

Fri Dec 09 2022 11:27:41 GMT+0000 (Coordinated Universal Time) https://chat.openai.com/chat

#c++
star

Fri Dec 09 2022 00:56:49 GMT+0000 (Coordinated Universal Time) https://chat.openai.com/chat

#c++
star

Fri Dec 09 2022 00:48:24 GMT+0000 (Coordinated Universal Time) https://chat.openai.com/chat

#c++
star

Thu Dec 08 2022 23:41:57 GMT+0000 (Coordinated Universal Time) https://chat.openai.com/chat

#c++
star

Sat Dec 03 2022 13:55:28 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Nov 26 2022 22:54:16 GMT+0000 (Coordinated Universal Time) https://www.iubenda.com/en/dashboard

#c++ #c#
star

Thu Nov 24 2022 00:36:50 GMT+0000 (Coordinated Universal Time) https://blog.csdn.net/zlqqhs/article/details/16898251

#c++
star

Tue Nov 22 2022 11:39:18 GMT+0000 (Coordinated Universal Time) https://www.hivelance.com/blockchain-forking

#b2b #c++ #css #react.js #javascript #mongoshell #mysql #crypto #nft #blockchainfork development
star

Tue Nov 22 2022 11:38:10 GMT+0000 (Coordinated Universal Time) https://www.hivelance.com/nft-token-development

#b2b #c++ #css #react.js #javascript #mongoshell #mysql #crypto #nft #nfttoken
star

Tue Nov 22 2022 11:36:30 GMT+0000 (Coordinated Universal Time) https://www.hivelance.com/erc20-token-development

#erc20 #b2b #c++ #css #react.js #javascript #mongoshell #mysql #crypto
star

Fri Nov 18 2022 17:37:59 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/word-break/

#c++ #trienode
star

Sat Nov 12 2022 16:48:44 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/NOV221D/problems/SPBALL

#c++
star

Sat Nov 12 2022 10:28:26 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/print-diagonally4331/1

#c++
star

Wed Nov 09 2022 13:20:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Nov 08 2022 18:19:38 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/longest-common-prefix/

#c++
star

Tue Nov 08 2022 16:17:11 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/roman-to-integer/

#c++
star

Tue Nov 08 2022 05:54:38 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/boolean-matrix-problem-1587115620/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Tue Nov 08 2022 03:34:36 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/spirally-traversing-a-matrix-1587115621/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Mon Nov 07 2022 17:17:12 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/search-in-a-matrix-1587115621/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Mon Nov 07 2022 05:15:19 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/sorting-elements-of-an-array-by-frequency/0

#c++
star

Sun Nov 06 2022 06:31:19 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/shuffle-a-given-array-using-fisher-yates-shuffle-algorithm/

#c++
star

Fri Nov 04 2022 13:00:04 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/equilibrium-point-1587115620/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Wed Nov 02 2022 09:12:02 GMT+0000 (Coordinated Universal Time)

#c++ #make #cmake
star

Mon Oct 31 2022 01:32:36 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Oct 29 2022 17:33:58 GMT+0000 (Coordinated Universal Time) https://leetcode.com/contest/biweekly-contest-90/problems/words-within-two-edits-of-dictionary/

#c++
star

Sat Oct 29 2022 16:18:33 GMT+0000 (Coordinated Universal Time) https://leetcode.com/contest/biweekly-contest-90/problems/odd-string-difference/

#c++
star

Fri Oct 28 2022 14:01:09 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/subarray-with-0-sum-1587115621/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++ #morgan
star

Fri Oct 28 2022 10:57:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Oct 28 2022 03:23:34 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/sorted-subsequence-of-size-3/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Wed Oct 26 2022 08:40:56 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Oct 26 2022 07:58:35 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Oct 26 2022 07:46:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Oct 26 2022 07:43:34 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Oct 20 2022 13:07:05 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/count-equal-and-divisible-pairs-in-an-array/

#c++
star

Thu Oct 20 2022 12:48:43 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/flipping-an-image/

#c++
star

Thu Oct 20 2022 09:56:13 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/count-good-triplets/

#c++
star

Tue Oct 18 2022 17:23:48 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/sorted-subsequence-of-size-3/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article

#c++
star

Wed Oct 12 2022 09:52:24 GMT+0000 (Coordinated Universal Time) http://www.sr2jr.com/textbook-solutions/computer-science/40501005/absolute-cpp-arrays

#c++
star

Mon Oct 10 2022 17:29:48 GMT+0000 (Coordinated Universal Time)

#frequency #string_to_int_array #int_to_string_array #vector #c++
star

Mon Oct 10 2022 02:34:54 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/count-pairs-in-array-divisible-by-k/1?page=1&company[]=PayPal&sortBy=submissions

#c++
star

Sun Oct 09 2022 18:39:05 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/lowest-common-ancestor-in-a-binary-tree/1?page=1&company[]=PayPal&sortBy=submissions

#c++
star

Sun Oct 09 2022 17:56:31 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/intersection-of-two-arrays2404/1?page=1&company[]=PayPal&sortBy=submissions

#c++
star

Sun Oct 09 2022 05:53:33 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/number-of-arithmetic-triplets/

#c++
star

Sun Oct 09 2022 05:35:50 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/largest-local-values-in-a-matrix/

#c++
star

Sat Oct 08 2022 19:36:10 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/reverse-prefix-of-word/

#c++
star

Sat Oct 08 2022 19:17:09 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-first-palindromic-string-in-the-array/

#c++
star

Sat Oct 08 2022 18:59:50 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/reverse-words-in-a-given-string5459/1

#c++
star

Sat Oct 08 2022 17:00:45 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/replace-all-digits-with-characters/

#c++
star

Sat Oct 08 2022 16:42:21 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/

#c++
star

Sat Oct 08 2022 15:33:48 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/remove-outermost-parentheses/

#c++
star

Sat Oct 08 2022 13:48:29 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/check-if-the-sentence-is-pangram/

#c++
star

Sat Oct 08 2022 13:38:56 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/reverse-words-in-a-string-iii/

#c++
star

Sat Oct 08 2022 11:29:37 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/rings-and-rods/

#c++
star

Sat Oct 08 2022 08:30:04 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/count-the-number-of-consistent-strings/

#c++
star

Sat Oct 08 2022 07:52:37 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/to-lower-case/

#c++
star

Sat Oct 08 2022 07:41:15 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/unique-morse-code-words/

#c++
star

Sat Oct 08 2022 06:49:17 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/sort-the-people/

#c++
star

Sat Oct 08 2022 04:45:10 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/count-items-matching-a-rule/

#c++
star

Fri Oct 07 2022 20:40:02 GMT+0000 (Coordinated Universal Time) https://www.onlinegdb.com/online_c++_compiler

#c++
star

Thu Oct 06 2022 19:06:05 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/

#c++
star

Thu Oct 06 2022 15:49:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Oct 05 2022 17:23:09 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Oct 05 2022 09:48:07 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/228d0aa9f26db93ee5b2cb3583dbd4b197447e16/1

#c++
star

Tue Oct 04 2022 20:32:17 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/shuffle-string/

#c++
star

Tue Oct 04 2022 18:55:33 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/decode-xored-array/

#c++
star

Tue Oct 04 2022 18:04:00 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/maximum-number-of-words-found-in-sentences/

#c++
star

Sun Oct 02 2022 18:52:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Oct 01 2022 13:35:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 30 2022 03:32:08 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/implement-atoi/1

#c++
star

Thu Sep 29 2022 12:27:44 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/

#c++
star

Thu Sep 29 2022 09:37:51 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/an-in-place-algorithm-for-string-transformation/

#c++
star

Thu Sep 29 2022 09:28:43 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/print-all-the-duplicates-in-the-input-string/

#c++
star

Wed Sep 28 2022 20:42:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Sep 28 2022 04:19:09 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Sep 26 2022 15:58:12 GMT+0000 (Coordinated Universal Time) https://discuss.codechef.com/t/how-to-take-input-of-an-array-in-1-line-in-c/2810

#c++ #input
star

Sat Sep 24 2022 14:16:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 23 2022 15:17:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 23 2022 11:11:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 23 2022 03:14:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 23 2022 02:55:07 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 20 2022 16:59:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 20 2022 11:11:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Sep 19 2022 15:48:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 18 2022 13:15:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 18 2022 12:11:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 18 2022 09:10:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 18 2022 08:36:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 18 2022 08:31:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 18 2022 08:21:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 16:41:22 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 12:28:41 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 12:22:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 12:15:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 12:05:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 11:59:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 11:56:04 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 11:39:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 08:16:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 08:11:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 08:08:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 08:04:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 07:57:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 07:54:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 07:31:41 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 07:24:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 07:13:16 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 06:55:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 06:37:34 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 06:29:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 05:52:47 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 05:33:14 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Sep 17 2022 03:55:35 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 15:24:30 GMT+0000 (Coordinated Universal Time) https://www.w3schools.com/cpp/trycpp.asp?filename

#undefined #c++
star

Fri Sep 16 2022 09:30:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 09:24:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 09:14:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 09:09:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 09:06:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 09:03:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:59:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:54:32 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:50:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:46:35 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:44:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:41:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:34:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:30:40 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:29:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:27:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:24:50 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:23:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:19:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 08:15:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 07:04:22 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 07:02:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 06:59:02 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 06:39:47 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 06:21:07 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 06:14:16 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 05:52:44 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 04:06:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 02:37:07 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 02:16:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 01:37:53 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 01:23:59 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 01:22:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 01:16:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 01:15:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 01:15:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 16 2022 01:04:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Sep 14 2022 17:03:53 GMT+0000 (Coordinated Universal Time) https://www.w3schools.com/cpp/trycpp.asp?filename

#undefined #c++
star

Wed Sep 14 2022 16:55:17 GMT+0000 (Coordinated Universal Time) https://www.w3schools.com/cpp/trycpp.asp?filename

#undefined #c++
star

Tue Sep 13 2022 16:31:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Sep 12 2022 16:50:34 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/subarray-with-given-sum-1587115621/1?page

#c++
star

Sun Sep 11 2022 08:46:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 06 2022 16:54:56 GMT+0000 (Coordinated Universal Time)

#c++ #number #number_theory #modulo
star

Sat Sep 03 2022 20:25:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 02 2022 13:04:44 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/modulo-operator-in-c-cpp-with-examples/

#c++ #number #number_theory #modulo
star

Fri Sep 02 2022 09:47:02 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

#c++
star

Mon Aug 29 2022 08:35:01 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Aug 29 2022 08:27:22 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Aug 18 2022 08:08:24 GMT+0000 (Coordinated Universal Time)

#c++ #data_types
star

Thu Aug 18 2022 08:07:34 GMT+0000 (Coordinated Universal Time)

#c++ #data_types
star

Thu Aug 18 2022 07:58:56 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/bit-tricks-competitive-programming/

#c++ #data_types
star

Thu Aug 18 2022 07:27:48 GMT+0000 (Coordinated Universal Time)

#c++ #data_types
star

Thu Aug 18 2022 07:22:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Aug 17 2022 20:45:01 GMT+0000 (Coordinated Universal Time) https://cses.fi/problemset/task/1085

#c++ #data_types
star

Wed Aug 17 2022 20:40:17 GMT+0000 (Coordinated Universal Time)

#c++ #data_types
star

Wed Aug 17 2022 20:36:19 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/implementing-upper_bound-and-lower_bound-in-c/

#c++ #math #binary_search #two_pointer
star

Wed Aug 17 2022 20:33:33 GMT+0000 (Coordinated Universal Time)

#c++ #math
star

Wed Aug 17 2022 20:31:42 GMT+0000 (Coordinated Universal Time)

#c++ #stls #built-in_function
star

Wed Aug 17 2022 20:29:54 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/c-magicians-stl-algorithms/

#c++ #stls #built-in_function
star

Wed Aug 17 2022 20:23:19 GMT+0000 (Coordinated Universal Time)

#c++ #rangequiries
star

Wed Aug 17 2022 20:15:27 GMT+0000 (Coordinated Universal Time)

#c++ #rangequiries
star

Wed Aug 03 2022 17:04:50 GMT+0000 (Coordinated Universal Time)

#c++ #algorithm #dsa #sorting #insertionsort #insertion
star

Wed Aug 03 2022 11:54:49 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Aug 03 2022 06:39:13 GMT+0000 (Coordinated Universal Time) https://leetcode.com/contest/weekly-contest-303/problems/equal-row-and-column-pairs/

#c++
star

Mon Aug 01 2022 13:01:59 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/4sum/

#c++
star

Sun Jul 31 2022 12:29:38 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/kth-largest-element-in-an-array/submissions/

#c++
star

Sun Jul 31 2022 12:15:43 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/kth-smallest-element5635/0

#c++
star

Sat Jul 30 2022 09:31:05 GMT+0000 (Coordinated Universal Time) https://www.codingninjas.com/codestudio/guided-paths/data-structures-algorithms

#kadene #c++
star

Fri Jul 29 2022 09:45:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jul 21 2022 12:16:00 GMT+0000 (Coordinated Universal Time)

#c++ #algorithm #dsa #sorting #insertionsort #insertion
star

Thu Jul 21 2022 12:13:32 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jul 21 2022 12:11:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jul 20 2022 09:51:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jul 20 2022 07:24:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jul 15 2022 21:58:59 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jul 15 2022 21:03:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jul 13 2022 11:01:38 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/longest-consecutive-sequence/

#c++
star

Sun Jul 10 2022 12:02:21 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/determine-if-two-trees-are-identical/1/#

#c++
star

Sun Jul 10 2022 10:07:22 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/diameter-of-binary-tree/1/

#c++
star

Sun Jul 10 2022 07:34:22 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/check-for-balanced-tree/1/

#c++
star

Sat Jul 09 2022 18:38:31 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/height-of-binary-tree/1/

#c++
star

Sat Jul 09 2022 05:51:19 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/write-a-c-program-to-delete-a-tree/

#c++
star

Sat Jul 02 2022 17:45:31 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jul 02 2022 17:36:40 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jul 02 2022 06:54:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jul 02 2022 06:38:47 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jul 02 2022 04:55:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jul 01 2022 18:01:44 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jul 01 2022 16:28:27 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/ide

#c++
star

Wed Jun 29 2022 11:03:36 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/nth-node-from-end-of-linked-list/1/#

#c++
star

Tue Jun 28 2022 13:55:34 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/reinterpret_cast-in-c-type-casting-operators/

#c++
star

Sun Jun 26 2022 18:29:58 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/triplet-sum-in-array-1587115621/1

#c++
star

Sun Jun 26 2022 18:22:23 GMT+0000 (Coordinated Universal Time) https://www.interviewbit.com/problems/3-sum-zero/

#c++
star

Sun Jun 26 2022 13:10:16 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 26 2022 07:06:41 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 26 2022 06:11:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jun 25 2022 10:13:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 24 2022 05:43:08 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/excel-sheet-column-title/

#c++
star

Thu Jun 23 2022 18:58:10 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/excel-sheet-column-number/

#c++
star

Thu Jun 23 2022 18:17:34 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/palindrome-number/

#c++
star

Thu Jun 23 2022 17:06:49 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/move-zeroes/

#c++
star

Tue Jun 21 2022 18:01:32 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/trapping-rain-water/

#c++
star

Tue Jun 21 2022 16:19:17 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=St0Jf_VmG_g&list=PL_z_8CaSLPWdeOezg68SKkeLN4-T_jNHd&index=8

#c++
star

Tue Jun 21 2022 14:13:52 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=J2X70jj_I1o&list=PL_z_8CaSLPWdeOezg68SKkeLN4-T_jNHd&index=7

#c++
star

Tue Jun 21 2022 13:11:29 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=p9T-fE1g1pU&list=PL_z_8CaSLPWdeOezg68SKkeLN4-T_jNHd&index=6

#c++
star

Fri Jun 17 2022 11:42:33 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=nc1AYFyvOR4&list=PL_z_8CaSLPWdeOezg68SKkeLN4-T_jNHd&index=5

#c++
star

Fri Jun 17 2022 09:28:03 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=85LWui3FlVk&list=PL_z_8CaSLPWdeOezg68SKkeLN4-T_jNHd&index=4

#c++
star

Fri Jun 17 2022 09:02:29 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=T5s96ynzArg&list=PL_z_8CaSLPWdeOezg68SKkeLN4-T_jNHd&index=3

#c++
star

Thu Jun 16 2022 19:44:44 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/delete-node-in-a-linked-list/submissions/

#c++
star

Thu Jun 16 2022 18:51:22 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/middle-of-the-linked-list/

#c++
star

Thu Jun 16 2022 12:18:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 16 2022 12:17:22 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 16 2022 08:52:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Jun 13 2022 12:47:47 GMT+0000 (Coordinated Universal Time) https://favtutor.com/blogs/find-peak-element

#java #c++
star

Mon Jun 13 2022 10:21:10 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/subset-sums2234/1#

#c++
star

Sun Jun 12 2022 17:15:56 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 09 2022 07:45:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Jun 09 2022 06:57:22 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/given-an-array-a-and-a-number-x-check-for-pair-in-a-with-sum-as-x/

#c++
star

Wed Jun 08 2022 20:54:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 08 2022 20:48:28 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 08 2022 20:46:02 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 08 2022 20:35:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 08 2022 20:24:04 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 08 2022 20:12:36 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 08 2022 08:48:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Jun 07 2022 17:54:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Jun 06 2022 07:41:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 05 2022 21:57:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 05 2022 20:35:30 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 05 2022 20:07:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jun 05 2022 06:42:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jun 04 2022 18:58:25 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/segregate-even-and-odd-numbers4629/1/

#c++
star

Sat Jun 04 2022 18:25:15 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/segregate-even-and-odd-numbers4629/1/

#c++
star

Sat Jun 04 2022 10:10:20 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/linked-list-set-2-inserting-a-node/

#c++
star

Sat Jun 04 2022 06:46:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jun 03 2022 19:16:05 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/find-minimum-and-maximum-element-in-an-array4428/1/#

#c++
star

Fri Jun 03 2022 19:10:57 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/find-minimum-and-maximum-element-in-an-array4428/1/

#c++
star

Fri Jun 03 2022 18:36:45 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/reverse-a-string/1#

#c++
star

Thu Jun 02 2022 19:07:32 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/finding-the-numbers0215/1/

#c++
star

Thu Jun 02 2022 15:56:34 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/two-numbers-with-odd-occurrences5846/1/

#c++
star

Tue May 10 2022 13:39:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 10 2022 13:36:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue May 10 2022 13:35:34 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun May 08 2022 04:44:34 GMT+0000 (Coordinated Universal Time)

#c++ #oop #date
star

Sat May 07 2022 12:46:49 GMT+0000 (Coordinated Universal Time)

#c++ #list #oop
star

Sat May 07 2022 05:20:37 GMT+0000 (Coordinated Universal Time)

#c++ #matrix
star

Thu Apr 28 2022 21:44:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:43:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:42:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:42:08 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:41:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:40:45 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:38:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:37:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:36:37 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:35:40 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:34:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:33:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:33:04 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Apr 28 2022 21:32:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 18:47:52 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 13:28:59 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 13:22:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 13:21:44 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 13:20:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:51:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:28:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:27:59 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:27:14 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:26:29 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:25:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:25:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:24:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:23:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:22:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:21:38 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:20:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 12:18:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 11:54:26 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 11:44:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 11:27:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 11:24:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 10:21:24 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 10:07:43 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 10:03:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 10:00:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 09:58:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 09:56:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Apr 26 2022 09:39:16 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Apr 18 2022 01:05:41 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Apr 16 2022 15:57:56 GMT+0000 (Coordinated Universal Time) https://forum.arduino.cc/t/using-millis-for-timing-a-beginners-guide/483573

#c++
star

Sat Apr 16 2022 15:57:04 GMT+0000 (Coordinated Universal Time) https://dzone.com/articles/arduino-using-millis-instead-of-delay

#c++
star

Sat Apr 16 2022 15:56:44 GMT+0000 (Coordinated Universal Time) https://dzone.com/articles/arduino-using-millis-instead-of-delay

#c++
star

Mon Apr 11 2022 21:41:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Apr 11 2022 21:34:40 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Apr 11 2022 18:56:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Mar 24 2022 11:59:19 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/bitwise-operators-in-c-cpp/

#c++
star

Wed Mar 23 2022 18:11:21 GMT+0000 (Coordinated Universal Time) https://gist.github.com/atkvishnu/3dcdc9fa45ee5e0c6c463d820c13b6b9

#c++
star

Mon Mar 21 2022 10:14:52 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/22984956/tellg-function-give-wrong-size-of-file

#c++
star

Wed Mar 16 2022 19:41:52 GMT+0000 (Coordinated Universal Time) https://www.learncpp.com/cpp-tutorial/pass-by-lvalue-reference/

#c++
star

Wed Mar 16 2022 19:38:07 GMT+0000 (Coordinated Universal Time) https://www.learncpp.com/cpp-tutorial/lvalue-references/

#c++
star

Wed Mar 16 2022 19:35:36 GMT+0000 (Coordinated Universal Time) https://www.learncpp.com/cpp-tutorial/lvalue-references/

#c++
star

Wed Mar 16 2022 19:35:13 GMT+0000 (Coordinated Universal Time) https://www.learncpp.com/cpp-tutorial/lvalue-references/

#c++
star

Wed Mar 16 2022 19:24:38 GMT+0000 (Coordinated Universal Time) https://www.learncpp.com/cpp-tutorial/function-templates/

#c++
star

Wed Mar 16 2022 19:08:15 GMT+0000 (Coordinated Universal Time) https://www.learncpp.com/cpp-tutorial/stdcin-and-handling-invalid-input/

#c++
star

Fri Mar 11 2022 11:03:06 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 10:45:42 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 10:44:36 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 10:29:48 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 10:19:20 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 10:18:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Mar 11 2022 10:16:04 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 10:10:54 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 10:08:44 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 10:04:43 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 09:20:36 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 09:17:11 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 09:14:20 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 09:12:07 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 09:09:17 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 09:07:32 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 09:04:17 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 08:59:25 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Fri Mar 11 2022 08:57:21 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Thu Mar 10 2022 15:15:33 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Thu Mar 10 2022 14:51:14 GMT+0000 (Coordinated Universal Time) https://cppquiz.org/

#c++
star

Sun Mar 06 2022 22:35:30 GMT+0000 (Coordinated Universal Time) https://ayushshuklas.blogspot.com

#c++
star

Sat Mar 05 2022 07:11:12 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/dsa/binary-search

#c++
star

Fri Mar 04 2022 17:24:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Feb 17 2022 12:49:49 GMT+0000 (Coordinated Universal Time)

#c++ #c
star

Sat Feb 12 2022 03:34:41 GMT+0000 (Coordinated Universal Time)

#c++ #codeforces
star

Sun Jan 23 2022 04:44:32 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Jan 18 2022 03:26:32 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/5029840/convert-char-to-int-in-c-and-c

#c++
star

Thu Jan 13 2022 18:47:14 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Jan 11 2022 16:05:38 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/binary-search/

#c++
star

Sun Jan 09 2022 14:21:05 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/53da3dbb4a5168369a0000fe/train/cpp

#c++
star

Sun Jan 09 2022 14:09:41 GMT+0000 (Coordinated Universal Time) https://www.hackerrank.com/challenges/c-tutorial-basic-data-types/problem

#c++
star

Sun Jan 09 2022 14:04:55 GMT+0000 (Coordinated Universal Time) https://www.hackerrank.com/challenges/c-tutorial-pointer/problem?h_r=profile

#c++
star

Sun Jan 09 2022 11:48:11 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Jan 09 2022 09:49:36 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jan 08 2022 15:00:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Sat Jan 08 2022 09:14:50 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Dec 27 2021 06:01:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Dec 14 2021 11:27:30 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Dec 14 2021 11:17:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Dec 14 2021 08:21:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Dec 14 2021 07:55:04 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Dec 13 2021 11:06:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Dec 13 2021 09:35:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Dec 13 2021 09:30:14 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 12 2021 13:09:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 12 2021 08:16:59 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 12 2021 07:49:39 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 12 2021 07:45:54 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 10 2021 16:53:50 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 10 2021 16:12:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 10 2021 15:36:10 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 10 2021 11:38:23 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 10 2021 10:01:09 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 10 2021 07:19:07 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 10 2021 07:05:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 10 2021 04:09:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 09 2021 18:27:36 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 09 2021 17:22:41 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 09 2021 14:02:47 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 09 2021 09:27:14 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 09 2021 06:51:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Dec 09 2021 05:32:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Dec 08 2021 17:13:49 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Dec 08 2021 15:12:25 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Dec 03 2021 08:22:07 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-processing-an-unsorted-array

#c++
star

Thu Nov 18 2021 11:00:12 GMT+0000 (Coordinated Universal Time) https://favtutor.com/blogs/reverse-a-linked-list-cpp

#c++
star

Wed Nov 17 2021 07:53:08 GMT+0000 (Coordinated Universal Time) https://sgo.tomedu.ru/angular/school/studentdiary/

#java #c++
star

Mon Oct 25 2021 13:57:16 GMT+0000 (Coordinated Universal Time)

#c #c++
star

Mon Oct 25 2021 12:19:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Oct 10 2021 07:54:16 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Oct 07 2021 11:43:56 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/reshape-the-matrix/

#c++
star

Wed Oct 06 2021 08:57:16 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/best-time-to-buy-and-sell-stock/

#c++
star

Wed Oct 06 2021 08:11:28 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/intersection-of-two-arrays-ii/submissions/

#c++
star

Wed Oct 06 2021 07:45:46 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/

#c++
star

Wed Oct 06 2021 07:37:13 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/move-zeroes/

#c++
star

Tue Oct 05 2021 12:13:11 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/rotate-array/

#c++
star

Tue Oct 05 2021 11:18:54 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/squares-of-a-sorted-array/

#c++
star

Mon Oct 04 2021 12:09:28 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/contains-duplicate/

#c++
star

Mon Oct 04 2021 10:24:48 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/merge-sorted-array/

#c++
star

Mon Oct 04 2021 09:30:38 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/plus-one/

#c++
star

Mon Oct 04 2021 08:26:09 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/maximum-subarray/

#c++
star

Mon Oct 04 2021 08:06:18 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/search-insert-position/

#c++
star

Mon Oct 04 2021 07:37:20 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/remove-element/

#c++
star

Sat Oct 02 2021 18:08:51 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Sep 07 2021 09:04:19 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Sep 05 2021 18:21:30 GMT+0000 (Coordinated Universal Time)

#c #c++
star

Sun Sep 05 2021 18:20:03 GMT+0000 (Coordinated Universal Time)

#c #c++
star

Sun Sep 05 2021 18:12:07 GMT+0000 (Coordinated Universal Time)

#c #c++
star

Thu Sep 02 2021 08:48:00 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Sep 02 2021 07:14:28 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Sep 02 2021 06:44:36 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Aug 30 2021 07:18:58 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Aug 30 2021 01:00:16 GMT+0000 (Coordinated Universal Time)

#c #c++
star

Sat Aug 28 2021 16:20:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Aug 18 2021 18:16:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Aug 13 2021 04:11:57 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Aug 12 2021 09:38:38 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/palindrome-number/

#c++
star

Thu Aug 12 2021 08:50:25 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/reverse-integer/

#c++
star

Thu Aug 12 2021 08:48:54 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/two-sum/submissions/

#c++
star

Thu Jul 08 2021 07:53:58 GMT+0000 (Coordinated Universal Time) https://pastebin.com/YfYcJ5f1

#c++
star

Fri Jul 02 2021 18:33:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jul 02 2021 17:34:27 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Jul 02 2021 08:16:57 GMT+0000 (Coordinated Universal Time) https://leetcode.com/explore/challenge/card/july-leetcoding-challenge-2021/608/week-1-july-1st-july-7th/3800/

#c++
star

Wed Jun 23 2021 05:09:08 GMT+0000 (Coordinated Universal Time) https://www.codechef.com/submit/VOTERS

#c++
star

Tue Jun 22 2021 02:54:54 GMT+0000 (Coordinated Universal Time) https://github.com/imneonizer/How-to-find-if-an-image-is-bright-or-dark/

#python #c++
star

Fri Jun 18 2021 14:33:24 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/reverse-a-string-in-c-cpp-different-methods/

#c++
star

Wed Jun 02 2021 16:09:47 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 02 2021 11:56:03 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 02 2021 10:39:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Jun 02 2021 10:37:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed May 26 2021 22:05:48 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/5307169/what-is-the-meaning-of-a-c-wrapper-class

#c #c++ #wrapper
star

Wed May 26 2021 20:58:04 GMT+0000 (Coordinated Universal Time) https://www.c-plusplus.net/forum/topic/270976/was-ist-ein-wrapper

#c #c++ #wrapper
star

Sat May 08 2021 17:17:06 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon May 03 2021 16:22:37 GMT+0000 (Coordinated Universal Time)

#c++ #output #xcode #redirection
star

Mon May 03 2021 16:14:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Apr 28 2021 00:56:03 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/6264249/how-does-the-compilation-linking-process-work#:~:text=The%20compilation%20of%20a%20C%2B%2B%20program%20involves%20three%20steps%3A&text=Compilation%3A%20the%20compiler%20takes%20the,library%20or%20an%20executable%20file.

#c++
star

Tue Apr 20 2021 01:06:11 GMT+0000 (Coordinated Universal Time) https://gitlab.eecs.umich.edu/eecs281/wiki/-/wikis/xcode-file-redirection

#c++ #output #xcode #redirection
star

Sat Apr 17 2021 00:49:25 GMT+0000 (Coordinated Universal Time) https://www.udemy.com/course/learn-advanced-c-programming/learn/lecture/3688332?%24web_only=true&~channel=email&~stage=published&utm_medium=email&utm_campaign=email&utm_source=sendgrid.com&_branch_match_id=890253272865013170#questions/14628310/

#c++
star

Thu Apr 15 2021 19:48:48 GMT+0000 (Coordinated Universal Time) https://www.udemy.com/course/learn-advanced-c-programming/learn/lecture/3688274#questions/10258738

#c++
star

Thu Apr 15 2021 17:02:27 GMT+0000 (Coordinated Universal Time) https://www.udemy.com/course/learn-advanced-c-programming/learn/lecture/3688272#questions/14617278

#c++
star

Thu Apr 15 2021 16:53:13 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Apr 14 2021 17:38:00 GMT+0000 (Coordinated Universal Time) https://www.udemy.com/course/learn-advanced-c-programming/learn/lecture/3688272#questions/14612872/

#c++
star

Thu Apr 08 2021 21:39:39 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/10359702/c-filehandling-difference-between-iosapp-and-iosate#:~:text=ios%3A%3Aapp%20%22set%20the,file%20when%20you%20open%20it.&text=The%20ios%3A%3Aate%20option,to%20the%20end%20of%20file.

#c++
star

Fri Apr 02 2021 11:14:20 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 30 2021 13:35:34 GMT+0000 (Coordinated Universal Time)

#c++
star

Mon Mar 29 2021 15:48:43 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/11938979/what-exception-classes-are-in-the-standard-c-library

#c++
star

Wed Mar 17 2021 04:14:46 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Mar 17 2021 02:53:18 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Mar 17 2021 01:58:37 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Mar 17 2021 01:57:12 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Mar 10 2021 03:42:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Mar 09 2021 17:08:05 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Jan 26 2021 22:43:21 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Thu Jan 21 2021 20:17:57 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Wed Jan 20 2021 22:02:30 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Sat Jan 09 2021 02:24:44 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Fri Jan 08 2021 09:33:32 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Thu Jan 07 2021 06:42:04 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Wed Jan 06 2021 21:53:09 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Sat Jan 02 2021 17:54:04 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Dec 29 2020 11:21:13 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Mon Dec 28 2020 03:44:59 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Dec 20 2020 11:27:54 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/29995863/how-to-add-custom-code-snippets-in-vscode

#c++
star

Fri Dec 18 2020 02:16:44 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Fri Dec 11 2020 20:09:09 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Wed Dec 09 2020 03:00:16 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Thu Nov 26 2020 14:13:55 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Nov 25 2020 01:54:07 GMT+0000 (Coordinated Universal Time)

#c++
star

Sun Nov 15 2020 20:41:49 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Sun Nov 15 2020 04:08:15 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Sun Nov 15 2020 02:54:42 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Fri Nov 13 2020 03:52:42 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Nov 12 2020 14:28:30 GMT+0000 (Coordinated Universal Time)

#c++
star

Tue Nov 10 2020 22:42:18 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Tue Nov 10 2020 16:12:46 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Mon Nov 09 2020 07:53:26 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Mon Nov 09 2020 01:01:29 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Sun Nov 08 2020 23:35:48 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Sat Nov 07 2020 03:20:33 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/lambda-expression-in-c/

#c++
star

Fri Nov 06 2020 17:32:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Nov 06 2020 15:00:33 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Nov 06 2020 14:49:48 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Nov 06 2020 03:45:15 GMT+0000 (Coordinated Universal Time)

#c++
star

Thu Nov 05 2020 20:47:39 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Tue Oct 27 2020 02:55:57 GMT+0000 (Coordinated Universal Time) https://zerojudge.tw/ShowProblem?problemid

#c++
star

Sun Oct 25 2020 03:45:41 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Sat Oct 24 2020 17:58:24 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Sat Oct 24 2020 11:35:47 GMT+0000 (Coordinated Universal Time) http://cpp.sh/

#c++
star

Wed Oct 21 2020 08:25:33 GMT+0000 (Coordinated Universal Time) https://www.javatpoint.com/fibonacci-series-in-cpp

#c++ #fibonacci
star

Wed Oct 21 2020 07:59:21 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Oct 14 2020 22:19:09 GMT+0000 (Coordinated Universal Time)

#c++
star

Wed Oct 14 2020 18:44:50 GMT+0000 (Coordinated Universal Time)

#c++
star

Fri Sep 11 2020 14:28:11 GMT+0000 (Coordinated Universal Time) https://www.technical-recipes.com/2011/simple-binary-tree-implementation/

#c++
star

Thu Jul 16 2020 13:01:21 GMT+0000 (Coordinated Universal Time) https://github.com/an-tao/drogon

#c++ #web #rest
star

Wed Dec 25 2019 10:57:06 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/

#c++ #algorithms #interviewquestions #arrays

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension