Language: Java

#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int m;
  int co=0;
  while(cin>>m,m){
    co++;
    int n;
    char d;
    cin>>n;
    vector<int>w(n),v(n);
    vector<vector<int> >dp(n+1);
    rep(i,m+1)dp[0].pb(0);
    rep(i,n)cin>>v[i]>>d>>w[i];
    rep(i,n){
      //dp[i].pb(0);
      rep(j,m+1){
	if(w[i]>j)dp[i+1].pb(dp[i][j]);
	else dp[i+1].pb(max(dp[i][j],dp[i][j-w[i]]+v[i]));
      }
    }
    int maxi=0;
    rep(i,m)if(dp[n][i]==dp[n][m]){maxi=i;break;}

    cout<<"Case "<<co<<":"<<endl;
    cout<<dp[n][m]<<endl;
    cout<<maxi<<endl;
  }


}

Compiler output:
Main.java:1: error: illegal character: '#'
#include<iostream>
^
Main.java:2: error: illegal character: '#'
#include<string>
^
Main.java:3: error: illegal character: '#'
#include<algorithm>
^
Main.java:4: error: illegal character: '#'
#include<map>
^
Main.java:5: error: illegal character: '#'
#include<set>
^
Main.java:6: error: illegal character: '#'
#include<utility>
^
Main.java:7: error: illegal character: '#'
#include<vector>
^
Main.java:8: error: illegal character: '#'
#include<cmath>
^
Main.java:9: error: illegal character: '#'
#include<cstdio>
^
Main.java:10: error: illegal character: '#'
#define loop(i,a,b) for(int i=a;i<b;i++) 
^
Main.java:10: error: class, interface, enum, or record expected
#define loop(i,a,b) for(int i=a;i<b;i++) 
                                ^
Main.java:10: error: class, interface, enum, or record expected
#define loop(i,a,b) for(int i=a;i<b;i++) 
                                    ^
Main.java:11: error: illegal character: '#'
#define rep(i,a) loop(i,0,a)
^
Main.java:12: error: illegal character: '#'
#define pb push_back
^
Main.java:13: error: illegal character: '#'
#define mp make_pair
^
Main.java:14: error: illegal character: '#'
#define it ::iterator
^
Main.java:15: error: illegal character: '#'
#define all(in) in.begin(),in.end()
^
Main.java:17: error: class, interface, enum, or record expected
const double ESP=1e-10;
^
Main.java:18: error: class, interface, enum, or record expected
using namespace std;
^
Main.java:22: error: not a statement
  while(cin>>m,m){
               ^
Main.java:26: error: not a statement
    cin>>n;
       ^
Main.java:27: error: not a statement
    vector<int>w(n),v(n);
                 ^
Main.java:28: error: not a statement
    vector<vector<int> >dp(n+1);
                            ^
Main.java:30: error: not a statement
    rep(i,n)cin>>v[i]>>d>>w[i];
                        ^
Main.java:41: error: not a statement
    cout<<"Case "<<co<<":"<<endl;
                          ^
Main.java:42: error: not a statement
    cout<<dp[n][m]<<endl;
                  ^
Main.java:43: error: not a statement
    cout<<maxi<<endl;
              ^
Main.java:19: error: unnamed classes are a preview feature and are disabled by default.
int main(){
^
  (use --enable-preview to enable unnamed classes)
Main.java:22: error: ')' expected
  while(cin>>m,m){
              ^
Main.java:22: error: ';' expected
  while(cin>>m,m){
                ^
Main.java:27: error: ';' expected
    vector<int>w(n),v(n);
                ^
Main.java:27: error: ';' expected
    vector<int>w(n),v(n);
                  ^
Main.java:28: error: ';' expected
    vector<vector<int> >dp(n+1);
                          ^
Main.java:28: error: ';' expected
    vector<vector<int> >dp(n+1);
                              ^
Main.java:29: error: ';' expected
    rep(i,m+1)dp[0].pb(0);
              ^
Main.java:30: error: ';' expected
    rep(i,n)cin>>v[i]>>d>>w[i];
            ^
Main.java:31: error: ';' expected
    rep(i,n){
            ^
Main.java:33: error: ';' expected
      rep(j,m+1){
                ^
Main.java:39: error: ';' expected
    rep(i,m)if(dp[n][i]==dp[n][m]){maxi=i;break;}
            ^
39 errors