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

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
int main() {
	string s;
	while (getline(cin, s), s == "END OF INPUT") {
		for (int i = 0, n = 0; i < s.length; i++) {
			if (i == s.length -1 || s[i] == ' ') {
				cout << n;
			} else {
				n++;
			}
		}
		cout << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:46: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
    9 |                 for (int i = 0, n = 0; i < s.length; i++) {
      |                                            ~~^~~~~~
      |                                                    ()
a.cc:10:36: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   10 |                         if (i == s.length -1 || s[i] == ' ') {
      |                                  ~~^~~~~~
      |                                          ()
Language: C++

#include <iostream>
using namespace std;
int main(){
    string s;
    int temp;
    whlie(true){
        getline(cin,s);
        if(s=="END OF INPUT")return 0;
        temp=0;
        for(int i=0;i<s.size();i++){
            if(s[i]==' '){
                printf("%d",temp);
                temp=0;
            }
            else temp++;
        }
        printf("%d\n",temp);
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'whlie' was not declared in this scope
    6 |     whlie(true){
      |     ^~~~~
Language: C++

#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
    string s;
    int temp;
    whlie(true){
        getline(cin,s);
        if(s=="END OF INPUT")return 0;
        temp=0;
        for(int i=0;i<s.size();i++){
            if(s[i]==' '){
                printf("%d",temp);
                temp=0;
            }
            else temp++;
        }
        printf("%d\n",temp);
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'whlie' was not declared in this scope
    7 |     whlie(true){
      |     ^~~~~
Language: C++

#include<iostream>
#include<string>
int main(){std::string s;while(1){std::getline(cin,s);if(s=="END OF INPUT")break;int t=0;for(int i=0;i<s.length();i++)if(s.at(i)==' ')std::cout<<t,t=0;else t++;std::cout<<t<<"\n";}}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:48: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    3 | int main(){std::string s;while(1){std::getline(cin,s);if(s=="END OF INPUT")break;int t=0;for(int i=0;i<s.length();i++)if(s.at(i)==' ')std::cout<<t,t=0;else t++;std::cout<<t<<"\n";}}
      |                                                ^~~
      |                                                std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

#include<iostream>
using namespace std;
int main(void){
	char w[100],end[12]={"END OF INPUT"};
	int i;
	int cnt;

	while(1){
	cnt=0;
	cin.getline(w,sizeof(w));
		for(i=0;i<12;i++){
			if(w[i]!=end[i])
				break;
			else
				return 0;
		}
		for(i=0;w[i]!='\0';i++){
			if(w[i]==' '){
				cout<<cnt;
				cnt=0;
				if(w[i+1]==' '){
					cout<<cnt;
					i+=2;
				}
				continue;
			}
			cnt++;
		}
		cout<<cnt<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:30: error: initializer-string for 'char [12]' is too long [-fpermissive]
    4 |         char w[100],end[12]={"END OF INPUT"};
      |                              ^~~~~~~~~~~~~~
Language: C++

#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char s[1000];
	int n,i;
	for(;gets(s),strpbrk(s,"END OF INPUT");)
		for(n=i=0;i<strlen(s);i++)
			i==strlen(s)-1?printf("%d\n",n+1):s[i]==' '?printf("%d",n),n=0:n++;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:14: error: 'gets' was not declared in this scope; did you mean 'getw'?
    7 |         for(;gets(s),strpbrk(s,"END OF INPUT");)
      |              ^~~~
      |              getw
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main(){
  string str;
  while(cin >> str){
    if(str == "END_OF_INPUT") break;
    str += " ";
    int idx = 0;
    while(idx < str.size()){
      int cnt = 0;
      while(str[idx++]!=" ") cnt++;
      cout << cnt;
    }
    cout << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |       while(str[idx++]!=" ") cnt++;
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main(){
  string str;
  while(getline(ciin, str)){
    if(str == "END OF INPUT") break;
    int idx = 0;
    while(idx < str.size()){
      int cnt = 0;
      while(idx < str.size() && str[idx++]!=' ') cnt++;
      cout << cnt;
    }
    cout << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'ciin' was not declared in this scope
    8 |   while(getline(ciin, str)){
      |                 ^~~~
Language: C++

import java.io.*;
public class aoj1042 {
   public static void main(String[] args) throws IOException{
	   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	   String s;
	   while(true){
		   s = br.readLine();
		   if(s.equals("END OF INPUT")) break;
		   String[] ss = s.split(" ");
		   for(int i=0;i<ss.length;i++) System.out.print(ss[i].length());
		   System.out.println();
	   }
   }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
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 aoj1042 {
      | ^~~~~~
Language: Java

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		P1043_Selecting_Teams_Advanced_to_Regional p = new P1043_Selecting_Teams_Advanced_to_Regional();
		int n;
		Team t;
		ArrayList<Team> at;


		while(true){
			n = sc.nextInt();
			at = new ArrayList<P1043_Selecting_Teams_Advanced_to_Regional.Team>();

			if(n == 0){
				break;
			}

			for(int i=0;i<n;i++){
				t = p.new Team();
				t.id = sc.nextInt();
				t.school = sc.nextInt();
				t.solve = sc.nextInt();
				t.wa = sc.nextInt();
				at.add(t);
			}

			Collections.sort(at, new Comparator<P1043_Selecting_Teams_Advanced_to_Regional.Team>() {
				public int compare(Team t1, Team t2){
					String t1str = String.format("$1%2s$2%6s$3%4s", t1.solve,100000-t1.wa,1000-t1.id);
					String t2str = String.format("$1%2s$2%6s$3%4s", t2.solve,100000-t2.wa,1000-t2.id);
					return t2str.compareTo(t1str);
				}
			});

			HashMap<Integer,Integer> hm = new HashMap<Integer, Integer>();
			int count=0;
			while(!at.isEmpty()){
				if(hm.get(at.get(0).school) == null){
					hm.put(at.get(0).school,1);
					System.out.println(at.get(0).id);
					at.remove(0);
					count++;
				}else{
					switch(hm.get(at.get(0).school)){
					case 1:
						if(count < 20){
							hm.put(at.get(0).school,2);
							System.out.println(at.get(0).id);
							at.remove(0);
							count++;
						}else{
							at.remove(0);
						}
						break;
					case 2:
						if(count < 10){
							hm.put(at.get(0).school,3);
							System.out.println(at.get(0).id);
							at.remove(0);
							count++;
						}else{
							at.remove(0);
						}
						break;
					case 3:
						at.remove(0);
					}
				}
				if(count == 26){
					break;
				}
			}
		}
	}


	public class Team{
		public int id;
		public int school;
		public int solve;
		public int wa;
	}
}

Compiler output:
Main.java:11: error: cannot find symbol
		P1043_Selecting_Teams_Advanced_to_Regional p = new P1043_Selecting_Teams_Advanced_to_Regional();
		^
  symbol:   class P1043_Selecting_Teams_Advanced_to_Regional
  location: class Main
Main.java:11: error: cannot find symbol
		P1043_Selecting_Teams_Advanced_to_Regional p = new P1043_Selecting_Teams_Advanced_to_Regional();
		                                                   ^
  symbol:   class P1043_Selecting_Teams_Advanced_to_Regional
  location: class Main
Main.java:19: error: package P1043_Selecting_Teams_Advanced_to_Regional does not exist
			at = new ArrayList<P1043_Selecting_Teams_Advanced_to_Regional.Team>();
			                                                             ^
Main.java:34: error: package P1043_Selecting_Teams_Advanced_to_Regional does not exist
			Collections.sort(at, new Comparator<P1043_Selecting_Teams_Advanced_to_Regional.Team>() {
			                                                                              ^
4 errors
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

struct Team {
	int id;
	int uni;
	int solved;
	int penalty;
	bool selected;

	bool operator<(const Team& another) const {
		if(solved != another.solved) {
			return (solved > another.solved);
		}
		if (penalty != another.penalty) {
			return (penalty < another.penalty);
		}
		return id < another.id;
	}
};

int selectedCounts[1001];

int main() {
	int n;
	while(true) {
		cin >> n;
		if (n == 0) {
			break;
		}

		vector<Team> teams(n);
		for (int i = 0; i < n; i++) {
			cin >> teams[i].id >> teams[i].uni >> teams[i].solved >> teams[i].penalty;
			teams[i].selected = false;
		}

		for (int i = 0; i < 1001; i++) {
			selectedCounts[i] = 0;
		}

		sort(teams.begin(), teams.end());

		int entireSelectedCount = 0;

		for (int i = 0; i < n; i++) {
			if(entireSelectedCount < 10 && selectedCounts[teams[i].uni] < 3
					|| entireSelectedCount < 20 && selectedCounts[teams[i].uni] < 2
					|| entireSelectedCount < 26 && selectedCounts[teams[i].uni] < 1) {
				selectedCounts[teams[i].uni]++;
				entireSelectedCount++;
				cout << teams[i].id << endl;
			}
		}

	}
	return 0;
}

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

#include<iostream>
#include<vector>
#include<string.h>

using namespace std;

struct log{
	int id,belong,correct,penalty;
};

int main(void){
	
	struct log team[1001];
	int n,idcount[1001];

	while(cin>>n,n){
		
		memset(team,0,sizeof(team));
		memset(idcount,0,sizeof(idcount));
		
		for(int i=1;i<=n;i++){
			cin>>team[i].id>>team[i].belong>>team[i].correct>>team[i].penalty;
		}
		
		for(int i=1;i<=n;i++){
			for(int j=n;j>=i+1;j--){
				if(team[j-1].correct<team[j].correct){
					struct log temp;
					temp=team[j];
					team[j]=team[j-1];
					team[j-1]=temp;
				}
			}
		}

		for(int i=1;i<=n;i++){
			for(int j=n;j>=i+1;j--){
				if(team[j-1].correct==team[j].correct && team[j-1].penalty>team[j].penalty){
					struct log temp;
					temp=team[j];
					team[j]=team[j-1];
					team[j-1]=temp;
				}
			}
		}
			
		for(int i=1;i<=n;i++){
			for(int j=n;j>=i+1;j--){
				if(team[j-1].correct==team[j].correct && team[j-1].penalty==team[j].penalty && team[j-1].id>team[j].id){
					struct log temp;
					temp=team[j];
					team[j]=team[j-1];
					team[j-1]=temp;
				}
			}
		}
	
		idcount[team[i].belong]=0;
		for(int i=1;i<=n;i++){
			if(i<10 && idcount[team[i].belong]<3){
				cout<<team[i].id<<endl;
				idcount[team[i].belong]++;
			}
			else if(i<=10 && i<20 && idcount[team[i].belong]<2){
				cout<<team[i].id<<endl;
				idcount[team[i].belong]++;
			}
			else if(i<=20 && i<26 && idcount[team[i].belong]==0){
				cout<<team[i].id<<endl;
				idcount[team[i].belong]++;
			}
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:30: error: 'i' was not declared in this scope
   58 |                 idcount[team[i].belong]=0;
      |                              ^
Language: Java

package aoj10xx;

import java.util.Scanner;

public class AOJ1044 {


	public static void main ( String[] args ){
		Scanner sc = new Scanner( System.in );
		while( true ){
			String src = sc.next();
			char[] strc = src.toCharArray();
			String type = sc.next();
			char diff =  'a' - 'A';
			switch (type.toCharArray()[ 0 ] ){
			case 'X':
				return;
			case 'U':
				if( 'a' <= strc[ 0 ] && strc[ 0 ] <= 'z' ){
					strc[ 0 ] -= diff; // to upper case
				}
				for( int i = 1; i < strc.length; i++ ){
					if( strc[ i ] == '_' ){
						String s1 = "";
						String s2 = "";
						for( int j = 0; j < i; j++ ){
							s1 += strc[ j ];
						}
						if( 'a' <= strc[ i + 1 ] && strc[ i + 1 ] <= 'z' ){
							strc[ i + 1 ] -= diff;
						}
						for( int j = i + 1; j < strc.length; j++ ){
							s2 += strc[ j ];
						}
						strc = ( s1 + s2 ).toCharArray();
					}
				}
				System.out.println( strc );
				break;
			case 'L':
				if( 'A' <= strc[ 0 ] && strc[ 0 ] <= 'Z' ){
					strc[ 0 ] += diff; // to upper case
				}
				for( int i = 1; i < strc.length; i++ ){
					if( strc[ i ] == '_' ){
						String s1 = "";
						String s2 = "";
						for( int j = 0; j < i; j++ ){
							s1 += strc[ j ];
						}
						if( 'a' <= strc[ i + 1 ] && strc[ i + 1 ] <= 'z' ){
							strc[ i + 1 ] -= diff;
						}
						for( int j = i + 1; j < strc.length; j++ ){
							s2 += strc[ j ];
						}
						strc = ( s1 + s2 ).toCharArray();
					}
				}
				System.out.println( strc );
				break;
			case 'D':
				if( 'A' <= strc[ 0 ] && strc[ 0 ] <= 'Z' ){
					strc[ 0 ] += diff; // to upper case
				}
				for( int i = 1; i < strc.length; i++ ){
					if( 'A' <= strc[ i ] && strc[ i ] <= 'Z' ){
						String s = "";
						for( int j = 0; j < i; j++ ){
							s += strc[ j ];
						}
						s += "_";
						strc[ i ] += diff;
						for( int j = i; j < strc.length; j++ ){
							s += strc[ j ];
						}
						strc = s.toCharArray();
					}
				}
				System.out.println( strc );
				break;
			}

		}
	}
}

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

#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	string::iterator i;
	char c;
	int x;
	while(cin>>s>>c,c-'X')
	{
		s[0]=toupper(s[0]);
		while(x=s.find('_'),x!=string::npos)
			s.erase(x,1),s[x]=toupper(s[x]);
		if(c-'U')s[0]=tolower(s[0]);
		if(c=='D')
			for(i=s.begin();(i=find_if(i,s.end(),isupper))!=s.end();++i)
				*i=tolower(*i),s.insert(i,'_');
		cout<<s<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:51: error: no matching function for call to 'find_if(std::__cxx11::basic_string<char>::iterator&, std::__cxx11::basic_string<char>::iterator, <unresolved overloaded function type>)'
   19 |                         for(i=s.begin();(i=find_if(i,s.end(),isupper))!=s.end();++i)
      |                                            ~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:3867:5: note: candidate: 'template<class _IIter, class _Predicate> _IIter std::find_if(_IIter, _IIter, _Predicate)'
 3867 |     find_if(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3867:5: note:   template argument deduction/substitution failed:
a.cc:19:51: note:   couldn't deduce template parameter '_Predicate'
   19 |                         for(i=s.begin();(i=find_if(i,s.end(),isupper))!=s.end();++i)
      |                                            ~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:52:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Predicate> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate)'
   52 | find_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred);
      | ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:52:1: note:   candidate expects 4 arguments, 3 provided
Language: C++

#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	string s;
	string::iterator i;
	char c;
	int x;
	while(cin>>s>>c,c-'X')
	{
		s[0]=toupper(s[0]);
		while(x=s.find('_'),x!=string::npos)
			s.erase(x,1),s[x]=toupper(s[x]);
		if(c-'U')s[0]=tolower(s[0]);
		if(c=='D')
			for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(isupper)))!=s.end();++i)
				*i=tolower(*i),s.insert(i,'_');
		cout<<s<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:69: error: no matching function for call to 'ptr_fun(<unresolved overloaded function type>)'
   20 |                         for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(isupper)))!=s.end();++i)
      |                                                              ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_function.h:1123:5: note: candidate: 'template<class _Arg, class _Result> std::pointer_to_unary_function<_Arg, _Result> std::ptr_fun(_Result (*)(_Arg))'
 1123 |     ptr_fun(_Result (*__x)(_Arg))
      |     ^~~~~~~
/usr/include/c++/14/bits/stl_function.h:1123:5: note:   template argument deduction/substitution failed:
a.cc:20:69: note:   couldn't deduce template parameter '_Arg'
   20 |                         for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(isupper)))!=s.end();++i)
      |                                                              ~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:1150:5: note: candidate: 'template<class _Arg1, class _Arg2, class _Result> std::pointer_to_binary_function<_Arg1, _Arg2, _Result> std::ptr_fun(_Result (*)(_Arg1, _Arg2))'
 1150 |     ptr_fun(_Result (*__x)(_Arg1, _Arg2))
      |     ^~~~~~~
/usr/include/c++/14/bits/stl_function.h:1150:5: note:   template argument deduction/substitution failed:
a.cc:20:69: note:   candidate expects 2 arguments, 1 provided
   20 |                         for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(isupper)))!=s.end();++i)
      |                                                              ~~~~~~~^~~~~~~~~
a.cc:20:69: note:   couldn't deduce template parameter '_Arg1'
Language: C++

while true do
  identifier, role = gets.chomp.split(' ')
  break if role == 'X'

  words = Array.new
  if identifier[0] =~ /[A-Z]/ then
    words = identifier.scan(/[A-Z][a-z]*/).map {|x| x.downcase }
  elsif identifier.include? '_' then
    words = identifier.split '_'
  else
    words = identifier.scan(/(?:^[a-z]*)|(?:[A-Z][a-z]*)/).map {|x| x.downcase }
  end

  if role == 'U'
    puts words.map {|x| x.capitalize }.join
  elsif role == 'L'
    print words.shift
    puts words.map {|x| x.capitalize }.join
  elsif role == 'D'
    puts words.join '_'
  end
end

Compiler output:
a.cc:1:1: error: expected unqualified-id before 'while'
    1 | while true do
      | ^~~~~
a.cc:8:3: error: 'elsif' does not name a type
    8 |   elsif identifier.include? '_' then
      |   ^~~~~
a.cc:12:3: error: 'end' does not name a type
   12 |   end
      |   ^~~
a.cc:15:39: error: expected unqualified-id before '.' token
   15 |     puts words.map {|x| x.capitalize }.join
      |                                       ^
a.cc:18:39: error: expected unqualified-id before '.' token
   18 |     puts words.map {|x| x.capitalize }.join
      |                                       ^
Language: Java

import java.util.*;

public class Main {
    
    static int n;
    static int[] a = new int[21];
    
    static int dfs(int A, int B, int i) {
        int x;
        int y;
        if(i == n) return Math.abs(A-B);
        x = dfs(A+a[i], B, i+1);
        y = dfs(A, B+a[i], i+1);
        return Math.min(x, y);
    }
    
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            while(sc.hasNext())｛
                n = sc.nextInt();
                if(n == 0) break;
                for(int i=0; i<n; i++) {
                    a[i] = sc.nextInt();
                }
                System.out.println(dfs(0, 0, 0));
            ｝
        }
    }
}



Compiler output:
Main.java:19: error: illegal character: '\uff5b'
            while(sc.hasNext())?
                               ^
Main.java:26: error: illegal character: '\uff5d'
            ?
            ^
2 errors
Language: C

#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void)
{
	int i, n, array[20], A, B;
	
	while (scanf("%d", &n), n != 0){
		A = B = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		sort(array, array + n);
		reverse(array, array + n);
		
		for (i = 0; i < n; i++){
			if (A < B){
				A += array[i];
			}
			else {
				B += array[i];
			}
		}
		
		printf("%d\n", abs(A - B));
	}
	
	return (0);
}

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

#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
	int i, n, array[20], A, B;
	
	while (scanf("%d", &n), n != 0){
		A = B = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		sort(array, array + n);
		reverse(array, array + n);
		
		for (i = 0; i < n; i++){
			if (A < B){
				A += array[i];
			}
			else {
				B += array[i];
			}
		}
		
		printf("%d\n", abs(A - B));
	}
	
	return (0);
}

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

#include<stdio.h>
#include<math.h>

int result;

int main(){
  int i,n,data[20],;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++)scanf("%d",&data[i]);
    result=1000000;
    printf("%d\n",search(n,data,0,0,0));
  }
  return 0;
}

int search(int n,int data[],int i,int a,int b){

  if(i<n){
    search(n,data,i+1,a+data[i],b);
    search(n,data,i+1,a,b+data[i]);
  }
  else if(abs(a-b)<result)result=abs(a-b);

  return result;
}

Compiler output:
main.c: In function 'main':
main.c:7:20: error: expected identifier or '(' before ';' token
    7 |   int i,n,data[20],;
      |                    ^
main.c:13:19: error: implicit declaration of function 'search' [-Wimplicit-function-declaration]
   13 |     printf("%d\n",search(n,data,0,0,0));
      |                   ^~~~~~
main.c: In function 'search':
main.c:24:11: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   24 |   else if(abs(a-b)<result)result=abs(a-b);
      |           ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 |
Language: C++

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

static const int MAX_MEMBERS = 20;

int Members;
int FightingPower[MAX_MEMBERS];

vector<int> power;
int seek = 0;

int FightingPower[MAX_MEMBERS], n, res;
const int INF = 1000001;

void dfs(int i, int a_sum, int b_sum) {
	if (i == n) {
		res = min(abs(a_sum - b_sum), res);
	}
	else {
		dfs(i + 1, a_sum + FightingPower[i], b_sum);
		dfs(i + 1, a_sum, b_sum + FightingPower[i]);
	}
}

int main() {
	while (cin >> n && n!=0) {
		for (int i = 0; i<n; i++) {
			cin >> FightingPower[i];
		}
		res = INF;
		dfs(0, 0, 0);
		cout << res << endl;
	}
}

Compiler output:
a.cc:16:5: error: redefinition of 'int FightingPower [20]'
   16 | int FightingPower[MAX_MEMBERS], n, res;
      |     ^~~~~~~~~~~~~
a.cc:11:5: note: 'int FightingPower [20]' previously declared here
   11 | int FightingPower[MAX_MEMBERS];
      |     ^~~~~~~~~~~~~
Language: C++

#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;

int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		int a=0,b=0;
		vector<int> s(n);
	
	for(int i=0;i<n;i++)
		cin>>s[i];
	
	sort(s.begin(),s.end(),greater<int>());
	
	
		for(int i=0;i<n;i++){
			if(s[i]>0){
			if(a>b)
				b+=s[i];
			else
				a+=s[i];
		}
			else{
				if(a>b)
				a+=s[i];
			else
				b+=s[i];
			}
		cout<<abs(a-b)<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: 'cin' was not declared in this scope
   14 |         while(cin>>n,n!=0){
      |               ^~~
a.cc:8:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    7 | #include <map>
  +++ |+#include <iostream>
    8 | using namespace std;
a.cc:21:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   21 |         sort(s.begin(),s.end(),greater<int>());
      |         ^~~~
      |         sqrt
a.cc:37:17: error: 'cout' was not declared in this scope
   37 |                 cout<<abs(a-b)<<endl;
      |                 ^~~~
a.cc:37:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:37:33: error: 'endl' was not declared in this scope
   37 |                 cout<<abs(a-b)<<endl;
      |                                 ^~~~
a.cc:8:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    7 | #include <map>
  +++ |+#include <ostream>
    8 | using namespace std;
a.cc:39:2: error: expected '}' at end of input
   39 | }
      |  ^
a.cc:10:11: note: to match this '{'
   10 | int main(){
      |           ^
Language: C++

#include<iostream>
using namespace std;
int abs(int a){return a < 0 ? -a : a;}
int main(){
    int n;
    int a[22];
    while(cin>>n,n){
        for(int i=0;i<n;i++)
            cin>>a[i];
        int mi=INT_MAX;
        for(int l=0;l<(2<<n);l++){
            int p=0,q=0;
            for(int i=0;i<n;i++){
                if((l>>i)&1)
                    p+=a[i];
                else
                    q+=a[i];
            }
            mi=min(abs(q-p),mi);
        }
        cout<<mi<<endl;
    }
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: 'INT_MAX' was not declared in this scope
   10 |         int mi=INT_MAX;
      |                ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C++

void dfs(int now, int i);

int a[100];
int minimum = 1000000000, n, sum;
void dfs(int now,int i){
  if(i == n){
    if(minimum > abs(sum-now*2)){
      minimum = abs(sum-now*2);
      return;
    }
  }
  dfs(now, i+1);
  dfs(now-a[i], i+1);
}
int main(){
  while(1){
    sum = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0;i < n;i++){
      cin >> a[i];
      sum += a[i];
    }

    sort(a, a+n);

    dfs(sum, 0);

    cout << minimum << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:7:18: error: 'abs' was not declared in this scope
    7 |     if(minimum > abs(sum-now*2)){
      |                  ^~~
a.cc: In function 'int main()':
a.cc:18:5: error: 'cin' was not declared in this scope
   18 |     cin >> n;
      |     ^~~
a.cc:26:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   26 |     sort(a, a+n);
      |     ^~~~
      |     short
a.cc:30:5: error: 'cout' was not declared in this scope
   30 |     cout << minimum << endl;
      |     ^~~~
a.cc:30:24: error: 'endl' was not declared in this scope
   30 |     cout << minimum << endl;
      |                        ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<math>
using namespace std;
int main(){
	double sum,mostnear;
	bool a[20];
	int n,kyas[20],shiftmax,sssum,ansint,i,j;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<n;i++){
			scanf("%d",&kyas[i]);
		}
		sort(kyas,kyas+n);
		sum=0;
		for(i=0;i<n;i++){
			sum+=kyas[i];
		}
		sum/=2;
		mostnear = 2100000000;
		shiftmax = 1<<n;
		for(i=0;i<shiftmax;i++){
			for(j=0;j<n;j++){
				a[j] = i&1<<j;
			}
			sssum=0;
			for(j=0;j<n;j++){
				sssum += a[j]*kyas[j];
			}
			mostnear = mostnear>fabs(sssum-sum) ? fabs(sssum-sum) : mostnear;
		}
		printf("%d\n",(int)(mostnear*2));
	}
}

Compiler output:
a.cc:3:9: fatal error: math: No such file or directory
    3 | #include<math>
      |         ^~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<algorithm>
#include<math>
using namespace std;
int main(void){
	double sum,mostnear;
	bool a[20];
	int n,kyas[20],shiftmax,sssum,ansint,i,j;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<n;i++){
			scanf("%d",&kyas[i]);
		}
		sort(kyas,kyas+n);
		sum=0;
		for(i=0;i<n;i++){
			sum+=kyas[i];
		}
		sum/=2;
		mostnear = 2100000000;
		shiftmax = 1<<n;
		for(i=0;i<shiftmax;i++){
			for(j=0;j<n;j++){
				a[j] = i&1<<j;
			}
			sssum=0;
			for(j=0;j<n;j++){
				sssum += a[j]*kyas[j];
			}
			mostnear = mostnear>fabs(sssum-sum) ? fabs(sssum-sum) : mostnear;
		}
		printf("%d\n",(int)(mostnear*2));
	}
	return 0;
}

Compiler output:
a.cc:3:9: fatal error: math: No such file or directory
    3 | #include<math>
      |         ^~~~~~
compilation terminated.
Language: C++

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

using namespace std;

int main()
{
	int n;
	
	for(;;)
	{
		vector<int> num;
		cin >> n;
		if(n==0)
			break;
		for(int i=0;i<n;i++)
		{
			int a;
			cin >> a;
			num.push_back(a);
		}
		
		sort(num.begin(),num.end());
		
		int a=0,b=0;
		int a_f=1;
		
		if(num.size()==2)
		{
			cout << sqrt((num[0]-num[1])*(num[0]-num[1])) << endl;
		}
		else
		{
			if(num.size()%2==0)
			{
				for(int i=0,j=num.size()-1;i<j;i++,j--)
				{
					if(a_f==1)
					{
						a+=num[i]+num[j];
						a_f=0;
					}
					else
					{
						b+=num[i]+num[j];
						a_f=1;
					}
				}
			}
			else
			{
				for(int i=1,j=num.size()-1;i<=j || i<num.size();i++,j--)
				{
					if(a_f==1)
					{
						a+=num[i]+num[j];
						a_f=0;
					}
					else
					{
						b+=num[i]+num[j];
						a_f=1;
					}
				}
				if(a<=b)
					a+=num[0];
				else
					b+=num[0];
			}
			cout << "a:" << a << " b:" << b << endl;
			cout << sqrt((a-b)*(a-b)) << endl;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:33: error: 'sqrt' was not declared in this scope
   31 |                         cout << sqrt((num[0]-num[1])*(num[0]-num[1])) << endl;
      |                                 ^~~~
a.cc:72:33: error: 'sqrt' was not declared in this scope
   72 |                         cout << sqrt((a-b)*(a-b)) << endl;
      |                                 ^~~~
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int main () {


	int ab[20];
	bool used[20];
	int sum;
	int aSum;
	int bSum;
	bool aUsed[20];
	bool bUsod[20];

	while (true) {
	
		int n;
		cin >> n;
		if ( n == 0)
			break;
		sum = 0;
		aSum = 0;
		bSum = 0;
		for (int i=0; i<n; i++ ) {
			cin >> ab[i];
			used[i] = false;
			aUsed[i] = false;
			bUsed[i] = false;
			sum += ab[i];
		}

		sort ( ab, &ab[n]);

		for ( int i=n; i>=0; i-- ) {
			if ( aSum <= bSum ) {
				aSum += ab[i];
				aUsed[i] = true;
			} else {
				bSum += ab[i];
				bUsed[i] = true;
			}
		}
		/*
		bool stop = true;
		while (true) {
			if (abs (aSum - bSum) / 2 == 0 ) {
				break;
			}

			for ( int i=0; i<n; i++ ) {
				if ( abs(aSum - bSum)/2 >= ab[i] ) {
					if ( aUsed > bUsed ) {

			}
		}
				*/

		cout << abs(aSum - bSum);
	}


}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:25: error: 'bUsed' was not declared in this scope; did you mean 'bUsod'?
   30 |                         bUsed[i] = false;
      |                         ^~~~~
      |                         bUsod
a.cc:42:33: error: 'bUsed' was not declared in this scope; did you mean 'bUsod'?
   42 |                                 bUsed[i] = true;
      |                                 ^~~~~
      |                                 bUsod
Language: C++

#include<cstdio>
#include<cstdlib>
#include<numeric>

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int a[20];
		for(int i=0;i<n;i++)	scanf("%d",a+i);

		int ans=1<<30;
		int sum=accumulate(a,a+n,0);
		for(int i=0;i<(1<<n);i++){
			int psum=0;
			for(int j=0;j<n;j++){
				if(i&(1<<j))	psum+=a[j];
			}
			ans=min(ans,abs(sum-2*psum));
		}

		printf("%d\n",ans);
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:29: error: 'min' was not declared in this scope; did you mean 'main'?
   19 |                         ans=min(ans,abs(sum-2*psum));
      |                             ^~~
      |                             main
Language: C++

#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,p[20],s[1<<20],s1[1<<10];

int main(){
	while(cin>>n){
		if(!n)return 0;
		int n2=n/2;
		fill(s1,s1+(1<<n2),0);
		int sum=0;
		for(int i=0;i<n;i++){cin>>p[i];sum+=p[i];}
		if(n<2){
			fill(s,s+(1<<n),0);
			for(int i=0;i<1<<n;i++){
				int sss=0;
				for(int j=0;j<n;j++)if((i/(1<<j))%2)sss+=p[j];
				dif=min(dif,abs(sss*2-sum));
			}
			cout<<dif<<endl;
		}
		else{
		for(int i=0;i<1<<n2;i++){
			for(int j=0;j<n2;j++)if(i>>j&1)s1[i]+=p[j];
		}
		sort(s1,s1+(1<<n2));
		int ans=1e+9;
		for(int i=0;i<1<<(n-n2);i++){
			int ss=0;
			
			for(int j=0;j<n-n2;j++)if(i>>j&1)ss+=p[j+n2];
			ans=min(ans,min(abs((*lower_bound(s1,s1+(1<<n2),(sum+1)/2-ss)+ss)*2-sum),abs((*(lower_bound(s1,s1+(1<<n2),(sum+1)/2-ss)-1)+ss)*2-sum)));
		}
		cout<<ans<<endl;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:33: error: 'dif' was not declared in this scope; did you mean 'div'?
   30 |                                 dif=min(dif,abs(sss*2-sum));
      |                                 ^~~
      |                                 div
a.cc:32:31: error: 'dif' was not declared in this scope; did you mean 'div'?
   32 |                         cout<<dif<<endl;
      |                               ^~~
      |                               div
Language: C++


	int n;
	while(cin>>n&&n!=0){
		int a[20];
		int sum=0;
		for(int i=0; i < n; i++){
			cin >> a[i];
			sum+=a[i];
		}
		sort(a,a+n);

		int Asum=0;
		vector<int>A,B;
		for(int i = 0; i < n; i++){
			if(Asum < sum){
				A.push_back(a[i]);
				Asum+=a[i];
				sum-=a[i];
			}
			else{
				for(int j = i; j < n; j++){
					B.push_back(a[j]);
				}
				break;
			}
		}

		int minSum = abs(Asum-sum);
		for(int i = 0; i < A.size(); i++){
			if(Asum <= sum)
				break;
			Asum-=a[i];
			sum+=a[i];
			minSum = min(minSum,abs(Asum-sum));
		}
		cout << minSum << endl;
	}

	return 0;
}

Compiler output:
a.cc:3:9: error: expected unqualified-id before 'while'
    3 |         while(cin>>n&&n!=0){
      |         ^~~~~
a.cc:39:9: error: expected unqualified-id before 'return'
   39 |         return 0;
      |         ^~~~~~
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C++

#include <cstdio>
#include <algorithm>
using namespace std;
#define INF (1<<25)
 
int main(){
	int n , v[20] , X[41] , Y[41] , top;
	while(scanf("%d\n",&n)&& n){
		int dp2[21] = {0};
		for(int i = 0 ; i < n ; i++) scanf("%d",&v[i]) , memo[i].clear();
		sort(v,v+n,greater<int>());
		for(int i = n-1 ; i >= 0 ; i--) dp2[i] = dp2[i+1] + v[i];
		
		int ans = INF;
		
		top = 0;
		X[top] = Y[top] = 0;
		while(~top){
			int pos = X[top] , sum = Y[top]; top--;
			if(pos==n) ans = min(ans,sum);
			else{
				if( sum >= dp2[pos] && ans <= sum-dp2[pos] ) continue; // ツ枝ツ偲ォ
				X[++top] = pos+1 , Y[top]   = sum+v[pos];
				X[++top] = pos+1 , Y[top]   = abs(sum-v[pos]);
			}
		}
		printf("%d\n",ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:66: error: 'memo' was not declared in this scope
   10 |                 for(int i = 0 ; i < n ; i++) scanf("%d",&v[i]) , memo[i].clear();
      |                                                                  ^~~~
a.cc:11:28: error: 'greater' was not declared in this scope
   11 |                 sort(v,v+n,greater<int>());
      |                            ^~~~~~~
a.cc:11:36: error: expected primary-expression before 'int'
   11 |                 sort(v,v+n,greater<int>());
      |                                    ^~~
Language: C++

#include<cstdio>
#include<sstream>
#include<string>

#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)

using namespace std;


int main(void){
	int n;
	while(cin >> n){
		int ans = 100000000;
		int a[32]={0};
		if(!n)break;
		rep(i,n)cin >> a[i];
		
		rep(i,1<<n){
			int ga = 0,gb = 0;
			for(int j = 1,index = 0; j < 1<<n; j = j<<1,index++){
				if(i&j){
					ga+=a[index];
				}else{
					gb+=a[index];
				}
			}
			ans = min(abs(ga-gb), ans);
		}
		
		printf("%d\n", ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: 'cin' was not declared in this scope
   13 |         while(cin >> n){
      |               ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<sstream>
  +++ |+#include <iostream>
    3 | #include<string>
Language: C++

#include<cstdio>
#include<algorithm>

#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)

using namespace std;


int main(void){
	int n;
	while(cin >> n){
		int ans = 100000000;
		int a[32]={0};
		if(!n)break;
		rep(i,n)cin >> a[i];
		
		rep(i,1<<n){
			int ga = 0,gb = 0;
			for(int j = 1,index = 0; j < 1<<n; j = j<<1,index++){
				if(i&j){
					ga+=a[index];
				}else{
					gb+=a[index];
				}
			}
			ans = min(abs(ga-gb), ans);
		}
		
		printf("%d\n", ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: 'cin' was not declared in this scope
   12 |         while(cin >> n){
      |               ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 |
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
#define INF = (1 << 30)
#define rep(i,n) for(int i = 0 ; i < (n) ; ++i)
int n,ANS,vc[20];

void dfs(int rec,int now){
  if(now == n){
    ANS = min(ANS,abs(rec));
    return;
  }
  dfs(rec+vc[now],now+1);
  dfs(rec-vc[now],now+1);
}

int main(){
  while(cin >> n , n){
    ANS = INF;
    rep(i,n) cin >> vc[i];
    dfs(0,0);
    cout << ANS << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:13: error: expected primary-expression before '=' token
    4 | #define INF = (1 << 30)
      |             ^
a.cc:19:11: note: in expansion of macro 'INF'
   19 |     ANS = INF;
      |           ^~~
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF = (1 << 30)
#define rep(i,n) for(int i = 0 ; i < (n) ; ++i)
int n,ANS,vc[20];

void dfs(int rec,int now){
  if(now == n){
    ANS = min(ANS,abs(rec));
    return;
  }
  dfs(rec+vc[now],now+1);
  dfs(rec-vc[now],now+1);
}

int main(){
  while(cin >> n , n){
    ANS = INF;
    rep(i,n) cin >> vc[i];
    dfs(0,0);
    cout << ANS << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:13: error: expected primary-expression before '=' token
    5 | #define INF = (1 << 30)
      |             ^
a.cc:20:11: note: in expansion of macro 'INF'
   20 |     ANS = INF;
      |           ^~~
Language: C

#include <stdio.h>
#include <string.h>

typedef struct tag_Pair{
	int R;
	int C;
}Pair;


int main(){
	int H,W;
	char Map[21][21];
	char Pat[11];
	int i,j;
	
	while(1){
		scanf("%d %d",&H,&W);
		if(!H&&!W)break;
		for(i=0;i<H;i++){
			scanf("%s\n",Map[i]);
		}
		scanf("%s\n",Pat);
		
		int turn =0;
		int M[H][W];
		Pair P;P.R=-1;P.C=-1;
		
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				M[i][j]=-1;
				if(Map[i][j]=='A')M[i][j]=0;
				if(Map[i][j]=='B'){
					P.R=i;
					P.C=j;
				}
			}
		}
		
		int chk=1;
		int FS[H*W+1];//ハッシュの代わり
		int FScnt=0;//ハッシュの要素の個数。H*Wが小さいのでO(N)で管理。。。
		int move;
		int k;
		int PatLength=strlen(Pat);
		
		while(1){
			turn++;
			//まずAを進める
			for(i=0;i<H;i++){
				for(j=0;j<W;j++){
					if(M[i][j]==turn-1){
						if(i-1>=0 && Map[i-1][j]!='#' && M[i-1][j]==-1)M[i-1][j]=turn;
						if(i+1<H  && Map[i+1][j]!='#' && M[i+1][j]==-1)M[i+1][j]=turn;
						if(j-1>=0 && Map[i][j-1]!='#' && M[i][j-1]==-1)M[i][j-1]=turn;
						if(j+1<W  && Map[i][j+1]!='#' && M[i][j+1]==-1)M[i][j+1]=turn;
					}
				}
			}

			move=(turn -1)%(PatLength);
			if(Pat[move]=='8'){if(P.R-1>=0)P.R-=1;}
			if(Pat[move]=='4'){if(P.C-1>=0)P.C-=1;}
			if(Pat[move]=='5'){;}
			if(Pat[move]=='6'){if(P.C+1<W)P.C+=1;}
			if(Pat[move]=='2'){if(P.R+1<H)P.R+=1;}
			if(M[P.R][P.C]!=-1)break;
			if(turn>H*W){
				//ループ停止条件：
				//turn>H*Wであれば、Aが行けるところにはすべてフラグが立っている
				//Bの動きの周期点をturn>H*W以降で観察すれば、Bがループに入ったかどうかが分かる。
				if(move==0){
*/					for(k=0;k<FScnt;k++){
						if(FS[k]==P.R*W+P.C){
							chk=0;
						}
					}
					if(chk==0)break;
					FScnt++;
					FS[P.R*W+P.C];
				}
			}
		}
		if(chk==0){
			printf("impossible\n");
			continue;
		}
		printf("%d %d %d\n",turn,P.R,P.C);
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:72:2: error: expected expression before '/' token
   72 | */                                      for(k=0;k<FScnt;k++){
      |  ^
Language: C++

4 7
A#...#B
.#.#.#.
.#.#.#.
...#...
5
4 7
A#...#B
.#.#.#.
.#.#.#.
...#...
2
4 7
A#...#B
.#.#.#.
.#.#.#.
...#...
4
4 7
A#...#B
.#.#.#.
.#.#.#.
...#...
442668
1 10
A#.......B
55555554
1 10
A#.......B
55555555
0 0

Compiler output:
a.cc:2:2: error: stray '#' in program
    2 | A#...#B
      |  ^
a.cc:2:6: error: stray '#' in program
    2 | A#...#B
      |      ^
a.cc:3:2: error: stray '#' in program
    3 | .#.#.#.
      |  ^
a.cc:3:4: error: stray '#' in program
    3 | .#.#.#.
      |    ^
a.cc:3:6: error: stray '#' in program
    3 | .#.#.#.
      |      ^
a.cc:4:2: error: stray '#' in program
    4 | .#.#.#.
      |  ^
a.cc:4:4: error: stray '#' in program
    4 | .#.#.#.
      |    ^
a.cc:4:6: error: stray '#' in program
    4 | .#.#.#.
      |      ^
a.cc:5:4: error: stray '#' in program
    5 | ...#...
      |    ^
a.cc:8:2: error: stray '#' in program
    8 | A#...#B
      |  ^
a.cc:8:6: error: stray '#' in program
    8 | A#...#B
      |      ^
a.cc:9:2: error: stray '#' in program
    9 | .#.#.#.
      |  ^
a.cc:9:4: error: stray '#' in program
    9 | .#.#.#.
      |    ^
a.cc:9:6: error: stray '#' in program
    9 | .#.#.#.
      |      ^
a.cc:10:2: error: stray '#' in program
   10 | .#.#.#.
      |  ^
a.cc:10:4: error: stray '#' in program
   10 | .#.#.#.
      |    ^
a.cc:10:6: error: stray '#' in program
   10 | .#.#.#.
      |      ^
a.cc:11:4: error: stray '#' in program
   11 | ...#...
      |    ^
a.cc:14:2: error: stray '#' in program
   14 | A#...#B
      |  ^
a.cc:14:6: error: stray '#' in program
   14 | A#...#B
      |      ^
a.cc:15:2: error: stray '#' in program
   15 | .#.#.#.
      |  ^
a.cc:15:4: error: stray '#' in program
   15 | .#.#.#.
      |    ^
a.cc:15:6: error: stray '#' in program
   15 | .#.#.#.
      |      ^
a.cc:16:2: error: stray '#' in program
   16 | .#.#.#.
      |  ^
a.cc:16:4: error: stray '#' in program
   16 | .#.#.#.
      |    ^
a.cc:16:6: error: stray '#' in program
   16 | .#.#.#.
      |      ^
a.cc:17:4: error: stray '#' in program
   17 | ...#...
      |    ^
a.cc:20:2: error: stray '#' in program
   20 | A#...#B
      |  ^
a.cc:20:6: error: stray '#' in program
   20 | A#...#B
      |      ^
a.cc:21:2: error: stray '#' in program
   21 | .#.#.#.
      |  ^
a.cc:21:4: error: stray '#' in program
   21 | .#.#.#.
      |    ^
a.cc:21:6: error: stray '#' in program
   21 | .#.#.#.
      |      ^
a.cc:22:2: error: stray '#' in program
   22 | .#.#.#.
      |  ^
a.cc:22:4: error: stray '#' in program
   22 | .#.#.#.
      |    ^
a.cc:22:6: error: stray '#' in program
   22 | .#.#.#.
      |      ^
a.cc:23:4: error: stray '#' in program
   23 | ...#...
      |    ^
a.cc:26:2: error: stray '#' in program
   26 | A#.......B
      |  ^
a.cc:29:2: error: stray '#' in program
   29 | A#.......B
      |  ^
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 4 7
      | ^
Language: C++

#include<iostream>
#include<queue>
using namespace std;
typedef pair<pair<int,int>,int> pa;
#define ff first.first
#define fs first.second

int h,w,sx,sy,gx,gy;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
int co[21][21];
char ma[21][21];
bool visited[21][21];
string pat;

int main(){
    while(cin>>h>>w,h){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                co[i][j]=INT_MAX;
                cin>>ma[i][j];
                if(ma[i][j]=='A')
                    sx=j,sy=i;
                else if(ma[i][j]=='B')
                    gx=j,gy=i;
            }
        }
        queue<pa>q;
        q.push(make_pair(make_pair(sx, sy), 0));
        while(q.size()){
            pa p = q.front();
            q.pop();
            if(co[p.fs][p.ff]!=INT_MAX)
                continue;
            co[p.fs][p.ff]=p.second;
            for(int i=0;i<4;i++){
                int nx=p.ff+dx[i];
                int ny=p.fs+dy[i];
                if(nx>=0&&nx<w&&ny>=0&ny<h&&ma[ny][nx]!='#'&&co[ny][nx]==INT_MAX)
                    q.push(make_pair(make_pair(nx, ny), p.second+1));
            }
        }
        cin>>pat;
        for(int j=0,go=0;;j++,go++){
            int i=j%pat.length();
            if(co[gy][gx]<=go){
                cout<<go<<" "<<gy<<" "<<gx<<endl;
                break;
            }
            if(go>100000){
                cout<<"impossible"<<endl;
                break;
            }
            if(pat[i]=='8')
                gy--;
            else if(pat[i]=='6')
                gx++;
            else if(pat[i]=='4')
                gx--;
            else if(pat[i]=='2')
                gy++;
            gy=max(0,min(h-1,gy));
            gx=max(0,min(w-1,gx));
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:26: error: 'INT_MAX' was not declared in this scope
   20 |                 co[i][j]=INT_MAX;
      |                          ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<queue>
  +++ |+#include <climits>
    3 | using namespace std;
a.cc:33:32: error: 'INT_MAX' was not declared in this scope
   33 |             if(co[p.fs][p.ff]!=INT_MAX)
      |                                ^~~~~~~
a.cc:33:32: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:39:74: error: 'INT_MAX' was not declared in this scope
   39 |                 if(nx>=0&&nx<w&&ny>=0&ny<h&&ma[ny][nx]!='#'&&co[ny][nx]==INT_MAX)
      |                                                                          ^~~~~~~
a.cc:39:74: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'