Language: C++

using System;
using System.Linq;
using System.Collections.Generic;

class Dmondai
{
    static void Main()
    {
        var nw = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = nw[0];
        var W = nw[1];
        //index,重さ＝価値
        var dp = new long[N + 1, W + 1];
        for (int i = 0; i <= N; i++) for (int j = 0; j <= W; ++j) dp[i, j] = 0;
        for (int i=0;i<N;++i)
        {
            var wv = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            var w = wv[0];
            var v = wv[1];
            for (int j=0;j<=W;++j)
            {
                if (dp[i, j] == 0) continue;
                dp[i + 1, j] = Math.Max(dp[i+1,j],dp[i,j]);
                if (j + w <= W) dp[i + 1, j + w] = Math.Max(dp[i+1,j+w],dp[i,j]+v);
            }
            dp[i+1, w] = Math.Max(dp[i,w],v);
        }
        var ans = 0L;
        for (int i=0;i<=W;++i)
        {
            ans = Math.Max(dp[N,i],ans);
        }
        Console.WriteLine(ans);
    }
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Linq;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:35:2: error: expected ';' after class definition
   35 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Dmondai::Main()':
a.cc:9:9: error: 'var' was not declared in this scope
    9 |         var nw = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
      |         ^~~
a.cc:10:13: error: expected ';' before 'N'
   10 |         var N = nw[0];
      |             ^
a.cc:11:13: error: expected ';' before 'W'
   11 |         var W = nw[1];
      |             ^
a.cc:13:13: error: expected ';' before 'dp'
   13 |         var dp = new long[N + 1, W + 1];
      |             ^~
a.cc:14:30: error: 'N' was not declared in this scope
   14 |         for (int i = 0; i <= N; i++) for (int j = 0; j <= W; ++j) dp[i, j] = 0;
      |                              ^
a.cc:14:59: error: 'W' was not declared in this scope
   14 |         for (int i = 0; i <= N; i++) for (int j = 0; j <= W; ++j) dp[i, j] = 0;
      |                                                           ^
a.cc:14:67: error: 'dp' was not declared in this scope
   14 |         for (int i = 0; i <= N; i++) for (int j = 0; j <= W; ++j) dp[i, j] = 0;
      |                                                                   ^~
a.cc:15:24: error: 'N' was not declared in this scope
   15 |         for (int i=0;i<N;++i)
      |                        ^
a.cc:17:17: error: expected ';' before 'wv'
   17 |             var wv = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
      |                 ^~
a.cc:18:17: error: expected ';' before 'w'
   18 |             var w = wv[0];
      |                 ^
a.cc:19:17: error: expected ';' before 'v'
   19 |             var v = wv[1];
      |                 ^
a.cc:20:29: error: 'W' was not declared in this scope
   20 |             for (int j=0;j<=W;++j)
      |                             ^
a.cc:22:21: error: 'dp' was not declared in this scope
   22 |                 if (dp[i, j] == 0) continue;
      |                     ^~
a.cc:23:17: error: 'dp' was not declared in this scope
   23 |                 dp[i + 1, j] = Math.Max(dp[i+1,j],dp[i,j]);
      |                 ^~
a.cc:23:32: error: 'Math' was not declared in this scope
   23 |                 dp[i + 1, j] = Math.Max(dp[i+1,j],dp[i,j]);
      |                                ^~~~
a.cc:24:25: error: 'w' was not declared in this scope
   24 |                 if (j + w <= W) dp[i + 1, j + w] = Math.Max(dp[i+1,j+w],dp[i,j]+v);
      |                         ^
a.cc:24:81: error: 'v' was not declared in this scope
   24 |                 if (j + w <= W) dp[i + 1, j + w] = Math.Max(dp[i+1,j+w],dp[i,j]+v);
      |                                                                                 ^
a.cc:26:13: error: 'dp' was not declared in this scope
   26 |             dp[i+1, w] = Math.Max(dp[i,w],v);
      |             ^~
a.cc:26:21: error: 'w' was not declared in this scope
   26 |             dp[i+1, w] = Math.Max(dp[i,w],v);
      |                     ^
a.cc:26:26: error: 'Math' was not declared in this scope
   26 |             dp[i+1, w] = Math.Max(dp[i,w],v);
      |                          ^~~~
a.cc:26:43: error: 'v' was not declared in this scope
   26 |             dp[i+1, w] = Math.Max(dp[i,w],v);
      |                                           ^
a.cc:28:13: error: expected ';' before 'ans'
   28 |         var ans = 0L;
      |             ^~~
a.cc:29:25: error: 'W' was not declared in this scope
   29 |         for (int i=0;i<=W;++i)
      |                         ^
a.cc:31:13: error: 'ans' was not declared in this scope
   31 |             ans = Math.Max(dp[N,i],ans);
      |             ^~~
a.cc:31:19: error: 'Math' was not declared in this scope
   31 |             ans = Math.Max(dp[N,i],ans);
      |                   ^~~~
a.cc:31:28: error: 'dp' was not declared in this scope
   31 |             ans = Math.Max(dp[N,i],ans);
      |                            ^~
a.cc:31:31: error: 'N' was not declared in this scope
   31 |             ans = Math.Max(dp[N,i],ans);
      |                               ^
a.cc:33:9: error: 'Console' was not declared in this scope
   33 |         Console.WriteLine(ans);
      |         ^~~~~~~
a.cc:33:27: error: 'ans' was not declared in this scope
   33 |         Console.WriteLine(ans);
      |                           ^~~