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

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

int countR(string y){
  int c=0;
  for(int i=0;i<y.size();i++){
    if(y[i]=='R'){
      c++;
    }
  }
  return c;
}

int main(){
  int n;
  string x;
  cin>>n>>x;
  int d=countR(x);
  int fr,frc=0,fw=0;
  for(int j=0;j<n;j++){
    if(x[j]=='W'){
      fw++;
    }
    else{
      fr=i;
      break;
    }
  }
  for(int k=fr;k<n;k++){
    if(x[k]=='R'){
      frc++;
    }
    else{
      break;
    }
  }
  if(fw<=d-frc){
    cout<<d-frc<<endl;
  }
  else{
    cout<<d<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:10: error: 'i' was not declared in this scope
   25 |       fr=i;
      |          ^
Language: C++

//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin(N);

    string c;
    cin(c);

    int count =0;
    bool tf = true;

while(tf){
    for(int i =0; i < c.size(); i++){
        if(c.at(i) == W && c.at(i+1) == R)
        {
            c.at(i) = R;
            c.at(i+1) = R+1;
            count ++;
            continue;
        }
    }
}

    //vll X(N)
    //REP(i,N) cin(X.at(i));




    //出力
    cout << count << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:23: error: 'W' was not declared in this scope
   88 |         if(c.at(i) == W && c.at(i+1) == R)
      |                       ^
a.cc:88:41: error: 'R' was not declared in this scope
   88 |         if(c.at(i) == W && c.at(i+1) == R)
      |                                         ^
Language: Java

//package abc174;

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

public class D {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		
		String str = br.readLine();
		
		int ptr1 = 0;
		int ptr2 = str.length()-1;
		
		long ans = 0;
		
		while(ptr1 < ptr2) {
			if(str.charAt(ptr1) == 'W' && str.charAt(ptr2) == 'W') {
				ptr2--;
			}else if(str.charAt(ptr1) == 'R' && str.charAt(ptr2) == 'R') {
				ptr1++;
			}else if(str.charAt(ptr1) == 'W' && str.charAt(ptr2) == 'R') {
				ans++;
				ptr1++;
				ptr2--;
			}else {
				ptr1++;
				ptr2--;
			}
		}
		
		System.out.println(ans);
	}	

}


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

#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int r=0,w=0;
	for(int i=0;i<s.size();i++)
		if(s[i]=='R')
			r++;
	for(int i=0;i<s.size;i++){
		if(w>=r){
			cout<<r<<endl;
			return 0;
		}
		if(s[i]==w)
			w++;
		else
			r--;
	}
	return 0;
}

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

#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
   ll n,w=0,r=0;
cin>>n;
string s;
cin>>s;
for(ll i=0;i<n;i++) s[i]=='W'?w++:r++;
if(w==0) cout<<"0\n";
else if(w==n) cout<<"0\n";
else{
ll count=0;
for(ll i=n-w;i<n;i++) if(s[i]=='W') count++;
cout<<w-count<<"\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:2: error: expected '}' at end of input
   69 | }
      |  ^
a.cc:57:1: note: to match this '{'
   57 | {
      | ^
Language: C++

#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0;
    string s;
    cin>>s;
    string s=t;
    sort(s.begin(),s.end());
    for (int i=0; i<n; i++) ans+=(s[i]!=t[i]);
    cout<<ans/2+ans%2;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: redeclaration of 'std::string s'
   10 |     string s=t;
      |            ^
a.cc:8:12: note: 'std::string s' previously declared here
    8 |     string s;
      |            ^
a.cc:10:14: error: 't' was not declared in this scope
   10 |     string s=t;
      |              ^
Language: C++


#pragma optimization_level 3   									//Comment optimisations for an interatcive problem - use endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          	cerr<<"///REACHED///\n";
#define deb1(x)        	cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      	cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    	cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
//#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll   	N   	=  	2*MAX5;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, m, y;
string s, t;
 
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> s;
	ll i=0;
	while(i<n && s[i]=='R') i++;
	if(i == n) {
		cout<<0;return;
	}
	s = s.substr(i);
	n = s.length();

	vll w,r;
	for(ll i=0;i<n;i++) {
		if(s[i]=='W') w.pb(i);
		else r.pb(i);
	}
	reverse(all(r));

	i=0;
	while(i<w.size() && i<r.size()) {
		if(w[i] < r[i]) {
			i++;
		}
		else break;
	}
	cout<<min({i,(ll)w.size(),(ll)r.size()});
}	

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:6:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:186:14: note: called from here
  186 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~
Language: Java

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

public class Main {
    public static void main(String[] args){
        // input N
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        int ANS = 0;
        String S = sc.next();
        for (int i =0;i < N; i ++){
            if ('W' == S.charAt(i)){
                ANS += 1;
            }
        }
        String SS = S.substring(N-ANS);
        long len = SS.length();
        for(int j = 0; j < len;j++){
            if ('W' == SS.charAt(i)){
                ANS -= 1;
            }
        }
        System.out.println(ANS);
        
    }
}

Compiler output:
Main.java:16: error: incompatible types: possible lossy conversion from long to int
        String SS = S.substring(N-ANS);
                                 ^
Main.java:19: error: cannot find symbol
            if ('W' == SS.charAt(i)){
                                 ^
  symbol:   variable i
  location: class Main
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: Java

import java.util.*;

public class Main{
	public static void main(String args[]){
     	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	char[] c = sc.nextInt().toCharArray();
        int count = 0;
       int extra = 0;
      	int len = c.length;
        for(char ch: c){
            if(ch=='W')
            count++;
        }
      	for(int i =len-1;i>=len-count;i--){
            if(c[i]=='W')
            extra++;
        }
       if(count-extra < len/2)
        System.out.println(count-extra);
      else{
        System.out.println(len-count+extra);
      }
    }
}


Compiler output:
Main.java:7: error: int cannot be dereferenced
      	char[] c = sc.nextInt().toCharArray();
      	                       ^
1 error
Language: Java

import java.util.*;

public class Main{
	public static void main(String args[]){
     	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	char[] c = sc.nextInt().toCharArray();
        int count = 0;
       int extra = 0;
      	int len = c.length;
        for(char c: c){
            if(c=='W')
            count++;
        }
      	for(int i =len-1;i>=len-count;i--){
            if(c=='W')
            extra++;
        }
       if(count-extra < len/2)
        System.out.println(count-extra);
      else{
        System.out.println(len-count+extra);
      }
    }
}


Compiler output:
Main.java:7: error: int cannot be dereferenced
      	char[] c = sc.nextInt().toCharArray();
      	                       ^
Main.java:11: error: variable c is already defined in method main(String[])
        for(char c: c){
                 ^
Main.java:16: error: bad operand types for binary operator '=='
            if(c=='W')
                ^
  first type:  char[]
  second type: char
3 errors
Language: C++

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

int main() {
	// your code goes 
	long int n;
	cin>>n;
	string s;
	cin>>s;
	long int l=0,r=n-1;
	long int ans=0;
	while(1)
	{
	    while(r>=0 s[r]!='R')
	    r--;
	    while(l<n && s[l]!='W')
	    l++;
	    if(l<r)
	    {
	        ans++;
	        swap(s[l],s[r]);
	    }
	    else
	    break ;
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:23: error: expected ')' before 's'
   15 |             while(r>=0 s[r]!='R')
      |                  ~    ^~
      |                       )
a.cc:15:33: error: expected ';' before ')' token
   15 |             while(r>=0 s[r]!='R')
      |                                 ^
      |                                 ;
Language: C++

#include <iostream>
#include <cctype>
#include <string>
#include <algorithm>
using namespace std;


int main(){
    string wr; cin >> wr;
    int compte =0;
    for (int i=0; i<(int)(wr.length)-1; i++){
        if ((wr[i]=='W') && (wr[i+1]=='R')){
            compte+=1;
        }    
    }
    cout << compte;
}

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

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	string s; cin >> s;
	int r_cnt = 0, w_cnt = 0;
	for (int i = 0; i <= n - 1; i++) {
		r_cnt += (s[i] == 'R')
		         w_cnt += (s[i] == 'W');
	}
	int ans = 0;
	int j = n - 1;
	while (j >= 0 and s[j] == 'W') j--;

	if (j == 0) {
		cout << 0;
		return 0;
	}
	int k = j - 1;
	for (int i = 0; i <= k; i++) {
		if (s[i] == 'W') {
			swap(s[i], s[j]);
			ans++;
			while (j >= 0 and s[j] == 'W') j--;
			if (j <= i) break;
		}
	}

	for (int i = 0; i <= j; i++) if (s[i] == 'W') s[i] = 'R', ans++;
	debug(s);
	cout << min({r_cnt, w_cnt, ans});

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:39: error: expected ';' before 'w_cnt'
   75 |                 r_cnt += (s[i] == 'R')
      |                                       ^
      |                                       ;
   76 |                          w_cnt += (s[i] == 'W');
      |                          ~~~~~
Language: C++

#include <bits/stdc++.h> 

using namespace std;

int main(){
	int t;
	string c;
	cin>>t>>c;
	vector<int> a(t,0);
	int r=0;
	for(int i=0;i<n;i++){
		if(c[i]=='R'){
			r++;
		}
		a[i]=r;
	}
	cout<<r-a[r-1];
}



Compiler output:
a.cc: In function 'int main()':
a.cc:11:23: error: 'n' was not declared in this scope
   11 |         for(int i=0;i<n;i++){
      |                       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,ans=0,mn=0,rem;
    cin>>n;
    char ch;
    int a[n+1]={0};
    for(i=1;i<=n;i++){'
    cin>>ch;
        if(ch=='R')a[i]=1,mn++;
    }
    rem=n-mn;
    for(i=1;i<=mn;i++){if(rem<=0)break;
        if(!a[i]){ans++;rem--;}
        ans+=rem;
        cout<<ans;
    return 0;
}

Compiler output:
a.cc:8:23: warning: missing terminating ' character
    8 |     for(i=1;i<=n;i++){'
      |                       ^
a.cc:8:23: error: missing terminating ' character
a.cc: In function 'int main()':
a.cc:18:2: error: expected '}' at end of input
   18 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
char a[200005];
int b[200005]={0};
int c[200005]={0};
int main()
{
    int n;
    cin >> n;
    cin >> a+1;
    for(int i=1;i<=n;i++){
        b[i]=b[i-1];
        if(a[i]=='W')
            b[i]++;
    }
    for(int i=n;i>0;i--){
        c[i]=c[i+1];
        if(a[i]=='R')
            c[i]++;
    }
    int ans = INT_MAX ;
    for(int i=1;i<=n+1;i++){
        ans = min(ans,max(b[i-1],c[i]));
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:15: error: 'INT_MAX' was not declared in this scope
   24 |     int 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 <map>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,ans=0,mn=0,rem;
    cin>>n;
    char ch;
    int a[n+1]={0};
    for(i=1;i<=n;i++){'
    cin>>ch;
        if(ch=='R')a[i]=1,mn++;
    }
    rem=n-mn;
    for(i=1;i<=mn;i++){if(rem<=0)break;
        if(!a[i])ans++;rem--;}
        ans+=rem;
        cout<<ans;
    return 0;
}

Compiler output:
a.cc:8:23: warning: missing terminating ' character
    8 |     for(i=1;i<=n;i++){'
      |                       ^
a.cc:8:23: error: missing terminating ' character
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

const int N = 200010;

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = false; c = getchar();}
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int n;
char s[N];

int main() {
    n = read(), gets(s + 1);
    int cnt = 0;
    Rep(i, 1, n) {
        if (s[i] == 'R') ++cnt;
    }
    int ans = 0;
    Rep(i, cnt + 1, n) {
        if (s[i] == 'R') ++ans;
    }
    printf("%d", ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'gets' was not declared in this scope; did you mean 'getw'?
   24 |     n = read(), gets(s + 1);
      |                 ^~~~
      |                 getw
a.cc:26:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   26 |     Rep(i, 1, n) {
      |         ^
a.cc:7:34: note: in definition of macro 'Rep'
    7 | #define Rep(i, s, e) for (re int i = s; i <= e; ++i)
      |                                  ^
a.cc:30:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   30 |     Rep(i, cnt + 1, n) {
      |         ^
a.cc:7:34: note: in definition of macro 'Rep'
    7 | #define Rep(i, s, e) for (re int i = s; i <= e; ++i)
      |                                  ^
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
#define ll long long
using namespace std;

int n;
int k;
int a[200005];

bool check(int dis)
{
    int cnt = 0;
    for(i=0; i<n; ++i){
        cnt += (a[i]-1)/dis; //这里如果a[i]是偶数，则段数减1，所以直接a[i]-1变成奇数就行
    }
    if(cnt <= k)
        return true;
    return false;
}
int main()
{
    int l = 1;
    int r = 0;
    cin>>n>>k;
    for(int i=0; i<n; ++i){
        cin>>a[i];
        r = max(r,a[i]);
    }
    while(l<=r){
        int mid = l + (r-l)/2;
        if(check(mid)){
            l = mid+1;
        }
        else
            r = mid-1;
    }
    cout<<l<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'bool check(int)':
a.cc:23:9: error: 'i' was not declared in this scope
   23 |     for(i=0; i<n; ++i){
      |         ^
Language: C

//#include<iostream>
//#include<algorithm>
//#include<queue>
//using namespace std;
//typedef __int128 int;
#define int __int128

int a[200010];

inline int read() {
    char ch = getchar();
    int f = 1;
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -f;
        ch = getchar();
    }
    int x = 0;
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * f;
}

inline void write(int x) {
    if (x < 0) {
        putchar('-');
        write(-x);
        return;
    }
    if (x < 10) {
        putchar(char(x % 10 + '0'));
        return;
    }
    write(x / 10);
    putchar(char(x % 10 + '0'));
}

int n,k;
int cal(int x){
    int ans=0;
    for(int i=1;i<=n;++i){
        if(a[i]/x>k){
            return 1e9;
        }
        ans=ans+(a[i]/x);
        if(ans>k){
            return 1e9;
        }
    }
    if(ans<0){
        return 1e9;
    }
    return ans;
}

signed main(){
    read(n),read(k);
//    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;++i){
        read(a[i]);
//        scanf("%lld",&a[i]);
    }
    int l=0,r=1e10,mid;
    while(l<=r){
        mid=(l+r)/2;
        int f=cal(mid);
        if(f>k)l=mid+1;
        else r=mid-1;
    }
    write(l);
//    printf("%lld\n",l);


}


Compiler output:
main.c: In function 'read':
main.c:11:15: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
   11 |     char ch = getchar();
      |               ^~~~~~~
main.c:1:1: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
  +++ |+#include <stdio.h>
    1 | //#include<iostream>
main.c: In function 'write':
main.c:25:9: error: implicit declaration of function 'putchar' [-Wimplicit-function-declaration]
   25 |         putchar('-');
      |         ^~~~~~~
main.c:25:9: note: include '<stdio.h>' or provide a declaration of 'putchar'
main.c:30:17: error: expected expression before 'char'
   30 |         putchar(char(x % 10 + '0'));
      |                 ^~~~
main.c:34:13: error: expected expression before 'char'
   34 |     putchar(char(x % 10 + '0'));
      |             ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef __int128 int;
//#define int __int128

int a[200010];

inline int read() {
    char ch = getchar();
    int f = 1;
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -f;
        ch = getchar();
    }
    int x = 0;
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * f;
}

inline void write(int x) {
    if (x < 0) {
        putchar('-');
        write(-x);
        return;
    }
    if (x < 10) {
        putchar(char(x % 10 + '0'));
        return;
    }
    write(x / 10);
    putchar(char(x % 10 + '0'));
}

int n,k;
int cal(int x){
    int ans=0;
    for(int i=1;i<=n;++i){
        if(a[i]/x>k){
            return 1e9;
        }
        ans=ans+(a[i]/x);
        if(ans>k){
            return 1e9;
        }
    }
    if(ans<0){
        return 1e9;
    }
    return ans;
}

signed main(){
    read(n),read(k);
//    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;++i){
        read(a[i]);
//        scanf("%lld",&a[i]);
    }
    int l=0,r=1e10,mid;
    while(l<=r){
        mid=(l+r)/2;
        int f=cal(mid);
        if(f>k)l=mid+1;
        else r=mid-1;
    }
    write(l);
//    printf("%lld\n",l);


}


Compiler output:
a.cc:5:9: error: multiple types in one declaration
    5 | typedef __int128 int;
      |         ^~~~~~~~
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | typedef __int128 int;
      |                  ^~~
a.cc: In function 'int main()':
a.cc:56:9: error: too many arguments to function 'int read()'
   56 |     read(n),read(k);
      |     ~~~~^~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
a.cc:56:17: error: too many arguments to function 'int read()'
   56 |     read(n),read(k);
      |             ~~~~^~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
a.cc:59:13: error: too many arguments to function 'int read()'
   59 |         read(a[i]);
      |         ~~~~^~~~~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
a.cc:62:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
   62 |     int l=0,r=1e10,mid;
      |               ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
//typedef pair<int,int> pii;
#define int __int128

int a[200010];

inline int read() {
    char ch = getchar();
    int f = 1;
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -f;
        ch = getchar();
    }
    int x = 0;
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * f;
}

inline void write(int x) {
    if (x < 0) {
        putchar('-');
        write(-x);
        return;
    }
    if (x < 10) {
        putchar(char(x % 10 + '0'));
        return;
    }
    write(x / 10);
    putchar(char(x % 10 + '0'));
}

int n,k;
int cal(int x){
    int ans=0;
    for(int i=1;i<=n;++i){
        if(a[i]/x>k){
            return 1e9;
        }
        ans=ans+(a[i]/x);
        if(ans>k){
            return 1e9;
        }
    }
    if(ans<0){
        return 1e9;
    }
    return ans;
}

signed main(){
    read(n),read(k);
//    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;++i){
        read(a[i]);
//        scanf("%lld",&a[i]);
    }
    int l=0,r=1e10,mid;
    while(l<=r){
        mid=(l+r)/2;
        int f=cal(mid);
        if(f>k)l=mid+1;
        else r=mid-1;
    }
    write(l);
//    printf("%lld\n",l);


}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:9: error: too many arguments to function '__int128 read()'
   56 |     read(n),read(k);
      |     ~~~~^~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
a.cc:56:17: error: too many arguments to function '__int128 read()'
   56 |     read(n),read(k);
      |             ~~~~^~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
a.cc:59:13: error: too many arguments to function '__int128 read()'
   59 |         read(a[i]);
      |         ~~~~^~~~~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
//typedef pair<int,int> pii;
#define int __int128

int a[500010];

inline int read() {
    char ch = getchar();
    int f = 1;
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -f;
        ch = getchar();
    }
    int x = 0;
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * f;
}

inline void write(int x) {
    if (x < 0) {
        putchar('-');
        write(-x);
        return;
    }
    if (x < 10) {
        putchar(char(x % 10 + '0'));
        return;
    }
    write(x / 10);
    putchar(char(x % 10 + '0'));
}

int n,k;
int cal(int x){
    int ans=0;
    for(int i=1;i<=n;++i){
        if(a[i]/x>k){
            return 1e9;
        }
        ans=ans+(a[i]/x);
        if(ans>k){
            return 1e9;
        }
    }
    if(ans<0){
        return 1e9;
    }
    return ans;
}

signed main(){
    read(n),read(k);
//    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;++i){
        read(a[i]);
//        scanf("%lld",&a[i]);
    }
    int l=0,r=1e10,mid;
    while(l<=r){
        mid=(l+r)/2;
        int f=cal(mid);
        if(f>k)l=mid+1;
        else r=mid-1;
    }
    write(l);
//    printf("%lld\n",l);


}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:9: error: too many arguments to function '__int128 read()'
   56 |     read(n),read(k);
      |     ~~~~^~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
a.cc:56:17: error: too many arguments to function '__int128 read()'
   56 |     read(n),read(k);
      |             ~~~~^~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
a.cc:59:13: error: too many arguments to function '__int128 read()'
   59 |         read(a[i]);
      |         ~~~~^~~~~~
a.cc:10:12: note: declared here
   10 | inline int read() {
      |            ^~~~
Language: C++

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

int main(){
  int N,K;cin>>N>>K;
  vector<long> A(N);
  for( i=0;i<N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  long left=1;
  long right=A.at(N-1);
  while(left<right){
    long X=(left+right)/2;
    long ans=0;
    for(int i=0;i<N;i++) ans+=A.at(i)/X;
    if(X>K) left=X+1;
    else right=X;
  }
  cout<<right<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: 'i' was not declared in this scope
    7 |   for( i=0;i<N;i++) cin>>A.at(i);
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long a[200005],n,k;
bool check(int m) {
	int sl=0;
	for(int i=1; i&lt; =n; i++) {
		sl=sl+(a[i]/m);
		if(a[i]%m==0) sl--;
	}
	return (sl&lt; =k);
}
int main() {
	long dau=1,cuoi,giua,M;
	cin>>n>>k;
	for(int i=1; i&lt; =n; i++) {
		cin>>a[i];
		cuoi=max(cuoi,a[i]);
	}
	while(dau&lt; =cuoi) {
		giua=(dau+cuoi)/2;
		if(check(giua)==true) {
			M=giua;
			cuoi=giua-1;
		} else dau=giua+1;
	}
	cout&lt;
	&lt;
	M;
}


Compiler output:
a.cc: In function 'bool check(int)':
a.cc:6:24: error: 'lt' was not declared in this scope
    6 |         for(int i=1; i&lt; =n; i++) {
      |                        ^~
a.cc:6:28: error: expected primary-expression before '=' token
    6 |         for(int i=1; i&lt; =n; i++) {
      |                            ^
a.cc:6:30: error: expected ')' before ';' token
    6 |         for(int i=1; i&lt; =n; i++) {
      |            ~                 ^
      |                              )
a.cc:6:32: error: 'i' was not declared in this scope
    6 |         for(int i=1; i&lt; =n; i++) {
      |                                ^
a.cc:10:20: error: 'lt' was not declared in this scope
   10 |         return (sl&lt; =k);
      |                    ^~
a.cc:10:22: error: expected ')' before ';' token
   10 |         return (sl&lt; =k);
      |                ~     ^
      |                      )
a.cc:10:24: error: expected primary-expression before '=' token
   10 |         return (sl&lt; =k);
      |                        ^
a.cc: In function 'int main()':
a.cc:15:24: error: 'lt' was not declared in this scope
   15 |         for(int i=1; i&lt; =n; i++) {
      |                        ^~
a.cc:15:28: error: expected primary-expression before '=' token
   15 |         for(int i=1; i&lt; =n; i++) {
      |                            ^
a.cc:15:30: error: expected ')' before ';' token
   15 |         for(int i=1; i&lt; =n; i++) {
      |            ~                 ^
      |                              )
a.cc:15:32: error: 'i' was not declared in this scope
   15 |         for(int i=1; i&lt; =n; i++) {
      |                                ^
a.cc:19:19: error: 'lt' was not declared in this scope
   19 |         while(dau&lt; =cuoi) {
      |                   ^~
a.cc:19:21: error: expected ')' before ';' token
   19 |         while(dau&lt; =cuoi) {
      |              ~      ^
      |                     )
a.cc:19:23: error: expected primary-expression before '=' token
   19 |         while(dau&lt; =cuoi) {
      |                       ^
a.cc:26:14: error: 'lt' was not declared in this scope
   26 |         cout&lt;
      |              ^~
Language: C++

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

int main() {
  int l = 1, r = 0, n, k;

  cin >> n >> k;

  vector<int> a(n,0);
  
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    r = max(r, a[i]);
  }

  while(r > l) {
    int x = l + (r - l) / 2;

    for(int i = 0; i < n; i++)
      c += (a[i] - 1) / x;
    
    if(c <= k)
      r = x;
    else
      l = x + 1;
  }

  cout << r;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:7: error: 'c' was not declared in this scope
   20 |       c += (a[i] - 1) / x;
      |       ^
a.cc:22:8: error: 'c' was not declared in this scope
   22 |     if(c <= k)
      |        ^
Language: C++

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

int main(){
    
    long long int i, N, K, min, max, mid, cut;
    cin >> N >> K;
    
    vector<long long int> A(N);
    
    for (i = 0; i < N; i++){
        cin >> A[i];
    }
    
    qsort(A.begin(), A.end());
    
    min = 0;
    max = A[N - 1];
    
    while(max - min > 1){
        
        mid = (min + max) / 2;
        cut = 0;
        
        for (i = 0; i < N; i++){
            cut += A[i] / mid;
        }
        
        if (cut > K){
            min = mid;
        } else {
            max = mid;
        }
        
    }
    
    cout << max << "\n";

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: cannot convert 'std::vector<long long int>::iterator' to 'void*'
   18 |     qsort(A.begin(), A.end());
      |           ~~~~~~~^~
      |                  |
      |                  std::vector<long long int>::iterator
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:970:26: note:   initializing argument 1 of 'void qsort(void*, size_t, size_t, __compar_fn_t)'
  970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
      |                    ~~~~~~^~~~~~
Language: C++

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

int main(){
    
    long long int i, N, K, min, max, mid, cut;
    cin >> N >> K;
    
    vector<long long int> A(N);
    
    for (i = 0; i < N; i++){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    
    min = 0;
    max = A[N - 1];
    
    while(max - min > 1){
        
        mid = (min + max) / 2;
        cut = 0;
        
        for (i = 0; i < N; i++){
            cut += A[i] / mid;
        }
        
        if (cut > K){
            min = mid;
        } else {
            max = mid;
        }
        
    }
    
    cout << max << "\n";

    return 0;
}



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

#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <stack>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

void printVP(vector<pair<long long int,long long int>> vec_of_pairs);
void printV(vector<int> vec);
void printVVI(vector<vector<int>> vec);
void printMapSP(map<string,pair<int,int>> mp);
void printPQ(priority_queue<int> pq);
void printVC(vector<char> vec);
void printCurrMap(map<char,set<char>> mp);

int K, ans;
vi all_a;

bool can_get_height_with_less_cuts_than_k(int height){
    int tot_num_cuts = 0;
    for(int i=0;i<all_a.size();i++){
        int num_curr_cuts = ceil((all_a[i]*1.0)/height - 1);
        tot_num_cuts += num_curr_cuts;
//        cout<<num_curr_cuts<<" "<<height<<" "<<all_a[i]<<endl;
    }
//    cout<<"Total: "<<tot_num_cuts<<" "<<height<<endl;

    if(tot_num_cuts > K)
        return false;
    else
        return true;
}


//Inclusive of heights
void binary_search(int lower_height, int upper_height){
//    cout<<lower_height<<" "<<upper_height<<endl;

    if(upper_height - lower_height == 1) {
        if(can_get_height_with_less_cuts_than_k(lower_height))
            ans = lower_height;
        else
            ans = upper_height;

        return;
    }

    int mid = (upper_height + lower_height)/2;

    if(can_get_height_with_less_cuts_than_k(mid))
        // Then try do more cuts
        upper_height = mid;
    else
        lower_height = mid;

    binary_search(lower_height, upper_height);
}

void solve(){
    int N, Ai, max_Ai;
    cin>>N>>K;

    max_Ai = -1;

    for(int i=0;i<N;i++){
        cin>>Ai;
        all_a.push_back(Ai);
        if(Ai > max_Ai)
            max_Ai = Ai;
    }

    binary_search(1, max_Ai);

    cout<<ans<<endl;
}

int main(){
    int t;
//    cin>>t;
    t = 1;
    for(int i=0;i<t;i++){
//        cout<<"Case #"<<i+1<<": ";
        solve();
    }
    return 0;
}

Compiler output:
a.cc:25:6: error: variable or field 'printPQ' declared void
   25 | void printPQ(priority_queue<int> pq);
      |      ^~~~~~~
a.cc:25:14: error: 'priority_queue' was not declared in this scope
   25 | void printPQ(priority_queue<int> pq);
      |              ^~~~~~~~~~~~~~
a.cc:10:1: note: 'std::priority_queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    9 | #include <stack>
  +++ |+#include <queue>
   10 | 
a.cc:25:29: error: expected primary-expression before 'int'
   25 | void printPQ(priority_queue<int> pq);
      |                             ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int n,k;
vector<int> a;

bool ok(int md){
	int cnt = 0;
	for(int  i = 0; i < n; i++){
		cnt += (a[i] - 1) / md;
	}
	return cnt <= k;3 0
3 4 5

}

int main(){
	cin >> n >> k;
	a.resize(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int low = 0;
	int high = 1e9;
	int ans = 1e9;
	while(low <= high){
		int md = (low + high) / 2;
		if(ok(md)){
			high = md - 1;
			ans = min(ans,md);
		}else{
			low = md + 1;
		}
	}
	cout << ans << "\n";
	return 0;
}


Compiler output:
a.cc: In function 'bool ok(int)':
a.cc:15:26: error: expected ';' before numeric constant
   15 |         return cnt <= k;3 0
      |                          ^~
      |                          ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 200000;
ll mod = INF;

int n,k;
ll a[maxn];
ll ans=INF;

int main(){

    cin >> n>>k;

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

    sort(a,a+n);
    ll l=0,r=a[n-1];
    int idx=0;
    while(idx<30){
        bool key=false;
        ll mid=(l+r)/2.0;
        //cout << l<<" "<<r<<" "<<mid<<" ";
        priority_queue<ll> que;
        for(int i=n-1;i>=0;i--){
          if(a[i]>mid)que.push(a[i]);
        }

        for(int i=0;i<k;i++){
            if(que.empty()){
                key=true;
                break;
            }
            ll arg=que.top();que.pop();
            if(arg<=mid){
                break;
            }else{
                ll h1=arg/2;
                ll h2=arg-h1;
                if(h1>arg)que.push(h1);
                if(h2>arg)que.push(h2);
            }
        }
        if(!key&&!que.empty()&&que.top<=mid)key=true;

        if(key){
            ans=min(ans,mid);
            //cout << ans<<endl;
            r=mid;
        }else{
            //cout <<endl;
            l=mid;
        }
idx++;
    }

    if(k==0)ans=a[n-1];
    //cout << ans<<endl;
    cout << (ll)ans<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:36: error: invalid use of member function 'std::priority_queue<_Tp, _Sequence, _Compare>::const_reference std::priority_queue<_Tp, _Sequence, _Compare>::top() const [with _Tp = long long int; _Sequence = std::vector<long long int, std::allocator<long long int> >; _Compare = std::less<long long int>; const_reference = const long long int&]' (did you forget the '()' ?)
   47 |         if(!key&&!que.empty()&&que.top<=mid)key=true;
      |                                ~~~~^~~
      |                                       ()
Language: C++

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

int main(void)
{
    int N,K; cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i < N; ++i) cin >> A[i];
    
    int left = 0;
    int right = *max_element(A.begin(), A.end());

    while (right - left > 1){
        int mid = (left + right) /2;
        long long jk = 0;
        for(int j=0; j < N; j++){
            jk += A[j] / mid - 1;
            if(A[j] % mid != 0) jk++;
        }
        if(jk <= K) right = mid;
        else left = mid;
    }

    cout << right <<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:24:26: error: expected '}' at end of input
   24 |     cout << right <<endl;
      |                          ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

// AtCoder template
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

ll f(vector<ll> &a, ll x){
    int n = a.size();
    ll ret = 0LL;
    rep(i,n) ret += a[i]/x;
    return ret;
}

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

    int n; ll k; cin >> n >> k;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());

    ll left = 0, right = a[0], mid;
    
    while(abs(left - right) > 1){
        mid = (left + right)>>1;
        if(f(a, mid) <= k) right = mid; // ok
        else left = mid; // false
    }

    cout << roundup(mid) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:13: error: 'roundup' was not declared in this scope; did you mean 'roundl'?
   30 |     cout << roundup(mid) << endl;
      |             ^~~~~~~
      |             roundl
Language: C++

import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector.Unboxed as Vec
import Debug.Trace as De

getIntList = map read . words <$> getLine


listToTriple abc =(a,b,c)
    where [a,b,c]=abc
main :: IO ()

fir (a,_,_)=a
sec (_,b,_)=b
trd (_,_,c)=c

canlogcut::Int->[Int]->Int ->Bool
canlogcut k as l = k >= (sum (map (\x ->  (x-1) `div` l )as) )

solve:: Int->[Int]->Int->Int ->Int
solve k as bmin bmax
    | bmin+1==bmax = bmax
    | (canlogcut k as bgen) = solve k as bmin bgen
    | otherwise = solve k as bgen bmax
        where bgen =(bmin+bmax) `div` 2


main = do
    [_,k]<-getIntList
    as<-getIntList
    putStrLn(show (solve k as 0 1000000005))



    



Compiler output:
a.cc:19:36: error: stray '\' in program
   19 | canlogcut k as l = k >= (sum (map (\x ->  (x-1) `div` l )as) )
      |                                    ^
a.cc:19:49: error: stray '`' in program
   19 | canlogcut k as l = k >= (sum (map (\x ->  (x-1) `div` l )as) )
      |                                                 ^
a.cc:19:53: error: stray '`' in program
   19 | canlogcut k as l = k >= (sum (map (\x ->  (x-1) `div` l )as) )
      |                                                     ^
a.cc:26:33: error: stray '`' in program
   26 |         where bgen =(bmin+bmax) `div` 2
      |                                 ^
a.cc:26:37: error: stray '`' in program
   26 |         where bgen =(bmin+bmax) `div` 2
      |                                     ^
a.cc:1:1: error: 'import' does not name a type
    1 | import Control.Monad
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  int upper = *max_element(a.begin(), a.end());
  int lower = 0;
  while (upper - lower > 1) {
    int mid = lower a+ (upper - lower) / 2;
    auto ok = [&](int x) {
      int cnt = 0;
      for (auto&& e : a) {
        cnt += (e - 1) / x;
      }
      return (cnt <= k);
    };
    if (ok(mid)) {
      upper = mid;
    } else {
      lower = mid;
    }
  }
  cout << upper << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:21: error: expected ',' or ';' before 'a'
   19 |     int mid = lower a+ (upper - lower) / 2;
      |                     ^
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    long K =sc.nextLong();
    double A[] =new double[N];
    for(int i=0;i<N;i++){
      A[i] =sc.nextDouble();}
    List<double> B =Arrays.asList(A);
    Collections.sort(B, Collections.reverseOrder());
    for(int i=0;i<K;i++){
      double t = B.get(0);
      t =t/2;
      B.remove(0);
      B.add(t);
      B.add(t);
       Collections.sort(B, Collections.reverseOrder());}
    double m =B.get(0);
    long n =(long)m;
    if(n==m){System.out.println(n);}
    else{System.out.println(n+1);}
  }
}

Compiler output:
Main.java:10: error: unexpected type
    List<double> B =Arrays.asList(A);
         ^
  required: reference
  found:    double
1 error