criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

main() {
	int n, m;
	int C[21];
	int T[NMAX + 1];

	cin >> n >> m;

	for (int i = 1; i <= m; i++) {
		cin >> C[i];
	}

	for (int i = 0; i <= NMAX; i++)T[i] = INFTY;
	T[0] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j + C[i] <= n; j++) {
			T[j + C[i]] = min(T[j + C[i], T[j] + 1]);
		}
	}

	cout << T[n] << endl;

	return 0;
}


Compiler output:
a.cc:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:25:42: error: no matching function for call to 'min(int&)'
   25 |                         T[j + C[i]] = min(T[j + C[i], T[j] + 1]);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:25:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |                         T[j + C[i]] = min(T[j + C[i], T[j] + 1]);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

int main() {
	int n, m;
	int C[21];
	int T[NMAX + 1];

	cin >> n >> m;

	for (int i = 1; i <= m; i++) {
		cin >> C[i];
	}

	for (int i = 0; i <= NMAX; i++)T[i] = INFTY;
	T[0] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j + C[i] <= n; j++) {
			T[j + C[i]] = min(T[j + C[i], T[j] + 1]);
		}
	}

	cout << T[n] << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:42: error: no matching function for call to 'min(int&)'
   25 |                         T[j + C[i]] = min(T[j + C[i], T[j] + 1]);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:25:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |                         T[j + C[i]] = min(T[j + C[i], T[j] + 1]);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include <iostream>
using namespace std;

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

    int ans =0;
    for(i = 5; i >= 0; i--){
        int t = min(n/V[i],1);
        n -= t * V[i];
        ans += t;
    }

    cout << ans;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     for(i = 0; i < m; i++)
      |         ^
a.cc:8:16: error: expected primary-expression before 'int'
    8 |         cin >> int V[i];
      |                ^~~
a.cc:11:9: error: 'i' was not declared in this scope
   11 |     for(i = 5; i >= 0; i--){
      |         ^
a.cc:12:23: error: 'V' was not declared in this scope
   12 |         int t = min(n/V[i],1);
      |                       ^
Language: C++

#include <vector>
#include <algorithm>

using namespace std;
 
#define MAX_M 20
#define MAX_N 50000
#define INF 100000000

int n, m;
vector<int> c(MAX_M, 0);        //要素数MAX_M, すべての要素の値0
vector<int> dp(MAX_N + 1, INF); //要素数MAX_N+1, すべての要素の値INF
                                //※dp(INF) なら要素数INFの宣言
void solve() {
    dp[0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < m; j++) {
            if(i - c[j] >= 0) {
                if(dp[i] > dp[i - c[j]] + 1) {
                    dp[i] = dp[i - c[j]] + 1;
                }
            }
        }
    }
    printf("%d\n", dp[n]);
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; i++) cin >> c[i];
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:25:5: error: 'printf' was not declared in this scope
   25 |     printf("%d\n", dp[n]);
      |     ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include <algorithm>
  +++ |+#include <cstdio>
    3 | 
a.cc: In function 'int main()':
a.cc:29:5: error: 'cin' was not declared in this scope
   29 |     cin >> n >> m;
      |     ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <algorithm>
  +++ |+#include <iostream>
    3 |
Language: C++

#include<iostream>
#include<vector>
#include<map>
using namespace std;
vector<int> coin;

vector<int> get_change(int num) {
	vector<int> ret(num+1, 0);
	vector<int> r(num+1,0);
	for (int i = 1; i <= num; i++) {
		int q = INT_MAX;
		for (int j = 0; j < coin.size(); j++) {
			if (i >= coin[j]) {
				if (q > 1 + r[i - coin[j]]) {
					q = q < (1 + r[i - coin[j]]) ? q : (1 + r[i - coin[j]]);
					ret[i] = j;
				}
			}
		}
		r[i] = q;
	}
	return r[num];
}

int main() {
        int num,m;
　　cin>>num>>m;
	for (int i=0;i<m;i++) {
		int tmp;
                cin>>tmp;
		coin.push_back(tmp);
	}	
	int ans;
	ans = get_change(num);
        cout<<ans;
	return 0;
}


Compiler output:
a.cc:27:1: error: extended character 　 is not valid in an identifier
   27 | 　　cin>>num>>m;
      | ^
a.cc:27:1: error: extended character 　 is not valid in an identifier
a.cc: In function 'std::vector<int> get_change(int)':
a.cc:11:25: error: 'INT_MAX' was not declared in this scope
   11 |                 int q = INT_MAX;
      |                         ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<map>
  +++ |+#include <climits>
    4 | using namespace std;
a.cc:22:21: error: could not convert 'r.std::vector<int>::operator[](((std::vector<int>::size_type)num))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>'
   22 |         return r[num];
      |                     ^
      |                     |
      |                     __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
a.cc: In function 'int main()':
a.cc:27:1: error: '\U00003000\U00003000cin' was not declared in this scope
   27 | 　　cin>>num>>m;
      | ^~~~~~~
a.cc:34:25: error: cannot convert 'std::vector<int>' to 'int' in assignment
   34 |         ans = get_change(num);
      |               ~~~~~~~~~~^~~~~
      |                         |
      |                         std::vector<int>
Language: C++

#include<limits.h>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
vector<int> coin;
 
vector<int> get_change(int num) {
    vector<int> ret(num+1, 0);
    vector<int> r(num+1,0);
    for (int i = 1; i <= num; i++) {
        int q = INT_MAX;
        for (int j = 0; j < coin.size(); j++) {
            if (i >= coin[j]) {
                if (q > 1 + r[i - coin[j]]) {
                    q = q < (1 + r[i - coin[j]]) ? q : (1 + r[i - coin[j]]);
                    ret[i] = j;
                }
            }
        }
        r[i] = q;
    }
    return r[num];
}
 
int main() {
        int num,m;
　　cin>>num>>m;
    for (int i=0;i<m;i++) {
        int tmp;
                cin>>tmp;
        coin.push_back(tmp);
    }   
    int ans;
    ans = get_change(num);
        cout<<ans;
    return 0;
}


Compiler output:
a.cc:28:1: error: extended character 　 is not valid in an identifier
   28 | 　　cin>>num>>m;
      | ^
a.cc:28:1: error: extended character 　 is not valid in an identifier
a.cc: In function 'std::vector<int> get_change(int)':
a.cc:23:17: error: could not convert 'r.std::vector<int>::operator[](((std::vector<int>::size_type)num))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>'
   23 |     return r[num];
      |                 ^
      |                 |
      |                 __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
a.cc: In function 'int main()':
a.cc:28:1: error: '\U00003000\U00003000cin' was not declared in this scope
   28 | 　　cin>>num>>m;
      | ^~~~~~~
a.cc:35:21: error: cannot convert 'std::vector<int>' to 'int' in assignment
   35 |     ans = get_change(num);
      |           ~~~~~~~~~~^~~~~
      |                     |
      |                     std::vector<int>
Language: C++

#include<limits.h>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
vector<int> coin;
 
int get_change(int num) {
    vector<int> ret(num+1, 0);
    vector<int> r(num+1,0);
    for (int i = 1; i <= num; i++) {
        int q = INT_MAX;
        for (int j = 0; j < coin.size(); j++) {
            if (i >= coin[j]) {
                if (q > 1 + r[i - coin[j]]) {
                    q = q < (1 + r[i - coin[j]]) ? q : (1 + r[i - coin[j]]);
                    ret[i] = j;
                }
            }
        }
        r[i] = q;
    }
    return r[num];
}
 
int main() {
        int num,m;
　　cin>>num>>m;
    for (int i=0;i<m;i++) {
        int tmp;
                cin>>tmp;
        coin.push_back(tmp);
    }   
    int ans;
    ans = get_change(num);
        cout<<ans;
    return 0;
}


Compiler output:
a.cc:28:1: error: extended character 　 is not valid in an identifier
   28 | 　　cin>>num>>m;
      | ^
a.cc:28:1: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:28:1: error: '\U00003000\U00003000cin' was not declared in this scope
   28 | 　　cin>>num>>m;
      | ^~~~~~~
Language: C++

#include<limits.h>
#include<iostream>
#include<vector>
using namespace std;
vector<int> coin;
 
int get_change(int num) {
    vector<int> ret(num+1, 0);
    vector<int> r(num+1,0);
    for (int i = 1; i <= num; i++) {
        int q = INT_MAX;
        for (int j = 0; j < coin.size(); j++) {
            if (i >= coin[j]) {
                if (q > 1 + r[i - coin[j]]) {
                    q = q < (1 + r[i - coin[j]]) ? q : (1 + r[i - coin[j]]);
                    ret[i] = j;
                }
            }
        }
        r[i] = q;
    }
    return r[num];
}
 
int main() {
    int num;
    int m;
　cin>>num>>m;
    for (int i=0;i<m;i++) {
        int tmp;
                cin>>tmp;
        coin.push_back(tmp);
    }   
    int ans;
    ans = get_change(num);
        cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:28:1: error: extended character 　 is not valid in an identifier
   28 | 　cin>>num>>m;
      | ^
a.cc: In function 'int main()':
a.cc:28:1: error: '\U00003000cin' was not declared in this scope
   28 | 　cin>>num>>m;
      | ^~~~~
Language: C++

#include<limits.h>
#include<iostream>
#include<vector>
using namespace std;
vector<int> coin;
 
int get_change(int num) {
    vector<int> ret(num+1, 0);
    vector<int> r(num+1,0);
    for (int i = 1; i <= num; i++) {
        int q = INT_MAX;
        for (int j = 0; j < coin.size(); j++) {
            if (i >= coin[j]) {
                if (q > 1 + r[i - coin[j]]) {
                    q = q < (1 + r[i - coin[j]]) ? q : (1 + r[i - coin[j]]);
                    ret[i] = j;
                }
            }
        }
        r[i] = q;
    }
    return r[num];
}
 
int main() {
    int num;
    int m;
　cin>>num;
    cin>>m;
    for (int i=0;i<m;i++) {
        int tmp;
                cin>>tmp;
        coin.push_back(tmp);
    }   
    int ans;
    ans = get_change(num);
        cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:28:1: error: extended character 　 is not valid in an identifier
   28 | 　cin>>num;
      | ^
a.cc: In function 'int main()':
a.cc:28:1: error: '\U00003000cin' was not declared in this scope
   28 | 　cin>>num;
      | ^~~~~
Language: C++

#include<limits.h>
#include<vector>
using namespace std;
vector<int> coin;
 
int get_change(int num) {
    vector<int> ret(num+1, 0);
    vector<int> r(num+1,0);
    for (int i = 1; i <= num; i++) {
        int q = INT_MAX;
        for (int j = 0; j < coin.size(); j++) {
            if (i >= coin[j]) {
                if (q > 1 + r[i - coin[j]]) {
                    q = q < (1 + r[i - coin[j]]) ? q : (1 + r[i - coin[j]]);
                    ret[i] = j;
                }
            }
        }
        r[i] = q;
    }
    return r[num];
}
 
int main() {
    int num;
    int m;
　cin>>num>>m;
    for (int i=0;i<m;i++) {
        int tmp;
                cin>>tmp;
        coin.push_back(tmp);
    }   
    int ans;
    ans = get_change(num);
        cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:27:1: error: extended character 　 is not valid in an identifier
   27 | 　cin>>num>>m;
      | ^
a.cc: In function 'int main()':
a.cc:27:1: error: '\U00003000cin' was not declared in this scope
   27 | 　cin>>num>>m;
      | ^~~~~
a.cc:30:17: error: 'cin' was not declared in this scope
   30 |                 cin>>tmp;
      |                 ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<vector>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:35:9: error: 'cout' was not declared in this scope
   35 |         cout<<ans<<endl;
      |         ^~~~
a.cc:35:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:35:20: error: 'endl' was not declared in this scope
   35 |         cout<<ans<<endl;
      |                    ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<vector>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

#include<limits.h>
#include<iostream>
#include<vector>
using namespace std;
vector<int> coin;
 
int get_change(int num) {
    vector<int> ret(num+1, 0);
    vector<int> r(num+1,0);
    for (int i = 1; i <= num; i++) {
        int q = INT_MAX;
        for (int j = 0; j < coin.size(); j++) {
            if (i >= coin[j]) {
                if (q > 1 + r[i - coin[j]]) {
                    q = q < (1 + r[i - coin[j]]) ? q : (1 + r[i - coin[j]]);
                    ret[i] = j;
                }
            }
        }
        r[i] = q;
    }
    return r[num];
}
 
int main() {
    int n;
    int m;
　cin >> n >> m;
    for (int i=0;i<m;i++) {
        int tmp;
                cin>>tmp;
        coin.push_back(tmp);
    }   
    int ans;
    ans = get_change(n);
        cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:28:1: error: extended character 　 is not valid in an identifier
   28 | 　cin >> n >> m;
      | ^
a.cc: In function 'int main()':
a.cc:28:1: error: '\U00003000cin' was not declared in this scope
   28 | 　cin >> n >> m;
      | ^~~~~
Language: C++

n, m=[int(w) for w in input().split()]
cs=[int(w) for w in input().split()]
res=50001
def comb(i, acc):
    global cs, m
    if i>=m:
        compute(acc)
        return
    comb(i+1, acc)
    acc.append(cs[i])
    comb(i+1, acc)
    acc.pop()
def compute(lst):
    global res, n
    lst=reversed(sorted(lst))
    r=0
    v=n
    for e in lst:
        r+=v//e
        v%=e
        if v==0:
            res=min(res, r)
            break
comb(0, [])
print(res)



Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, m=[int(w) for w in input().split()]
      | ^
Language: C++

/*
Coin Changing Problem(https://onlinejudge.u-aizu.ac.jp/#/problems/DPL_1_A)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

int dp[32][50050];

void solve(void){
    int N, M;
    cin >> N >> M;
    rep(M+1, m) rep(N+1, n) dp[m][n] = INF;
    dp[0][0] = 0;
    rep(M, m) {
        int c;
        scanf("%d\n", &c);
        rep(N+1, n) {
            dp[m+1][n] = min(dp[m+1][n], dp[m][n]);
            if (n+c<=N) dp[m+1][n+c] = min(dp[m][n+c], dp[m+1][n]+1);
        }
    }
    cout << dp[M][N] << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:33:40: error: 'INF' was not declared in this scope
   33 |     rep(M+1, m) rep(N+1, n) dp[m][n] = INF;
      |                                        ^~~
Language: C++

#define BOTTOM 0
#define LEFT 1
#define RIGHT 2
#define TOP 3

struct point{
    double x,y;
    point(){}
    point(double x,double y):x(x),y(y){}
    point operator + (point &p){
        return point(x+p.x,y+p.y);
    }
    point operator - (point &p){
        return point(x-p.x,y-p.y);
    }
    point operator * (double k){
        return point(x*k,y*k);
    }
    point operator / (double k){
        return point(x/k,y/k);
    }
};

struct segment{
    point p1,p2;
};

struct endpoint{
    point p;
    int seg,st;
    endpoint(){}
    endpoint(point p,int seg,int st):p(p),seg(seg),st(st){}
    bool operator < (const endpoint &ep)const{
        if(p.y==ep.p.y){
            return st<ep.st;//y相同时，按照下断点，左端点，右端点，上端点的顺序排列
        }else{
            return p.y<ep.p.y;
        }
    }
};
endpoint ep[2*maxn];

int manhattanIntersection(vector<segment>s)
{
    int n=s.size();
    for(int i=0,k=0;i<n;i++){
        if(s[i].p1.y==s[i].p2.y){
            if(s[i].p1.x>s[i].p2.x){
                swap(s[i].p1,s[i].p2);
            }
        }else if(s[i].p1.y>s[i].p2.y){
            swap(s[i].p1,s[i].p2);
        }
        if(s[i].p1.y==s[i].p2.y){
            ep[k++]=endpoint(s[i].p1,i,LEFT);
            ep[k++]=endpoint(s[i].p2,i,RIGHT);
        }else{
            ep[k++]=endpoint(s[i].p1,i,BOTTOM);
            ep[k++]=endpoint(s[i].p2,i,TOP);
        }
    }
    sort(ep,ep+(2*n));
    set<int>bt;
    bt.insert(1000000001);
    int cnt=0;
    for(int i=0;i<2*n;i++){
        if(ep[i].st==TOP){
            bt.erase(ep[i].p.x);
        }else if(ep[i].st==BOTTOM){
            bt.insert(ep[i].p.x);
        }else if(ep[i].st==LEFT){
            set<int>::iterator b=bt.lower_bound(s[ep[i].seg].p1.x);
            set<int>::iterator e=bt.upper_bound(s[ep[i].seg].p2.x);
            cnt+=distance(b,e);
        }
    }
    return cnt;
}


Compiler output:
a.cc:41:15: error: 'maxn' was not declared in this scope
   41 | endpoint ep[2*maxn];
      |               ^~~~
a.cc:43:27: error: 'vector' was not declared in this scope
   43 | int manhattanIntersection(vector<segment>s)
      |                           ^~~~~~
a.cc:43:41: error: expected primary-expression before '>' token
   43 | int manhattanIntersection(vector<segment>s)
      |                                         ^
a.cc:43:42: error: 's' was not declared in this scope
   43 | int manhattanIntersection(vector<segment>s)
      |                                          ^
Language: C++

#!/usr/bin/env python
import sys
sys.setrecursionlimit(100000000)

n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = {}

# num 番目までのコインを使い、yen 円支払うときに必要な枚数
def func(num, yen):
	if num < 0 or yen < 0:
		return 10 ** 18
	if num == 0 and yen == 0:
		return 0
	if not (num, yen) in DP:
		DP[(num, yen)] = min(func(num - 1, yen), func(num, yen - c[num]) + 1)
	return DP[(num, yen)]

print(func(m - 1, n))



Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/env python
      |  ^
a.cc:9:3: error: invalid preprocessing directive #num
    9 | # num 番目までのコインを使い、yen 円支払うときに必要な枚数
      |   ^~~
a.cc:9:7: error: extended character 、 is not valid in an identifier
    9 | # num 番目までのコインを使い、yen 円支払うときに必要な枚数
      |       ^
a.cc:2:1: error: 'import' does not name a type
    2 | import sys
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: 'def' does not name a type
   10 | def func(num, yen):
      | ^~~
Language: C++

/*
 * Contents   : AOJ DPL 1 A
 * Author     : KitauraHiromi
 * LastUpdate : 20180611
 * Since      : 20180611
 */
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int N, W;
int dp[21][50001]; // dp[i][n]: i種類目までのコインをn円するときの最小枚数を保持
int value[20];
int main(void){
    cin >> N >> M;
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<M; ++m) cin >> value[m];
    for(int i=0; i<M; ++m){
        for(int n=0; n<=N; ++n){
            (n >= value[i]) ? dp[i+1][n] = min(dp[i+1][n-value[i]] + 1, dp[i][n]) : dp[i+1][n] = dp[i][n];
        }
    }
    cout << dp[N][M] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'M' was not declared in this scope
   15 |     cin >> N >> M;
      |                 ^
a.cc:17:25: error: 'm' was not declared in this scope
   17 |     for(int i=0; i<M; ++m) cin >> value[m];
      |                         ^
a.cc:18:25: error: 'm' was not declared in this scope
   18 |     for(int i=0; i<M; ++m){
      |                         ^
Language: C++

/*
 * Contents   : AOJ DPL 1 A
 * Author     : KitauraHiromi
 * LastUpdate : 20180611
 * Since      : 20180611
 */
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int N, M;
int dp[21][50001]; // dp[i][n]: i種類目までのコインをn円するときの最小枚数を保持
int value[20];
int main(void){
    cin >> N >> M;
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<M; ++m) cin >> value[m];
    for(int i=0; i<M; ++m){
        for(int n=0; n<=N; ++n){
            (n >= value[i]) ? dp[i+1][n] = min(dp[i+1][n-value[i]] + 1, dp[i][n]) : dp[i+1][n] = dp[i][n];
        }
    }
    cout << dp[N][M] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:25: error: 'm' was not declared in this scope
   17 |     for(int i=0; i<M; ++m) cin >> value[m];
      |                         ^
a.cc:18:25: error: 'm' was not declared in this scope
   18 |     for(int i=0; i<M; ++m){
      |                         ^
Language: C++

/*
 * Contents   : AOJ DPL 1 A
 * Author     : KitauraHiromi
 * LastUpdate : 20180611
 * Since      : 20180611
 */
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int N, M;
int dp[21][50001]; // dp[i][n]: i種類目までのコインをn円するときの最小枚数を保持
int value[20];
int main(void){
    cin >> N >> M;
    memset(dp, 0, sizeof(dp));
    for(int m=0; i<M; ++m) cin >> value[m];
    for(int m=0; i<M; ++m){
        for(int n=0; n<=N; ++n){
            (n >= value[i]) ? dp[i+1][n] = min(dp[i+1][n-value[i]] + 1, dp[i][n]) : dp[i+1][n] = dp[i][n];
        }
    }
    cout << dp[N][M] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:18: error: 'i' was not declared in this scope
   17 |     for(int m=0; i<M; ++m) cin >> value[m];
      |                  ^
a.cc:18:18: error: 'i' was not declared in this scope
   18 |     for(int m=0; i<M; ++m){
      |                  ^
Language: C++

/*
 * Contents   : AOJ DPL 1 A
 * Author     : KitauraHiromi
 * LastUpdate : 20180611
 * Since      : 20180611
 */
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int N, M;
int dp[21][50001]; // dp[m][i]: m種類目までのコインをi円集めたときの最小枚数を保持
int value[21];
int main(void){
    cin >> N >> M;
    memset(dp, 50001, sizeof(dp));
    for(int m=0; m<M; ++m) cin >> value[m];
    for(int m=0; m<=M; ++m) dp[m] = 0;
    for(int i=0; i<=N; ++i){
        for(int m=0; m<M; ++m){
            if(i >= value[m]) dp[m+1][i] = min(dp[m+1][i-value[m]] + 1, dp[m][i+1]);
            else dp[m+1][i] = dp[m][i+1];
        }
    }
    cout << dp[M][N] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:35: error: incompatible types in assignment of 'int' to 'int [50001]'
   18 |     for(int m=0; m<=M; ++m) dp[m] = 0;
      |                             ~~~~~~^~~
Language: C++

#include <iostream>
#include <set>

using namespace std;

int n, m;
int c[20];
int a[50000];

void solve() {
    for (int i = 0; i < m; ++i) {
        for (int j = c[i]; j < n; ++j) {
            a[j] = min(a[j], 1 + a[j-c[i]]);
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }
    for (int j = 0; j < m; ++j) {
        for (int i = 0; i < n; ++i) {
            a[i] = INT_MAX;
        }
    }
    a[0] = 0;
    solve();

    cout << a[n] << endl;


    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:25:20: error: 'INT_MAX' was not declared in this scope
   25 |             a[i] = INT_MAX;
      |                    ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <set>
  +++ |+#include <climits>
    3 |
Language: C++

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <conio.h>
#include <cstring>

using namespace std;

int Coins[20];
int Dest,hmCoins;

const int INF = 99999999;

int dfs(int DestMoney,int LeftCoins){
	if(LeftCoins == 0){
		return INF;
	}else if(DestMoney == 0){
		return 0;
	}else{
		return min(dfs(DestMoney - Coins[LeftCoins],LeftCoins - 1) + 1,dfs(DestMoney,LeftCoins - 1));
	}
}

int main()
{
	cin >> Dest >> hmCoins;

	for(int i = 0;i < hmCoins;i++){
		cin >> Coins[i];
	}

	cout << dfs(Dest,hmCoins - 1);

	return 0;
}

Compiler output:
a.cc:5:10: fatal error: conio.h: No such file or directory
    5 | #include <conio.h>
      |          ^~~~~~~~~
compilation terminated.
Language: Java


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();

        int[] v = new int[N+1];
        int[] w = new int[W+1];

        for(int i=1; i<N+1; i++) {
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }

        int dp[][] = new int[N+1][W+1];
        for(int i=0; i<N+1; i++)
            Arrays.fill(dp[i], 0);

        for(int ni=1; ni<N+1; ni++) {
            for(int wi=1; wi<W+1; wi++) {
                dp[ni][wi] = dp[ni - 1][wi];
                if(wi-w[ni] >= 0)
                    dp[ni][wi] = Math.max(dp[ni][wi], dp[ni-1][wi-w[ni]] + v[ni]);
            }
         }

        System.out.println(dp[N][W]);
    }


Compiler output:
Main.java:32: error: reached end of file while parsing
    }
     ^
1 error
Language: Java

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int wmax=Integer.parseInt(line.split(" ")[1]);
int[] v=new int[n];
int[] w=new int[n];
for(int i=0;i<n;i++){
line=br.readLine();
v[i]=Integer.parseInt(line.split(" ")[0]);
w[i]=Integer.parseInt(line.split(" ")[1]);
}
int[][] dp=new int[n+1][w+1];
for(int j=n-1;j>=0;j--){
for(int i=0;i<=wmax;i++){
if(i<w[j]) dp[j][i]=dp[j+1][i];
else dp[j][i]=Math.min(dp[j+1][i],dp[j][i-w[j]]+v[j]);
}
}
out.println(dp[0][wmax]);
}
out.flush();
}
}

Compiler output:
Main.java:23: error: bad operand types for binary operator '+'
int[][] dp=new int[n+1][w+1];
                         ^
  first type:  int[]
  second type: int
1 error
Language: Java

import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int WW = Integer.parseInt(sc.next());
    int[] v = new int[N];
    int[] w = new int[N];
    for(int i=0; i<N; i++){
      v = Integer.parseInt(sc.next());
      w = Integer.parseInt(sc.next());
    }

    int[][] dp = new int[N+1][WW+1];
    for(int i=1; i<N+1; i++){
        dp[i][0] = 0;
    }
  
    for (int i=1; i<=N; i++) {
      for (int W=1; W<=WW; W++) {
        if(W>=w[i]){
            dp[i][W] = Math.max(dp[i-1][W], dp[i-1][W-w[i]] + v[i]);
        }else{
          dp[i][W] = dp[i-1][WW];
        }
      
      }
    }

    Systm.out.println(dp[N][W]);
  }
}

Compiler output:
Main.java:11: error: incompatible types: int cannot be converted to int[]
      v = Integer.parseInt(sc.next());
                          ^
Main.java:12: error: incompatible types: int cannot be converted to int[]
      w = Integer.parseInt(sc.next());
                          ^
Main.java:31: error: cannot find symbol
    Systm.out.println(dp[N][W]);
                            ^
  symbol:   variable W
  location: class Main
Main.java:31: error: package Systm does not exist
    Systm.out.println(dp[N][W]);
         ^
4 errors
Language: Java

import java.util.Scanner;

public class KnapsackTopDown {
    static int n, w;
    static int[] value, weight;
    static int[][] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        w = sc.nextInt();

        value = new int[n + 1];
        weight = new int[n + 1];
        dp = new int[n + 1][w + 1];
        for (int i = 0; i < n; i++) {
            value[i + 1] = sc.nextInt();
            weight[i + 1] = sc.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= w; j++) {
                dp[i][j] = dp[i - 1][j];
                if (j - weight[i] >= 0) {
                    dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - weight[i]] + value[i]);
                }
            }
        }
        System.out.println(dp[n][w]);
    }
}

Compiler output:
Main.java:3: error: class KnapsackTopDown is public, should be declared in a file named KnapsackTopDown.java
public class KnapsackTopDown {
       ^
1 error
Language: Java


/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B
 */
/**
 * Result: AC
 * TC: O(N^2)
 * SC: O(N)
 */
import java.util.Scanner;

public class Main {

    int capacity;
    int n;
    int[] cost;
    int[] value;
    int[] rowCurr;
    Scanner in = new Scanner(System.in);

    boolean readCase() {
        while (in.hasNext()) {
            n = in.nextInt();
            capacity = in.nextInt();
            cost = new int[n];
            value = new int[n];
            for (int i = 0; i < n; i++) {
                value[i] = in.nextInt();
                cost[i] = in.nextInt();
            }
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        Main_DP_1_Array main = new Main_DP_1_Array();
        while (main.readCase()) {
            main.solve();
        }
    }

    void solve() {
        rowCurr = new int[capacity + 1];
        for (int numOfItems = 1; numOfItems <= n; numOfItems++) {
            for (int weight = capacity; weight >= cost[numOfItems - 1]; weight--) {
                if (weight >= cost[numOfItems - 1]) {
                    rowCurr[weight] = Math.max(
                            rowCurr[weight - cost[numOfItems - 1]] + value[numOfItems - 1],
                            rowCurr[weight]);
                }
            }
        }
        System.out.println(rowCurr[capacity]);
    }
}

Compiler output:
Main.java:37: error: cannot find symbol
        Main_DP_1_Array main = new Main_DP_1_Array();
        ^
  symbol:   class Main_DP_1_Array
  location: class Main
Main.java:37: error: cannot find symbol
        Main_DP_1_Array main = new Main_DP_1_Array();
                                   ^
  symbol:   class Main_DP_1_Array
  location: class Main
2 errors
Language: Java

import java.util.Scanner;

public class Main_Memoization {

    static class Knapsack01 {

        int capacity;
        int n;
        int[] cost;
        int[] value;
        int[][] dp;

        public Knapsack01(int n, int capacity, int[] cost, int[] value) {
            this.n = n;
            this.capacity = capacity;
            this.cost = cost;
            this.value = value;
        }

        int solve() {
            dp = new int[n + 1][];
            for (int i = 0; i < n + 1; i++) {
                dp[i] = new int[capacity + 1];
                for (int j = 0; j < capacity + 1; j++) {
                    dp[i][j] = -1;
                }
            }
            return computeMemoization(0, capacity);
        }

        int computeMemoization(int itemIdx, int weight) {
            if (dp[itemIdx][weight] != -1) {
                return dp[itemIdx][weight];
            }
            int res;
            if (itemIdx == n) {
                res = 0;
            } else if (weight < cost[itemIdx]) {
                res = computeMemoization(itemIdx + 1, weight);
            } else {
                res = Math.max(computeMemoization(itemIdx + 1, weight),
                        computeMemoization(itemIdx + 1, weight - cost[itemIdx]) + value[itemIdx]);
            }
            dp[itemIdx][weight] = res;
            return res;
        }
    }

    static Scanner in = new Scanner(System.in);

    static Knapsack01 readCase() {
        while (in.hasNext()) {
            int n = in.nextInt();
            int capacity = in.nextInt();
            int[] cost = new int[n];
            int[] value = new int[n];
            for (int i = 0; i < n; i++) {
                value[i] = in.nextInt();
                cost[i] = in.nextInt();
            }
            Knapsack01 knapsack01 = new Knapsack01(n, capacity, cost, value);
            return knapsack01;
        }
        return null;
    }

    public static void main(String[] args) {
        Knapsack01 knapsack01 = null;
        while ((knapsack01 = readCase()) != null) {
            System.out.println(knapsack01.solve());
        }
    }

}

Compiler output:
Main.java:3: error: class Main_Memoization is public, should be declared in a file named Main_Memoization.java
public class Main_Memoization {
       ^
1 error
Language: Java

import java.util.Scanner;
import java.lang.Integer;
import java.lang.Math;

class Item {
  private int value;
  private int weight;
  private boolean choosed;

  public Item(int value, int weight) {
    this.set(value, weight);
  }

  public void set(int value, int weight) {
    this.value = value;
    this.weight = weight;
  }

  public int getValue() {
    return this.value;
  }

  public int getWeight() {
    return this.weight;
  }
  
  public choosed() {
    choosed = true;
  }

}

class Main {
  private static int[][] dp;

  private static int calc(int N, int W, Item[] item) {
    if (N <= 0) {
      return 1;
    }

    for (int i = 1; i < N + 1; i++) {
      for (int j = 0; j < W + 1; j++)  {
        int candidate1 = dp[i - 1][j];
        int candidate2 = 0;

        if ((j - item[i].getWeight() >= 0) && (item[i].getWeight() <= W)) {
          candidate2 = (dp[i - 1][j - item[i].getWeight()] + item[i].getValue());
        } else {
          candidate2 = Integer.MIN_VALUE;
        }

        dp[i][j] = Math.max(candidate1, candidate2);
        //System.out.println(((j - item[i].getWeight() >= 0) && (item[i].getWeight() <= W)) + " candidate1 " + candidate1 + " candidate2 " + candidate2);
        //System.out.println("dp[" + i + "]" + "[" + j + "], " + dp[i][j]);
      }
    }

    return dp[N][W];
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int W = sc.nextInt();
    Item[] item = new Item[N + 1];
    item[0] = new Item(0, Integer.MIN_VALUE);
    for (int i = 1; i < N + 1; i++) {
      int value = sc.nextInt();
      int weight = sc.nextInt();
      item[i] = new Item(value, weight);
    }
    dp = new int[N + 1][W + 1];

    // init kind of coin(i) == 0;
    int i = 0;
    for (int j = 0; j < W + 1; j++) {
      dp[i][j] = 0;
    }

    int result = calc(N, W, item);

    System.out.println(result);
  }
}

Compiler output:
Main.java:27: error: invalid method declaration; return type required
  public choosed() {
         ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Bag {
	public static void main(String[] args) throws IOException{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		String str = BR.readLine();
		
		int an = Integer.parseInt(str.substring(0,str.indexOf(" ")));
		int mw = Integer.parseInt(str.substring(str.indexOf(" ")+1));
		
		int[] values = new int[an];
		int[] weights = new int[an];
		for (int i = 0;i<an;i++){
			String temp = BR.readLine();
			int tv = Integer.parseInt(temp.substring(0,str.indexOf(" ")));
			int tw = Integer.parseInt(temp.substring(str.indexOf(" ") + 1));
			values[i] = tv;
			weights[i] = tw;
		}
		
		int[][] Vtable = new int[an][mw+1];
		for (int i=0;i<an;i++){
			for (int j=0;j<mw+1;j++){
				if (i==0&&j>=weights[0]){
					Vtable[i][j] = values[0];
				}else if(j-weights[i]>=0){
					Vtable[i][j] = Math.max(Vtable[i-1][j-weights[i]]+values[i],Vtable[i-1][j]);
				}
			}
		}
		System.out.println(Vtable[an-1][mw]);
		BR.close();
	}
}

Compiler output:
Main.java:5: error: class Bag is public, should be declared in a file named Bag.java
public class Bag {
       ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

class Item {
    int value,weight; //????????????????????????
    public Item(int value, int weight) {
        this.value = value;
        this.weight = weight;
    }
    public int getValue() {
        return this.value;
    }
    public int getWeight() {
        return this.weight;
    }
}

public class???Main {
    
    static int N,W; //??????????????°?????????
    static int Nmax = 105;
    static int Wmax = 10005;
    static ArrayList<Item> items = new ArrayList<>(); //???????????????????????????
    static int[][] C = new int[Nmax+1][Wmax+1]; //?????????????¨?????????§????????????
    
    public static int knapsack() {
        int result = 0;
        int maxVal = 0;
        for(int i = 1; i <= N; i++) {
            for(int w = 1; w <= W; w++) {
                if(items.get(i).getWeight() <= w) {
                    if(items.get(i).getValue() + C[i-1][w - items.get(i).getWeight()] > C[i-1][w]) {
                        C[i][w] = items.get(i).getValue() + C[i-1][w - items.get(i).getWeight()];
                    } else {
                        C[i][w] = C[i-1][w];
                    }
                }else{
                    C[i][w] = C[i-1][w]; //?????????????????????
                }
            }
            maxVal = C[N][W];
        }
        return result=maxVal;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        
        Item padding = new Item(0,0);
        items.add(padding);
        
        for(int i = 0; i < N; i++) {
            Item item = new Item(sc.nextInt(),sc.nextInt());
            items.add(item);
        }
        
        System.out.println(knapsack());
    }
    
}

Compiler output:
Main.java:18: error: <identifier> expected
public class???Main {
            ^
1 error
Language: Java



import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
  private interface Solver {
    int solve(int W, List<Integer> values, List<Integer> weights);
  }

  private static class PrefixSolver implements Solver {
    @Override
    public int solve(int W, List<Integer> values, List<Integer> weights) {
      int[] dp = new int[W + 1];
      for (int i = 1; i <= values.size(); ++i) {
        for (int j = W; j >=0; --j) {
          int v = values.get(i - 1);
          int w = values.get(i - 1);
          if (j - w >= 0) {
            dp[j] = Math.max(dp[j], dp[j - w] + v);
          }
        }
      }
    }
  }

  private static final Pattern SPLIT = Pattern.compile("\\s");
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    List<Integer> weights = new ArrayList<>();
    List<Integer> values = new ArrayList<>();
    List<Integer> NW = Stream.of(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
        .collect(Collectors.toList());
    final int N = NW.get(0);
    final int W = NW.get(1);
    for (int i = 0; i < N; ++i) {
      List<Integer> collect = Stream.of(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
          .collect(Collectors.toList());
      values.add(collect.get(0));
      weights.add(collect.get(1));
    }
    System.out.println(new PrefixSolver().solve(W, values, weights));
  }
}

Compiler output:
Main.java:28: error: missing return statement
    }
    ^
1 error
Language: Java

import java.io.*;
import java.util.*;

public class SolutionDP {

  private static int N;
  private static int W;
  private static int[] v;
  private static int[] w;

  // DP????????????
  //  1st index: ?????????????????????????????????.
  //  2nd index: ???????????¶?????????????????°??????????????????.
  //  value: ?????§??????.
  private static int[][] dp;

  public static void main(String[] args) {

/*
    N = 4;
    W = 5;
    v = new int[]{4, 5, 2, 8};
    w = new int[]{2, 2, 1, 3};
*/

    N = 2;
    W = 20;
    v = new int[]{5, 4};
    w = new int[]{9, 10};

    int ret = search(0, W);

    System.out.println(ret);
  }

  /**
    i ?????§???????????????????????¶???????????\????????¨????????????????????§????????????.

    search(i + 1, weight) = max(
     search(i, weight - weight[i]) + value[i],
     search(i, weight)
    )

    ?????°??¢??°??????????????¶: i == N

    @return ??????????????§???.
  */
  public static int search(int i, int weight) {
    if (i == N) {
      return 0;
    } else if (weight < w[i]) {
      return search(i + 1, weight);
    } else {
      return Math.max(
        search(i + 1, weight - w[i]) + v[i],
        search(i + 1, weight)
      );
    }
  }

}

Compiler output:
Main.java:4: error: class SolutionDP is public, should be declared in a file named SolutionDP.java
public class SolutionDP {
       ^
1 error
Language: Java

import java.io.*;
import java.util.*;

public class Solution {

  private static int N;
  private static int W;
  private static int[] v;
  private static int[] w;

  public static void main(String[] args) {

/*
    N = 4;
    W = 5;
    v = new int[]{4, 5, 2, 8};
    w = new int[]{2, 2, 1, 3};
*/

    N = 2;
    W = 20;
    v = new int[]{5, 4};
    w = new int[]{9, 10};

    int ret = search(0, W);

    System.out.println(ret);
  }

  /**
    i ?????§???????????????????????¶???????????\????????¨????????????????????§????????????.

    search(i + 1, weight) = max(
     search(i, weight - weight[i]) + value[i],
     search(i, weight)
    )

    ?????°??¢??°??????????????¶: i == N

    @return ??????????????§???.
  */
  public static int search(int i, int weight) {
    if (i == N) {
      return 0;
    } else if (weight < w[i]) {
      return search(i + 1, weight);
    } else {
      return Math.max(
        search(i + 1, weight - w[i]) + v[i],
        search(i + 1, weight)
      );
    }
  }

}

Compiler output:
Main.java:4: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error