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

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

char list[52];

char Decoding(char c,int key){
  
  int num;
  
  if(c >= 'A' && c <= 'Z'){
    num=c-65;
  }else{
    num=c-71;
  }

  num=(num+51*key)%52;
  
  return list[num];
  
}
int main(){

  string str;
  int n;
  int key[52];

  for(int i=0 ; i+65 <= 90 ; i++)list[i]=i+65;
  for(int j=0 ; j+97 <= 122 ; j++)list[j+26]=j+97;

  while(1){
    
    cin >>n;
    if(n == 0)break;
    
    for(int i=0 ; i < n ; i++)cin >>key[i];
    
    cin >>str;
    
    for(int i=0 ; i < str.size() ; i++){
      cout <<Decoding(str[i],key[i%n]);
    }
    
    cout <<endl;
    
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'char Decoding(char, int)':
a.cc:18:10: error: reference to 'list' is ambiguous
   18 |   return list[num];
      |          ^~~~
In file included from /usr/include/c++/14/list:65,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:150,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:4:6: note:                 'char list [52]'
    4 | char list[52];
      |      ^~~~
a.cc: In function 'int main()':
a.cc:27:34: error: reference to 'list' is ambiguous
   27 |   for(int i=0 ; i+65 <= 90 ; i++)list[i]=i+65;
      |                                  ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:4:6: note:                 'char list [52]'
    4 | char list[52];
      |      ^~~~
a.cc:28:35: error: reference to 'list' is ambiguous
   28 |   for(int j=0 ; j+97 <= 122 ; j++)list[j+26]=j+97;
      |                                   ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:4:6: note:                 'char list [52]'
    4 | char list[52];
      |      ^~~~
Language: C++

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

char list[52];

char Decoding(char c,int key){
  
  int num;
  
  if(c >= 'A' && c <= 'Z'){
    num=c-65;
  }else{
    num=c-71;
  }
  
  num=(num+51*key)%52;
  
  return list[num];
  
}
int main(){

  string str;
  int n;
  int key[100];
  
  for(int i=0 ; i+65 <= 90 ; i++)list[i]=i+65;
  for(int j=0 ; j+97 <= 122 ; j++)list[j+26]=j+97;
  
  while(1){
    
    cin >>n;
    if(n == 0)break;
    
    for(int i=0 ; i < n ; i++)cin >>key[i];
    
    cin >>str;
    
    for(int i=0 ; i < (int)str.size() ; i++){
      cout <<Decoding(str[i],key[i%n]);
    }
    
    cout <<endl;
    
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'char Decoding(char, int)':
a.cc:18:10: error: reference to 'list' is ambiguous
   18 |   return list[num];
      |          ^~~~
In file included from /usr/include/c++/14/list:65,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:150,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:4:6: note:                 'char list [52]'
    4 | char list[52];
      |      ^~~~
a.cc: In function 'int main()':
a.cc:27:34: error: reference to 'list' is ambiguous
   27 |   for(int i=0 ; i+65 <= 90 ; i++)list[i]=i+65;
      |                                  ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:4:6: note:                 'char list [52]'
    4 | char list[52];
      |      ^~~~
a.cc:28:35: error: reference to 'list' is ambiguous
   28 |   for(int j=0 ; j+97 <= 122 ; j++)list[j+26]=j+97;
      |                                   ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:4:6: note:                 'char list [52]'
    4 | char list[52];
      |      ^~~~
Language: C++

#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    char hoge[]={"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    int hoge_size=(int)strlen(hoge);
    map<char,int>mp;
    rep(i,hoge_size){
        mp[hoge[i]]=i;
    }
    while(cin>>n){
        vi key(n); rep(i,n)cin>>key[i];
        string s; cin>>s;
        string ans;
        int cnt=0;
        for(int i=0; i<s.size();i++){
            int gotiusa=mp[s[i]]-key[cnt];
            if(gotiusa<0)gotiusa+=52;
            cout<<hoge[gotiusa];
            cnt++;
            if(cnt==key.size())cnt=0;
        }
        cout<<endl;
    }
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:24: error: 'strlen' was not declared in this scope
   47 |     int hoge_size=(int)strlen(hoge);
      |                        ^~~~~~
a.cc:23:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   22 | #include <stack>
  +++ |+#include <cstring>
   23 | #define vi vector<int>
Language: C++

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

using namespace std;

int main(){
	int n;
	string s;
	while(cin >> n, n){
		vector<int> key(n);
		for(int i = 0; i < n; i++){
			int tmp;
			cin >> tmp;
			k[i] = tmp % 52;
		}
		cin >> s;
		
		for(int i = 0; i < s.size(); i++){
			int tmp = i % n;
			s[i] = s[i] - key[tmp];
			if('Z' < s[i] && s[i] < 'a'){
				s[i] = 'Z' + (s[i] - 'a') + 1;
			}
			if(s[i] < 'A'){
				s[i] = 'z' + (s[i] - 'A') + 1;
			}
		}
		cout << s << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: error: 'k' was not declared in this scope
   16 |                         k[i] = tmp % 52;
      |                         ^
Language: C++

#include<iostream>
using namespace std;
int main(){
  int *k,count;
  char *s;
while(1){
  int n,i;
  s=new char[100];
  cin>>n;
  if(n==0)break;
  count=1
  k= new int[n+1];
  for(i=1;i<=n;i++)cin>>k[i];
  cin>>s;
  for(i=0;s[i]!=0;i++){
    s[i]-=k[count>n?count=0:count++];
    if(s[i]<'A')s[i]='z'-('A'-s[i]);
  }
  cout<<s<<endl;

  delete s;
  delete k;
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: expected ';' before 'k'
   11 |   count=1
      |          ^
      |          ;
   12 |   k= new int[n+1];
      |   ~
Language: C++

#include<iostream>
using namespace std;
int main(){
  int *ki;
  char *s;
while(1){
  int n;
  s=new char[100];
  cin>>n;
  if(n==0)break;
  k= new int[n+1];
  for(i=1;i<=n;i++)cin>>k[i];
  cin>>s;
  for(i=0;s[i]!=0;i++){
    s[i]-=k[i%n+1];
    if(s[i]<'A')s[i]-='A'-'z'-1;
    else if(s[i]>'Z' && s[i]<'a')s[i]-=6;
  }
  cout<<s<<endl;

  delete s;
  delete k;
}

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'k' was not declared in this scope
   11 |   k= new int[n+1];
      |   ^
a.cc:12:7: error: 'i' was not declared in this scope
   12 |   for(i=1;i<=n;i++)cin>>k[i];
      |       ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i=0;s[i]!=0;i++){
      |       ^
a.cc:22:3: error: type '<type error>' argument given to 'delete', expected pointer
   22 |   delete k;
      |   ^~~~~~~~
Language: C++

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


int n;
int key[1000];
string str;

char x[60];

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



    for(int i= 0; i < n ; i++)
      cin >> key[i];

    cin >> str;
    for(int i = 0,j = 0; i < str.size() ; i++,j++){
      if(i % n == 0) j = 0;
      
      char tmp = str[i] - key[j]; 
   
      if(str[i] - key[j] < 'A' && str[i] <= 'Z' ){
	str[i] += 52 + 6;
      }else  if(str[i] - key[j] < 'A' && str[i] >= 'Z' ){
	str[i] += 52;
      }
      if(str[i] >= 'a' && str[i] - key[j] < 'a') str[i] -= 6;
      str[i] -= key[j];
    }
    cout << str << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'cin' was not declared in this scope
   19 |     cin >> n;
      |     ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    6 | #include <string>
  +++ |+#include <iostream>
    7 | using namespace std;
a.cc:41:5: error: 'cout' was not declared in this scope
   41 |     cout << str << endl;
      |     ^~~~
a.cc:41:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:41:20: error: 'endl' was not declared in this scope
   41 |     cout << str << endl;
      |                    ^~~~
a.cc:7:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    6 | #include <string>
  +++ |+#include <ostream>
    7 | using namespace std;
Language: C++

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


int n;
int key[1000];
string str;

char x[60];

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



    for(int i= 0; i < n ; i++)
      cin >> key[i];

    cin >> str;

    int size = str.size();
    //  cout << size <<" ";
    for(int i = 0,j = 0; i < size; i++,j++){
      if(i % n == 0){
	j = 0;
      }      
   
      for(int k = 0; k < key[j] ; k++){
	str[i]--;
	if(str[i]  < 'a' && str[i] > 'Z') str[i] -= 6;
	if(str[i] < 'A' ) str[i] += 52 + 6;

      }
      /*
	if(str[i] - key[j] < 'A' && str[i] <= 'Z' && ){
	str[i] += 52 + 6;
	}else  if(str[i] - key[j] < 'A' && str[i] >= 'a' ){
	str[i] += 52;
	}
	if(str[i] >= 'a' && str[i] - key[j] < 'a' && str[i] - key[j] > 'Z') str[i] -= 6;
	str[i] -= key[j];
	}

      */
5    }
    cout << str << endl;
    
  }
    return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:2: error: expected ';' before '}' token
   55 | 5    }
      |  ^   ~
      |  ;
Language: Java

import static java.lang.System.*;

import java.util.*;

public class B {
	
	
	void run(){
		while(true){
			int s=sc.nextInt(),n=sc.nextInt(), t = sc.nextInt();
			String week = sc.next(), time = sc.next();
			int p = sc.nextInt(), m = sc.nextInt();
			if(s==0 && n==0 && t == 0)return;
			
			int count = 0;
			int w = 60*24*7;
			if (week.equals("All") && time.equals("All")){
				count = m;
			} else {

				if (!week.equals("All")) {
					int b;
					if (time.equals("All") || time.equals("Day")) {
						if (time.equals("All")) b = 1440;
						else b = 720;
						for (int begin = 0; begin < w; begin++) {
							int c = 0;
							for (int i = 0; i < m; i++) {
								if ((begin +i*t)%w <= b && (begin +i*t+s)%w < b) {
									c++;
								}
							}
							count = Math.max(count, c);
						}
					} else {
						b = 360;
						for (int begin = 0; begin < w; begin++) {
							int c = 0;
							for (int i = 0; i < m; i++) {
								if (((begin +i*t)%w <= b && (begin +i*t+s)%w < b) || (1080 <=(begin +i*t)%w && (begin +i*t)%w < b+1080 && (begin +i*t+s)%w < b+1080 && 1080 < (begin +i*t+s)%w)) {
									c++;
								}
							}
							count = Math.max(count, c);
						}
					}
				} else {
					int b;
					if (time.equals("All")) b = 1440;
					else b = 720;
					for (int begin = 0; begin < w; begin++) {
						int c = 0;
						for (int i = 0; i < m; i++) {
							boolean flag = false;
							for (int j = 0; j < 7; j++) {
								if (1440*j <= (begin +i*t)%w && (begin +i*t)%w < b+1440*j &&
										1440*j <= (begin +i*t+s)%w && (begin +i*t+s)%w < b+1440*j) {
									flag = true;
									break;
								}
							}
							if (flag)
								c++;
						}
						count = Math.max(count, c);
					}
				}
			}
			
			out.printf("%.10f\n", 1.0-Math.pow((double)(p-1)/p, n*count));
		}
	}
	
	public static void main(String[]_){
		new B().run();
		out.flush();
		out.close();
	}
	
	static Scanner sc=new Scanner(in);


}

Compiler output:
Main.java:74: error: as of release 9, '_' is a keyword, and may not be used as an identifier
	public static void main(String[]_){
	                                ^
1 error
Language: Java

gimport java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	int s;
	int n;
	int t;
	String weekday;
	String time;
	Map<String, Integer> wmap = new HashMap<String, Integer>();

	int p;
	int m;
	final int WEEK = 60 * 24 * 7;
	final int DAY = 60 * 24;

	void run() {

		wmap.put("Sun", 0);
		wmap.put("Mon", 1);
		wmap.put("Tue", 2);
		wmap.put("Wed", 3);
		wmap.put("Thu", 4);
		wmap.put("Fri", 5);
		wmap.put("Sat", 6);
		wmap.put("All", 7);
		// 0 < s <= 500
		// 0 < n <= 100
		// s < t <= 1000
		// weekday ∈ {All, Sun, Mon, Tue, Wed, Thu, Fri, Sat}
		// All は、全ての曜日を意味する
		// time ∈ {All, Day, Night}
		// All は [0:00~24:00), Day は [6:00~18:00), Night は [18:00~6:00)
		// の時間帯を意味する。
		// 1 <= p <= 99999
		// 1 <= m <= 100

		// s n t weekday time p m
		while (true) {
			s = sc.nextInt();
			n = sc.nextInt();
			t = sc.nextInt();
			weekday = sc.next();
			time = sc.next();
			p = sc.nextInt();
			m = sc.nextInt();
			if (s == 0)
				break;
			int max = 0;
			for (int sw = 0; sw < 7; sw++) {
				for (int st = 0; st < 24 * 60; st++) {
					int w = sw;
					int ctime = st;
					int cnt = 0;
					for (int k = 0; k < m; k++) {
						if (check(ctime, w)) {
							cnt++;
						}
						ctime += t;
						w += ctime / DAY;
						ctime %= DAY;
						max = Math.max(max, cnt);
					}
				}
			}
			double ans = 1.0 - Math.pow(1.0 - 1.0 / p, n * max);
			System.out.printf("%.10f\n", ans);
		}
	}

	boolean check(int ctime, int week) {
		// 開始時の曜日
		boolean AllWeek = weekday.equals("All");
		if (wmap.get(weekday) != week && !AllWeek)
			return false;
		// 孵化時の曜日
		// week += (ctime + s) % DAY;
		// if (wmap.get(weekday) != week && !AllWeek)
		// return false;
		int start = 0;
		int end = 0;
		if (time.equals("All")) {
			start = 0;
			end = 24 * 60;
		}
		// Dayのときは[6:00~18:00)
		if (time.equals("Day")) {
			start = 6 * 60;
			end = 18 * 60;
		}
		// Nightのときは[18:00~6:00)
		if (time.equals("Night")) {
			return false;
		}
		if (start <= ctime && ctime + s < end)
			return true;
		return false;
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
gimport java.util.HashMap;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.Map;
^
Main.java:3: error: class, interface, enum, or record expected
import java.util.Scanner;
^
3 errors
Language: C++

#include<iostream>
#include<vector>
#include<string>

using namespace std;


int main(){
	while (true){
		int s, n, t, p, m;
		string wd, dt;
		int ret=0;
		cin >> s >> n >> t >> wd >> dt >> p >> m;
		if (s == 0 && wd == "None"){
			break;
		}
		if (wd == "All" && dt == "All"){
			ret = n*m;
		}
		else{
			int	time = 0, head = 0;
			int day;
			if (dt == "Day"){
				puts("!!");
				day = 1;
			}
			else
				day = 0;
			ret = 0;
			int les = 0;
			while (m > 0){
				if ((time % 7) == 0 || wd == "All"){
					head = 1;
				}
				else
					head = 0;
				if (dt == "Day" && (day % 4 == 1 || day % 4 == 2)){
					head = head * 1;
				}
				else if (dt == "Night" && (day % 4 == 0 || day % 4 == 3)){
					head = head * 1;
				}
				else if (dt == "All"){
					head = head * 1;
				}
				else
					head = 0;
				int min = 60 * 6;
				int tmp;
				min -= les;
				if ((tmp = (min / t)) >= m){
					ret += m*n*head;
				}
				else{
					ret += head*tmp*n;
				}
				m = m - tmp;
				//printf("tmp=%d  ", tmp);
				if (m > 0 && min%t >= s){
					//puts("!!!!!!");
					ret += head*n;
				}
				if (min%t < s && day % 4 == 1 && min%t!=0){
					//puts("!!");
					ret += head*n;
				}
				//printf("m=%d  ", m);
				if (min%t != 0){
					les = t - min%t;
					m--;
				}

				//printf("les=%d  ",les);
				//printf("day=%d  time=%d  ret=%d\n", day, time,ret);
				if ((day++)%4 == 3){
					time++;
				}
			}
		}
		double a1 = (((double)p - 1) / (double)p);
		double ans = 1 - pow(a1, ret);
		printf("%0.10f\n", ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:34: error: 'pow' was not declared in this scope
   81 |                 double ans = 1 - pow(a1, ret);
      |                                  ^~~
Language: C++

#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int s, n, t, p, m;
	char weekday[10]={0}, time_[10] = {0};

	while(1){
		cin >> s >> n >> t >> weekday >> time_ >> p >> m;

		if(s == 0 && n == 0 && t == 0 && !strcmp(weekday, "None") && !strcmp(time_, "None") && p == 0 && m == 0){
			break;
		}

		if(!strcmp(weekday, "All")){
			if(!strcmp(time_, "All")){
				cout << p / (n * m) << endl;

			} else {
				int b = 720 / t;
				if(720 % t > s){
					b++
				}
				a = t * m / (60 * 24);
				if(t * m % (60*24) > s){
					cout << 1.0 * (p/(n*b))*a + 1.0 * p* ((t * m % 60 * 24)/s)/n << endl;
				} else {
					cout << 1.0 * (p/(n*b))*a << endl;
				}
			}
		} else {
			if(!strcmp(time_, "All")){
				b = 1440 / t;
				if(1440 % t > s){
					b++;
				}
				a = t * m / (60 * 24 * 7);
				if(t * m % (60 * 24 * 7) > s){
					cout << 1.0 * (p / n * b) * a + 1.0 * p * ((t * m % 60 * 24 * 7 )/s)/n << endl;
				} else {
					cout << (p / n * b) * a;
				}
			} else {
					b = 720 / t;
				if(720 % t > s){
					b++;
				}
				a = t * m / (60 * 24 * 7);
				if(t * m % (60 * 24 * 7) > s){
					cout << 1.0 * (p / n * b) * a + 1.0 * p * ((t * m % 60 * 24 * 7 )/s)/n << endl;
				} else {
					cout << (p / n * b) * a;
				}
			}

		}

	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:44: error: expected ';' before '}' token
   24 |                                         b++
      |                                            ^
      |                                            ;
   25 |                                 }
      |                                 ~           
a.cc:26:33: error: 'a' was not declared in this scope
   26 |                                 a = t * m / (60 * 24);
      |                                 ^
a.cc:35:33: error: 'b' was not declared in this scope
   35 |                                 b = 1440 / t;
      |                                 ^
a.cc:39:33: error: 'a' was not declared in this scope
   39 |                                 a = t * m / (60 * 24 * 7);
      |                                 ^
a.cc:46:41: error: 'b' was not declared in this scope
   46 |                                         b = 720 / t;
      |                                         ^
a.cc:50:33: error: 'a' was not declared in this scope
   50 |                                 a = t * m / (60 * 24 * 7);
      |                                 ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cstdio>
#include <cmath>

using namespace std;

string str_week[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "All" };
map<string, int> W;
int s, n, t, p, m;
string week, sTime;

// 時間を進める(分単位)
void addTime ( int &hh, int &mm, int &ww, int x )
{
	static const int day = 24 * 60 * 60;
	static const int hou = 60 * 60;
	static const int min = 60;
	if (!x) { return; }
	int tt = hh * hou + mm * min + x * min;
	if (tt >= day) {
		ww <<= 1;
		tt %= day;
		if (ww >= (1 << 7)) { ww = 1; }
	}
	hh = tt / hou;
	tt %= hou;
	mm = tt / min;
}

// 突然変異可能な曜日・時間帯か調べる
bool isChange ( int hh, int mm, int ww )
{
	if ((W[week] & ww) == 0) { return false; }
	if (sTime == "All") { return true; }
	if (sTime == "Day" && (6 <= hh && hh < 18)) { return true; }
	if (sTime == "Night" && (18 <= hh || hh < 6)) { return true; }
	return false;
}

double prob = 0;

// 確率をシミュレーションする
double getProb ( int hh, int mm, int ww )
{
	double miss = 1.0;
	for (int i = 0; i < m; ++i) {
		bool hit = true;
		hit &= isChange(hh, mm, ww); // 卵の出現した時は変異の範囲内か
		addTime(hh, mm, ww, s);
		hit &= isChange(hh, mm, ww); // 孵化の時は変異の範囲内か
		if (hit) { // 出現から孵化まで変異の範囲内なので変化が起こる(失敗)
			miss *= prob;
		}
		addTime(hh, mm, ww, t - s); // ステージの終了まで時間を進める
	}
	return 1.0 - miss;
}

int main ( void )
{
	W["All"] = (1 << 7) - 1;
	for (int i = 0; i < 7; ++i) {
		W[str_week[i]] = 1 << i;
	}
	while (cin >> s >> n >> t >> week >> sTime >> p >> m) {
		if (s+n+t+p+m == 0 && week == sTime && week == "None") { break; }
		double ans = 0;
		prob = pow((p - 1.0)/ (double)p, n)
		for (int i = 0; i < 7; ++i) {
			for (int j = 0; j < 24; ++j) {
				for (int k = 0; k < 60; ++k) {
					ans = max(ans, getProb(j, k, W[str_week[i]]));
				}
			}
		}
		printf("%.10lf\n", ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:52: error: expected ';' before 'for'
   71 |                 prob = pow((p - 1.0)/ (double)p, n)
      |                                                    ^
      |                                                    ;
   72 |                 for (int i = 0; i < 7; ++i) {
      |                 ~~~                                 
a.cc:72:33: error: 'i' was not declared in this scope
   72 |                 for (int i = 0; i < 7; ++i) {
      |                                 ^
Language: C++

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

//s n t weekday time p m
int main(){
	int s,t,m;
	double n,p;
	string weekday,time;
	while(1){
		cin >> s >> n >> t >> weekday >> time >> p >> m;
		if(s == 0){break;}
		int egg = 0;
		if(weekday == "All"){
			if(time == "All"){
				egg = m;
			}
			else{
				for(int i = 0; i < m; i++){
					if((t*i)% 1440 < 720 &&(t*i+s)% 1440 < 720){
						egg++;
					}
				}
			}
		}else{
		if(time == "All"){//一日
			for(int i = 0; i < m; i++){
				if((t*i)% 10080 < 1440 && (t*i+s)% 10080 < 1440){
					egg++;
				}
			}
		}else if(time == "Day"){//昼
			for(int i = 0; i < m; i++){
				if((t*i)% 10080 < 720 && (t*i+s)% 10080 < 720){
					egg++;
				}
			}
		}else{
			for(int i = 0; i < m; i++){
				if((t*i)% 10080 < 360 && (t*i+s)% 10080 < 360){
					egg++;
				}
				if((t*i)% 10080 < 1440 && (t*i)% 10080 >= 1080 && (t*i+s)% 10080 < 1440 && (t*i+s)% 10080 >= 1080){
					egg++;
				}
			}
		}
		}
		//(1-pow((1-1/p),n*egg))
		printf("%.10f\n", 1-pow((1-1/p),n*egg));
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:37: error: 'pow' was not declared in this scope
   52 |                 printf("%.10f\n", 1-pow((1-1/p),n*egg));
      |                                     ^~~
Language: C++

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


int s,n,t,p,m;
int blockw;
int blockt;
int minute[10081];
string wd,tim;

double check(int start){
	int i, j;
	int suc=0;
	for(i=0;i<m;i++,start+=t;){
		for(j = 0;j <= s;j++) if(!minute[(start+j)%10080]) break;
		if(j>s) suc ++;
	}
	return 1-pow(1-1/(double)p, (double)suc*n);
}

main(){
	int i,j;
	while(cin >> s >> n >> t >> wd >> tim >> p >> m, s){
		fill(minute, &minute[10080], 0);
		if(wd=="All") blockw = (1<<7)-1;
		else blockw = 1;
		if(tim=="Night") blockt = 1;
		else if(tim=="Day") blockt = 2;
		else blockt = 3;
		for(i=0;i<10080;i++){
			if((blockw & (1 << i/1440)) == 0) continue;
			if((blockt & (1 << ((i/360+1)%4/2))) == 0) continue;
			minute[i] = 1;
		}
		double ans = 0;
		for(i=0;i<1440;i++){
			double ret = check(i);
			ans = max(ans, ret);
		}
		printf("%.10f\n", ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'double check(int)':
a.cc:22:33: error: expected ')' before ';' token
   22 |         for(i=0;i<m;i++,start+=t;){
      |            ~                    ^
      |                                 )
a.cc:22:34: error: expected primary-expression before ')' token
   22 |         for(i=0;i<m;i++,start+=t;){
      |                                  ^
a.cc: At global scope:
a.cc:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main(){
      | ^~~~
Language: C++

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

int main (int argc, char* argv[]){

  while (true) {
    int s,n,t,p,m,cnt_max;
    string week_input,time_input;
    cin >> s >> n >> t >> week_input >> time_input >> p >> m;
    if ( s == 0 ) break;

    int week = 0;
    if ( week_input == "Sun" ) {
      week = 0;
    }else if ( week_input == "Mon" ) {
      week = 1;
    }else if ( week_input == "Tue" ) {
      week = 2;
    }else if ( week_input == "Wed" ) {
      week = 3;
    }else if ( week_input == "Thu" ) {
      week = 4;
    }else if ( week_input == "Fri" ) {
      week = 5;
    }else if ( week_input == "Sat" ) {
      week = 6;
    }

	cnt_max = 0;

	for ( int k = 0; k < 7; k++ ) {
	for ( int i = 0; i < 60*24; i++ ) {
		int time = k * 60*24 + i - t;

		int cnt = 0;
		for ( int j = 0; j < m; j++ ) {
			time += t;
			time = time % 60*24*7
			if ( week_input != "All" ) {
				if ( time / ( 60*24 ) != week || ( time + s ) / ( 60*24 ) != week ) continue;
			}
			if ( time_input == "Day" ) {
				if ( time % (60*24) < 60*6 || time % (60*24) >= 60*18 || (time+s) % (60*24) <= 60*6 || (time+s) % (60*24) >= 60*18 ) continue;
			}else if ( time_input == "Night" ) {
				if ( ( time % (60*24) >= 60*6 ) && ( time % (60*24) < 60*18 ) && ( (time+s) % (60*24) >= 60*6 ) && ( (time+s) % (60*24) <= 60*18 ) ) continue;
			}
			cnt++;
		}

		cnt_max = max( cnt_max, cnt );
	}
	}

	double q = 1.0 - 1.0/p;
	//cout << fixed << 1-powf(q,n*cnt_max) << endl;
    //printf("%d\n", cnt_max);
    printf("%.10lf\n", 1 - pow(q, n * cnt_max));
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:41:46: error: expected ';' before 'if'
   41 |                         time = time % 60*24*7
      |                                              ^
      |                                              ;
   42 |                         if ( week_input != "All" ) {
      |                         ~~
Language: C++

#include <iostream>
#include <fstream>

using namespace std;

int r[1001], w[1001];
int time;
bool dp[1001] = { 0 };

int w_book(int wait, int n, int r_max) {
	int i_max = 0;
	dp[0] = 1;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (i != r_max || cnt > 0) {
			for (int j = wait; j >= w[i]; j--) {
				dp[j] = dp[j - w[i]];
				if (dp[j]) {
					if (i_max < j) i_max = j;
				}
			}
		}
		else cnt++;
	}
	return i_max;
}

int main() {
	ifstream fin("input.txt");
	ofstream fout("output.txt");

	int n;
	cin >> n;
	for (int i = 1; i < 1001; i++) {
		cin >> r[i] >> w[i];
	}
	int r_max = 0;
	int r_total = 0, w_total = 0;
	for (int i = 1; i <= n; i++) {
		if (r_max < r[i]) r_max = r[i];
		r_total += r[i];
		w_total += w[i];
	}
	if (r_max <= r_total - r_max) time = r_total + w_total;
	else time = 2 * r_max + w_total - w_book(r_max - (r_total - r_max), n, r_max);

	cout << time << endl;

	return 0;
}

Compiler output:
a.cc:7:5: error: 'int time' redeclared as different kind of entity
    7 | int time;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:44:44: error: assignment of function 'time_t time(time_t*)'
   44 |         if (r_max <= r_total - r_max) time = r_total + w_total;
      |                                       ~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:45:19: error: assignment of function 'time_t time(time_t*)'
   45 |         else time = 2 * r_max + w_total - w_book(r_max - (r_total - r_max), n, r_max);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

int r[1001], w[1001];
int time;
bool dp[1001] = { 0 };

int w_book(int wait, int n, int r_max) {
	sort(r, r + n);
	sort(w, w + n);
	int i_max = 0;
	dp[0] = 1;
	int cnt = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = wait; j >= w[i]; j--) {
			dp[j] = dp[j - w[i]];
			if (dp[j]) {
				if (i_max < j) i_max = j;
			}
		}
	}
	return i_max;
}

int main() {
	//ifstream fin("input.txt");
	//ofstream fout("output.txt");

	int n;
	cin >> n;
	for (int i = 1; i < 1001; i++) {
		cin >> r[i] >> w[i];
	}
	int r_max = 0;
	int r_total = 0, w_total = 0;
	for (int i = 1; i <= n; i++) {
		if (r_max < r[i]) r_max = r[i];
		r_total += r[i];
		w_total += w[i];
	}
	if (r_max <= r_total - r_max) time = r_total + w_total;
	else time = 2 * r_max + w_total - w_book(r_max - (r_total - r_max), n, r_max);

	cout << time << endl;

	return 0;
}

Compiler output:
a.cc:8:5: error: 'int time' redeclared as different kind of entity
    8 | int time;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:44:44: error: assignment of function 'time_t time(time_t*)'
   44 |         if (r_max <= r_total - r_max) time = r_total + w_total;
      |                                       ~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:45:19: error: assignment of function 'time_t time(time_t*)'
   45 |         else time = 2 * r_max + w_total - w_book(r_max - (r_total - r_max), n, r_max);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

typedef pair<int,int> pii;
#define fi first
#define se second

int main() {
	int N;
	while(cin >> N, N) {
		vector<pii> v;
		v.resize(N);
		for(int i = 0; i < N; i++) {
			cin >> v[i].fi >> v[i].se;
		}
		sort(v.begin(), v.end());
		int sum = 0;
		int res = 0;
		for(int i = 0; i < N; i++) {
			sum += v[i].fi;
			res += v[i].fi + v[i].se;
		}
		//cout << sum << " " << v.back().fi << endl;
		if(v.back().fi*2 > sum) {
			int dp[1100] = {};
			int tmp = 0;
			dp[0] = 1;
			for(int i = 0; i < v.size()-1; i++) {
				for(int j = 1099; j >= 0; j--) {
					if(j + v[i].se < 1100 && dp[j]) {
						dp[j+v[i].se] = 1;
					}
				}
				tmp += v[i].fi;
			}
			for(int i = v.back().fi - tmp; i >= 0; i--) {
				if(dp[i]) {
					res += (v.back().fi-tmp) - i;
					break;
				}
			}
		}
		cout << res << endl;
	}
}

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

#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
pair<int, int>x[1000]; int n, a, b, s1, s2, dp[1100000];
int main() {
	while (true) {
		cin >> n; s1 = 0; s2 = 0; if (n == 0)break;
		for (int i = 0; i < n; i++) { cin >> a >> b; x[i] = make_pair(a, b); s1 += a; s2 += b; }
		sort(x, x + n);
		if (x[n - 1].first * 2 <= s1) { cout << s1 + s2 << endl; }
		else {
			for (int i = 0; i <= s2; i++)dp[i] = 0; dp[0] = 1; queue<int>Q; Q.push(0);
			for (int i = 0; i < n - 1; i++) {
				vector<int>f;
				while (!Q.empty()) {
					int a1 = Q.front(); Q.pop();
					if (dp[a1 + x[i].second] == 0) { f.push_back(a1 + x[i].second); dp[a1 + x[i].second] = 1; }
				}
				for (int i = 0; i < f.size(); i++)Q.push(f[i]);
			}
			int g = 0; for (int i = x[n - 1].first - (s1 - x[n - 1].first); i >= 0; i--) { if (dp[i] == 1) { g = i; break; } }
			cout << (x[n - 1].first - (s1 - x[n - 1].first) - g) + s1 + s2 << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |                 sort(x, x + n);
      |                 ^~~~
      |                 short
Language: C++

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

int n,mi;
int r,w[1001];
int dp[1001][1001];

int rec(int i, int j){
	if(dp[i][j] >= 0) return dp[i][j];
	int res;
	if(i==n) res = 0;
	else if(j < w[i] || i==mi) res = rec(i+1, j);
	else res = max(rec(i+1, j), rec(i+1, j-w[i]) + w[i]);
	return dp[i][j] = res;
}

main(){
	int i,j;
	while(cin >> n, n){
		int sr=0,sw=0,mr=0;
		memset(dp, -1, sizeof(dp));
		for(i=0;i<n;i++){
			cin >> r >> w[i];
			sr += r;sw += w[i];
			if(mr<r){
				mr = max(mr, r);
				mi = i;
			}
		}
		if(sr-mr < mr){
			int blank = mr - (sr-mr);
			cout << mr*2 + sw - rec(0, blank) << endl;
		}else cout << sr + sw << endl;
	}
	return 0;
}

Compiler output:
a.cc:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:22:17: error: 'memset' was not declared in this scope
   22 |                 memset(dp, -1, sizeof(dp));
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdlib>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
 
int p[222];
void init(int n){ for(int i = 0; i <= n; i++) p[i] = i; }
int find(int x){ return p[x] = ( (p[x] == x)?x:find(p[x])); }
void merge(int x,int y){ p[find(x)] = find(y); }
bool same(int x,int y){ return find(x) == find(y); }
 
bool used[222];
 
int n,m;
int h[222];
vector<int> s[1111111];
int a[44444],b[44444],c[44444];
pair<int,pair<int,int> > e[44444];
int main(void){
 
  while(cin >> n >> m && n){
    int ans = 0;
    init(n);
    memset(used,false,sizeof(used));
 
    for(int i = 0; i < 1111111; i++) s[i].clear();
 
    for(int i = 0; i < n; i++){
      cin >> h[i];
      s[ h[i] ].push_back(i+1);
    }
 
    for(int i = 0; i < m; i++){
      cin >> a[i] >> b[i] >> c[i];
      e[i] = make_pair(c[i],make_pair(a[i],b[i]));
    }
    sort(e,e+m);
     
    int c = 0;
    int f = -1;
    for(int t = 1000000; t > 0; t--){
      for(int i = 0; i < (int)s[t].size(); i++){
    used[ s[t][i] ] = true;
    f++;
    c++;
flag = true;
      }
      if(flag && f > 0){
    for(int i = 0; i < m; i++){
      bool flag = false;
      int u = e[i].second.first, v = e[i].second.second;
      //cout << u << " " << v << endl;
      if(used[u] && used[v] && !same(u,v) ){
        merge(u,v);
        ans += e[i].first;
        f--;
      }
    }
    if(f > 0){
      ans = 0;
      init(n);
      f = c-1;
    }
      }
    }
    cout << ans << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:1: error: 'flag' was not declared in this scope
   49 | flag = true;
      | ^~~~
a.cc:51:10: error: 'flag' was not declared in this scope
   51 |       if(flag && f > 0){
      |          ^~~~
Language: C++

3 3
1
2
3
1 2 1
1 3 1
2 3 10
3 2
100
10000
1000000
1 2 2
1 3 3
6 6
2
3
5
7
11
13
1 3 17
3 5 19
5 1 23
2 4 29
4 6 31
6 2 37
11 16
74
25
3
39
55
18
74
55
74
3
18
1 7 200
9 1 423
2 9 205
6 2 255
2 5 123
4 2 193
2 3 200
10 2 333
2 11 256
3 10 171
4 10 512
1 2 201
8 5 314
6 7 150
11 6 257
7 9 315
20 38
412516
185397
509168
712745
966959
101213
666120
790528
275431
677098
623178
240167
4371
299088
925699
72800
121416
796859
810604
142754
13 5 1000000
3 7 991832
10 1 781938
15 8 455731
1 3 655887
1 20 604802
19 10 452912
15 5 360121
10 15 256967
9 5 682599
8 7 917302
5 18 974821
2 19 790778
17 5 298105
15 11 132405
18 19 745543
2 4 790778
1 2 790778
11 14 269668
15 4 882901
1 14 522591
15 18 424799
9 19 712540
20 5 592132
18 17 770826
19 8 592380
16 5 258739
8 4 794157
3 18 569611
7 19 340021
19 11 803293
8 18 692318
9 6 626882
20 2 592133
2 17 196463
12 14 506077
16 20 928375
12 18 894053
0 0

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 3 3
      | ^
Language: C++

# undo が出来るゲームは全て2手だけ見ればよい
ops = ["+", "*", "-", "&", "^", "|"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]


def check(x):
    # +*
    op = 0
    for c in x:
        if c in ops:
            op += 1
            if op >= 2:
                return None
        else:
            op = 0
    # +...
    for op in ops:
        if x.startswith(op):
            return None
        if ("(" + op) in x:
            return None
    # 0がないか
    zero_ok = False
    for c in x:
        if not zero_ok and c == "0":
            return None
        if c in ops:
            zero_ok = False
        elif c in numbers:
            zero_ok = True
        else:  # ( )
            zero_ok = False
    try:
        val = int(eval(x))
        return val
    except:
        return None


def get_nexts(x):
    # 削除
    result = []
    for i in range(len(x)):
        y = x[:i] + x[i + 1:]
        val = check(y)
        if val != None:
            result.append((val, y))
    # 追加
    for i in range(len(x) + 1):
        add_list = numbers + ops
        for s in add_list:
            y = x[:i] + s + x[i:]
            val = check(y)
            if val != None:
                result.append((val, y))
    return result


while True:
    n, x = input().split(" ")
    n = int(n)
    if n == 0:
        quit()
    nexts = get_nexts(x)
    if n == 1:
        nexts.sort(key=lambda a: - a[0])
        print(nexts[0][0])
        continue
    maxval = eval(x)
    tele = x
    minvals = []
    for (val, y) in nexts:
        nextss = get_nexts(y)
        nextss.sort(key=lambda a: a[0])
        minvals.append(nextss[0][0])
        if maxval < nextss[0][0]:
            maxval = nextss[0][0]
            tele = nextss[0][1]
    if n % 2 == 0:
        print(max(minvals))  # 999+9999 -> 9&99+9999
        continue
    nexts = get_nexts(tele)
    if n % 2 == 1:
        nexts.sort(key=lambda a: -a[0])
        print(nexts[0][0])
        continue



Compiler output:
a.cc:1:3: error: invalid preprocessing directive #undo
    1 | # undo が出来るゲームは全て2手だけ見ればよい
      |   ^~~~
a.cc:7:7: error: invalid preprocessing directive #+
    7 |     # +*
      |       ^
a.cc:16:7: error: invalid preprocessing directive #+
   16 |     # +...
      |       ^
a.cc:22:7: error: "0がないか" after # is not a positive integer
   22 |     # 0がないか
      |       ^~~~~~~~~
a.cc:31:16: error: stray '#' in program
   31 |         else:  # ( )
      |                ^
a.cc:41:7: error: invalid preprocessing directive #\U0000524a\U00009664
   41 |     # 削除
      |       ^~~~
a.cc:48:7: error: invalid preprocessing directive #\U00008ffd\U000052a0
   48 |     # 追加
      |       ^~~~
a.cc:80:30: error: stray '#' in program
   80 |         print(max(minvals))  # 999+9999 -> 9&99+9999
      |                              ^
a.cc:2:1: error: 'ops' does not name a type
    2 | ops = ["+", "*", "-", "&", "^", "|"]
      | ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) c.begin(),c.end()
typedef long long ll;
ll inf=1e18;
string op="*+-&^|";
inline void change(ll &x,ll y,bool A){
    if(A) x=max(x,y);
    else x=min(x,y);
}
string st;
ll factor(int& be);
ll v4(int &be){
    ll x=factor(be);
    while(st[be]=='*'){
        be++;
        ll y=factor(be);
        x*=y;
    }
    return x;
}
ll v3(int &be){
    ll x=v4(be);
    while(st[be]=='+'||st[be]=='-'){
        if(st[be]=='+'){
            be++;
            ll y=v4(be);
            x+=y;
        }else{
            be++;
            ll y=v4(be);
            x-=y;
        }
    }
    return x;
}
ll v2(int &be){
    ll x=v3(be);
    while(st[be]=='&'){
        be++;
        ll y=v3(be);
        x&=y;
    }
    return x;
}
ll v1(int &be){
    ll x=v2(be);
    while(st[be]=='^'){
        be++;
        ll y=v2(be);
        x^=y;
    }
    return x;
}
ll v0(int &be){
    ll x=v1(be);
    while(st[be]=='|'){
        be++;
        ll y=v1(be);
        x|=y;
    }
    return x;
}
ll num(int &be){
    ll x=0;
    while(isdigit(st[be])){
        x*=10;
        x+=st[be]-'0';
        be++;
    }
    return x;
}
ll factor(int &be){
    if(st[be]=='('){
        be++;
        ll x=v0(be);
        be++;
        return x;
    }
    return num(be);
}
ll dfs(string s,int cnt,bool A){
    if(cnt==0){
        st=s+"$";
        int be=0;
        return v0(be);
    }
    int N=s.size();
    ll ret=0;
    if(A) ret=-inf;
    else ret=inf;
    rep(i,N-1){ //+ op
        if(isdigit(s[i])&&isdigit(s[i+1])&&s[i+1]!='0'){
            rep(j,6){
                string ns=s.substr(0,i+1)+op[j]+s.substr(i+1);
                change(ret,dfs(ns,cnt-1,!A),A);
            }
        }
    }
    rep(i,N+1){ //+ dig
        if( (i>0&&isdigit(s[i-1])) || (i<N&&isdigit(s[i])) ){
            rep(j,10){
                if(j==0&&(i==0||!isdigit(s[i-1]))) continue; 
                string ns=s.substr(0,i)+string(1,'0'+j)+s.substr(i);
                change(ret,dfs(ns,cnt-1,!A),A);
            }
        }
    }
    rep(i,N){
        if(s[i]=='('||s[i]==')') continue;
        if(isdigit(s[i])){  //-dig
            if((i>0&&isdigit(s[i-1])) || (i+1<N&&isdigit(s[i+1]))){
                string ns=s.substr(0,i)+s.substr(i+1);
                change(ret,dfs(ns,cnt-1,!A),A);
            }
        }else{  //-op
            if(isdigit(s[i-1]&&isdigit(s[i+1]))){
                string ns=s.substr(0,i)+s.substr(i+1);
                change(ret,dfs(ns,cnt-1,!A),A);
            }
        }
    }
    return ret;
}
int main(){
    while(true){
        int N;
        string s;
        cin>>N>>s;
        if(N==0) break;
        N%=2
if(N==0) N=2;
        cout<<dfs(s,N,1)<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:132:13: error: expected ';' before 'if'
  132 |         N%=2
      |             ^
      |             ;
  133 | if(N==0) N=2;
      | ~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) c.begin(),c.end()
typedef long long ll;
ll inf=1e18;
string op="*+-&^|";
inline void change(ll &x,ll y,bool A){
    if(A) x=max(x,y);
    else x=min(x,y);
}
string st;
ll factor(int& be);
ll v4(int &be){
    ll x=factor(be);
    while(st[be]=='*'){
        be++;
        ll y=factor(be);
        x*=y;
    }
    return x;
}
ll v3(int &be){
    ll x=v4(be);
    while(st[be]=='+'||st[be]=='-'){
        if(st[be]=='+'){
            be++;
            ll y=v4(be);
            x+=y;
        }else{
            be++;
            ll y=v4(be);
            x-=y;
        }
    }
    return x;
}
ll v2(int &be){
    ll x=v3(be);
    while(st[be]=='&'){
        be++;
        ll y=v3(be);
        x&=y;
    }
    return x;
}
ll v1(int &be){
    ll x=v2(be);
    while(st[be]=='^'){
        be++;
        ll y=v2(be);
        x^=y;
    }
    return x;
}
ll v0(int &be){
    ll x=v1(be);
    while(st[be]=='|'){
        be++;
        ll y=v1(be);
        x|=y;
    }
    return x;
}
ll num(int &be){
    ll x=0;
    while(isdigit(st[be])){
        x*=10;
        x+=st[be]-'0';
        be++;
    }
    return x;
}
ll factor(int &be){
    if(st[be]=='('){
        be++;
        ll x=v0(be);
        be++;
        return x;
    }
    return num(be);
}
ll dfs(string s,int cnt,bool A){
    if(cnt==0){
        st=s+"$";
        int be=0;
        return v0(be);
    }
    int N=s.size();
    ll ret=0;
    if(A) ret=-inf;
    else ret=inf;
    rep(i,N-1){ //+ op
        if(isdigit(s[i])&&isdigit(s[i+1])&&s[i+1]!='0'){
            rep(j,6){
                string ns=s.substr(0,i+1)+op[j]+s.substr(i+1);
                change(ret,dfs(ns,cnt-1,!A),A);
            }
        }
    }
    rep(i,N+1){ //+ dig
        if( (i>0&&isdigit(s[i-1])) || (i<N&&isdigit(s[i])) ){
            rep(j,10){
                if(j==0&&(i==0||!isdigit(s[i-1]))) continue; 
                string ns=s.substr(0,i)+string(1,'0'+j)+s.substr(i);
                change(ret,dfs(ns,cnt-1,!A),A);
            }
        }
    }
    rep(i,N){
        if(s[i]=='('||s[i]==')') continue;
        if(isdigit(s[i])){  //-dig
            if((i>0&&isdigit(s[i-1])) || (i+1<N&&isdigit(s[i+1])&&s[i+1]!='0')){
                string ns=s.substr(0,i)+s.substr(i+1);
                change(ret,dfs(ns,cnt-1,!A),A);
            }
        }else{  //-op
            if(isdigit(s[i-1]&&isdigit(s[i+1]))){
                string ns=s.substr(0,i)+s.substr(i+1);
                change(ret,dfs(ns,cnt-1,!A),A);
            }
        }
    }
    return ret;
}
int main(){
    while(true){
        int N;
        string s;
        cin>>N>>s;
        if(N==0) break;
        N%=2;
        if(N==0) N=2;
        cout<<dfs(s,N,1)<<endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:135:6: error: expected '}' at end of input
  135 |     }
      |      ^
a.cc:126:11: note: to match this '{'
  126 | int main(){
      |           ^