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

// AOJ 1346 "Miscalculation" (ICPCアジア地区予選 2014 東京大会 Problem B)
import java.util.Scanner;

public class Main {
    static int pos = 0; // 四則演算の構文解析における現在位置
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int ansOfBob = sc.nextInt();
        
        int ansMulFirst = evalMulFirst(s);
        it ansLeftToRight = evalLeftToRight(s);
        
        if (ansOfBob == ansMulFirst && ansOfBob == ansLeftToRight) {
            System.out.println("U");
        } else if (ansOfBob == ansMulFirst) {
            System.out.println("M");
        } else if (ansOfBob == ansLeftToRight) {
            System.out.println("L");
        } else {
            System.out.println("I");
        }
    }
    
    public static int evalMulFirst(String s) {
        int ans = evalMul(s);
        while (pos < s.length()) {
            pos++;
            ans += evalMul(s);
        }
        return ans;
    }
    
    private static int evalMul(String s) {
        int ans = evalFactor(s);
        while (pos < s.length() && s.charAt(pos) == '*') {
            pos++;
            int b = evalFactor(s);
            ans *= b;
        }
        
        return ans;
    }
    
    private static int evalFactor(String s) {
        int num = s.charAt(pos) - '0';
        pos++;
        return num;
    }
    
    public static int evalLeftToRight(String s) {
        int ans = s.charAt(0) - '0'; // 最初の文字を足す
        for (int i = 1; i < s.length(); i += 2) {
            char c = s.charAt(i);
            if (c == '+') {
                ans += s.charAt(i + 1) - '0';
            } else {
                ans *= s.charAt(i + 1) - '0';
            }
        }
        
        return ans;
    }
}

Compiler output:
Main.java:13: error: cannot find symbol
        it ansLeftToRight = evalLeftToRight(s);
        ^
  symbol:   class it
  location: class Main
1 error
Language: C

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#define mem(a) memset(a,0,sizeof(a))

using namespace std;

char str[30];
int ans;
int M,L;

int main()
{
	//freopen("in.txt","r",stdin);
	while(~scanf("%s",str))
	{
	    M = 0;L = 0;
	    scanf("%d",&ans);
	    char strr[30] = "";
	    strcat(strr,str);
	    int len = strlen(str);
	    if(len == 1)
	    {
	        L = M  = str[0]-48;
	        if(ans == M&&ans != L)cout<<"M"<<endl;
	    else if(ans == L && ans != M)cout<<"L"<<endl;
	    else if(ans == L && ans == M)cout<<"U"<<endl;
	    else cout<<"I"<<endl;
	        continue;
	    }
	    for(int i = 0;i < len;i ++)
	    {
	        if(str[i] == '+')
	        {
	            int a = str[i-1]-48;
	            int b = str[i+1]-48;
	            str[i+1] = (a + b) + 48;
	        }
	        else if(str[i] == '*')
	        {
	            int a = str[i-1]-48;
	            int b = str[i+1]-48;
	            str[i+1] = (a * b);
	        }
	        if(i == len - 1)L = str[i];
	    }
	    for(int i = 0;i < len;i ++)
	    {
	        if(strr[i] == '*')
	        {
	            M+=(strr[i-1]-'0')*(strr[i+1]-'0');
	            strr[i] = strr[i-1] = strr[i + 1] = '@';
	        }
	    }
	    for(int i = 0 ;i < len;i ++)
	    {
	        if(strr[i] == '+')
	        {
	            if(strr[i-1] >= '0'&&strr[i-1]<='9')M+=(strr[i-1]-48);
	            if(strr[i+1] >= '0'&&strr[i+1]<='9')M+=(strr[i+1]-48);
	        }
	        //if(i == len -1)M = str[i];
	    }
	    //cout<<L<<"  "<<M<<endl;
	    if(ans == M&&ans != L)cout<<"M"<<endl;
	    else if(ans == L && ans != M)cout<<"L"<<endl;
	    else if(ans == L && ans == M)cout<<"U"<<endl;
	    else cout<<"I"<<endl;
	}
	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
using namespace std;
string s;
long long ans;
int cur;
long long suu(){
  string num = "";
  while(cur < s.size() && '0' <= s[cur] && s[cur] <= '9' ){
	fflush(stdout);
	num += s[cur];
	cur++;
  }

  return stoll(num);
}
long long kou(){
  long long res = suu();
  if(cur < s.size() && s[cur] == '*'){
	cur++;
	res *= kou();
  }
  return res;
}
long long siki(){
  long long res = kou();	
  if(cur < s.size() && s[cur] == '+'){
	cur++;
	res += siki()

  }
  return res;
}
long long left_siki(){
  long long res = suu();
  char op;
  while( cur < s.size() && ((op = s[cur]) == '+' || (op == '*') ) ){
	cur++;
	if(op == '+'){
	  res += suu();
	}else if(op == '*'){
	  res *=  suu();
	}
  }
  return res;
}
int main(){
  cur = 0;
  cin >> s >> ans;
  long long res1 = siki();

  cur = 0;
  long long res2 = left_siki();
  
  int flag = 0;
  if(res1 == ans){
	flag = 1;
  }
  if(res2 == ans){
	flag |= 2;
  }

  if(flag == 0)cout << "I" << endl;
  else if(flag == 3)cout << "U" << endl;
  else if(flag == 1) cout << "M" << endl;
  else if(flag == 2) cout << "L" << endl;
  
  return 0;
  
}

Compiler output:
a.cc: In function 'long long int siki()':
a.cc:32:22: error: expected ';' before '}' token
   32 |         res += siki()
      |                      ^
      |                      ;
   33 | 
   34 |   }
      |   ~
Language: C++

Last login: Wed Nov  5 19:00:32 on ttys001
Darsein-MBP:B Darsein$ emacs b.cpp &
[1] 15778
Darsein-MBP:B Darsein$ gpp b
Darsein-MBP:B Darsein$ ./b < in1
I
Darsein-MBP:B Darsein$ ./b < in2
I
Darsein-MBP:B Darsein$ ./b < in3
I
Darsein-MBP:B Darsein$ ./b < in4
I
Darsein-MBP:B Darsein$ gpp b
Darsein-MBP:B Darsein$ ./b < in1
-85 -83
I
Darsein-MBP:B Darsein$ gpp b
Darsein-MBP:B Darsein$ ./b < in1
1+2*3+4
-85 -83
I
Darsein-MBP:B Darsein$ gpp b
Darsein-MBP:B Darsein$ ./b < in1
1
-85 -83
I
Darsein-MBP:B Darsein$ gpp b
b.cpp: In function 'int main()':
b.cpp:12:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<s.size();i+=2){
                ^
b.cpp:23:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<s.size();i+=2){
                ^
Darsein-MBP:B Darsein$ ./b < in1
1
11 13
M
Darsein-MBP:B Darsein$ gpp b
b.cpp: In function 'int main()':
b.cpp:11:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<s.size();i+=2){
                ^
b.cpp:22:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<s.size();i+=2){
                ^
Darsein-MBP:B Darsein$ ./b < in1
M
Darsein-MBP:B Darsein$ ./b < in2
L
Darsein-MBP:B Darsein$ ./b < in3
U
Darsein-MBP:B Darsein$ ./b < in4
I
Darsein-MBP:B Darsein$ 

Compiler output:
a.cc:28:20: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes
   28 | b.cpp: In function 'int main()':
      |                    ^~~~~~~~~~~~
a.cc:40:20: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes
   40 | b.cpp: In function 'int main()':
      |                    ^~~~~~~~~~~~
a.cc:1:1: error: 'Last' does not name a type
    1 | Last login: Wed Nov  5 19:00:32 on ttys001
      | ^~~~
a.cc:30:16: error: 'i' does not name a type
   30 |    for(int i=1;i<s.size();i+=2){
      |                ^
a.cc:30:27: error: 'i' does not name a type
   30 |    for(int i=1;i<s.size();i+=2){
      |                           ^
Language: C++

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

int main(){
	string str;
	int n;
	cin >> str >> n;
	char x = 'x';
	int f = 0, s = 0;
	int num[10];
	bool used[10];
	rep(i,10) used[i] = false;
	char ope[10];
	for(int i = 0; i < str.size(); i++){
		if(i%2 == 0){
			num[i/2] = str[i]-'0';
		} else{
			ope[i/2] = str[i];
		}
	}
	int t = -1;
	for(int i = 0; i < str.size()/2; i++){
		if(ope[i] == '*'){
			if(t == -1){
				t = num[i]*num[i+1];
				used[i] = true;
				used[i+1] = true;
			} else{
				t *= num[i+1];
				used[i+1] = true;
			}
		} else{
			if(t != -1) f += t;
			t = -1;
		}
	}
	for(int i = 0; i < (str.size()+1)/2; i++){
		if(!used[i]) f += num[i];
	}
	for(int i = 0; i < str.size(); i++){
		if(i%2 == 0){
			if(x == 'x') s = str[i]-'0';
			if(x == '+') s += str[i]-'0';
			if(x == '*') s *= str[i]-'0';
		} else{
			x = str[i];
		}
	}
	if(s == n){
		if(f == n) cout << "U" << endl;
		else cout << "L" << endl;
	} else{
		if(f == n) cout << "M" << endl;
		else cout << "I" << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: 'i' was not declared in this scope
   12 |         rep(i,10) used[i] = false;
      |             ^
a.cc:12:9: error: 'rep' was not declared in this scope
   12 |         rep(i,10) used[i] = false;
      |         ^~~
Language: C++

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

using namespace std;
bool isM(int n,string s)
{
	vector<bool> used(s.length());
	for (int i = 0; i < s.length(); i++)
	{
		used[i] = false;
	}
	bool flag = false;
	int sum = 0;
	for (int i = 1; i < s.length(); i+= 2)
	{
		if (s[i] == '*')
		{
			if (used[i - 1])
			{
				sum *= (s[i + 1] - '0');
				used[i + 1] = true;
			}
			else
			{
				if (!flag)
				{
					sum = (s[i - 1] - '0') * (s[i + 1] - '0');
					flag = true;
				}
				else
				{
					sum += (s[i - 1] - '0') * (s[i + 1] - '0');
				}
				used[i - 1] = true;
				used[i + 1] = true;
			}
			//cout << sum << endl;
		}
	}
	for (int i = 0; i < s.length(); i += 2)
	{
		if (used[i])continue;
		sum += (s[i] - '0');
	}
	//cout << sum << endl;
	if (n == sum)return true;
	else return false;
}

bool isL(int n,string s)
{
	if (s.length() == 1 && s[0] - '0' == n)return true;
	int sum = 0;
	for (int i = 1; i < s.length(); i += 2)
	{
		if (i == 1)
		{
			if (s[i] == '+')
			{
				sum = s[i - 1] - '0' + (s[i + 1] - '0');
			}
			else
			{
				sum = (s[i - 1] - '0') * (s[i + 1] - '0');
			}
		}
		else
		{
			if (s[i] == '+')
			{
				sum += (s[i + 1] - '0');
			}
			else
			{
				sum *= (s[i + 1] - '0');
			}
		}
	}

	if (sum == n)return true;
	else return false;
}

int main()
{
	string exp;
	int n;
	cin >> exp;
	cin >> n;
	if (isM(n, exp) && isL(n, exp))
	{
		cout << "U" << endl;
	}
	else if (isM(n,exp))
	{
		cout << "M" << endl;
	}
	else if (isL(n, exp))
	{
		cout << "L" << endl;
	}
	else
	{
		cout << "I" << endl;
	}

	return 0;
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: Java


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

public class Q3 {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	public void run() {
		int n = in.nextInt(), m = in.nextInt();
		int[] array = new int[n+1];
		
		for (int i = 0; i < m; i++) {
			int c = in.nextInt(), d = in.nextInt();
			for (int j = c; j < d; j++) {
				array[j] = 1;
			}
		}
		
		int cnt = 0;
		for (int i = 0; i < n; i++)
			if (array[i] == 1) cnt++;
		
		System.out.println(cnt * 2 + n + 1);
		
		out.close();
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

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

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


struct Range{
	int s,e;
	Range(){}
	Range(int s,int e):s(s),e(e){}
	bool operator<(const Range &r)const{return e<r.e;}
};
vector<Range> merge_range(vector<Range> &r){
	vector<Range> res;
	sort(r.begin(),r.end());
	for(int i=0;i<(int)r.size();i++){
		int mi=r[i].s;
		while(!res.empty()&&r[i].s<=res.back().e){
			mi=min(mi,res.back().s);
			res.pop_back();
		}
		res.push_back(Range(mi,r[i].e));
	}
	return res;
}


int main(){
	int n,m;
	Range r[500];
	cin>>n>>m;
	rep(i,m)cin>>r[i].s>>r[i].e;
	int ans=n+1;
	vector<Range> vr(merge_range(vector<Range>(r,r+m)));
	rep(i,vr.size()){
		ans+=(vr[i].e-vr[i].s)*2;
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:38: error: cannot bind non-const lvalue reference of type 'std::vector<Range>&' to an rvalue of type 'std::vector<Range>'
   44 |         vector<Range> vr(merge_range(vector<Range>(r,r+m)));
      |                                      ^~~~~~~~~~~~~~~~~~~~
a.cc:23:42: note:   initializing argument 1 of 'std::vector<Range> merge_range(std::vector<Range>&)'
   23 | vector<Range> merge_range(vector<Range> &r){
      |                           ~~~~~~~~~~~~~~~^
Language: C++

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; int i; bool used; };
 
int MOD = 1000000007;

int main() {
	int d, n, b; cin >> d >> n >> b;
	vector<int> p(n), h(n);
	for (int i = 0; i < n; i++) cin >> p[i] >> h[i];
	double ans = FLT_MAX;
	for (int t = 1; t <= b + 1; t++) {
		double l = (double)d / t;
		double lb = 0, ub = 1000000;
		for (int k = 0; k < 100; k++) {
			double vy = (lb + ub) / 2;
			double vx = l / (vy * 2);
			bool flag = true;
			for (int i = 0; i < n; i++) {
				double x = fmod(p[i], l);
				double y = x * vy / vx - x * x / (vx * vx * 2);
				if (y < h[i]) flag = false;
			}
			if (flag) ub = vy;
			else lb = vy;
		}
		double vy = max(lb, sqrt(l / 2)), vx = l / (vy * 2);
		ans = min(ans, sqrt(vx * vx + vy * vy));
	}
	printf("%.10f\n", ans);
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:33:22: error: 'FLT_MAX' was not declared in this scope
   33 |         double ans = FLT_MAX;
      |                      ^~~~~~~
a.cc:13:1: note: 'FLT_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>'
   12 | #include <stack>
  +++ |+#include <cfloat>
   13 | #include <string>
Language: C++

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

constexpr int MAX_N = 10;

int dist, n, max_bound;
double p[MAX_N], h[MAX_N];

constexpr double EPS = 1e-8;

// ax^2 + bx + c = 0
vector<double> solve_quadratic_equation(double a, double b, double c) {
	if(abs(a) <= EPS) {
		if(abs(b) <= EPS) {
			if(abs(c) <= EPS) return {0};
			return {};
		}
		return {-c / b};
	}

	const double d = b * b - 4 * a * c;
	if(d < 0) return {};

	return {(-b - sqrt(d)) / (2 * a), (-b + sqrt(d)) / (2 * a)};
}

double calc_y(double vx, double vy, double x) {
	return - (1.0 / (2.0 * vx * vx)) * (x * x) + (vy / vx) * x;
}

double calc_vx(double x, double y, double theta) {
	const double a = (x * sin(theta) / cos(theta) - y);
	const double b = 0.0;
	const double c = - x * x / 2.0;

	double res = 0.0;
	for(const auto &e : solve_quadratic_equation(a, b, c)) {
		if(e > 0.0) {
			res = e;
			break;
		}
	}

	return res;
}

double calc_vy(double vx, double theta) {
	return vx * sin(theta) / cos(theta);
}

bool check(int bound, double theta) {
	const double jump_dist = dist / (bound + 1.0);
	const double vx = calc_vx(jump_dist, 0, theta);
	const double vy = calc_vy(vx, theta);

	for(int i = 0; i < n; ++i) {
		double s = 0.0;
		while(s + jump_dist + EPS < p[i]) {
			s += jump_dist;
		}

		if(calc_y(vx, vy, p[i] - s) + EPS < h[i]) return false;
	}
	
	return true;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	cin >> dist >> n >> max_bound;

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

	double ans = INT_MAX;
	for(int bound = 0; bound <= max_bound; ++bound) {
		double L = M_PI / 4.0, R = M_PI / 2.0;

		for(int i = 0; i < 100; ++i) {
			const double M = (L + R) / 2;

			if(check(bound, M)) {
				R = M;
			}
			else {
				L = M;
			}
		}

		const double vx = calc_vx(dist / (bound + 1.0), 0, L);
		const double vy = calc_vy(vx, L);
		ans = min(ans, vx * vx + vy * vy);
	}

	cout << sqrt(ans) << endl;

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:22: error: 'INT_MAX' was not declared in this scope
   83 |         double ans = INT_MAX;
      |                      ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <vector>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

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

struct Info{
	int x;
	long double h;
};

long double calc(long double tmp_x,long double tmp_distance){
	return sqrt(tmp_x*tmp_x + (tmp_distance/(2*tmp_x))*(tmp_distance/(2*tmp_x)));
}

int main(){

	double distance;
	int N,bounce_limit;

	scanf("%lf %d %d",&distance,&N,&bounce_limit);

	Info info[N];

	for(int i = 0; i < N ;i++){
		cin >> info[i].x >> info[i].h;
	}

	long double tmp_distance;

	long double ans = 1000000.0;
	long double left,right,m,tmp_x,max_x,tmp_y,tmp_dist,tmp_h;

	bool FLG;

	for(int b_count = 1; b_count <= bounce_limit+1; b_count++){

		tmp_distance = (double)distance/b_count;

		left = 0.0,right = DBL_MAX,m = (left+right)/2;

		while(left <= right){

			tmp_x = m;
			tmp_y = tmp_distance/(2*tmp_x);

			FLG = true;

			for(int i = 0; i < N; i++){
				tmp_dist = info[i].x;

				while(tmp_dist >= tmp_distance)tmp_dist -= tmp_distance;

				tmp_h = (tmp_y/tmp_x)*tmp_dist-1.0/(2*tmp_x*tmp_x)*(tmp_dist*tmp_dist);

				if(info[i].h > tmp_h){
					FLG = false;
					break;
				}
			}
			if(FLG){
				left = m+EPS;
			}else{
				max_x = m;
				right = m-EPS;
			}
			m = (left+right)/2;
		}

		ans = min(ans,calc(max_x,tmp_distance));

		left = 0.0,right = max_x;

		while(true){
			if(right-left < EPS){
				ans = min(ans,calc((right-left)/2,tmp_distance));
				break;
			}

			long double mid1 = left + (right-left)/3;
			long double mid2 = left + (right-left)/3*2;

			long double v_1 = calc(mid1,tmp_distance);
			long double v_2 = calc(mid2,tmp_distance);

			ans = min(ans,min(v_1,v_2));

			if(v_1 < v_2){
				right = mid2-EPS;
			}else{
				left = mid1+EPS;
			}
		}
	}

	printf("%.12Lf\n",ans);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:42: error: 'EPS' was not declared in this scope
   59 |                                 left = m+EPS;
      |                                          ^~~
a.cc:62:43: error: 'EPS' was not declared in this scope
   62 |                                 right = m-EPS;
      |                                           ^~~
a.cc:72:41: error: 'EPS' was not declared in this scope
   72 |                         if(right-left < EPS){
      |                                         ^~~
a.cc:86:46: error: 'EPS' was not declared in this scope
   86 |                                 right = mid2-EPS;
      |                                              ^~~
a.cc:88:45: error: 'EPS' was not declared in this scope
   88 |                                 left = mid1+EPS;
      |                                             ^~~
Language: C++

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

struct Info{
	int x;
	double h;
};

double  calc(double  tmp_x,double  tmp_dist){
	return sqrt(tmp_x*tmp_x + (tmp_dist/(2*tmp_x))*(tmp_dist/(2*tmp_x)));
}

int main(){

	double dist;
	int N,B;

	scanf("%lf %d %d",&dist,&N,&B);

	Info info[N];

	for(int i = 0; i < N ;i++)scanf("%d %lf",&info[i].x,&info[i].h);

	double  tmp_dist;

	double  ans = 1000000.0;
	double  left,right,m,tmp_x,max_x,tmp_y,tmp_dist,tmp_h,limit,maximize_x;

	bool FLG;

	for(int b_count = 1; b_count <= B+1; b_count++){

		tmp_dist = (double)dist/b_count;

		left = 0.0,right = DBL_MAX,m = (left+right)/2;
		max_x = 0;

		while(left <= right){

			tmp_x = m;
			tmp_y = tmp_dist/(2*tmp_x);

			FLG = true;

			for(int i = 0; i < N; i++){
				tmp_dist = info[i].x;

				while(tmp_dist >= tmp_dist)tmp_dist -= tmp_dist;

				tmp_h = (tmp_y/tmp_x)*tmp_dist-1.0/(2*tmp_x*tmp_x)*(tmp_dist*tmp_dist);

				if(info[i].h > tmp_h){
					FLG = false;
					break;
				}
			}
			if(FLG){
				max_x = max(max_x,m);
				left = m+EPS;
			}else{
				right = m-EPS;
			}
			m = (left+right)/2;
		}

		limit = tmp_dist*tmp_dist/4.0;

		left = 0.0,right = 101.0,m = (left+right)/2;

		while(left <= right){
			if(m*m*m*m > limit){
				right = m-EPS;
			}else{
				maximize_x = m;
				left = m+EPS;
			}
			m = (left+right)/2;
		}

		if(max_x >= maximize_x){
			ans = min(ans,calc(maximize_x,tmp_dist));
		}else{
			ans = min(ans,calc(max_x,tmp_dist));
		}
	}

	printf("%.12lf\n",ans);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:48: error: redeclaration of 'double tmp_dist'
   28 |         double  left,right,m,tmp_x,max_x,tmp_y,tmp_dist,tmp_h,limit,maximize_x;
      |                                                ^~~~~~~~
a.cc:25:17: note: 'double tmp_dist' previously declared here
   25 |         double  tmp_dist;
      |                 ^~~~~~~~
Language: C++

w#include<bits/stdc++.h>

using namespace std;
#define FOR(i,bg,ed) for(int i=bg;i<ed;i++)
#define REP(i,n) FOR(i,0,n)

template<typename T>
bool chmax(T& l,T r){
    bool ret = l<r;
    if(l<r)l=r;
    return ret;
}
template<typename T>
bool chmin(T& l,T r){
    bool ret = l>r;
    if(l>r)l=r;
    return ret;
}

typedef long long LL;
typedef double D;
LL d;
LL n,b;
LL p[32];
LL h[32];



D v(D vx,D vy){
    return vx*vx+vy*vy;
}
D g(D vy,D yard){
    if(vy<=0)return 1e20;
    return v(vy,yard/(2*vy)); 
}
D g(D yard){
    D lb = 0;
    D ub = 1e9;
    REP(i,100){
        const D m1 = (lb+lb+ub)/3.0;
        const D m2 = (lb+ub+ub)/3.0;
        if(g(m1,yard)<g(m2,yard)){
            ub = m2;
        }
        else{
            lb = m1;
        }
    }
    return lb;
}
D f(D m){
    D yard = d/m;
    D need = 0;
    REP(i,n){
        D x = p[i];
        while(x>yard){
            x-=yard;
        }
        D vy = (yard*h[i])
            /
            ((1.0-x/yard)*2*x);
        chmax(need,sqrt(vy));
    }
    D td = g(yard);
    if(td>=need)return g(td,yard);
    else return g(need,yard);
}

//check yard = d/m
bool check(LL m){
    REP(i,n){
        REP(j,m){
            if((j+1)*d == p[i] * m){
                return false;
            }
        }
    }
    return true;
}
        
int main(){
    D ret=1e20;
    cin>>d>>n>>b;
    REP(i,n)cin>>p[i]>>h[i];
    FOR(i,1,b+2)if(check(i)){
        chmin(ret,f(i));
    }
    cout<<fixed<<sqrt(ret)<<endl;
    return 0;
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | w#include<bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'w' does not name a type
    1 | w#include<bits/stdc++.h>
      | ^
a.cc: In function 'D f(D)':
a.cc:62:20: error: 'sqrt' was not declared in this scope
   62 |         chmax(need,sqrt(vy));
      |                    ^~~~
a.cc: In function 'int main()':
a.cc:83:5: error: 'cin' was not declared in this scope
   83 |     cin>>d>>n>>b;
      |     ^~~
a.cc:88:5: error: 'cout' was not declared in this scope
   88 |     cout<<fixed<<sqrt(ret)<<endl;
      |     ^~~~
a.cc:88:11: error: 'fixed' was not declared in this scope
   88 |     cout<<fixed<<sqrt(ret)<<endl;
      |           ^~~~~
a.cc:88:18: error: 'sqrt' was not declared in this scope
   88 |     cout<<fixed<<sqrt(ret)<<endl;
      |                  ^~~~
a.cc:88:29: error: 'endl' was not declared in this scope
   88 |     cout<<fixed<<sqrt(ret)<<endl;
      |                             ^~~~
Language: C++

#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<iostream>

using namespace std;

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

typedef pair<int,int> pii;

const int N = 55;
const int M = 111;
const int W = 111;

int n,stx,sty,m;
int a[N],b[N],c[N],d[N];
int e[M];
char f[M];

bool input(){
	cin>>n>>stx>>sty>>m;
	rep(i,n){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	rep(i,m){
		cin>>e[i]>>f[i];
	}
	
	int sum = 0;
	rep(i,m){
		e[i] *= 2;
		sum += e[i];
		e[i] = sum;
	}
	
	rep(i,n){
		a[i] *= 2;
		b[i] *= 2;
		c[i] *= 2;
		d[i] *= 2;
	}
	stx*=2;
	sty*=2;
	
	return true;
}

int visit[W][W][4];
int board[W][W];

class P{
	public:
	int x;
	int y;
	int dir;
	int count;
	P(int x,int y,int dir,int count):x(x),y(y),dir(dir),count(count){}
};

int dnum(char c){
	if(c=='N')return 0;
	if(c=='E')return 1;
	if(c=='S')return 2;
	return 3;
}
vector<pii> solve(){
	
	rep(i,W)rep(j,W)board[i][j]=1;
	rep(i,n){
		if(a[i]==c[i]){
			reps(j,min(b[i],d[i]),max(b[i],d[i])+1)board[j][a[i]]=0;
		}else{
			reps(j,min(a[i],c[i]),max(a[i],c[i])+1)board[b[i]][j]=0;
		}
	}
	
	rep(i,W)rep(j,W)rep(k,4)visit[i][j][k]=-1;
	
	queue<P> que;
	rep(i,4)que.push(P(stx,sty,i,0));
	
	int turn = -1;
	
	while(1){
		if(que.empty())break;
		
		P u = que.front();
		que.pop();
		
		if(turn != u.count){
			turn = u.count;
			rep(i,m){
				if(e[i]==turn-1){
					rep(j,W){
						rep(k,W){
							rep(p,4){
								if(p!=dnum(f[i]))visit[j][k][p]=-1;
							}
						}
					}
				}
			}
			if(turn>e[m-1])break;
		}
		if(visit[u.y][u.x][u.dir]==u.count)continue;
		visit[u.y][u.x][u.dir] = u.count;
		
		//printf("turn = %d   u.x,u.y,u.dir,u.count = %d | %d | %d | %d\n",turn,u.x,u.y,u.dir,u.count);
		
		
		int dx[] = {0,1,0,-1};
		int dy[] = {1,0,-1,0};
		
		int nx = u.x + dx[u.dir];
		int ny = u.y + dy[u.dir];
		
		if(nx<0 || ny<0 || nx>=W || ny>=W || board[ny][nx]==1)continue;
		
		rep(i,4){
			if(i != (u.dir+2)%4){
				que.push(P(nx,ny,i,u.count+1));
			}
		}
	}
	/*
		int w = 40;
		rep(i,w){
			rep(j,w){
				rep(p,4){
					if(visit[i][j][p]==-1)printf("--|");
					else printf("%2d|",visit[i][j][p]);
				}
				printf(" ");
			}puts("");
		}
		rep(i,w){
			rep(j,w)printf("%d",board[i][j]);
			puts("");
		}
	*/	
	vector<pii> ret;
	rep(i,W){
		rep(j,W){
			bool ok = false;
			rep(k,4)if(visit[i][j][k]==e[m-1])ok=true;
			if(ok)ret.push_back(pii(j/2,i/2));
		}
	}
	sort(ret.begin(),ret.end());
	return ret;
}

void call(){
	vector<pii> ans = solve();
	
	rep(i,ans.size()){
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
}

int main(){
	input();
	call();
}

Compiler output:
a.cc: In function 'std::vector<std::pair<int, int> > solve()':
a.cc:154:9: error: 'sort' was not declared in this scope; did you mean 'short'?
  154 |         sort(ret.begin(),ret.end());
      |         ^~~~
      |         short
Language: C

#include<stdio.h>
int main(void){
	int n,m,i,j,sum=0,a,b,c,sg,lg,min,anssum=0,ansb=0,past=0;
	int cost[501][501]={0},flag[501][501]={0},used[501][501]={0},gu[501],con[501];
	scanf("%d %d",&n,&m);
	i=m;
	while(i!=0){
		scanf("%d %d %d",&a,&b,&c);
		cost[a][b]=c;
		flag[a][b]=1;
		i--;
	}
	for(i=1;i<=n;i++){
		gu[i]=i;
		con[i]=0;
	}
	while(1){
		past=min;
		min=1000000;
		for(a=1;a<=n;a++){
			for(b=a+1;b<=n;b++){
				if(flag[a][b]==1&&min>cost[a][b]&&gu[a]!=gu[b]){
					min=cost[a][b];
				}
			}
		}
		for(a=1;a<=n;a++){
			for(b=a+1;b<=n;b++){
				if(min==cost[a][b]&&gu[a]!=gu[b]){
					sum+=cost[a][b];
					used[a][b]=1;
					con[a]++;
					con[b]++;
					if(gu[a]>gu[b]){
						sg=gu[b];
						lg=gu[a];
					}
					else{
						sg=gu[a];
						lg=gu[b];
					}
					for(c=1;c<=n;c++){
						if(gu[c]==lg){
							gu[c]=sg;
						}
					}
				}
			}
		}
		if(min==1000000){
			break;
		}
	}
	int tsum,sw,q[501],head,tail,qn;
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			if(used[i][j]==0||cost[i][j]>past){
				continue;
			}
			for(a=1;a<=n;a++){
				gu[a]=1;
				q[a]=0;
			}
			gu[i]=2;
			head=tail=1;
			qn=i;
			sw=0;
			while(1){
				for(b=1;b<qn;b++){
					if(flag[b][qn]==1&&gu[b]!=gu[qn]){
						gu[b]=gu[qn]=2;
						q[tail]=b;
						tail++;
					}
				}
				for(b=qn+1;b<=nb++){
					if(flag[qn][b]==1&&gu[b]!=gu[qn]){
						gu[b]=gu[qn]=2;
						q[tail]=b;
						tail++;
					}
				}
				qn=q[head];
				head++;
				if(head>tail){
					break;
				}
			}
			for(a=1;a<=n;a++){
				if(gu[a]!=2){
					sw=99;
					break;
				}
			}
			if(sw==99){
				continue;
			}
			tsum=0;
			for(a=1;a<=n;a++){
				gu[a]=a;
			}
			while(1){
				min=1000000;
				for(a=1;a<=n;a++){
					for(b=a+1;b<=n;b++){
						if(flag[a][b]==1&&min>cost[a][b]&&past>=cost[a][b]&&gu[a]!=gu[b]){
							if(a!=i||b!=j){
								min=cost[a][b];
							}
						}
					}
				}
				if(past<min){
					break;
				}
				for(a=1;a<=n;a++){
					for(b=a+1;b<=n;b++){
						if(min==cost[a][b]&&gu[a]!=gu[b]){
							if(a!=i||b!=j){
								tsum+=cost[a][b];
								if(gu[a]>gu[b]){
									sg=gu[b];
									lg=gu[a];
								}
								else{
									sg=gu[a];
									lg=gu[b];
								}
								for(c=1;c<=n;c++){
									if(gu[c]==lg){
										gu[c]=sg;
									}
								}
							}
						}
					}
				}
			}
			sw=0;
			for(a=1;a<=n;a++){
				if(gu[a]!=1){
					sw++;
					break;
				}
			}
			if(tsum>sum||sw!=0){
				anssum+=cost[i][j];
				ansb++;
			}
		}
	}
	printf("%d %d\n",ansb,anssum);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:76:47: error: 'nb' undeclared (first use in this function); did you mean 'b'?
   76 |                                 for(b=qn+1;b<=nb++){
      |                                               ^~
      |                                               b
main.c:76:47: note: each undeclared identifier is reported only once for each function it appears in
main.c:76:51: error: expected ';' before ')' token
   76 |                                 for(b=qn+1;b<=nb++){
      |                                                   ^
      |                                                   ;
Language: C++

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

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)&#160; (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)&#160; cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct Node{
	int s,t,c;
	bool operator< (Node a) const { return c < a.c; }
};

Node node[50010];
bool used[50010];

vector<pii> tree[510];
int n,m;

class UF{
	public:
		void init(int n){
			par.resize(n);
			rank.resize(n);
			rep(i,n) par[i]=i,rank[i]=0;
			return;
		}
		int find(int x){
			if(par[x]==x)
				return x;
			else
				return par[x]=find(par[x]);
		}
		void unite (int x,int y){
			x=find(x);
			y=find(y);
			if(x==y) return ;
			if(rank[x]<rank[y]){
				par[x]=y;
			}else{
				par[y]=x;
				if(rank[x]==rank[y]) rank[x]++;
			}
		}
		bool same(int x,int y){
			return find(x)==find(y);
		}
		private:	
			vi par,rank;
};

bool dfs(int v,int p,int c,int r){
	if(v==r)
		return true;
	bool ok=false;
	rep(i,tree[v].size()){
		int v2=tree[v][i].first;
		if(v2!=p){
			bool ok2=dfs(v2,v,c,r);
			if(ok2&&node[tree[v][i].second].c==c)
				used[tree[v][i].second]=false;
			ok|=ok2;
		}
	}
	return ok;
}

int main(void){
	cin >> n >> m;
	
	rep(i,m) {
		cin >> node[i].s >> node[i].t >> node[i].c;
		node[i].s--;node[i].t--;
		if(node[i].t < node[i].s) swap(node[i].s,node[i].t);
	}

	sort(node,node+m);

	UF uf;
	uf.init(n);
	
	rep(i,m){
		Node e=node[i];
		if(uf.same(e.s,e.t)){
			dfs(e.t,-1,e.c,e.s);
		}else{
			uf.unite(e.s,e.t);
			pii in; 
			in.first=e.t; in.second=i;
			tree[e.s].pb(in);
			in.first=e.s; 
			tree[e.t].pb(in);
			used[i]=true;
		}
	}
	int ai=0;
	int ac=0;
	rep(i,m){
		if(used[i]){
			ai++;
			ac+=node[i].c;
		}
	}
	cout << ai <<" "<< ac << endl;
	return 0;
}

Compiler output:
a.cc:14:14: error: '#' is not followed by a macro parameter
   14 | #define all(a)&#160; (a).begin(),(a).end()
      |              ^
a.cc:23:15: error: '#' is not followed by a macro parameter
   23 | #define dump(x)&#160; cerr << #x << " = " << (x) << endl;
      |               ^
Language: C++

#include <bits/stdc++.h>
#define maxn 50008
#define N 508
#define inf 200000000
#define PII pair<int,int>
using namespace std;
int n,m;
int father[N];
struct edge
{
    int from,to,cost;
} edg[maxn];
int v[N];
bool cmp(edge a,edge b)
{return a.cost<b.cost;}
void init()
{
    for(int i = 0;i <= n;i ++)
    {
        father[i]=i;
    }
}
int find(int x)
{
    int r = x;
    while(father[r]!=r)
    {
        r = father[r];
    }
    return r;
}
bool same(int x,int y){
    int fx = find(x),fy = find(y);
    if(fx==fy)
    {
        return true;
    }
    else
    {
        return false;
    }
}
void Union(int x,int y)
{

         father[fx] = fy;  
}
int krus1()
{
    int res = 0;
    int j = 1;
    for(int i = 1;i <= m;i ++)
    {
        if(same(edg[i].from,edg[i].to))
        {
            continue;
        }
        else
        {
            v[j] = i;
            Union(edg[i].from,edg[i].to);
            res+=edg[i].cost;
            j++;
        }
    }
    return res;
}
int krus2(int tg)
{
    int res = 0;
    int j = 1;
    for(int i = 1;i <= m;i ++)
    {
        if(i == tg)continue;
        if(same(edg[i].from,edg[i].to))
        {
            continue;
        }
        else
        {
            Union(edg[i].from,edg[i].to);
            res+=edg[i].cost;
            j++;
        }
    }
    //cout << "j=" << j << endl; 
    if(j == n)return res;
    else return inf;
}
int main()
{
   // freopen("in.txt","r",stdin);
    while(~scanf("%d%d",&n,&m))
    {
        memset(v,0,sizeof(v));
        int ans = 0;
    int sum = 0,res = 0;
    init();
    for(int i = 1;i <= m;i ++)
    {
        scanf("%d%d%d",&edg[i].from,&edg[i].to,&edg[i].cost);
    }
    sort(edg,edg+m,cmp);
    ans = krus1();
    for(int i = 1;i < n;i ++)
    {
        init();
        int ans1 = krus2(v[i]);
       // cout << ans1 << endl;
        if(ans1!=ans)
        {
            sum+=edg[v[i]].cost;
            res++;
        }
    }
    printf("%d %d\n",res,sum);
}
}
    

Compiler output:
a.cc: In function 'void Union(int, int)':
a.cc:46:17: error: 'fx' was not declared in this scope; did you mean 'x'?
   46 |          father[fx] = fy;
      |                 ^~
      |                 x
a.cc:46:23: error: 'fy' was not declared in this scope; did you mean 'y'?
   46 |          father[fx] = fy;
      |                       ^~
      |                       y
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
typedef long long int i64;
typedef pair<int, int> pint;

struct UnionFind {
    vector<int> data;
    UnionFind(int N) : data(N, -1), group(N) {}
    void init(int N) { data.assign(N, -1);}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y){
            data[x] += data[y];
            data[y] = x;
            --group;
        }
    }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]);}
    bool same(int a, int b) { return root(a) == root(b);}
};

struct Edge {
    int from, to, num;
    Edge(int f, int t, int n)
         : from(f), to(t), num(n) {}
};
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    int s_, t_, c_;
    map<int, vector<Edge>> edges;
    rep(i, M) {
        cin >> s_ >> t_ >> c_;
        --s_; --t_;
        edges[c_].push_back(Edge(s_, t_, i));
    }
    UnionFind uf(N);
    vector<pint> memo;
    for(const auto& pev: edges) { 
        rep(i, pev.second.size()) {
            Edge e = pev.second[i];
            if(uf.same(e.from, e.to)) continue;
            uf.unite(e.from, e.to);
            memo.push_back(pint(pev.first, i));
        }
    }
    int ans_num = 0, ans_cos = 0;
    UnionFind temp(N);
    for(const pint& p : memo) {
        Edge aim = edges[p.first][p.second];
        temp.init(N);
        for(const pint& e : memo)
          if(p != e) temp.unite(edges[e.first][e.second].from, edges[e.first][e.second].to);
        int ra = temp.root(aim.from), rb = temp.root(aim.to);
        bool ok = true;
        REP(i, p.second + 1, edges[p.first].size()) {
            Edge e = edges[p.first][i];
            int rf = temp.root(e.from), rt = temp.root(e.to);
            if((ra == rf && rb == rt) || (ra == rt && rb == rf)) {
                ok = false;
                continue;
            }
        }
        if(ok) { ans_num++; ans_cos += p.first;}
    }
    cout << ans_num << ' ' << ans_cos << endl;
    return 0;
}

Compiler output:
a.cc: In constructor 'UnionFind::UnionFind(int)':
a.cc:11:37: error: class 'UnionFind' does not have any field named 'group'
   11 |     UnionFind(int N) : data(N, -1), group(N) {}
      |                                     ^~~~~
a.cc: In member function 'void UnionFind::unite(int, int)':
a.cc:18:15: error: 'group' was not declared in this scope
   18 |             --group;
      |               ^~~~~
Language: Java

himport java.util.*;

class Main{

    int n, m, sz;
    char[] kakko;
    int[] a, bkt, add;

    void solve(){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        kakko = sc.next().toCharArray();

        sz = Math.max(1, (int)Math.sqrt(n) + 10);
        a = new int[n];
        bkt = new int[n/sz+10];
        add = new int[n/sz+10];
        TreeSet<Integer> set = new TreeSet<Integer>();

        for(int i=0; i<n; i++){
            if(i==0) a[i] = 1;
            else{
                if(kakko[i]=='(') a[i] = a[i-1] + 1;
                else{
                    a[i] = a[i-1] - 1;
                    set.add(i);
                }
            }
            bkt[i/sz] = Math.min(a[i], bkt[i/sz]);
        }

        for(int i=0; i<m; i++){
            int q = sc.nextInt()-1;
            int idx = 0;
            if(kakko[q]=='('){
                kakko[q] = ')';
                set.add(q);
                add(q, n, -2);
                //idx = set.higher(new Integer(-1));
                idx = set.pollFirst();
                kakko[idx] = '(';
                set.remove(idx);
                add(idx, n, 2);
            }else{
                kakko[q] = '(';
                set.remove(q);
                add(q, n, 2);
                idx = search(q);
                kakko[idx] = ')';
                add(idx, n, -2);
                set.add(idx);
            }
            //System.out.println(Arrays.toString(kakko));
            System.out.println(idx+1);
        }
    }

    void add(int start, int last, int num){
        int from = start - start%sz;
        int to = from + sz;
        for(int i=start/sz; i * sz <=last; i++){
            if(start<=from && to<=last){
                add[i] += num;
            }else{
                for(int j=Math.max(from, start); j<to && j<last; j++){
                    a[j] += num;
                }
                int min = Integer.MAX_VALUE;
                for(int j=from; j<to && j<a.length; j++){
                    min = Math.min(min, a[j]);
                }
                bkt[i] = min;
            }
            from = to;
            to += sz;
        }
    }

    int search(int f){        
        int from = f - f%sz;
        int to = from + sz;
            
        for(int i=f/sz; i>=0; i--){
            if(bkt[i]+add[i]<=1){
                for(int j=Math.min(f-1, to-1); j>=from; j--){
                    if(a[j]+add[i]==1) return j+1;
                }
            }
            to = from;
            from -= sz;
        }
        return 0;
    }

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

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
himport java.util.*;
^
1 error
Language: C

#include <cstdio>
#include <cctype>
#include <iostream>
#include <cstring>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#define Inf 0x3f3f3f3f
#define MAXN 300010
#define MAXM 150010
#define LL long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
struct node
{
    int max,l,r;
    int add;
}tr[MAXN*5];
int a[MAXN],b[MAXN],ans[MAXM];
int jsq,n,m;
char st[MAXN];
void pushup(int rt)
{
    int L=rt*2,R=rt*2+1;
    tr[rt].max=max(tr[L].max,tr[R].max);
}

void pushdown(int rt)
{
    if (tr[rt].add)
    {
        int L=rt*2,R=rt*2+1;
        int x=tr[rt].add;
        tr[L].max+=x;
        tr[R].max+=x;
        tr[L].add+=x;
        tr[R].add+=x;
        tr[rt].add=0;
    }
}

void build(int l,int r,int rt)
{
    tr[rt].l=l;tr[rt].r=r;
    tr[rt].add=0;
    if (l==r)
    {
        tr[rt].max=b[l];
        return ;
    }
    int m=(l+r)/2;
    build (lson);
    build(rson);
    pushup(rt);
}

void update(int L,int R,int val,int l,int r,int rt)
{
    //printf("%d %d\n",L,R);
    if (L==l && r==R)
    {
        tr[rt].add+=val;
        tr[rt].max+=val;
        return ;
    }
    int m=(l+r)/2;
    if (R<=m)   update(L,R,val,lson);
    else if (L>m)  update(L,R,val,rson);
    else
    {
        update(L,m,val,lson);
        update(m+1,R,val,rson);
    }
    pushup(rt);
}

int find(int x,int l,int r,int rt)
{
    int L=rt*2,R=rt*2+1;
    if (l==r) return l;
    int m=(l+r)/2;
    if (tr[L].max>=x)  return find(x,lson);
    else return find(x,rson);
}
int main()
{
    int i,j;
    while (scanf("%d%d",&n,&m)!=EOF)
    {
        scanf("%s",st);
        jsq=0;
        for (i=0; i<n; i++)
        {
            if (st[i]=='(')  a[i+1]=1;
            else a[i+1]=-1;
        }
        for (i=1; i<=n; i++)  b[i]=b[i-1]+a[i];
        build(1,n,1);
        //for (i=1; i<=20; i++) printf("%d ",tr[i].max); printf("\n");
        for (i=1; i<=m; i++)
        {
            int x;
            scanf("%d",&x);
            int d=0;
            if (a[x]==1)  d=-2;
                else d=2;
            //printf("x==%d\n",x);
            update(x,n,d,1,n,1);
            a[x]=-a[x];
            int k;
            if(d==2) k=find(2,1,n,1);
            else
            {
                for (j=1; j<=n; j++)  if (a[j]<0) break;
                k=j;
            }
            printf("%d\n",k);
            update(k,n,-d,1,n,1);
            a[k]=-a[k];
            ans[++jsq]=k;
        }
    }
    return 0;
}

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

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

int main(){
    int n,Q;
    cin>>n>>Q;
    string s;
    cin>>s;
    int c=0;
    int l=0;
    set<pair<int,int>> range;
    set<int> rp; 
    for(int i=0;i<n;i++){
        if(s[i]=='(') c++;
        else c--,rp.insert(i);
        if(c==0){
            range.insert({l,i+1});
            l=i+1;
        }
    }
    assert(c==0);
    auto swapPar=[&](int lhs,int rhs){
        rp.erase(rhs),rp.insert(lhs);
        // assert(s[lhs]=='(');
        // assert(s[rhs]==')');
        /s[lhs]=')';
        s[rhs]='(';
    };
    while(Q--){
        int q;
        cin>>q;
        q--;
        auto it=range.upper_bound(make_pair(q,n+1));
        it--;
        int l=it->first,r=it->second;
        if(s[q]==')'){
            //split
            if(l+2==r){
                assert(q==l+1);
                cout<<q+1<<"\n";
            }
            else{
                assert(s[l]=='(');                
                assert(s[l+1]=='(');                
                cout<<l+2<<"\n";
                swapPar(l+1,q);
                range.erase({l,r});
                range.insert({l,l+2});
                range.insert({l+2,r});
            }
        }
        else{
            //merge
            int leftr=*rp.begin();
            if(leftr<q){
                cout<<leftr+1<<"\n";
                swapPar(q,leftr);
                vector<pair<int,int>> tmp;
                for(auto &e:range){
                    tmp.push_back(e);
                    if(e==make_pair(l,r)) break;
                }
                for(auto &e:tmp){
                    range.erase(e);
                }
                range.insert({0,r});
            }
            else{
                cout<<q+1<<"\n";
            }
        }
    }
    return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:26:9: error: expected primary-expression before '/' token
   26 |         /s[lhs]=')';
      |         ^
Language: C++

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

typedef long long ll;
#define rep(i,j) for(i=0;i<j;i++)
#define rep_a_to(a,i,j) for(i=a;i<=j;i++)
#define rev_rep(i,j) for(i=j;i>=0;i&#8212;-)

int main()
{
  string cline;
  int n,q;
  cin>>n>>q;
  int i,j;
  //入力
  cin>>cline;

  //solve
  rep(i,q)
    {
      int flip;
      cin>>flip;
      flip--;
      if(cline[flip]=='(')
	{
	  cline[flip]=')';
	  int ans=cline.find(')',0);
	  cout<<ans+1<<endl;
	  cline[ans]='(';

	}
      else
	{
	  cline[flip]='(';
	  int cnt=0;
	  rep_a_to(flip,j,n-1)
	    {
	      if(cline[j]=='(')cnt++;
	      else cnt--;
	    }
	  int ans;
	  if(cnt>=0)
	    ans=flip;
	  else
	    ans=cline.find('(',1);
	  cout<<ans+1<<endl;
	  cline[ans]=')';
	}
    }


  return 0;
}

Compiler output:
a.cc:16:20: error: '#' is not followed by a macro parameter
   16 | #define rev_rep(i,j) for(i=j;i>=0;i&#8212;-)
      |                    ^