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

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

typedef long long int ll;
typedef pair<ll,ll> pll;

#define FOR(i,n,m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i,n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll d[100005];
int main()
{
while(true)
{
    ll D,N,M;
    cin>>D
if(D==0)break;
cin>>N>>M;
    d[0]=0;
    REP(i,N-1)
    {
        cin>>d[i+1];
    }
    sort(d,d+N);
    ll sum=0;
    REP(i,M)
    {
        ll k;
        cin>>k;
        int ok=0,ng=N;
        while(abs(ng-ok)>1)
        {
            int mid=(ok+ng)/2;
            if(d[mid]<=k)
            {
                ok=mid;
            }
            else
            {
                ng=mid;
            }
        }
        sum+=min(k-d[ok],abs((D+d[(ok+1)%N])-k)%D);
    }
    cout<<sum<<endl;
}
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:11: error: expected ';' before 'if'
   20 |     cin>>D
      |           ^
      |           ;
   21 | if(D==0)break;
      | ~~
Language: C++

    #include <map>  
    #include <set>  
    #include <cmath>  
    #include <queue>  
    #include <stack>  
    #include <cctype>  
    #include <cstdio>  
    #include <string>  
    #include <vector>  
    #include <cstdlib>  
    #include <cstring>  
    #include <sstream>  
    #include <iostream>  
    #include <algorithm>  
    #include <functional>  
      
    #define INF (2 << 28)  
    #define fr first  
    #define sc second  
    using namespace std;  
      
    typedef long long ll;  
    typedef pair<int, int> iP;  
      
    int n, d, m, k[100001];  
      
    int main(){  
        
      whlie(cin >> d >> n >> m, d){  
      k[0] = 0;  
      for(int i = 1; i < n; i++) cin >> k[i];  
      
      int sum = 0;  
      for(int i = 0; i < m; i++){  
        int q; cin >> q;  
        int ret = INF;  
        for(int j = 0; j < n; j++){  
          ret = min(ret, min(abs(q - k[j]), k[j] + (d - q)));  
        }  
        sum += ret;  
        // cout << sum << endl;   
      }  
      cout << sum << endl;  
       }  
    }  

Compiler output:
a.cc: In function 'int main()':
a.cc:29:7: error: 'whlie' was not declared in this scope
   29 |       whlie(cin >> d >> n >> m, d){
      |       ^~~~~
Language: C++

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



using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
int map[10][10000];//0????????????



int main(){
	while(1){
		int d,n,m;//????????¨?????????????????°?????¨???????????°
		int N[100002];
		scanf("%d",&d);
		if(d==0)break;
		scanf("%d %d",&n,&m);

		N[0]=0;
		rep(i,n-1){scanf("%d",&N[i+1]);}
		sort(N,N+n);
		N[n]=d;//??¬?????????????°??????????
		long long int ans=0;
		rep(i,m){
			int t;
			scanf("%d",&t);
			int a=lower_bound(N,N+n+1,t)-N;
			if(a==0)ans+=N[a]-t;
			else{
				if(t-N[a-1]<=N[a]-t)ans+=t-N[a-1];
				else ans+=N[a]-t;
			}
		}
		printf("%lld\n",ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: 'scanf' was not declared in this scope
   18 |                 scanf("%d",&d);
      |                 ^~~~~
a.cc:24:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |                 sort(N,N+n);
      |                 ^~~~
      |                 short
a.cc:37:17: error: 'printf' was not declared in this scope
   37 |                 printf("%lld\n",ans);
      |                 ^~~~~~
a.cc:4:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    3 | #include<queue>
  +++ |+#include <cstdio>
    4 |
Language: C++

#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ALL(a) a.begin(),a.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 
using namespace std;

void solve(){
 int D,n,m;
 for(;;){
  cin>>D;
  if(!D) break;
  cin>>n;
  cin>>m;
  int ans=0;
  vector<int> d;
  d.pb(0); d.pb(n);
  int dd;
  FOR(i,n-1){
   cin>>dd;
   d.pb(dd);
  }
  int k,ind;
  sort(ALL(d));
  FOR(i,m){
   cin>>k;
   int ind=upper_bound(ALL(d),k)-d.begin();
   int mi=1000000001;
   if(ind<d.size()) mi=min(mi,v[ind]-k);
   ind--;
   if(ind>=0) mi=min(mi,k-v[ind]);
   ans+=mi;
  }
  cout<<ans<<endl;
 }
}

int main(){
 solve();
 return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:36:31: error: 'v' was not declared in this scope
   36 |    if(ind<d.size()) mi=min(mi,v[ind]-k);
      |                               ^
a.cc:38:27: error: 'v' was not declared in this scope
   38 |    if(ind>=0) mi=min(mi,k-v[ind]);
      |                           ^
Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> vi;

#define PB push_back
#define rep(i,x) for(int i=0;i<(x);++i)
#define all(a) a.begin(),a.end()

template<typename T>T get(){T a;cin>>a;return a;}

int main()
{
	int D, N, M;
	vi d;
	while (scanf("%d", &D), D) {
		scanf("%d%d", &N, &M);
		d.resize(N + 1); d[N - 1] = 0; d[N] = D;

		rep(i, N - 1) scanf("%d", &d[i]);

		sort(all(d));

		int sum = 0;

		rep(i, M) {
			int k; scanf("%d", &k);
			int pos1 = lower_bound(all(d), k) - d.begin() - 1;
			int pos2 = lower_bound(all(d), k) - d.begin();
			if (pos1 == -1) pos1 = 0;
			sum += min(abs(k - d[pos1]), abs(k - d[pos2]));
		}

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

Compiler output:
a.cc: In function 'T get()':
a.cc:13:33: error: 'cin' was not declared in this scope
   13 | template<typename T>T get(){T a;cin>>a;return a;}
      |                                 ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <algorithm>
  +++ |+#include <iostream>
    4 |
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]){
    int d, n, m;
    vector<int> store;
    store.push_back(0);

    while (cin>>d, d){
        int ans = 0;
        cin>>n;
        cin>>m;

        for (int i = 0; i < m-1; i++){
            int s;
            cin>>s;
            store.push_back(s);
        }
        store.push_back(d);
        sort(begin(store), end(store));

        for (int i = 0; i < n; i++){
            int d;
            cin>>d;
            auto itl = lower_bound(begin(store), end(store), d);
            auto itu = itl - 1;
            ans += min(*itl - d, d - *itu);
        }

        cout<<ans<<endl;
    }

    return 0;
}

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

#include<map>
using namespace std;
#define SIZE 100002
#define QUERY 10001
int shop[SIZE];

int Bsearch(int n,int target){
  int l=0,r=n-1;
  int mid;
  while(l < r){
    mid = (r+l)/2;
    if ( shop[mid]> target){
      r=mid;
    }else if ( shop[mid]<target){
      l=mid;
    }else return 0;
    if ( l+1== r )break;
  }
  int ret1 = max(shop[mid],target)-min(shop[mid],target);
  int ret2 = max(shop[(mid+1)%n],target)-min(shop[(mid+1)%n],target);
  int ret3 = max(shop[(mid+n-1)%n],target)-min(shop[(mid+n-1)%n],target);  
  //cout << shop[mid] << " " << target << endl;
  return min(ret1,min(ret2,ret3));
}

int solve(int n,map<int,int> &M){
  map<int,int>::iterator itr = M.begin();
  int ret =0;
  while(itr != M.end()){
    ret+= Bsearch(n,(*itr).first) * (*itr).second;
    itr++;
  }
  return ret;
}

main(){
  int d,n,m;
  while(cin>>d>>n>>m && d){
    shop[0]=0;
    for(int i=1;i<n;i++){
      int tmp;
      cin>>tmp;
      shop[i]=tmp;
    }
    shop[n++]=d;
    sort(shop,shop+n);
    map<int,int> M;
    for(int i=0;i<m;i++){
      int tmp;
      cin>>tmp;
      M[tmp]++;
    }
    cout <<solve(n,M)<<endl;
    
  }
  return false;
}

Compiler output:
a.cc:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:38:9: error: 'cin' was not declared in this scope
   38 |   while(cin>>d>>n>>m && d){
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<map>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:46:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   46 |     sort(shop,shop+n);
      |     ^~~~
      |     short
a.cc:53:5: error: 'cout' was not declared in this scope
   53 |     cout <<solve(n,M)<<endl;
      |     ^~~~
a.cc:53:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:53:24: error: 'endl' was not declared in this scope
   53 |     cout <<solve(n,M)<<endl;
      |                        ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<map>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#include<cstdio>
#include<iostream>
#include<vector>

#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int mise[100002];

int main(){
	while(1){
		int d,n,m;
		sint(d);
		if(d==0)break;
		
		sintt(n,m);
		
		mise[0]=0;
		rep(i,n-1){
			sint(mise[i+1]);
		}
		
		mise[n]=d;
		n++;
		sort(mise,mise+n);
		
		int ans=0;
		rep(i,m){
			int aa;
			sint(aa);
			
			int *nn=lower_bound(mise,mise+n,aa);
			
			int kekka=min(aa-*(nn-1),*nn-aa);
			ans+=kekka;
		}
		
		
		printf("%d\n",ans);
	}
}

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

#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<algorithm>

using namespace std;

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

vector<int> mise;

int main(){
	while(1){
		int d,m,n;
		scanf("%d",&d);
		if(d==0)break;
		scanf("%d",&n);
		scanf("%d",&m);
		
		mise.clear();
		mise.push_back(0);
		mise.push_back(d);
		
		rep(i,n-1){
			int a;
			scanf("%d",&a);
			mise.push_back(a);
		}
		
		sort(mise.begin(),mise.end());
		
		int ans=0;
		
		rep(j,m){
			int a;
			scanf("%d",&a);
			int *p=lower_bound(mise.begin(),mise.end(),a);
			
			int val1,val2;
			val1=*p-a;
			val2=a-*(p-1);
			
			if(val1<0)val1*=-1;
			if(val2<0)val2*=-1;
			
			ans+=min(val1,val2);
		}
		
		printf("%d\n",ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:43: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int*' in initialization
   41 |                         int *p=lower_bound(mise.begin(),mise.end(),a);
      |                                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                           |
      |                                           __gnu_cxx::__normal_iterator<int*, std::vector<int> >
Language: C++

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

using namespace std;

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

int main(){
	while(1){
		int d,n,m;
		cin>>d;
		if(d==0)break;
		cin>>n>>m;
		
		vector<int> shop;
		shop.push_back(0);
		shop.push_back(d);
		
		rep(i,n-1){
			int a;
			cin>>a;
			shop.push_back(a);
		}
		
		sort(shop.begin(),shop.end());
		
		int ans=0;
		rep(i,m){
			int a;
			cin>>a;
			
			int *b = upper_bound(shop.begin(),shop.end(),a);
			ans += min(*b-a,a-*(b-1));
		}
		printf("%d\n",ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:45: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int*' in initialization
   38 |                         int *b = upper_bound(shop.begin(),shop.end(),a);
      |                                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                             |
      |                                             __gnu_cxx::__normal_iterator<int*, std::vector<int> >
Language: C++

#include<cstdio>
#include<vector>

using namespace std;

int main(void){
	int d;
	while(scanf("%d", &d) && d != 0){
		int S[100009];
		int n,m;
		int temp;
		int l,ls,ss;
		int ans= 0;
		
		scanf("%d%d", &n, &m);
		
		S[0] = 0;
		S[n] = d;
		
		for(int i = 1; i < n; i++){
			scanf("%d", &S[i]);
		}
		
		sort(S,S+n);
		
		for(int i = 0; i < m; i++){
			scanf("%d", &temp);
			int *mx = upper_bound(S,S+n+1,temp);
			ls = mx - S;
			ss = mx -1 -S;
//			printf("S[%d] = %d : S[%d] = %d\n", ls, S[ls], ss, S[ss]);
			
			l = min( S[ls]-temp, temp-S[ss]);
//			printf("%d\n",l);
			ans+=l;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |                 sort(S,S+n);
      |                 ^~~~
      |                 short
a.cc:28:35: error: 'upper_bound' was not declared in this scope
   28 |                         int *mx = upper_bound(S,S+n+1,temp);
      |                                   ^~~~~~~~~~~
Language: C++

#include<stdio.h>
#include<algorithm>
int*it,shop[100001],n,m,d,i;
int main(){
	for(;scanf("%d%d%d",&d,&n,&m),shop[n]=d;i=!printf("%d\n",i)){
		for(i=n;i--;)
			scanf("%d",shop+i)
		for(std::sort(shop,shop+n);m--;i+=min(*it - d, d - it[-1] ))
			scanf("%d",&d),
			it = std::upper_bound( shop, shop+n, d );
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:43: error: expected ';' before 'for'
    7 |                         scanf("%d",shop+i)
      |                                           ^
      |                                           ;
    8 |                 for(std::sort(shop,shop+n);m--;i+=min(*it - d, d - it[-1] ))
      |                 ~~~                        
a.cc:8:51: error: 'min' was not declared in this scope; did you mean 'std::min'?
    8 |                 for(std::sort(shop,shop+n);m--;i+=min(*it - d, d - it[-1] ))
      |                                                   ^~~
      |                                                   std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include<stdio.h>
#include<algorithm>
*it,shop[100001],n,m,d,i;
main(){
	for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
		for(;--i;)
			scanf("%d",shop+i);
		for(std::sort(shop,shop+n);m--;i+=std::min(*it - d, d - it[-1] ))
			scanf("%d",&d),
			it = std::upper_bound( shop, shop+n, d );
	}
}

Compiler output:
a.cc:3:4: error: expected constructor, destructor, or type conversion before ',' token
    3 | *it,shop[100001],n,m,d,i;
      |    ^
a.cc:3:17: error: expected constructor, destructor, or type conversion before ',' token
    3 | *it,shop[100001],n,m,d,i;
      |                 ^
a.cc:3:19: error: expected constructor, destructor, or type conversion before ',' token
    3 | *it,shop[100001],n,m,d,i;
      |                   ^
a.cc:3:21: error: expected constructor, destructor, or type conversion before ',' token
    3 | *it,shop[100001],n,m,d,i;
      |                     ^
a.cc:3:23: error: expected constructor, destructor, or type conversion before ',' token
    3 | *it,shop[100001],n,m,d,i;
      |                       ^
a.cc:3:25: error: expected constructor, destructor, or type conversion before ';' token
    3 | *it,shop[100001],n,m,d,i;
      |                         ^
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:5:30: error: 'd' was not declared in this scope
    5 |         for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
      |                              ^
a.cc:5:33: error: 'n' was not declared in this scope
    5 |         for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
      |                                 ^
a.cc:5:36: error: 'm' was not declared in this scope
    5 |         for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
      |                                    ^
a.cc:5:39: error: 'shop' was not declared in this scope
    5 |         for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
      |                                       ^~~~
a.cc:5:44: error: 'i' was not declared in this scope
    5 |         for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
      |                                            ^
a.cc:8:61: error: 'it' was not declared in this scope; did you mean 'int'?
    8 |                 for(std::sort(shop,shop+n);m--;i+=std::min(*it - d, d - it[-1] ))
      |                                                             ^~
      |                                                             int
Language: C++

#include<stdio.h>
#include<algorithm>
int*it,shop[100001],n,m,d;
main(i){
	for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
		for(;--i;)
			scanf("%d",shop+i);
		for(std::sort(shop,shop+n);m--;i+=std::min(*it - d, d - it[-1] ))
			scanf("%d",&d),
			it = std::upper_bound( shop, shop+n, d );
	}
}

Compiler output:
a.cc:4:5: error: expected constructor, destructor, or type conversion before '(' token
    4 | main(i){
      |     ^
Language: C++

#include<stdio.h>
#include<algorthm>
int*t,s[99999],n,m,d,i;
main(){
	for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf("%d\n",i)){
		for(;--i;)
			scanf("%d",s+i);
		for(std::sort(s,s+n);m--;i+=std::min(*t - d, d - t[-1] ))
			scanf("%d",&d),
			t = std::upper_bound( s, s+n, d );
	}
}

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

#include<stdio.h>
#include<algorithm>
int*t,,n,m,d,i,s[99999];
main(){
	for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf("%d\n",i)){
		for(;--i;)
			scanf("%d",s+i);
		for(std::sort(s,s+n);m--;i+=std::min(*t - d, d - t[-1] ))
			scanf("%d",&d),
			t = std::upper_bound( s, s+n, d );
	}
}

Compiler output:
a.cc:3:7: error: expected unqualified-id before ',' token
    3 | int*t,,n,m,d,i,s[99999];
      |       ^
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
Language: C++

#include<stdio.h>
#include<algorithm>
int*t,n,m,d,i,s[99999];
main(){
	for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf("%d\n",i)){
		for(;--i;)
			scanf("%d",s+i);
		for(std::sort(s,s+n);m--;i+=fmin(*t-d,d-t[-1]))
			scanf("%d",&d),
			t=std::upper_bound(s,s+n,d);
	}
}

Compiler output:
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:45: error: 'fmin' was not declared in this scope
    8 |                 for(std::sort(s,s+n);m--;i+=fmin(*t-d,d-t[-1]))
      |                                             ^~~~
Language: C++

#include<iostream>
#include<algo.h>
using namespace std;int*t,n,m,d,i,s[99999];main(){for(;cin>>d>>n>>m,s[i=n]=d;cout<<i<<'\n'){for(;--i;)cin>>s[i];for(sort(s,s+n);m--;t=upper_bound(s,s+n,d),i+=min(*t-d,d-t[-1]))cin>>d;}}

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

#include<iostream.h>
#include<algorithm.h>
using namespace std;
int*t,n,m,d,i,s[99999];
main(){
	for(;cin>>d>>n>>m,s[i=n]=d;cout<<i<<endl){
		for(;--i;)
			cin>>s[i];
		for(sort(s,s+n);m--;t=upper_bound(s,s+n,d),i+=min(*t-d,d-t[-1]))
			cin>>d;
	}
}

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

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
while(true) {
int d, n, m;
vector<int> s;
scanf("%d", &d);
if(d == 0)
break;
s.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d", &s[i]);
sort(s.begin(), s.end());
s.push_back(s[0] + d);
s.push_back(s[n - 1] - d);
sort(s.begin(), s.end());
int sum = 0;
for(int i = 0; i < m; ++i) {
int t;
scanf("%d", &t);
int r = lower_bound(s.begin(), s.end()) - s.begin();
l = r - 1;
sum += min(abs(s[l] - t), abs(s[r] - t));
}
printf("%d\n", sum);
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:20: error: no matching function for call to 'lower_bound(std::vector<int>::iterator, std::vector<int>::iterator)'
   25 | int r = lower_bound(s.begin(), s.end()) - s.begin();
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 2 provided
a.cc:26:1: error: 'l' was not declared in this scope
   26 | l = r - 1;
      | ^
Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
while(true) {
int d, n, m;
vector<int> s;
scanf("%d", &d);
if(d == 0)
break;
s.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d", &s[i]);
sort(s.begin(), s.end());
s.push_back(s[0] + d);
s.push_back(s[n - 1] - d);
sort(s.begin(), s.end());
int sum = 0;
for(int i = 0; i < m; ++i) {
int t;
scanf("%d", &t);
int r = lower_bound(s.begin(), s.end(), t) - s.begin();
l = r - 1;
sum += min(abs(s[l] - t), abs(s[r] - t));
}
printf("%d\n", sum);
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:1: error: 'l' was not declared in this scope
   26 | l = r - 1;
      | ^
Language: C++

#include <iostream>

using namespace std;

int main()
{
	int dp[10000],to,store[100000];
	int d,n,m,minsum,prmin,x;

	cin >> d;
	while(d != 0){
		cin >> n >> m;

		store[0] = 0;
		for(int i = 1; i < n; i++){
			cin >> store[i];
		}
		minsum = 0;
		for(int i = 0; i < m; i++){
			cin >> to;
			prmin = INT_MAX;
			for(int j = 0; j < n; j++){
				x = to - store[j];
				if(x < 0){
					x *= -1;
				}
				x = min(x,d-x);
				prmin = min(prmin,x);
			}
			minsum += prmin;
		}
		cout << minsum << endl;

		cin >> d;
	}


	return 0;
}

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

#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <cstdlib>
using namespace std;

int D,N,M,K;
int in;

int main(void)
{
	
	while(cin >> D, D){
		static vector<long> d,k;
		static vector<long> pos;

		cin >> N >> M;

		d.push_back(0);
		d.push_back(0);
		for(int i = 0; i < N-1; i++){
			cin >> in;
			d.push_back(in);
		}
		d.push_back(D);
		d.push_back(D);

		sort(d.begin(), d.end() );
		for(int i = 0; i < M; i++){
			cin >> in;
			k.push_back(in);
		}

		long sum = 0;

		for(int i = 0; i < M; i++){
			long pos = (long)(lower_bound(d.begin(), d.end(), k[i] ) - d.begin());
			long ans = miin( min( abs(d[pos]-k[i]), abs(d[pos-1]-k[i]) ), abs(d[pos+1]-k[i]) );
			sum += ans;;
		}
		cout << sum << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:36: error: 'miin' was not declared in this scope; did you mean 'main'?
   39 |                         long ans = miin( min( abs(d[pos]-k[i]), abs(d[pos-1]-k[i]) ), abs(d[pos+1]-k[i]) );
      |                                    ^~~~
      |                                    main
Language: C++

#include<vector>
#include<algorithm>
using namespace std;

int froms[100002];
int D, N, M;

int main()
{
 loop:
  cin >> D;
  if(!D)
    return 0;
  cin >> N >> M;
  froms[0] = 0;
  for(int i = 1; i < N; i++)
  {
    int d;
    cin >> d;
    froms[i] = d;
  }
  froms[N] = D;
  sort(froms, froms + N + 1);

  int ans = 0;
  for(int i = 0; i < M; i++)
  {
    int k;
    cin >> k;
    int *p = lower_bound(froms, froms + N + 1, k);
    int *p2 = p - 1;
    ans += min(*p - k, k - *p2);
  }
  cout << ans << endl;
  goto loop;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'cin' was not declared in this scope
   11 |   cin >> D;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:34:3: error: 'cout' was not declared in this scope
   34 |   cout << ans << endl;
      |   ^~~~
a.cc:34:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:34:18: error: 'endl' was not declared in this scope
   34 |   cout << ans << endl;
      |                  ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<algorithm>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

#include<bits\stdc++.h>
using namespace std;
typedef pair<int ,int > pii;
typedef pair<int ,pii > pipii;

void solve();

int N,M,H,K;
int S[1010];
int now[1010];

int main()
{
    while(scanf("%d%d%d%d",&N,&M,&H,&K),N + M + H + K)
    {
        for(int i = 1; i < N + 1; i++)
        {
            scanf("%d",&S[i]);
        }
        solve();
    }
    return 0;
}

void solve()
{
    int ans = 0,mem = 0;
    vector<pii> l;
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        l.push_back(make_pair(b,a));
    }
    sort(l.begin(),l.end());
    for(int i = 1; i < N + 1; i++)
    {
        now[i] = i;
    }
    for(int i = M - 1; i >= 0; i--)
    {
        int memo = S[l[i].second];
        S[l[i].second] = S[l[i].second + 1];
        S[l[i].second + 1] = memo;
    }
    for(int i = 1; i < K + 1; i++)
    {
        ans += S[i];
    }
    for(int i = 0; i < M; i++)
    {
        int Ma = max(now[l[i].second],now[l[i].second + 1]),
            Mi = min(now[l[i].second],now[l[i].second + 1]);
        if(Mi <= K && K < Ma)
        {
            mem = max(mem,S[Mi] - S[Ma]);
        }
        int memo = now[l[i].second];
        now[l[i].second] = now[l[i].second + 1];
        now[l[i].second + 1] = memo;
    }
    printf("%d\n",ans - mem);
    return;
}

Compiler output:
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
    1 | #include<bits\stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#include<chrono>
using namespace std;
typedef long long ll;
ll a[1001];
struct A{
	ll h;//high
	ll a;//left
	ll lb,rb;//up from left,up from,right
	ll lc,rc;//down from left,down from right
	ll lv,rv;//number on vctor
};
A b[100001];
struct C{
	ll h;//high
	ll b;//number
	bool c;//left=true,right=false
};
vector<C>c[1001];
ll n,m,h,k;
struct J{
	ll u1,u2;
};
J u[100001];
bool operator<(J a,J b){return a.}
int main(){
	cin>>n>>m>>h>>k;
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	for(ll i=1;i<=m;i++)
		cin>>u[i].u1>>u[i].u2;
	sort(u+1,u+1+m);
	for(ll i=1;i<=m;i++){
		ll ai=u[i].u1,bi=u[i].u2;
		ll oi=(ll)c[ai].size(),io=(ll)c[ai+1].size();
		b[i]=A{bi,ai,-1,-1,-1,-1,oi,io};
		c[ai].push_back(C{bi,i,true});
		c[ai+1].push_back(C{bi,i,false});
	}
	for(ll i=1;i<=n;i++){
		ll d=i;
		ll e=-1;
		while(e + 1 != c[d].size()) {
			
		}
	}
}

Compiler output:
a.cc: In function 'bool operator<(J, J)':
a.cc:37:34: error: expected unqualified-id before '}' token
   37 | bool operator<(J a,J b){return a.}
      |                                  ^
a.cc:37:34: error: expected ';' before '}' token
   37 | bool operator<(J a,J b){return a.}
      |                                  ^
      |                                  ;
Language: C++

#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>

using namespace std;

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

	vector<pair<int,int> > y;
int main(){
	while(1){
		int n,m,h,k;
		scanf("%d%d%d%d",&n,&m,&h,&k);
		if(n==0)break;
		
		int tt[1002];
		rep(i,n){
			scanf("%d",&tt[i]);
		}
		
		y.clear();
		rep(j,m){
			int a,b;
			scanf("%d%d",&a,&b);
			y.push_back(make_pair(b,a));
		}
		
		int num[1002];
		rep(i,1002)num[i]=i;
		
		sort(y.begin(),y.end());
		
		int hav[1002];
		rep(i,m){
			swap(num[y[i].second-1],num[y[i].second]);
		}
		
		rep(i,n){
			hav[num[i]]=tt[i];
		}
		
		rep(i,1002)num[i]=i;
		
		int maxi=0;
		rep(i,m){
			swap(num[y[i].second-1],num[y[i].second]);
			int a=num[y[i].second-1];
			int b=num[y[i].second];
			
			if(a>b)swap(a,b);
			
			if(a<k && k<=b){
				int val=hav[a]-hav[b];
				if(val<0)val*=-1;
				maxi=max(maxi,val);
			}
		}
		
		int ans=0;
		rep(i,k){
			ans+=hav[i];
		}
		ans-=maxi;
		
		printf("%d\n",ans);
	}
}

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

#include <iostream>
#include <vector>
#include <set>
#include <utility>

using namespace std;
typedef pair<int, int> pii;

int main(){
        while(true){
                int n, m, h, k;
                cin >> n >> m >> h >> k;
                if(n == 0 && m == 0 && h == 0 && k == 0){ break; }
                vector<int> points(n);
                for(int i = 0; i < n; ++i){ cin >> points[i]; }
                vector<pii> lines(m);
                for(int i = 0; i < m; ++i){ cin >> lines[i].second >> lines[i].first; }
                sort(lines.begin(), lines.end());
                vector<int> dest(n);
                for(int i = 0; i < n; ++i){ dest[i] = i; }
                set<pii> swapTable;
                for(int i = 0; i < m; ++i){
                        swap(dest[lines[i].second - 1], dest[lines[i].second]);
                        swapTable.insert(pii(
                                min(dest[lines[i].second - 1], dest[lines[i].second]),
                                max(dest[lines[i].second - 1], dest[lines[i].second])
                        ));
                }
                vector<int> scores(n);
                for(int i = 0; i < n; ++i){ scores[dest[i]] = points[i]; }
                int sum = 0, answer = 0;
                for(int i = 0; i < k; ++i){ sum += scores[i]; }
                answer = sum;
                for(
                        set<pii>::iterator it = swapTable.begin();
                        it != swapTable.end(); ++it
                ){
                        if(it->first >= k || it->second < k){ continue; }
                        answer = min(answer, sum - scores[it->first] + scores[it->second]);
                }
                cout << answer << endl;
        }
        return 0;
}

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

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair
#define MSG(a) cout << #a << " = " << a << endl;
#define rep(i, n) for(int i = 0; i < n; i++)

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf_s("%d", &x); return x; }

const int MAX_N = 1000;

struct cross
{
	int right_num, left_num;
	int right_point, left_point;
	int r, l, h;
};

bool operator < (const cross &left, const cross &right)
{	return left.h < right.h;	}


int main()
{
	int n, m, h, k;

	while( cin >> n >> m >> h >> k && n )
	{
		int points[1005];
		vector<cross> crosses;

		rep(i, n)
			cin >> points[i];
		
		rep(i, m)
		{
			cross c;
			cin >> c.l >> c.h;
			c.r = c.l + 1;

			crosses.push_back(c);
		}

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

		
		int work[1001];

		rep(i, n)
			work[i+1] = i+1;

		rep(i, m)
		{
			crosses[i].left_num = work[crosses[i].l];
			crosses[i].right_num = work[crosses[i].r];

			swap(crosses[i].l, crosses[i].r);
		}

		int score = 0;
		rep(i, n)
			work[i + 1] = points[i];

		rep(i, k)
			score += work[i+1];

		int max = 0;
		rep(i, m)
		{
			// out of range
			if( ( crosses[i].left_num <= k && crosses[i].right_num <= k )
				|| ( crosses[i].left_num > k && crosses[i].right_num > k ) )
					continue;

			// right
			if(crosses[i].left_num <= k)
			{
				if( crosses[i].left_point >= crosses[i].right_point )
					continue;

				chmin(max, crosses[i].right_point - crosses[i].left_point);
			}

			// left
			if(crosses[i].right_num <= k)
			{
				if( crosses[i].left_point <= crosses[i].right_point )
					continue;
				
				chmin(max, crosses[i].left_point - crosses[i].right_point);
			}
		}

		cout << score - max << endl;
	}
}

Compiler output:
a.cc: In function 'int in()':
a.cc:33:19: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   33 | int in() { int x; scanf_s("%d", &x); return x; }
      |                   ^~~~~~~
      |                   scanf
Language: C++

#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int n,m,h,k;

inline long long sumk(int *score, int k){
	long long ret = 0;
	for(int i=0;i<k;i++) ret += score[i];
	return ret;
}

int main(){
	
	while(cin >> n >> m >> h >> k){
		bool edge[h-1][n-1];
		int point[n];
		int score[n];
		int work[n];
		long long ret = 1e+15;
		set<pair<int,int> > cand;
		fill((bool *)edge, (bool *)edge + (n-1)*(h-1), false);
		
		for(int i=0;i<n;i++){
			cin >> point[i];
			work[i] = i;
		}
		for(int i=0;i<m;i++){
			int x,y;
			cin >> x >> y;
			edge[y-1][x-1] = true;
		}
		for(int i=0;i<h-1;i++){
			for(int j=0;j<n-1;j++){
				if(edge[i][j]){
					cand.insert(make_pair(work[j], work[j+1]));
					swap(work[j], work[j+1]);
				}
			}
		}
		for(int i=0;i<n;i++){
			score[work[i]] = point[i];
		}
		ret = min(ret, sumk(score, k));
		
		it = cand.begin();
		while(it != cand.end()){
			swap(score[(*it).first], score[(*it).second]);
			ret = min(ret, sumk(score,k));
			swap(score[(*it).first], score[(*it).second]);
			++it;
		}
		cout << ret << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:17: error: 'it' was not declared in this scope; did you mean 'int'?
   48 |                 it = cand.begin();
      |                 ^~
      |                 int
Language: C++

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

int n,m,h,k;

vector< pair<int,int> > g[1000];
int v[1000];


short dp[1010][1010][2];
short dp2[1010][1010][2];

int dfs(int x,int y,int l){
	if( dp[x][y][l] != -1 ) return dp[x][y][l];
	
	if( y == h ) return x;
	
	if( l == 0 ){
		int ny = (*upper_bound(g[x].begin(),g[x].end(),make_pair(y,999999))).first;
		return dp[x][y][l] = dfs(x,ny,1);
	}else{
		int sw = (*lower_bound(g[x].begin(),g[x].end(),make_pair(y,-999999))).second;
		return dp[x][y][l] = dfs(x+sw,y,0);
	}
}

int dfs2(int x,int y,int l){
	if( dp2[x][y][l] != -1 ) return dp2[x][y][l];
	
	if( y == 0 ) return x;
	
	if( l == 0 ){
		int ny = (*(lower_bound(g[x].begin(),g[x].end(),make_pair(y,-999999))-1)).first;
		return dp2[x][y][l] = dfs2(x,ny,1);
	}else{
		int sw = (*lower_bound(g[x].begin(),g[x].end(),make_pair(y,-999999))).second;
		return dp2[x][y][l] = dfs2(x+sw,y,0);
	}
}



int main(){
	while(cin >> n >> m >> h >> k && n){
		
		memset(dp,-1,sizeof(dp));
		memset(dp2,-1,sizeof(dp2));
		for(int i = 0 ; i < n ; i++) g[i].push_back( make_pair(0,-2) ) , g[i].push_back( make_pair(h,-2) );
		
		
		for(int i = 0 ; i < n ; i++) cin >> v[i];	
		
		vector< pair<int,int> > e;
		for(int i = 0 ; i < m ; i++){
			int a,b;
			cin >> a >> b;
			a--;
			g[a].push_back(make_pair(b,1));
			g[a+1].push_back(make_pair(b,-1));
			e.push_back(make_pair(a,b));
		}
		for(int i = 0 ; i < n ; i++) sort(g[i].begin(),g[i].end());
		
		long long ans = 0;
		for(int i = 0 ; i < k ; i++){
			ans += v[dfs(0,i,0)];
		}
		//for(int i = 0 ; i < n ; i++) cout << dfs(i,0,0) << endl;
		long long tans = ans;
		for(int i = 0 ; i < m ; i++){
			int a = e[i].first , b = e[i].second;
			int c = dfs2(a,b,0) , d = dfs2(a+1,b,0);
			//cout << i << " " << ">" << dfs(a,b,1) << " " << dfs(a+1,b,1) << endl;
			int C = v[dfs(a,b,1)] , D = v[dfs(a+1,b,1)];
			//cout << "(" << a << "," << a+1 << ")" << " - " << b << " [" << c << "," << d << "]" << " = {" << C << "," << D << "}" << endl;
			
			long long sub = ans;
			if( c >= k && d < k){
				sub += C-D;
			}else if( d >= k && c < k){
				sub += D-C;
			}else{

			}
			//cout << "[" << a << " " << a+1 << "]" << " " <<  b << " " <<  sub << endl;
			
			//cout << sub << endl;
			tans = min(sub,tans);
		}
		cout << tans << endl;
			
	}
	
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:21:28: error: 'upper_bound' was not declared in this scope
   21 |                 int ny = (*upper_bound(g[x].begin(),g[x].end(),make_pair(y,999999))).first;
      |                            ^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:64:46: error: 'sort' was not declared in this scope; did you mean 'short'?
   64 |                 for(int i = 0 ; i < n ; i++) sort(g[i].begin(),g[i].end());
      |                                              ^~~~
      |                                              short
Language: C++

#include <cstdio>
#include <queue>
#include <vector>
int main(void){
  int n,m,h,k;
  scanf("%d%d%d%d",&n,&n,&h,&k);
  while(n!=0){
    int ten[1000]={0};
    int bo[100000]={0};
    int maps[100000][1000]={0};
    int i=0;

    priority_queue<pair<int,int> > que;
    for(i=0;i<n;i++)scanf("%d",&(ten[i]));
    pair<int,int>pa;
    for(i=0;i<m;i++){
      scanf("%d%d",&(pa.second),&(pa.first));
      que.push(pa);
    }
    for(i=0;i<m;i++){
      pa=que.top();
      bo[i]=pa.second;
      que.pop();
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   13 |     priority_queue<pair<int,int> > que;
      |     ^~~~~~~~~~~~~~
      |     std::priority_queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:496:11: note: 'std::priority_queue' declared here
  496 |     class priority_queue
      |           ^~~~~~~~~~~~~~
a.cc:13:20: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   13 |     priority_queue<pair<int,int> > que;
      |                    ^~~~
      |                    std::pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/queue:62:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:13:25: error: expected primary-expression before 'int'
   13 |     priority_queue<pair<int,int> > que;
      |                         ^~~
a.cc:15:10: error: expected primary-expression before 'int'
   15 |     pair<int,int>pa;
      |          ^~~
a.cc:17:22: error: 'pa' was not declared in this scope
   17 |       scanf("%d%d",&(pa.second),&(pa.first));
      |                      ^~
a.cc:18:7: error: 'que' was not declared in this scope
   18 |       que.push(pa);
      |       ^~~
a.cc:21:7: error: 'pa' was not declared in this scope
   21 |       pa=que.top();
      |       ^~
a.cc:21:10: error: 'que' was not declared in this scope
   21 |       pa=que.top();
      |          ^~~
Language: C++

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

pair<int,int> make_pair(int a,int b){
	pair<int,int> ret; ret.first=a; ret.second=b; return ret;
}

bool f(pair<int,int> a,pair<int,int> b){
	return a.second<=b.second;
}

int main(){
while(1){
	int n,m,h,k,sum=0,ret=2000000001;
	int s[1002]
	char a[100000+2],b[100000+2];
	char t[1005],u[1005];
	vector<pair<int,int>> vp,lis;
	scanf("%d%d%d%d",&n,&m,&h,&k);
	if(n==0)break;
	for(int i=0;i<1000;i++){t[i]=i; u[i]=i;}
	for(int i=1;i<=n;i++){
		scanf("%d",&s[i]);
		//t[i]=i;
		//u[i]=i;
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a[i],&b[i]);
		vp.push_back(make_pair(a[i],b[i]));
	}
	sort(vp.begin(),vp.end(),f);
	/*for(int i=0;i<m;i++){
		lis.push_back(make_pair(u[vp[i].first],u[vp[i].first+1]));
		int c=t[u[vp[i].first]]; t[u[vp[i].first]]=t[u[vp[i].first+1]]; t[u[vp[i].first+1]]=c;
		c=u[vp[i].first]; u[vp[i].first]=u[vp[i].first+1]; u[vp[i].first+1]=c;
	}
	for(int i=1;i<=k;i++)sum+=s[t[i]];
	ret=sum;
	//cout<<ret<<endl;
	for(int i=0;i<m;i++){
		if(lis[i].first<=k&&lis[i].second>k)ret=min(ret,sum+s[t[lis[i].second]]-s[t[lis[i].first]]);
		if(lis[i].first>k&&lis[i].second<=k)ret=min(ret,sum-s[t[lis[i].second]]+s[t[lis[i].first]]);
	}*/
	printf("%d\n",ret);
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: expected initializer before 'char'
   18 |         char a[100000+2],b[100000+2];
      |         ^~~~
a.cc:25:29: error: 's' was not declared in this scope
   25 |                 scanf("%d",&s[i]);
      |                             ^
a.cc:30:31: error: 'a' was not declared in this scope
   30 |                 scanf("%d%d",&a[i],&b[i]);
      |                               ^
a.cc:30:37: error: 'b' was not declared in this scope
   30 |                 scanf("%d%d",&a[i],&b[i]);
      |                                     ^
Language: Java

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x = 0;
		int y = 0;
		int h;
		int w;
		int n;
		int[][] route;
		while(ture){
			h = scan.nextInt();
			w = scan.nextInt();
			n = scan.nextInt();
			if(h == 0 && w == 0 && n == 0){
				break;
			}
			route = new int[h][w];
			for(int i = 0;i < h;i++){
				for(int j = 0;j < w;j++){
					route[i][j] = scan.nextInt();
				}
			}
			for(int i = 0;i < n;i++){
				x = 0;
				y = 0;
				while(x < h && y < w){
					if(route[x][y] == 0){
						route[x][y] = 1;
						x++;
					}else{
						route[x][y] = 0;
						y++;
					}
				}
			}
			System.out.println(x+1 + " " + (y+1));
		}
	}
}

Compiler output:
Main.java:12: error: cannot find symbol
		while(ture){
		      ^
  symbol:   variable ture
  location: class Main
1 error
Language: C

#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int h,w,n,i,j;
int kan[10000][10000];
int dp[10000][10000];
int main(void){
	scanf("%d %d %d",&h,&w,&n);
	while(h!=0 && w!=0 && n!=0){
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				scanf("%d",&kan[i][j]);	//kan=kanbann
				dp[i][j]=0;
			}
		}
		dp[1][1]=n-1;
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(kan[i][j]==1){
					if(dp[i][j]%2==1){
						dp[i][j+1]+=(dp[i][j]/2)+1;
						dp[i+1][j]+=(dp[i][j]/2);
					}
					else {
						dp[i][j+1]=dp[i][j]/2;
						dp[i+1][j]=dp[i][j]/2;
					}
				}
				else if(kan[i][j]==0){
					if(dp[i][j]%2==1){
						dp[i][j+1]+=(dp[i][j]/2);
						dp[i+1][j]+=(dp[i][j]/2)+1;
					}
					else {
						dp[i][j+1]=dp[i][j]/2;
						dp[i+1][j]=dp[i][j]/2;
					}
				}
			}
		}
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(dp[i][j]!=0){
					if(dp[i][j]%2==1){
						if(kan[i][j]==0){
							kan[i][j]=1;
						}
						else if(kan[i][j]==1){
							kan[i][j]=0;
						}
					}
				}
			}
		}
		i=1;
		j=1;
		//printf("%d %d\n",h,w);
		while(i<h+1 || j<w+1){
			if(kan[i][j]==1){
				j++;
			}
			else if(kan[i][j]==0){
				i++;
			}
			if(i==h+1 || j==w+1){
				break;
			}
		}
		printf("%d %d\n",i,j);	
		/*for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				printf("%d ",kan[i][j]);		
			}
			printf("\n");
		}*/
		scanf("%d &d %d\n",&h,&w,&n);
	}
	
	return 0;
}

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

#include<stdio.h>
int main(void) {
   int h, w, n, key[1005][1005], x, y, i, j, k, l;
   scanf("%d %d %d", &h, &w, &n);
   while ( 1 ) {
      for ( i = 1; i <= h + 1; i++ ) {
         for ( j = 1; j <= j + 1; j++ ) {
            scanf("%d", &[i][j]);
         }
      }
      for ( k = 0; k < n; k++ ) {
         x = y = 1;
         while () {
            if ( key[y][x] == 0 ) {
               key[y][x] = 1;
               y++;
            }
            else if ( key[y][x] == 1 ) {
               key[y][x] = 0;
               x++;
            }
            if ( x == x + 1 || y == h + 1 ) break
         }
      }
      printf("%d %d\n", x, y);
      scanf("%d %d %d", &h, &w, &n);
      if ( h == 0 && w == 0 && n == 0 ) break;
   }
   return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:26: error: expected expression before '[' token
    8 |             scanf("%d", &[i][j]);
      |                          ^
main.c:13:17: error: expected expression before ')' token
   13 |          while () {
      |                 ^
main.c:22:50: error: expected ';' before '}' token
   22 |             if ( x == x + 1 || y == h + 1 ) break
      |                                                  ^
      |                                                  ;
   23 |          }
      |          ~