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

import java.util.Scanner;
 
public class Main {
    public static int N;
    public static int M;
    public static int[] p;
    public static int[] rank;
    public static int[] weight;

    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int x, int y, int w) {
        int i = findSet(x);
        int j = findSet(y);
        w -= weight[j] - weight[i];

        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
            weight[j] = w;
        } else {
            p[i] = p[j];
            weight[i] = -w;
            if(rank[i] == rank[j]){
            rank[j]++;
            }
        }	
    }
 
    public static int findSet(int i) {
       if(p[i] == i){ 
           return i;
        }else{
          return p[i] = findSet(p[i]);
        }
    }
 
    public static void DisjointSet() {
        p = new int[N];
        rank = new int[N];
        weight = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
            weight[i] = 0;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
        N = scanner.nextInt();
        M = scanner.nextInt();

        if(N==0 |M==0){
           break;
        }
 
        DisjointSet();

        for (int i = 0; i < M; i++) {
            if(scanner.next().equals("!")){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int w = scanner.nextInt();
 
            a--; b--;   
            unite(a, b, w);
            }else{
               if(same(a,b)){
                    System.out.println(weight[b] - weight[a]);
                }else{
                    System.out.println("UNKNOWN");
		}
            }
        }
       }
      
    }
}

Compiler output:
Main.java:76: error: cannot find symbol
               if(same(a,b)){
                       ^
  symbol:   variable a
  location: class Main
Main.java:76: error: cannot find symbol
               if(same(a,b)){
                         ^
  symbol:   variable b
  location: class Main
Main.java:77: error: cannot find symbol
                    System.out.println(weight[b] - weight[a]);
                                              ^
  symbol:   variable b
  location: class Main
Main.java:77: error: cannot find symbol
                    System.out.println(weight[b] - weight[a]);
                                                          ^
  symbol:   variable a
  location: class Main
4 errors
Language: Java

import java.util.Scanner;
 
public class Main {
    public static int N;
    public static int M;
    public static int[] p;
    public static int[] rank;
    public static int[] weight;

    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int x, int y, int w) {
        int i = findSet(x);
        int j = findSet(y);
        w -= weight[j] - weight[i];

        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
            weight[j] = w;
        } else {
            p[i] = p[j];
            weight[i] = -w;
            if(rank[i] == rank[j]){
            rank[j]++;
            }
        }	
    }
 
    public static int findSet(int i) {
       if(p[i] == i){ 
           return i;
        }else{
          return p[i] = findSet(p[i]);
        }
    }
 
    public static void DisjointSet() {
        p = new int[N];
        rank = new int[N];
        weight = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
            weight[i] = 0;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
        N = scanner.nextInt();
        M = scanner.nextInt();

        if(N==0 |M==0){
           break;
        }
 
        DisjointSet();

        for (int i = 0; i < M; i++) {
            if(scanner.next().equals("!")){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int w = scanner.nextInt();
 
            a--; b--;   
            unite(a, b, w);
            }else if(same(a,b)){
              System.out.println(weight[b] - weight[a]);
            }else{
              System.out.println("UNKNOWN");
	    }
           }
        }
       }
      
    }
}

Compiler output:
Main.java:85: error: class, interface, enum, or record expected
}
^
1 error
Language: Java

import java.util.Scanner;
 
public class Main {
    public static int N;
    public static int M;
    public static int[] p;
    public static int[] rank;
    public static int[] weight;

    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int x, int y, int w) {
        int i = findSet(x);
        int j = findSet(y);
        w -= weight[j] - weight[i];

        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
            weight[j] = w;
        } else {
            p[i] = p[j];
            weight[i] = -w;
            if(rank[i] == rank[j]){
            rank[j]++;
            }
        }	
    }
 
    public static int findSet(int i) {
       if(p[i] == i){ 
           return i;
        }else{
          return p[i] = findSet(p[i]);
        }
    }
 
    public static void DisjointSet() {
        p = new int[N];
        rank = new int[N];
        weight = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
            weight[i] = 0;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
        N = scanner.nextInt();
        M = scanner.nextInt();

        if(N==0 |M==0){
           break;
        }
 
        DisjointSet();

        for (int i = 0; i < M; i++) {
            if(scanner.next().equals("!")){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int w = scanner.nextInt();
 
            a--; b--;   
            unite(a, b, w);
            }else if(same(a,b)){
              System.out.println(weight[b] - weight[a]);
            }else{
              System.out.println("UNKNOWN");
	    }
           }
        
       }
      
    }
}

Compiler output:
Main.java:75: error: cannot find symbol
            }else if(same(a,b)){
                          ^
  symbol:   variable a
  location: class Main
Main.java:75: error: cannot find symbol
            }else if(same(a,b)){
                            ^
  symbol:   variable b
  location: class Main
Main.java:76: error: cannot find symbol
              System.out.println(weight[b] - weight[a]);
                                        ^
  symbol:   variable b
  location: class Main
Main.java:76: error: cannot find symbol
              System.out.println(weight[b] - weight[a]);
                                                    ^
  symbol:   variable a
  location: class Main
4 errors
Language: Java

import java.util.Scanner;
 
public class Main {
    public static int N;
    public static int M;
    public static int[] p;
    public static int[] rank;
    public static int[] weight;

    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int x, int y, int w) {
        int i = findSet(x);
        int j = findSet(y);
        w -= weight[j] - weight[i];

        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
            weight[j] = w;
        } else {
            p[i] = p[j];
            weight[i] = -w;
            if(rank[i] == rank[j]){
            rank[j]++;
            }
        }	
    }
 
    public static int findSet(int i) {
       if(p[i] == i){ 
           return i;
        }else{
          return p[i] = findSet(p[i]);
        }
    }
 
    public static void DisjointSet() {
        p = new int[N];
        rank = new int[N];
        weight = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
            weight[i] = 0;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
        N = scanner.nextInt();
        M = scanner.nextInt();

        if(N==0 |M==0){
           break;
        }
 
        DisjointSet();

        for (int i = 0; i < M; i++) {
            if(scanner.next().equals("!")){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int w = scanner.nextInt();
 
            a--; b--;   
            unite(a, b, w);
            }else{ 
               if(same(a,b)){
                    System.out.println(weight[b] - weight[a]);
               }else{
                    System.out.println("UNKNOWN");
	       }
            }
          }
       }
      
    }
}

Compiler output:
Main.java:76: error: cannot find symbol
               if(same(a,b)){
                       ^
  symbol:   variable a
  location: class Main
Main.java:76: error: cannot find symbol
               if(same(a,b)){
                         ^
  symbol:   variable b
  location: class Main
Main.java:77: error: cannot find symbol
                    System.out.println(weight[b] - weight[a]);
                                              ^
  symbol:   variable b
  location: class Main
Main.java:77: error: cannot find symbol
                    System.out.println(weight[b] - weight[a]);
                                                          ^
  symbol:   variable a
  location: class Main
4 errors
Language: Java

import java.util.Scanner;
 
public class ouyou2 {
    public static int N;
    public static int M;
    public static int[] p;
    public static int[] rank;
    public static int[] weight;

    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int x, int y, int w) {
        int i = findSet(x);
        int j = findSet(y);
        w -= weight[j] - weight[i];

        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
            weight[j] = w;
        } else {
            p[i] = p[j];
            weight[i] = -w;
            if(rank[i] == rank[j]){
		rank[j]++;
            }
        }	
    }
 
    public static int findSet(int i) {
	if(p[i] == i){ 
	    return i;
        }else{
	    return p[i] = findSet(p[i]);
        }
    }
 
    public static void DisjointSet() {
        p = new int[N];
        rank = new int[N];
        weight = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
            weight[i] = 0;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
	    N = scanner.nextInt();
	    M = scanner.nextInt();

	    if(N==0 |M==0){
		break;
	    }
 
	    DisjointSet();

	    for (int i = 0; i < M; i++) {
		String c = scanner.next();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		a--; b--; 
		
		if(c.equals("!")){
		    int w = scanner.nextInt();
		    unite(a, b, w);
		}else{ 
		    if(same(a,b)){
			System.out.println(weight[b] - weight[a]);
		    }else{
			System.out.println("UNKNOWN");
		    }
		}
	    }
	}
      
    }
}

Compiler output:
Main.java:3: error: class ouyou2 is public, should be declared in a file named ouyou2.java
public class ouyou2 {
       ^
1 error
Language: Java

import java.util.Scanner;
  
public class saisyu2 {
    public static int N;
    public static int M;
    public static int[] p;
    public static int[] rank;
    public static int[] weight;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
  
    public static void unite(int x, int y, int w) {
        int i = findSet(x);
        int j = findSet(y);
       
 
        if (i == j){
        return;
    }
        if (rank[i] > rank[j]){
            p[j] = i;	   
            weight[j] =  weight[x] + w;
        } else {
            p[i] = j;
            weight[i] = weight[y] - w;
            if(rank[i] == rank[j]){
        rank[j]++;
            }
        }   
    }
  
    public static int findSet(int i) {
    if(p[i] == i){ 
        return i;
        }else{
        return p[i] = findSet(p[i]);
        }
    }
  
    public static void DisjointSet() {
        p = new int[N];
        rank = new int[N];
        weight = new int[N];
  
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
            weight[i] = 0;
        }
    }
  
  
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
        N = scanner.nextInt();
        M = scanner.nextInt();
 
        if(N==0 && M==0){
        break;
        }
  
        DisjointSet();
 
        for (int i = 0; i < M; i++) {
        String c = scanner.next();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        a--; b--; 
         
        if(c.equals("!")){
            int w = scanner.nextInt();
            unite(a, b, w);
        }else{ 
            if(same(a,b)){
		System.out.println(weight[b] - weight[a]);
            }else{
            System.out.println("UNKNOWN");
            }
        }
        }
    }
       
    }
}

Compiler output:
Main.java:3: error: class saisyu2 is public, should be declared in a file named saisyu2.java
public class saisyu2 {
       ^
1 error
Language: Java

import java.util.Scanner;
  
public class saisyu2 {
    public static int N;
    public static int M;
    public static int[] p;
    public static int[] rank;
    public static int[] weight;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
  
    public static void unite(int x, int y, int w) {
        int i = findSet(x);
        int j = findSet(y);
       
 
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = i;	   
            weight[j] =  w - weight[y] + weight[x];
        } else {
            p[i] = j;
            weight[i] =  -w - weight[x] + weight[y];
            if(rank[i] == rank[j]){
		rank[j]++;
            }
        }   
    }
  
    public static int findSet(int i) {
	if(p[i] == i){ 
	    return i;
        }else{
	    int tmp = findSet(p[i]);
	    weight[i] += weight[p[i]];
	    return p[i] = tmp;
        }
    }
  
    public static void DisjointSet() {
        p = new int[N];
        rank = new int[N];
        weight = new int[N];
  
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
            weight[i] = 0;
        }
    }
  
  
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
	    N = scanner.nextInt();
	    M = scanner.nextInt();
 
	    if(N==0 && M==0){
		break;
	    }
  
	    DisjointSet();
 
	    for (int i = 0; i < M; i++) {
		String c = scanner.next();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		a--; b--; 
         
		if(c.equals("!")){
		    int w = scanner.nextInt();
		    unite(a, b, w);
		}else{ 
		    if(same(a,b)){
			System.out.println(weight[b] - weight[a]);
		    }else{
			System.out.println("UNKNOWN");
		    }
		}
	    }
	}
       
    }
}

Compiler output:
Main.java:3: error: class saisyu2 is public, should be declared in a file named saisyu2.java
public class saisyu2 {
       ^
1 error
Language: Java

import java.util.Scanner;
   
public class Main {
    public static int N;
    public static int M;
    public static int[] p;
    public static int[] rank;
    public static int[] weight;
  
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
   
    public static void unite(int x, int y, int w) {
        int i = findSet(x);
        int j = findSet(y);
        
  
        if (i == j){
        return;
    }
        if (rank[i] > rank[j]){
            p[j] = i;      
            weight[j] =  w - weight[y] + weight[x];
            weight[y] += weight[j]; 
        } else {
            p[i] = j;
            weight[i] =  -w - weight[x] + weight[y];
            weight[x] += weight[i]; 
            if(rank[i] == rank[j]){
        rank[j]++;
            }
        }   
    }
   
    public static int findSet(int i) {
    if(p[i] == i){ 
        return i;
        }else{      
          return p[i] = findSet(p[i]);;
        }
    }
   
    public static void DisjointSet() {
        p = new int[N];
        rank = new int[N];
        weight = new int[N];
   
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
            weight[i] = 0;
        }
    }
   
   
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
        N = scanner.nextInt();
        M = scanner.nextInt();
  
        if(N==0 && M==0){
        break;
        }
   
        DisjointSet();
  
        for (int i = 0; i < M; i++) {
        String c = scanner.next();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        a--; b--; 
          
        if(c.equals("!")){
            int w = scanner.nextInt();
            unite(a, b, w);
        }else{ 
            if(same(a,b)){
            System.out.println(weight[b] - weight[a]);
            }else{
            System.out.println("UNKNOWN");
            }
        }
        }
    }
        
    }
}

Compiler output:
Main.java:40: error: unreachable statement
          return p[i] = findSet(p[i]);;
                                      ^
1 error
Language: C

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <string>
#include <cctype>
#include <vector>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

LL a[110000];
int f[110000];

int gf(int x){
	int y=f[x];
	if (x==y) return x;
	f[x]=gf(y); a[x]+=a[y];
	return f[x];
}

int main(){
	int N,M,i;
	while (scanf("%d%d",&N,&M),N || M){
		for (i=1;i<=N;i++){
			f[i]=i; a[i]=0;
		}
		while (M--){
			char s[110];
			int u,v,d,x,y;
			scanf("%s",s);
			if (*s=='!'){
				scanf("%d%d%d",&u,&v,&d);
				x=gf(u); y=gf(v);
				if (x==y) continue;
				a[y]=a[u]-a[v]+d; f[y]=x;
			}else{
				scanf("%d%d",&u,&v);
				x=gf(u); y=gf(v);
				printf(x==y?"%lld\n":"UNKNOWN\n",a[v]-a[u]);
			}
		}
	}
}

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

#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 1<<30
#define MAX 1000010
using namespace std;

long long p[MAX],w[MAX];

pair<int,int> find(int a){
  pair<int,int> pii;
  if(p[a]==a){
    pii.f=a;pii.s=0;
    return pii;
  }
  pii=find(p[a]);
  pii.s+=w[a];
  p[a]=pii.f;
  w[a]=pii.s;
  return pii;
}

int main()
{
  int n,q,a,b,d;
  char c;

  while(cin>>n>>q && n ){
    for(int i=0;i<n;i++){
      p[i]=i;
      w[i]=0;
    }
    M.clear();

    for(int i=0;i<q;i++){
      cin>>c;
      if(c=='!'){
	cin>>a>>b>>d;
	a--;b--;
	pair<int,int> pa=find(a);
	p[pa.f]=b;
	w[pa.f]=d+w[a]+w[b];
      }
      else {
	cin>>a>>b;
	a--;b--;
	pair<int,int> pa=find(a),pb=find(b);
	if(pa.f!=pb.f)cout<<"UNKNOWM"<<endl;
	else {
	  p[a]=pa.f;
	  w[a]=pa.s;
	  p[b]=pb.f;
	  w[b]=pb.s;
	  cout<<pa.s-pb.s<<endl;
	}
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:5: error: 'M' was not declared in this scope
   34 |     M.clear();
      |     ^
Language: C++

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

using namespace std;
int weight[100000];

class DisjointSet{
public:
  int rank[100000],p[100000];

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;i++){
      makeSet(i);
      weight[i]=0;
    }
  }

  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
  void unite(int x,int y,int w){
    weight[x]=w;
    link(x,y);
  }
  void link(int x,int y){   
    p[x]=y;
    if(rank[x]>=rank[y]){  
      rank[y]=rank[x]+1;
    }
  }
  int findSet(int x){
    if(x==p[x]){
      return x;
    }else{
      return findSet(p[x]);
    }
  }
  int depth(int x){
    int ans=0;
    ans+=weight[x];
    while(x!=p[x]){
      ans+=weight[p[x]];
      x=p[x];
    }
    return ans;
  }
};
int main(){
  int n,m;
  while(scanf("%d%d",&n,&m)){
    if(!n&&!m){
      break;
    }else{
      string query;
      DisjointSet ds=DisjointSet(n);
      for(int i=0;i<m;i++){
        cin>>query;
        if(query=="!"){
          int a,b,w;
          scanf("%d%d%d",&a,&b,&w);
          ds.unite(a,b,w);
        }else{
          int c,d;
          scanf("%d%d",&c,&d);
          if(!ds.same(c,d)){
            printf("UNKNOWN\n");
          }else{
            printf("%d\n",ds.depth(c)-ds.depth(d));
          }
        }
      }
    }
  }
  return 0;
}
      

Compiler output:
a.cc: In constructor 'DisjointSet::DisjointSet(int)':
a.cc:15:10: error: request for member 'resize' in '((DisjointSet*)this)->DisjointSet::rank', which is of non-class type 'int [100000]'
   15 |     rank.resize(size,0);
      |          ^~~~~~
a.cc:16:7: error: request for member 'resize' in '((DisjointSet*)this)->DisjointSet::p', which is of non-class type 'int [100000]'
   16 |     p.resize(size,0);
      |       ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int S = 100010;

struct UnionFind {
  vector<int> node;
  vector<ll> weight;
  UnionFind() : node(S, -1), weight(S, 0) {}
  void unite(int u, int v, ll w) {
    int ov = v, ou = u;
    u = find(u), v = find(v);
    int wa = weight[ov], wb = weight[ou];
    if(u == v) return;
    
    // (v ??????) ??? (u ??????) ???????????????
    node[u] += node[v];
    node[v] = u;
    weight[v] += w + wb - wa;
  }
  
  int find(int u) {
    if(node[u] < 0) return u;
    int par = node[u], root = find(node[u]);
    weight[u] += weight[par];
    return node[u] = root;
  }
};

int main() {
  int N, M;
  while(cin >> N >> M, N) {
    UnionFind uf;
    for(int i=0; i<M; i++) {
      char c; cin >> c;
      if(c == '!') {
	int a, b, d; cin >> a >> b >> d;
	a--; b--;
	uf.unite(a, b, d);
      }
      else {
	int a, b; cin >> a >> b;
	a--; b--;
	if(uf.find(a) != uf.find(b)) cout << "UNKNOWN" << endl;
	else {
	  ll wa = uf.get_weight(a);
	  ll wb = uf.get_weight(b);
	  cout << wb - wa << endl;
	}
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:22: error: 'struct UnionFind' has no member named 'get_weight'; did you mean 'weight'?
   46 |           ll wa = uf.get_weight(a);
      |                      ^~~~~~~~~~
      |                      weight
a.cc:47:22: error: 'struct UnionFind' has no member named 'get_weight'; did you mean 'weight'?
   47 |           ll wb = uf.get_weight(b);
      |                      ^~~~~~~~~~
      |                      weight
Language: C++

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

class union_find{
private:
	vector<int> parents;
	vector<int> weight;
public:
	union_find(int n){
		for(int i=0;i<n;i++){
			parents.push_back(i);
			rank.push_back(0);
			weight.push_back(0);
		}
	}
	int find(int x){
		if(parents[x]==x){
			return x;
		}else{
			int tmp=find(parents[x]);
			weight[x]=weight[x]+weight[parents[x]];
			return parents[x]=tmp;
		}
	}
	void unite(int x,int y,int w){
		int tmpx=find(x);
		int tmpy=find(y);
		if(tmpx==tmpy)return;
		weight[tmpx]=w-weight[x]+weight[y];
		parents[tmpx]=tmpy;
	}
	int get_weight(int x,int y){
		if(find(x)==find(y)){
			return weight[x]-weight[y];
		}else{
			return -2000000;
		}
	}
};
int main(){
	char c;
	int a,b,w;
	int n,m;
	while(cin>>n>>m,n!=0||m!=0){
		union_find uf(n+1);
		for(int i=0;i<m;i++){
			cin>>c;
			if(c=='!'){
				cin>>a>>b>>w;
				uf.unite(a,b,w);
			}else if(c=='?'){
				cin>>a>>b;
				int tmp=uf.get_weight(a,b);
				if(tmp!=-2000000){
					cout<<tmp<<endl;
				}else{
					cout<<"UNKNOWN"<<endl;
				}
			}
		}
	}
}

Compiler output:
a.cc: In constructor 'union_find::union_find(int)':
a.cc:16:29: error: expected unqualified-id before '.' token
   16 |                         rank.push_back(0);
      |                             ^
Language: C++

#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//FILE *in = freopen("input.txt", "r", stdin);
//FILE *out = freopen("output.txt", "w", stdout);

int n, m;

struct UnionFind {
	vector<int> par; vector<int> rank;
	UnionFind(int n){
		par = vector<int>(n);
		rank = vector<int>(n);
		for(int i = 0; i < n; i++) {
			par[i] = i;
		}
	}
	int find(int x) {
		if(par[x]==x) return x;
		else return find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x]<rank[y])
			par[x] = y;
		else {
			par[y] = x;
			if(rank[x]==rank[y])rank[x]++;
		}
	}
	inline bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int bfs(vector<vector<pair<int,int>>> data, int a, int b) {
	bool chk[100001];
	memset(chk, 0, sizeof(chk));
	queue<pair<int,int>> que;
	que.push(make_pair(a, 0));
	chk[a] = true;
	while(!que.empty()){
		int cur = que.front().first;
		int val = que.front().second;
		que.pop();
		if(cur == b)
			return val;

		for(int i = 0; i < data[cur].size(); i++) {
			if(chk[data[cur][i].first]) continue;
			chk[data[cur][i].first] = true;
			que.push(make_pair(data[cur][i].first, val + data[cur][i].second));
		}
	}
	return -1;
}

void process() {
	UnionFind uf(n+1);
	vector<vector<pair<int,int>>> data(n+1);
	char tt[10];
	int a, b, c;
	for(int k = 0; k < m; k++) {
		scanf("%s%d%d", tt, &a, &b);
		if(tt[0] == '!') {
			scanf("%d", &c);
			if(uf.same(a,b)) continue;
			data[a].push_back(make_pair(b, c));
			data[b].push_back(make_pair(a, -c));
			uf.unite(a,b);
		}
		else {
			if(!uf.same(a, b)) {
				printf("UNKNOWN\n");
				continue;
			}
			printf("%d\n", bfs(data, a, b));
		}
	}
}

int main() {
	while(true){
		scanf("%d%d", &n, &m);
		if(!n)break;
		process();
	}
	return 0;
}

Compiler output:
a.cc: In function 'int bfs(std::vector<std::vector<std::pair<int, int> > >, int, int)':
a.cc:44:9: error: 'memset' was not declared in this scope
   44 |         memset(chk, 0, sizeof(chk));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <algorithm>
  +++ |+#include <cstring>
    5 |
Language: C++

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

using namespace std;

const int MAX = 100005;

class UnionFind{
public:
 
  int par[MAX];
  int rank[MAX];

  void init(int n){
    for(int i = 0; i < n; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank[x] < rank[y]) par[x] = par[y];
    else{
      par[y] = par[x];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }
  
  bool same(int x, int y){
    return find(x) == find(y);
  }
};

int N,M,val[MAX];
bool used[MAX];
UnionFind uf;
vector<int> V;

void init(){
  memset(used,false,sizeof(used));
  memset(val,0,sizeof(val));
  uf.init(N+1);
  V.clear();
}


void update(){
  
  int a,b,c;
  cin >> a >> b >> c;
  if(!uf.same(a,b)){
    if(!used[a]){
      V.push_back(a);
      used[a] = true;
    }
    if(!used[b]){
      V.push_back(b);
      used[b] = true;
    }
    
    int diff = val[a]-val[b]+c;
    for(int i = 0; i < V.size(); i++){
      if(uf.same(V[i],b)) val[V[i]]+=diff;
    }
    uf.unite(a,b);
  }
}

void print(){
  int a,b;
  cin >> a >> b;
  if(uf.same(a,b)) cout << val[b]-val[a] << endl;
  else cout << "UNKNOWN" << endl;
}

int main(){
  
  while(cin >> N >> M && N+M){
    init();
    for(int i = 0; i < M; i++){
      char c;
      cin >> c;
      if(c == '!') update();
      else print();
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'void init()':
a.cc:50:3: error: 'memset' was not declared in this scope
   50 |   memset(used,false,sizeof(used));
      |   ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,w, len[51111],psum[51111];
struct SegTree{
	int n, seg[401111];
	void init(int _n){
		n=_n;
		memset(seg,0,sizeof(seg));
	}
	void set(int i, int x){
		// printf("[%d] = %d\n",i,x);
		set(i,x,0,n,0);
	}
	int qmax(int l, int r){
		// printf("%d - %d:  %d\n",l,r,qmax(l,r,0,n,0));
		return qmax(l,r,0,n,0);
	}
	void set(int i, int x, int sl, int sr, int sid){
		if(sr<=i || i<sl)return;
		if(sr-sl<=1){
			seg[sid]=x; return;
		}
		set(i, x, sl, (sl+sr)/2, sid*2+1);
		set(i, x, (sl+sr)/2, sr, sid*2+2);
		seg[sid] = max(seg[sid*2+1], seg[sid*2+2]);
	}
	int qmax(int l, int r, int sl, int sr, int sid){
		if(sr<=l || r<=sl)return 0;
		if(l<=sl && sr<=r)return seg[sid];
		return max(qmax(l, r, sl, (sl+sr)/2, sid*2+1), qmax(l, r, (sl+sr)/2, sr, sid*2+2));
	}
}st;
int ceiling(int x, int y){
	if(y==0){
		printf("QQ %d %d\n",x,y);
		while(1);
	}
	return (x-1)/y+1;
}
bool check(int d){
	// printf("\t\t\td = %d\n",d);
	static int dp[51111];
	memset(dp,0,sizeof(dp));
	st.init(n);

	for(int i=1; i<n; i++){
		// printf(" i= %d\n",i);
		int lb=-1, ub=i-1, b, a;
		while(1<ub-lb){
			int md=(lb+ub)/2;
			if(ceiling(w-psum[i+1]+psum[md+1], i-md-1)<=d)
				lb=md;
			else
				ub=md;
		}
		b=lb;
		lb=-1, ub=i;
		while(1<ub-lb){
			int md=(lb+ub)/2;
			if(psum[i+1]-psum[md+1]+i-md-1<=w)
				ub=md;
			else
				lb=md;
		}
		a= ub;
		// printf("%d - %d\n",a,b);
		if(psum[i+1]+i<=w && ceiling(w-psum[i+1], i)<=d)dp[i]=1;
		// printf("%d<=%d && %d/%d<=%d\n", psum[i+1]+i,w, w-psum[i+1], i, d);
		if(a<=b)
			dp[i] = st.qmax(a,b+1);
		st.set(i,dp[i]);
		// printf("dp(%d) = %d\n",i,dp[i]);
	}
	int res=0;
	for(int i=0; i<n-1; i++){
		if(psum[n]-psum[i+1]+n-i-1<=w)
			res = max(res, dp[i]);
	}

	return res || dp[n-1] || psum[n]+n-1<=w;

}
int main(){
	while(scanf("%d%d",&w,&n)&&(n+w>0)){
		for(int i=0; i<n; i++)scanf("%d",&len[i]);
		psum[0]=0;
		for(int i=0; i<n; i++)psum[i+1] = psum[i]+len[i];
		int lb=0, ub=w;
		while(1<ub-lb){
			int md=(lb+ub)/2;
			if(check(md))
				ub=md;
			else
				lb=md;
		}
		printf("%d\n",ub);
	}
}

/*

11 4
4 2 1 3
5 7
1 1 1 2 2 1 2
11 7
3 1 3 1 3 3 4
100 3
30 30 39
30 3
2 5 3
0 0

*/

Compiler output:
a.cc: In member function 'void SegTree::init(int)':
a.cc:10:17: error: 'memset' was not declared in this scope
   10 |                 memset(seg,0,sizeof(seg));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
a.cc: In function 'bool check(int)':
a.cc:45:9: error: 'memset' was not declared in this scope
   45 |         memset(dp,0,sizeof(dp));
      |         ^~~~~~
a.cc:45:9: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	int n, k, s, cnt, use_cnt;

	void run() {
		for (;;) {
			n = sc.nextInt(); // less than or equal n
			k = sc.nextInt(); // num of elements
			s = sc.nextInt(); // sum of integer
			if ((n | k | s) == 0) {
				break;
			}
			cnt = 0;
			dfs(0, 1, 0);
			System.out.println(cnt);
		}
	}

	void dfs(int use_cnt, int num, int sum) {
		if (num - 1 > n) {
			return;
		}
		if (use_cnt == k) {
			if (sum == s) {
				cnt++;
			}
			return;
		} else {
			dfs(use_cnt + 1, num + 1, sum + num); // use num
			dfs(use_cnt, num + 1, sum); // not use num
		}
	}

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

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

Compiler output:
Main.java:39: error: cannot find symbol
		new AOJ_1335().run();
		    ^
  symbol:   class AOJ_1335
  location: class Main
1 error
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	int n, k, s, cnt, use_cnt;

	void run() {
		for (;;) {
			n = sc.nextInt(); // less than or equal n
			k = sc.nextInt(); // num of elements
			s = sc.nextInt(); // sum of integer
			if ((n | k | s) == 0) {
				break;
			}
			cnt = 0;
			dfs(0, 1, 0);
			System.out.println(cnt);
		}
	}

	void dfs(int use_cnt, int num, int sum) {
		if (num - 1 > n) {
			return;
		}
		if (use_cnt == k) {
			if (sum == s) {
				cnt++;
			}
			return;
		} else {
			dfs(use_cnt + 1, num + 1, sum + num); // use num
			dfs(use_cnt, num + 1, sum); // not use num
		}
	}

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

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

Compiler output:
Main.java:39: error: cannot find symbol
		new Main.run();
		        ^
  symbol:   class run
  location: class Main
1 error
Language: C

#include<stdio.h>
#include<stdlib.h>
int N,K,S;

int dfs(int d,int n,int s)
{
	int i,r=0;
	if(d==K&&n==0)
		return 1;
	if(s>N||d>=K)return 0;
	for(i=s;i<=N;i++)
	{
		dbg[d]=i;
		r+=dfs(d+1,n-i,i+1);
	}
	return r;
}

int main()
{
	for(;scanf("%d%d%d",&N,&K,&S),N;)
	{
		printf("%d\n",dfs(0,S,1));
	}
	return 0;
}

Compiler output:
main.c: In function 'dfs':
main.c:13:17: error: 'dbg' undeclared (first use in this function)
   13 |                 dbg[d]=i;
      |                 ^~~
main.c:13:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int ans,n,k,s;
int used[21];
void dfs(int d,int sum,int t){
    if(sum==s&&d==0){ans++;return;}
    else if(d==0) return ;
    for(int i=t+1;i<=n;i++){
        if(!used[i]){
            used[i]=1;
            dfs(d-1,sum+i,i);
            used[i] =0;
        }
    }
}
int main()
{
    while(cin >> n >> k >>s&&n){
        memset(used,0,sizeof(used));
        ans = 0;
        dfs(k,0,0);
        cout << ans << endl;
    }
    return 0;
}

 

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

#include<stdio.h>

int main(){
 int q,w,e,r,t,y;
 int i,j,k;
 int dp[21][11][156];
 
 dp[0][0][0] = 1;
 
 for(i = 1;i < 21;i++){
  dp[i][0][0]=1;
  for(j = 1;j < 11;j++){
   for(k = 1;k < 156;k++){
    dp[i][j][k] = (n<=s ? dp[i-1][j-1][k-i] : 0) + dp[i-1][j][k];
}}}

 while(scanf("%d%d%d",&q,&w,&e),q){
  printf("%d\n",dp[q][w][e]);
 }
 return 0;
}

Compiler output:
main.c: In function 'main':
main.c:14:20: error: 'n' undeclared (first use in this function)
   14 |     dp[i][j][k] = (n<=s ? dp[i-1][j-1][k-i] : 0) + dp[i-1][j][k];
      |                    ^
main.c:14:20: note: each undeclared identifier is reported only once for each function it appears in
main.c:14:23: error: 's' undeclared (first use in this function)
   14 |     dp[i][j][k] = (n<=s ? dp[i-1][j-1][k-i] : 0) + dp[i-1][j][k];
      |                       ^
Language: C++

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

long dp[25][200][30]; //dp[何個目まで足したか][残ってる数]
int n, k;

long rec(int a, int b, int c){ //a番目,残りb,前に足した数c
	if(dp[a][b][c]>=0) return dp[a][b][c];
	
	long ret=0;
	if(a==k && b>=0){
		if(b==0) ret=1;
		else ret=0;	
	}
	else if(b<0) ret=0;
	else{
		for(int i=c-1; i>0; --i) ret+=rec(a+1, b-i, i);
		//printf("%d %d = %ld\n", a, b, ret);
	}
	//printf("ret dp[%d][%d] = %ld\n", a, b, ret);
	return dp[a][b][c]=ret;
}

int main(){
	while(1){
		int s;
		scanf(" %d %d %d", &n, &k, &s);
		if(n==0) break;	
		
		memset(dp, -1, sizeof(dp));
		printf("%ld\n", rec(0, s, n+1) );
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: 'memset' was not declared in this scope
   31 |                 memset(dp, -1, sizeof(dp));
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <iostream>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <bitset>
#include <numeric>

using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define rall(a)		(a).rbegin(), (a).rend()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)
#define fi first
#define se second
bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int mod = 1000000007;
const int INF = 1e9;

int main()
{
	int n, k, s;

	while (cin >> n >> k >> s && n){

		int ans = 0;
		rep(i, (1 << n) + 1)if (__popcnt(i) == k){
			
			int v = 0;
			rep(j, n){
				if ((i >> j ) & 1){
					v += j+1;
				}
			}

			if (v == s){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:41: error: '__popcnt' was not declared in this scope
   49 |                 rep(i, (1 << n) + 1)if (__popcnt(i) == k){
      |                                         ^~~~~~~~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;
a
double A, B, C;
int dp[10][190][21] = {};
// dp[i][j][k] : 
signed main(void)
{
	int i, j, k;
	int j2, k2;
	while (1) {
		int N, K, S;
		cin >> N >> K >> S;
		if (N == 0) return 0;
		rep(i, 10) rep(j, 190) rep(k, 21) dp[i][j][k] = 0;
		REP(i, 1, N + 1) {
			dp[0][i][i] = 1;
		}

		REP(i, 1, K) {
			rep(j, S) {
				rep(k, N) {
					REP(j2, k, N + 1) {
						dp[i][j + j2][max(k, j2)] += dp[i - 1][j][k];
					}
				}
			}
		}
		rep(i, K) rep(j, S) rep(k, N) {
			printf("dp[%d][%d][%d] = %d\n", i, j, k, dp[i][j][k]);
		}
		int sum = 0;
		rep(k, N+1) sum += dp[K - 1][S][k];
		cout << sum << endl;
	}

	return 0;
}

Compiler output:
a.cc:46:1: error: 'a' does not name a type
   46 | a
      | ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

        int count = 0;
        // k個選ぶ
        std::string bitMask(k, 1);
        // n個の中から
        bitMask.resize(n, 0);
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                // 組み合わせに選ばれた値
                if (bitMask[i]) {
                    // 0からなので1ずらす
                    sum += i + 1;
                }
            }
            if (sum == s) {
                count += 1;
            }
            // 次のマスクを求める
        } while (std::prev_permutation(bitMask.begin(), bitMask.end()));
        cout << count << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:23: error: 'prev_permutation' is not a member of 'std'; did you mean 'is_permutation'?
   33 |         } while (std::prev_permutation(bitMask.begin(), bitMask.end()));
      |                       ^~~~~~~~~~~~~~~~
      |                       is_permutation
Language: C++

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

int main(){
    int n,k,s,i,c,res;
    while(1){
        scanf("%d",&n);
        scanf("%d",&k);
        scanf("%d",&s);
        if(!n && !k && !s){break;}
        vector<int> t(n,0);
        vector<int> cd(n);
        iota(cd.begin(),cd.end(),1);
        for(i=0;i<k;i++){t[n-i-1]=1;}    
        res=0;
        do{
            c=0;
            for(i=0;i<n;i++){c+=(t[i]*cd[i]);}
            if(c==s){res++;}
        } while(next_permutation(t.begin(),t.end()));
        printf("%d\n",res);
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'scanf' was not declared in this scope
    9 |         scanf("%d",&n);
      |         ^~~~~
a.cc:23:9: error: 'printf' was not declared in this scope
   23 |         printf("%d\n",res);
      |         ^~~~~~
a.cc:4:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    3 | #include <algorithm>
  +++ |+#include <cstdio>
    4 | using namespace std;
Language: C++

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n);

using namespace std;

int dp[21][11][160];
int dfs(int n, int k, int s){
	if(k == 0) return s == 0; 

	int &res = dp[n][k][s];
	if(res >= 0) return res;

	res = 0;
	for(int i = n; i >= k; i--){
		res += dfs(i-1, k-1, s-i);
	}

	return res;
}

int main(){
	int n, k, s;
	memset(dp, -1, sizeof(dp));
	while(cin >> n >> k >> s, n|k|s){
		cout << dfs(n, k, s) << endl;
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'memset' was not declared in this scope
   28 |         memset(dp, -1, sizeof(dp));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | #include <string>
Language: Java

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

import com.sun.media.sound.DirectAudioDeviceProvider;
import com.sun.org.apache.xml.internal.serializer.ElemDesc;

public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while (cin.hasNextInt()) {
			int n = cin.nextInt(), l = cin.nextInt();
			if (n == 0) break;
			int dir[] = new int[n];
			int pos[] = new int[n];
			boolean in[] = new boolean[n];
			//System.out.println("ffff");
			for (int i = 0; i < n; ++ i) {
				in[i] = true;
				String s = cin.next();
				if (s.charAt(0) == 'L') dir[i] = -1;
				else dir[i] = 1;
				pos[i] = cin.nextInt();
			}
			int ltime = -1, rtime = -1, lid = -1, rid = -1;
			for (int t = 1, rest = n; rest > 0; ++ t) {
				for (int i = 0; i < n; ++ i) {
					pos[i] += dir[i];
				}
				for (int i = 0; i < n; ++ i) {
					if (!in[i]) continue;
					if (pos[i] == 0) {
						in[i] = false; -- rest;
						ltime = t; lid = i + 1;
					}
					if (pos[i] == l) {
						in[i] = false; -- rest;
						rtime = t; rid = i + 1;
					}
				}
				for (int i = 0; i < n; ++ i) {
					for (int j = 0; j < n; ++ j) {
						if (i != j && in[i] && in[j] && pos[i] == pos[j]) {
							dir[i] = -dir[i];
						}
					}
				}
			}
			if (ltime >= rtime) System.out.println(ltime + " " + lid);
			else System.out.println(rtime + " " + rid);
		}
	}
}

Compiler output:
Main.java:5: error: package com.sun.media.sound is not visible
import com.sun.media.sound.DirectAudioDeviceProvider;
                    ^
  (package com.sun.media.sound is declared in module java.desktop, which does not export it)
Main.java:6: error: package com.sun.org.apache.xml.internal.serializer is not visible
import com.sun.org.apache.xml.internal.serializer.ElemDesc;
                                      ^
  (package com.sun.org.apache.xml.internal.serializer is declared in module java.xml, which does not export it)
2 errors
Language: C++

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


int main(){
	int n,l;
	char d[100];
	int x[100];
	while(cin>>n>>l,n|l){
		int count=0;
		int leave,t=0;
		rep(i,n)cin>>d[i]>>x[i];
		while(count<n){
			for(int i=0;i<n;i++){
				if(x[i]==-1)continue;
				if(d[i]=='L')x[i]--;
				else x[i]++;
			}
			for(int i=0;i<n;i++){
				if(x[i]==-1)continue;
				for(int j=i+1;j<n;j++){
					if(x[j]==-1)continue;
					if(x[i]==x[j])swap(d[i],d[j]);
				}
			}
			leave=-1;
			for(int i=0;i<n;i++){
				if(x[i]==0||x[i]==l){
					count++;
					x[i]=-1;
					if(leave==-1 || d[leave]=='R')leave=i;
				}
			}
			t++;
		}
		cout<<t<<' '<<leave+1<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: 'i' was not declared in this scope
   13 |                 rep(i,n)cin>>d[i]>>x[i];
      |                     ^
a.cc:13:17: error: 'rep' was not declared in this scope
   13 |                 rep(i,n)cin>>d[i]>>x[i];
      |                 ^~~