Language: C++

#include <bits/stdc++.h>
#define long long int ll 
using namespace std;
ll KnapSack(ll val[], ll wt[], ll n, ll W) 
{ 
    // matrix to store final result 
    ll mat[2][W+1]; 
    memset(mat, 0, sizeof(mat)); 
  
    // iterate through all items 
    ll i = 0; 
    while (i < n) // one by one traverse each element 
    { 
        ll j = 0; // traverse all weights j <= W 
  
        // if i is odd that mean till now we have odd 
        // number of elements so we store result in 1th 
        // indexed row 
        if (i%2!=0) 
        { 
            while (++j <= W) // check for each value 
            { 
                if (wt[i] <= j) // include element 
                    mat[1][j] = max(val[i] + mat[0][j-wt[i]], 
                                    mat[0][j] ); 
                else           // exclude element 
                    mat[1][j] = mat[0][j]; 
            } 
  
        } 
  
        // if i is even that mean till now we have even number 
        // of elements so we store result in 0th indexed row 
        else
        { 
            while(++j <= W) 
            { 
                if (wt[i] <= j) 
                    mat[0][j] = max(val[i] + mat[1][j-wt[i]], 
                                     mat[1][j]); 
                else
                    mat[0][j] = mat[1][j]; 
            } 
        } 
        i++; 
    } 
  
    // Return mat[0][W] if n is odd, else mat[1][W] 
    return (n%2 != 0)? mat[0][W] : mat[1][W]; 
}
int main()
{
    long long int n,W,i;
    cin>>n>>W;
    long long int wt[n+1],val[n+1];
    for(i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    cout<<KnapSack(W,wt,val,n)<<endl;
    return 0;
}

Compiler output:
a.cc:4:1: error: 'll' does not name a type
    4 | ll KnapSack(ll val[], ll wt[], ll n, ll W)
      | ^~
a.cc: In function 'int main()':
a.cc:2:14: error: expected initializer before 'long'
    2 | #define long long int ll
      |              ^~~~
a.cc:53:10: note: in expansion of macro 'long'
   53 |     long long int n,W,i;
      |          ^~~~
a.cc:54:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   54 |     cin>>n>>W;
      |          ^
      |          yn
a.cc:54:13: error: 'W' was not declared in this scope
   54 |     cin>>n>>W;
      |             ^
a.cc:2:14: error: expected initializer before 'long'
    2 | #define long long int ll
      |              ^~~~
a.cc:55:10: note: in expansion of macro 'long'
   55 |     long long int wt[n+1],val[n+1];
      |          ^~~~
a.cc:56:9: error: 'i' was not declared in this scope
   56 |     for(i=0;i<n;i++)
      |         ^
a.cc:58:14: error: 'wt' was not declared in this scope
   58 |         cin>>wt[i]>>val[i];
      |              ^~
a.cc:58:21: error: 'val' was not declared in this scope
   58 |         cin>>wt[i]>>val[i];
      |                     ^~~
a.cc:60:22: error: 'wt' was not declared in this scope
   60 |     cout<<KnapSack(W,wt,val,n)<<endl;
      |                      ^~
a.cc:60:25: error: 'val' was not declared in this scope
   60 |     cout<<KnapSack(W,wt,val,n)<<endl;
      |                         ^~~
a.cc:60:11: error: 'KnapSack' was not declared in this scope
   60 |     cout<<KnapSack(W,wt,val,n)<<endl;
      |           ^~~~~~~~