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

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100;

int N;
ll a[MAX_N + 1];

// ford-fulkerson O(FE) F:Flow
// maximum flow problem
// 1. init G[V] by add_edge
// 2. max_flow(s, t) return the max flow

const int MAX_V = MAX_N + 2;

struct edge{int to, cap, rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
  G[from].push_back((edge){to, cap, int(G[to].size())});
  G[to].push_back((edge){from, 0, int(G[from].size() -1)});
}

int dfs(int v, int t, int f){
  if(v == t) return f;
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t){
  int flow = 0;
  for(;;){
    memset(used, 0, sizeof(used));
    int f = dfs(s, t, INFi);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(){
  cin >> N;

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

  ll ans = 0;

  int s = 0, t = N + 1;
  for(int i = 1; i <= N; i++) {
    if(a[i] < 0) {
      add_edge(s, i, -a[i]);
    } else {
      ans += a[i];
      add_edge(i, t, a[i]);
    }
    for(int j = 2; i * j <= N; j++) {
      add_edge(i, i * j, INFll);
    }
  }

  ans -= max_flow(s, t);

  cout << ans << endl;


  return 0;
}


Compiler output:
a.cc: In function 'int max_flow(int, int)':
a.cc:74:5: error: 'memset' was not declared in this scope
   74 |     memset(used, 0, sizeof(used));
      |     ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <map>
  +++ |+#include <cstring>
    8 | #include <deque>
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100;

int N;
ll a[MAX_N + 1];

// Dinic O(EV^2)
// maximum flow problem
// 1. init G[V] by add_edge
// 2. max_flow(s, t) return the max flow

const int MAX_V = MAX_N + 2;

struct edge{int to, cap, rev;};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap){
  G[from].push_back((edge){to, cap, int(G[to].size())});
  G[to].push_back((edge){from, 0, int(G[from].size() -1)});
}

void bfs(int s){
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(!que.empty()){
    int v = que.front(); que.pop();
    REP(i,G[v].size()){
      edge &e = G[v][i];
      if (e.cap > 0 && level[e.to] < 0){
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}

int dfs(int v, int t, int f){
  if(v == t) return f;
  for (int &i = iter[v]; i < G[v].size(); i++){
    edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]){
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t){
  int flow = 0;
  for(;;){
    bfs(s);
    if(level[t] < 0) return flow;
    int f;
    while((f = dfs(s, t, INFi)) > 0){
      flow += f;
    }

  }
}

int main(){
  cin >> N;

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

  ll ans = 0;

  int s = 0, t = N + 1;
  for(int i = 1; i <= N; i++) {
    if(a[i] < 0) {
      add_edge(s, i, -a[i]);
    } else {
      ans += a[i];
      add_edge(i, t, a[i]);
    }
    for(int j = 2; i * j <= N; j++) {
      add_edge(i, i * j, INFi);
    }
  }

  ans -= max_flow(s, t);

  cout << ans << endl;


  return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:56:3: error: 'memset' was not declared in this scope
   56 |   memset(level, -1, sizeof(level));
      |   ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <map>
  +++ |+#include <cstring>
    8 | #include <deque>
Language: C++

#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int n;
    long long num[105];
    long long he;
    cin>>n;
    for (int i=1;i<=n;i++) cin>>num[i];
    for (int i=1;i<=n;i++) {
        he=num[i];
        if (num[i]<=0)
            for (int j=2;j<=n/i;j++)
                if (num[j*i]>0) he+=num[j*i];
        if (he<=0)
            for (int j=1;j<=n/i;j++) num[j*i]=0;
    }
    he=0;
    for (int i=1;i<=n;i++) he+=num[i];
    cout<<(long long) (he)<<endl;
    return 0;x
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: 'x' was not declared in this scope
   21 |     return 0;x
      |              ^
Language: C++

#include <bits/stdc++.h>

const int N = 200;
const int INF = 1<<30;
const int LIM = 2000;

int n, a[N];

int tmp[N];

inline double random() { return rand() * 1.0 / RAND_MAX; }

inline int solve()
{
    for( int i = 1; i <= n; i ++ )
        tmp[i] = a[i];

    for( int i = n; i >= 1; i -- )
    {
        int now = 0;
        for( int j = i; j <= n; j += i )
            now -= tmp[j];

        if( now >= 0 || exp( now * 1.0 / i ) >= random() )
            for( int j = i; j <= n; j += i ) tmp[j] = 0;
    }

    int ret = 0;
    for( int i = 1; i <= n; i ++ )
        ret += tmp[i];
    return ret;
}

int main()
{
    srand( time( 0 ) );

    scanf( "%d", &n );
    for( int i = 1; i <= n; i ++ )
        scanf( "%d", &a[i] );

    int ans = 0;
    for( int i = 1; i <= LIM; i ++ )
        ans = std::max( ans, solve() );
    printf( "%d\n", ans );

    return 0;
}

Compiler output:
a.cc:11:15: error: ambiguating new declaration of 'double random()'
   11 | inline double random() { return rand() * 1.0 / RAND_MAX; }
      |               ^~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:521:17: note: old declaration 'long int random()'
  521 | extern long int random (void) __THROW;
      |                 ^~~~~~
Language: C++

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

int main(){

    long long n = 0; cin >> n;
    vector<long long> a(n + 1);
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = n; i >= 1; i--){
        
        long long c = 0;
        for(int j = i; j <= n; j += i){
            c += a[j];
        }
        if(c < 0){
            ans.push_back(i);
            for(int j = i; j <= n; j += i) a[j] = 0;
            
        }
    }

    long long q = 0;
    for(int i = 1; i <= n; i++) q += a[i];
    cout << q << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |             ans.push_back(i);
      |             ^~~
      |             abs
Language: C++

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
    int N;
    cin >> N;
    int halfN = N/2 + 1;


    vector<long long >vec1(N);

    vector<bool>flgV(N);

    
    REP(i,N){
        cin >> vec1[i];
        flgV[i] = true;
    }
 
    for(int i=N-1;i>=0 ;--i){
        if( i >= halfN && vec1[i] < 0) flgV[i] = false;
        else
            {
                long long s = 0;
                for(int a=1; a*(i+1) <= N; ++a){
                    if(flgV[a*(i+1) - 1]) s += vec1[a*(i+1)-1];                    
                }
                if (s =< 0){
                    for(int a=1; a*(i+1) <= N; ++a){
                        flgV[a*(i+1) -1] = false;
                    }
                }
            }
    }
        
    long long ans =0;

    REP(i,N){
        if(flgV[i]) ans+= vec1[i];
    }
    
    cout << ans << endl;


   
}




Compiler output:
a.cc: In function 'int main()':
a.cc:97:24: error: expected primary-expression before '<' token
   97 |                 if (s =< 0){
      |                        ^
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

const int p[18] = { 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,3,9,15,21,5,7 };
//const int q[4] = { 13,14,15,16 };

int main(){
	int N;
	ll a[102] = {};
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&a[i]);
	}
	for(int i = N/2+1 ; i <= N ; i ++){
		a[i] = max( a[i] , 0LL );
	}
	
	ll ret = 0;
	for(int s = 0 ; s < (1<<21) ; ++s){
		ll A[102];
		for(int i = 1 ; i <= N ; ++i){
			A[i] = a[i];
		}
		for(int i = 0 ; i < 21 ; ++i){
			if((s>>i)&1){
				for(int j = p[i] ; j <= N ; j += p[i]){
					A[j] = 0;
				}
			}
		}
		
		for(int i = N/2 ; i >= 1 ; --i){
			ll sum = 0;
			for(int j = i ; j <= N ; j += i){
				sum += A[j];
			}
			if(i == 1){
				ret = max( ret , sum );
				break;
			}
			if(sum < 0){
				for(int j = i ; j <= N ; j += i){
					A[j] = 0;
				}
			}
			/*for(int j = 0 ; j < 2 ; j ++){
				if(i == 2*q[j]){
					sum = A[2*q[j]]+A[3*q[j]]+A[6*q[j]];
					if(sum < 0){
						A[2*q[j]] = 0;
						A[3*q[j]] = 0;
						A[6*q[j]] = 0;
					}
				}
			}*/
		}
		
		
	}
	cout << ret << endl;
}



Compiler output:
a.cc:17:79: error: too many initializers for 'const int [18]'
   17 | const int p[18] = { 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,3,9,15,21,5,7 };
      |                                                                               ^
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

const int p[18] = { 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,3,9,15,21,5,7 };
//const int q[4] = { 13,14,15,16 };

int main(){
	int N;
	ll a[102] = {};
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&a[i]);
	}
	for(int i = N/2+1 ; i <= N ; i ++){
		a[i] = max( a[i] , 0LL );
	}
	
	ll ret = 0;
	for(int s = 0 ; s < (1<<22) ; ++s){
		ll A[102];
		for(int i = 1 ; i <= N ; ++i){
			A[i] = a[i];
		}
		for(int i = 0 ; i < 22 ; ++i){
			if((s>>i)&1){
				for(int j = p[i] ; j <= N ; j += p[i]){
					A[j] = 0;
				}
			}
		}
		
		for(int i = N/2 ; i >= 1 ; --i){
			ll sum = 0;
			for(int j = i ; j <= N ; j += i){
				sum += A[j];
			}
			if(i == 1){
				ret = max( ret , sum );
				break;
			}
			if(sum < 0){
				for(int j = i ; j <= N ; j += i){
					A[j] = 0;
				}
			}
			/*for(int j = 0 ; j < 2 ; j ++){
				if(i == 2*q[j]){
					sum = A[2*q[j]]+A[3*q[j]]+A[6*q[j]];
					if(sum < 0){
						A[2*q[j]] = 0;
						A[3*q[j]] = 0;
						A[6*q[j]] = 0;
					}
				}
			}*/
		}
		
		
	}
	cout << ret << endl;
}



Compiler output:
a.cc:17:79: error: too many initializers for 'const int [18]'
   17 | const int p[18] = { 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,3,9,15,21,5,7 };
      |                                                                               ^
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

const int p[19] = { 2,4,6,8,10,12,14,16,18,20,22,24,3,9,15,21,5,7,32,30 };
const int q[4] = { 13,14,15,16 };

int main(){
	int N;
	ll a[102] = {};
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&a[i]);
	}
	for(int i = N/2+1 ; i <= N ; i ++){
		a[i] = max( a[i] , 0LL );
	}
	
	ll ret = 0;
	for(int s = 0 ; s < (1<<20) ; s ++){
		ll A[102];
		for(int i = 1 ; i <= N ; i ++){
			A[i] = a[i];
		}
		for(int i = 0 ; i < 20 ; i ++){
			if((s>>i)&1){
				for(int j = p[i] ; j <= N ; j += p[i]){
					A[j] = 0;
				}
			}
		}
		
		for(int i = N ; i >= 1 ; i --){
			ll sum = 0;
			for(int j = i ; j <= N ; j += i){
				sum += A[j];
			}
			if(i == 1){
				ret = max( ret , sum );
				break;
			}
			if(sum < 0){
				for(int j = i ; j <= N ; j += i){
					A[j] = 0;
				}
			}
			for(int j = 0 ; j < 2 ; j ++){
				if(i == 2*q[j]){
					sum = A[2*q[j]]+A[3*q[j]]+A[6*q[j]];
					if(sum < 0){
						A[2*q[j]] = 0;
						A[3*q[j]] = 0;
						A[6*q[j]] = 0;
					}
				}
			}
		}
		
		
	}
	cout << ret << endl;
}



Compiler output:
a.cc:17:73: error: too many initializers for 'const int [19]'
   17 | const int p[19] = { 2,4,6,8,10,12,14,16,18,20,22,24,3,9,15,21,5,7,32,30 };
      |                                                                         ^
Language: C++

#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

void set_score(vector<int> &score, vector<int> &a, vector<bool> &alive){
    int N = score.size();
    for (int pos = 1; pos <= N; pos++){
        int s=0;
        int i = pos;
        while(i <= N){
            if (alive[i-1]){
                s += a[i - 1];
            }
            i+=pos;
        }
        score[pos-1]=s;
    }
}

void set_dead(int pos, vector<bool> &alive){
    int N = alive.size();
    int i = pos;
    while(i <= N){
        alive[i -1]=false;
        i += pos;
    }
}

void show_vec(vector<int> &vec){
    int N = vec.size();
    for (int i=1; i<=N;i++){
        cout<<i<<":"<<vec[i-1]<<endl;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i =0;i<N;i++){
        cin>>a[i];
    }

    vector<bool> alive(N, true);
    vector<int> score(N, 0);
    set_score(score, a, alive);

    while (true) {
        int pos = min_element(score.begin(), score.end()) - score.begin() + 1;
        int minVal = score[pos - 1];
        if (minVal >= 0) {
            break;
        } else {
            set_dead(pos, alive);
            set_score(score, a, alive);
        }
    }

    cout<<score[0]<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:51:19: error: 'min_element' was not declared in this scope
   51 |         int pos = min_element(score.begin(), score.end()) - score.begin() + 1;
      |                   ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
int N;
int a[128];
bool flag[128];

#define MAX_N 128
#define INF (2<<21)

class dinic {
private:
	struct edge { int to, cap, rev; };
	vector<edge> G[MAX_N];
	//sからの深さを記憶
	vector<int> level;
	int V;

	//深さ優先で経路を検索
	//経路を見つけたら流して更新
	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap <= 0) continue;
			if (level[v] >= level[e.to]) continue;
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}

	//幅優先
	void bfs(int s) {
		level.assign(V, -1);
		queue<int> q;
		q.push(s);
		level[s] = 0;
		for (; !q.empty();) {
			int v = q.front(); q.pop();
			for (int i = 0; i < G[v].size(); i++) {
				struct edge e = G[v][i];
				if (e.cap <= 0) continue;
				//既に通った辺なら
				if (level[e.to] >= 0) continue;
				level[e.to] = level[v] + 1;
				q.push(e.to);
			}
		}
	}


public:
	dinic(int v) {
		V = v;
	}
	void add_edge(int from, int to, int cap) {
		struct edge tmp;
		tmp = { to, cap, int(G[to].size()) };
		G[from].push_back(tmp);
		tmp = { from, 0, int(G[from].size() - 1) };
		G[to].push_back(tmp);
	}

	int run(int s, int t) {
		int f = 0;
		for (;;) {
			bfs(s);
			if (level[t] < 0) break;
			f += dfs(s, t, INF);
		}
		return f;
	}
};

void MUL() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	//後半で負の宝石は問答無用で叩き割る
	for (int i = (N + 1 / 2); i < N; i++) {
		a[i] = a[i] < 0 ? 0 : a[i];
	}

	int ideal = 0;
	for (int i = 0; i < N; i++) {
		ideal += a[i] > 0 ? a[i] : 0;
	}

	memset(flag, 0, sizeof(flag));

	dinic d(N + 2);
	for (int i = 0; i < N; i++) {
		if (a[i] > 0) {
			d.add_edge(0, i + 1, a[i]);
			d.add_edge(i + 1, N + 1, 0);
		}
		else {
			d.add_edge(i + 1, N + 1, -a[i]);
			d.add_edge(0, i + 1, 0);
		}
		for (int j = (i + 1) * 2; j < N + 1; j += i + 1) {
			d.add_edge(j, (i + 1), INF);
		}
	}
	cout << ideal - d.run(0, N + 1) << endl;
}

int main() {
	MUL();
	return 0;
}


Compiler output:
a.cc: In function 'void MUL()':
a.cc:98:9: error: 'memset' was not declared in this scope
   98 |         memset(flag, 0, sizeof(flag));
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <queue>
  +++ |+#include <cstring>
    6 | using namespace std;
Language: C++

#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;
ll n, mx, sum, a[105];
bool b[105][105];
bool bo[105];

void g(ll p)
{
    for(ll i = p; i <= n; i += p)
    {
        if(bo[i] == false)bo[i] = true;
    }
}

void f(ll p)
{
    if(p > n)
    {
        sum = 0;
        ll i;
        for(i = 1; i <= n; i++)
        {
            sum += (1 - bo[i]) * a[i];
        }
        mx = max(mx, sum);
        return;
    }
    f(p + 1);
    if(a[p] < 0) g(p), f(p + 1)

int main()
{
    scanf("%lld", &n);
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    f(1);
    printf("%lld", mx);
    return 0;
}


Compiler output:
a.cc: In function 'void f(ll)':
a.cc:33:32: error: expected ';' before 'int'
   33 |     if(a[p] < 0) g(p), f(p + 1)
      |                                ^
      |                                ;
   34 | 
   35 | int main()
      | ~~~                             
a.cc:45:2: error: expected '}' at end of input
   45 | }
      |  ^
a.cc:20:1: note: to match this '{'
   20 | {
      | ^
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define int long long
const int N=110;
int n,a[N];
namespace isap{
    const int N=110,M=5000;
    int tot=1,fi[N],ne[M],a[M],c[M];
    inline void add(int x,int y,int z){
        a[++tot]=y;c[tot]=z;ne[tot]=fi[x];fi[x]=tot;
        a[++tot]=x;c[tot]=0;ne[tot]=fi[y];fi[y]=tot;
    }
    int n,s,t,gap[N],cur[N],h[N];
    inline int dfs(int x,int f){
        if (x==t) return f;
        int rst=0;
        for (int &i=cur[x];i;i=ne[i]) if (c[i]&&h[x]==h[a[i]]+1){
            int temp=dfs(a[i],min(f,c[i]));
            c[i]-=temp;c[i^1]+=temp;f-=temp;rst+=temp;
            if (!f) return rst;
        }
        if (--gap[h[x]]==0) h[s]=n+1;
        ++gap[++h[x]];cur[x]=fi[x];
        return rst;
    } 
    inline int maxflow(int _n,int _s,int _t){
        n=_n;s=_s;t=_t;
        memcpy(cur,fi,sizeof fi);gap[0]=n;
        int mf=0;
        while (h[s]<=n) mf+=dfs(s,1e9);
        return mf;
    }
}
signed main(){
	scanf("%lld",&n);
	int s=n+1,t=n+2,ans=0;
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]),ans+=max(a[i],0ll);
	for (int i=1;i<=n;++i) if (a[i]<0){
		isap::add(s,i,-a[i]);
		for (int j=2*i;j<=n;j+=i) if (a[j]>0) isap::add(i,j,1e9);
	}else if (a[i]>0) isap::add(i,t,a[i]);
	printf("%lld",ans-isap::maxflow(n+2,s,t));
	return 0;
}

Compiler output:
a.cc: In function 'long long int isap::maxflow(long long int, long long int, long long int)':
a.cc:30:9: error: 'memcpy' was not declared in this scope
   30 |         memcpy(cur,fi,sizeof fi);gap[0]=n;
      |         ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MN 105
#define inf 0x7f7f7f7f
int fr[MN],nex[MN*MN],vi[MN*MN],wi[MN*MN],tot=0,pi[MN*MN];
void Add(int x,int y,int z){
	vi[++tot]=y;wi[tot]=z;nex[tot]=fr[x];fr[x]=tot;
	vi[++tot]=x;wi[tot]=0;nex[tot]=fr[y];fr[y]=tot;
}
int v[MN],n;
int cur[MN],dep[MN],s,t,xr[MN];
void init(){
	++xr[dep[t]=1];
	queue<int> Q;Q.push(t);
	while(!Q.empty()){
		int x=Q.front();Q.pop();
		for(int i=fr[x];i;i=nex[i])if(!dep[vi[i]]){
			++xr[dep[vi[i]]=dep[x]+1];
			Q.push(vi[i]);
		}
	}
	for(int i=0;i<=n+1;++i)cur[i]=fr[i];
}
long long dfs(int x,int f){
	if(x==t||f==0)return f;
	int flow=0,fl;
	for(int &i=cur[x];i;i=nex[i]){
		if(dep[x]==dep[vi[i]]+1&&(fl=dfs(vi[i],min(f,wi[i])))>0){
			f-=fl;flow+=fl;wi[i]-=fl;wi[(i&1)?(i+1):(i-1)]+=fl;if(!f)return flow;
		}
	}
	if(!(--xr[dep[x]]))dep[s]=n+3;
	else ++xr[++dep[x]],cur[x]=fr[x];
	return flow;
}
int main(){
	long long sum=0;scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",v+i);
	for(int i=1;i<=n;++i){
		if(v[i]>=0)add(i,n+1,v[i]),sum+=v[i];
		else add(0,i,-v[i]);
		for(int j=2;j*i<=n;++j){
			add(i,j*i,inf);
		}
	}
	s=0;t=n+1;init();
	while(dep[s]<=n+2)sum-=dfs(s,inf);
	cout<<sum;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:28: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   40 |                 if(v[i]>=0)add(i,n+1,v[i]),sum+=v[i];
      |                            ^~~
      |                            std::filesystem::perm_options::add
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here
  219 |       add       = 0x2,
      |       ^~~
a.cc:41:22: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   41 |                 else add(0,i,-v[i]);
      |                      ^~~
      |                      std::filesystem::perm_options::add
/usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here
  219 |       add       = 0x2,
      |       ^~~
a.cc:43:25: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   43 |                         add(i,j*i,inf);
      |                         ^~~
      |                         std::filesystem::perm_options::add
/usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here
  219 |       add       = 0x2,
      |       ^~~
Language: C++

#include<bits/stdc++.h>
#define ll int
#define lpl long long 
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=1e5+500;
const ll mod=1e9+7;
const ll inf=1e9+500;

ll a[maxn];
ll b[maxn];
int main(){
	ll n;
	lpl ans=0;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	l q=n/3+1;
	for(ll i=n;i>=q;i--){
		lpl s=a[i];
		for(ll j=2*i;j<=n;j+=i){
			s+=a[j];
		}
		if(s<0){
			for(ll j=i;j<=n;j+=i){
				a[j]=0;
			}
		}	
	}

	for(ll i=n;i>=q;i--){
		lpl s=a[i];
		for(ll j=2*i;j<=n;j+=i){
			s+=a[j];
		}
		if(s<0){
			for(ll j=i;j<=n;j+=i){
				a[j]=0;
			}
		}	
	}
	for(ll i=n;i>=q;i--){
		lpl s=a[i];
		for(ll j=2*i;j<=n;j+=i){
			s+=a[j];
		}
		if(s<0){
			for(ll j=i;j<=n;j+=i){
				a[j]=0;
			}
		}	
	}
	for(ll i=n;i>=q;i--){
		lpl s=a[i];
		for(ll j=2*i;j<=n;j+=i){
			s+=a[j];
		}
		if(s<0){
			for(ll j=i;j<=n;j+=i){
				a[j]=0;
			}
		}	
	}
	ll tof=25;
	vector<ll> vec;
	for(ll i=1;i<=n && vec.size()<=tof;i++){
		if(a[i]<0){
			vec.pb(i);
		}
	}
	if(vec.size()==0){
		lpl s=0;
		for(ll i=1;i<=n;i++){
			s+=a[i];
		}
		cout<<s;
		return 0;
	}

	for(ll i=1;i<=n;i++){
		b[i]=a[i];
	}
	ll t=vec.size();
	for(ll mask=0;mask<(1<<t);mask++){
		lpl s=0;
		for(ll i=0;i<t;i++){
			if((mask>>i)&1){
				ll v=vec[i];
				for(ll j=v;j<=n;j+=v){
					a[j]=0;
				}
			}
		}
		for(ll i=1;i<=n;i++){
			s+=a[i];
			a[i]=b[i];
		}
		ans=max(ans,s);
	}
	cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'l' was not declared in this scope
   25 |         l q=n/3+1;
      |         ^
a.cc:26:23: error: 'q' was not declared in this scope
   26 |         for(ll i=n;i>=q;i--){
      |                       ^
a.cc:38:23: error: 'q' was not declared in this scope
   38 |         for(ll i=n;i>=q;i--){
      |                       ^
a.cc:49:23: error: 'q' was not declared in this scope
   49 |         for(ll i=n;i>=q;i--){
      |                       ^
a.cc:60:23: error: 'q' was not declared in this scope
   60 |         for(ll i=n;i>=q;i--){
      |                       ^
Language: C++

#include<bits/stdc++.h>
#define N 5000
#define INF 1000000000000000LL
typedef long long LL;
using namespace std;
int nd[N], nx[N], g[N], a[N], d[N], cnt = 2+, S, T, n;
LL c[N];

void link(int x, int y, LL z) {
    nd[cnt] = y, nx[cnt] = g[x], c[cnt] = z, g[x] = cnt++;
    nd[cnt] = x, nx[cnt] = g[y], c[cnt] = 0, g[y] = cnt++;
}

bool bfs() {
    memset(d, -1, sizeof(d));
    queue<int> q;
    q.push(S), d[S] = 0;
    while (!q.empty()) {
        int tmp = q.front();
        q.pop();
        for(int p = g[tmp]; p; p = nx[p])
            if (d[nd[p]] == -1 && c[p]) {
                d[nd[p]] = d[tmp] + 1;
                q.push(nd[p]);
            }
    }
    return d[T] != -1;
}

LL dfs(int u, LL f) {
    if (u == T || f == 0) return f;
    LL ret = 0;
    for(int p = g[u]; p; p = nx[p])
        if (d[nd[p]] == d[u] + 1 && c[p]) {
            LL w = dfs(nd[p], min(f, c[p]));
            c[p] -= w, c[p ^ 1] += w, f -= w;
            ret += w;
        }
    if (!ret) d[u] = -1;
    return ret;
}

LL dinic() {
    LL ret = 0;
    while (bfs())
        ret += dfs(S, INF);
    return ret;
}

void make_edge() {
    S = 0, T = n + 1;
    for(int i = 1; i <= n; i++) {
        if (a[i] >= 0) link(i, T, a[i]);
        if (a[i] < 0) link(S, i, -a[i]);
    }
    for(int i = 1; i <= n; i++)
        for(int j = 2 * i; j <= n; j += i)
            link(i, j, INF);
}

int main() {
    cin >> n;
    LL ans = 0;
    for(int i = 1; i <= n; i++) cin >> a[i], ans += a[i] * (a[i] > 0);
    make_edge();
    cout << ans - dinic() << endl;
}


Compiler output:
a.cc:6:45: error: expected primary-expression before ',' token
    6 | int nd[N], nx[N], g[N], a[N], d[N], cnt = 2+, S, T, n;
      |                                             ^
a.cc: In function 'bool bfs()':
a.cc:17:12: error: 'S' was not declared in this scope
   17 |     q.push(S), d[S] = 0;
      |            ^
a.cc:27:14: error: 'T' was not declared in this scope
   27 |     return d[T] != -1;
      |              ^
a.cc: In function 'LL dfs(int, LL)':
a.cc:31:14: error: 'T' was not declared in this scope
   31 |     if (u == T || f == 0) return f;
      |              ^
a.cc: In function 'LL dinic()':
a.cc:46:20: error: 'S' was not declared in this scope
   46 |         ret += dfs(S, INF);
      |                    ^
a.cc: In function 'void make_edge()':
a.cc:51:5: error: 'S' was not declared in this scope
   51 |     S = 0, T = n + 1;
      |     ^
a.cc:51:12: error: 'T' was not declared in this scope
   51 |     S = 0, T = n + 1;
      |            ^
a.cc:51:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   51 |     S = 0, T = n + 1;
      |                ^
      |                yn
a.cc: In function 'int main()':
a.cc:62:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   62 |     cin >> n;
      |            ^
      |            yn
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 107;

int A[MAXN];
vector <int> M, D[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	LL sum;
	cin >> n;
	FOR(i, 1, n + 1)
	{
		cin >> A[i];
		FOR(j, 1, i + 1)
			if (i % j == 0) D[i].push_back(j);
	}
	RFOR(i, n + 1, 1)
	{
		sum = 0;
		for (int j = i; j <= n; j += i)
			sum += A[j];
		if (sum < 0)
			for (int j = i; j <= n; j += i)
				A[j] = 0;
	}
	FOR(i, 1, n + 1)
		if (A[i] < 0) M.push_back(i);
	LL ans = 0;
	REP(mask, 1 << SZ(M))
	{
		LL cur = 0;
		bool del[MAXN];
		memset(del, 0, MAXN);
		REP(i, SZ(M))
		{
			if (mask & (1 << i))
				for (int j = M[i]; j <= n; j += M[i])
					del[j] = 1;
		}
		FOR(i, 1, n + 1)
			if (!del[i]) cur += A[i];
		ans = max(ans, cur);
	}
	cout << ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:17: error: 'memset' was not declared in this scope
   75 |                 memset(del, 0, MAXN);
      |                 ^~~~~~
a.cc:22:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   21 | #include <complex>
  +++ |+#include <cstring>
   22 | #include <stdio.h>
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#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 all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef long long int;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vi level,iter;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	void bfs(int s){
		level=vi(n,-1);
		queue<int>q;
		level[s]=0;
		q.push(s);
		while(!q.empty()){
			int v=q.front();q.pop();
			for(int i=0;i<G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					q.push(e.to);
				}
			}
		}
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge &e=G[v][i];
			if(level[v]>=level[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int mf(int s,int t) {//from s to t,ford_fulkerson
		int flow=0;
		while(1){
			bfs(s);
			if(level[t]<0)return flow;
			iter=vi(n);
			int f;
			while((f=dfs(s,t,inf))>0)flow+=f;
		}
	}
};
int main(){
	int n;
	cin>>n;
	MF mf(n+2);
	int s=n,t=n+1;
	ll sum=0;
	rep(i,n){
		ll a;cin>>a;
		if(a>=0)sum+=a,mf.add_edge(i,t,a);
		else mf.add_edge(s,i,-a);
	}
	loop(i,1,n)loop(j,1,n+1)if(i*j<=n)mf.add_edge(i-1,i*j-1,inf);
	cout<<sum-mf.mf(s,t)<<endl;
}






Compiler output:
a.cc:25:19: error: declaration does not declare anything [-fpermissive]
   25 | typedef long long int;
      |                   ^~~
Language: C++

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

typedef long long ll;

int N;
vector<int> arr, chk;

int main() {
    scanf("%d", &N);

    arr.resize(N);
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        scanf("%d", &arr[i]);
        ans += arr[i];
    }

    chk = vector<int>(N, 0);

    while(1) {
        bool ok = false;
        for(int i = N; i >= 1; i--) {
            if(!chk[j - 1] && arr[i - 1] >= 0) continue;
            ll sum = 0;
            for(int j = i; j <= N; j += i) {
                if(!chk[j - 1]) sum += arr[j - 1];
            }
            if(sum < 0) {
                ans -= sum;
                for(int j = i; j <= N; j += i) {
                    chk[j - 1] = 1;
                }
                ok = true;
                break;
            }
        }
        if(!ok) break;
    }
    cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:21: error: 'j' was not declared in this scope
   24 |             if(!chk[j - 1] && arr[i - 1] >= 0) continue;
      |                     ^
Language: Java

import java.util.*;

public class Main {

  class MaxFlow {
        class Edge {
            public final int to, rev;
            public long cap;
 
            public Edge(int to, int rev, long cap) {
                this.to = to;
                this.rev = rev;
                this.cap = cap;
            }
        }
 
        int v;
        List<Edge> G[];
        boolean used[];
 
        public MaxFlow(int v) {
            this.v = v;
            G = new List[v];
            for (int i = 0; i < v; ++i) {
                G[i] = new ArrayList<>();
            }
            used = new boolean[v];
        }
 
        public void add_edge(int from, int to, long cap) {
            G[from].add(new Edge(to, G[to].size(), cap));
            G[to].add(new Edge(from, G[from].size() - 1, 0));
        }
 
        long dfs(int v, int t, long f) {
            if (v == t) return f;
            used[v] = true;
            for (Edge e : G[v]) {
                if (!used[e.to] && e.cap > 0) {
                    long d = dfs(e.to, t, Math.min(f, e.cap));
                    if (d > 0) {
                        e.cap -= d;
                        G[e.to].get(e.rev).cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }
 
        public long max_flow(int s, int t) {
            long flow = 0;
            while (true) {
                Arrays.fill(used, false);
                long f = dfs(s, t, Long.MAX_VALUE);
                if (f == 0) return flow;
                flow += f;
            }
        }
    }
 
    long solve(int n, long[] a) {
        MaxFlow flow = new MaxFlow(n + 2);
        for (int i = 0; i < n; ++i) {
            if (a[i] > 0) {
                flow.add_edge(i, t, a[i]);
            } else {
                flow.add_edge(s, i, -a[i]);
            }
            for (int j = (i + 1) * 2; j <= n; j += i + 1) {
                flow.add_edge(i, j - 1, Long.MAX_VALUE / 2);
            }
        }
        long x = 0;
        for (long i : a) if (i > 0) x += i;
        return x - flow.max_flow(n, n + 1);
    }
 
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N];
        for(int i = 0; i < N; i++) {
          a[i] = sc.nextLong();
        }
        long ans = new Main().solve(N, a);
        System.out.println(ans);
    }
}

Compiler output:
Main.java:66: error: cannot find symbol
                flow.add_edge(i, t, a[i]);
                                 ^
  symbol:   variable t
  location: class Main
Main.java:68: error: cannot find symbol
                flow.add_edge(s, i, -a[i]);
                              ^
  symbol:   variable s
  location: class Main
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: Java

import java.util.*;

public class Main {

  class MaxFlow {
        class Edge {
            public final int to, rev;
            public long cap;
 
            public Edge(int to, int rev, long cap) {
                this.to = to;
                this.rev = rev;
                this.cap = cap;
            }
        }
 
        int v;
        List<Edge> G[];
        boolean used[];
 
        public MaxFlow(int v) {
            this.v = v;
            G = new List[v];
            for (int i = 0; i < v; ++i) {
                G[i] = new ArrayList<>();
            }
            used = new boolean[v];
        }
 
        public void add_edge(int from, int to, long cap) {
            G[from].add(new Edge(to, G[to].size(), cap));
            G[to].add(new Edge(from, G[from].size() - 1, 0));
        }
 
        long dfs(int v, int t, long f) {
            if (v == t) return f;
            used[v] = true;
            for (Edge e : G[v]) {
                if (!used[e.to] && e.cap > 0) {
                    long d = dfs(e.to, t, Math.min(f, e.cap));
                    if (d > 0) {
                        e.cap -= d;
                        G[e.to].get(e.rev).cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }
 
        public long max_flow(int s, int t) {
            long flow = 0;
            while (true) {
                Arrays.fill(used, false);
                long f = dfs(s, t, Long.MAX_VALUE);
                if (f == 0) return flow;
                flow += f;
            }
        }
    }

    public static long solve(int n, long[] a) {
      MaxFlow flow = new MaxFlow(n + 2);
      long ans = 0;
      for(int i = 0; i < n; i++) {
        if(a[i] > 0) ans += a[i];
      }

      for(int i = 0; i < n; i++) {
        if(a[i] > 0) flow.add_edge(i, n + 1, (int)a[i]);
        if(a[i] <= 0) flow.add_edge(n, i, (-1) * (int)a[i]);
      }
      for(int i = 0; i < n; i++) {
        for(int j = 1; (i + 1) * j <= n; j++) {
          flow.add_edge(i, (i + 1) * j - 1, Long.MAX_VALUE / 2);
        }
      }
      return ans - flow.max_flow(n, n + 1);
    }

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

    long ans = solve(N, a);

    System.out.println(ans);
  }
}


Compiler output:
Main.java:63: error: non-static variable this cannot be referenced from a static context
      MaxFlow flow = new MaxFlow(n + 2);
                     ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: Java

import java.util.*;

public class Main {

  class MaxFlow {
        class Edge {
            public final int to, rev;
            public long cap;
 
            public Edge(int to, int rev, long cap) {
                this.to = to;
                this.rev = rev;
                this.cap = cap;
            }
        }
 
        int v;
        List<Edge> G[];
        boolean used[];
 
        public MaxFlow(int v) {
            this.v = v;
            G = new List[v];
            for (int i = 0; i < v; ++i) {
                G[i] = new ArrayList<>();
            }
            used = new boolean[v];
        }
 
        public void add_edge(int from, int to, long cap) {
            G[from].add(new Edge(to, G[to].size(), cap));
            G[to].add(new Edge(from, G[from].size() - 1, 0));
        }
 
        long dfs(int v, int t, long f) {
            if (v == t) return f;
            used[v] = true;
            for (Edge e : G[v]) {
                if (!used[e.to] && e.cap > 0) {
                    long d = dfs(e.to, t, Math.min(f, e.cap));
                    if (d > 0) {
                        e.cap -= d;
                        G[e.to].get(e.rev).cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }
 
        public long max_flow(int s, int t) {
            long flow = 0;
            while (true) {
                Arrays.fill(used, false);
                long f = dfs(s, t, Long.MAX_VALUE);
                if (f == 0) return flow;
                flow += f;
            }
        }
    }

    public long solve(int n, long[] a) {
      MaxFlow flow = new MaxFlow(n + 2);
      long ans = 0;
      for(int i = 0; i < n; i++) {
        if(a[i] > 0) ans += a[i];
      }

      for(int i = 0; i < n; i++) {
        if(a[i] > 0) flow.add_edge(i, n + 1, (int)a[i]);
        if(a[i] <= 0) flow.add_edge(n, i, (-1) * (int)a[i]);
      }
      for(int i = 0; i < n; i++) {
        for(int j = 1; (i + 1) * j <= n; j++) {
          flow.add_edge(i, (i + 1) * j - 1, Long.MAX_VALUE / 2);
        }
      }
      return ans - flow.max_flow(n, n + 1);
    }

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

    long ans = solve(N, a);

    System.out.println(ans);
  }
}

Compiler output:
Main.java:86: error: non-static method solve(int,long[]) cannot be referenced from a static context
    long ans = solve(N, a);
               ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: Java

import java.util.*;

public class Main {

  class MaxFlow {
        class Edge {
            public final int to, rev;
            public long cap;
 
            public Edge(int to, int rev, long cap) {
                this.to = to;
                this.rev = rev;
                this.cap = cap;
            }
        }
 
        int v;
        List<Edge> G[];
        boolean used[];
 
        public MaxFlow(int v) {
            this.v = v;
            G = new List[v];
            for (int i = 0; i < v; ++i) {
                G[i] = new ArrayList<>();
            }
            used = new boolean[v];
        }
 
        public void add_edge(int from, int to, long cap) {
            G[from].add(new Edge(to, G[to].size(), cap));
            G[to].add(new Edge(from, G[from].size() - 1, 0));
        }
 
        long dfs(int v, int t, long f) {
            if (v == t) return f;
            used[v] = true;
            for (Edge e : G[v]) {
                if (!used[e.to] && e.cap > 0) {
                    long d = dfs(e.to, t, Math.min(f, e.cap));
                    if (d > 0) {
                        e.cap -= d;
                        G[e.to].get(e.rev).cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }
 
        public long max_flow(int s, int t) {
            long flow = 0;
            while (true) {
                Arrays.fill(used, false);
                long f = dfs(s, t, Long.MAX_VALUE);
                if (f == 0) return flow;
                flow += f;
            }
        }
    }

    public long solve(int n, long[] a) {
      MaxFlow flow = new MaxFlow(n + 2);
      long ans = 0;
      for(int i = 0; i < n; i++) {
        if(a[i] > 0) ans += a[i];
      }

      for(int i = 0; i < n; i++) {
        if(a[i] > 0) flow.add_edge(i, n + 1, (int)a[i]);
        if(a[i] <= 0) flow.add_edge(n, i, (-1) * (int)a[i]);
      }
      for(int i = 0; i < n; i++) {
        for(int j = 1; (i + 1) * j <= n; j++) {
          flow.add_edge(i, (i + 1) * j - 1, Long.MAX_VALUE / 2);
        }
      }
      return ans - flow.max_flow(n, n + 1);
    }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long a[] = new long[N];
    long ans = 0;
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextLong();
      if(a[i] > 0) ans += a[i];
    }

    long ans = solve(N, a);

    System.out.println(ans);
  }
}

Compiler output:
Main.java:91: error: variable ans is already defined in method main(String[])
    long ans = solve(N, a);
         ^
Main.java:91: error: non-static method solve(int,long[]) cannot be referenced from a static context
    long ans = solve(N, a);
               ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors