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

void solve(string str, string output, int index, vector<string>& ans)
{
   //base case
   if(index >= str.length())
   {
      if(output.length()>0) ans.push_back(output);
      return;
   }
   //exclude
   solve(str, output, index+1, ans);
   
   //include
   char element = str[index];
   output.push_back(element);
   solve(str, output, index+1, ans);
}
vector<string> subsequences(string str)
{
   vector<string> ans;
   string output = "";
   int index = 0;
   solve(str, output, index, ans);
   return ans;
}
int main() {
	string s="abcd";
	vector<string> v=subsequences(s);
	for(int i=0;i<v.size();i++)
	{
	   cout<<v[i]<<" ";
	}
	return 0;
}
class Solution {
public:
    
    void solve(vector<int> nums, vector<int> output, int index, vector<vector<int>> &ans)
    {
        //base case
        if(index>=nums.size())
        {
            ans.push_back(output);
            return;
        }
        
        //eclude
        solve(nums, output, index+1, ans);
        
        //include
        int element = nums[index];
        output.push_back(element);
        solve(nums, output, index+1, ans);
    }
    vector<vector<int>> subsets(vector<int>& nums) {
        
        vector<vector<int>>ans;
        vector<int> output;
        int index=0;
        solve(nums,output,index,ans);
        return ans;
    }
};
#include <bits/stdc++.h>
using namespace std;

int partition(int arr[],int s,int e)
{
   int pivot=arr[s];
   int cnt=0;
   for(int i=s+1;i<=e;i++)
   {
      if(arr[i]<=pivot)
      {
         cnt++;
      }
   }
   
   //place pivot at right position
   int pivotindex = s+cnt;
   swap(arr[pivotindex],arr[s]);
   
   //left and right wala part sambhal lete sambhal
   int i=s, j=e;
   while(i < pivotindex && j > pivotindex)
   {
      while(arr[i]<pivot)
      {
         i++;
      }
      while(arr[j]>pivot)
      {
         j--;
      }
      if(i < pivotindex && j > pivotindex)
      {
         swap(arr[i++],arr[j--]);
      }
   }
   return pivotindex;
}
void quicksort(int arr[], int s,int e)
{
   //base case
   if(s>=e) return;
   
   //partition
   int p=partition(arr,s,e);
   //recursion
   //left part ko sort karo
   quicksort(arr,s,p-1);
   //right part ko sort karo
   quicksort(arr,p+1,e);
}


int main() {
	int a[8]={9,78,6,23,14,2,8,1};
	int n=8;
	quicksort(a,0,n-1);
	for(int i=0;i<n;i++)
	{
	   cout<<a[i]<<" ";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

void merge(int *arr, int s, int e)
{
   int mid = (s+e)/2;
   int len1=mid-s+1;
   int len2=e-mid;
   
   int *first = new int[len1];
   int *second=new int[len2];
   
   //copy value
   int mainArrayIndex = s;
   for(int i=0;i<len1;i++)
   {
      first[i]=arr[mainArrayIndex++];
   }
   mainArrayIndex=mid+1;
   for(int i=0;i<len2;i++)
   {
      second[i]=arr[mainArrayIndex++];
   }
   
   //merge 2 sorted arrays
   int index1=0;
   int index2=0;
   mainArrayIndex=s;
   
   while(index1<len1&&index2<len2)
   {
      if(first[index1]<second[index2])
      {
         arr[mainArrayIndex++]=first[index1++];
      }
      else 
      {
         arr[mainArrayIndex++]=second[index2++];
      }
   }
   while(index1<len1)
   {
      arr[mainArrayIndex++]=first[index1++];
   }
   while(index2<len2)
   {
      arr[mainArrayIndex++]=second[index2++];
   }
   delete []first;
   delete []second;
  
}
void mergesort(int *arr,int s,int e)
{
   //base case
   if(s>=e)
   {
      return;
   }
   
   int mid=(s+e)/2;
   //left part sort karna h
   mergesort(arr, s, mid);
   //right part sort karna right
   mergesort(arr, mid+1, e);
   
   //merge
   merge(arr,s,e);
   
}
int main() {
   
	int a[5]={5,6,1,4,3};
   int n=5;
   mergesort(a,0,n-1);
	for(int i=0;i<5;i++)
	{
	   cout<<a[i]<<" ";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

void bubblesrt(int a[],int n)
{
   if(n==0||n==1) return;
   for(int i=0;i<n-1;i++)
   {
      if(a[i]>a[i+1]) swap(a[i],a[i+1]);
   }
   bubblesrt(a,n-1);
}
int main() {
   
	int a[5]={5,6,1,4,3};
   bubblesrt(a,5);
	for(int i=0;i<5;i++)
	{
	   cout<<a[i]<<" ";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD= 1e9+7;
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	  ll fact=1;
	  ll n;
	  cin>>n;
	   for(ll i=1;i<=n;i++)
	   {    
      fact=(fact*i)%MOD;    
      }
      ll ans=(fact*n)%MOD;
      ll ans2=(ans*(n-1))%MOD;
	 cout<<ans2<<"\n"; 
	 
	}
	return 0;
}
class Solution{
  public:
    //Function to check whether the list is palindrome.
    bool isPalindrome(Node *head)
    {
        //Your code here
        stack<int> s;
        Node *t;
        t=head;
        while(t)
        {
            s.push(t->data);
            t=t->next;
        }
        t=head;
        while(t)
        {
            if(s.top()==t->data)
            {
                s.pop();
            }
            t=t->next;
        }
        if(s.empty()) return true;
        else return false;
        
    }
};
#include <bits/stdc++.h> 
int countDistinctWays(long long nStairs) {
    //  Write your code here.
    //Base case 
    if(nStairs<0) return 0;
    if(nStairs==0) return 1;
    int ans=countDistinctWays(nStairs-1) + countDistinctWays(nStairs-2);
    return ans;
}
//Factorial
#include <bits/stdc++.h>
using namespace std;

int fac(int n)
{
   //Base call and return must be there
   if(n==0) return 1;
   return n*fac(n-1);
}
int main() {
   int t;
   cin>>t;
   while(t--)
   {
      int n;
      cin>>n;
      int ans = fac(n);
      cout<<ans<<"\n";
   }
	return 0;
}

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

long long powerofto(long long n)
{
   if(n==0) return 1;
   return 2*powerofto(n-1);
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	     long long n;
	     cin>>n;
	     long long ans=powerofto(n);
	     cout<<ans<<"\n";
	}
	return 0;
}

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

void printcnt(int n)
{
   if(n==0) return;
   
   //cout<<n<<" ";
   printcnt(n-1);
   cout<<n<<" ";
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int n;
	        cin>>n;
	        printcnt(n);
	        cout<<"\n";
	}
	return 0;
}

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

void reachome(int dest, int src)
{
   if(src==dest)
   {
      cout<<src<<" Pahunchh gya: ";
      return;
      
   }
   cout<<src<<" ";
   src++;
   reachome(dest, src);
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	      int dest;
	      int src;
	      cin>>dest;
	      cin>>src;
	      reachome(dest,src);
	      cout<<"\n";
	}
	return 0;
}

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

int fab(int n)
{
   if(n==1) return 1;
   if(n==0) return 0;
   return fab(n-1)+fab(n-2);
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int n;
	        cin>>n;
	        int ans=fab(n);
	        cout<<ans<<"\n";
	}
	return 0;
}

//Print digits in string
#include <bits/stdc++.h>
using namespace std;

void print(int n, string arr[])
{
   if(n==0) return;
   int digit = n%10;
   n=n/10;
   
   print(n,arr);
   cout<<arr[digit]<<" ";
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        string arr[10]={"zero", "one","two","three","four","five","six","seven","eight","nine"};
	        int n;
	        cin>>n;
	        print(n,arr);
	        cout<<"\n";
	}
	return 0;
}

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

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	       int n;
	       cin>>n;
	       char a[n][10];
	       for(int i=0;i<n;i++)
	       {
	           for(int j=0;j<10;j++)
	           {
	               cin>>a[i][j];
	           }
	       }
	       int ans=0;
	       for(int i=0;i<10;i++)
	       {
	           int cnt=0;
	           for(int j=0;j<n;j++)
	           {
	               if(a[j][i]=='1') cnt++;
	           }
	           if(cnt%2==1) ans++;
	       }
	       cout<<ans<<"\n";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

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

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int n;
	        cin>>n;
	        int a[n];
	        for(int i=0;i<n;i++)
	        {
	            cin>>a[i];
	        }
	        int ans=0;
	        for(int i=0;i<n-1;i++)
	        {
	            for(int j=i+1;j<n;j++)
	            {
	                if((a[i]==1&&a[j]==1)||(a[i]==0)) ans++;
	            }
	        }
	        cout<<ans<<"\n";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	        int p;
	        cin>>p;
	        int itemprice=2048;
	        int ans=0;
	        while(p>0)
	        {
	            ans+=p/itemprice;
	            p%=itemprice;
	            itemprice/=2;
	        }
	        cout<<ans<<"\n";
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	int n,y;
	cin>>t;
	while(t--)
	{
	      cin>>n>>y;
	      long a[n];
	      bool u=false;
	      for(int i=0;i<n;i++)
	      {
	          cin>>a[i];
	      }
	      long p=0;
	      for(int i=0;i<n;i++)
	      {
	          p=p | a[i];
	      }
	      for(int i=0;i<=y;i++)
	      {
	          if((p|i)==y)
	          {
	              cout<<i<<"\n";
	              u=true;
	              break;
	          }
	      }
	      if(u==false) cout<<"-1\n";
	}
	return 0;
}

METHOD 2:-

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

int main() {
	int t,n,y;
	cin>>t;
	while(t--)
	{
	    cin>>n>>y;
	    int a[n];
	    string required, current;
	    int orans=0;
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	        orans|=a[i];
	    }
	    current=bitset<32>(orans).to_string();
	    required=bitset<32>(y).to_string();
	    int flag=0, answer=0;
	    for(int i=31; i>=0; i--)
	    {
	        if(current[i]=='1' && required[i]=='0')
	        {
	            flag=1;
	            break;
	        }
	        if(current[i]=='0' && required[i]=='1')
	        {
	            answer+=pow(2,31-i);
	        }
	    }
	    if(flag){cout<<-1<<endl;}
	    else {cout<<answer<<endl;}
	}
	return 0;
}
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    
    double gr1, gr2, gr3, gr4, gr5, gr6, gr7, gr8, gr9, gr10, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, aggregate_grade, gwa;
    int un1, un2, un3, un4, un5, un6, un7, un8, un9, un10, numsub, total_units;
    string sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10;
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    cout << "------------------------\n"
        << "IT 202D FINAL OUTPUT\n" 
        << "GWA CALCULATOR\n"
        << "------------------------\n"
        << "Please enter the number of subjects that " << endl
        << "you took this semester (excluding NSTP and subjects \n"
        << "with non-numeric ratings): ";
    cin >> numsub;
    
    if (numsub == 2)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    aggregate_grade = p1 + p2;
    total_units = un1 + un2;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 3)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    aggregate_grade = p1 + p2 + p3;
    total_units = un1 + un2 + un3;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 4)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    aggregate_grade = p1 + p2 + p3 + p4;
    total_units = un1 + un2 + un3 + un4;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 5)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5;
    total_units = un1 + un2 + un3 + un4 + un5;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 6)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6;
    total_units = un1 + un2 + un3 + un4 + un5 + un6;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 7)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub7;
    cout << "Number of Credited Units: ";
    cin >> un7;
    cout << "Grade: ";
    cin >> gr7;
    p7 = un7 * gr7;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7;
    total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 8)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub7;
    cout << "Number of Credited Units: ";
    cin >> un7;
    cout << "Grade: ";
    cin >> gr7;
    p7 = un7 * gr7;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub8;
    cout << "Number of Credited Units: ";
    cin >> un8;
    cout << "Grade: ";
    cin >> gr8;
    p8 = un8 * gr8;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8;
    total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 9)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub7;
    cout << "Number of Credited Units: ";
    cin >> un7;
    cout << "Grade: ";
    cin >> gr7;
    p7 = un7 * gr7;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub8;
    cout << "Number of Credited Units: ";
    cin >> un8;
    cout << "Grade: ";
    cin >> gr8;
    p8 = un8 * gr8;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub9;
    cout << "Number of Credited Units: ";
    cin >> un9;
    cout << "Grade: ";
    cin >> gr9;
    p8 = un9 * gr9;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
    total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8 + un9;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 10)
    {
    cout << "------------------------\n"
        << "Subject Code: ";
    cin >> sub1;
    cout << "Number of Credited Units: ";
    cin >> un1;
    cout << "Grade: ";
    cin >> gr1;
    p1 = un1 * gr1;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub2;
    cout << "Number of Credited Units: ";
    cin >> un2;
    cout << "Grade: ";
    cin >> gr2;
    p2 = un2 * gr2;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub3;
    cout << "Number of Credited Units: ";
    cin >> un3;
    cout << "Grade: ";
    cin >> gr3;
    p3 = un3 * gr3;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub4;
    cout << "Number of Credited Units: ";
    cin >> un4;
    cout << "Grade: ";
    cin >> gr4;
    p4 = un4 * gr4;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub5;
    cout << "Number of Credited Units: ";
    cin >> un5;
    cout << "Grade: ";
    cin >> gr5;
    p5 = un5 * gr5;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub6;
    cout << "Number of Credited Units: ";
    cin >> un6;
    cout << "Grade: ";
    cin >> gr6;
    p6 = un6 * gr6;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub7;
    cout << "Number of Credited Units: ";
    cin >> un7;
    cout << "Grade: ";
    cin >> gr7;
    p7 = un7 * gr7;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub8;
    cout << "Number of Credited Units: ";
    cin >> un8;
    cout << "Grade: ";
    cin >> gr8;
    p8 = un8 * gr8;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub9;
    cout << "Number of Credited Units: ";
    cin >> un9;
    cout << "Grade: ";
    cin >> gr9;
    p8 = un9 * gr9;
    
    cout << "\n------------------------\n"
        << "Subject Code: ";
    cin >> sub10;
    cout << "Number of Credited Units: ";
    cin >> un10;
    cout << "Grade: ";
    cin >> gr10;
    p8 = un10 * gr10;
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
    total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8 + un9 + un10;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "GWA = " << gwa 
        << "\n------------------------\n"; 
    }
    
    else
    {
        cout << "\n------------------------\n"
        << "Invalid entry";
    }
    return 0;
    }
#include <fstream>
#include <iostream>
using namespace std;


int main() {

    // Part 1: Write on a file.
    ofstream oFile;
    oFile.open("my-bio.txt");

    string name;
    int age;

    // User input. 
    cout << "Enter name: ";
    getline(cin, name);

    cout << "Enter age: ";
    cin >> age;

    oFile << "My name is " << name << ". \n";
    oFile << "I am " << age << " years old. \n";

    oFile.close();

    // Part 2: Read from a file.
    string str;

    ifstream iFile;
    iFile.open("my-bio.txt");

    cout << "\nReading data from the file: \n\n";

    while(!iFile.eof()) {
        getline(iFile, str);
        cout << str << endl;
    }

    iFile.close();

    return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		File Handling
*/

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


int main() {

	// The string will hold the text present in each line on the file.
	string str;

	// Create ifstream (Input File Stream) object.
	ifstream iFile;

	// Open the file.
	iFile.open("my-note.txt");

	// Use a while loop together with the getline() function to read the file line by line.
	while(!iFile.eof()) {
		getline(iFile, str);		// Reads a line.
		cout << str << endl;		// Prints the line.
	}

	// Close the opened file.
	iFile.close();

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		File Handling
*/

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


int main() {

	// Create an ofstream (Output File Stream) object.
	ofstream oFile;

	// Create a file (if it doesn't exist) and open it.
	oFile.open("my-note.txt");

	// Write on the file.
	oFile << "Hi! \n";
	oFile << "I love to travel. \n";
	oFile << "I am " << 25 << " years old. \n";

	// Close the opened file.
	oFile.close();

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

void findSquareRoot(float n);


int main() {

    // Find the square root of 'n' entered by the user.
    cout << "Program starts -->" << endl << endl;

    float n;

    cout << "Enter n: ";
    cin >> n;

    findSquareRoot(n);

    cout << "<-- Program ends" << endl;

    return 0;
}

void findSquareRoot(float n) {

    try {
        if (n < 0) {
            throw "The value of 'n' must be greater than or equal to 0. Please try again.";
        }

        float result = sqrt(n);
        cout << "Result: " << result << endl << endl;
    } catch (const char *msg) {
        cout << msg << endl << endl;
    }
}
#include <iostream> 
#include <cmath> 
using namespace std; 


int main() {

    // Find the square root of 'n' entered by the user.
    cout << "Program starts -->" << endl << endl;

    float n;

    cout << "Enter n: ";
    cin >> n;

    try {
        if (n < 0) {
            throw "The value of 'n' must be greater than or equal to 0. Please try again.";
        }

        float result = sqrt(n);
        cout << "Result: " << result << endl << endl;
    } catch (const char *msg) {
        cout << msg << endl << endl;
    }

    cout << "<-- Program ends" << endl;

    return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Exception Handling
*/

#include <iostream>
using namespace std;


int main() {

	// Divide two integers: a divided by b.
	cout << "Program starts -->" << endl << endl;

	int a, b;

	cout << "Enter a: ";
	cin >> a;

	cout << "Enter b: ";
	cin >> b;

	try {
		if (b == 0) {
			throw "The value of 'b' must not be 0. Please try again.";
		}

		int result = a / b;
		cout << "Result: " << result << endl << endl;
	} catch (const char *msg) {
		cout << msg << endl << endl;
	}

	cout << "<-- Program ends" << endl;

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Preprocessor Directives
*/

#include <iostream>
using namespace std;

#define UPPER_LIMIT 10		// Macro definition
#define AREA(r) (3.14 * r * r)	// Macro with parameter


int main() {

	// Find even numbers from 1 to 10.
	for (int i = 1; i <= UPPER_LIMIT; i++) {

		if (i % 2 == 0)
			cout << i << endl;
	}

	// Find the area of a circle.
	cout << "Area: " << AREA(5);		// 3.14 * 5 * 5

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Standard Libraries
*/

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

class Employee {
	// Your code 
};

int main() {

	/* C++ <vector> Header
	   Vectors are similar to arrays, but it can change its size. */

	Employee emp1, emp2, emp3, emp4;
	vector<Employee> employeeList;
	employeeList.push_back(emp1);
	employeeList.push_back(emp2);
	employeeList.push_back(emp3);
	employeeList.push_back(emp4);
	
	vector<string> names;
	names.push_back("Rahul");		// Adds element at the end
	names.push_back("Peter");
	names.push_back("Ravi");

	// Check the size.
	cout << "Size: " << names.size() << endl;		// 3

	// Accessing an element.
	cout << "Element at index 0: " << names[0] << endl;		// Rahul

	// Remove element from the end.
	names.pop_back();		// Removes "Ravi"
	cout << "Size: " << names.size() << endl;		// 2

	// Modify element.
	names[0] = "Aditya";
	cout << "Element at index 0: " << names[0] << endl;		// Aditya

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Standard Libraries
*/

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


int main() {

	/* C++ <cmath> Header */

	int x = 4, y = 9;

	cout << "The greater number: " << fmax(x, y) << endl;		// 9
	cout << "The smaller number: " << fmin(x, y) << endl;		// 4
	cout << "The difference: " << fdim(y, x) << endl;			// 5

	cout << "2 to the power 4: " << pow(2, 4) << endl;	// 2 * 2 * 2 * 2 = 16

	cout << sqrt(64) << endl;		// 8
	cout << round(2.5) << endl;		// 3
	cout << round(2.4) << endl;		// 2
	cout << floor(4.9) << endl;		// 4
	cout << log(2) << endl;			// 0.693

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Standard Libraries
*/

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <unistd.h>
using namespace std;


int main() {

	/* WAP to roll a dice.*/

	int randomValue;

	srand(time(NULL));

	randomValue = (rand() % 6) + 1;		// 1, 2, 3, 4, 5, 6

	cout << "Rolling the dice...\n\n";
	usleep(2000000);

	cout << "You got: " << randomValue;

	return 0;
}
/*
 Author:	Internshala
 Module:	Diving into C++ Programming
 Topic:		Namespaces
*/

#include <iostream>
using namespace std;

namespace jp {

	float dollarValue = 108;	// 1 USD = 108 Japanese Yen

	double toDollars(float currencyUnits) {
		return currencyUnits / dollarValue;
	}
}

namespace cn {

	float dollarValue = 7;		// 1 USD = 7 Chinese Yuan

	double toDollars(float currencyUnits) {
		return currencyUnits / dollarValue;
	}
}


int main() {

	cout << "1 USD = " << jp::dollarValue << " Yen" << endl;
	cout << "1 USD = " << cn::dollarValue << " Yuan" << endl;

	cout << "8960 Yen = " << jp::toDollars(8960) << " USD" << endl;
	cout << "610 Yuan = " << cn::toDollars(610) << " USD" << endl;

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Friend Class and Friend Function
*/

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

class Employee {

	private:
		string phNo;

	public:
		string name;

		void setPhoneNumber(string phoneNumber) {
			this->phNo = phoneNumber;
		}

		friend void display(Employee);		// Function declaration
};

void display(Employee emp) {	// Function definition
	cout << "Employee name: " << emp.name << ", Phone: " << emp.phNo << endl;
}


int main() {

	Employee employee;
	employee.setPhoneNumber("+91-8093");
	employee.name = "Rishi Raj";

	display(employee);

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Friend Class and Friend Function
*/

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

class Employee {

	private:
		string phNo;

	public:
		string name;

		void setPhoneNumber(string phoneNumber) {
			this->phNo = phoneNumber;
		}

		friend class Car;
};

class Car {			// Friend class of class Employee

	public:
		string carName;

		void display(Employee emp) {
			cout << "Employee name: " << emp.name << ", Phone: " << emp.phNo << ", Car name: " << carName << endl;
		}
};


int main() {

	Employee employee;
	employee.setPhoneNumber("+91-8093");
	employee.name = "Rishi Raj";

	Car car;
	car.carName = "Ferrari 488";
	car.display(employee);

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

class Shape {

    public:
        virtual double getArea() = 0;
        virtual double getPerimeter() = 0;
};

class Square : public Shape {

    public:
        float side;

        virtual double getArea() {
            return side * side;
        }

        virtual double getPerimeter() {
            return 4 * side;
        }
};

class Rectangle : public Shape {

    public:
        float length;
        float breadth;

        virtual double getArea() {
            return length * breadth;
        }

        virtual double getPerimeter() {
            return 2 * (length + breadth);
        }
};

class Circle : public Shape {

    public:
        float radius;

        virtual double getArea() {
            return 3.14 * radius * radius;
        }

        virtual double getPerimeter() {
            return 2 * 3.14 * radius;
        }
};

class Triangle : public Shape {

    public:
        float base;
        float height;
        float side1;
        float side2;

        virtual double getArea() {
            return (base * height) / 2;
        }

        virtual double getPerimeter() {
            return base + side1 + side2;
        }
};


int main() {

Circle circle;
    circle.radius = 10;
    double area = circle.getArea();
    double perimeter = circle.getPerimeter();

    cout << "The area and the perimeter of the circle is " << area << " square units and " << perimeter << " units respectively." << endl;

    return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Abstract Class
*/

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

class Animal {		// Abstract class

	public:
		virtual void sound() = 0;		// Pure virtual function

		virtual void sleep() {
			cout << "Animal class: sleeping" << endl;
		}
};

class Dog : public Animal {		// Concrete class

	public:
		virtual void sound() {
			cout << "Dog class: bow-bow" << endl;
		}

		virtual void sleep() {
			cout << "Dog class: sleeping" << endl;
		}
};


int main() {

//	Animal a;	 // a --> Animal object	 // Error. Cannot create an object of an abstract class. 
	
	Dog dog;		// dog --> Dog object
	dog.sound();
	dog.sleep();

	Animal *animal = new Dog();		// animal --> Dog object
	animal->sound();
	animal->sleep();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Polymorphism
*/

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

class Animal {

	public:
		virtual void sound() {
			cout << "Animal class: making sound" << endl;
		}

		virtual void sleep() {
			cout << "Animal class: sleeping" << endl;
		}
};

class Dog : public Animal {

	public:
		virtual void sound() {
			cout << "Dog class: bow-bow" << endl;
		}

		virtual void sleep() {
			cout << "Dog class: sleeping" << endl;
		}
};


int main() {

	Dog dog;		// dog --> Dog object
	dog.sound();
	dog.sleep();

	Animal *animal = new Dog();		// animal --> Dog object
	animal->sound();
	animal->sleep();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Polymorphism
*/

#include <iostream>
using namespace std;

class Animal {

	public:
		void sound() {
			cout << "Animal class: making sound" << endl;
		}

		void sleep() {
			cout << "Animal class: sleeping" << endl;
		}
};

class Dog : public Animal {

	public:
		void sound() {
			cout << "Dog class: bow-bow" << endl;
		}

		void sleep() {
			cout << "Dog class: sleeping" << endl;
		}
};


int main() {

	Animal animal;
	animal.sound();
	animal.sleep();

	Dog dog;
	dog.sound();
	dog.sleep();

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

class Person {

    private:
        string phoneNumber;

    public:
        string fullName;

        void setPhoneNumber(string phoneNumber) {
            this->phoneNumber = phoneNumber;
        }
};

class Employee : public Person {

    private:
        float salary;

    public:
        int id;

        void setSalary(float salary) {

            this->salary = salary;
        }

        void addBonus(float bonus) {
            this->salary = this->salary + bonus;
        }

        void displaySalary() {
            cout << "Current salary: " << salary;
        }
};


int main() {

    Employee employee;
    employee.id = 1;
    employee.fullName = "Aditya Sharma";
    employee.setPhoneNumber("+91-887700132");
    employee.setSalary(35000);
    employee.addBonus(4000);
    employee.displaySalary();

    return 0;
}

/*
The function ‘addBonus’ in the class Employee should be present under the public section so that it can be accessed from outside the class i.e. from the ‘main’ function. Therefore, the protected section in class Employee was not required. 
*/
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Access Specifiers
*/

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

class Person {

	protected:
		string phoneNumber;

	public:
		string fullName;

		void setPhoneNumber(string phoneNumber) {
			this->phoneNumber = phoneNumber;
		}

		void displayPersonDetails() {
			cout << "Name: " << fullName << ", Phone: " << phoneNumber << endl;
		}
};

class Student : public Person {

	public:
		int id;

		void displayStudentDetails() {
			cout << "Id: " << id << ", Name: " << fullName << ", Phone: " << phoneNumber << endl;
		}

};


int main() {

	Person person;
	person.fullName = "Rahul Kamal";
	person.setPhoneNumber("+91-9431");
//	string phone = person.phoneNumber;		// protected: Cannot be accessed. Error. 
	person.displayPersonDetails();

	Student student;
	student.id = 1;
	student.fullName = "Aditya Sharma";
	student.setPhoneNumber("+91-8877");
//	string phNo = student.phoneNumber;		// protected: Cannot be accessed. Error. 
	student.displayStudentDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Access Specifiers
*/

#include <iostream>
using namespace std;

class Circle {

	private:		// Access Specifier
		float radius;

	public:
		void setRadius(float radius) {
			this->radius = radius;
		}

		double getArea() {
			return 3.14 * radius * radius;
		}
};


int main() {

	Circle circle;
	circle.setRadius(5);
	double area = circle.getArea();
	cout << "Area of the circle is " << area << " square units." << endl;

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Inheritance
*/

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

class Animal {

	public:
		int age;
		string color;

		void run() {
			cout << "Running" << endl;
		}
};

class Dog : public Animal {

	public:
		string petName;

		void bark() {
			cout << "Barking" << endl;
		}
};

class Lion : public Animal {

	public:
		void roar() {
			cout << "Roaring" << endl;
		}
};


int main() {

	Dog dog;
	dog.age = 5;
	dog.color = "Black";
	dog.petName = "Jackie";
	dog.bark();
	dog.run();

	Lion lion;
	lion.age = 10;
	lion.color = "Brown";
	lion.roar();
	lion.run();

	Animal animal;
	animal.age = 7;
	animal.color = "White";
	animal.run();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Constructors and Destructors
*/

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

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		Employee();			// Default constructor declaration
		Employee(int, string, string);	// Parameterized constructor declaration
		
		~Employee();		// Destructor declaration 
		
		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

Employee :: ~Employee() {	// Destructor definition
	cout << "Employee object being deleted";
}

Employee :: Employee(int id, string firstName, string lastName) {	// Parameterized constructor
	this->id = id;
	this->firstName = firstName;
	this->lastName = lastName;
}

Employee :: Employee() {	// Default constructor definition
	cout << "Employee object created\n";
}

void Employee :: displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {
	
	// Create an object of Employee class
	Employee emp1(1, "Rahul", "Sharma");

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	Employee emp3 = emp2;		// Executes copy constructor
	emp3.id = 3;
	emp3.displayDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Constructors and Destructors
*/

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

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		Employee();			// Default constructor declaration
		Employee(int, string, string);	// Parameterized constructor declaration

		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

Employee :: Employee(int id, string firstName, string lastName) {	// Parameterized constructor
	this->id = id;
	this->firstName = firstName;
	this->lastName = lastName;
}

Employee :: Employee() {	// Default constructor definition
	cout << "Employee object created\n";
}

void Employee :: displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {

	// Create an object of Employee class
	Employee emp1(1, "Rahul", "Sharma");

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	Employee emp3 = emp2;		// Executes copy constructor
	emp3.id = 3;
	emp3.displayDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Constructors and Destructors
*/

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

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		Employee();			// Default constructor declaration
		Employee(int, string, string);	// Parameterized constructor declaration

		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

Employee :: Employee(int id, string firstName, string lastName) {	// Parameterized constructor
	this->id = id;
	this->firstName = firstName;
	this->lastName = lastName;
}

Employee :: Employee() {	// Default constructor definition
	cout << "Employee object created\n";
}

void Employee :: displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {

	// Create an object of Employee class
	Employee emp1(1, "Rahul", "Sharma");

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Constructors and Destructors
*/

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

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		Employee();			// Default constructor declaration

		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

Employee :: Employee() {	// Default constructor definition
	cout << "Employee object created\n";
}

void Employee :: displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {

	// Create an object of Employee class
	Employee emp1;

	// Access attributes and set values
	emp1.id = 1;
	emp1.firstName = "Rahul";
	emp1.lastName = "Sharma";

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	return 0;
}
BSTNode * BST::Insert(BSTNode * node, int key)
{
    // If BST doesn't exist
    // create a new node as root
    // or it's reached when
    // there's no any child node
    // so we can insert a new node here
    if(node == NULL)
    {
        node = new BSTNode;
        node->Key = key;
        node->Left = NULL;
        node->Right = NULL;
        node->Parent = NULL;
    }
    // If the given key is greater than
    // node's key then go to right subtree
    else if(node->Key < key)
    {
        node->Right = Insert(node->Right, key);
        node->Right->Parent = node;
    }
    // If the given key is smaller than
    // node's key then go to left subtree
    else
    {
        node->Left = Insert(node->Left, key);
        node->Left->Parent = node;
    }
#include <iostream>
using namespace std;

int main() {
    int x = 1;
    
    while (x <= 30)
    {
        cout << x << endl;
        x += 3;
    }
    
    return 0;
    
}
// Online C++ compiler to run C++ program online
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main() {
    string a[] = {"apple" , "a", "ap", "al", "ae", "app", "apl", "ape", "ale", "appl", "appe", "aple", "apple", "p", "pp", "pl", "pe", "ppl", "ppe", "ple", "pple", "l", "le", "e"} ; 
    cout << sizeof(a)/sizeof(a[0])  ; 
    

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

class Dog {    // Defining class

    public:    // public section 
        string breed;
        int age;
        string color;
        string petName;

        void displayDetails();    // Method declaration 
};

void Dog :: displayDetails() {    // Method definition
    cout << "Dog's Pet Name: " << petName << endl << "Breed: " << breed << endl << "Age: " << age << endl << "Color: " << color <<"\n\n";
}


int main() {

    // Creating dog object 
    Dog dog1;
    dog1.breed = "Dalmatian";
    dog1.age = 7;
    dog1.color = "White-black";
    dog1.petName = "Jackie";
    dog1.displayDetails();

    // Creating dog object 
    Dog dog2;
    dog2.breed = "Beagle";
    dog2.age = 4;
    dog2.color = "Brown";
    dog2.petName = "Pluto";
    dog2.displayDetails();

    return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Class and Object
*/

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

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member

		string getFullName() {		// Method/function definition
			return firstName + " " + lastName;
		}

		void displayDetails();		// Method/function declaration
};

void Employee::displayDetails() {	// Method/function definition
	cout << "ID: " << id << endl << "Name: " << getFullName() << "\n\n";
}


int main() {

	// Create an object of Employee class
	Employee emp1;

	// Access attributes and set values
	emp1.id = 1;
	emp1.firstName = "Rahul";
	emp1.lastName = "Sharma";

	// Print attribute values
	emp1.displayDetails();

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	emp2.displayDetails();

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Class and Object
*/

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

class Employee {

	public:					// Access specifier
		int id;				// Attribute or data member
		string firstName;	// Attribute or data member
		string lastName;	// Attribute or data member
};


int main() {

	// Create an object of Employee class
	Employee emp1;

	// Access attributes and set values
	emp1.id = 1;
	emp1.firstName = "Rahul";
	emp1.lastName = "Sharma";

	// Print attribute values
	cout << "ID: " << emp1.id << endl << "Name: " << emp1.firstName << " " << emp1.lastName  << "\n\n";

	// Another employee object
	Employee emp2;
	emp2.id = 2;
	emp2.firstName = "Yajat";
	emp2.lastName = "Agrawal";

	cout << "ID: " << emp2.id << endl << "Name: " << emp2.firstName << " " << emp2.lastName  << "\n\n";

	return 0;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Migrating from C to C++
*/

#include <iostream>
using namespace std;

void add(int, int);
void add(string, string);
void add(int, int, int);


int main() {

	// Function Overloading
	add(10, 20);
	add("Hello ", "World");
	add(91, 85, 74);

	return 0;
}

void add(int num1, int num2) {

	cout << num1 + num2 << endl;
}

void add(string str1, string str2) {

	cout << str1 + str2 << endl;
}

void add(int num1, int num2, int num3) {

	cout << num1 + num2 + num3 << endl;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Migrating from C to C++
*/

#include <iostream>
using namespace std;

void display(int, float, string message = "Welcome!");


int main() {

	// Functions: Default parameters
	display(2, 40.8, "Welcome! Hope you are doing great.");

	display(10, 7.8);

	return 0;
}

void display(int num1, float num2, string message) {

	cout << "num1: " << num1 << endl;
	cout << "num2: " << num2 << endl;
	cout << "message: " << message << endl << endl;
}
/*
 Author:	Internshala
 Module:	Fundamentals of Object Oriented Programming Using C++
 Topic:		Migrating from C to C++
*/

#include <iostream>
using namespace std;


int main() {

	// Boolean values: true or false.
	bool isCodingFun = true;	// 1 means true and 0 means false.
	if (isCodingFun) {
		cout << "Let's code more.\n";
	} else {
		cout << "Find another job.\n";
	}

	int x = 9, y = 20;
	bool b1 = x > y;		// false
	bool b2 = x < y;		// true
	bool b3 = x == y;		// false
	cout << "b1: " << b1 << endl;
	cout << "b2: " << b2 << endl;
	cout << "b3: " << b3 << endl;

	cout << true + 7;		// 1 + 7 = 8

	return 0;
}
void printReverse(Node* head)
{
    // Base case
    if (head == NULL)
    return;
 
    // print the list after head node
    printReverse(head->next);
 
    // After everything else is printed, print head
    cout << head->data << " ";
}
class Solution
{
    public:
    //Function to reverse a linked list.
    struct Node* reverseList(struct Node *head)
    {
        if(head->next==NULL) return head;
        Node *l,*t,*f;
        l=head,t=head->next,f=head->next->next;
        head->next=NULL;
        while(t->next)
        {
            t->next=l;
            l=t;
            t=f;
            f=f->next;
        }
        t->next=l;
        head=t;
        return head;
        // code here
        // return head of reversed list
    }
    
};
#include <iostream>
#include <string>
using namespace std;


int main() {

    string name = "India";
    char dollar = '$';
    float gdp = 2.2;
    int year = 2015;

    cout << "Enter country name:";
    getline(cin, name);

    cout << "Enter dollar symbol:";
    cin >> dollar;

    cout << "Enter GDP:";
    cin >> gdp;

    cout << "Enter year:";
    cin >> year;

    cout << "As economic reforms picked up the pace, " << name << "'s GDP grew five-fold to reach US" << dollar << gdp <<" trillion in " << year << " (as per IMF estimates).";

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


int main() {

    string name = "India";
    char dollar = '$';
    float gdp = 2.2;
    int year = 2015;

    cout << "As economic reforms picked up the pace, " << name << "'s GDP grew five-fold to reach US" << dollar << gdp <<" trillion in " << year << " (as per IMF estimates).";

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

int main() {
    int Choice, option;
    
    cout << "1.Caesar Cipher \n 2.Vernam Cipher \n 3.Vigenere Cipher \n 4.Transposition Cipher \n 5.RSA \n";
    cout << "Choose one of the options above: ";
    
    cin >> Choice;
    
    switch(Choice) {
        case 1:
            cout <<"1.Encrypt a message \n";
            cout <<"2.Decrypt a message \n";
            cout <<"Choose one option from above: ";
            cin >>option;
            
            if(option == 1) {
                string message, cipher;
                char chr;
                int shift, x;
                
                cout <<"Enter your message: ";
                cin >> message;
                
                cout <<"Enter the shift value: ";
                cin >> shift;
        
                for(int i=0; i<message.length(); i++) {
                    chr = message[i];
        
                    if (int(chr) <= 90){
                        x = ((int(chr) + shift - 65) % 26 + 65);
                        cipher[i] = char(x);
                    }
            
                    else {
                        
                        x = ((int(chr) + shift - 97) % 26 + 97);
                        cipher[i] = char(x);
                    }
                }
                cout<<"Your cipher text is: ";
                for(int i=0; i<message.length(); i++) {
                    cout<<cipher[i];
                }
            }
            else if(option == 2) {
                string message, cipher;
                char chr;
                int shift, x;
                
                cout<<"Enter your cipher text: ";
                cin>>cipher;
                
                cout<<"Enter the shift value: ";
                cin>>shift;
                
                for(int i=0; i<cipher.length(); i++) {
                    chr = cipher[i];
                    
                    if(int(chr) < 90) {
                         x = ((int(chr) - shift - 65) % 26 + 65);
                         message[i] = char(x);
                    }
                    else {
                         x = ((int(chr) - shift - 97) % 26 + 97);
                         message[i] = char(x);
                    }
                }
                cout<<"Your decrypted message is: ";
                for(int i=0; i<cipher.length(); i++) {
                    cout<<message[i];
                }
            }
        break;
        case 2:
            cout <<"1.Encrypt a message \n";
            cout <<"2.Decrypt a message \n";
            cout <<"Choose one option from above: ";
            cin >>option;
            
            if(option == 1) {
                string message, cipher, key;
                char chr, keychar;
                int x;
                
                cout <<"Enter your message: ";
                cin >> message;
                
                cout <<"Enter the key: ";
                cin >>key;
                
                for(int i=0; i<message.length(); i++){
                    char chr = message[i];
                    char keychar = key[i];
            
                    if (int(chr) < 90){
                        x = ((int(chr) + int(keychar) - 130) % 26 + 65);
                        cipher[i] = char(x);
                    }
                
                    else{
                       x = ((int(chr) + int(keychar) - 194) % 26 + 97);
                       cipher[i] = char(x);
                    }
                }     
                cout<<"Your cipher text is: ";
                for(int i=0; i<message.length(); i++) {
                    cout<<cipher[i];
                }
            }
            if(option == 2) {
                string cipher, message, key;
                char chr, keychar;
                int x;
                
                cout <<"Enter the cipher text: ";
                cin >> cipher;
                
                cout <<"Enter the key: ";
                cin >>key;
                
                for(int i=0; i<cipher.length(); i++){
                    chr = cipher[i];
                    keychar = key[i];
            
                    if (int(chr) < 90){
                        x = ((int(chr) - int(keychar) - 130) % 26 + 65);
                        message[i] = char(x);
                    }
                    else{
                       x = ((int(chr) - int(keychar)) % 26 + 97);
                       message[i] = char(x);
                    }
                }
                cout<<"Your decrypted message is: ";
                for(int i=0; i<cipher.length(); i++) {
                    cout<<message[i];
                }
            }
        break;
        case 3:
            cout <<"1.Encrypt a message \n";
            cout <<"2.Decrypt a message \n";
            cout <<"Choose one option from above: ";
            cin >>option;
            
            if(option == 1) {
                string message, cipher, key;
                char chr, keychar;
                int x;
                
                cout <<"Enter your message: ";
                cin >> message;
                
                cout <<"Enter the key: ";
                cin >>key;
                
                char newkey[message.length()];
                int length = 0;
                
                
                while(length < message.length()) {
                    for(int i=0; i<key.length(); i++) {
                        if(length <= message.length()) {
                            newkey[length] = key[i];
                            length += 1;
                        }
                        else
                            break;
                    }
                }
                
                for(int i=0; i<message.length(); i++){
                    chr = message[i];
                    keychar = newkey[i];
            
                    if (int(chr) < 90){
                        x = ((int(chr) + int(keychar) - 130) % 26 + 65);
                        cipher[i] = char(x);
                    }
                
                    else{
                       x = ((int(chr) + int(keychar) - 194) % 26 + 97);
                       cipher[i] = char(x);
                    }
                }     
                cout<<"Your cipher text is: ";
                for(int i=0; i<message.length(); i++) {
                    cout<<cipher[i];
                }
            }
            if(option == 2) {
                string cipher, message, key;
                char chr, keychar;
                int x;
                
                cout <<"Enter the cipher text: ";
                cin >> cipher;
                
                cout <<"Enter the key: ";
                cin >>key;
                
                char newkey[cipher.length()];
                int length = 0;
                
                
                while(length < cipher.length()) {
                    for(int i=0; i<key.length(); i++) {
                        if(length <= cipher.length()) {
                            newkey[length] = key[i];
                            length += 1;
                        }
                        else
                            break;
                    }
                }
                
                for(int i=0; i<cipher.length(); i++){
                    chr = cipher[i];
                    keychar = newkey[i];
            
                    if (int(chr) < 90){
                        x = ((int(chr) - int(keychar) - 130) % 26);
                        if(x<0){
                           x += 91;
                       }
                       else{
                           x += 65;
                       }
                        message[i] = char(x);
                    }
                    else{
                       x = ((int(chr) - int(keychar)) %26);
                       if(x<0){
                           x += 123;
                       }
                       else{
                           x += 97;
                       }
                       message[i] = char(x);
                    }
                }
                cout<<"Your decrypted message is: ";
                for(int i=0; i<cipher.length(); i++) {
                    cout<<message[i];
                }
            }
        break;
    }
    return 0;
}
class Solution {
public:
    vector<int> dailyTemperatures(vector<int>& t) {
        vector<int> ans;
        stack<int> s;
        int n=t.size();
        for(int i=n-1;i>=0;i--)
        {
            if(s.empty())
            {
                s.push(i);
                ans.push_back(0);
            }
            else 
            {
                while(!s.empty() && t[s.top()]<=t[i])
                {
                    s.pop();
                }
                if(s.empty())
                { 
                    s.push(i);
                    ans.push_back(0);
                }
                else if(!s.empty()&&t[s.top()]>t[i])
                {
                    ans.push_back(s.top()-i);
                    s.push(i);
                }
            }
        }
        reverse(ans.begin(),ans.end());
        return ans;
    }
};
# Define the grid
grid = initialize_grid()

# Set up the initial conditions for the fields and particles
fields = initialize_fields(grid)
particles = initialize_particles(grid)

# Loop over timesteps
while (time < end_time):
  
  # Advance the particles using the Lorentz force
  particles = push_particles(particles, fields, dt)

  # Update the fields based on the current particle positions and velocities
  fields = solve_fields(fields, particles, dt)

  # Deposit the particle currents onto the grid
  fields = deposit_currents(fields, particles)

  # Interpolate the fields at the particle positions
  fields_at_particles = interpolate_fields(fields, particles)

  # Compute the Lorentz force on the particles
  particles = compute_lorentz_force(particles, fields_at_particles)

  # Increment time
  time += dt
void powell_eyink(double* B, double divB) {
  double alpha = -divB / (2 * dot_product(B, B));
  for (int i = 0; i < 3; i++) {
    B[i] += alpha * B[i];
  }
}
def div_clean(grid, B, tolerance):
  # Compute the divergence of the magnetic field
  divB = compute_divergence(B)

  # Identify points where the divergence exceeds the tolerance
  error_points = [i for i in range(len(grid)) if abs(divB[i]) > tolerance]

  # Adjust the magnetic field at these points using the Powell-Eyink scheme
  for i in error_points:
    B[i] = powell_eyink(B[i], divB[i])
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

// physical parameters
const double gamma = 5./3.; // gas adiabatic index
const double pressure = 1.0; // gas pressure

// simulation parameters
const int nx = 100; // number of cells
const double dx = 0.01; // cell size
const double dt = 0.001; // time step
const double tmax = 1.0; // maximum time

// arrays for storing cell values
double density[nx];
double velocity[nx];
double energy[nx];

// helper function for computing the pressure
double pressure_func(double density, double energy)
{
  return (gamma-1)*density*energy;
}

// main simulation loop
int main(int argc, char **argv)
{
  // initialize density, velocity, and energy
  for (int i = 0; i < nx; i++)
  {
    density[i] = 1.0;
    velocity[i] = 0.0;
    energy[i] = pressure/(gamma-1);
  }

  // time stepping loop
  for (double t = 0; t < tmax; t += dt)
  {
    // compute fluxes at cell interfaces
    double flux_density[nx+1], flux_momentum[nx+1], flux_energy[nx+1];
    for (int i = 0; i < nx+1; i++)
    {
      // left and right cell values
      double density_l = density[i];
      double velocity_l = velocity[i];
      double energy_l = energy[i];
      double pressure_l = pressure_func(density_l, energy_l);

      double density_r = density[i+1];
      double velocity_r = velocity[i+1];
      double energy_r = energy[i+1];
      double pressure_r = pressure_func(density_r, energy_r);

      // Roe average values
      double rho_avg = sqrt(density_l*density_r);
      double vel_avg = (sqrt(density_l)*velocity_l + sqrt(density_r)*velocity_r)/(sqrt(density_l)+sqrt(density_r));
      double h_avg = (sqrt(density_l)*(energy_l+pressure_l/density_l) + sqrt(density_r)*(energy_r+pressure_r/density_r))/(sqrt(density_l)+sqrt(density_r));
      double a_avg = sqrt((gamma-1)*(h_avg-0.5*vel_avg*vel_avg));

      // left and right wave speeds
      double lambda_l = vel_avg - a_avg;
      double lambda_r = vel_avg + a_avg;

      // compute fluxes
      flux_density[i] = rho_avg*vel_avg;
      flux_momentum[i] = rho_avg*vel_avg*vel_avg
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

// A struct to represent a 3D vector
typedef struct Vector {
  double x;
  double y;
  double z;
} Vector;

// A struct to represent a sphere in 3D space
typedef struct Sphere {
  Vector center;
  double radius;
} Sphere;

// A struct to represent a ray in 3D space
typedef struct Ray {
  Vector origin;
  Vector direction;
} Ray;

// Returns the distance from the ray's origin to the point where it intersects
// the sphere, or -1 if the ray does not intersect the sphere.
double intersects(Ray ray, Sphere sphere) {
  Vector oc = {
    .x = ray.origin.x - sphere.center.x,
    .y = ray.origin.y - sphere.center.y,
    .z = ray.origin.z - sphere.center.z
  };

  double b = 2 * (oc.x * ray.direction.x + oc.y * ray.direction.y + oc.z * ray.direction.z);
  double c = oc.x * oc.x + oc.y * oc.y + oc.z * oc.z - sphere.radius * sphere.radius;

  double discriminant = b * b - 4 * c;
  if (discriminant < 0) {
    return -1;
  }

  double t1 = (-b - sqrt(discriminant)) / 2;
  double t2 = (-b + sqrt(discriminant)) / 2;

  // Return the smallest non-negative value of t
  if (t1 >= 0 && t2 >= 0) {
    return fmin(t1, t2);
  } else if (t1 >= 0) {
    return t1;
  } else if (t2 >= 0) {
    return t2;
  } else {
    return -1;
  }
}

int main() {
  // Create a sphere at the origin with radius 1
  Sphere sphere = {
    .center = {
      .x = 0,
      .y = 0,
      .z = 0
    },
    .radius = 1
  };

  // Create a ray that starts at the origin and points in the direction of the
  // positive x-axis
  Ray ray = {
    .origin = {
      .x = 0,
      .y = 0,
      .z = 0
    },
    .direction = {
      .x = 1,
      .y = 0,
      .z = 0
    }
  };

  double distance = intersects(ray, sphere);

  printf("The ray intersects the sphere at a distance of %f\n", distance);

  return 0;
}
/ Function to refine the mesh at a given level of refinement
void refine_mesh(int level) {
    // Loop over all cells in the mesh
    for (int i = 0; i < num_cells; i++) {
        // Check if the cell needs to be refined
        if (cell_needs_refinement(i, level)) {
            // Split the cell into subcells
            split_cell(i);
        }
    }
}

// Function to check if a cell needs to be refined
bool cell_needs_refinement(int cell_index, int level) {
    // Implement the criteria for deciding if a cell needs to be refined here
    // For example, you could check if the error estimate for the cell exceeds a certain threshold
    // or if the cell is near a region of interest (e.g. near a boundary or singularity)
}

// Function to split a cell into subcells
void split_cell(int cell_index) {
    // Create the subcells and update the data structures that store the mesh
    // For example, you could create 4 new subcells by dividing the cell into quadrants
    // and then update the arrays that store the vertices and connectivity of the mesh
}
#include <iostream>
#include <iomanip>
#include <string.h>
using namespace std;

int main() {
    
    double gr1, gr2, gr3, gr4, gr5, gr6, gr7, gr8, gr9, gr10, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, aggregate_grade, gwa;
    int un1, un2, un3, un4, un5, un6, un7, un8, un9, un10, numsub, total_units;
    string id, sec, sec2, sem, sy, sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10;
    char stringarray[50];
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    cout << "------------------------\n"
        << "IT 202D FINAL OUTPUT\n" 
        << "GWA CALCULATOR\n"
        << "------------------------\n";
    
    cout << "Name of Student: ";
    cin.getline(stringarray,30);
    cout << "Student ID: ";
    cin >> id;
    cout << "Year & Section (e.g. BSIT 2B): ";
    cin >> sec >> sec2;
    cout << "Academic Year: ";
    cin >> sy;
    cout << "Semester (e.g. First): ";
    cin >> sem;
    
    cout << "------------------------\n"
        << "Please enter the number of subjects that " << endl
        << "you took this semester (excluding NSTP and subjects \n"
        << "with non-numeric ratings): ";
    cin >> numsub;
    
    if (numsub == 2)
    {
        cout << "------------------------\n"
        << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
    
        cout << "\n-\n"
        << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        total_units = un1 + un2;
    
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
    
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
    
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
    
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
    
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 3)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
    
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
        << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        total_units = un1 + un2 + un3;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        aggregate_grade = p1 + p2 + p3;
        gwa = aggregate_grade / total_units;
        cout << "\n------------------------\n"
            << "Academic Year "<< sy << endl
            << sem << " Semester \n"
            << endl << "GWA = " << gwa 
            << "\n------------------------\n";
    }
    
    else if (numsub == 4)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        total_units = un1 + un2 + un3 + un4;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
    aggregate_grade = p1 + p2 + p3 + p4;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 5)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        total_units = un1 + un2 + un3 + un4 + un5;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
       << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 6)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        total_units = un1 + un2 + un3 + un4 + un5 + un6;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 7)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub7;
        cout << "Number of Credited Units: ";
        cin >> un7;
        cout << "Grade: ";
        cin >> gr7;
        p7 = un7 * gr7;
        total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr7 >= 3.00)
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 8)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub7;
        cout << "Number of Credited Units: ";
        cin >> un7;
        cout << "Grade: ";
        cin >> gr7;
        p7 = un7 * gr7;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub8;
        cout << "Number of Credited Units: ";
        cin >> un8;
        cout << "Grade: ";
        cin >> gr8;
        p8 = un8 * gr8;
        total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr7 >= 3.00)
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr8 >= 3.00)
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 9)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub7;
        cout << "Number of Credited Units: ";
        cin >> un7;
        cout << "Grade: ";
        cin >> gr7;
        p7 = un7 * gr7;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub8;
        cout << "Number of Credited Units: ";
        cin >> un8;
        cout << "Grade: ";
        cin >> gr8;
        p8 = un8 * gr8;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub9;
        cout << "Number of Credited Units: ";
        cin >> un9;
        cout << "Grade: ";
        cin >> gr9;
        p8 = un9 * gr9;
        total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8 + un9;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr7 >= 3.00)
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr8 >= 3.00)
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr9 >= 3.00)
        {
            cout << setw(7) << left << sub9
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub9
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else if (numsub == 10)
    {
        cout << "------------------------\n"
            << "Subject Code: ";
        cin >> sub1;
        cout << "Number of Credited Units: ";
        cin >> un1;
        cout << "Grade: ";
        cin >> gr1;
        p1 = un1 * gr1;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub2;
        cout << "Number of Credited Units: ";
        cin >> un2;
        cout << "Grade: ";
        cin >> gr2;
        p2 = un2 * gr2;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub3;
        cout << "Number of Credited Units: ";
        cin >> un3;
        cout << "Grade: ";
        cin >> gr3;
        p3 = un3 * gr3;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub4;
        cout << "Number of Credited Units: ";
        cin >> un4;
        cout << "Grade: ";
        cin >> gr4;
        p4 = un4 * gr4;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub5;
        cout << "Number of Credited Units: ";
        cin >> un5;
        cout << "Grade: ";
        cin >> gr5;
        p5 = un5 * gr5;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub6;
        cout << "Number of Credited Units: ";
        cin >> un6;
        cout << "Grade: ";
        cin >> gr6;
        p6 = un6 * gr6;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub7;
        cout << "Number of Credited Units: ";
        cin >> un7;
        cout << "Grade: ";
        cin >> gr7;
        p7 = un7 * gr7;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub8;
        cout << "Number of Credited Units: ";
        cin >> un8;
        cout << "Grade: ";
        cin >> gr8;
        p8 = un8 * gr8;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub9;
        cout << "Number of Credited Units: ";
        cin >> un9;
        cout << "Grade: ";
        cin >> gr9;
        p8 = un9 * gr9;
        
        cout << "\n-\n"
            << "Subject Code: ";
        cin >> sub10;
        cout << "Number of Credited Units: ";
        cin >> un10;
        cout << "Grade: ";
        cin >> gr10;
        p8 = un10 * gr10;
        total_units = un1 + un2 + un3 + un4 + un5 + un6 + un7 + un8 + un9 + un10;
        
        cout << "------------------------\n"
            << endl << stringarray << endl
            << id << endl
            << sec << " " << sec2 << endl
            << "\nGrade Status \n";
        
        if (gr1 >= 3.00)
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << endl << setw(7) << left << sub1 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr2 >= 3.00)
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub2 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr3 >= 3.00)
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub3 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr4 >= 3.00)
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub4 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr5 >= 3.00)
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub5 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr6 >= 3.00)
        {
            cout << setw(7) << left << sub6
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub6 
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr7 >= 3.00)
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub7
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr8 >= 3.00)
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub8
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr9 >= 3.00)
        {
            cout << setw(7) << left << sub9
            << setw(1) << ":   " << left << "Failed\n";
        }
        
        else
        {
            cout << setw(7) << left << sub9
            << setw(1) << ":   " << left << "Passed\n";
        }
        
        if (gr10 >= 3.00)
        {
            cout << setw(7) << left << sub10
            << setw(1) << ":   " << left << "Failed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
        
        else
        {
            cout << setw(7) << left << sub10
            << setw(1) << ":   " << left << "Passed\n";
            
            cout << endl << "Total Number of Units: " 
                << total_units << endl;
        }
    
    aggregate_grade = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
    gwa = aggregate_grade / total_units;
    cout << "\n------------------------\n"
        << "Academic Year "<< sy << endl
        << sem << " Semester \n"
        << endl << "GWA = " << gwa 
        << "\n------------------------\n";
    }
    
    else
    {
        cout << "\n------------------------\n"
        << "Invalid entry";
    }
    
    return 0;
    }
<a href="https://www.iubenda.com/privacy-policy/34674803" class="iubenda-white iubenda-noiframe iubenda-embed iubenda-noiframe " title="Privacy Policy ">Privacy Policy</a><script type="text/javascript">(function (w,d) {var loader = function () {var s = d.createElement("script"), tag = d.getElementsByTagName("script")[0]; s.src="https://cdn.iubenda.com/iubenda.js"; tag.parentNode.insertBefore(s,tag);}; if(w.addEventListener){w.addEventListener("load", loader, false);}else if(w.attachEvent){w.attachEvent("onload", loader);}else{w.onload = loader;}})(window, document);</script>
struct ScatteredBullet
		{
			DoubleBullet *pBullet1;
			DoubleBullet *pBullet2;
			DoubleBullet *pBullet3;
		};
	ScatteredBullet *pScatteredBullet = (struct ScatteredBullet*)malloc(sizeof(struct ScatteredBullet));
		DoubleBullet *pBullet1 = new DoubleBullet;
		DoubleBullet *pBullet2 = new DoubleBullet;
		DoubleBullet *pBullet3 = new DoubleBullet;
		pScatteredBullet->pBullet1 = pBullet1;
		pScatteredBullet->pBullet2 = pBullet2;
		pScatteredBullet->pBullet3 = pBullet3;
Grab up to 30% off on our blockchain fork development Services limited time Offer ends in November 25.

For the development of many business sectors, blockchain forks are essential. However, depending on the position, the process requires the use of technology. This is why we're going to look at some of the ways that cryptocurrencies can be developed, including forking existing blockchains to create new ones.

Hivelance, a leading blockchain fork development company, creates a customizable Blockchain Fork Development on various blockchain networks such as Ethereum, Tron, and Binance Smart Chain (BSC), allowing innovators to launch their businesses faster.

visit our site for know more-

https://www.hivelance.com/blockchain-forking
Black Friday sale : Grab up to 30% off on our NFT Token development Services limited time Offer ends in November 25.

Hivelance is a reputable NFT Token development business that works with clients from all over the world and across many industry sectors. We have developed secure, efficient, and revenue-generating NFT development solutions. Hivelance is a leading NFT token development company that offering a  top-notch innovative NFT token development solutions for various businesses across multiple industries. Being the best token development company we create and launch the different types of tokens according to the client’s requirement. We make engaging non-fungible token with transparency, high-end security, and faster delivery.

visit our website for more info-

https://www.hivelance.com/nft-token-development
Grab up to 30% off on our ERC20 Token development Services limited time Offer ends in November 25.

The ERC20 Token contract is the smart contract code logic that executes the fungible token activity. When a contract is put into practise on Ethereum, it can be exchanged for any tokens with a similar value. The ERC20 token standard is used for crypto staking, voting, and the exchange of digital cash as a result. Anyone can generate ERC20 tokens and import them into Ethereum virtual machines.

Hivelance provides ERC20 token development service.  We offer an alot of options as part of our ERC20 Token development package, such as code generation, logo design, an audit of the ERC token contract, deployment to the EVM, ongoing development, security audits at regular intervals, and more. We have supported various ICO projects and helped them scale up their fundraising efforts.

https://www.hivelance.com/erc20-token-development
class TrieNode{
    vector<TrieNode*> v;
    public:
    TrieNode(){
        v.resize(26,NULL);
    }
};

void push(string word,TrieNode* root){
    TrieNode* currRoot = root;
    for(char letter:word){
        if(currRoot->v[letter - 'a'] == NULL)
            currRoot->v[letter - 'a'] = new TrieNode();
        currRoot = currRoot->v[letter-'a'];
    }
}
#include <bits/stdc++.h>
using namespace std;
 

int main() {
    int t;
    cin>>t;
    vector<long long int> v1;
      vector<long long int> v2;
      v1.push_back(1);
      v2.push_back(1);
      long long int mod = 1e9 + 7;
      for(long long int i=1;i<1e6;i++)
      {
        //  v1.push_back(v1[i-1]+1);
          v2.push_back((v2[i-1]*(i+1))%mod);
      }
    while(t--)
    {
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
      }
      sort(a,a+n);
       long long int ans=0;
      
      
      for(int long long i=0;i<n;i++)
      {
          ans+=(v2[a[i]-1]%1000000007);
      }
      ans=ans%1000000007;
      cout<<ans<<"\n";
    }
	return 0;
}
class Solution{
	public:
	vector<int> downwardDigonal(int n, vector<vector<int>> a)
	{
	    vector<int> v;
		for(int j=0;j<n;j++)
		{
		    int i=0,k=j;
		    while(i<n && k>=0)
		    {
		        v.push_back(a[i][k]);
		        i++;
		        k--;
		    }
		}
		for(int i=1;i<n;i++)
		{
		    int j=i,k=n-1;
		    while(j<n && k>=0)
		    {
		        v.push_back(a[j][k]);
		        j++;
		        k--;
		    }
		}
		return v;
	}
};
#include <iostream>
using namespace std;

void write_vertical(int n);

int main()
{
    int n;
    
    cout << "Recursion" << endl
        << "Enter a number with one or more digits: ";
    cin >> n;
    cout << "--------------------------------------" << endl;
    write_vertical(n);
    
    return 0;
}

void write_vertical(int n)
{
    if (n < 10)
    {
        cout << n << endl;
    }
    else
    {
        write_vertical(n / 10);
        cout << (n % 10) << endl;
    }
}
class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        int n1=strs.size();
        int ans=strs[0].length();
        for(int i=1;i<n1;i++)
        {
            int j=0;
            while(j<strs[i].size() && strs[i][j]==strs[0][j])
            {
                j++;
                
            }
            ans=min(ans,j);
        }
        return strs[0].substr(0,ans);
    }
};
class Solution {
public:
    int romanToInt(string s) {
        
        map<char,int>mp;
        mp['I']=1;
        mp['V']=5;
        mp['X']=10;
        mp['L']=50;
        mp['C']=100;
        mp['D']=500;
        mp['M']=1000;
       
        int n=s.size(),num,sum=0;
        for(int i=0;i<n;i++)
        {
            if(mp[s[i]]<mp[s[i+1]])
            {
                sum-=mp[s[i]];
            }
            else 
            {
                sum+=mp[s[i]];
            }
        }
        
        return sum;
    }
};
class Solution
{   
    public:
    //Function to modify the matrix such that if a matrix cell matrix[i][j]
    //is 1 then all the cells in its ith row and jth column will become 1.
    void booleanMatrix(vector<vector<int> > &matrix)
    {
       
        int n1=matrix.size();
        int n2=matrix[0].size();
        vector<pair<int,int>> v;
        for(int i=0;i<n1;i++)
        {
            for(int j=0;j<n2;j++)
            {
                if(matrix[i][j]==1) 
                {
                    v.push_back({i,j});
                    
                }
            }
        }
        int n3=v.size();
        for(int i=0;i<n3;i++)
        {
            for(int j=0;j<n2;j++)
            {
                matrix[v[i].first][j]=1;
            }
            for(int j=0;j<n1;j++)
            {
                matrix[j][v[i].second]=1;
            }
        }
    }
};
class Solution
{   
    public: 
    //Function to return a list of integers denoting spiral traversal of matrix.
    vector<int> spirallyTraverse(vector<vector<int> > matrix, int r, int c) 
    {
        
        int l=0;
        int ri=c-1;
        int u=0;
        int d=r-1;
        
        vector<int>v;
        while(l<=ri && u<=d)
        {
            for(int i=l;i<=ri;i++)
            {
                v.push_back(matrix[u][i]);
            }
            u++;
            
            for(int i=u;i<=d;i++)
            {
                v.push_back(matrix[i][ri]);
            }
            ri--;
            
            if(u<=d)
            {
                for(int i=ri;i>=l;i--)
                {
                    v.push_back(matrix[d][i]);
                }
                
                d--;
            }
            
            if(l<=ri)
            {
                for(int i=d;i>=u;i--)
                {
                    v.push_back(matrix[i][l]);
                }
                l++;
            }
        }
        return v;
    }
};
class Solution
{
    public:
    //Function to search a given number in row-column sorted matrix.
    bool search(vector<vector<int> > matrix, int n, int m, int x) 
    {
        int long long i=0,j=m-1;
        while(i<n && j>=0&& j<n&&i>=0)
        {
            if(matrix[i][j]==x) return 1;
            else if(matrix[i][j]>=x) j--;
            else i++;
        }
        return 0;
    }
};
#include <bits/stdc++.h>
using namespace std;

int main() 
{
    int t;
    cin>>t;
    while(t--)
    {
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++)
      {
         cin>>a[i];
      }
      unordered_map<int,int> m1;
      for(int i=0;i<n;i++)
      {
         m1[a[i]]++;
      }
      priority_queue<pair<int,int>> maxH;
      for(auto x:m1)
      {
         maxH.push({x.second,-1*(x.first)});
      }
      while(!maxH.empty())
      {
         int freq=maxH.top().first;
         int ele=-1*(maxH.top().second);
         for(int i=0;i<freq;i++)
         {
            cout<<ele<<" ";
         }
         maxH.pop();
      }
      cout<<"\n";
    }
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
     int n;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++)
     {
        cin>>a[i];
     }
     srand(time(0));
     for(int i=n-1;i>=0;i--)
     {
        int j=rand()%(i+1);
        swap(a[j],a[i]);
     }
     for(int i=0;i<n;i++)
     {
        cout<<a[i]<<" ";
     }
	return 0;
}
public:
    // Function to find equilibrium point in the array.
    // a: input array
    // n: size of array
    int equilibriumPoint(long long a[], int n) {
    long long p=0;
    for(int i=0;i<n;i++)
    {
        p+=a[i];
    }
    long long a1[n];
    long long a2[n];
    a1[0]=-1;
    a2[n-1]=-1;
    int p1=0;
    int p2=0;
    for(int i=1;i<n;i++)
    {
        p1+=a[i-1];
        a1[i]=p1;
    }
    for(int i=n-2;i>=0;i--)
    {
        p2+=a[i+1];
        a2[i]=p2;
    }
    for(int i=0;i<n;i++)
    {
        if(a1[i]==a2[i])
        {
            return i+1;
        }
    }
    return -1;
xargs rm < install_manifest.txt
#include<iostream>

class A1{
    void f1() { std::cout << "print f1" << std::endl; }
    public:
    void f2() { std::cout << "print f2" << std::endl; }
    void f5() { f1(); }
    protected:
    void f3() { std::cout << "print f3" << std::endl; }
};

class A2 : public A1{
    public:
    void f4() { f3(); }
};

int main(){
    A1 obj;
    A2 obj1;
    obj1.f4();
    obj1.f2();
    obj1.f5();
    obj.f2();
    obj.f5();
    return 0;
}
class Solution {
public:
    vector<string> twoEditWords(vector<string>& q, vector<string>& d) {
        int n1=d.size();
        int n2=q.size();
        int k=q[0].size();
        vector<string>v;
        set<int> idx;
        for(int i=0;i<n2;i++)
        {
            for(int j=0;j<n1;j++)
            {
                int c=0;
                for(int h=0;h<k;h++)
                {
                    if(d[j][h]!=q[i][h]) c++;
                }
                if(c<=2) idx.insert(i);
            }
        }
        for(auto x:idx)
        {
           v.push_back(q[x]) ;
        }
        return v;
    }
};
class Solution {
public:
    string oddString(vector<string>& words) {
        int n1=words.size();
        int k = words[0].size();
        map<vector<int>, int> m;
        vector<vector<int>> v;
        for(int i=0;i<n1;i++)
        {
            //int n2=words[i].length();
            vector<int> a(k-1,0);
            //a[k-1]=i;
            for(int j=0;j<k-1;j++)
            {
                a[j]=words[i][j+1]-words[i][j];
                
            }
            v.push_back(a);
            m[a]++;
        }
        vector<int>v2;
        string s;
        for(auto x:m)
        {
            if(x.second==1)
            {
                for(int i=0;i<x.first.size();i++)
                {
                    v2.push_back(x.first[i]);
                }
                break;
            }
        }
        for(int i=0;i<n1;i++)
        {
            if(v[i]==v2)
            {
                s=words[i];
            }
        }
        
        return s;
    }
};
class Solution{
    public:
    //Complete this function
    //Function to check whether there is a subarray present with 0-sum or not.
    bool subArrayExists(int arr[], int n)
    {
        int pref_sum=0;
        unordered_set<int> s;
        for(int i=0;i<n;i++)
        {
            pref_sum+=arr[i];
            if(pref_sum==0) return true;
            if(s.find(pref_sum)!=s.end()) return true;
            s.insert(pref_sum);
        }
        return false;
        //Your code here
    }
};
#include <iostream>

void initialize_screen();
double celsius(double fahrenheit);
void show_results(double f_degrees, double c_degrees);

int main()
{
    using namespace std;
    double f_temperature, c_temperature;
    
    initialize_screen();
    cout << "I will convert a Fahrenheit temperature "
        << "to Celsius.\n"
        << "Enter a temperature in  Fahrenheit: ";
    cin >> f_temperature;
    
    c_temperature = celsius(f_temperature);
    
    show_results(f_temperature, c_temperature);
    return 0;
}

void initialize_screen()
{
    using namespace std;
    cout << endl;
    return;
}

double celsius(double fahrenheit)
{
    return ((5.0/9.0)*(fahrenheit - 32));
    
}

void show_results(double f_degrees, double c_degrees)
{
    using namespace std;
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    cout << f_degrees
        << " degrees Fahrenheit is equivalent to\n"
        << c_degrees << " degrees Celsius.\n";
    return;
}
class Solution{
  public:
  
    vector<int> find3Numbers(vector<int> arr, int n) {
        // Your code here
        vector<int>v;
        int min=0;
        int max=n-1;
        int* smaller=new int[n];
        int* greater=new int[n];
        smaller[0]=-1;
        greater[n-1]=-1;
        for(int i=1;i<n;i++)
        {
            if(arr[i]<=arr[min])
            {
                min=i;
                smaller[i]=-1;
            }
            else smaller[i]=min;
        }
        for(int i=n-2;i>=0;i--)
        {
            if(arr[i]>=arr[max])
            {
                max=i;
                greater[i]=-1;
            }
            else greater[i]=max;
        }
        for(int i=0;i<n;i++)
        {
            if(smaller[i]!=-1 && greater[i]!=-1)
            {
                v.push_back(arr[smaller[i]]);
                v.push_back(arr[i]);
                v.push_back(arr[greater[i]]);
                break;
            }
        }
        delete[] greater;
        delete[] smaller;
        return v;
    }
};
#include<iostream>

class baseClass{
    public:
    void a() {std::cout << "Base class atau Parent class" << std::endl;}
};

class derivedClass : public baseClass{
    public:
    void b() {std::cout << "Derived class atau Child class" << std::endl;}
};

int main(){
    derivedClass obj;
    obj.a();
    obj.b();
    return 0;
}
#include<iostream>

struct A {
    void a();
};

void A::a() {std::cout << "Fungsi dari struct A" << std::endl;}

class B {
    public:
    void b();
    struct A c;
};

void B::b() {std::cout << "Fungsi dari class B" << std::endl;}

int main(){
    B obj;
    obj.b();
    obj.c.a();
    return 0;
}
#include<iostream>
// mendeklarasikan class
class A;
// mendefinisikan class
class A{
    public:
    int a;
    void b() {std::cout << "nilai a = " << a << std::endl;}
};

int main(){
    A obj;
    obj.a = 5;
    obj.b();
    return 0;
}
#include<iostream>
// mendeklarasikan struct
struct A;
// mendefinisikan struct 
struct A {
    int a;
    void b() { std::cout << "nilai a = " << a << std::endl;}
};

int main(){
    struct A test;
    test.a = 5;
    test.b();
    return 0;
}
class Solution {
public:
    int countPairs(vector<int>& nums, int k) {
        int n=nums.size();
        int c=0;
        for(int i=0;i<n-1;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                int p=i*j;
                if(nums[i]==nums[j]&&p%k==0) c++;
            }
        }
        return c;
    }
};
class Solution {
public:
    vector<vector<int>> flipAndInvertImage(vector<vector<int>>& a) {
        int n=a.size();
        for(int i=0;i<n;i++)
        {
           reverse(a[i].begin(),a[i].end());
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]==0) a[i][j]=1;
                else a[i][j]=0;
            }
        }
        return a;
    }
};
class Solution {
public:
    int countGoodTriplets(vector<int>& arr, int a, int b, int c) {
         int ans=0;
        int n=arr.size();
        for(int i=0;i<n-2;i++)
        {
            for(int j=i+1;j<n-1;j++)
            {
                for(int k=j+1;k<n;k++)
                {                                                                                                       if(abs(arr[i]-arr[j])<=a && abs(arr[j]-arr[k])<=b && abs(arr[i]-arr[k])<=c)
                    {
                        ans++;
                    }
                }
            }
        }
        return ans;
    }
};
class Solution{
  public:
    vector<int> find3Numbers(vector<int> arr, int N) {
        // Your code here
        vector<int>v;
        int left=INT_MAX;
        int mn=left;
        int mid=INT_MAX;
        if(N<3) 
        {
            return {};
        }
        for(int i=0;i<N;i++)
        {
            if(arr[i]<left) 
            {
                left=arr[i];
            }
            else if(arr[i]>left&&arr[i]<mid)
            {
                mid=arr[i];
                mn=left;
            }
            else if(arr[i]>mid) 
            {
                v.push_back(mn);
                v.push_back(mid);
                v.push_back(arr[i]);
                return v;
            }
        }
        return {};
    
    }
};
#include <iostream>
using namespace std;

const int MAX_SIZE = 20;

void readNumber(int number[], int &count)
{
	char ch;

	cin.get(ch);
	while (ch != '\n' && count < MAX_SIZE)
	{
		number[count] = ch - '0';
		count++;

		cin.get(ch);
	}
}

void reverseDigits(int number[], int count)
{
	int i = 0;
	int j = count - 1;

	while (i < j)
	{
		int temp = number[i];
		number[i] = number[j];
		number[j] = temp;

		i++;
		j--;
	}
}

bool addNumbers(int number1[], int count1, int number2[], int count2,
		int result[], int &size)
{
	int sum = 0;
	int carry = 0;
	int i = 0;
	int j = 0;

	while (i < count1 && j < count2 && size < MAX_SIZE)
	{
		sum = number1[i] + number2[j] + carry;

		if (sum > 9)
		{
			carry = sum / 10;
			sum = sum % 10;
		}
		else
		{
			carry = 0;
		}

		result[size] = sum;
		size++;
		i++;
		j++;

		if(carry != 0 && size == MAX_SIZE)
			return false;
	}

	while (i < count1 && size < MAX_SIZE)
	{
		sum = number1[i] + carry;

		if (sum > 9)
		{
			carry = sum / 10;
			sum = sum % 10;
		}
		else
		{
			carry = 0;
		}

		result[size] = sum;
		size++;
		i++;

		if(carry != 0 && size == MAX_SIZE)
			return false;
	}

	while (j < count2 && size < MAX_SIZE)
	{
		sum = number2[j] + carry;

		if (sum > 9)
		{
			carry = sum / 10;
			sum = sum % 10;
		}
		else
		{
			carry = 0;
		}

		result[size] = sum;
		size++;
		j++;

		if(carry != 0 && size == MAX_SIZE)
			return false;
	}

	if (carry > 0)
	{
		result[size] = carry;
		size++;
	}

	return true;
}

void printNumber(int number[], int count)
{
	for (int i = count - 1; i >= 0; i--)
	{
		cout << number[i];
	}
}

int main()
{
	int number1[MAX_SIZE];
	int number2[MAX_SIZE];
	int result[MAX_SIZE];
	int count1 = 0;
	int count2 = 0;
	int size = 0;

	cout << "Enter the first number:  ";
	readNumber(number1, count1);

	cout << "Enter the second number: ";
	readNumber(number2, count2);

	reverseDigits(number1, count1);
	reverseDigits(number2, count2);

	bool success = addNumbers(number1, count1, number2, count2, result, size);

	if(success)
	{
		cout << endl;
		printNumber(number1, count1);
		cout << " + ";
		printNumber(number2, count2);
		cout << " = ";
		printNumber(result, size);
		cout << endl;
	}
	else
	{
		cout << "integer overflow" << endl;
	}

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

string IntToString(int arr[], int k){
	string ans;

	for(int i = 0;i<k;i++){
		ans+= to_string(arr[i]);
	}
	return ans;
}

void StringToInt(string s){
	vector<int>v;
	map<int, int> mp;
	for(int i = 0;i<s.length();i++){
		v.push_back(s[i]-'0');
	}
	sort(v.begin(), v.end());
	for(int i = 0;i<v.size();i++){
		mp[v[i]]++;
	}
	cout<<"counting the frequency : \n";
	for(auto i:mp){
			cout<<i.first<<" "<<i.second<<endl;
	}
}

int main(){
	string s = "123343233434435";
	int brr[] = {2,3,4,5,6,7};
	int n = sizeof(brr)/sizeof(brr[0]);
	cout<<IntToString(brr, n)<<endl;
	StringToInt(s);
	return 0;
}
class Solution
{
    public:
    long long countKdivPairs(int A[], int n, int K)
    {
        //code here
        long ans=0;
        unordered_map<int,int>m;
        for(int i=0;i<n;i++)
        {
            int rem=A[i]%K;
            if(rem!=0)
            {
                ans+=m[K-rem];
            }
            else ans+=m[0];
            m[rem]++;
        }
        return ans;
    }
};
class Solution
{
    public:
    //Function to return the lowest common ancestor in a Binary Tree.
    Node* lca(Node* root,int n1,int n2 )
    {
        if(root==NULL) return NULL;
        if(root->data==n1 || root->data==n2) return root;
        
        Node* left=lca(root->left,n1,n2);
        Node* right=lca(root->right,n1,n2);
         
         if(left==NULL) return right;
         if(right==NULL) return left;
         return root;
        
       //Your code here 
    }
};
class Solution {
  public:
    // Function to return the count of the number of elements in
    // the intersection of two arrays.
    int NumberofElementsInIntersection(int a[], int b[], int n, int m) {
        // Your code goes here
        unordered_map<int,int> s,t;
        int ans=0;
        for(int i=0;i<n;i++)
        {
            s[a[i]]++;
        }
        for(int i=0;i<m;i++)
        {
            t[b[i]]++;
        }
        for(auto x:s)
        {
            if(t.count(x.first)>0)
            {ans++;}
        }
        return ans;
    }
};
class Solution {
public:
    int arithmeticTriplets(vector<int>& nums, int diff) {
        int n=nums.size();
        set<int> s(nums.begin(),nums.end());
        int ans=0;
        for(int i=0;i<n;i++)
        {
            if(s.find(nums[i]-diff)!=s.end() && s.find(nums[i]-2*diff)!=s.end())
            {
                ans++;
            }
        }
        return ans;
    }
};
class Solution {
public:
    int maxfind(vector<vector<int>>& grid, int i, int j)
    {
        int maxa=INT_MIN;
        for(int x=i;x<i+3;x++)
        {
            for(int y=j;y<j+3;y++)
            {
                maxa = max(grid[x][y],maxa);
            }
        }
        return maxa;
    }
    vector<vector<int>> largestLocal(vector<vector<int>>& grid) {
        int n=grid.size();
        vector<vector<int>> v(n-2, vector<int>(n-2));
        for(int i=0;i<n-2;i++)
        {
            for(int j=0;j<n-2;j++)
            {
                v[i][j]=maxfind(grid, i ,j);
            }
        }
        return v;
    }
};
class Solution {
public:
    string reversePrefix(string word, char ch) {
        int n=word.size();
        int r=0;
        for(int i=0;i<n;i++)
        {
            if(word[i]!=ch)
            {
                r++;
            }
            else break;
        }
        if(r==n) return word;                                                                               reverse(word.begin(),word.begin()+r+1);
        return word;
    }
};
class Solution {
public:
    string firstPalindrome(vector<string>& words) {
        int n=words.size();
        
        string temp="";
        for(int i=0;i<n;i++)
        {
            temp="";
            int n1=words[i].size();
            temp=words[i];
            for(int j=0;j<n1/2;j++)
            {
                swap(temp[j],temp[n1-j-1]);
            }
            if(temp==words[i])
            {
               return words[i];
            }
            else temp="";
        }
    return temp;
    }
};
class Solution
{
    public:
    //Function to reverse words in a given string.
    string reverseWords(string S) 
    { 
       int n=S.size();
       stack<string>st;
       string si="";
       for(int i=0;i<n;i++)
       {
           if(S[i]=='.')
           {
               st.push(si);
               st.push(".");
               si="";
           }
           else { si+=S[i];}
       }
       st.push(si);
       string an="";
       int t=st.size();
       for(int i=0;i<t;i++)
       {
           an.append(st.top());
           st.pop();
       }
       return an;
    } 
};
class Solution {
public:
    string replaceDigits(string s) {
        int n=s.size();
        string p="";
        for(int i=0;i<n;i++)
        {
            if((s[i]-'0')>=0 && (s[i]-'0')<=9)
            {
                p+=(s[i-1]+(s[i]-'0'));
                
            }
            else 
            {
                p+=s[i];
            }
        }
        return p;
    }
};
class Solution {
public:
    int numOfStrings(vector<string>& patterns, string word) {
        int c=0;
        for(int i=0;i<patterns.size();i++)
        {
            if(word.find(patterns[i])!=-1) c++;
        }
        return c;
    }
};
class Solution {
public:
    string removeOuterParentheses(string s) 
    {
        int n=s.size();
        int j=0;
        string p="";
        for(int i=0;i<n;i++)
        {
            if(s[i]==41)
            {
                j--;
            }
            if(j!=0) 
            {
                p+=s[i];
            }
            if(s[i]==40)
            {
                j++;
            }
            
        }
        return p;
    }
};
class Solution {
public:
    bool checkIfPangram(string s) {
        int n=s.size();
        vector<bool> v(26,false);
        if(n<26) return false;
        else if(n>=26)
        {
            for(int i=0;i<n;i++)
            {
                v[s[i]-'a']=true;
            }
        }
        for(int i=0;i<26;i++)
        {
            if(v[i]==false) return false;
        }
        return true;
    }
};
class Solution {
public:
    string reverseWords(string s) {
        int n=s.size();
        int l=0,r=0;
        while(l<n)
        {
            while(r<n && s[r]!=' ')
            {
               r++;
            }
            reverse(s.begin()+l,s.begin()+r);
            l=r+1;
            r=l;
        }
        return s;
    }
};
class Solution {
public:
    int countPoints(string ri) {
        int n=ri.size();
        vector<bool> r(10,false);
        vector<bool> g(10,false);
        vector<bool> b(10,false);
        for(int i=1;i<n;i=i+2)
        {
            if(ri[i-1]=='R')
            {
                r[ri[i]-'0']=true;
            }
            else if(ri[i-1]=='G')
            {
                g[ri[i]-'0']=true;
            }
            else  if(ri[i-1]=='B')
            {
                b[ri[i]-'0']=true;
            }
        }
        int c=0;
        for(int i=0;i<10;i++)
        {
            if(r[i]==true && g[i]==true && b[i]==true)
            {
                c++;
            }
        }
        return c;
    }
};
class Solution {
public:
    int countConsistentStrings(string allowed, vector<string>& words) {
        int n1=allowed.size();
        int n2=words.size();
        int ans=0;
        for(int i=0;i<n2;i++)
        {
            int n3=words[i].size();
            int ci=0;
            for(int j=0;j<n3;j++)
            {
                bool f=false;
                for(int k=0;k<n1;k++)
                {
                    if(words[i][j]==allowed[k])
                    {
                        f=true;
                        break;
                    }
                }
                if(f==true) ci++;
            }
            if(ci==n3) ans++;
            
        }
        return ans;
    }
};
class Solution {
public:
    string toLowerCase(string s) {
        int n=s.size();
        string s1="";
        for(int i=0;i<n;i++)
        {
            if(int(s[i])>=65 && int(s[i])<=90)
            {
                s1+=s[i]+32;
                continue;
            }
            s1+=s[i];
        }
        return s1;
    }
};
class Solution {
public:
    int uniqueMorseRepresentations(vector<string>& words) {
        unordered_map<char,string> mp;
        mp['a']=".-";
        mp['b']="-...";
        mp['c']="-.-.";
        mp['d']="-..";
        mp['e']=".";
        mp['f']="..-.";
        mp['g']="--.";
        mp['h']="....";
        mp['i']="..";
        mp['j']=".---";
        mp['k']="-.-";
        mp['l']=".-..";
        mp['m']="--";
        mp['n']="-.";
        mp['o']="---";
        mp['p']=".--.";
        mp['q']="--.-";
        mp['r']=".-.";
        mp['s']="...";
        mp['t']="-";
        mp['u']="..-";
        mp['v']="...-";mp['w']=".--";mp['x']="-..-";mp['y']="-.--";mp['z']="--..";
        set<string> s;
        int n=words.size();
        for(int i=0;i<n;i++)
        {
            int n1=words[i].size();
            string s1="";
            for(int j=0;j<n1;j++)
            {
                s1.append(mp[words[i][j]]);
            }
            s.insert(s1);
            
        }
        return s.size();
        
        
        
    }
};
class Solution {
public:
    vector<string> sortPeople(vector<string>& names, vector<int>& heights) {
        int n=names.size();
        map<int,string> mp;
        for(int i=0;i<n;i++)
        {
            mp[heights[i]]=names[i];
        }
        vector<string> v;
        map<int,string>::iterator i;
        for(auto i=mp.begin();i!=mp.end();i++)
        {
            v.push_back(i->second);
            
        }
        reverse(v.begin(),v.end());
        return v;
    }
};
class Solution {
public:
    int countMatches(vector<vector<string>>& items, string ruleKey, string ruleValue) {
        int n=items.size();
        int p=3;
        int i;
        int c=0;
        if(ruleKey=="type")
        {
            i=0;
            for(int j=0;j<n;j++)
            {
                if(items[j][i]==ruleValue)
                {c++;}
            }
        }
        else if(ruleKey=="color")
        {
            i=1;
            for(int j=0;j<n;j++)
            {
                if(items[j][i]==ruleValue) {c++;}
            }
        }
        else if(ruleKey=="name")
        {
            i=2;
            for(int j=0;j<n;j++)
            {
                if(items[j][i]==ruleValue) {c++;}
            }
        }
        return c;
    }
};
class Solution {
public:
    vector<string> cellsInRange(string s) {
        char c1=s[0], r1=s[1], c2=s[3], r2=s[4];
        vector<string> v;
        for(int i=0;i+c1<=c2;i++)
        {
            for(int j=0;j+r1<=r2;j++)
            {
                string p;
                p+=(c1+i);
                p+=(r1+j);
                v.push_back(p);
            }
        }
        return v;
    }
};
for(int i=0;i<n;i++){
  //do something
}
#include <Windows.h>
#include <TlHelp32.h>
#include <tchar.h>
#include <vector>
#include <stdlib.h>
#include <iostream>

using namespace std;

DWORD GetModuleBaseAddress(TCHAR* lpszModuleName, DWORD pID) {
    DWORD dwModuleBaseAddress = 0;
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pID); // make snapshot of all modules within process
    MODULEENTRY32 ModuleEntry32 = { 0 };
    ModuleEntry32.dwSize = sizeof(MODULEENTRY32);

    if (Module32First(hSnapshot, &ModuleEntry32)) //store first Module in ModuleEntry32
    {
        do {
            if (_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0) // if Found Module matches Module we look for -> done!
            {
                dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
                break;
            }
        } while (Module32Next(hSnapshot, &ModuleEntry32)); // go through Module entries in Snapshot and store in ModuleEntry32


    }
    CloseHandle(hSnapshot);
    return dwModuleBaseAddress;
}

DWORD GetPointerAddress(HWND hwnd, DWORD gameBaseAddr, DWORD address, vector<DWORD> offsets)
{
    DWORD pID = NULL; // Game process ID
    GetWindowThreadProcessId(hwnd, &pID);
    HANDLE phandle = NULL;
    phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
    if (phandle == INVALID_HANDLE_VALUE || phandle == NULL);

    DWORD offset_null = NULL;
    ReadProcessMemory(phandle, (LPVOID*)(gameBaseAddr + address), &offset_null, sizeof(offset_null), 0);
    DWORD pointeraddress = offset_null; // the address we need
    for (int i = 0; i < offsets.size() - 1; i++) // we dont want to change the last offset value so we do -1
    {
        ReadProcessMemory(phandle, (LPVOID*)(pointeraddress + offsets.at(i)), &pointeraddress, sizeof(pointeraddress), 0);
    }
    return pointeraddress += offsets.at(offsets.size() - 1); // adding the last offset
}

int main()
{
    HWND hwnd_Chaos = FindWindowA(NULL, "Chaos");
    if (hwnd_Chaos != FALSE);
    DWORD pID = NULL;
    GetWindowThreadProcessId(hwnd_Chaos, &pID);
    HANDLE phandle = NULL;
    phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
    if (phandle == INVALID_HANDLE_VALUE || phandle == NULL);

    char gamemodule1[] = "ChaosGame424-Win64-Shipping.exe";
    DWORD gamebaseadress1 = GetModuleBaseAddress(_T(gamemodule1), pID);

    //Ammo
    DWORD ammoAddr = 0x035CC570;
    vector<DWORD> ammoOffsets{ 0x10, 0x20, 0x50, 0x298, 0xE0, 0x248, 0x974 };
    DWORD ammoPtrAddr = GetPointerAddress(hwnd_Chaos, gamebaseadress1, ammoAddr, ammoOffsets);

    //Write the memory finally 
    while (true)
    {
        int ammo = 1000;
        WriteProcessMemory(phandle, (LPVOID*)(ammoPtrAddr), &ammo, 4, 0);
        cout << "test";

    }
}

class Solution {
  public:
    int findTime(string S1, string S2) {
        // code here
        int n=S1.size();
        int m=S2.size();
        unordered_map<char,int>mp;
        for(int i=0;i<n;i++)
        {
            mp[S1[i]]=i;
        }
        int ans=0;
        int temp=0;
        for(int j=0;j<m;j++)
        {
            int b=mp[S2[j]];
            ans+=abs(b-temp);
            temp=b;
        }
        return ans;
    }
};
class Solution {
public:
    string restoreString(string s, vector<int>& indices) {
        int n=s.size();
        vector<char> S(n);
        for(int i=0;i<n;i++)
        {
            S[indices[i]]=s[i];
        }
        string s1="";
        for(int i=0;i<n;i++)
        {
           s1=s1+S[i] ;
        }
        return s1;
    }
};
class Solution {
public:
    vector<int> decode(vector<int>& encoded, int first) {
        vector<int>v;
        int n=encoded.size();
        v.push_back(first);
        for(int i=0;i<n;i++)
        {
            int x=encoded[i]^v[i];
            v.push_back(x);
        }
        return v;
    }
};
class Solution {
public:
    int countWords(string str)
{
    // Breaking input into word
    // using string stream
   
    // Used for breaking words
    stringstream s(str);
   
    // To store individual words
    string word;
 
    int count = 0;
    while (s >> word)
        count++;
    return count;
}
    int mostWordsFound(vector<string>& sen) {
        int n=sen.size();
        int maxi=INT_MIN;
        for(int i=0;i<n;i++)
        {
            maxi=max(maxi,countWords(sen[i]));
        }
       return maxi;
    }
};
#include<bits/stdc++.h>
#include <fstream>
#include <sstream>
#include <sys/stat.h>
#include <sys/time.h>
#include <vector>
#include <cstdio>
#include<time.h>
#include<stdio.h>
#define ll long long int

using namespace std;

struct Node
{
	ll data;
	ll  index;
};

class PriorityQueue
{
public:
	int size;
	Node * pq = new Node [1000000];
	PriorityQueue()
	{
		size = 0;
	}

	bool isEmpty()
	{
		return size == 0;
	}

	int getSize()
	{
		return size;
	}
	Node getMin()
	{
		if (isEmpty())
		{
			return {0, 0};
		}
		return pq[0];
	}
	Node top()
	{
		return pq[0];
	}

	void display()
	{
		for (int i = 0; i < size; ++i)
		{
			cout << pq[i].data << " ";
		}
		cout << endl;
	}


	void insert(Node element)
	{
		pq[size] = element;
		size++;
		int childIndex = size - 1;
		while (childIndex > 0)
		{
			int parentIndex = (childIndex - 1) / 2;
			if (pq[childIndex].data < pq[parentIndex].data)
			{
				swap(pq[childIndex] , pq[parentIndex]);
			}
			else
			{
				break;
			}
			childIndex = parentIndex;
		}
	}

	Node  removeMin()
	{
		if (isEmpty())
			return { -1, -1};
		Node min = pq[0];
		pq[0] = pq[size - 1];
		size = size - 1;

		//down-heapify
		int parentIndex = 0;
		int leftChildIndex = 2 * parentIndex + 1;
		int rightChildIndex = 2 * parentIndex + 2;

		while (leftChildIndex <  size)
		{
			int minIndex = parentIndex;
			if (pq[minIndex].data > pq[leftChildIndex].data)
			{
				minIndex = leftChildIndex;
			}
			if (rightChildIndex < size && pq[rightChildIndex].data < pq[minIndex].data)
			{
				minIndex = rightChildIndex;
			}
			if (minIndex == parentIndex)
			{
				break;
			}
			swap(pq[minIndex], pq[parentIndex]);

			parentIndex = minIndex;
			leftChildIndex = 2 * parentIndex + 1;
			rightChildIndex = 2 * parentIndex + 2;
		}
		return min;
	}
};



void chunk_division(string inputFile, string outputFile, vector<string>&store_temp_file_names)
{
	long long int chunk_size = 255; //1000000;
	ll max_num_of_elements = 0;
	cout << "Number of integers in a temporary file : " << chunk_size << endl;

	ifstream in(inputFile);
	ll inp;
	while (!in.eof())
	{
		in >> inp;
		max_num_of_elements++;
	}
	in.close();

	cout << "maximum number of elements :" << max_num_of_elements << endl;

	ll num_of_chunks = max_num_of_elements / chunk_size;
	ll last_chunk_size =  max_num_of_elements % chunk_size;

	if (last_chunk_size != 0)
		num_of_chunks++;
	else
		last_chunk_size = chunk_size;
	cout << "Number of temporary files created : " << num_of_chunks << endl;

	in.open(inputFile);

	for (ll chunk = 0; chunk < num_of_chunks; ++chunk)
	{
		vector<int>data;
		long long int  value;
		for (ll i = 0; i < chunk_size; ++i)
		{
			if (!in.eof()) //until reaches end of file
			{
				in >> value;
				data.push_back(value); //endl lagana padega to get similar to file
			}
		}
		sort(data.begin(), data.end());

		string fileName = "./q2/a/chunk" + to_string(chunk) + ".txt";
		store_temp_file_names.push_back(fileName);

		ofstream out;
		out.open(fileName);

		for (ll x = 0; x < data.size(); x++)
		{
			out << data[x] << endl;
		}
		out.close();
	}
	in.close();


	ofstream out2;
	out2.open(outputFile);

	ifstream file[store_temp_file_names.size()];
	for (int i = 0; i < store_temp_file_names.size(); ++i)
		file[i].open(store_temp_file_names[i]);


	int flag = 1;
	ll value;
	PriorityQueue p;
	for (ll x = 0; x < max_num_of_elements; ++x)
	{
		if (flag == 1)
		{
			for (ll i = 0; i < store_temp_file_names.size(); ++i)
			{
				file[i] >> value;
				ifstream *file1;
				file1 = new ifstream(store_temp_file_names[i].c_str(), std::ios::in);
				p.insert({value , i});
			}
			flag = 0;
		}
		// cout << "before insert\n";
		// p.display();
		if (!p.isEmpty())
		{
			Node ele = p.removeMin();

			out2 << ele.data << endl;
			// cout << "mindata: " << ele.data << endl;

			ll k;
			if (file[ele.index] >> k)
			{
				p.insert({k, ele.index});
				// cout << "chuck" << ele.index << "->  data :" << k << endl;
			}
		}
		// cout << "after insert\n ";
		// p.display();
		// cout << "\n\n";
	}
	for (int i = 0; i < store_temp_file_names.size(); ++i)
		file[i].close();
	out2.close();
}

void delete_temp_chunks(vector<string>store_temp_file_names)
{
	for (int i = 0; i < store_temp_file_names.size(); ++i)
		remove(store_temp_file_names[i].c_str());
}

int main(int argv , char**argc)
{
#ifdef ONLINE_JUDGE
	freeopen("input.txt", "r", stdin);
	freeopen("output.txt", "r", stdin);
#endif
	ll tick1 = clock();

	// if (argv != 3)
	// {
	// 	cout << "wrong cmd , do again like:\n ./a.out ./data/input.txt ./data/output.txt";
	// }



	// string inputFile = "./q2/input.txt" ;
	// string outputFile = "./q2/output.txt" ;


	string inputFile =   argc[1];
	string outputFile =   argc[2] ;



	vector<string>store_temp_file_names;

	chunk_division(inputFile, outputFile, store_temp_file_names );

	delete_temp_chunks(store_temp_file_names);

	ll tick2 = clock();
	ll elapsed = tick2 - tick1;
	double elapsed_time = (double) elapsed / CLOCKS_PER_SEC;
	cout << elapsed_time   << " sec" << endl;
	return 0;
}
#include <iostream>
#include <cmath>
using namespace std;

double unitprice(int diameter, double price) {
    const double PI = 3.14159;
    double radius, area;
    
    radius = diameter / static_cast <double> (2);
    area = PI * radius * radius;
    return (price/area);
}

double unitprice(int length, int width, double price) {
    double area = length * width;
    return (price/area);
}

int main() {
    
    int diameter, length, width;
    double price_round, unitprice_round,
        price_rectangular, unitprice_rectangular;
    
    cout << "Please enter the diameter of the round cake: ";
    cin >> diameter;
    cout << "Please enter the price of the round piza: $";
    cin >> price_round;
    cout << "Please enter the length and width of the rectangular\n"
        << "cake in inches: ";
    cin >> length >> width;
    cout << "Please enter the price of the rectangular cake: $";
    cin >> price_rectangular;
    
    unitprice_rectangular = unitprice(length, width, price_rectangular);
    unitprice_round = unitprice(diameter, price_round);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    cout << "-------------------------------------\n"
        << "I see... \n";
    
    if (unitprice_round < unitprice_rectangular) {
        cout << "Seems like the round cake is the better option,\n";
        cout << "I suggest you buy it.\n";
    }
    
    else 
    {
        cout << "Seems like the rectangular one is the better option,\n";
        cout << "I suggest you buy it.\n";
    }
    
    return 0;
}
class Solution
{
  public:
    /*You are required to complete this method */
    int atoi(string A)
    {
        //Your code here
    int res=0;
    int cnt=0;
    for(int i=0; i<A.size();i++)
      {
        int c=(A[i]-'0');
        if(c==-3)
        {
            cnt++;
            
        }
        else if(c>=0 && c<=9)
        {
            res=res*10+(A[i]-'0');
        }
        else return -1;
      }
      if(cnt>1)
            {
            return -1;
            }
      if(cnt==1)
            {
            cout<<"-";
            }
    return res;
    }
    
    
};
class Solution {
public:
   int strStr(string s1,string s2)
   {
   int l1=s1.length();
   int l2=s2.length();
   if(s1==s2) return 0;
   if(l1<l2) return -1;
   for(int i=0;i<=l1-l2;i++)
   {
      int j=0;
      while(j<l2)
      {
         if(s1[i]==s2[j])
         {
            i++;
            j++;
         }
         else break;
      }
      if(j==l2) return i-j;
      else i=i-j;
   }
   return -1;
   }
};
#include <bits/stdc++.h>

using namespace std;

int main()
{
   string s="a1b2c3d4e5f6g7h8i9j1k2l3m4";
   string w1="";
   string w2="";
   int n=s.size();
   for(int i=0;i<n;i++)
   {
       if(i%2==0) {w1+=s[i];}
       else w2+=s[i];
   }
   cout<<w1+w2<<"\n";
   cout<<w1.append(w2);
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s="geeksforgeeks";
    unordered_map<char,int>mp;
    for(auto x:s)
    {
        mp[x]++;
    }
    for(auto x:mp)
    {
        cout<<x.first<<", "<<"count"<<"["<<x.second<<"]"<<"\n";
    }
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

class TrieNode
{
public:
	char data;
	TrieNode ** children;
	bool isEndOfString = false;
	TrieNode(char data)
	{
		this->data = data;
		children = new TrieNode*[26];
		for (int i = 0; i < 26; ++i)
		{
			children[i] = NULL;
		}
		isEndOfString = false;
	}
};


class Trie
{
	TrieNode *root;
public:
	Trie()
	{
		root = new TrieNode ('\0');
	}
private:
	void insertWord(TrieNode *root , string word)
	{
		//base case
		if (word.size() == 0)
		{
			root->isEndOfString = true;
			return;
		}

		//small calculation
		int index = word[0] - 'a'; //for 0th letter
		// a-0 b-1 c-2 d-3 e-4 f-5 g-6---y-24 z-25
		//now check at that particular index
		TrieNode * child;
		if (root->children[index] == NULL)
		{
			//make new node and put its address childern ptr
			child = new TrieNode(word[0]);
			root-> children[index] = child;
		}
		else
		{
			child = root->children[index];
			//child will take address  for recursive call
		}
		//recursion from index one
		insertWord(child , word.substr(1));
	}

public:
	void insertWord(string word)
	{
		return insertWord(this->root , word);
	}

private:
	bool search(TrieNode*root , string word)
	{
		if (word.size() == 0)
		{
			return 	root->isEndOfString;
		}
		TrieNode *child;
		int index = word[0] - 'a';
		if ( root->children[index] != NULL)
		{
			child = root->children[index];
		}
		else
			return false;

		return search(child , word.substr(1));

	}

public:
	bool search(string word)
	{
		return search(this->root, word);
	}

	void display(TrieNode* node , string word, vector<string> & v)
	{
		if (node->isEndOfString == true)
		{
			// cout << word << endl;
			v.push_back(word);
		}

		TrieNode * child;
		for (int i = 0; i < 26; ++i)
		{
			if (node->children[i] != NULL )
			{
				child = node->children[i];
				display(child , word + node->children[i]->data, v);
			}
		}
	}

	void display()
	{
		string word = "";
		vector <string> v;
		display(root, word , v);
	}

private:
	TrieNode* autoComplete(TrieNode*node , string word)
	{
		if ( word.length() == 0)
			return node;
		TrieNode *child;
		int index = word[0] - 'a';
		if ( node->children[index] != NULL)
		{
			child = node->children[index];
		}
		else
			return NULL;
		TrieNode * n =  autoComplete(child , word.substr(1));
		return n;
	}

public:
	void autoComplete(string word)
	{
		string a = word;
		TrieNode*node =  autoComplete(root, word);
		// cout << node->data << endl;
		if (node)
		{

			vector<string>v;
			display(node , word, v );
			cout << v.size() << endl;
			for (int i = 0; i < v.size(); ++i)
			{
				cout << v[i] << endl;
			}
		}
		else
		{
			cout << "\n Not a valid word to autoComplete:" << endl;
		}
	}

	int  distance(string str1 , string str2)
	{

		int cost = 0;

		int m = str1.length();
		int n = str2.length();

		int lev[m + 1][n + 1];
		for (int i = 0; i <= m; ++i)
		{
			for (int j = 0; j <= n; ++j)
			{
				lev[i][j] = 0;
			}
		}

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

		for (int j = 0; j <= n; j++)
			lev[0][j] = j;

		for (int j = 1; j <= n; ++j)
		{
			for (int i = 1; i <= m; ++i)
			{
				if (str1[i] == str2[j])
					cost = 0 ;
				else
					cost = 1;
				lev[i][j] =  min(lev[i - 1][j - 1] + cost,  min(1 + lev[i - 1][j], 1 + lev[i][j - 1]));

			}
		}

		return lev[m][n];
	}

	void edit_dis_word(TrieNode*node, string word , string lev_word , vector<string>&v)
	{
		if (node->isEndOfString == true)
		{
			int k = distance(word , lev_word);
			if (k <= 3)
				v.push_back(word);
		}

		TrieNode * child;
		for (int i = 0; i < 26; ++i)
		{
			if (node->children[i] != NULL )
			{
				child = node->children[i];
				edit_dis_word(child , word + node->children[i]->data, lev_word, v);
			}
		}
	}


	void autoCorrect(string lev_word)
	{

		vector<string>matching;
		//for storing the lev_distance owrd
		edit_dis_word(root , "" , lev_word, matching);
		cout << matching.size() << endl;

		for (int i = matching.size() - 1; i >= 0 ; i--)
		{
			cout << matching[i] << endl;
		}

	}
};


int main()
{
#ifdef ONLINE_JUDGE
	freeopen("input.txt", "r", stdin);
	freeopen("output.txt", "r", stdin);
#endif
	int num_words;
	int q;
	cin >> num_words >> q;
	Trie t;
	string word;
	while (num_words--)
	{
		cin >> word;
		t.insertWord(word);
	}

	int choice;
	while (q--)
	{
		cin >> choice;
		if (choice == 1) // spell check
		{
			cin >> word;
			cout << (t.search(word) ? "1\n" : "0\n");
		}
		else if (choice == 2) //auto complete
		{
			cin >> word;
			t.autoComplete(word);
		}
		else if (choice == 3)
		{
			cin >> word;
			t.autoCorrect(word);// autoCorrect
		}

	}

	// t.display();



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

double unitprice(int diameter, double price) {
    const double PI = 3.14159;
    double radius, area;
    
    radius = diameter / static_cast <double> (2);
    area = PI * radius * radius;
    return (price/area);
}

int main() {
    
    int diameter_small, diameter_large;
    double price_small, unitprice_small,
        price_large, unitprice_large;
    
    cout << "Please enter the diameter of the small pizza: ";
    cin >> diameter_small;
    cout << "Please enter the price of the small piza: $";
    cin >> price_small;
    cout << "Please enter the diameter of the large pizza: ";
    cin >> diameter_large;
    cout << "Please enter the price of the large piza: $";
    cin >> price_large;
    
    unitprice_small = unitprice(diameter_small, price_small);
    unitprice_large = unitprice(diameter_large, price_large);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    
    cout << "-------------------------------------\n"
        << "I see... \n";
    
    if (unitprice_large < unitprice_small) {
        cout << "Seems like the larger pizza is the better option,\n";
        cout << "I suggest you buy it.\n";
    }
    
    else 
    {
        cout << "Seems like the smaller one is the better option,\n";
        cout << "I suggest you buy it.\n";
    }
    
    return 0;
}
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;

int main() {
    double w, x, y, b, c, d, expo, sr, absolute_double, ceiling, fl;
    int a, z, absolute;
    long abs_long;
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    
    cout << "Enter the values of the following : \n"
        << "-------------------------------\n"
        << "pow(x, y)\n"
        << "x: ";
    cin >> x;
    cout << "y: ";
    cin >> y;
    cout << "sqrt(w)\n"
        << "w: ";
    cin >> w;
    cout << "abs(z)\n"
        << "z: ";
    cin >> z;
    cout << "labs(a)\n"
        << "a: ";
    cin >> a;
    cout << "fabs(b)\n"
        << "b: ";
    cin >> b;
    cout << "ceil(c)\n"
        << "c: ";
    cin >> c;
    cout << "floor(d)\n"
        << "d: ";
    cin >> d;
    
    expo = pow(x, y);
    cout << "___________________________\n"
    << "pow(x, y) = pow(" << x << ", " 
    << y << ") "<< " = " << expo << endl;
    
    sr = sqrt(w);
    cout << "sqrt(w) = sqrt(" << w
    << ") "<< " = " << sr << endl;
    
    absolute = abs(z);
    cout << "abs(z) = abs(" << z
    << ") "<< " = " << absolute << endl;
    
    abs_long = labs(a);
    cout << "labs(a) = labs(" << a
    << ") "<< " = " << abs_long << endl;
    
    absolute_double = fabs(b);
    cout << "fabs(b) = fabs(" << b
    << ") "<< " = " << absolute_double << endl;
    
    ceiling = ceil(c);
    cout << "ceil(c) = ceil(" << c
    << ") "<< " = " << ceiling << endl;
    
    fl = floor(d);
    cout << "floor(d) = floor(" << d
    << ") "<< " = " << fl << endl;
    
    return 0;
}
#include <iostream>
using namespace std;

double var(int x, double y) {
    return ((x + y)/2);
}

int main()
{
    double y, ave;
    int x;
    
    cout << "Average of two arguements\n"
        << "----------------------------\n"
        << "Please enter arguement x: ";
    cin >> x;
    cout << "Please enter arguement y: ";
    cin >> y;
    
    ave = var(x, y);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    cout << "____________________________\n"
        << "The average of these two numbers are "
        << ave << endl;
    
    return 0;
}
#include<iostream>
using namespace std;

class Element
{
public:
	int row;
	int col;
	int data;

};

class List
{
public:
	int row;
	int col;
	int data;
	List*next;
};



class  Sparse
{

public:
	int countElements;
	Element * elementArr = new Element[10000];
	Sparse()
	{
		countElements = 0;
	}


	void insert(int row	, int col, int data)
	{
		Element newElem;
		newElem.row = row;
		newElem.col = col;
		newElem.data = data;
		elementArr[countElements] = newElem;
		elementArr[0].data = countElements;
		countElements++;
	}

	// void add()


};

void display(Sparse* sp)
{
	for (int i = 0; i <= sp->elementArr[0].data  ; ++i)
	{
		cout << sp->elementArr[i].row << " " << sp->elementArr[i].col << "  " << sp->elementArr[i].data;
		cout  << endl;

	}

}

void add ( Sparse *s1 , Sparse *s2 , Sparse *s3)
{
	s3->elementArr[0].row = s1->elementArr[0].row;
	s3->elementArr[0].col = s1->elementArr[0].col;

	int i = 1; //points to sp1
	int j = 1; //points to sp2
	int k = 1; //points to sp3
	while (i <= s1->elementArr[0].data && j <= s2->elementArr[0].data )
	{
		if (s1->elementArr[i].row < s2->elementArr[j].row)
		{
			s3->elementArr[i].row = s1->elementArr[j].row;
			s3->elementArr[i].col = s1->elementArr[j].col;
			s3->elementArr[k++] = s1->elementArr[i++];
			s3->elementArr[0].data ++;
			s3->countElements++;
		}
		else if (s1->elementArr[i].row > s2->elementArr[j].row)
		{
			s3->elementArr[k].row = s2->elementArr[j].row;
			s3->elementArr[k].col = s2->elementArr[j].col;
			s3->elementArr[k++] = s2->elementArr[j++];
			s3->elementArr[0].data ++;
			s3->countElements++;
		}
		else if (s1->elementArr[i].row == s2->elementArr[j].row)
		{
			if (s1->elementArr[i].col < s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s1->elementArr[j].row;
				s3->elementArr[k].col = s1->elementArr[j].col;
				s3->elementArr[k++] = s1->elementArr[i++];
				s3->elementArr[0].data ++;
				s3->countElements++;
			}
			else if (s1->elementArr[i].col > s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s2->elementArr[j].row;
				s3->elementArr[k].col = s2->elementArr[j].col;
				s3->elementArr[k++] = s2->elementArr[j++];
				s3->elementArr[0].data ++;
				s3->countElements++;
			}
			else if (s1->elementArr[i].col == s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s2->elementArr[j].row;
				s3->elementArr[k].col = s2->elementArr[j].col;
				s3->elementArr[k++].data = s2->elementArr[j++].data + s1->elementArr[i++].data;
				s3->elementArr[0].data ++;
				s3->countElements++;
			}

		}
		cout << "hi" << endl;
		display(s3);
		cout << endl;
	}



}
// void display(Sparse* sp)
// {
// 	for (int i = 0; i <= sp->elementArr[0].data  ; ++i)
// 	{
// 		cout << sp->elementArr[i].row << " " << sp->elementArr[i].col << "  " << sp->elementArr[i].data;
// 		cout  << endl;

// 	}

// }

void transpose(Sparse *s1, Sparse*s3)
{
	//no. of elements in each col of s1
	int col_count_s1 = s1->elementArr[0].col + 1;
	int *col_s1 = new int [col_count_s1] {0};
	col_s1[0] = s1->elementArr[0].col;
	for (int i = 1; i <= s1->elementArr[0].data; ++i)
	{
		col_s1[s1->elementArr[i].col]++;
		//it will act as row element for s2
	}

	// for (int i = 0; i < col_count_s1; ++i)
	// {
	// 	cout << col_s1[i] << " ";
	// 	//it will act as row element for s2
	// }
	cout << endl;
	int *row_index = new int [col_count_s1 + 1];
	//one size greater than col_s1;
	row_index[1] = 1;
	for (int i = 2; i <= col_count_s1   ; ++i)
	{
		row_index[i] = row_index[i - 1] + col_s1[i - 1];
	}
	// for (int i = 0 ; i <= col_count_s1; ++i)
	// {
	// 	cout << row_index[i] << " ";
	// 	//it will act as row element for s2
	// }
	cout << endl;
	cout << endl;


	for (int i = 0; i <= s1->elementArr[0].data; ++i)
	{
		if (i == 0)
		{
			s3->elementArr[i].row = s1->elementArr[i].col;
			s3->elementArr[i].col = s1->elementArr[i].row;
			s3->elementArr[i].data = s1->elementArr[i].data;
		}
		else
		{
			int r_index  = s1->elementArr[i].col;
			int index = row_index[r_index];
			s3->elementArr[index].row = s1->elementArr[i].col;
			s3->elementArr[index].col = s1->elementArr[i].row;
			s3->elementArr[index].data = s1->elementArr[i].data;
			row_index[r_index]++;
		}
	}
}

void matrix(Sparse *s)
{
	int k = 1;
	for (int i = 1; i <= s->elementArr[0].row; ++i)
	{
		for (int j = 1; j <= s->elementArr[0].col; j++)
		{
			if (i == s->elementArr[k].row && j == s->elementArr[k].col)
				cout << s->elementArr[k++].data << " ";
			else
				cout << "0 ";
		}
		cout << endl;
	}
}


void multiply ( Sparse *s1 , Sparse *s2 , Sparse *s3)
{
	Sparse *s4 = new Sparse();
	display(s1); cout << endl;
	display(s2); cout << endl;
	s3->insert(s1->elementArr[0].row , s2->elementArr[0].col , 0 );
	for (int i = 1; i <= s1->elementArr[0].data; i++ )
	{

		int sum = 0;

		for (int j = 1; j <= s2->elementArr[0].data; j++)
		{
			int sum = 0;
			if (s1->elementArr[i].col == s2->elementArr[j].row)
			{
				sum = s1->elementArr[i].data * s2->elementArr[j].data;
				s3->insert(s1->elementArr[i].row , s2->elementArr[j].col , sum);
			}
		}
	}


	display(s3);


	cout << endl;
	cout << endl;
	transpose (s3, s4);//saved in new transpose matrix s4
	transpose (s4, s3);//saved in new transpose matrix s3
	//now s3 is in sorted order
	Sparse *s5 = new Sparse();
	for (int i = 0; i <= s3->elementArr[0].data; ++i)
	{
		if (i == 0)
		{
			s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, 0);
		}
		else if (i == 1)
		{
			s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, s3->elementArr[i].data);
		}
		else
		{
			int flag = 0;
			for (int k = 1; k <= s5->elementArr[0].data; k++)
			{
				if (s3->elementArr[i].row == s5->elementArr[k].row && s3->elementArr[i].col == s5->elementArr[k].col)
				{
					s5->elementArr[k].data += s3->elementArr[i].data;
					flag = 1;
					break;
				}
			}
			if (flag == 0)
			{
				s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, s3->elementArr[i].data);

			}
		}

	}





	display(s3);
	cout << endl;
	s3 = s5;
	display(s3);
	cout << endl;
	matrix(s3);
	cout << s3->elementArr[0].row ;

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


	int type;
	int op;
	int R1, R2, C1, C2;
	// do {
	cout << "What operation do you want to perform? " <<
	     " Select Option number. Enter 0 to exit." << endl;
	cout << "1. Array" << endl;
	cout << "2. Link list" << endl;
	cout << "Enter datastructure to use :\n";
	cin >> type;
	cout << "Type of operation :\n";
	cout << "1. Addition" << endl;
	cout << "2. Transpose " << endl;
	cout << "3. Multiplication  " << endl;
	cin >> op;
	int data;


	Sparse *sp1 = new Sparse();
	Sparse *sp2 = new Sparse();

	int n = 0;
	if (type == 1 )
	{
		//MATRIX 1
		cin >> R1 >> C1;
		sp1->insert(R1, C1, 0);// FOR Checking #r , #c , #elements
		for (int i = 1; i <= R1; ++i)
		{
			for (int j = 1; j <= C1; ++j)
			{
				cin >> data;
				if (data != 0)
					sp1->insert(i, j, data);
			}
		}
		if (op == 2)//transpose
		{
			Sparse*sp3 = new Sparse();
			transpose(sp1 , sp3);
			display(sp1);
			cout << endl;
			display(sp3);
			cout << endl;
			// sp1 = sp3; //after transpose just change the pointer
			matrix(sp1);
			cout << endl;
			matrix(sp3);
			cout << endl;
		}

		if (op == 1 || op == 3)//addition or mul
		{
			//MATRIX 2
			cin >> R2 >> C2;
			sp2->insert(R2, C2, 0);
			for (int i = 1; i <= R2; ++i)
				for (int j = 1; j <= C2; ++j)
				{
					cin >> data;
					if (data != 0)
						sp2->insert(i, j, data);
				}
			Sparse *sp3 = new Sparse();;
			if (op == 1) //add
			{
				if (R1 != R2 || C1 != C2)
				{
					cout << " wrong matrix sizes: \n";
					return 0;
				}
				add(sp1, sp2, sp3);
				cout << endl;
				display(sp1);
				cout << endl;
				display(sp2);
				cout << endl;
				display(sp3);
				cout << endl;
				cout << sp1->elementArr[0].data << endl;
				cout << sp2->elementArr[0].data << endl ;
				cout << sp3->elementArr[0].data << endl ;
				matrix(sp1);
				cout << endl;
				matrix(sp2);
				cout << endl;
				matrix(sp3);
				cout << endl;
			}
			else if (op == 3) //multiplication
			{
				if (C1 != R2)
				{
					cout << " wrong matrix sizes: \n";
					return 0;
				}
				multiply(sp1, sp2, sp3);
				cout << endl;
				// 	display(sp1);
				// 	cout << endl;
				// 	display(sp2);
				// 	cout << endl;
				// 	display(sp3);
				// 	cout << endl;
				// 	matrix(sp1);
				// 	cout << endl;
				// 	matrix(sp2);
				// 	cout << endl;
				// 	matrix(sp3);
				// 	cout << endl;
			}





			// for (int i = 0; i < 5 ; ++i)
			// {
			// 	cout << sp3->elementArr[i].row << " " << sp3->elementArr[i].col << "  " << sp3->elementArr[i].data;
			// 	cout  << endl;
			// }
			// cout << sp3->elementArr[0].row << " " << sp3->elementArr[0].col << "  " << sp3->elementArr[0].data;


		}
	}





// 	switch (option) {
// 	case 0:
// 		break;
// 	case 1:
// 		cout << "Enter VALUE of TREE sp to INSERT in AVL Tree: ";
// 		cin >> val;

// 		obj_avl.root = obj_avl.insert(val);
// 		cout << endl;
// 		break;

// 	case 2:
// 		cout << "Enter VALUE of TREE sp to delete in AVL Tree: ";
// 		cin >> val;
// 		obj_avl.root = obj_avl.deleteData(val);
// 		break;


// 	case 3:
// 		cout << "Enter VALUE of TREE sp to search in AVL: ";
// 		cin >> val;
// 		cout << obj_avl.search(val);
// 		break;

// 	default:
// 		cout << "Enter Proper Option number " << endl;
// 	}

// } while (option != 0);



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

int add(int x, int y, int z) {
    return (x + y + z);
}

int main()
{
    int x, y, z, sum;
    
    cout << "Sum of three arguements\n"
        << "----------------------------\n"
        << "Please enter three arguements: ";
    cin >> x >> y >> z;
    
    sum = add(x, y,z);
 
    cout << "____________________________\n"
        << x << " + " << y << " + "
        << z << endl
        << "The sum these three arguements are: " << sum;

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

double total_cost(int number_par, double price_par) {
}

int main()
{
    double price, bill;
    int number;
    
    cout << "Enter the number of items purchased: ";
    cin >> number;
    cout << "Enter the price per item $";
    cin >> price;
    
    bill = total_cost(number, price);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    cout << number << " items at "
    << "$" << price << " each.\n"
    << "Final bill, including tax, is $" << bill
    << endl;
    
    return 0;
}
#include<iostream>
using namespace std;

class Element
{
public:
	int row;
	int col;
	int data;

};



class  Sparse
{

public:
	int countElements;
	Element * elementArr = new Element[10000];
	Sparse()
	{
		countElements = 0;
	}


	void insert(int row	, int col, int data)
	{
		Element newElem;
		newElem.row = row;
		newElem.col = col;
		newElem.data = data;
		elementArr[countElements] = newElem;
		elementArr[0].data = countElements;
		countElements++;
	}

	// void add()


};

void display(Sparse* sp)
{
	for (int i = 0; i <= sp->elementArr[0].data  ; ++i)
	{
		cout << sp->elementArr[i].row << " " << sp->elementArr[i].col << "  " << sp->elementArr[i].data;
		cout  << endl;

	}

}

void add ( Sparse *s1 , Sparse *s2 , Sparse *s3)
{
	s3->elementArr[0].row = s1->elementArr[0].row;
	s3->elementArr[0].col = s1->elementArr[0].col;

	int i = 1; //points to sp1
	int j = 1; //points to sp2
	int k = 1; //points to sp3
	while (i <= s1->elementArr[0].data && j <= s2->elementArr[0].data )
	{
		if (s1->elementArr[i].row < s2->elementArr[j].row)
		{
			s3->elementArr[i].row = s1->elementArr[j].row;
			s3->elementArr[i].col = s1->elementArr[j].col;
			s3->elementArr[k++] = s1->elementArr[i++];
			s3->elementArr[0].data ++;
			s3->countElements++;
		}
		else if (s1->elementArr[i].row > s2->elementArr[j].row)
		{
			s3->elementArr[k].row = s2->elementArr[j].row;
			s3->elementArr[k].col = s2->elementArr[j].col;
			s3->elementArr[k++] = s2->elementArr[j++];
			s3->elementArr[0].data ++;
			s3->countElements++;
		}
		else if (s1->elementArr[i].row == s2->elementArr[j].row)
		{
			if (s1->elementArr[i].col < s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s1->elementArr[j].row;
				s3->elementArr[k].col = s1->elementArr[j].col;
				s3->elementArr[k++] = s1->elementArr[i++];
				s3->elementArr[0].data ++;
				s3->countElements++;
			}
			else if (s1->elementArr[i].col > s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s2->elementArr[j].row;
				s3->elementArr[k].col = s2->elementArr[j].col;
				s3->elementArr[k++] = s2->elementArr[j++];
				s3->elementArr[0].data ++;
				s3->countElements++;
			}
			else if (s1->elementArr[i].col == s2->elementArr[j].col)
			{
				s3->elementArr[k].row = s2->elementArr[j].row;
				s3->elementArr[k].col = s2->elementArr[j].col;
				s3->elementArr[k++].data = s2->elementArr[j++].data + s1->elementArr[i++].data;
				s3->elementArr[0].data ++;
				s3->countElements++;
			}

		}
		cout << "hi" << endl;
		display(s3);
		cout << endl;
	}



}
// void display(Sparse* sp)
// {
// 	for (int i = 0; i <= sp->elementArr[0].data  ; ++i)
// 	{
// 		cout << sp->elementArr[i].row << " " << sp->elementArr[i].col << "  " << sp->elementArr[i].data;
// 		cout  << endl;

// 	}

// }

void transpose(Sparse *s1, Sparse*s3)
{
	//no. of elements in each col of s1
	int col_count_s1 = s1->elementArr[0].col + 1;
	int *col_s1 = new int [col_count_s1] {0};
	col_s1[0] = s1->elementArr[0].col;
	for (int i = 1; i <= s1->elementArr[0].data; ++i)
	{
		col_s1[s1->elementArr[i].col]++;
		//it will act as row element for s2
	}

	// for (int i = 0; i < col_count_s1; ++i)
	// {
	// 	cout << col_s1[i] << " ";
	// 	//it will act as row element for s2
	// }
	cout << endl;
	int *row_index = new int [col_count_s1 + 1];
	//one size greater than col_s1;
	row_index[1] = 1;
	for (int i = 2; i <= col_count_s1   ; ++i)
	{
		row_index[i] = row_index[i - 1] + col_s1[i - 1];
	}
	// for (int i = 0 ; i <= col_count_s1; ++i)
	// {
	// 	cout << row_index[i] << " ";
	// 	//it will act as row element for s2
	// }
	cout << endl;
	cout << endl;


	for (int i = 0; i <= s1->elementArr[0].data; ++i)
	{
		if (i == 0)
		{
			s3->elementArr[i].row = s1->elementArr[i].col;
			s3->elementArr[i].col = s1->elementArr[i].row;
			s3->elementArr[i].data = s1->elementArr[i].data;
		}
		else
		{
			int r_index  = s1->elementArr[i].col;
			int index = row_index[r_index];
			s3->elementArr[index].row = s1->elementArr[i].col;
			s3->elementArr[index].col = s1->elementArr[i].row;
			s3->elementArr[index].data = s1->elementArr[i].data;
			row_index[r_index]++;
		}
	}
}

void matrix(Sparse *s)
{
	int k = 1;
	for (int i = 1; i <= s->elementArr[0].row; ++i)
	{
		for (int j = 1; j <= s->elementArr[0].col; j++)
		{
			if (i == s->elementArr[k].row && j == s->elementArr[k].col)
				cout << s->elementArr[k++].data << " ";
			else
				cout << "0 ";
		}
		cout << endl;
	}
}


void multiply ( Sparse *s1 , Sparse *s2 , Sparse *s3)
{
	Sparse *s4 = new Sparse();
	display(s1); cout << endl;
	display(s2); cout << endl;
	s3->insert(s1->elementArr[0].row , s2->elementArr[0].col , 0 );
	for (int i = 1; i <= s1->elementArr[0].data; i++ )
	{

		int sum = 0;

		for (int j = 1; j <= s2->elementArr[0].data; j++)
		{
			int sum = 0;
			if (s1->elementArr[i].col == s2->elementArr[j].row)
			{
				sum = s1->elementArr[i].data * s2->elementArr[j].data;
				s3->insert(s1->elementArr[i].row , s2->elementArr[j].col , sum);
			}
		}
	}


	display(s3);


	cout << endl;
	cout << endl;
	transpose (s3, s4);//saved in new transpose matrix s4
	transpose (s4, s3);//saved in new transpose matrix s3
	//now s3 is in sorted order
	Sparse *s5 = new Sparse();
	for (int i = 0; i <= s3->elementArr[0].data; ++i)
	{
		if (i == 0)
		{
			s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, 0);
		}
		else if (i == 1)
		{
			s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, s3->elementArr[i].data);
		}
		else
		{
			int flag = 0;
			for (int k = 1; k <= s5->elementArr[0].data; k++)
			{
				if (s3->elementArr[i].row == s5->elementArr[k].row && s3->elementArr[i].col == s5->elementArr[k].col)
				{
					s5->elementArr[k].data += s3->elementArr[i].data;
					flag = 1;
					break;
				}
			}
			if (flag == 0)
			{
				s5->insert(s3->elementArr[i].row, s3->elementArr[i].col, s3->elementArr[i].data);

			}
		}

	}





	display(s3);
	cout << endl;
	s3 = s5;
	display(s3);
	cout << endl;
	matrix(s3);
	cout << s3->elementArr[0].row ;

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


	int type;
	int op;
	int R1, R2, C1, C2;
	// do {
	cout << "What operation do you want to perform? " <<
	     " Select Option number. Enter 0 to exit." << endl;
	cout << "1. Array" << endl;
	cout << "2. Link list" << endl;
	cout << "Enter datastructure to use :\n";
	cin >> type;
	cout << "Type of operation :\n";
	cout << "1. Addition" << endl;
	cout << "2. Transpose " << endl;
	cout << "3. Multiplication  " << endl;
	cin >> op;
	int data;


	Sparse *sp1 = new Sparse();
	Sparse *sp2 = new Sparse();

	int n = 0;
	if (type == 1 )
	{
		//MATRIX 1
		cin >> R1 >> C1;
		sp1->insert(R1, C1, 0);// FOR Checking #r , #c , #elements
		for (int i = 1; i <= R1; ++i)
		{
			for (int j = 1; j <= C1; ++j)
			{
				cin >> data;
				if (data != 0)
					sp1->insert(i, j, data);
			}
		}
		if (op == 2)//transpose
		{
			Sparse*sp3 = new Sparse();
			transpose(sp1 , sp3);
			display(sp1);
			cout << endl;
			display(sp3);
			cout << endl;
			// sp1 = sp3; //after transpose just change the pointer
			matrix(sp1);
			cout << endl;
			matrix(sp3);
			cout << endl;
		}

		if (op == 1 || op == 3)//addition or mul
		{
			//MATRIX 2
			cin >> R2 >> C2;
			sp2->insert(R2, C2, 0);
			for (int i = 1; i <= R2; ++i)
				for (int j = 1; j <= C2; ++j)
				{
					cin >> data;
					if (data != 0)
						sp2->insert(i, j, data);
				}
			Sparse *sp3 = new Sparse();;
			if (op == 1) //add
			{
				if (R1 != R2 || C1 != C2)
				{
					cout << " wrong matrix sizes: \n";
					return 0;
				}
				add(sp1, sp2, sp3);
				cout << endl;
				display(sp1);
				cout << endl;
				display(sp2);
				cout << endl;
				display(sp3);
				cout << endl;
				cout << sp1->elementArr[0].data << endl;
				cout << sp2->elementArr[0].data << endl ;
				cout << sp3->elementArr[0].data << endl ;
				matrix(sp1);
				cout << endl;
				matrix(sp2);
				cout << endl;
				matrix(sp3);
				cout << endl;
			}
			else if (op == 3) //multiplication
			{
				if (C1 != R2)
				{
					cout << " wrong matrix sizes: \n";
					return 0;
				}
				multiply(sp1, sp2, sp3);
				cout << endl;
				// 	display(sp1);
				// 	cout << endl;
				// 	display(sp2);
				// 	cout << endl;
				// 	display(sp3);
				// 	cout << endl;
				// 	matrix(sp1);
				// 	cout << endl;
				// 	matrix(sp2);
				// 	cout << endl;
				// 	matrix(sp3);
				// 	cout << endl;
			}





			// for (int i = 0; i < 5 ; ++i)
			// {
			// 	cout << sp3->elementArr[i].row << " " << sp3->elementArr[i].col << "  " << sp3->elementArr[i].data;
			// 	cout  << endl;
			// }
			// cout << sp3->elementArr[0].row << " " << sp3->elementArr[0].col << "  " << sp3->elementArr[0].data;


		}
	}





// 	switch (option) {
// 	case 0:
// 		break;
// 	case 1:
// 		cout << "Enter VALUE of TREE sp to INSERT in AVL Tree: ";
// 		cin >> val;

// 		obj_avl.root = obj_avl.insert(val);
// 		cout << endl;
// 		break;

// 	case 2:
// 		cout << "Enter VALUE of TREE sp to delete in AVL Tree: ";
// 		cin >> val;
// 		obj_avl.root = obj_avl.deleteData(val);
// 		break;


// 	case 3:
// 		cout << "Enter VALUE of TREE sp to search in AVL: ";
// 		cin >> val;
// 		cout << obj_avl.search(val);
// 		break;

// 	default:
// 		cout << "Enter Proper Option number " << endl;
// 	}

// } while (option != 0);



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

int main() {
    double a, b, c, ex, bac, sum1, sr, sum2, prod, quo;
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    
    cout << "Using the Quadratic Formula.\n"
    << "Please enter the value of a: ";
    cin >> a;
    cout << "Please enter the value of b: ";
    cin >> b;
    cout << "Please enter the value of c: ";
    cin >> c;
    
    ex = pow(b,2);
    bac = -4 * a * c;
    sum1 = ex + bac;
    sr = sqrt(sum1);
   
    if (sr > 0) { 
        sum2 = -b + sr;
        prod = 2 * a;
        quo = sum2 / prod;
        cout << "x = " << quo << endl;
    }
    
    else {
    cout << " - Undefined -" << endl 
        << "The square root of a negative number does not exist" << endl 
        << "in the set of real numbers." << endl;
    }
    
    return 0;
}
#include <iostream>
#include <cmath>
using namespace std;

int main() {
    double a, b, c, ex, bac, sum1, sr, sum2, prod, quo;
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);
    
    cout << "Using the Quadratic Formula.\n"
    << "-----------------------------------\n" 
    << "Please enter the value of a: ";
    cin >> a;
    cout << "Please enter the value of b: ";
    cin >> b;
    cout << "Please enter the value of c: ";
    cin >> c;
    
    ex = pow(b,2);
    cout << "-----------------------------------\n" 
    << "Evaluate the power of b,\n"
    << b << " ^ 2 = " << ex << endl;
    
    bac = -4 * a * c;
    cout << "Calculate the product of -4(a)(c), \n"
    << "-4(a)(c) = -4(" << a << ")("
    << c << ") = " << bac << endl;
    
    sum1 = ex + bac;
    cout << "Add the product of b and -4(a)(c), \n"
    << ex << " + " << bac << " = " << sum1 << endl;
    
    sr = sqrt(sum1);
    cout << "Evaluate the square root of " << sum1 << "," <<endl
    << "√" << sum1 << " = " << sr << endl;
   
    if (sr > 0) { 
        sum2 = -b + sr;
        cout << "Calculate the sum of -" << b << " and " << sr << "," << endl
        << "-" << b << " + " << sr << " = " << sum2 << endl;
    
        prod = 2 * a;
        cout << "Multiply for the product of 2 and (a), \n"
        << "2(" << a << ") = " << prod << endl;
    
        quo = sum2 / prod;
        cout << "Calculate the quotient of " << sum2 << " and "<< prod << "," << endl
        << sum2 << " / " << prod << " = " << quo << endl
        << "-----------------------------------\n"
        << "x = " << quo << endl 
        << "-----------------------------------\n";
    }
    
    else {
        cout << "-----------------------------------\n" 
        << " - Undefined -" << endl 
        << "The square root of a negative number does not exist" << endl 
        << "in the set of real numbers." << endl 
        << "-----------------------------------\n";
    }
    
    return 0;
}
#include<iostream>
using namespace std;
void getMinMax(int arr[], int arrSize, int *minVal, int *maxVal)
{
  for (int i = 1; i < arrSize; i++)
  {
    if (arr[i] > *maxVal)
    {
      *maxVal = arr[i];
    }
    if (arr[i] < *minVal)
    {
      *minVal = arr[i];
    }

  }
}
int main()
{
  int arr[5] = { 1, 2, -9, 45, 0};
  int max = arr[0];
  int min = arr[0];
  getMinMax(arr, 5, &min, &max);
  cout << min << " " << max << endl;
  return 0;
}
#include<iostream>
using namespace std;
int main(){
  int arr[5] = { 1,2,3,4,5 };
  cout << arr << endl;
  return 0;
}
#include<iostream>
using namespace std;
void printData(void *ptr, char dataType){
  switch (dataType)
  {
    case 'i':
      cout << *((int *)ptr) << endl;
      break;

    case 'c':
      cout << *(static_cast<char *>(ptr)) << endl;
      break;
  }
}
int main(){
  int n = 7;
  char b = 'b';
  printData(&n, 'i');
  printData(&b, 'c');
  return 0;
}
#include<iostream>
using namespace std;
int main(){
  int *ptr;
  *ptr = 6;
  cout << *ptr << endl;
  return 0;
}
#include<iostream>
using namespace std;
int main(){
  int n = 6;
  float *ptr = &n;
  *ptr = 10;
  cout << *ptr << " " << n << endl;
  return 0;
}
#include<iostream>
using namespace std;
int main(){
  int n = 6;
  int *ptr = &n;
  *ptr = 10;
  cout << *ptr << " " << n << endl;
  return 0;
}
#include<bits/stdc++.h>
using namespace std;

class BinaryTreeNode
{
public:
	int data;
	BinaryTreeNode * left;
	BinaryTreeNode *right;
	int height;

	// BinaryTreeNode()
	// {
	// 	data = 0;
	// 	left = NULL;
	// 	right = NULL;
	// }
	BinaryTreeNode(int data)
	{
		this->data = data;
		left = NULL;
		right = NULL;
	}
	~BinaryTreeNode()
	{
		delete left;
		delete right;
	}

};


class AVL
{
public:
	BinaryTreeNode *root;
	AVL()
	{
		this->root = NULL;
	}


	int getheight(BinaryTreeNode* root)
	{
		if (root == NULL)
			return 0;

		return 1 + max(getheight(root->left) , getheight(root->right));
	}

	int getbalanceFactor(BinaryTreeNode* node)
	{
		if ( node == NULL)
			return 0;
		return getheight(node->left) - getheight(node->right);
	}

	BinaryTreeNode* rightRotate(BinaryTreeNode* y)
	{


		/*

			 	y           x
			   / \		   / \
			  x   T3 ---->T1  y
			 / \			 / \
			T1  T2			T2  T3
			*/
		BinaryTreeNode* x = y->left;
		BinaryTreeNode *T2 = x->right;
		// T1 & T3 not required because their ptr not changes
		x->right = y;
		y->left = T2;
		//updation to heights
		// y->height = 1 + max(getHeight(y->left) , getHeight(y->right));
		// X->height = 1 + max(getHeight(x > left) , getHeight(x->right));
		return x;
		//as now x is root node
	}
	BinaryTreeNode* leftRotate(BinaryTreeNode* x)
	{
		/*  	y           x
			   / \		   / \
			  x   T3 <--- T1  y
			 / \			 / \
			T1  T2			T2  T3
			*/
		//before rotation
		BinaryTreeNode* y = x->right;
		BinaryTreeNode *T2 = y->left;
		// T1 & T3 not required because their ptr not changes
		//changes to rotation
		y->left = x;
		x->right = T2;
		//updation to heights
		// y->height = 1 + max(getHeight(y->left) , getHeight(y->right));
		// X->height = 1 + max(getHeight(x > left) , getHeight(x->right));
		return y;
		//as now y is root node
	}


// 1. insert
private:
	BinaryTreeNode * insert(BinaryTreeNode* node, int data)
	{
		if ( node == NULL)
		{
			BinaryTreeNode* newnode = new BinaryTreeNode (data);
			return newnode;
		}

		if (data <= node->data)
			node->left = this->insert( node->left , data);
		else if (data > node->data)
			node->right = this->insert(node->right , data);
		else
			return node;

		// node->height = 1 + max(getHeight(node > left) , getHeight(node->right));
		// //height update krni padegi as it is req in balfac

		int balfac =  getbalanceFactor(node) ;
		// left left case ..bf= leftH -rightH >1
		if (balfac > 1 && data < node->left->data)
		{	//insertion takes place at LST
			return this->rightRotate(node);
		}

		//right right case , bf= leftH -rightH < -1
		if (balfac < -1 && node->right->data < data)
		{
			return this->leftRotate(node);
		}

		//left rightcase,bf= leftH -rightH >1
		if (balfac > 1 && node->left->data < data)//bf>1 tabhi root k left me imbal
		{
			/*
				 r= 30          30     25
				   /   			/	  /	  \
				 20	   	   	  25     20	  30
				  \			 /
			  data=25		20
			*/

			node->left = leftRotate(node->left); //
			return this->rightRotate(node);
		}


		//right left case bf= leftH -rightH <-1
		if (balfac > 1 && node->left->data < data)//bf>1 tabhi root k left me imbal
		{
			/*
				 r= 20           20         25
				      \   		   \       /  \
				 	  30	   	    25    20   30
					 /	             \
			  data=25		          30
			*/

			node->right = rightRotate(node->right); //
			//now RR imbalance
			return this->leftRotate(node);
		}
		return node;
	}




public:
	BinaryTreeNode* insert ( int data)
	{
		// BinaryTreeNode *node = new BinaryTreeNode(data);
		this->root = insert(this->root , data);
		return  root;
	}



	//2. delete : trick think node as leaf or any internal node
private:
	BinaryTreeNode * deleteData(BinaryTreeNode* node , int data)
	{
		if (node == NULL)
			return NULL;
		if (data < node->data)
		{
			node ->left = deleteData(node->left , data);
			return node;
		}
		else if (node->data < data)
		{
			node->right = deleteData(node -> right , data);
			return node;
		}
		else // if value matche
		{
			if (node->left == NULL && node->right == NULL) //a leaf
			{
				delete node;
				return NULL;
			}
			else if (node->left == NULL)
			{
				BinaryTreeNode *rightsubtree = node->right;
				node ->right = NULL;
				delete node;
				return rightsubtree;
			}
			else if (node->right == NULL)
			{
				BinaryTreeNode *leftsubtree = node->left;
				node->left = NULL;
				delete node;
				return leftsubtree;
			}
			else // both rst and lst exists
			{
				BinaryTreeNode * minNode = node ->right;
				while (minNode->left != NULL)
				{
					minNode = minNode->left;
				}
				int minFromRST = minNode->data;
				node->data = minFromRST;
				node->right = deleteData(node->right, minFromRST);
				return node;
			}
		}


		int balfac = getbalanceFactor(node);

		if (balfac == 2 && getbalanceFactor(node->left ) >= 0)
		{
			/*
				 r= 30         			 30                 30      20
				   / \  				/ \	                /	   /  \
				 20	  40**del 	or    20   40 **del =     20	  10   30
				 /\					 /					 /
			   10  25				10					10
			*/
			// 25 case will be taken care by rightrotate

			BinaryTreeNode*newnode = rightRotate(node);
			return newnode;
		}
		else if (balfac == 2 && getbalanceFactor(node->left) == -1)
		{
			/*
				 r= 30         			 30                        25
				   / \  				/ 	                 	  /  \
			(-1) 20	  40**del or (-1) 20  	lr imbalance	=    20	  30
				  \					 	\
			      25					 25
			*/
			// 25 case will be taken care by rightrotate

			node->left = leftRotate(node->left);
			BinaryTreeNode*newnode = rightRotate(node);
			return newnode;
		}
		else if (balfac == -2 && getbalanceFactor(node->right) <= 0)
		{
			/*
			 20			20		   	 30
			/ \			/ \		     / \
			del 10  30  del(10) 30        20  40
			   /\			 \
			  25 40 		 40

			  // 25 case will be taken care by leftrotate
			*/
			BinaryTreeNode * newnode = leftRotate(node);
			return newnode;
		}
		else if (balfac == -2 && getbalanceFactor(node->right) == 1)
		{
			/*
			 20			 	 20                25
			/ \			 	   \			   / \
			del 10  30 (1)          30	rl imbal  20  30
			   / 			 	/
			  25 		  	  25
			  	*/
			node->right  =  leftRotate(node->right);
			BinaryTreeNode * newnode = leftRotate(node);
			return newnode;
		}
	}
public:
	BinaryTreeNode* deleteData( int data)
	{
		this->root = deleteData(this->root , data);
		return root;
	}


	//3.search
private:
	bool search(BinaryTreeNode* node , int data)
	{
		if (node == NULL)
			return false;
		if (node->data == data)
			return true;
		else if (node->data < data)
			return search (node->right , data);
		else
			return search(node->left , data);
	}
public:
	bool search(int data)
	{
		return search(root, data);
	}



	//4. occurences
private :
	int count_occurence(BinaryTreeNode*node , int data)
	{
		if (node == NULL)
			return 0;

		if (node ->data == data)
			return 1 + count_occurence(node->left, data) + count_occurence(node->right, data);
		else if (node->data < data)
			return count_occurence(node->right, data);
		else if (data < node->data )
			return count_occurence(node->left, data);
		return 0;
	}

public:
	int count_occurence(int data)
	{
		return count_occurence(this->root , data);
	}

private:
	int upper_bound(BinaryTreeNode*node, int data)
	{
		if (node == NULL)
			return 0;

		//leaf data=15  leaf=14(node->data)(rightmost)
		if (node->left == NULL && node->right == NULL && node->data <= data)
		{
			return 0;
		}

		//data=12 ex=  null (12) 13(root)  or   11 (12) 13(root) or 12 (12) 13(root)
		if ((data < node->data && node->left == NULL) || (node->left->data <= data && data < node->data))
		{
			return node->data;
		}
		//data=12  11(root) (12)  or   12(root) (12)
		if (node->data <= data)
		{	//node->left->data se compare wali cond already checked above
			return upper_bound(node->right, data);
		}
		else if (data < node->data)
		{
			//data=12  14(root->left)  15(root)
			return upper_bound(node->left , data);
		}
		return 0;
	}
public:
	int upper_bound(int data)
	{
		return upper_bound(this->root , data);
	}


private:
	int lower_bound(BinaryTreeNode*node, int data)
	{
		if (node == NULL)
			return 0;

		//reachd to leaf data =14 leaf=15(node->data) leftmost node
		if (node->left == NULL && node->right == NULL &&  data < node->data )
		{
			return 0;
		}
		//itsef a leaf
		if (node->left == NULL  && node->right == NULL &&  data == node->data)
			return node->data;

		//data=12  11(root) null or   11(root) 13  or  12(root)   13
		if ((node->data < data   && node->right == NULL) || (node->data < data && data < node->right->data))
		{
			return node->data;
		}
		//data=12  12 13(root)  or   (12)   12(root)
		if ( data <= node->data)
		{
			return lower_bound(node->left, data);
		}
		else if ( node->data < data)
		{	//node->right->data se compare wali cond already checked above
			//data=12  10(root)  11(root->right) 12
			return lower_bound(node->right, data);
		}
		return 0;
	}
public:
	int lower_bound(int data)
	{
		return lower_bound(this->root , data);
	}

public:
	int lesser_bound(BinaryTreeNode*node , int data)
	{
		if (node == NULL)
			return 0;

		//reachd to leaf data =14 leaf=15(node->data) leftmost node
		if (node->left == NULL && node->right == NULL &&  data < node->data )
		{
			return 0;
		}
		//itsef a leaf
		if (node->left == NULL  && node->right == NULL &&  data == node->data)
			return 0;

		//data=12  11(root) null or   11(root) 13  or  12(root)   13
		if ((node->data < data   && node->right == NULL) || (node->data < data && data < node->right->data))
		{
			return node->data;
		}
		//data=12  12 13(root)  or   (12)   12(root)
		if ( data <= node->data)
		{
			return lesser_bound(node->left, data);
		}
		else if ( node->data < data)
		{	//node->right->data se compare wali cond already checked above
			//data=12  10(root)  11(root->right) 12
			return lesser_bound(node->right, data);
		}
		return 0;
	}



private:
	int closest_element(BinaryTreeNode*node , int data)
	{
		if (node == NULL)
			return -1;
		if (node->data == data)
			return node->data;
		int x = upper_bound(node, data);
		int y = lesser_bound(node, data);
		//y----------data ---------x
		if (y != 0 && x != 0)
			return (data - y) > (x - data) ? x : y;
		else if (y == 0 && x != 0)
			return x;
		else
			return y;

	}
public:
	int closest_element(int data)
	{
		return closest_element(this->root , data);
	}


private:
	BinaryTreeNode* Element_Kth_largest(BinaryTreeNode*node , int &k)
	{
		// if (node == NULL || c > k )
		// 	return -1;
		// //reverse inorder traversal
		// Element_Kth_largest(node->right, k, c );
		// c++;
		// if (k == c)
		// 	return node->data;
		// Element_Kth_largest(node->left, k , c);
		// return -1;
		if (node == NULL)
			return NULL;

		BinaryTreeNode* newnode = Element_Kth_largest(node->right, k);
		if (newnode  != NULL)
			return newnode;
		k--;

		if (k == 0)
			return node;

		return Element_Kth_largest(node->left, k);
	}
public:
	int Element_Kth_largest(int k)
	{

		BinaryTreeNode*newnode = Element_Kth_largest(this->root, k );
		int c = -1;
		if (newnode == NULL)
			return c;
		else
			c = newnode->data;
		return c;
	}

private:
	int count_range(BinaryTreeNode*node, int eLeft, int eRight)
	{
		if (node == NULL)
			return 0;
		// if (node->data == eLeft && node->data == eRight)
		// 	return 1;

		int count = 0;
		// Special Optional case for improving efficiency
		// if (eLeft <= node->data  && node->data <= eRight)
		// 	return 1 + count_range(node->left , eLeft, eRight) + count_range(root->right , eLeft, eRight);

		if (eLeft <= node->data  && node->data <= eRight)
			count += 1;
		count += count_range(node->left , eLeft, eRight);

		return count + count_range(node->right , eLeft, eRight);
		// else if (node->data < eLeft )
		// 	return count_range(node->right, eLeft, eRight)	;
		// else
		// 	return count_range(root->left , eLeft, eRight);
	}
public:
	int count_range(int eLeft , int eRight)
	{
		return count_range(this->root, eLeft, eRight);
	}


};



void preorder(BinaryTreeNode * root)
{
	if (root == NULL)
		return;
	cout << root->data << " ";
	preorder(root->left);
	preorder(root->right);
}
void inorder(BinaryTreeNode * root)
{
	if (root == NULL)
		return;
	inorder(root->left);
	cout << root->data << " ";
	inorder(root->right);
}



int main()
{
#ifdef ONLINE_JUDGE
	freeopen("input.txt", "r", stdin);
	freeopen("output.txt", "r", stdin);
#endif


	AVL obj_avl;


	//segmentationfault state
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(31);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(60);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(30);
	// obj_avl.root = obj_avl.insert(40);


	// int option;
	// do {
	// 	cout << "What operation do you want to perform? " <<
	// 	     " Select Option number. Enter 0 to exit." << endl;
	// 	cout << "1. Insert Node" << endl;
	// 	cout << "2. Delete Node" << endl;
	// 	cout << "3. Search Node" << endl;
	// 	cout << "4.  " << endl;
	// 	cout << "5.  " << endl;
	// 	cout << "6.  " << endl;
	// 	cout << "0. Exit Program" << endl;
	// 	cin >> option;
	// 	//Node n1;
	// 	int val;

	// 	switch (option) {
	// 	case 0:
	// 		break;
	// 	case 1:
	// 		cout << "Enter VALUE of TREE NODE to INSERT in AVL Tree: ";
	// 		cin >> val;

	// 		obj_avl.root = obj_avl.insert(val);
	// 		cout << endl;
	// 		break;

	// 	case 2:
	// 		cout << "Enter VALUE of TREE NODE to delete in AVL Tree: ";
	// 		cin >> val;
	// 		obj_avl.root = obj_avl.deleteData(val);
	// 		break;


	// 	case 3:
	// 		cout << "Enter VALUE of TREE NODE to search in AVL: ";
	// 		cin >> val;
	// 		cout << obj_avl.search(val);
	// 		break;

	// 	default:
	// 		cout << "Enter Proper Option number " << endl;
	// 	}

	// } while (option != 0);




	int n = 5;
	int ins[11] = {1, 12, 23, 34, 45, 63, 67, 30, 89, 39, 4};
	for (int i = 0; i < n; ++i)
	{
		obj_avl.root = obj_avl.insert(ins[i]);
	}


	cout << endl;
	cout << "\npreorder :";
	preorder(obj_avl.root);
	cout << "\ninorder  :";
	inorder(obj_avl.root);
	cout << endl;

	int arr[10] = { -1, 9, 20, 23 , 44 , 5, 6 , 40, 50, 67 };
	int k = 7;
	int lar[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
	// for (int i = 0; i < k; ++i)
	// {
	// 	int u;
	// 	int e = lar[i];
	// 	cout << "\nkth largest element : " << e  ;
	// 	u = obj_avl.Element_Kth_largest(e);
	// 	cout << " is:" << u;
	// }
	cout << endl;

	for (int i = 2; i < 8; ++i)
	{
		int l = arr[i];
		int h = arr[i + 1];
		if (l > h)
			swap(l, h);
		cout << "Count of nodes between [" << l << ", " << h << "] is " << obj_avl.count_range(l, h) << endl;
	}

	// for (int i = 0; i < k; ++i)
	// {
	// 	int u;
	// 	int e = arr[i];
	// 	cout << "\nclosest element to : " << e  ;
	// 	u = obj_avl.closest_element(e);
	// 	cout << " is:" << u;
	// }
	// cout << endl;

	// for (int i = 0; i < k; ++i)
	// {
	// 	int u;
	// 	int e = arr[i];
	// 	cout << "\nlower bound of : " << e  ;
	// 	u = obj_avl.lower_bound(e);
	// 	cout << " is:" << u;
	// }
	// cout << endl;
	// for (int i = 0; i < k; ++i)
	// {
	// 	int u;
	// 	int e = arr[i];
	// 	cout << "\nupper bound of :" << e  ;
	// 	u = obj_avl.upper_bound(e);
	// 	cout << ":" << u;
	// }


	// int count_o[10] = {30, 55, 38, 40, 60, 89, 31, 35, 47, 69};
	// for (int i = 0; i < 10; ++i)
	// {
	// 	int s = count_o[i];
	// 	int r  ;

	// 	cout << "\n\ncount:" << s;
	// 	r = obj_avl.count_occurence(s);
	// 	cout << "\nnumber of  " << s << " are :" << r  ;
	// }



	// int find[10] = {30, 55, 38, 40, 60, 89, 31, 35, 47, 69};
	// for (int i = 0; i < 10; ++i)
	// {
	// 	int s = find[i];
	// 	int r = 0;
	// 	cout << "\n\nsearch:" << s;
	// 	r = obj_avl.search(s);
	// 	if (r)
	// 		cout << "\nyes " << s << " is found";
	// 	else
	// 		cout << "\nno. :" << s << " is not found";
	// }


	// cout << endl;
	// cout << "\npreorder :";
	// preorder(obj_avl.root);
	// cout << "\ninorder  :";
	// inorder(obj_avl.root);

	// int del[10] = {50, 38, 60, 56, 3, 30, 60};
	// for (int i = 0; i < 10; ++i)
	// {
	// 	int v = find[i];
	// 	int r = 0;
	// 	cout << "\n\ndelete :" << v << endl;
	// 	r = obj_avl.search(v);
	// 	if (!r)
	// 	{

	// 		cout << "no.    :" << v << " is not found";
	// 	}
	// 	else
	// 	{
	// 		obj_avl.root = obj_avl.deleteData(v);
	// 		cout << "sucessfully deleted :" << v << endl;
	// 		cout << "preorder :";
	// 		preorder(obj_avl.root);
	// 		cout << "\ninorder  :";
	// 		inorder(obj_avl.root);
	// 	}

	// }





	return 0;
}
#include <iostream>
using namespace std;
int main()
{
  int array[] = {10, 20, 30};
  cout << -2[array];
  return 0;
}
#include<iostream>
using namespace std;
int main()
{
  int a = 5, b = 10, c = 15;
  int arr[3] = {&a, &b, &c};
  cout << *arr[*arr[1] - 8];
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  char *ptr;
  char Str[] = "abcdefg";
  ptr = Str;
  ptr += 4;
  cout << ptr;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  char arr[20];
  int i;
  for(i = 0; i < 10; i++)
    *(arr + i) = 65 + i;
  cout << arr;
  return(0);
}
#include <iostream>
using namespace std;
int main()
{
  int a = 5, b = 10, c = 15;
  int *arr[ ] = {&a, &b, &c};
  cout << arr[1];
  return 0;
}
string* x, y;
int (*fp)(char*)
#include <iostream>
using namespace std;
enum channel {star, sony, zee};
enum symbol {hash, star};
int main()
{
  int i = 0;
  for (i = star; i <= zee; i++) 
  {
    printf("%d ", i);
  }
  return 0;
}
#include <iostream>
using namespace std;
enum colour 
{
  green, red, blue, white, yellow, pink
};
int main()
{
  cout << green << " " <<
  red << " " << blue << " " << 
  white << " " << yellow << " " << pink;
  return 0;
}
#include <iostream>
using namespace std;
enum test 
{
  A = 12, B, C
};
int main()
{
  cout << A << " " << B << " " << C;
  return 0;
}
#include <iostream>
using namespace std;
enum  cat 
{
  temp = 6
};
int main()
{
  int age = 12;
  age /= temp;
  cout << "If you were cat, you would be " << age << endl;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  void a = 10, b = 10;
  int c;
  c = a + b;
  cout << c;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  void a;
  a = 5;
  cout << a << endl;
  return 0;
}
// program 1
#include <iostream>
using namespace std;
int main()
{
  register int i = 1;
  int ptr = i;
  cout << ptr;
  return 0;
}

// program 2
#include <iostream>
using namespace std;
int main()
{
  register int i = 1;
  int *ptr = &i;
  cout << *ptr;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  int i = 6;
  int l = i / -5;
  int k = i % -5;
  cout << l << " " << k;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  int a = 8;
  cout << "AND integer 'a' with 'true' :" << (a && true);
  cout << endl;
  cout << "AND integer 'a' with 'true' :" << a && true;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  unsigned int x = 1;
  int y = -2;

  if(x > y) 
  {
    cout << "x is greater";
  }
  else 
  {
    cout << "y is greater";
  }      
}
#include <iostream>
using namespace std;
int main()
{
  int p;
  bool a = true;
  bool b = false;
  int x = 10;
  int y = 5;
  p = ((x | y) + (a + b));
  cout << p << endl;
  return 0;
}
#include <iostream>
using namespace std;
int f(int p, int q)
{
  if (p > q)
    return p;
  else
    return q;
}
main()
{
  int a = 5, b = 10;
  int k;
  bool x = true;
  bool y = f(a, b);
  k =((a * b) + (x + y));
  cout << k;
}
#include <iostream>
using namespace std;
class Point
{
    int x, y;
  public:
   Point(int i = 0, int j =0)
   { x = i; y = j;  }
   int getX() const { return x; }
   int getY() {return y;}
};
 
int main()
{
    const Point t;
    cout << t.getX() << " ";
    cout << t.getY();
    return 0;
}
#include <iostream>
class Test
{
   public:
     void fun();
};
static void Test::fun()   
{
    std::cout<<"fun() is static";
}
int main()
{
    Test::fun();   
    return 0;
}
#include<iostream>
using namespace std;
class Test
{
   private:
     static int count;
   public:
     Test& fun(); 
};
int Test::count = 0;
Test& Test::fun()
{
    Test::count++;
    cout << Test::count << " ";
    return *this;
}
int main()
{
    Test t;
    t.fun().fun().fun().fun();
    return 0;
}
#include <iostream>
using namespace std;
​
int main() {
  int myAge = 35;
  cout << "I am " << myAge << " years old.";
  return 0;
}
​
#include <iostream>
using namespace std;
class A
{
   private:
     int x;
   public:
     A(int _x)  {  x = _x; }
     int get()  { return x; }
};
class B
{
    static A a;
  public:
   static int get()
   {  return a.get(); }
}; 
int main(void)
{
    B b;
    cout << b.get();
    return 0;
}
#include <iostream>
using namespace std;
class Player
{
  private:
    int id;
    static int next_id;
  public:
    int getID() { return id; }
    Player()  {  id = next_id++; }
};
int Player::next_id = 1;
int main()
{
  Player p1;
  Player p2;
  Player p3;
  cout << p1.getID() << " ";
  cout << p2.getID() << " ";
  cout << p3.getID();
  return 0;
}
#include <iostream>
using namespace std;
class Test
{
    static int x;
  public:
    Test() { x++; }
    static int getX() {return x;}
};
int Test::x = 0;
int main()
{
    cout << Test::getX() << " ";
    Test t[5];
    cout << Test::getX();
}
// Program 1
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}

// Program 2
#include <iostream>
int main(int argc, char const *argv[])
{
	std::cout<<"Hello World";
	return 0;
}
#include<stdio.h>
struct STRUCT
{
  int static a;
};
int main()
{
  struct STRUCT s;
  return 0;
}
#include<stdio.h>
struct STRUCT
{
  int a;
  int func()
  {
      printf("HELLO THIS IS STRUCTURE\n");
  }
};
int main()
{
  struct STRUCT s;
  s.func();
  return 0;
}
#include<iostream>
using namespace std;
int main ()
{
   int cin;
   cin >> cin;
   cout << "cin: " << cin;
   return 0;
}
#include<iostream>
using namespace std;
int x[100];
int main()
{
    cout << x[99] << endl;
}
#include<iostream>
using namespace std;
class A
{
  ~A(){
     cout<<"Destructor called\n";
   }
};
int main()
{
    A *a1 = new A();
    A *a2 = new A();
    return 0;
}
#include<iostream>
using namespace std;
class A
{
  ~A(){
    cout<<"Destructor called\n";
  }
};
int main()
{
    A a;
    return 0;
}
#include<iostream>
using namespace std;
int x = 1;
int main()
{
    int x = 2;
    {
        int x = 3;
        cout << ::x << endl;
    }
    return 0;
}
// First program
#include<stdio.h>
int main(int argc, char const *argv[])
{
	printf("%d\n", (int)sizeof('a'));
	return 0;
}

// Second program
#include<stdio.h>
int main(int argc, char const *argv[])
{
	char a = 'a';
	printf("%d\n", (int)sizeof(a));
	return 0;
}
#include <stdio.h> 
void func()
{
	printf("Hello");
}
void main() 
{ 
	func();
	func(2);
}
#include <stdio.h> 
void func(void)
{
	printf("Hello");
}
void main() 
{ 
	func();
	func(2);
}
#include <stdio.h> 
void main() 
{ 
	printf("Hello World"); 
}
#include <stdio.h> 
int main(void) 
{ 
         int new = 5;
         printf("%d", new); 
}
int *p = malloc(10);
#include <stdio.h> 
int main(void) 
{
	const int j = 20; 
	int *ptr = &j;
	printf("*ptr: %d\n", *ptr); 
	return 0; 
}
#include<stdio.h> 
int main() 
{ 
   foo();
}  
int foo() 
{ 
   printf("Hello"); 
   return 0;  
}
int *ptr = new int;
delete ptr;
delete ptr;
int *ptr = NULL;
delete ptr;
#include <iostream>
using namespace std;
 
class A 
{
  int a;
  A() {
    a = 5;
  }
};
 
int main()
{
  A *obj = new A;
  cout << obj->a;
}
#include<iostream> 
using namespace std; 
class Base { 
public: 
  Base() {
    cout << "Constructing Base \n";
  } 
  virtual~Base() {
    cout << "Destructing Base \n";
  }	 
}; 
class Derived: public Base { 
public:
  Derived() {
    cout << "Constructing Derived \n";
  } 
  ~Derived() {
    cout << "Destructing Derived \n";
  } 
}; 
 
int main(void) 
{ 
	Derived *d = new Derived(); 
	Base *b = d; 
	delete b; 
	return 0; 
}
#include<iostream> 
using namespace std; 
class Base { 
public: 
  Base() { 
    cout<<"Constructing Base \n"; 
  } 
  ~Base() { 
    cout<<"Destructing Base \n"; 
  }	 
}; 
class Derived: public Base { 
public: 
  Derived() {
    cout<<"Constructing Derived \n"; 
  } 
  ~Derived() {
    cout<<"Destructing Derived \n"; 
  } 
}; 
 
int main(void) 
{ 
	Derived *d = new Derived(); 
	Base *b = d; 
	delete b; 
	return 0; 
}
#include <iostream>
using namespace std;
class A{
public:
	A(){
		cout<<"Constructor called\n";
	   }
	~A(){
		cout<<"Destructor called\n";
	    } 
};
int main(int argc, char const *argv[])
{
	A *a = new A[5];
	delete[] a;
	return 0;
}
		SHOW DATABASES;
		USE ssd_assignment_2;

					CREATE TABLE PERSON (
							EmpID int NOT NULL PRIMARY KEY,
							NamePrefix varchar(10),
							FirstName varchar(255),
							MiddleInitial varchar(10),
							LastName varchar(255),
							Gender varchar(10),
							Email varchar(255),
							FatherName varchar(255),
							MotherName varchar(255),
							MotherMaidenName varchar(255),
							DOB varchar(12),
							TimeOfBirth varchar(12),
							WeightInKgs int,
							DateOfJoining varchar(12),TimeOfBirth
							Salary int,
							LastHike varchar(10),  
							PlaceName varchar(255),
							Country varchar(255),
							City varchar(255),
							State varchar(255),
							Region varchar(255)
						);
    -- SELECTING PERSON TABLE    
    select * from PERSON;
    
    
    
    --   1.A-----------------------------------
   -- CREATING  hike2022 table   
						   CREATE TABLE hike2022 (
							HikePK int AUTO_INCREMENT PRIMARY KEY,
							EmpIDFK INT ,
							FirstName varchar(255),
							LastName varchar(255),
							Gender varchar(255),
							WeightInKg INT,
							LastHike varchar(10),
							LastSalary INT,
							NewHike varchar(10),
							NewSalary INT ,
							FOREIGN KEY ( EmpIDFK) REFERENCES PERSON ( EmpID) 	
							);
    
 -- drop hike2022 table   
    drop table hike2022;
    
 -- INSERTING FROM TABLE PERSON 
				INSERT INTO hike2022 ( EmpIDFK, FirstName, LastName, Gender, WeightInKg,  LastHike, LastSalary )
								select EmpID,   FirstName, LastName, Gender, WeightInKgs, LastHike, Salary from  PERSON
                                       WHERE WeightInKgs < 50;
                  
   -- SELECTING FROM hike2022 table 
				SELECT * FROM hike2022;
    
 
  -- PROCEDURE FOR UPDATE_HIKE ---------
					drop PROCEDURE UPDATE_HIKE;
				DELIMITER //
					CREATE PROCEDURE UPDATE_HIKE()
					BEGIN
						UPDATE hike2022 
							SET NewHike = CONCAT(cast(CAST(substring(LastHike, 1, length(LastHike)-1) AS unsigned) + 2 as char) , "%" )
								where HikePK != 0 ;
					
						UPDATE hike2022
							SET Newsalary = LastSalary  + (LastSalary * CAST(substring(NewHike, 1, length(NewHike)-1) AS unsigned)) / 100 
								where HikePK != 0 ;
					END  //
				DELIMITER ;					
-- PROCEDURE ENDED

-- EXECUTE AND PRINT HIKE TABLE 
			call `UPDATE_HIKE`();
			select * from hike2022;
            
            -- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
            
            
            drop table PersonJoining;
    --  1.B.---------------------------------------------------------------------
    
					CREATE TABLE PersonJoining (
                       PJoinPK  int AUTO_INCREMENT PRIMARY KEY,
                       EmpIDFK INT ,
                       FirstName varchar(255),
                       LastName varchar(255),
                       DateofBirth varchar(12),
                       Age INT ,
                       DateofJoining varchar(255),
                       DayofJoining varchar(255),
                       MonthofJoining varchar(255),
                       YearofJoining varchar(255),
                       WorkExpinDays varchar(255) ,
                       FOREIGN KEY ( EmpIDFK) REFERENCES PERSON ( EmpID)
                       );
                       
     -- INSERTING FROM TABLE PERSON  TO PERSON JOINING
				INSERT INTO PersonJoining ( EmpIDFK, FirstName, LastName, DateofBirth, DateofJoining )
								     select EmpID,   FirstName, LastName, DOB, 		   DateofJoining
                                          from  PERSON ;
                                       
      -- SELECT FROM PERSONJIONING
              SELECT * FROM PersonJoining ;
              
   -- PROCEDURE FOR UPDATE_DATES ---------
					drop PROCEDURE UPDATE_DATES;
				DELIMITER //
					CREATE PROCEDURE UPDATE_DATES()
					BEGIN
						UPDATE PersonJoining
                         SET AGE =(DATEDIFF(CURRENT_DATE, STR_TO_DATE(DateofBirth, '%m/%d/%Y'))/365.25)							
								where PJoinPK != 0 ;  
                                
                       UPDATE PersonJoining
                         SET   DayofJoining =  substring(DateofJoining,length(DateofJoining)-6, 2) 
                          where PJoinPK != 0 ;
                         
					  UPDATE PersonJoining
                         SET    MonthofJoining =  monthname(STR_TO_DATE(DateofJoining, '%m/%d/%Y'))
                          where PJoinPK != 0 ;
                           
					  UPDATE PersonJoining
                         SET   YearofJoining = substring(DateofJoining,length(DateofJoining)-3, length(DateofJoining) )    
                          where PJoinPK != 0 ;
                          
                      UPDATE PersonJoining
                         SET   WorkExpinDays = (DATEDIFF(CURRENT_DATE, STR_TO_DATE(DateofJoining, '%m/%d/%Y')))							
								where PJoinPK != 0 ;    
					
					END  //
				DELIMITER ;					
-- PROCEDURE ENDED

-- EXECUTE AND PRINT HIKE TABLE 
			call `UPDATE_DATES`();
			select * from PersonJoining;
        
                            
                            
                            
                            
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
 
 DESC PERSON;
 
drop TABLE PersonTransfer ;
 -- 1.c ------------>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
				CREATE TABLE PersonTransfer  (
                       PTPK int AUTO_INCREMENT PRIMARY KEY,
                       EmpIDFK INT,
                       FirstName varchar(255),
                       LastName varchar(255),
                       Gender varchar(10),
                       DateofJoining varchar(12),
                       CurrentRegion varchar(255),
                       NewRegion varchar(255), 
                       WorkExpinYear int ,
                       FOREIGN KEY ( EmpIDFK) REFERENCES PERSON ( EmpID)
                       );
						 
	  -- INSERTING FROM TABLE PERSON  TO PERSON JOINING
				INSERT INTO PersonTransfer ( EmpIDFK, FirstName, LastName, Gender, DateofJoining, CurrentRegion )
								      select EmpID,   FirstName, LastName, Gender, DateofJoining, Region
                                          from  PERSON ;
                                          
                                          
                                                                                 
      -- SELECT FROM PERSONJIONING
              SELECT * FROM PersonTransfer ;
    --           Populate NewRegion column to “DC” using your stored procedure
-- for employees with Gender “F” whose Work Experience is more than 10 years. Populate
-- the NewRegion column to “Capitol” using the same stored procedure for employees with
-- Gender “M” whose Work Experience is more than 20 years. Re-running the storedprocedure should delete the data from existing PersonTransfer table and should
-- repopulate the PersonTransfer tabl
   -- PROCEDURE FOR UPDATE_DATES ---------
					drop PROCEDURE UPDATE_Transfer_city;
				DELIMITER //
					CREATE PROCEDURE UPDATE_Transfer_city()
					BEGIN
						UPDATE PersonTransfer
                         SET WorkExpinYear = (DATEDIFF(CURRENT_DATE, STR_TO_DATE(DateofJoining, '%m/%d/%Y'))/365.25)
                         where PTPK != 0 ;
                        
                        UPDATE PersonTransfer
                         SET NewRegion = "DC"						
								where PTPK != 0 AND Gender ="F" AND WorkExpinYear >10   ;
                                
                         UPDATE PersonTransfer
                         SET NewRegion = "Capitol"						
								where PTPK != 0 AND Gender ="M" AND WorkExpinYear > 20  ;         
					
					END  //
				DELIMITER ;					
-- PROCEDURE ENDED

-- EXECUTE AND PRINT HIKE TABLE 
			call `UPDATE_Transfer_city`();
			select * from PersonTransfer;
            
            
            
            
            
            
            
                            
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
-- =============================================================================================================================
 Q3--->


 SELECT REGION ,TIME_A
   FROM PERSON
    
 
 
 
 
 -- dummy
 
 DROP PROCEDURE IF EXISTS Person_T;
DELIMITER //
CREATE PROCEDURE Person_T()
BEGIN
-- Drop Table IF exists PersonTransfer;
CREATE TABLE PersonTransfer1(
			PT int PRIMARY KEY AUTO_INCREMENT,
            emp_ID int,
            FOREIGN KEY (emp_ID) REFERENCES PERSON(EmpID),
            FirstName varchar(200),
            LastName varchar(200),
            Gender varchar(10),
            DateofJoining date,
            CurrentRegion varchar(200),
            NewRegion varchar (200)
            );
            
INSERT INTO PersonTransfer1(emp_ID, FirstName,LastName,Gender,	DateofJoining,				    CurrentRegion)
					SELECT EmpID,  FirstName,LastName,Gender,STR_TO_DATE(DateofJoining, "%m/%d/%Y"),Region
									FROM PERSON;
UPDATE PersonTransfer1 set NewRegion="DC"
WHERE PT!=0 AND Gender="F" AND (DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),DateofJoining)), '%Y') + 0)>10;

END //
DELIMITER ;

CALL Person_T();
select * from PersonTransfer1 ;


UPDATE   PERSON 
 SET TimeOfBirth =  STR_TO_DATE( TimeofBirth , ' %h:%i:%s %p' )
	where EmpID != 0;
    
    
SELECT Region, 
   COUNT(case when time_format(TimeOfBirth,"%T") between '00:00:00' and '08:00:00' then 1 else 0 end) as daystart,
   COUNT(case when time_format(TimeOfBirth,"%T") between '08:01:00' and '15:00:00' then 1 else 0 end) as midday,
   COUNT(case when time_format(TimeOfBirth,"%T") between '15:01:00' and '23:59:00' then 1 else 0 end) as lastday   
  FROM PERSON
  --  where TimeofBirth between 00: 
  GROUP BY Region;
  
  
  
  				 
						 
	  
                                          
                                                                                 
    
		 
            
            
            
            
            
            
            


#include <iostream>
using namespace std;
class A{
public:
	A(){
		cout<<"Constructor called\n";
	   }
	~A(){
		cout<<"Destructor called\n";
	    }
};
int main(int argc, char const *argv[])
{
	A *a = new A[5];
	delete a;
	return 0;
}
class A
{
    int i;
    public:
    void print(){
      cout<<"hello"<<i;
    }
}
 
class B: public A
{
    int j;
    public:
    void assign(int a){
      j = a;
    }
}
int func(float);
float func(int, int, char);
void test(int arg); //arg is a formal parameter

int main()
{
    int val = 1;
    test(val);  //val is an actual parameter
}
// this is comment

/* 
this 
is
also
comment
*/
// this is comment

/* 
this 
is
also
comment
*/
// case i
var_name
VARNAME
VAR_1234
var_Name

// case ii
1var_name
22VARNAME
987VAR_1234
23var_Name

// case iii
@var_name
+VARNAME
%VAR_1234
!var_Name
// case i
int var_name
VARNAME
VAR_1234
var_Name

// case ii
1var_name
22VARNAME
987VAR_1234
23var_Name

// case iii
@var_name
#VARNAME
%VAR_1234
!var_Name
// case i
var_name
VARNAME
VAR_1234
var_Name

// case ii
1var_name
22VARNAME
987VAR_1234
23var_Name

// case iii
@var_name
#VARNAME
%VAR_1234
!var_Name
#include "header1"
#include "fileHeader"
#include "libraryKita"
#include <iostream>
using namespace std;
​
int main() {
  cout << "Hello World! \n";
  cout << "I am learning C++";
  return 0;
}
​
#include <iostream>
using namespace std;
​
int main() {
  cout << "Hello World!";
  return 0;
}
​
class LRUCache
{
public:
	struct  Node
	{
		int key;
		int value;
		Node *prev;
		Node *next;
	};

	Node *head;
	Node *tail;
	int size , capacity;
	unordered_map<int , Node*>mapi;
	LRUCache(int capacity)
	{
		this->capacity = capacity;
		head = new Node();
		tail = new Node();
		head->next = tail;
		tail->prev = head;
		size =0;
	}

	Node* insertNode(int k , int v)
	{
		Node*newnode = new Node();
		newnode ->key = k;
		newnode->value=v;
		newnode->prev =head;
		newnode->next = head->next;
		newnode->next->prev = newnode;
		head->next = newnode;
		// // unordered_map<int , Node*>mapi
		// pair<int , int> p(k,v);
		mapi.erase(k);
		mapi[k] = newnode; 
		return newnode;
	}

	void pushtowardsHead(Node * newnode)
	{
		if(head->next == newnode)
			return;
		newnode->prev->next = newnode->next;
		newnode->next->prev = newnode->prev;
		newnode->prev =head;
		newnode->next = head->next;
		newnode->next->prev = newnode;
		head->next = newnode;
	}

	void removeTail()
	{
		Node*newnode = tail ->prev;
		tail->prev = newnode ->prev;
		newnode->prev->next= tail;
		mapi.erase(newnode->key);
	}

	int get(int k)
	{
		if(mapi.find(k) == mapi.end())
			return -1;
		Node* newnode =mapi[k];
		pushtowardsHead(newnode);
		return newnode->value;
	}

	void put(int k ,int v)
	{
		if(mapi.find(k)!=mapi.end())
		{//already present
			Node*newnode = mapi[k];
			newnode->value = v;
			pushtowardsHead(newnode);
			return;
		}

		insertNode(k,v);
		if(size <capacity)
		{
			size++;
			return;
		}
		else
		{
			removeTail();
		}
	}
};	
#include <bits/stdc++.h>
using namespace std;
class Solution
{
    public:
    vector<int> subarraySum(int arr[], int n, long long s)
    {
    
        long long sum=0;
        for(long long int i=0;i<n;i++){
            sum=arr[i];
            if(sum==s) return {i+1,i+1};
            for(long long int j=i+1;j<n;j++){
                sum+=arr[j];
                if(sum==s) return {i+1 , j+1};
                else if(sum>s) break;
            }
        }
        return {-1};
       
    }
};

int main()
 {
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        long long s;
        cin>>n>>s;
        int arr[n];
        const int mx = 1e9;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        Solution ob;
        vector<int>res;
        res = ob.subarraySum(arr, n, s);
        
        for(int i = 0;i<res.size();i++)
            cout<<res[i]<<" ";
        cout<<endl;
        
    }
	return 0;
}
#include<bits/stdc++.h>
using namespace std;


struct Node{
    int data;
    struct Node *next;
    Node(int data){
        this->data = data;
        next = NULL;
    }
};
    
    
struct LinkedList {
    
    Node *head;
    LinkedList() { head = NULL;}
    
    
    void reverse()
    {
        Node *current = head;
        Node *prev = NULL;
        Node *next = NULL;
        
        while(current != NULL) {
            next = current->next;
            current-> next = prev;
            prev = current;
            current = next;
        }
        head = prev;
    }
    
    
    void print()
    {
        struct Node* temp = head;
        while(temp != NULL){
            cout << temp->data << " ";
            temp = temp->next;
        }
    }
    
    
    void push(int data)
    {
        Node *temp = new Node(data);
        temp -> next = head;
        head = temp;
    }
};
    
int main()
{
    LinkedList ll;
    ll.push(1);
    ll.push(2);
    ll.push(3);
    ll.push(4);
    
    
    ll.print();
    cout << endl;
    
    ll.reverse();
    ll.print();
    
    return 0;
}
//----------------------------header files------------
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<termios.h>
#include<unistd.h>
#include<ctype.h>
#include<limits.h>
#include<dirent.h>
#include<sys/stat.h>
#include<algorithm>
#include<iomanip>
#include<sys/ioctl.h>
#include<stack>
#include<pwd.h>
#include<grp.h>
#include<signal.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<fstream>
#include<fcntl.h>
#include <cmath>
#include<iomanip>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include<cstring>
#include<dirent.h>
using namespace std;

//--------------------user defined--------
#define UP 65
#define DOWN 66
#define RIGHT 67
#define LEFT 68
#define ENTER 10
#define MODE 0777
#define BUF_SIZE 8192


//---------global items-----------------

vector<string>vec_dir_list;
int directory_position = 1;
stack<string>back_stack;
stack<string>forward_stack;
string curr_dir ;
int LIST_SIZE ;
stack <string>st;



//---------stat------------------

static struct termios term, oterm;
struct termios raw;
struct termios raw_out;
struct termios orig_termios;


//----------------FUNCTION PROTOTYPES------------

void keys(string  );
void enableRawMode() ;
void disableRawMode();
void enableRawMode2() ;
void createdir(string , string);
int search(string , string);
vector<string> getcommand();
void create_file(string , string);
void create_dir(string , string);
void delete_dir(string );
void keys(string);
void copy_file(string , string );
void copy_dir(string , string );
void move_file(string , string );
void move_dir(string , string );
void delete_file( string );
void delete_dir(string );
string name_of_folder(string );//get path from back upto 1st '/'
void rename(string, int , vector<string>);

//-----------------RAW MODE ----------------
void disableRawMode();
void enableRawMode();
void editorRefreshScreen()
{
	write(STDOUT_FILENO, "\x1b[2J", 4);
}

string cwd()
{
	// string a = get_current_dir_name();
	// return a;
	char cwd[100];
	getcwd(cwd, sizeof(cwd));
	string a = cwd;
	return a;
}
string prnt = cwd();

int isfolder(string fileName)
{
	struct stat path;

	stat(fileName.c_str(), &path);

	return S_ISREG(path.st_mode);
}


int isDir(const char* fileName)
{
	struct stat path;

	stat(fileName, &path);

	return S_ISREG(path.st_mode);
}

void clear()
{
	cout << "\033[2J\033[1;1H";
	// printf(" \033[%d;%dH", 4, 0);
}

string output_permissions(mode_t st)
{
	string s = "";

	s += ( st & S_IRUSR ? "r" : "-" );
	s += ( st & S_IWUSR ? "w" : "-" );
	s += ( st & S_IXUSR ? "x" : "-" );
	s += ( st & S_IRGRP ? "r" : "-" );
	s += ( st & S_IWGRP ? "w" : "-" );
	s += ( st & S_IXGRP ? "x" : "-" );
	s += ( st & S_IROTH ? "r" : "-" );
	s += ( st & S_IWOTH ? "w" : "-" );
	s += ( st & S_IXOTH ? "x" : "-" );
	return s;
}
string check_tilda(string s)
{
	string t = "";
	t += s[0];
	if (t == "~")
	{
		t = s.substr(1, s.length() - 1);
		const char *homedir;
		if ((homedir = getenv("HOME")) == NULL)
		{
			homedir = getpwuid(getuid())->pw_dir;
		}
		t = homedir + t;
		return t;
	}
	else if (t == "/")
	{
		return s;
	}
	return "";
}


//---PRINT DATA OF A PARTICULAR FILE
void print ()
{
	struct group *grp;
	struct passwd *pwd;
	struct stat st;
	for (int i = 0; i < vec_dir_list.size(); i++)
	{
		stat(vec_dir_list[i].c_str(), &st);
		string perm = output_permissions(st.st_mode);

		cout << setw(2) << perm << "\t";

		//2.links
		string link =  to_string(st.st_nlink);
		cout << setw(2) << link << "\t";

		//3.group id
		grp = getgrgid(st.st_uid );
		//printf(" %s", grp->gr_name);
		//temp.push_back(grp->gr_name);
		cout << setw(2) << grp->gr_name << "\t";

		//4.person id
		pwd = getpwuid(st.st_gid);
		//printf(" %s", pwd->pw_name);
		cout << setw(2) << pwd->pw_name << "\t  ";

		//5.size
		int size = st.st_size;
		float a = size / 1024.0;
		cout << setw(6) << fixed << setprecision(2) << a << " KB\t  ";


		//6.modified time
		string time = ctime(&st.st_mtime) ;
		string t2 = time.substr(0, time.length() - 1);
		cout << setw(2) << t2 << "\t";

		cout << left << setw(10) << vec_dir_list[i];
		cout << endl;
	}
}

//-------------Push all files of Current dir to vector------------------
void listFiles(string dir_name)
{
	clear();

	vec_dir_list.clear();
	DIR * dir = opendir(dir_name.c_str());
	if (dir == NULL)
		return ;

	dirent *entity;
	entity = readdir(dir);

	struct stat st;

	while ( entity != NULL)
	{
		stat(entity->d_name, &st);
		vec_dir_list.push_back(entity->d_name);
		entity = readdir(dir);
	}

	//Sort on basis of name
	sort(vec_dir_list.begin(), vec_dir_list.end());
	// sort(file_name.begin(), file_name.end());

	closedir(dir);
	print();
}



//------------********keys -*****-(most important)--------------

void keys(string pwd)
{
	LIST_SIZE = vec_dir_list.size();
	cout << LIST_SIZE << endl;
	int pos = 0;
	char ch;
	curr_dir = cwd();
	printf(" \e[H");
	while (1)
	{
		ch = cin.get();
		if (ch == DOWN)
		{
			if (pos < LIST_SIZE)
			{

				pos++;
				directory_position = pos;

				printf("%c[%d;%df", 0x1B, pos, 1);
				// cout << pos;
			}
		}
		else if (ch == UP)
		{
			if (pos >= 0)
			{
				pos--;
				directory_position = pos;


				printf("%c[%d;%df", 0x1B, pos, 1);
				// cout << pos;
			}
		}
		else if (ch == ENTER)
		{
			struct stat st;


			string s = pwd;
			s += "/" + vec_dir_list[directory_position - 1];

			stat(s.c_str(), &st);


			if ((st.st_mode & S_IFMT) == S_IFDIR)
			{

				back_stack.push(pwd);
				pwd = s;
				curr_dir = pwd;
				cout << "curr_dir :" << curr_dir << endl;
				clear();
				vec_dir_list.clear();
				// cout << s << "-----------------" << endl;
				directory_position = 1;
				listFiles(s);
				keys(s);
			}
			else if ((st.st_mode & S_IFMT) == S_IFREG)
			{
				pid_t pid = fork();
				if (pid == 0)
				{
					execlp("xdg-open", "xdg-open", s.c_str(), NULL);
					exit(0);
				}

			}


		}
		else if (ch == LEFT)
		{
			if (!back_stack.empty())
			{
				clear();
				string s = back_stack.top();
				forward_stack.push(s);//current push to forward
				back_stack.pop();
				listFiles(s);
				keys(s);

			}
		}
		else if (ch == RIGHT)
		{

			if (!forward_stack.empty())
			{
				clear();
				string s = forward_stack.top();
				forward_stack.pop();
				back_stack.push(pwd);
				listFiles(s);
				keys(s);
			}
		}
		else if ( ch ==  127) //backspace
		{
			clear();

			// int i;
			// for (i = prnt.length() - 1; prnt[i] != '/' && i >= 0; i--);
			// prnt = prnt.substr(0, i);
			back_stack.push(curr_dir);
			// pwd = prnt;
			curr_dir += "/";
			curr_dir += "..";
			listFiles(curr_dir);
		}
		else if (ch == 104) //home directrotry
		{
			clear();
			const char *homedir;

			if ((homedir = getenv("HOME")) == NULL)
			{
				homedir = getpwuid(getuid())->pw_dir;
			}
			back_stack.push(curr_dir);
			pwd = string(homedir);

			curr_dir = string(homedir);
			listFiles(pwd);
			keys(pwd);
		}
		else if (ch == 'q')
		{
			printf("\033c");
			return;
		}
		else if (ch == ':')
		{
			// clear();
			disableRawMode();
			enableRawMode2();
			// editorRefreshScreen();
			// cout << "YOU ARE IN COMMAND MODE : \n";
			// char c = cin.get();

			struct winsize w;
			ioctl(0, TIOCGWINSZ, &w);
			int rows = w.ws_row;
			int a = rows - 12;


			printf("\033[%d;1H", a);
			printf("\033[0;36m""COMMAND MODE STARTED:\n ");
			cout << "CURRENT PATH IS :" << curr_dir << endl;
			cout << "$ ";

			while (1)
			{
				char c;
				vector <string> v;
				v = getcommand();

				if (v[0] == "rename")
				{
					if (v.size() != 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG FILE NAME :\n";
						break;
					}
					rename(pwd, a, v);
				}
				else if (v[0] == "27")//to escape
				{

					enableRawMode();
					clear();
					listFiles(curr_dir);
					keys(curr_dir);
				}
				else if (v[0] == "quit")
				{	//write quit then space then enter to quit

					printf("\033c");
					return;
				}
				else if (v[0] == "goto")
				{

					if (v.size() != 2)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}

					curr_dir = check_tilda(v[1]);
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";
				}
				else if (v[0] == "create_file")
				{
					if (v.size() != 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					string path = check_tilda(v[2]);

					create_file(v[1] , path);
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";
				}
				else if ( v[0] == "create_dir")//create_dir
				{

					if (v.size() != 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					string path = check_tilda(v[2]);
					create_dir(v[1], path);
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";
				}
				else if (v[0] == "search") //search file or folder
				{
					if (v.size() != 2)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					int t = search(v[1] , ".");
					if (t == 1)
						cout << "TRUE";
					else
						cout << "FALSE";
				}
				else if (v[0] == "delete_file")
				{
					if (v.size() != 2)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					string s = check_tilda(v[1]);
					s += "/" + v[1];
					if (remove(v[1].c_str()))
						cout << "fail";
					else
						cout << "success";

					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string st = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << st << endl;
					cout << "$ ";
				}
				else if (v[0] == "delete_dir")
				{
					if (v.size() != 2)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					// string s = check_tilda(v[1]);
					// s += "/" + v[1];
					delete_dir(v[1]);//complete path name pr hi kaam karega


					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string st = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << st << endl;
					cout << "$ ";
				}
				else if (v[0] == "copy")
				{
					if (v.size() < 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					for (int i = 1; i <= v.size() - 2; i++)
					{
						string des_path = check_tilda(v[v.size() - 1]);
						
						
						
						if (!isfolder(v[i])) //opposite return true k liye 0
						{
							des_path += "/" + v[i];
							mkdir( des_path.c_str(), 0777 );

							string sa = get_current_dir_name();
							string source_foldr = sa + "/" + v[i];

							copy_dir(source_foldr, des_path );
						}
						else
						{
							string s = curr_dir + "/" + v[i];
							cout << "\n\n\n\n\n\n\n:::::: " << curr_dir << "  \n:::\n\n\n\n\n";
							copy_file(s, des_path);
						}
					}
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";

				}
				else if (v[0] == "move")
				{
					if (v.size() < 3)
					{
						clear();
						pwd = curr_dir;
						listFiles(pwd);
						printf("\033[%d;1H", a);
						printf("\033[0;36m""COMMAND MODE STARTED:\n ");
						cout << "WRONG COMMAND :\n";
						cout << "CURRENT PATH IS :" << curr_dir << endl;
						cout << "$ ";
						break;
					}
					for (int i = 1; i <= v.size() - 2; i++)
					{
						string des_path = check_tilda(v[v.size() - 1]);
						if (!isfolder(des_path)) //opposite return true k liye 0
						{
							string folder_n = curr_dir + "/" + v[i];
							des_path += "/" + v[i];
							move_dir(folder_n , des_path );
						}
						else
						{
							string s = curr_dir + "/" + v[i];
							move_file(s, des_path);
						}
					}
					pwd = curr_dir;
					clear();
					listFiles(pwd);
					// keys(pwd);
					printf("\033[%d;1H", a);
					printf("\033[0;36m""COMMAND MODE STARTED:\n ");
					string s = realpath(curr_dir.c_str(), NULL);
					cout << "CURRENT PATH IS :" << s << endl;
					cout << "$ ";
				}

			}
		}

	}
}

void rename(string pwd, int a, vector<string>v)
{
	string s = curr_dir;
	cout << "curr_dir: " << curr_dir << endl;
	string aa = "";
	string b = "";
	aa += s + "/" + v[1];
	b += s + "/" + v[2];
	int result = rename(aa.c_str() , b.c_str() );
	clear();
	pwd = curr_dir;
	listFiles(pwd);
	printf("\033[%d;1H", a);
	printf("\033[0;36m""COMMAND MODE STARTED:\n ");
	string ss = realpath(curr_dir.c_str(), NULL);
	if (result == 0)
		cout << "successful rename\n";
	else
		cout << "Write file name carefully\n";
	cout << "CURRENT PATH IS :" << ss << endl;
	cout << "$ ";
}
void move_file(string fileName, string destination)
{
	copy_file(fileName , destination);


	if (remove(fileName.c_str()))
		cout << "fail";
	else
		cout << "success";
	return;
}

void move_dir(string source , string destination)
{

	int result = rename(source.c_str() , destination.c_str() );
	if (result == 0)
		cout << "success";
	else
		cout << "something went wrong";
}

void copy_file(string sr, string dt)
{


  int src, dst, in, out;
  char buf[BUF_SIZE];
  // if (argc != 3) exit(1);

  src = open(sr.c_str(), O_RDONLY);
  if (src < 0)
    exit(2);
  // dt += "/" + sr;//complete path +name
  dst = creat(dt.c_str(), MODE);
  if (dst < 0)
    exit(3);
  while (1) {
    in = read(src, buf, BUF_SIZE);
    if (in <= 0) break;
    out = write(dst, buf, in);
    if (out <= 0) break;
  }
  close(src); close(dst); return;
}



void copy_dir(string folderName, string destination)
{

	DIR* dir = opendir(folderName.c_str());
	if (dir == NULL)
	{
		printf("no such source directory found\n");
		return;
	}
	// cout << folderName << endl;

	struct dirent* entity;
	while ((entity = readdir(dir)) != NULL )
	{
		// printf("%hhd  %s\n", entity->d_type,   entity->d_name);
		if ( string(entity->d_name) == "." || string(entity->d_name) == "..")
		{
			// cout << string(entity->d_name) << endl;
			continue;
		}
		else
		{
			string s = string(entity->d_name);
			string source_path = folderName + "/" + entity->d_name;
			struct stat tmp;
			if (stat(source_path.c_str(), &tmp) == -1)
			{
				printf(" cannot get souurce  stat\n");
				continue;
			}
			if (!isfolder(source_path))
			{
				string dest_path = destination + "/" + entity->d_name;
				mkdir( dest_path.c_str(), 0777 );
				copy_dir(source_path, dest_path );
			}
			else
			{
				string dest_path = destination + "/" + entity->d_name;
				copy_file(source_path, dest_path);
			}

			// cout << "entity name: " << s << endl;
			// cout << "source_path:" << source_path << endl;
			// cout << "destination_path" << dest_path << endl;
		}


	}
	closedir(dir);

	return;
}


void create_file(string  Name , string folder)//create_file
{
	string s = folder;
	s += "/" + Name;
	FILE* file = fopen(s.c_str(), "w+");
	fclose(file);

}


void create_dir(string Name , string folder)
{

	string s = folder;
	s += "/" + Name;
	mkdir( s.c_str(), 0775 );
}


string name_of_folder(string path)//last piche se folder 
{
	string a = "";
	for (int i = path.length() - 1; i >= 0 ; -- i)
	{
		string m = "";
		m += path[i];
		if (m != "/")
			a += m;
		else
			break;
	}

	path = "";
	for (int i = a.length() - 1; i >= 0; i--)
	{
		path += a[i];
	}
	return path;

}


int  search(string Name , string folder)
{
	DIR* dir = opendir(folder.c_str());
	if (dir == NULL) {
		return 0;
	}
	struct dirent* entity;
	entity = readdir(dir);
	while (entity != NULL)
	{
		if (entity->d_type == DT_DIR && strcmp(entity->d_name, ".") != 0 && strcmp(entity->d_name, "..") != 0)
		{
			string folder_name = name_of_folder(folder);
			if (Name == entity->d_name)
			{
				return 1;
			}


			char path[100] = { 0 };
			strcat(path, folder.c_str());
			strcat(path, "/");
			strcat(path, entity->d_name);
			if ((search(Name , path)))
				return 1;
		}
		else
		{
			if (entity->d_name == Name)
			{
				return 1;
			}
		}
		entity = readdir(dir);
	}
	closedir(dir);
	return 0;
}

void delete_dir(string dirname)
{
	DIR* dir = opendir(dirname.c_str());
	if (dir == NULL) {
		return;
	}

	int count = 5;
	// printf("Reading files in: %s\n", dirname);

	struct dirent* entity;
	while ((entity = readdir(dir)) != NULL && (count-- > 0))
	{
		if (entity->d_name == "."  || entity->d_name == "..")
			continue;
		else if (entity->d_type == DT_DIR && strcmp(entity->d_name, ".") != 0 && strcmp(entity->d_name, "..") != 0)
		{
			string path = dirname + "/" + entity->d_name;
			// cout << "foldr_name: " << entity->d_name << endl;
			delete_dir(path);
		}
		else
		{
			string path = dirname + "/" + entity->d_name;
			// cout << "\n--fiile:  " << entity->d_name << endl;
			// cout << "file_path: " << path << endl;
			if (strcmp(entity->d_name, ".") != 0 && strcmp(entity->d_name, "..") != 0)
			{
				int status = remove(path.c_str());
				if (status == 0)
					cout << "\nFile Deleted Successfully!\n";
				else
					cout << "\nIN FILE Error Occurred!\n";
			}
		}

	}
	closedir(dir);

	// string path = dirname + "/" + entity->d_name;
	// cout << "foldr_name: " << dirname << endl;
	int status = remove(dirname.c_str());

	if (status == 0)
		cout << "\nFOLDER Deleted Successfully!\n";
	else
		cout << "\nIN FOLDER Error Occurred!\n";
	return;
}










void enableRawMode2() {
	tcgetattr(STDIN_FILENO, &orig_termios);
	atexit(disableRawMode);
	struct termios raw = orig_termios;
	raw.c_lflag &= ~(ICANON);
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}


void disableRawMode() {
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}


void enableRawMode() {
	tcgetattr(STDIN_FILENO, &orig_termios);
	atexit(disableRawMode);
	struct termios raw = orig_termios;
	raw.c_lflag &= ~(ECHO | ICANON);
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}

vector<string> getcommand()
{

	char ch;
	string s ;

	getline (cin , s);

	//-------------------------------------------------
	// string s = "";
	// char c;
	// c = cin.get();
	// while (c != 10)
	// {
	// 	if (c != 127)
	// 	{
	// 		s += c;
	// 	}
	// 	else if (c == 127)
	// 	{
	// 		printf ("\033[0K");
	// 		s = s.substr(0, s.length() - 1);
	// 		cout << s;
	// 	}
	// 	c = cin.get();
	// }
	//---------------------------------------------------------
	vector<string> v;
	string input = "";
	for (int i = 0; i < s.length() ; ++i)
	{
		string m = "";
		m += s[i];
		if (m != " ")
		{
			input += m;

		}
		else if (m == " ")
		{
			v.push_back(input);
			input = "";
		}


	}
	v.push_back(input);
	return v;

}



int main()
{
	clear();
	enableRawMode();//enable to get into canonicall mode
	// /get_current_dir_name()
	curr_dir = get_current_dir_name(); //global path
	back_stack.push(curr_dir);
	listFiles(curr_dir);
	keys(curr_dir);
	return 0;
}
// if you want to know a distance between the number and divisor of other number
int n,m;
n = 3, m = 17;
int mod = 17 % 3;     //3 is a divisor of 15 and distance between 15 and 18 is 2 
cout<<mod;            // 2
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;

int Partition(int *A, int start, int end)
{
    int pivot = A[end];
    int partitionIndex = start;
    for(int i =start; i < end; i++)
    {
        if(A[i]<= pivot)
        {
            swap(A[i], A[partitionIndex]);
            partitionIndex++;
        }
    }
    swap(A[partitionIndex], A[end]);
    return partitionIndex;
}

void QuickSort(int *A, int start, int end)
{
    if(start < end)
    {
        int pertitionIndex = Partition(A, start, end);
        QuickSort(A, start, pertitionIndex-1);
        QuickSort(A, pertitionIndex+1, end);
    }
}

int main() {
    int A[] = {7,6,5,4,3,2,1,0};
    QuickSort(A, 0, 7);
    for (int i = 0; i<8; i++) cout<<A[i]<<" ";
    return 0;
}
void ABolter::BeginPlay()
{
	Super::BeginPlay();
	
	CurrentAmmoWithYou = FMath::DivideAndRoundUp(MaxAmmoCarry, 2);
	CurrentAmmoInMagazine = MaxAmmoMagazine;
	CurrentAmmoWithYou -= CurrentAmmoInMagazine;
}

void ABolter::Fire()
{
	if (CurrentAmmoInMagazine <= 0)
	{
		UGameplayStatics::PlaySoundAtLocation(SkeletalMesh, EmptyMagazineSound, 
        this->GetActorLocation(), 
        this->GetActorRotation());
		return;
	}
  
	--CurrentAmmoInMagazine;
}

void ABolter::StopFireRate()
{
	if (!GetWorldTimerManager().IsTimerActive(FireRateTimerHandle)) { return; }

	GetWorldTimerManager().ClearTimer(FireRateTimerHandle);
}

bool ABolter::IsShooting()
{
	return GetWorldTimerManager().IsTimerActive(FireRateTimerHandle);
}

void ABolter::Reload()
{
	OwnerCharacterSpaceMarine = Cast<ASpaceMarineCharacter>(GetOwner());

	if (CurrentAmmoWithYou > 0 && CurrentAmmoInMagazine != MaxAmmoMagazine && !IsShooting())
	{
		if (!OwnerCharacterSpaceMarine) { return; }

		OwnerCharacterSpaceMarine->SetIsReloading(true);
		OwnerCharacterSpaceMarine->GetCharacterMovement()->MaxWalkSpeed = 300.f;

		UGameplayStatics::PlaySoundAtLocation(SkeletalMesh, ReloadSound, this->GetActorLocation(), this->GetActorRotation());
		GetWorldTimerManager().SetTimer(ReloadTimer, this, &ABolter::CalculateBulletsAmountToReload, ReloadTime);
	}
}

void ABolter::CalculateBulletsAmountToReload()
{
	OwnerCharacterSpaceMarine->SetIsReloading(false);
	OwnerCharacterSpaceMarine->GetCharacterMovement()->MaxWalkSpeed = 600.f;

	int32 AmmoToReload = MaxAmmoMagazine - CurrentAmmoInMagazine;

	if (CurrentAmmoWithYou < AmmoToReload)
	{
		CurrentAmmoInMagazine += CurrentAmmoWithYou;
		CurrentAmmoWithYou = 0;
	}
	else
	{
		CurrentAmmoInMagazine += AmmoToReload;
		CurrentAmmoWithYou -= AmmoToReload;

		if (CurrentAmmoWithYou < 0)
		{
			CurrentAmmoWithYou = 0;
		}
	}
}

int32 ABolter::GetAmmoInMagazineValue()
{
	return CurrentAmmoInMagazine;
}

int32 ABolter::GetAmmoWithYouValue()
{
	return CurrentAmmoWithYou;
}

void ABolter::ReplenishAmmo()
{
	if (CurrentAmmoWithYou < MaxAmmoCarry)
	{
		UGameplayStatics::PlaySoundAtLocation(SkeletalMesh, TakeAmmo, this->GetActorLocation(), this->GetActorRotation());

		CurrentAmmoWithYou = MaxAmmoCarry;
	}
}
private:
	int32 CurrentAmmoWithYou;
	int32 CurrentAmmoInMagazine;

	UPROPERTY(EditAnywhere, Category = "Statistics")
	float ReloadTime = 1.6f;
	UPROPERTY(EditAnywhere, Category="Statistics")
	float MaxDistance = 100.f;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	float Damage = 10.f;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	int32 MaxAmmoCarry = 360;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	int32 MaxAmmoMagazine = 15;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	float AccuracyMin = 0;
	UPROPERTY(EditAnywhere, Category = "Statistics")
	float AccuracyMax = 0;

	FTimerHandle ReloadTimer;

	void CalculateBulletsAmountToReload();

public:	
	bool IsShooting();
	void ReplenishAmmo();

	int32 GetAmmoInMagazineValue();
	int32 GetAmmoWithYouValue();
//general approach Template
void Backtrack(int start)
{
    //Base case 

// loop for all possible values
{
    //include the current element at this position if possible in the ans 
	//More generally, make a choice 

    Backtrack(start+1) 

    //backtrack by removing current element 
}
                            ------------------------------------------------

//Generate all subsets (non dublicated)
int n;
void GenerateSubs(vector<int> &a, int s, vector<int> &subset, vector<vector<int>> &ans) {
    for (int i = s; i < n; i++) {
        subset.push_back(a[i]); //include element at ith position
        GenerateSubs(a, i + 1, subset, ans); //generate all subsets including ith element
        subset.pop_back(); //backtrack
    }
    ans.push_back(subset);
}

vector<vector<int>> subsets(vector<int> &a) {
    vector<vector<int>> ans;
    vector<int> subset;
    n = a.size();

    GenerateSubs(a, 0, subset, ans);
    return ans;
}

int main() {
    fast;
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> ans(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ans = subsets(a);
    for (vector<int> i: ans) {
        for (int j: i) {
            cout << j;
        }
        cout << '\n';
    }
}
// i/p :
  //3
  //1,2,3
// o/p : 
                              ------------------------------------------------

//Generate all subsets (dublicated)
int n;
void GenerateSubs(vector<int>&a,int s,vector<int>&subset,vector<vector<int>>&ans)
{
    for(int i=s;i<n;i++)
    {
        if(i==s||a[i]!=a[i-1])
        {
            subset.push_back(a[i]); //include element at ith position
            GenerateSubs(a,i+1,subset,ans); //generate all subsets including ith element
            subset.pop_back(); //backtrack
        }
    }
    ans.push_back(subset);
}
vector<vector<int>> subsetsWithDup(vector<int> &a) {
    vector<vector<int>> ans;
    vector<int> subset;
    n = a.size();

    sort(a.begin(), a.end()); //sort the elements so that we can keep track of duplicates
    GenerateSubs(a, 0, subset, ans);
    return ans;
}

int main() {
    fast;
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
#endif
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> ans(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ans = subsetsWithDup(a);
    for (vector<int> i: ans) {
        for (int j: i) {
            cout << j;
        }
        cout << '\n';
    }
}
// i/p :
  //4
  //1 2 3 2
/* o/p :
1223
122
123
12
13
1
223
22
23
2
3
  */
                              ------------------------------------------------
                              ------------------------------------------------

//---------------------------------------Examples--------------------------------------------------
//Generate all subset instead '?'
string s;
string o;

void solve(int i) {
    //base case
    if (i == s.length()) {
        for (int j = 0; j < s.length(); ++j) {
            cout << o[j];
        }
        cout << '\n';
        return;
    }
    if (s[i] != '?') {
        o[i] = s[i];
        solve(i + 1);
    } else {
        for (int j = 'a'; j <= 'z'; ++j) {
            o[i] = j;
            solve(i + 1);
        }
    }
}


int main() {
    cin >> s;
    solve(0);
}
---------------------------------------------------------------------------------------------------
//Generating Permutations Using next_permutation

int n;
int const N = 11;
bool taken[N];
int stk[N];

void prm(int i) {
    //base case
    if (i == n) {
        for (int j = 0; j < n; ++j) {
            cout << stk[j] << ' ';
        }
        cout << el;
        return;
    }
    for (int j = 1; j <= n; ++j) {
        if (!taken[j]) {
            taken[j] = true;
            stk[i] = j;
            prm(i + 1);
            taken[j] = false;
        }
    }
}


int main() {

    fast;
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
#endif
    cin >> n;
    prm(0);
}
---------------------------------------------------------------------------------------------------
//  
// Left shift ---> Multiplying by 2 
int x = 6;
x <<= 1;
cout << x;   // 12
--------------------------------------------------------------------------------------------------
//Right shift ---> Divide by 2 
int x = 12;
x >>= 1;
cout << x;   // 6
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
//  Checking if given 32 bit integer is power of 2 
// if true return 1 else return 0
int isPowerof2(int x)
{
    return (x && !(x & x-1));
}
--------------------------------------------------------------------------------------------------
// Find log base 2 of 32 bit integer
// log2(8)=3 when 2^3 = 8
int log2(int x)
{
    int res = 0;
    while (x >>= 1)
        res++;
    return res;
}
--------------------------------------------------------------------------------------------------
#include<iostream>
using namespace std;

int main(){

//finding the length of the string

    string para = "I am Rishi";
    cout << para.length() << endl;

//finding according to the index of the string

    cout << para[2] << endl;

// replacing a string

    para[0] = 'G';
    cout << para << endl;

//substring

    cout  << para.substr(3, 4);

// creating another variable for the substring

    string parasub = para.substr(3, 4);
    cout << parasub << endl;

    return 0;
}

//1- (string) ---> (int)
stoi("String name");
 
//2- (int) ---> (string)
int n;
cin>>n;
String s = to_string(n);
cout<<s;
 
//3- (char) ---> (int)
String str;
cin>>str;
for(int i; str[i], i++){
  char ch = str[i]-'0';   //note:(str[i]-'0') to convert str[i] character to integer
  cout<<ch;
}
  
//3- (int) ---> (char)
int n;
cin>>n;
char ch = (char) n;
cout<<ch;
 
//4- (int) ---> (long long)
int a;
a = a*1LL;
 
//5- (double) ---> (int) && flooring number
double n = 7.99999999;
n = (int) n;
//Binary Search implementation //Time Complexity: O (log n) //return int {-1 , mid index}
int binarySearch(int tar, vector<int>& arr){
int lo=0, md, hi=arr.size()-1;
while(hi>=lo){
md = lo + (hi - lo) / 2;
if(arr[md]==tar) return md;
else if(arr[md]<tar) lo=md+1;
   		else hi=md-1;
}
return -1;
}
---------------------------------------------------------------------------------------------------
//Binary Search by using Stls //Time Complexity: O (log n)
// for binary search in containers like vector (let target element=6)
binary_search(v.begin(), v.end(), 6); 
// return 1 or 0 as present or not
---------------------------------------------------------------------------------------------------
//binary search with lower and upper bound by using stls
int x, ans; //x is passing value, ans is a value you want, v --> vector or any container
ans = lower_bound(v.begin(), v.end(), x) - v.begin(); //ans >= x (equal number or first number after x)
ans = upper_bound(v.begin(), v.end(), x) - v.begin(); // ans > x (first number after x)

//implementation
int lower_bound(vector<int> nums, int target){
        int l = 0, r = nums.size()-1, m = 0;
        while(l < r) {
            m = (l+r)/2;
            if(nums[m] < target)
                l = m+1;
            else 
                r = m;
        }
        return r;
    }

    int upper_bound(vector<int> nums, int target){
        int l = 0, r = nums.size()-1, m = 0;
        while(l < r) {
            m = (l+r)/2;
            if(nums[m] <= target)
                l = m+1;
            else 
                r = m;
        }
        return r;
    }
---------------------------------------------------------------------------------------------------
// Two Pointer implementation
// Two pointer technique based solution to find
// if there is a pair in A[0..N-1] with a given sum.
int isPairSum(int A[], int N, int X)
{
    // represents first pointer
    int i = 0;
  
    // represents second pointer
    int j = N - 1;
  
    while (i < j) {
      
        int curSum = A[i]+arr[j];
      
        // If we find a pair
        if curSum == X)
            return 1;
  
        // If sum of elements at current
        // pointers is less, we move towards
        // higher values by doing i++
        else if (curSum < X)
            i++;
  
        // If sum of elements at current
        // pointers is more, we move towards
        // lower values by doing j--
        else
            j--;
    }
    return 0;
}
//Sum of numbers from 1 ---> n
int n, sum;
sum = (n*(n+1))/2;
 
//flooring integer number (int)        "floor أرضيه"
int a=5, b=2;
int n = a/b; // n= 2
 
//Ceiling integer number (int)          "ceil سقف"
int a=5, b=2;
int ans = (a+(b-1))/b; //n=3
 
//Division Theory 
int a=10, b=3;     // a ---> numerator البسط / b ---> denominator المقام
int ans = a/b;     // n= 3
//meaning:
//1- you can give everyone of b ans
//2- ans is a number of numbers from 1--> a which is divisible by b (find multiple in Range)
 
//Number of Steps
//Power function //Complexity: O(exponent).
double x = 6.1, y = 4.8;
double result = pow(x, y);
--------------------------------------------------------------------------------------------------- 
// modulous a floating number types (n % dn)
double n = fmod(num , denum);
---------------------------------------------------------------------------------------------------
//limits of integer types and help you when you handle (min/max)
int n1 =INT_MAX;  //+2147483647 //== 2*1e9 
int n2 =INT_MIN;  //-2147483647 //== -2*1e9
---------------------------------------------------------------------------------------------------
//Ceiling and flooring with double numbers
//1- Flooring
double a = 2.3;  a = floor(a);  //2
double b = -2.3; b = floor(b);  //-3
//2- ceiling
double a = 2.3;  a = ceil(a);  //3
double b = -2.3; b = ceil(b);  //-2
---------------------------------------------------------------------------------------------------
// Square Root //Time Complexity: θ(log(N))
int x = 24;
double answer;
answer = sqrt(x);
---------------------------------------------------------------------------------------------------
// max/min of three numbers //Time Complexity: O(1)
ans = max(a,max(b,c));
ans = min(a, min(b,c));
---------------------------------------------------------------------------------------------------
//GCD //Library: 'algorithm' //Time Complexity: O(log(max(value1, value2))))
int a = 6, b = 20;
int ans = __gcd(a, b); //gcd(6, 20) = 2
---------------------------------------------------------------------------------------------------
//Lowercase and Uppercase handle  //Time Complexity: O(1)
// convert 'a' to uppercase
char ch = toupper('a');  //A
// convert 'A' to lowercase
char ch = tolower('A');  //a
---------------------------------------------------------------------------------------------------
//Rounding numbers // return double type
double dUp = round(2.6);
double dDown = round(2.4);
cout << dUp;   //3
cout << dDown;   //2
---------------------------------------------------------------------------------------------------
//search for x
find(vect.begin(), vect.end(),x);
//note 
// find() returns iterator to last address if element not present
find(vect.begin(), vect.end(),5) != vect.end()?
                         cout << "\nElement found": cout << "\nElement not found";
---------------------------------------------------------------------------------------------------
// for binary search in containers like vector (let target element=6)
binary_search(v.begin(), v.end(), 6); 
// return 1 or 0 as present or not
---------------------------------------------------------------------------------------------------
//binary search with lower and upper bound
int x, ans; //x is passing value, ans is a value you want, v --> vector or any container
ans = lower_bound(v.begin(), v.end(), x) - v.begin(); //>= x (equal number or first number after x)
a