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

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

#define int ll

int N;
int l[64], t[64], r[64], b[64];
int table[256][256];

inline bool in(int i, int j){return i >= 0 && j >= 0 && i < 256 && j < 256;}
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};

void dfs(int x, int y){
    int t = table[x][y];
    table[x][y] = -1;
    for(int d = 0; d < 4; d++){
        int nx = x + dx[d], ny = y + dy[d];
        if(in(nx, ny) && table[nx][ny] == t) dfs(nx, ny);
    }
}

int main(void){
    while(cin >> N, N){
        vector<int> tmp;
        map<int, int> zip;
        for(int i = 0; i < N; i++){
            cin >> l[i] >> t[i] >> r[i] >> b[i];
            tmp.pb(l[i]);
            tmp.pb(t[i]);
            tmp.pb(r[i]);
            tmp.pb(b[i]);
        }
        sort(tmp.begin(), tmp.end());
        for(int i = 1; i <= tmp.size(); i++){
            zip[tmp[i-1]] = i;
        }
        memset(table, 0, sizeof(table));
        for(int i = 0; i < N; i++){
            int mask = 1LL << i;
            int left = zip[l[i]];
            int right = zip[r[i]];
            int top = zip[t[i]];
            int bottom = zip[b[i]];
            for(int x = left; x < right; x++)
                for(int y = bottom; y < top; y++)
                    table[x][y] |= mask;
        }
        int ans = 0;
        for(int i = 0; i < 256; i++)
            for(int j = 0; j < 256; j++)
                if(table[i][j] != -1){
                    ans++;
                    dfs(i, j);
                }

        cout << ans << endl;
    }
    return 0LL;
}

Compiler output:
a.cc:27:13: error: '::main' must return 'int'
   27 | #define int ll
      |             ^~
a.cc:46:1: note: in expansion of macro 'int'
   46 | int main(void){
      | ^~~
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;

int field[200][200];
int dx[] = { 0, 1, 0,-1};
int dy[] = {-1, 0, 1, 0};

void dfs(int y, int x, int label) {
    if (x < 0 || x >= 200 || y < 0 || y >= 200) return;
    if (field[y][x] != -1) return;
    field[y][x] = label;
    for (int i=0; i<4; ++i) {
        dfs(y + dy[i], x + dx[i], label);
    }
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> vx, vy;
        vector<int> ls, ts, rs, bs;

        for (int i=0; i<200; ++i) for (int j=0; j<200; ++j) field[i][j] = -1;

        for (int i=0; i<n; ++i) {
            int l,t,r,b;
            cin >> l >> t >> r >> b;
            ls.push_back(l);
            ts.push_back(t);
            rs.push_back(r);
            bs.push_back(b);

            for (int i=-1; i<=1; ++i) {
                vx.push_back(l + i);
                vx.push_back(r + i);
                vy.push_back(t + i);
                vy.push_back(b + i);
            }
        }

        sort(vx.begin(), vx.end());
        sort(vy.begin(), vy.end());
        map<int,int> convert_x, convert_y;
        for (int i=0; i<vx.size(); ++i) convert_x[vx[i]] = i;
        for (int i=0; i<vy.size(); ++i) convert_y[vy[i]] = i;

        // ??§?¨???§???
        for (int i=0; i<n; ++i) {
            ls[i] = convert_x[ ls[i] ];
            ts[i] = convert_y[ ts[i] ];
            rs[i] = convert_x[ rs[i] ];
            bs[i] = convert_y[ bs[i] ];
        }

        /*
        // debug
        for (int i=0; i<n; ++i) {
            printf("%3d %3d %3d %3d\n", ls[i], ts[i], rs[i], bs[i]);
        }
        cout << endl;
        */

        // ????????????????????????, -1?????????0?????????1??\?????§????????????
        for (int k=0; k<n; ++k) {
            // ?¨???¨????????????
            for (int i=ls[k]; i<=rs[k]; ++i) {
                field[ts[k]][i] = 0;
                field[bs[k]][i] = 0;
            }
            for (int i=bs[k]; i<=ts[k]; ++i) {
                field[i][ls[k]] = 0;
                field[i][rs[k]] = 0;
            }
        }
        /*
        // debug
        for (int i=0; i<50; ++i) {
            for (int j=0; j<50; ++j) {
                printf(" %2d", field[i][j]);
            }
            cout << endl;
        }
        cout << endl;
        */
        int label = 1;
        for (int i=0; i<200; ++i) {
            for (int j=0; j<200; ++j) if (field[i][j] == -1) {
                dfs(i,j,label);
                label++;
            }
        }

        /*
        // debug
        for (int i=0; i<50; ++i) {
            for (int j=0; j<50; ++j) {
                printf(" %2d", field[i][j]);
            }
            cout << endl;
        }
        cout << endl;
        */

        cout << label - 1 << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   44 |         sort(vx.begin(), vx.end());
      |         ^~~~
      |         short
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <stack>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define MP make_pair

using namespace std;

typedef pair<int, int> P;

int l[55], t[55], r[55], b[55];

int x[200], y[200];

const int H = 500, W = 500;
int field[H][W];
int used[H][W];

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

int main(){
	int n;
	while(cin >> n, n){
		rep(i, n){
			cin >> l[i] >> t[i] >> r[i] >> b[i];
			x[i*2] = l[i], x[i*2+1] = r[i];
			y[i*2] = t[i], y[i*2+1] = b[i];
		}
		sort(x, x+n*2);
		sort(y, y+n*2);

		map<int, int> mx, my;
		rep(i, n*2){
			mx[x[i]] = 2*i+1;
			my[y[i]] = 2*i+1;
		}

		memset(field, 0, sizeof(field));
		memset(used, 0, sizeof(used));

		rep(i, n){
			int L = mx[l[i]], R = mx[r[i]];
			int T = my[t[i]], B = my[b[i]];
			for(int i = L; i <= R; i++){
				field[T][i] = 1;
				field[B][i] = 1;
			}
			for(int i = B; i <= T; i++){
				field[i][L] = 1;
				field[i][R] = 1;
			}
		}

		int ans = 0;
		rep(i, H){
			rep(j, W){
				if(!field[i][j] && !used[i][j]){
					ans++;
					queue<P> q;
					q.push(MP(j, i));
					while(!q.empty()){
						int px = q.front().first;
						int py = q.front().second;
						q.pop();

						rep(i, 4){
							int nx = px+dx[i], ny = py+dy[i];
							if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
							if(field[ny][nx] || used[ny][nx]) continue;
							used[ny][nx] = 1;
							q.push(MP(nx, ny));
						}
					}
				}
			}
		} // end rep
		cout << ans << endl;

		//rep(i, 30){
		//	rep(j, 30){
		//		cout << (field[i][j]?'#':'.');
		//	}cout << endl;
		//}cout << endl;
	}


	return 0;
}

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

#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define clr clear()
#define pb push_back
#define sz size()
#define INIT(a) memset(a,0,sizeof(a))
using namespace std;
typedef vector<int> vi;
typedef long long ll;

int n;
vi x,y;
int l[110],t[110],r[110],b[110];
ll rec[110][110];
const int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

void dfs(int py, int px, ll col){
  if(rec[py][px] != col)return;
  rec[py][px] = 0;

  rep(i,4){
    int ny = py + dy[i], nx = px + dx[i];
    if(ny<0 || nx<0 || ny>=y.sz || nx>=x.sz)continue;
    dfs(ny,nx,col);
  }
}

int main(){
  while(cin >> n,n){
    x.clr; y.clr;
    rep(i,n){
      cin >> l[i] >> t[i] >> r[i] >> b[i];
      x.pb(l[i]); x.pb(r[i]);
      y.pb(t[i]); y.pb(b[i]);
    }

    sort(all(x));
    x.erase(unique(all(x)),x.end());
    sort(all(y));
    y.erase(unique(all(y)),y.end());

    INIT(rec);
    
    rep(i,n){
      l[i] = lower_bound(all(x),l[i]) - x.begin();
      r[i] = lower_bound(all(x),r[i]) - x.begin();
      t[i] = lower_bound(all(y),t[i]) - y.begin();
      b[i] = lower_bound(all(y),b[i]) - y.begin();
      for(int j=b[i];j<t[i];j++){
	for(int k=l[i];k<r[i];k++){
	  rec[j][k] |= 1LL<<i;
	}
      }
    }

    /*
    rep(i,y.sz){
      rep(j,x.sz){
	cout << rec[y.sz-1-i][j] << ' ';
      }
      cout << endl;
    }
    */

    int ans = 1;
    rep(i,y.sz){
      rep(j,x.sz){
	if(rec[i][j]){
	  dfs(i,j,rec[i][j]); ans++;
	}
      }
    }
    cout << ans << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:17: error: 'memset' was not declared in this scope
    9 | #define INIT(a) memset(a,0,sizeof(a))
      |                 ^~~~~~
a.cc:45:5: note: in expansion of macro 'INIT'
   45 |     INIT(rec);
      |     ^~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 | #define rep(i,n) for(int i=0;i<(int)n;i++)
Language: Java

public class GetClockHandsAngle {

    private static final double MIN_PER_HOUR = 60;
    private static final double FULL_DEGREE = 360;
    private static final double DEGREE_PER_HOUR = FULL_DEGREE / 12;
    private static final double DEGREE_PER_MINITE_HAND = FULL_DEGREE / 60;
    private static final double DEGREE_PER_MINITE = DEGREE_PER_HOUR / MIN_PER_HOUR;

    public double getAngle(double hour, double minute) {
        double hourDegree = (hour%12) * DEGREE_PER_HOUR;
        double hourOffset = (minute%60) * DEGREE_PER_MINITE;
        hourDegree += hourOffset;

        double miniteDegree = minute * DEGREE_PER_MINITE_HAND;

        return Math.abs(miniteDegree - hourDegree);
    }
}

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

private static final double MIN_PER_HOUR = 60;
    private static final double FULL_DEGREE = 360;
    private static final double DEGREE_PER_HOUR = FULL_DEGREE / 12;
    private static final double DEGREE_PER_MINITE_HAND = FULL_DEGREE / 60;
    private static final double DEGREE_PER_MINITE = DEGREE_PER_HOUR / MIN_PER_HOUR;

    public double getAngle(double hour, double minute) {
        double hourDegree = (hour%12) * DEGREE_PER_HOUR;
        double hourOffset = (minute%60) * DEGREE_PER_MINITE;
        hourDegree += hourOffset;

        double miniteDegree = minute * DEGREE_PER_MINITE_HAND;

        return Math.abs(miniteDegree - hourDegree);
    }

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
private static final double MIN_PER_HOUR = 60;
                     ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: C

#include <array>
#include <cstdio>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
using namespace std;
const int dy[] = { -1, 1, 0, 0 };
const int dx[] = { 0, 0, 1, -1 };

int pack(array<array<int, 3>, 3> const & d) {
    int acc = 0;
    repeat (y, 3) {
        repeat (x, 3) {
            acc = acc * 10 + d[y][x];
        }
    }
    return acc;
}
tuple<array<array<int, 3>, 3>, int, int> unpack(int acc) {
    array<array<int, 3>, 3> d;
    int zy = -1, zx = -1;
    repeat_reverse (y, 3) {
        repeat_reverse (x, 3) {
            d[y][x] = acc % 10;
            acc /= 10;
            if (d[y][x] == 0) {
                zy = y;
                zx = x;
            }
        }
    }
    return make_tuple(d, zy, zx);
}

int main() {
    while (true) {
        // input
        int ch, cv; scanf("%d%d", &ch, &cv);
        if (ch == 0 and cv == 0) break;
        array<array<int, 3>, 3> start, goal;
        repeat (y, 3) repeat (x, 3) scanf("%d", &start[y][x]);
        repeat (y, 3) repeat (x, 3) scanf("%d", &goal[y][x]);
        // solve
        unordered_map<int, int> used;
        priority_queue<pair<int, int> > que;
        used[pack(start)] = 0;
        que.emplace(0, pack(start));
        int pack_goal = pack(goal);
        while (not que.empty()) {
            int c, s; tie(c, s) = que.top(); que.pop();
            c *= -1;
            if (used[s] < c) continue;
            if (s == pack_goal) break;
            array<array<int, 3>, 3> d; int y, x; tie(d, y, x) = unpack(s);
            repeat (i, 4) {
                int nx = x + dx[i];
                int cy = 0;
                if (nx == -1) {
                    nx = 2;
                    cy = -1;
                }
                if (nx == 3) {
                    nx = 0;
                    cy = 1;
                }
                int ny = (y + dy[i] + cy + 3) % 3;
                swap(d[y][x], d[ny][nx]);
                int ns = pack(d);
                swap(d[y][x], d[ny][nx]);
                int nc = c + (i < 2 ? cv : ch);
                if (not used.count(ns) or nc < used[ns]) {
                    used[ns] = nc;
                    que.emplace(- nc, ns);
                }
            }
        }
        // output
        printf("%d\n", used[pack_goal]);
    }
    return 0;
}



Compiler output:
main.c:1:10: fatal error: array: No such file or directory
    1 | #include <array>
      |          ^~~~~~~
compilation terminated.
Language: C++

//Name: Dragon's Cruller
//Level: 3
//Category: 最短経路,探索
//Note:

/**
 * 状態は高々9!通りしかないので、数の並び方を適当にエンコードして状態として使い、ダイクストラで最短経路を求めればよい。
 *
 * オーダーは O(V log V)。
 * ただしVは状態数の総数で、V=9!。
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <cassert>

using namespace std;

typedef long long LL;

array<int,9> field, goal;

LL encode() {
    LL res = 0;
    for(int i = 0; i < 9; ++i) {
        res *= 9;
        res += field[i];
    }
    return res;
}

void decode(LL v) {
    for(int i = 0; i < 9; ++i) {
        field[8-i] = v % 9;
        v /= 9;
    }
}

const int TO[4][9] = {
    {1, 2, 3, 4, 5, 6, 7, 8, 0},
    {8, 0, 1, 2, 3, 4, 5, 6, 7},
    {6, 7, 8, 0, 1, 2, 3, 4, 5},
    {3, 4, 5, 6, 7, 8, 0, 1, 2},
};
bool solve() {
    int CH, CV;
    if(!(cin >> CH >> CV)) return false;
    if(!CH && !CV) return false;

    for(int i = 0; i < 9; ++i) {
        cin >> field[i];
    }
    for(int i = 0; i < 9; ++i) {
        cin >> goal[i];
    }
    LL G = 0;
    {
        array<int,9> tmp = field;
        field = goal;
        G = encode();
        field = tmp;
    }

    unordered_map<LL,int> memo;
    memo[0] = encode();
    priority_queue<pair<int,int>> q;
    q.push(make_pair(0, encode()));
    while(!q.empty()) {
        const int cost = -q.top().first;
        const LL state = q.top().second;
        q.pop();
        if(memo.count(state) && memo[state] < cost) continue;
        if(state == G) {
            cout << cost << endl;
            return true;
        }
        decode(state);

        int zero = 0;
        while(field[zero] != 0) ++zero;

        for(int d = 0; d < 4; ++d) {
            swap(field[zero], field[TO[d][zero]]);
            const int nc = cost + (d < 2 ? CH : CV);
            const int ns = encode();
            swap(field[zero], field[TO[d][zero]]);
            if(memo.count(ns) && memo[ns] <= nc) continue;
            memo[ns] = nc;
            q.push(make_pair(-nc, ns));
        }
    }
    assert(false);
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    while(solve()) ;
    return 0;
}

Compiler output:
a.cc:23:14: error: aggregate 'std::array<int, 9> field' has incomplete type and cannot be defined
   23 | array<int,9> field, goal;
      |              ^~~~~
a.cc:18:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
   17 | #include <cassert>
  +++ |+#include <array>
   18 | 
a.cc:23:21: error: aggregate 'std::array<int, 9> goal' has incomplete type and cannot be defined
   23 | array<int,9> field, goal;
      |                     ^~~~
a.cc:23:21: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
a.cc: In function 'bool solve()':
a.cc:60:22: error: variable 'std::array<int, 9> tmp' has initializer but incomplete type
   60 |         array<int,9> tmp = field;
      |                      ^~~
a.cc:60:22: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
Language: C++

#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int a, b; vector<int> r1, r2;
int solve() {
	if (r1 == r2) return 0;
	map<vector<int>, bool> d; d[r1] = true;
	priority_queue<pair<int, vector<int> > > que; que.push(make_pair(0, r1));
	int w = 0;
	while (true) {
		pair<int, vector<int> > state = que.top(); que.pop();
		int cost = -state.first; vector<int> v = state.second;
		int ptr = find(v.begin(), v.end(), 0) - v.begin();
		if (u == r2) return cost + a;
		for (int i = 1; i <= 8; i += 7) {
			vector<int> u = v;
			swap(u[ptr], u[(ptr + i) % 9]);
			if (!d[u]) {
				d[u] = true;
				que.push(make_pair(-cost - a, u));
			}
		}
		for (int i = ptr % 3; i < 9; i += 3) {
			if (i == ptr) continue;
			vector<int> u = v;
			swap(u[ptr], u[i]);
			if (!d[u]) {
				d[u] = true;
				que.push(make_pair(-cost - b, u));
			}
		}
	}
	return -1;
}
int main() {
	while (cin >> a >> b, a | b) {
		r1 = vector<int>(9);
		for (int i = 0; i < 9; i++) cin >> r1[i];
		r2 = vector<int>(9);
		for (int i = 0; i < 9; i++) cin >> r2[i];
		cout << solve() << endl;
	}
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:17:21: error: 'u' was not declared in this scope
   17 |                 if (u == r2) return cost + a;
      |                     ^
Language: C++

#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int a, b; vector<int> r1, r2;
int solve() {
	if (r1 == r2) return 0;
	map<int, bool> d; d[r1] = true;
	priority_queue<pair<int, vector<int> > > que; que.push(make_pair(0, r1));
	int w = 0;
	while (true) {
		pair<int, vector<int> > state = que.top(); que.pop();
		int cost = -state.first; vector<int> v = state.second;
		int ptr = find(v.begin(), v.end(), 0) - v.begin();
		if (v == r2) return cost + a;
		for (int i = 1; i <= 8; i += 7) {
			vector<int> u = v;
			swap(u[ptr], u[(ptr + i) % 9]);
			int z = 0;
			for (int j = 0; j < 9; j++) z = z * 9 + u[j];
			if (!d[z]) {
				d[z] = true;
				que.push(make_pair(-cost - a, u));
			}
		}
		for (int i = ptr % 3; i < 9; i += 3) {
			if (i == ptr) continue;
			vector<int> u = v;
			swap(u[ptr], u[i]);
			int z = 0;
			for (int j = 0; j < 9; j++) z = z * 9 + u[j];
			if (!d[z]) {
				d[z] = true;
				que.push(make_pair(-cost - b, u));
			}
		}
	}
	return -1;
}
int main() {
	while (cin >> a >> b, a | b) {
		r1 = vector<int>(9);
		for (int i = 0; i < 9; i++) cin >> r1[i];
		r2 = vector<int>(9);
		for (int i = 0; i < 9; i++) cin >> r2[i];
		cout << solve() << endl;
	}
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:10:28: error: no match for 'operator[]' (operand types are 'std::map<int, bool>' and 'std::vector<int>')
   10 |         map<int, bool> d; d[r1] = true;
      |                            ^
In file included from /usr/include/c++/14/map:63,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = bool; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, bool> >; mapped_type = bool; key_type = int]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::map<int, bool>::key_type&' {aka 'const int&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = int; _Tp = bool; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, bool> >; mapped_type = bool; key_type = int]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::map<int, bool>::key_type&&' {aka 'int&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
Language: C++

#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int a, b; vector<int> r1, r2;
int solve() {
	if (r1 == r2) return 0;
	int zzz = 0;
	for (int i = 0; i < 9; i++) zzz = zzz * 9 + r1[i];
	map<int, bool> d; d[convert(r1)] = true;
	priority_queue<pair<int, vector<int> > > que; que.push(make_pair(0, r1));
	int w = 0;
	while (true) {
		pair<int, vector<int> > state = que.top(); que.pop();
		int cost = -state.first; vector<int> v = state.second;
		int ptr = find(v.begin(), v.end(), 0) - v.begin();
		if (v == r2) return cost;
		int zz = 0;
		for (int i = 0; i < 9; i++) zz = zz * 9 + v[i];
		d[zz] = true;
		for (int i = 1; i <= 8; i += 7) {
			vector<int> u = v;
			swap(u[ptr], u[(ptr + i) % 9]);
			int z = 0;
			for (int j = 0; j < 9; j++) z = z * 9 + u[j];
			if (!d[z]) {
				que.push(make_pair(-cost - a, u));
			}
		}
		for (int i = ptr % 3; i < 9; i += 3) {
			if (i == ptr) continue;
			vector<int> u = v;
			swap(u[ptr], u[i]);
			int z = 0;
			for (int j = 0; j < 9; j++) z = z * 9 + u[j];
			if (!d[z]) que.push(make_pair(-cost - b, u));
		}
	}
	return -1;
}
int main() {
	while (cin >> a >> b, a | b) {
		r1 = vector<int>(9);
		for (int i = 0; i < 9; i++) cin >> r1[i];
		r2 = vector<int>(9);
		for (int i = 0; i < 9; i++) cin >> r2[i];
		cout << solve() << endl;
	}
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:12:29: error: 'convert' was not declared in this scope; did you mean 'const'?
   12 |         map<int, bool> d; d[convert(r1)] = true;
      |                             ^~~~~~~
      |                             const
Language: C++

#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

const double pi = acos(-1.0),pStep = 20;
const int maxn = 15;
int N; double W,X[maxn],Y[maxn],Z[maxn];
struct Node
{
	double x,y;
	inline double norm() const { return sqrt(x*x+y*y); }
	inline Node(double _x = 0,double _y = 0):x(_x),y(_y) {}
	friend inline Node operator-(const Node &a,const Node &b) { return Node(a.x-b.x,a.y-b.y); }
	friend inline Node operator+(const Node &a,const Node &b) { return Node(a.x+b.x,a.y+b.y); }
	friend inline Node operator*(double a,const Node &b) { return Node(a*b.x,a*b.y); }
	friend inline Node operator*(const Node &b,double a) { return Node(a*b.x,a*b.y); }
}vec[12],needle[maxn];
vector <Node> cnd;

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

inline void ready()
{
	double alpha = 0;
	for (int i = 0;i < 12;++i)
		alpha += pi/6,vec[i] = Node(cos(alpha),sin(alpha));
}

inline bool in(const Node &P) { return P.x >= 0&&P.x <= 100&&P.y >= 0&&P.y <= 100; }

inline double calc(const Node &P)
{
	double ret = 1e60,d;
	for (int i = 1;i <= N;++i)
	{
		d = (P-needle[i]).norm();
		if (d <= Z[i]) ret = min(d,ret);
		else ret = min(ret,(d*d+Z[i]*Z[i])/(2.0*Z[i]));
	}

	d = P.x; if (d <= W) ret = min(d,ret);
	else ret = min(ret,(d*d+W*W)/(2.0*W));
	d = P.y; if (d <= W) ret = min(d,ret);
	else ret = min(ret,(d*d+W*W)/(2.0*W));
	d = 100-P.x; if (d <= W) ret = min(d,ret);
	else ret = min(ret,(d*d+W*W)/(2.0*W));
	d = 100-P.y; if (d <= W) ret = min(d,ret);
	else ret = min(ret,(d*d+W*W)/(2.0*W));

	return ret;
}

inline double work()
{
	double ans = 0;
	for (auto P:cnd)
	{
		double step = pStep,best; Node now = P,nxt;
		for (int i = 1;i <= 180;++i,step *= 0.9)
		{
			best = calc(now); nxt = now;
			for (int j = 0;j < 12;++j)
			{
				Node v = now+(vec[j]*step);
				if (in(v))
				{
					double res = calc(v);
					if (res > best)
						best = res,nxt = v;
				}
			}
			now = nxt;
		}
		ans = max(ans,calc(now));
	}
	return ans;
}

int main()
{
	//freopen("H.in","r",stdin);
	//freopen("H.out","w",stdout);
	ready();
	while (true)
	{
		N = gi(); W = gi(); if (!N) break; cnd.clear();
		for (int i = 1;i <= N;++i)
		{
			X[i] = gi(),Y[i] = gi(),Z[i] = gi();
			needle[i] = Node(X[i],Y[i]);
			for (int j = 0;j < 12;++j)
			{
				Node v = needle[i]+vec[j];
				if (in(v)) cnd.push_back(v);
			}javascript:void(0)
		}
		cout << fixed << setprecision(7) << work() << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:108:44: error: expected ';' before '}' token
  108 |                         }javascript:void(0)
      |                                            ^
      |                                            ;
  109 |                 }
      |                 ~
Language: C++

#error ""
#include <iostream>
#include <vector>
#include <complex>
#include <cstdio>
#include <utility>
using namespace std;
typedef complex<double>P;
typedef pair<P,P> L;
typedef pair<P,double> C;
const double EPS = (1e-10);

L cpcc(C a, C b){
  double d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.first-a.first)+a.first;
  P n = (a.first-b.first)*P(0,1);
  n /= abs(n);
  return make_pair(m-n*h, m+n*h);
}

int main(){
  int n;
  double w;
  cin >> n >> w;
  vector<P> V;
  vector<double> H;
  for(int i = 0; i < n; ++i){
    double x, y, h;
    cin >> x >> y >> h;
    V.emplace_back(x,y);
    H.emplace_back(h);
  }
  double ok = 0, ng = 1000;
  for(int _ = 0; _ < 100; ++_){
    double r = (ok + ng)/2;
    vector<C> Cs;
    for(int i = 0; i < n; ++i){
      Cs.emplace_back(V[i], sqrt(r*r - max(0.0, r-H[i])*max(0.0, r-H[i])));
    }
    vector<P> cps;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < i; ++j){
        L cp = cpcc(Cs[i], Cs[j]);
        if(abs(Cs[i].first-Cs[j].first) > Cs[i].second+Cs[j].second ||
           abs(Cs[i].first-Cs[j].first) > abs(Cs[i].second-Cs[j].second)) continue;
        cps.push_back(cp.first);
        cps.push_back(cp.second);
      }
    }
    int m = cps.size();
    for(int i = 0; i < m; ++i){
      P p = cps[i];
      bool f = true;
      for(int j = 0; j < n; ++j) f &= max(0.0, r-H[j])*max(0.0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      if(f){
        ok = r;
        break;
      }
    }
    ng = r;
  }
  printf("%.12f\n", ok);
  return 0;
}



Compiler output:
a.cc:1:2: error: #error ""
    1 | #error ""
      |  ^~~~~
Language: C++

#error ""
#include <iostream>
#include <vector>
#include <complex>
#include <cstdio>
#include <utility>
using namespace std;
typedef complex<double>P;
typedef pair<P,P> L;
typedef pair<P,double> C;
const double EPS = (1e-10);

L cpcc(C a, C b){
  double d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.first-a.first)+a.first;
  P n = (a.first-b.first)*P(0,1);
  n /= abs(n);
  return make_pair(m-n*h, m+n*h);
}

int main(){
  int n;
  double w;
  cin >> n >> w;
  vector<P> V;
  vector<double> H;
  for(int i = 0; i < n; ++i){
    double x, y, h;
    cin >> x >> y >> h;
    V.emplace_back(x,y);
    H.emplace_back(h);
  }
  double ok = 0, ng = 1000;
  for(int _ = 0; _ < 100; ++_){
    double r = (ok + ng)/2;
    vector<C> Cs;
    for(int i = 0; i < n; ++i){
      Cs.emplace_back(V[i], sqrt(r*r - max(0.0, r-H[i])*max(0.0, r-H[i])));
    }
    vector<P> cps;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < i; ++j){
        L cp = cpcc(Cs[i], Cs[j]);
        if(abs(Cs[i].first-Cs[j].first) > Cs[i].second+Cs[j].second ||
           abs(Cs[i].first-Cs[j].first) > abs(Cs[i].second-Cs[j].second)) continue;
        cps.push_back(cp.first);
        cps.push_back(cp.second);
      }
    }
    int m = cps.size();
    if(!m){
      ok = r;
      continue;
    }
    for(int i = 0; i < m; ++i){
      P p = cps[i];
      if(max(0.0, r-w) > p.real() ||
         100 - max(0.0, r-w) < p.real() ||
         max(0.0, r-w) > p.imag() ||
         100 - max(0.0, r-w) < p.imag()){
        continue;
      }
      bool f = true;
      for(int j = 0; j < n; ++j) f &= max(0.0, r-H[j])*max(0.0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      if(f){
        ok = r;
        break;
      }
    }
    ng = r;
  }
  printf("%.12f\n", ok);
  return 0;
}



Compiler output:
a.cc:1:2: error: #error ""
    1 | #error ""
      |  ^~~~~
Language: C++

#error ""

#include <iostream>
#include <vector>
#include <complex>
#include <cstdio>
#include <utility>
using namespace std;
typedef complex<double>P;
typedef pair<P,P> L;
typedef pair<P,double> C;
const double EPS = (1e-10);

L cpcc(C a, C b){
  double d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.first-a.first)+a.first;
  P n = (a.first-b.first)*P(0,1);
  n /= abs(n);
  return make_pair(m-n*h, m+n*h);
}

int main(){
  int n;
  double w;
  cin >> n >> w;
  vector<P> V;
  vector<double> H;
  for(int i = 0; i < n; ++i){
    double x, y, h;
    cin >> x >> y >> h;
    V.emplace_back(x,y);
    H.emplace_back(h);
  }
  double ok = 0, ng = 1000;
  for(int _ = 0; _ < 100; ++_){
    double r = (ok + ng)/2;
    vector<C> Cs;
    for(int i = 0; i < n; ++i){
      Cs.emplace_back(V[i], sqrt(r*r - max(0.0, r-H[i])*max(0.0, r-H[i])));
    }
    vector<P> cps;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < i; ++j){
        L cp = cpcc(Cs[i], Cs[j]);
        if(abs(Cs[i].first-Cs[j].first) > Cs[i].second+Cs[j].second ||
           abs(Cs[i].first-Cs[j].first) > abs(Cs[i].second-Cs[j].second)) continue;
        cps.push_back(cp.first);
        cps.push_back(cp.second);
      }
    }
    int m = cps.size();
    if(!m){
      ok = r;
      continue;
    }
    for(int i = 0; i < m; ++i){
      P p = cps[i];
      if(sqrt(r*r - max(0.0, r-w)*max(0.0, r-w)) > p.real() ||
         100 - sqrt(r*r - max(0.0, r-w)*max(0.0, r-w)) < p.real() ||
         sqrt(r*r - max(0.0, r-w)*max(0.0, r-w)) > p.imag() ||
         100 - sqrt(r*r - max(0.0, r-w)*max(0.0, r-w)) < p.imag()){
        continue;
      }
      bool f = true;
      for(int j = 0; j < n; ++j) f &= max(0.0, r-H[j])*max(0.0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      if(f){
        ok = r;
        break;
      }
    }
    if(abs(ok - r) > EPS) ng = r;
  }
  printf("%.12f\n", ok);
  return 0;
}



Compiler output:
a.cc:1:2: error: #error ""
    1 | #error ""
      |  ^~~~~
Language: C++

#tsurai

#include <iostream>
#include <vector>
#include <complex>
#include <cstdio>
#include <utility>
using namespace std;
typedef complex<double>P;
typedef pair<P,P> L;
typedef pair<P,double> C;
const double EPS = (1e-10);

L cpcc(C a, C b){
  double d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.first-a.first)+a.first;
  P n = (a.first-b.first)*P(0,1);
  n /= abs(n);
  return make_pair(m-n*h, m+n*h);
}

int main(){
  int n;
  double w;
  while(cin >> n >> w, n){
    vector<P> V;
    vector<double> H;
    for(int i = 0; i < n; ++i){
      double x, y, h;
      cin >> x >> y >> h;
      V.emplace_back(x,y);
      H.emplace_back(h);
    }
    double ok = 0, ng = 1000;
    for(int _ = 0; _ < 100; ++_){
      double r = (ok + ng)/2;
      vector<C> Cs;
      for(int i = 0; i < n; ++i){
        Cs.emplace_back(V[i], sqrt(r*r - max(0.0, r-H[i])*max(0.0, r-H[i])));
      }
      vector<P> cps;
      for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
          L cp = cpcc(Cs[i], Cs[j]);
          if(abs(Cs[i].first-Cs[j].first) > Cs[i].second+Cs[j].second ||
             abs(Cs[i].first-Cs[j].first) < abs(Cs[i].second-Cs[j].second)) continue;
          cps.push_back(cp.first);
          cps.push_back(cp.second);
        }
      }
      int m = cps.size();
      if(!m){
        ok = r;
        continue;
      }
      for(int i = 0; i < m; ++i){
        P p = cps[i];
        if(sqrt(r*r - max(0.0, r-w)*max(0.0, r-w)) > p.real() ||
           100 - sqrt(r*r - max(0.0, r-w)*max(0.0, r-w)) < p.real() ||
           sqrt(r*r - max(0.0, r-w)*max(0.0, r-w)) > p.imag() ||
           100 - sqrt(r*r - max(0.0, r-w)*max(0.0, r-w)) < p.imag()){
          continue;
        }
        bool f = true;
        for(int j = 0; j < n; ++j) f &= max(0.0, r-H[j])*max(0.0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
        if(f){
          ok = r;
          break;
        }
      }
      if(abs(ok - r) > EPS) ng = r;
    }
    printf("%.12f\n", ok);
  }
  return 0;
}



Compiler output:
a.cc:1:2: error: invalid preprocessing directive #tsurai
    1 | #tsurai
      |  ^~~~~~
Language: Java

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

public class HiddenTree{
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	int max(int a,int b){
		return Math.max(a,b);
	}
	
	String nextToken(){
		while(st==null||!st.hasMoreTokens()){
			try{
				st=new StringTokenizer(br.readLine());
			}catch (Exception e){
				eof=true;
				return null;
			}
		}
		return st.nextToken();
	}
	String nextString(){
		try{
			return br.readLine();
		}catch (IOException e){
			eof=true;
			return null;
		}
	}
	int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	
	HiddenTree() throws IOException{
		br=new BufferedReader(new InputStreamReader(System.in));
		out=new PrintWriter(System.out);
		solve();
		out.close();
	}
	public static void main(String[] args) throws IOException{
		new HiddenTree();
	}
	
	final int inf=1000000;
	int a[]=new int[1010];
	int N;
	
	ArrayList<Integer> vals=new ArrayList<Integer>();
	int dp[][]=new int[1010][257];
	public class edge{
		int to,cost;
		edge(){}
		edge(int a,int b){
			to=a;cost=b;
		}
	};
	int dp2[][]=new int[1010][1010];
	edge G[]=new edge[1010*1010];
	int sz[]=new int[1010];
	int c;
	
	boolean check(int x){
		while(x%2==0) x/=2;
		return x==1;
	}
	int put(int mi){
		int res=0;
		c=0;
		vals=new ArrayList<Integer>();
		for(int i=0;i<N;i++){
			if(a[i]%mi==0&&check(a[i]/mi)) vals.add(a[i]/mi);
		}
		int n=vals.size();
		if(n==0) return 0;
		int m=1;
		while(m*2<=n) m*=2;
		for(int le=0;le<n;le++){
			for(int i=le;i<=n;i++) for(int j=0;j<=256;j++) dp[i][j]=-inf;
			dp[le][0]=0;
			int prev=-1;
			sz[le]=0;
			for(int ri=le;ri<n;ri++){
				for(int j=0;j<256;j++){
					int ac=j&(-j);
					int v=vals.get(ri);
					if(v<=ac||j==0){
						dp[ri+1][j+v]=max(dp[ri+1][j+v],dp[ri][j]+1);
					}
					dp[ri+1][j]=max(dp[ri+1][j],dp[ri][j]);
				}
			}
			for(int j=1;j<=256;j*=2){
				res=max(res,dp[n][j]);
			}
			for(int ri=le+1;ri<=n;ri++){
				if(dp[ri][256]==-inf) continue;
				if(prev<dp[ri][256]){
					prev=dp[ri][256];
					sz[le]++;
					G[c]=new edge(ri,dp[ri][256]);
					c++;
				}
			}
		}
		for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) dp2[i][j]=-inf;
		dp2[0][0]=0;
		int id=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<=m;j++){
				for(int k=0;k<sz[i];k++){
					int to=G[id+k].to;
					int cost=G[id+k].cost;
					dp2[to][j+1]=max(dp2[to][j+1],dp2[i][j]+cost);
				}
				dp2[i+1][j]=max(dp2[i+1][j],dp2[i][j]);
			}
			id+=sz[i];
		}
		for(int i=1;i<=n;i*=2) res=max(res,dp2[n][i]);
		return res;
	}
	int solve_(){
		int res=0;
		for(int i=1;i<=500;i+=2){
			int tmp=put(i);
			res=max(res,tmp);
		}
		return res;
	}
	void solve() throws IOException{
		while(true){
			N=nextInt();
			if(N==0) return;
			for(int i=0;i<N;i++) a[i]=nextInt();
			int ans=solve_();
			out.println(ans);
		}
	}
}

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

#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

const int inf=1e6;

int a[1010];
int N;

vector<int> vals;
int dp[1010][257];

struct edge{
	int to,cost;
	edge(){}
	edge(int a,int b):to(a),cost(b){}
};

//vector<edge> G[1010];
int dp2[1010][1010];
edge G[1010*1010];
int sz[1010];
int c=0;

bool check(int x){
	while(x%2==0) x/=2;
	return x==1;
}

int put(int mi){
	int res=0;
	c=0;
	vals.clear();
	for(int i=0;i<N;i++){
		if(a[i]%mi==0&&check(a[i]/mi)) vals.push_back(a[i]/mi);
	}
	int n=vals.size();
	if(n==0) return 0;
//	for(int i=0;i<n;i++) printf("%d ",vals[i]);
//	printf("\n");
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) dp2[i][j]=0;
	for(int le=0;le<n;le++){
		for(int i=le;i<=n;i++) for(int j=0;j<=256;j++) dp[i][j]=-inf;
		dp[le][0]=0;
		int prev=-1;
		sz[le]=0;
		for(int ri=le;ri<n;ri++){
			for(int j=0;j<256;j++){
			//	if(dp[ri][j]==-inf) continue;
				int ac=j&(-j);
				if(vals[ri]<=ac||j==0){
					dp[ri+1][j+vals[ri]]=max(dp[ri+1][j+vals[ri]],dp[ri][j]+1);
		/*			if(j+vals[ri]==256&&dp[ri+1][256]>prev){
						prev=dp[ri][256];
						sz[le]++;
						G[c++]=edge(ri,dp[ri][256]);
					}*/
				}
				dp[ri+1][j]=max(dp[ri+1][j],dp[ri][j]);
			}
		}
//		for(int j=0;j<=8;j++) printf("%d ",dp[n][j]);
//		printf("\n");
		for(int j=1;j<=256;j*=2){
			res=max(res,dp[n][j]);
		}
	//	G[le].clear();
		int prev=-1;
		sz[le]=0;
		for(int ri=le+1;ri<=n;ri++){
	//		if(dp[ri][256]==-inf) continue;
			if(prev<dp[ri][256]){
			//	G[le].push_back(edge(ri,dp[ri][256]));
				prev=dp[ri][256];
				sz[le]++;
				G[c++]=edge(ri,dp[ri][256]);
			}
		//	if(c>1000*1000) fprintf(stderr,"error:c\n");
		}
	}
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) dp2[i][j]=-inf;
	dp2[0][0]=0;
	int id=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=n;j++){
		//	for(int k=0;k<G[i].size();k++){
			for(int k=0;k<sz[i];k++){
				int to=G[id+k].to,cost=G[id+k].cost;
		//		if(id+k>1000*1000) fprintf(stderr,"error:id\n");
				dp2[to][j+1]=max(dp2[to][j+1],dp2[i][j]+cost);
			}
			dp2[i+1][j]=max(dp2[i+1][j],dp2[i][j]);
		//	id+=sz[i];
		}
		id+=sz[i];
	}
	for(int i=1;i<=n;i*=2) res=max(res,dp2[n][i]);
	return res;
}

int solve(){
	int res=0;
	for(int i=1;i<=500;i+=2){
		int tmp=put(i);
		res=max(res,tmp);
	}
	return res;
}

int main(){
	while(true){
		scanf("%d",&N);
		if(N==0) break;
		for(int i=0;i<N;i++) scanf("%d",a+i);
		int ans=solve();
		printf("%d\n",ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int put(int)':
a.cc:70:21: error: redeclaration of 'int prev'
   70 |                 int prev=-1;
      |                     ^~~~
a.cc:47:21: note: 'int prev' previously declared here
   47 |                 int prev=-1;
      |                     ^~~~
Language: C++

def power_of_2?(n)
  (n & (n - 1)) == 0
end

def max_divisor(n)
  (~n & (n - 1)) + 1
end

def g(sequence)
  table = Hash.new(0)
  table[0] = 0
  sequence.each do |x|
    table.to_a.each do |a, count|
      table[a+x] = [table[a]+1, table[a+x]].max if a % x == 0
    end
  end
  table.select{|a, count| power_of_2? a}.map{|a, count| count}.max
end

def f(sequence)
  best = 0
  numbers = sequence.map{|k| k / max_divisor(k)}.sort.uniq
  numbers.each do |k|
    subsequence = sequence.select{|x| x % k == 0 && power_of_2?(x / k)}
    test = g(subsequence.map{|x| x / k})
    best = [test, best].max
  end
  best
end

loop do
  n = gets.to_i
  break if n == 0
  sequence = gets.split.map!(&:to_i)
  puts f(sequence)
end

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def power_of_2?(n)
      | ^~~
a.cc:17:41: error: expected unqualified-id before '.' token
   17 |   table.select{|a, count| power_of_2? a}.map{|a, count| count}.max
      |                                         ^
a.cc:17:63: error: expected unqualified-id before '.' token
   17 |   table.select{|a, count| power_of_2? a}.map{|a, count| count}.max
      |                                                               ^
a.cc:22:49: error: expected unqualified-id before '.' token
   22 |   numbers = sequence.map{|k| k / max_divisor(k)}.sort.uniq
      |                                                 ^
a.cc:25:5: error: 'test' does not name a type
   25 |     test = g(subsequence.map{|x| x / k})
      |     ^~~~
a.cc:25:40: error: expected unqualified-id before ')' token
   25 |     test = g(subsequence.map{|x| x / k})
      |                                        ^
Language: C++

#include <iostream>
#include <vector>

typedef std::vector<int> vec;

int power_of_2(int n) {
    return (n & (n - 1)) == 0;
}

int max_divisor(int n) {
    return (~n & (n - 1)) + 1;
}

int g(const vec& sequence) {
    int sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        sum += sequence[i];
    }

    vec table(sum + 1);
    std::fill(table.begin(), table.end(), -1);
    table[0] = 0;

    sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        for (int a = sum / x * x; a >= 0; a -= x) {
            if (table[a] >= 0) {
                if (table[a + x] >= 0) {
                    table[a + x] = std::max(table[a] + 1, table[a + x]);
                } else {
                    table[a + x] = table[a] + 1;
                }
            }
        }
        sum += sequence[i];
    }

    int i = 1;
    int max = 0;
    while (i <= sum) {
        max = std::max(max, table[i]);
        i *= 2;
    }

    return max;
}

vec extract(const vec& sequence, int k) {
    vec subsequence;
    int min = 0x7fffffff;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        if (x % k == 0 && power_of_2(x / k)) {
            subsequence.push_back(x);
            if (min > x) {
                min = x;
            }
        }
    }
    for (int i = 0; i < subsequence.size(); i++) {
        subsequence[i] /= min;
    }
    return subsequence;
}

int f(const vec& sequence) {
    vec numbers;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        numbers.push_back(x / max_divisor(x));
    }
    std::sort(numbers.begin(), numbers.end());
    numbers.erase(std::unique(numbers.begin(), numbers.end()), numbers.end());

    int max = 0;
    for (int i = 0; i < numbers.size(); i++) {
        int k = numbers[i];
        const vec& subsequence = extract(sequence, k);
        max = std::max(max, g(subsequence));
    }
    return max;
}

int main() {
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) {
            break;
        }
        vec sequence(n);
        for (int i = 0; i < n; i++) {
            std::cin >> sequence[i];
        }
        std::cout << f(sequence) << std::endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int f(const vec&)':
a.cc:73:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   73 |     std::sort(numbers.begin(), numbers.end());
      |          ^~~~
      |          qsort
a.cc:74:24: error: 'unique' is not a member of 'std'
   74 |     numbers.erase(std::unique(numbers.begin(), numbers.end()), numbers.end());
      |                        ^~~~~~
Language: C++

#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>

typedef std::vector<int> vec;

int power_of_2(int n) {
    return (n & (n - 1)) == 0;
}

int max_divisor(int n) {
    return (~n & (n - 1)) + 1;
}

int g(const vec& sequence) {
    int sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        sum += sequence[i];
    }

    vec table(sum + 1);
    std::fill(table.begin() + 1, table.end(), -1);
    table[0] = 0;

    sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        for (int a = sum & -x; a >= 0; a -= x) {
            if (table[a] >= 0) {
                int b = a + x;
                if (table[b] >= 0) {
                    table[b] = std::max(table[a] + 1, table[b]);
                } else {
                    table[b] = table[a] + 1;
                }
            }
        }
        sum += sequence[i];
    }

    int max = 0;
    for (int i = 1; i <= sum; i <<= 1) {
        max = std::max(max, table[i]);
    }
    return max;
}

vec extract(const vec& sequence, int k) {
    vec subsequence;
    int min = INT_MAX;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        if (x % k == 0 && power_of_2(x / k)) {
            subsequence.push_back(x);
            min = std::min(min, x);
        }
    }
    for (int i = 0; i < subsequence.size(); i++) {
        subsequence[i] /= min;
    }
    return subsequence;
}

int f(const vec& sequence) {
    vec numbers;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        numbers.push_back(x / max_divisor(x));
    }
    std::sort(numbers.begin(), numbers.end());
    numbers.erase(std::unique(numbers.begin(), numbers.end()), numbers.end());

    int max = 0;
    for (int i = 0; i < numbers.size(); i++) {
        int k = numbers[i];
        const vec& subsequence = extract(sequence, k);
        max = std::max(max, g(subsequence));
    }
    return max;
}

int main() {
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) {
            break;
        }
        vec sequence(n);
        for (int i = 0; i < n; i++) {
            std::cin >> sequence[i];
        }
        std::cout << f(sequence) << std::endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'vec extract(const vec&, int)':
a.cc:51:15: error: 'INT_MAX' was not declared in this scope
   51 |     int min = INT_MAX;
      |               ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <vector>
  +++ |+#include <climits>
    5 |
Language: C++

#include<map>
#include<queue>
#include<cmath>
#include<cassert>
#include<vector>
#include<iostream>
using namespace std;

vector<int> bits;
vector<int> after;

void print(vector<int> v){
  for(auto i:v){
    //cerr<<i<<" ";
  }//cerr<<endl;
}

void init(){
  bits.clear();
  after.clear();
}

bool input(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    bits.push_back(tmp);
  }
  for(int i=0;i<m;i++){
    int tmp;
    cin>>tmp;
    after.push_back(tmp);
  }
  return true;
}


int make_ans(vector<int> pre,vector<int> a,vector<int> b){
  queue<pair<int,vector<int>>> q;
  map<vector<int>,int> dp;
  q.push(make_pair(0,pre));
  while(!q.empty()){
    pair<int,vector<int>> now = q.front();q.pop();
    const vector<int> v = now.second;
    const int cost = now.first;
    if(v==a)return cost;
    if(v==b)return cost;
    if(dp.count(v)!=0)continue;
    dp[v]=cost;
    for(int i=0;i+1<v.size();i++){
      vector<int> next= v;
      swap(next[i],next[i+1]);
      q.push(make_pair(cost+1,next));
    }
  }
  return INT_MAX;
}

int solve(){
  vector<int> b;
  bool jj = false;
  for(int i=0;i<after.size();i++){
    for(int j=0;j<after[i];j++){
      b.push_back(jj);
    }
    jj = (!jj);
  }
  print(bits);
  print(b);
  vector<int> a = b;
  for(int i=0;i<b.size();i++){
    a[i] = (!a[i]);
  }
  print(b);
  int ans = make_ans(bits,a,b);
  return ans;
}

int main(){
  init();input();
  cout<<solve()<<endl;
}

Compiler output:
a.cc: In function 'int make_ans(std::vector<int>, std::vector<int>, std::vector<int>)':
a.cc:58:10: error: 'INT_MAX' was not declared in this scope
   58 |   return INT_MAX;
      |          ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<iostream>
  +++ |+#include <climits>
    7 | using namespace std;