criyle/codenet-compile-errors huggingface dataset:
Language: Java

public class Main {

	public static void main(String[] args) {
		solve2440();
	}

	public static void solve2440() {
		Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int p = sc.nextInt();
            int pfst = p;
            int out = 0;
            if(0 == n&&0 == p){
                break;
            }
            int[] s = new int[n];
            int i = 0;
            while(true){
            	if(s[i]>0&p>0) {
		        	s[i]+=1;
		        	p-=1;
		        }
            	else if(s[i]==0&p>0) {
		        	s[i]+=1;
		        	p-=1;
		        }
            	else if(p==0&s[i]==0) {

		        }
            	else if(p==0&s[i]>0) {
		        	p=s[i];
		        	s[i]=0;
		        }

	        	for(int j=0;j<n;j++) {
	        		if(s[j]==pfst) {
	        			System.out.println(j);
	        			pfst = 0;
	        			break;
	        		}
	        	}

		        if(pfst==0) {
		        	break;
		        }
		        i++;
		        if(i==n) {
		        	i=0;
		        }
            }
        }

	}


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

public class Main {

	public static void main(String[] args) {
		solve2440();
	}

	public static void solve2440() {
		Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int p = sc.nextInt();
            int pfst = p;
            int out = 0;
            if(0 == n&&0 == p){
                break;
            }
            int[] s = new int[n];
            int i = 0;
            while(true){
            	if(s[i]>0&p>0) {
		        	s[i]+=1;
		        	p-=1;
		        }
            	else if(s[i]==0&p>0) {
		        	s[i]+=1;
		        	p-=1;
		        }
            	else if(p==0&s[i]==0) {

		        }
            	else if(p==0&s[i]>0) {
		        	p=s[i];
		        	s[i]=0;
		        }

	        	for(int j=0;j<n;j++) {
	        		if(s[j]==pfst) {
	        			System.out.println(j);
	        			pfst = 0;
	        			break;
	        		}
	        	}

		        if(pfst==0) {
		        	break;
		        }
		        i++;
		        if(i==n) {
		        	i=0;
		        }
            }
        }

	}

}


Compiler output:
Main.java:8: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:8: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

public class Main {

	public static void main(String[] args) {
		solve2440();
	}

	public static void solve2440() {
		Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int p = sc.nextInt();
            int pfst = p;
            int out = 0;
            if(0 == n&&0 == p){
                break;
            }
            int[] s = new int[n];
            int i = 0;
            while(true){
            	if((s[i]>0&p>0)||(s[i]==0&p>0) ) {
		        	s[i]+=1;
		        	p-=1;
		        }
            	else if(p==0&s[i]>0) {
		        	p=s[i];
		        	s[i]=0;
		        }
	        	for(int j=0;j<n;j++) {
	        		if(s[j]==pfst) {
	        			System.out.println(j);
	        			pfst = 0;
	        			break;
	        		}
	        	}
		        if(pfst==0) {
		        	break;
		        }
		        i++;
		        if(i==n) {
		        	i=0;
		        }
            }
        }

	}

}


Compiler output:
Main.java:8: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:8: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            int n = sc.nextInt();
            int p = sc.nextInt();
            if(n == 0 && p == 0) break;
            int[] a = new int[n];
            int b = p;
            int k = 0;
            int ans;
            while(true) {
                if(b > 0) {
                    a[k]++;
                    b--;
                } else {
                    b += a[k];
                    a[k] = 0:
                }
                if(a[k] == p) {
                    ans = k;
                    break;
                }
                k = (k+1) % n;
            }
            System.out.println(ans);
        }
    }
}



Compiler output:
Main.java:18: error: ';' expected
                    a[k] = 0:
                            ^
1 error
Language: Java

import java.util.Scanner;

public class AOJ1159 {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			int p = stdIn.nextInt();
			if(n==0&&p==0){
				return;
			}
			int[] te = new int[n];
			int table = p;
			for(int i=0;i<n;i++){
				te[i] = 0;
			}
			int i = 0;
			while(true){
				if(te[i]==p){
					break;
				}
				if(table!=0){
					table--;
					te[i]++;
				}
				else{
					table = te[i];
					te[i] = 0;
				}
				i++;
				if(i==n){
					i = 0;
				}
			}
			System.out.println(i);
		}
	}
}

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

package icpc2009;

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

public class NextMayor {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int kohosha, wan;
		kohosha = scn.nextInt();	//候補者数
		wan = scn.nextInt();	//小石数
		while (kohosha != 0 || wan != 0) {
			int[] temoto = new int[kohosha];
			int turn = 0;
			while(true){
				if(wan == 0){
					wan = temoto[turn];
					temoto[turn] = 0;
				}else{
					temoto[turn]++;
					wan--;
				}
				if(wan == 0){
					boolean eflg = true;
					for(int i = 0; i < kohosha; i++) if(i != turn && temoto[i] != 0){eflg = false; break;}
					if(eflg) break;
				}
				turn = Math.min(turn + 1, (turn + 1) % kohosha);
			}
			System.out.println(turn);
			kohosha = scn.nextInt();
			wan = scn.nextInt();
		}
	}
}

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

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

public class NextMayor {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int kohosha, wan;
		kohosha = scn.nextInt();	//候補者数
		wan = scn.nextInt();	//小石数
		while (kohosha != 0 || wan != 0) {
			int[] temoto = new int[kohosha];
			int turn = 0;
			while(true){
				if(wan == 0){
					wan = temoto[turn];
					temoto[turn] = 0;
				}else{
					temoto[turn]++;
					wan--;
				}
				if(wan == 0){
					boolean eflg = true;
					for(int i = 0; i < kohosha; i++) if(i != turn && temoto[i] != 0){eflg = false; break;}
					if(eflg) break;
				}
				turn = Math.min(turn + 1, (turn + 1) % kohosha);
			}
			System.out.println(turn);
			kohosha = scn.nextInt();
			wan = scn.nextInt();
		}
	}
}

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

import java.util.Scanner;

public class NextMayor {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int kohosha, wan;
		kohosha = scn.nextInt();	//候補者数
		wan = scn.nextInt();	//小石数
		while (kohosha != 0 || wan != 0) {
			int[] temoto = new int[kohosha];
			int turn = 0;
			while(true){
				if(wan == 0){
					wan = temoto[turn];
					temoto[turn] = 0;
				}else{
					temoto[turn]++;
					wan--;
				}
				if(wan == 0){
					boolean eflg = true;
					for(int i = 0; i < kohosha; i++) if(i != turn && temoto[i] != 0){eflg = false; break;}
					if(eflg) break;
				}
				turn = Math.min(turn + 1, (turn + 1) % kohosha);
			}
			System.out.println(turn);
			kohosha = scn.nextInt();
			wan = scn.nextInt();
		}
	}
}

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

#include<stdio.h>
int main(void){
	int n,p;
	int mem[50]={0};
	int num,i,j;

	while(1){
		scanf("%d %d",&n,&p);
		for(i=0;i<n;i++){
				mem[i]=0;
			}
		num=p;
		if(n==0&&p==0){
			break;
		}
		while(1){
			for(i=0;i<n;i++){
				if(num==0&&mem[i]!=p){
					num=mem[i];
					mem[i]=0;
					}
				else{	
					mem[i]++;
					num--;
					if(num==0&&mem[i]==p){
						printf("%d\n",i);
						break;
					}
				}
			}
			if(num==0&&mem[i]==p){
				break;
			}
		}
	}

Compiler output:
main.c: In function 'main':
main.c:35:9: error: expected declaration or statement at end of input
   35 |         }
      |         ^
Language: C

#include <stdio.h>
int main()
{
	int i, j, k, n, p;
	int d[50];

	while(1)
	{
		for ( i = 0; i < 50; i++)
		{		
			d[i] = 0;
		}

		scanf("%d %d", &n, &p);
		if ( n == 0 && p == 0 ) return 0;
		t = p;
		while(1)
		{
			for ( i = 0; i < n; i++)
			{
				if ( p != 0 )
				{
					d[i] += 1;
					p--;
				}
				else if( p == 0 )
				{
					p = d[i];
				}
				if ( p == 0 && d[i] == t) goto owari;
			}
		}
		for( i = 0; i < n; i++)
		{
			if ( d[i] != 0 )
			{
				printf("%d\n",d[i]);
			}
		}
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:16:17: error: 't' undeclared (first use in this function)
   16 |                 t = p;
      |                 ^
main.c:16:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:30:33: error: label 'owari' used but not defined
   30 |                                 if ( p == 0 && d[i] == t) goto owari;
      |                                 ^~
Language: C

#include <stdio.h>

int candid[50] = {0};
int n, p, i, mark;

while(1){
scanf("%d %d",&n,&p);
if(n == 0 && p == 0) break;

mark = p;

for(i =0;i <= 1000000;i++){
 if(p!=0){
  if(candid[i%n] == 0){
   candid[i%n] = p;
   p = 0;
}
else{
  candid[i%n]++;
  p--;
}
}

else{
 if(candid[i%n] != 0){
  p=candid[i%n];
candid[i%n] = 0;
}
}

if(candid[i%n] == mark) break;
}

printf("%d\n",i);
}
return 0;
}

Compiler output:
main.c:6:1: error: expected identifier or '(' before 'while'
    6 | while(1){
      | ^~~~~
main.c:36:1: error: expected identifier or '(' before 'return'
   36 | return 0;
      | ^~~~~~
main.c:37:1: error: expected identifier or '(' before '}' token
   37 | }
      | ^
Language: C

#include<stdio.h>

int game(int n, int p){
	int x[50]={0};    //n??????????£????
	int loop = 0;    //n??????????£?????????????????????????
	int stones = p;   //?????£?????????????????°
	while(1){
		if(loop == n)  //loop???n?????§?????£??????0?????????
			loop = 0;
		if(stones > 0){  //???????????£????????????
			x[loop]++;   //x[loop]???????????????????????¨???
			stones--;    //??????????????????
			if(x[loop] == p)   //x[loop]???????????????p???(??¨???)??????loop?????????
				return loop;
		}
		else if(x[loop] != 0){
				stones = x[loop];
				x[loop] = 0;
		}
		loop++;
	}
}

int main(){
	int n, p;
	scanf("%d %d",&n ,&p);
	while((n!=0)||(p!=0)){ //n=0??????p=0??¨???????????§??°?????????
		printf("%d\n", game(n, p));
		scanf("%d %d",&n ,&p);
	}
	return 0;

Compiler output:
main.c: In function 'main':
main.c:31:9: error: expected declaration or statement at end of input
   31 |         return 0;
      |         ^~~~~~
Language: C

#include<stdio.h>

#define MAX 50  // ????£?????????????????¢??????\??£???????°????????????§??°

int main() {
    
    int n;               // ????£??????°???3 <= n <= 50???
    int p;               // ?°????????????°???2 <= p <= 50???
    int candidate[MAX];  // ???????£????????????£??????????°?????????°
    int wan;             // ?¢???????????°?????????°
    int position;        // ?¢?????????????????£????????????£????????????
   
    for (;;) {
        scanf("%d  %d", &n, &p);  // ????£??????°????°????????????°?????\???
        /* ???????????\??????0?????????????????? */
        if (n == 0 && p == 0){
            break;
        }
    
        position = 0;         /* ??????????¢????0???????????????????????? */
        candidate[i] = {};   /* ??????????????°????°????????????£???????????? */
        wan = p;              /* ??????????¢????????????°????????°??¨?????? */
        
        /* ????????????????????? */
        while (candidate[i] != p) {
            /* ?¢??????????????????\??£???????????° */
            if (wan > 0) {
                candidate[position]++;  // ?°???????1??????????????§???
                wan--;                  // ?¢???????????°???????1?????????
                if (candidate[position] == p) {
                    break;
                }
            }else {  // ?¢??????\??£??????????????°
                wan = candidate[position];  // ?????£??????????????????????¢????????????\???????????§
                candidate[position] = 0;    // ?????????????????£??????????°?????????°???0?????????
            }
            
            position++;  // ?¬????????????????
            /* ???????????????????????§?????£????????????????????¨????????£??????????????§0?????£??\?????? */
            if (position == n)  position = 0;
        }
        /* ?¬?????????? */
        printf("%d\n", position);
    }
    
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:21:19: error: 'i' undeclared (first use in this function)
   21 |         candidate[i] = {};   /* ??????????????°????°????????????£???????????? */
      |                   ^
main.c:21:19: note: each undeclared identifier is reported only once for each function it appears in
main.c:21:24: error: expected expression before '{' token
   21 |         candidate[i] = {};   /* ??????????????°????°????????????£???????????? */
      |                        ^
Language: C

#include <stdio.h>
int main()
{
????int i=0, l,?? p, q, j=0;
????int d[50];
??
????while(1)
????????{
????????????for ( i = 0; i < 50; i++)
????????{
????????????d[i] = 0;
????????}???? 
????????????scanf("%d %d", &l, &p);
????????????if( l == 0 && p == 0 ) break;
????????????q = p;
????????????while(1)
????????{
????????????????????if ( i >= l ) i = 0;
????????????if ( p > 0 )
????????????????{
????????????????????d[i] += 1;
????????????????????p--;
????????????????????if ( d[i] == q && p == 0)
????????????????{
????????????????????break;
????????????????}?? 
????????????????}
????????????else if ( p == 0 )
????????????????{
????????????????????p = d[i];
????????????????????d[i] = 0;
????????????????}
????????????i++;
????????}
????????????printf("%d\n", i);
????????}
????return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:1: error: expected expression before '?' token
    4 | ????int i=0, l,?? p, q, j=0;
      | ^
main.c:5:1: error: expected expression before '?' token
    5 | ????int d[50];
      | ^
main.c:6:1: error: expected expression before '?' token
    6 | ??
      | ^
Language: C

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int i,j,c;
	int a[50];
	int n,p;
	
	while(1)
	{
		scanf("%d %d",&n,&p);
		scanf("%d",&p);
		if(n == 0 && p == 0)break;
	
		for(i=0;i<n;i++){
		  a[i] = 0;
		}
	
		i = 0;
		while(1){
			while(1){
				a[i++] += 1;
				if(i==n)i -= n;
				p--;
				if(p==0){break;}
			}
			
			c = 0;
			for(j=0;j<n;j++)
			{
				if(a[j] != 0){
	  			c++;
	  			if(c==2)braek;
	  		}
			}
			if(c == 1){
				if(i==0)i=n;
				printf("%d\n",i-1);
				break;
			}
		
			while(a[i]==0){
				i++;
				if(i==n){
			  i = 0;}
			}

			p = a[i];
			a[i++] = 0;
			if(i==n)i = 0;

		}
	
	}
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:34:41: error: 'braek' undeclared (first use in this function)
   34 |                                 if(c==2)braek;
      |                                         ^~~~~
main.c:34:41: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
main(){
    int s[100],p,n,t;
    int i,j,sum;

    while(1){
	scanf("%d %d",&n,&p);
	if(n==0&&p==0){
            break;
        }
        t=p;

	for (int i = 0; i < 100; i++)
            s[i] = 0;
        for(i=0;;i++){
            if(p==0){
        	p=s[i%n];
        	s[i%n]=0;
            }else{
                s[i%n]++;
        	p--;
        	if(p==0&&s[i%n]==t){
                    break;
        	}
            }
        }
        printf("%d\n",i%n);
        s[i%n]=0;
    }
    return 0;
}

Compiler output:
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
    2 | main(){
      | ^~~~
Language: C++

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);

		while(true){
			int n=sc.nextInt();
			int p=sc.nextInt();
			if(n==0) break;

			int i=0;
			int[] a=new int[n];
			while(true){
				if(p>0){ p--; a[i]++; }
				else{ p+=a[i]; a[i]=0; }

				if(p==0){
					boolean end=true;
					for(int j=0;j<n;j++) if(i!=j && a[j]!=0) end=false;
					if(end) break;
				}

				i=(i+1)%n;
			}
			System.out.println(i);
		}

		return;
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

#! /usr/bin/env python
# -*- coding: utf-8 -*-
import copy

(n, p) = map(int, raw_input().split())
while n!=0 and p!=0:
    bawl = copy.copy(p)
    peb = [0]*n
    for i in range(1000000):
        if bawl > 0:
            bawl -= 1
            peb[i%n] += 1
        else:
            bawl += peb[i%n]
            peb[i%n] = 0

        if bawl == p:
            print i%n
            break
    (n, p) = map(int, raw_input().split())

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #! /usr/bin/env python
      |  ^
a.cc:2:3: error: invalid preprocessing directive #-
    2 | # -*- coding: utf-8 -*-
      |   ^
a.cc:3:1: error: 'import' does not name a type
    3 | import copy
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include<stdio.h>
#include<iostream>
using namespace std;

intmain(){

int N,M;
int n[51]={};
int i=0,p=0;
while(1){
scanf("%d %d",&N,&M);
if(N==0&&M==0)break;
p=M;i=0;
while(n[i]!=M)
{
if(p==0&&n[i]>0){p=n[i];n[i]=0;}
//else if(p==0&&n[i]==0)
else if(p>0){p--;n[i]++;}
i++;
if(i==N-1)i=0;
}
cout<<i<<endl;
}
return 0;
}

Compiler output:
a.cc:5:1: error: ISO C++ forbids declaration of 'intmain' with no type [-fpermissive]
    5 | intmain(){
      | ^~~~~~~
Language: C++

#include <iostream>
//#include <algorithm>
//#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
//#include <cmath>
//#include <string>
//#include <sstream>
//#include <iomanip>
//#include <complex>
using namespace std;
 
//#define ll long long
//#define vvi vector< vector<int> >
//#define All(X) X.begin(),X.end()
//#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
//#define pb push_back 
//ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  while(1){
    int n, p;
    cin >> n >> p;
    if(n==0&&p==0) break;
    int kago=p;
    int pc[n-1];
    int i;
    while(1){
      int k=i%(n-1);
      if(pc[k]==p){
	cout << k << lend;
	break;}
      if(kago>0){
	kago--;
	pc[k]++;}
      else{
	kago=pc[k];
	pc[k]=0;}
      i++;}
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:22: error: 'lend' was not declared in this scope
   34 |         cout << k << lend;
      |                      ^~~~
Language: C++

#include <iostream>
using namespace std;

void main() {
	int n, p;

	while (1) {
		int flag = 0;
		int player[50] = { 0 };
		cin >> n >> p;
		if (n == 0 && p == 0) break;
		int p_max = p;

		while (1)
		{
			for (int j = 0; j < n; j++) {
				if (p != 0) player[j] += 1, p--;
				else p = player[j], player[j] = 0;
				if (player[j] == p_max) {
					flag = -1;
					cout << j << endl;
					break;
				}
			}
			if (flag == -1) break;
		}
	}
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | void main() {
      | ^~~~
Language: C++

#include <iostream>
using namespace std;

void main() {
	int n, p;

	while (1) {
		int flag = 0;
		int player[50] = { 0 };
		cin >> n >> p;
		if (n == 0 && p == 0) break;
		int p_max = p;

		while (1)
		{
			for (int j = 0; j < n; j++) {
				if (p != 0) player[j] += 1, p--;
				else p = player[j], player[j] = 0;
				if (player[j] == p_max) {
					flag = -1;
					cout << j;
					break;
				}
			}
			if (flag == -1) break;
		}
	}
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | void main() {
      | ^~~~
Language: C++

#include <iostream>
using namespace std;

void main() {
	int n, p;

	while (1) {
		int flag = 0;
		int player[50] = { 0 };
		cin >> n >> p;
		if (n == 0 && p == 0) break;
		int p_max = p;

		while (1) {
			for (int j = 0; j < n; j++) {
				if (p != 0) player[j] += 1, p--;
				else p = player[j], player[j] = 0;
				if (player[j] == p_max) {
					flag = -1;
					cout << j << endl;
					break;
				}
			}
			if (flag == -1) break;
		}
	}
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | void main() {
      | ^~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
  int n,p;
  for(;;){
    cin >>n >> p;
    if(n == 0 && p == 0)break;
    int human[n];
    for(int i = 0;i < n;i++){
      human=0;
    }
    int stone = p;
    int turn = 0;
    for(;;){
      if(!stone){
        stone += human[turn];
        human[turn] = 0;

      } else if(stone > 0){
        stone--;
        human[turn]++;
        if(!stone && human[turn] == p){
          cout << turn << endl;
          break;
        }
      }

      turn++;
      if(turn >= n) turn = 0;
    }

  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: incompatible types in assignment of 'int' to 'int [n]'
   10 |       human=0;
      |       ~~~~~^~
Language: C++

#include <iostream>
using namespace std;

int main(void){
  while(1){
    int stone[50];
    for(int k = 0 ; k < 50 ; k++){stone[k] = 0;}

    int bowl;
    int n, p;  // n：候補者人数，p：小石の総数
    cin >> n;
    cin >> p;

    if(n == 0 && p == 0){return 0;}

    bowl = p;

    bool flg = true;
    int ans;

    for(int i = 0 ; flg ; i = (i+1) % n){

      if(bowl == 0){
        bowl = bowl + stone[i];
        stone[i] = 0;
      }else{
        stone[i]++;
        bowl--;
        if(bowl == 0 && stone[i] == p){ans = i; flg = false;}
      }
    }
    cout << ans << endl;
  }
}

あっはっは



Compiler output:
a.cc:36:1: error: '\U00003042\U00003063\U0000306f\U00003063\U0000306f' does not name a type
   36 | あっはっは
      | ^~~~~~~~~~
Language: C++

//YukiOtake-2018/03/04
//time:12:11
import java.util.Scanner;
class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(true){
      int n=scan.nextInt();
      int p=scan.nextInt();
      // int n=3,p=2;
      if(n==0 && p==0){
        break;
      }
      int[] data=new int[n];
      int i=0,temp=p;
      while(true){
        if(i==n){
          i=0;
        }
        if(temp>0){
          temp--;
          data[i]++;
        }
        else{
          temp=data[i];
          data[i]=0;
        }
        if(data[i]==p){
          break;
        }
        i++;        
      }
      System.out.println(i);
		}
	}
}



Compiler output:
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:15: error: expected ':' before 'static'
    5 |         public static void main(String args[]){
      |               ^~~~~~~
      |               :
a.cc:5:33: error: 'String' has not been declared
    5 |         public static void main(String args[]){
      |                                 ^~~~~~
a.cc:36:2: error: expected ';' after class definition
   36 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:6:17: error: 'Scanner' was not declared in this scope
    6 |                 Scanner scan = new Scanner(System.in);
      |                 ^~~~~~~
a.cc:8:13: error: 'scan' was not declared in this scope
    8 |       int n=scan.nextInt();
      |             ^~~~
a.cc:14:10: error: structured binding declaration cannot have type 'int'
   14 |       int[] data=new int[n];
      |          ^~
a.cc:14:10: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:14:10: error: empty structured binding declaration
a.cc:14:13: error: expected initializer before 'data'
   14 |       int[] data=new int[n];
      |             ^~~~
a.cc:22:11: error: 'data' was not declared in this scope
   22 |           data[i]++;
      |           ^~~~
a.cc:25:16: error: 'data' was not declared in this scope
   25 |           temp=data[i];
      |                ^~~~
a.cc:28:12: error: 'data' was not declared in this scope
   28 |         if(data[i]==p){
      |            ^~~~
a.cc:33:7: error: 'System' was not declared in this scope
   33 |       System.out.println(i);
      |       ^~~~~~
Language: C++

#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n, p, all;
  vector<int> r;
  while (cin >> n >> p && n && p) {
    bool flag = false;
    all = p;
    map<int, int> m;
    rep(i, n) m[i] = 0;
    while (!flag) {
      // cout << n << ' ' << p << endl;
      rep(i, m.size()) {
        if (p > 0) {
          p--;
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n, p, all;
  vector<int> r;
  while (cin >> n >> p && n && p) {
    bool flag = false;
    all = p;
    map<int, int> m;
    rep(i, n) m[i] = 0;
    while (!flag) {
      // cout << n << ' ' << p << endl;
      rep(i, m.size()) {
        if (p > 0) {
          p--;
          m[i]++;
        } else {
          p += m[i];
          m[i] = 0;
        }
      }
      rep(i, m.size()) {
        if (m[i] == all) {
          r.push_back(i);
          flag = true;
        }
      }
    }
  }
  rep(i, r.size()) { cout << r[i] << endl; }
  return 0;
}
          m[i]++;
        } else {
          p += m[i];
          m[i] = 0;
        }
      }
      rep(i, m.size()) {
        if (m[i] == all) {
          r.push_back(i);
          flag = true;
        }
      }
    }
  }
  for (auto i : r) {
    cout << i << endl;
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   26 | int main() {
      |         ^~
a.cc:26:9: note: remove parentheses to default-initialize a variable
   26 | int main() {
      |         ^~
      |         --
a.cc:26:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:26:12: error: a function-definition is not allowed here before '{' token
   26 | int main() {
      |            ^
Language: C++

import numpy as np

while True:
    try:
        l = list(map(int, input().split()))
        S = l[0]
        p = np.zeros(S)
        M = l[1]
        i = 0
        N = M

        while True:
            if N == M and i != 0:
                ans = i % S - 1
                if ans < 0:
                    ans = S + ans
                print(ans)
                break

            if N == 0:
                N = p[i % S]
                p[i % S] = 0
                i += 1

            else:
                N -= 1
                p[i % S] += 1
                i += 1

    except:
        break


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
using namespace std;

int main()
}
	int n,p;
	while(cin >> n >> p, n||p)
	{
		int s=p;
		int snum[64] = {0};

		for(int i=0; true; i=(i+1)%n)
		{
			if(s)
			{
				snum[i]++;
				if(snum[i]==p)
				{
					cout << i << endl;
					break;
				}
			}
			else
			{
				s=snum[i];
				snum[i]=0;
			}
		}
		
	}
}

Compiler output:
a.cc:5:1: error: expected initializer before '}' token
    5 | }
      | ^
a.cc:5:1: error: expected declaration before '}' token
a.cc:7:9: error: expected unqualified-id before 'while'
    7 |         while(cin >> n >> p, n||p)
      |         ^~~~~
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

#include<iostream>
using namespace std;

int main(){
int n,p;
int c[50];
for(;;){
cin >> n >> p;
if(!n && !p)break;
for(int i=0;i<n;i++)c[i] = 0;

int pos = -1;
for(;;){
pos = (pos+1)%n;
if(p){
c[pos]++;
p--;
}else{
p = c[pos];
c[pos] = 0;
}
if(!P){
int cnt = 0;
for(int i=0;i<n;i++)
if(c[i])cnt++;
if(cnt==1)break;
}
}
cout << pos << endl;
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'P' was not declared in this scope
   22 | if(!P){
      |     ^
Language: C++

#include<cstdio>
using namespace std;

int main(){
int n,p;
int c[50];
for(;;){
scanf("%d,%d",&n,&p);
if(!n && !p)break;
for(int i=0;i<n;i++)c[i] = 0;

int cnt = 0;
int pos = -1;
for(;;){
pos = (pos+1)%n;
if(p){
if(!c[pos])cnt++;
c[pos]++;
p--;
}else{
if(c[pos])cnt--;
p = c[pos];
c[pos] = 0;
}
if(!p && cntt==1)break;
}
printf("%d\n",pos);
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:10: error: 'cntt' was not declared in this scope; did you mean 'cnt'?
   25 | if(!p && cntt==1)break;
      |          ^~~~
      |          cnt
Language: C++

import java.util.*;
public class Main {
	int[] N;
	int n,p;
	Main(){
		n=-1;p=-1;
	}
		void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			n=sc.nextInt();
			p=sc.nextInt();
			if(n==0&&p==0)break;
			N=new int[n];
			System.out.println(solve(0,p));
		}
	}
		int solve(int current,int remains){
			while(true){
				if(remains==1&&N[current]+1==p)return current;
				if(remains==0){
					remains=N[current]+1;
					N[current]=0;
				}
				else{
					N[current]+=1;
				}
				current=(current+1)%n;
				remains=remains-1;
				for(int i=0;i<n;i++){
				}
			}
		}
	public static void main(String[] args) {
		new Main().run();
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
    2 | public class Main {
      | ^~~~~~
Language: C++

include<iostream>
#include<cstring>
using namespace std;

int main()
{
  int n,p;

  for(;cin>>n>>p,n||p;)
    {
      int count[n];
      memset(count,0,sizeof(count));
      int pp=p;
      for(int i=0;;i++)
	{
	  if(i>=n)
	    i=0;
	  if(pp!=0)
	    {
	      count[i]++;
	      pp--;
	    }
	  else
	    {
	      pp=count[i];
	      count[i]=0;
	    }
	  if(count[i]==p)
	    {
	      cout<<i<<endl;
	      break;
	    }
	}
      
    }
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:9:8: error: 'cin' was not declared in this scope
    9 |   for(;cin>>n>>p,n||p;)
      |        ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<cstring>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:30:15: error: 'cout' was not declared in this scope
   30 |               cout<<i<<endl;
      |               ^~~~
a.cc:30:15: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:24: error: 'endl' was not declared in this scope
   30 |               cout<<i<<endl;
      |                        ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<cstring>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: Java

import java.util.Scanner;

public class AC1 {

	static int a,b;
	static int[][] field;

	public static void main(String args[]){

		Scanner s=new Scanner(System.in);

		while(true){
			b=s.nextInt();
			a=s.nextInt();
			if(a==0)System.exit(0);

			field = new int[a][b];

			for(int i=0; i<a; i++) {
				for(int j=0; j<b; j++) {
					field[i][j] = s.nextInt();
				}
			}
			int count =0;
			for(int i=0; i<a; i++) {
				for(int j=0; j<b; j++) {
					if(field[i][j]==1) {
						count++;
						check(i,j);
					}
				}
			}

			System.out.println(count);
		}
	}

	static void check ( int x, int y) {

		field[x][y] = 0;

		if(x>0) {
			if(field[x-1][y]==1) check(x-1,y);
			if(y>0)if(field[x-1][y-1]==1)check(x-1,y-1);
			if(y<b-1)if(field[x-1][y+1]==1)check(x-1,y+1);
		}

		if(x<a-1) {
			if(field[x+1][y]==1) check(x+1,y);
			if(y>0)if(field[x+1][y-1]==1)check(x+1,y-1);
			if(y<b-1)if(field[x+1][y+1]==1)check(x+1,y+1);
		}
		if(y>0) if(field[x][y-1]==1) check(x-1,y);
		if(y<b-1) if(field[x][y+1]==1) check(x-1,y);

	}

}



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

import java.util.Scanner;

public class AC1 {

	static int a,b;
	static int[][] field;

	public static void main(String args[]){

		Scanner s=new Scanner(System.in);

		while(true){
			b=s.nextInt();
			a=s.nextInt();
			if(a==0)System.exit(0);

			field = new int[a][b];

			for(int i=0; i<a; i++) {
				for(int j=0; j<b; j++) {
					field[i][j] = s.nextInt();
				}
			}
			int count =0;
			for(int i=0; i<a; i++) {
				for(int j=0; j<b; j++) {
					if(field[i][j]==1) {
						count++;
						check(i,j);
					}
				}
			}

			System.out.println(count);
		}
	}

	static void check ( int x, int y) {

		field[x][y] = 0;

		if(x>0) {
			if(field[x-1][y]==1) check(x-1,y);
			if(y>0)if(field[x-1][y-1]==1)check(x-1,y-1);
			if(y<b-1)if(field[x-1][y+1]==1)check(x-1,y+1);
		}

		if(x<a-1) {
			if(field[x+1][y]==1) check(x+1,y);
			if(y>0)if(field[x+1][y-1]==1)check(x+1,y-1);
			if(y<b-1)if(field[x+1][y+1]==1)check(x+1,y+1);
		}
		if(y>0) if(field[x][y-1]==1) check(x-1,y);
		if(y<b-1) if(field[x][y+1]==1) check(x-1,y);

    return;
	}

}



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

import java.util.Scanner;

public class AC1 {

	static int a,b;
	static int[][] field;

	public static void main(String args[]){

		Scanner s=new Scanner(System.in);

		while(true){
			b=s.nextInt();
			a=s.nextInt();
			if(a==0)System.exit(0);

			field = new int[a][b];

			for(int i=0; i<a; i++) {
				for(int j=0; j<b; j++) {
					field[i][j] = s.nextInt();
				}
			}
			int count =0;
			for(int i=0; i<a; i++) {
				for(int j=0; j<b; j++) {
					if(field[i][j]==1) {
						count++;
						check(i,j);
					}
				}
			}

			System.out.println(count);
		}
	}

	static void check ( int x, int y) {

		field[x][y] = 0;

		if(x>0) {
			if(field[x-1][y]==1) check(x-1,y);
			if(y>0)if(field[x-1][y-1]==1)check(x-1,y-1);
			if(y<b-1)if(field[x-1][y+1]==1)check(x-1,y+1);
		}

		if(x<a-1) {
			if(field[x+1][y]==1) check(x+1,y);
			if(y>0)if(field[x+1][y-1]==1)check(x+1,y-1);
			if(y<b-1)if(field[x+1][y+1]==1)check(x+1,y+1);
		}
		if(y>0) if(field[x][y-1]==1) check(x,y-1);
		if(y<b-1) if(field[x][y+1]==1) check(x,y+1);

    return;
	}

}



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

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Created by YuyaKita on 2015/05/18.
 */
public class Main {
    static final int MAX_W = 50, MAX_H = 50;
    static int W, H;
    static int[][] world = new int[MAX_H + 1][MAX_W + 1];
    static int count = 0;
    static int[] dx = {-1, 0, 1, 0};
    static int[] dy = {0, -1, 0, 1};

    public static void main(String args[]) throws FileNotFoundException {

        Scanner sc = new Scanner(new File(System.in));
        while (true) {
            W = sc.nextInt();
            H = sc.nextInt();
            if (W == 0 && H == 0){

                break;
            }
            for (int i = 0; i < H; i++) {
                for(int j = 0;j<W;j++){
                    world[i][j] = sc.nextInt();
                }
            }

            System.out.println(solve(world));
        }

    }

    static int solve(int[][] input) {
        int res = 0;
        for (int i = 0; i < W; i++) {
            for (int j = 0; j < H; j++) {
                if (world[j][i] == 1){
                    dfs(i, j);
                    res++;
                }
            }
        }
        return res;
    }

    static void dfs(int x, int y) {
        count++;
        world[y][x] = 0;
        for (int dx = -1; dx <= 1; dx++) {
            for(int dy=-1; dy<=1;dy++){
            int nx = x + dx;
            int ny = y + dy;
                if (nx >= 0 && nx < W && ny >= 0 && ny < H && world[ny][nx] == 1) {
                    dfs(nx, ny);
                }
            }

        }

    }
}

Compiler output:
Main.java:18: error: no suitable constructor found for File(InputStream)
        Scanner sc = new Scanner(new File(System.in));
                                 ^
    constructor File.File(String) is not applicable
      (argument mismatch; InputStream cannot be converted to String)
    constructor File.File(URI) is not applicable
      (argument mismatch; InputStream cannot be converted to URI)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: Java

import java.util.Scanner;

public class HowManyIslands {
	public static void main(String args[]) {
		Scanner scr = new Scanner(System.in);
		while (true) {
			String[] ss = scr.nextLine().split(" ", 0);
			stage_size = new int[2];
			stage_size[0] = Integer.parseInt(ss[0]);
			stage_size[1] = Integer.parseInt(ss[1]);
			if (stage_size[0] == 0)
				break;
			stage = new int[stage_size[0]][stage_size[1]];
			visited = new boolean[stage_size[0]][stage_size[1]];
			for (int y = 0; y < stage_size[1]; y++) {
				String[] data = scr.nextLine().split(" ", 0);
				for (int x = 0; x < data.length; x++) {
					stage[x][y] = Integer.parseInt(data[x]);
					visited[x][y] = false;
				}
			}
			System.out.println(Islands());
		}
		scr.close();
	}

	static int[] stage_size;
	static int[][] stage;
	static boolean[][] visited;

	private static int Islands() {
		int islands = 0;
		for (int x = 0; x < stage.length; x++) {
			for (int y = 0; y < stage[x].length; y++) {
				if (visited[x][y] || stage[x][y] == 0)
					continue;
				else {
					Visit(x, y);
					islands++;
				}
			}
		}
		return islands;
	}

	private static void Visit(int x, int y) {
		if (x >= stage.length || y >= stage[0].length || x < 0 || y < 0 || stage[x][y] == 0 ||visited[x][y])
			return;
		if (stage[x][y] == 1) {
			visited[x][y] = true;
			Visit(x + 1, y);
			Visit(x, y + 1);
			Visit(x + 1, y + 1);
			Visit(x + 1, y - 1);
			Visit(x - 1, y);
			Visit(x, y - 1);
			Visit(x - 1, y + 1);
			Visit(x - 1, y - 1);
		}
	}
}

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

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


class Main{
  public static void main(String[] args)throws IOException{
	 int w,h;//size of map
	 int x=0,y=0;//temp
   	 int c=0;
   	 int map[][]=new int[50][50];//map[???][?¨?]
   	 System.out.println("tett");
	  while(true){		  
		  c=0;
    	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	 String str = br.readLine();
    	 
    	 String[] a=str.split(" ");
    	 w=Integer.parseInt(a[0]);
    	 h=Integer.parseInt(a[1]);
    	 if(w==0&&h==0){
    		 break;
    	 }
    	 
    	 //??????????????\????????????
    	 for(int i=0;i<h;i++){
    		 str=br.readLine();
    		 a=str.split(" ");
    		 for(int j=0;j<w;j++){
    			 map[i][j]=Integer.parseInt(a[j]);
    		 }
    	 }
    	 //??°??????
    	 for(int i=0;i<h;i++){
    		 for(int j=0;j<w;j++){
    			 if(map[i][j]==1){
    				 c++;
    				 System.out.println(i+","+j);
    				 count(map,i,j);
    			 }
    		 	
    		 	
    		 }
    	 }
    	 System.out.println(c);
     }      
   return 0;
  }
  static void count(int map[][],int x,int y){
	  if(x<0||y<0){
		  return;
	  }else if(map[x][y]==0){
		  return;
	  }
	  else if(map[x][y]==1){
		  map[x][y]=0;
		  count(map,x+1,y+1);
		  count(map,x+1,y);
		  count(map,x,y+1);
		  count(map,x-1,y-1);
		  count(map,x-1,y);
		  count(map,x,y-1);
		  count(map,x-1,y+1);
		  count(map,x+1,y-1);
	  }
	  
  }
}

Compiler output:
Main.java:47: error: incompatible types: unexpected return value
   return 0;
          ^
1 error
Language: Java

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

public class HMIs{
 public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  ArrayList<Integer> N_island = new ArrayList<Integer>();
  int[][] mesh = new int[52][52];
  int w,h;
  for(int i=0;i<52;i++){
   for(int j=0;j<52;j++){
   mesh[i][j]=0;
   }
  }
  int N_data=0;
  do{
  w=sc.nextInt();
  h=sc.nextInt();
  int count=0;
  int prev_Dcount=0;
  for(int i=1;i<h+1;i++){
   for(int j=1;j<w+1;j++){
   mesh[i][j]=sc.nextInt();
   }
  }
  for(int i=1;i<h+1;i++){
   for(int j=1;j<w+1;j++){
   if(mesh[i][j]==1){
    count++;
   if(mesh[i-1][j-1]==1||mesh[i-1][j]==1||mesh[j-1][j+1]==1||mesh[i][j-1]==1)
    prev_Dcount++;
     }
     }
   }
  N_island.add(N_data,count-prev_Dcount);
  N_data++;
  }while(w!=0||h!=0);

  for(int m=0;m<N_data-1;m++){
  System.out.println(N_island.get(m));
  }
 }
}

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

import java.util.*;

public class Aoj1160 {
	static int before, w, h;
	static int[][] dir = {{-1,0}, {-1,-1}, {0,-1}, {1,-1}, {1,0}, {1,1}, {0, 1}, {-1,1}};
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0){
				break;
			}
			int[][] c = new int[h][w];
			for(int i = 0; i < h; i++){/* ???????????? */
				for(int j = 0; j < w; j++){
					c[i][j] = sc.nextInt();
				}
			}
			
			int count = 0;
			for(int i = 0; i < h; i++){/* ?????¨????????§?????¢?´¢????§? */
				for(int j = 0; j < w; j++){
					before = 4;
					int z = search(c, i, j);/* ?????° */
					if(z == 1){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
	
	public static int search(int[][] c, int i, int j){
		if(c[i][j] == 0){
			return 0;
		}
		c[i][j] = 0;
		
		int d = before + 4/* ????????°????????????????????´???????§???? */;
		if(d > 7){
			d -= 8;
		}
		
		for(int k = 0; k < 7; k++){
			d++;
			if(d > 7){
				d -= 8;
			}
			
			before = d;
			int x = i + dir[d][0], y = j + dir[d][1];
			if((x >= 0) && (x < h) && (y >= 0) && (y < w)){
				int z = search(c, x, y);
			}
		}		
		return 1;
	}
}

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

import java.util.*;

public class main {
	static int before, w, h;
	static int[][] dir = {{-1,0}, {-1,-1}, {0,-1}, {1,-1}, {1,0}, {1,1}, {0, 1}, {-1,1}};
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0){
				break;
			}
			int[][] c = new int[h][w];
			for(int i = 0; i < h; i++){/* ???????????? */
				for(int j = 0; j < w; j++){
					c[i][j] = sc.nextInt();
				}
			}
			
			int count = 0;
			for(int i = 0; i < h; i++){/* ?????¨????????§?????¢?´¢????§? */
				for(int j = 0; j < w; j++){
					before = 4;
					int z = search(c, i, j);/* ?????° */
					if(z == 1){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
	
	public static int search(int[][] c, int i, int j){
		if(c[i][j] == 0){
			return 0;
		}
		c[i][j] = 0;
		
		int d = before + 4/* ????????°????????????????????´???????§???? */;
		if(d > 7){
			d -= 8;
		}
		
		for(int k = 0; k < 7; k++){
			d++;
			if(d > 7){
				d -= 8;
			}
			
			before = d;
			int x = i + dir[d][0], y = j + dir[d][1];
			if((x >= 0) && (x < h) && (y >= 0) && (y < w)){
				int z = search(c, x, y);
			}
		}		
		return 1;
	}
}

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

import java.util.Scanner;
import java.util.Stack;
import java.util.ArrayDeque;

public class j3{
    public static void main(String[] aaa){
        Scanner s = new Scanner(System.in);
        Stack<Integer> x =new Stack <Integer>();
        Stack<Integer> y =new Stack <Integer>();
        int h,w,i,j,k,l,count=0,xx,yy,nx,ny;
        int[][] memo = new int[51][51];
        while(true){
        h = s.nextInt();
        w = s.nextInt();
        if(h==0&&w==0)break;
        for(i=1;i<=w;i++){
            for(j=1;j<=h;j++){
                memo[i][j] = s.nextInt();
            }
        }
        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++){
                if(memo[i][j]==1){
                   // System.out.println("b"+(i)+" "+(j));
                    memo[i][j]=0;
                    x.push(i);
                    y.push(j);
                    //System.out.println("now"+now.x+" "+now.y);
                    while(x.size()>0&&y.size()>0){
                        nx=x.pop();
                        ny=y.pop();
                        
                        //System.out.println("a"+now.x+" "+now.y);
                        for(k=-1;k<=1;k++){
                            for(l=-1;l<=1;l++){
                                //if(nx==1)System.out.println("c"+(nx+k)+" "+(ny+l));
                                if((nx+k)>=1&&(nx+k)<=h&&(ny+l)>=1&&(ny+l)<=w&&memo[nx+k][ny+l]==1){
                                    memo[nx+k][ny+l]=0;
                                    x.push(nx+k);
                                    y.push(ny+l);
                                    //System.out.println("a"+(nx+k)+" "+(ny+l));
                                    //System.out.println(x.size()+" "+y.size());
                                }
                            }
                        }
                    }
                    count++;
                }
            }
        }
        System.out.println(count);
        count =0;
        for(i=1;i<=50;i++)for(j=1;j<=50;j++)memo[i][j]=0;
    }
    }
    System.out.println();
}


Compiler output:
Main.java:56: error: <identifier> expected
    System.out.println();
                      ^
1 error