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

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

const double eps = 1e-8;
const int maxn = 100 + 10;
typedef double Matrix[maxn][maxn];

// 逕ア莠取悽鬚倡噪迚ケ谿頑??梧カ亥?蜷惹ク堺ク?ョ壽弍蟇ケ隗帝亰?檎爆閾ウ荳堺ク?ョ壽弍髦カ譴ッ髦オ
// 菴?凶x[i]隗」諠滉ク?ク疲怏髯撰シ檎ャャi陦碁勁莠?[i][i]蜥窟[i][n]荵句、也噪蜈カ莉門?邏?插荳コ0
void gauss_jordan(Matrix A, int n)
{
    int i, j, k, r;
    for(i = 0; i < n; i++)
    {
        r = i;
        for(j = i+1; j < n; j++)
            if (fabs(A[j][i]) > fabs(A[r][i])) r = j;
        if(fabs(A[r][i]) < eps) continue; // 謾セ蠑?ソ吩ク?。鯉シ檎峩謗・螟?炊荳倶ク?。?(*)
        if(r != i) for(j = 0; j <= n; j++) swap(A[r][j], A[i][j]);

        // 荳朱勁莠?ャャi陦悟、也噪蜈カ莉冶。瑚ソ幄。梧カ亥?
        for(k = 0; k < n; k++) if(k != i)
                for(j = n; j >= i; j--) A[k][j] -= A[k][i]/A[i][i] * A[i][j];
    }
}

Matrix A;
int n;
double v[maxn];
int d;
int inf[maxn];

int main()
{
    //freopen("input.txt","r",stdin);
    while(scanf("%d", &d) == 1 && d)
    {

        for(int i=0; i<=d+2; i++)
            scanf("%lf",&v[i]);
        //for(int i=0;i<d+2;i++)
        //  cout << v[i] << " ";
        //cout <<endl;
        int found = 0;
        int anss = -1;
        for(int de = 0; de<=d+2; de++)
        {
            if(found)break;
            int kk;
            int cnt = 0;
            for(kk=0; kk<=d+2; kk++)
            {
                if(kk==de)continue;
                for(int i=0; i<=d; i++)
                    A[cnt][i] = pow((double)kk,(double)i);
                A[cnt][d+1] = v[kk];
                cnt++;
                if(cnt == d+1)break;
            }
            n = d+1;
            // for(int i=0;i<n;i++)
            // {
            //     for(int j=0;j<=n;j++)
            //         cout << A[i][j]  <<' ';
            //     cout <<endl;
            // }
            // 隗」譁ケ遞狗サ?シ梧?隶ー譌?ゥキ蜿倬?
            gauss_jordan(A, n);
            memset(inf, 0, sizeof(inf));
            for(int i = n-1; i >= 0; i--)
            {
                if(fabs(A[i][i])<eps && fabs(A[i][n])>eps) inf[i] = 1; // 逶エ謗・隗」蜃コ譚・逧?裏遨キ蜿倬?
                for(int j = i+1; j < n; j++)
                    if(fabs(A[i][j])>eps && inf[j]) inf[i] = 1; // 蜥梧裏遨キ蜿倬?謇ッ荳雁?邉サ逧?序驥丈ケ滓弍譌?ゥキ逧?            }
            double aa[10];
            int flag = 0;
            for(int i=0; i<n; i++)
                if(inf[i])
                {
                    flag = 1;
                    break;
                }
                else aa[i] = fabs(A[i][i])<eps ? 0.0 : A[i][n]/A[i][i];
            if(flag)continue;

            kk++;
            if(kk == de)kk++;
            double ans1 = 0,ans2 = 0;
            for(int i=0; i<n; i++)
            {
                ans1 += aa[i]*pow(kk,i);
                ans2 += aa[i]*pow(de,i);
            }
            if(fabs(ans1 - v[kk]) <= 0.001 && fabs(ans2 - v[de]) > 0.1)
            {
                anss = de;
                found = 1;
            }
        }
        printf("%d\n",anss);
    }
    return 0;
}

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

//Name: Find the Outlier
//Level: 
//Category:
//Note:

/**
 */
#include <iostream>
#include <vector>
#include <string>
#include <array>

using namespace std;

bool solve() {
    int N;
    cin >> N;
    if(!N) return false;

    vector<double> ys(N+3);
    for(int i = 0; i < N+3; ++i) {
        cin >> ys[i];
    }
    const int CHECKER = N+2;
    int candidate = CHECKER;
    for(int outlier = 0; outlier <= N+1; ++outlier) {
        double c = 0;
        // term for generate f(i)
        for(int i = 0; i <= N+1; ++i) {
            if(i == outlier) continue;
            double tmp = 1;
            for(int j = 0; j <= N+1; ++j) {
                if(j == i || j == outlier) continue;
                tmp *= static_cast<double>(CHECKER - j) / (i - j);
            }
            c += tmp * ys[i];
        }
        //cout << c << ' ' << ys[CHECKER] << endl;
        if(fabs(c - ys[CHECKER]) < 0.9) {
            candidate = outlier;
            break;
        }
    }
    cout << candidate << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Compiler output:
a.cc: In function 'bool solve()':
a.cc:39:12: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   39 |         if(fabs(c - ys[CHECKER]) < 0.9) {
      |            ^~~~
      |            labs
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[] w;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int a, int b, int w) {
        int i = findSet(a);
        int j = findSet(b);
	w -= w[b] - w[a];
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = w;
        } else {
            p[i] = p[j];
	    w[x] = -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];
	w = new int[N]
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[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();
	Solve();
	}
    }
    
    public static Solve(){
        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("UNKNOWN");
		}else{
		    System.out.println(w[b]-w[a]);
		}
	    }
	}
    }
}

Compiler output:
Main.java:45: error: ';' expected
	w = new int[N]
	              ^
Main.java:67: error: invalid method declaration; return type required
    public static Solve(){
                  ^
2 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[] w;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int a, int b, int w) {
        int i = findSet(a);
        int j = findSet(b);
	w -= w[b] - w[a];
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = w;
        } else {
            p[i] = p[j];
	    w[x] = -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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:17: error: array required, but int found
	w -= w[b] - w[a];
	      ^
Main.java:17: error: array required, but int found
	w -= w[b] - w[a];
	             ^
Main.java:24: error: array required, but int found
	    w[j] = w;
	     ^
Main.java:27: error: cannot find symbol
	    w[x] = -w;
	      ^
  symbol:   variable x
  location: class Main
Main.java:27: error: array required, but int found
	    w[x] = -w;
	     ^
Main.java:72: error: cannot find symbol
		    if(!same(a,b)){
		             ^
  symbol:   variable a
  location: class Main
Main.java:72: error: cannot find symbol
		    if(!same(a,b)){
		               ^
  symbol:   variable b
  location: class Main
Main.java:75: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                     ^
  symbol:   variable b
  location: class Main
Main.java:75: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                          ^
  symbol:   variable a
  location: class Main
9 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[] w;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int a, int b, int w) {
        int i = findSet(a);
        int j = findSet(b);
	w -= w[b] - w[a];
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = w;
        } else {
            p[i] = p[j];
	    w[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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:17: error: array required, but int found
	w -= w[b] - w[a];
	      ^
Main.java:17: error: array required, but int found
	w -= w[b] - w[a];
	             ^
Main.java:24: error: array required, but int found
	    w[j] = w;
	     ^
Main.java:27: error: array required, but int found
	    w[i] = -w;
	     ^
Main.java:72: error: cannot find symbol
		    if(!same(a,b)){
		             ^
  symbol:   variable a
  location: class Main
Main.java:72: error: cannot find symbol
		    if(!same(a,b)){
		               ^
  symbol:   variable b
  location: class Main
Main.java:75: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                     ^
  symbol:   variable b
  location: class Main
Main.java:75: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                          ^
  symbol:   variable a
  location: class Main
8 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[] w;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int a, int b, int w) {
        int i = findSet(a);
        int j = findSet(b);
	w -= w[b] - w[a];
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = w;
        } else {
            p[i] = p[j];
	    w[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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:17: error: array required, but int found
	w -= w[b] - w[a];
	      ^
Main.java:17: error: array required, but int found
	w -= w[b] - w[a];
	             ^
Main.java:24: error: array required, but int found
	    w[j] = w;
	     ^
Main.java:27: error: array required, but int found
	    w[i] = -w;
	     ^
Main.java:72: error: cannot find symbol
		    if(same(a,b)==false){
		            ^
  symbol:   variable a
  location: class Main
Main.java:72: error: cannot find symbol
		    if(same(a,b)==false){
		              ^
  symbol:   variable b
  location: class Main
Main.java:75: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                     ^
  symbol:   variable b
  location: class Main
Main.java:75: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                          ^
  symbol:   variable a
  location: class Main
8 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[] w;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int a, int b, int w) {
        int i = findSet(a);
        int j = findSet(b);
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = w;
        } else {
            p[i] = p[j];
	    w[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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:23: error: array required, but int found
	    w[j] = w;
	     ^
Main.java:26: error: array required, but int found
	    w[i] = -w;
	     ^
Main.java:71: error: cannot find symbol
		    if(same(a,b)==false){
		            ^
  symbol:   variable a
  location: class Main
Main.java:71: error: cannot find symbol
		    if(same(a,b)==false){
		              ^
  symbol:   variable b
  location: class Main
Main.java:74: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                     ^
  symbol:   variable b
  location: class Main
Main.java:74: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                          ^
  symbol:   variable a
  location: class Main
6 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[] w;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int a, int b, int k) {
        int i = findSet(a);
        int j = findSet(b);
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = k;
        } else {
            p[i] = p[j];
	    w[i] = -k;
            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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:71: error: cannot find symbol
		    if(same(a,b)==false){
		            ^
  symbol:   variable a
  location: class Main
Main.java:71: error: cannot find symbol
		    if(same(a,b)==false){
		              ^
  symbol:   variable b
  location: class Main
Main.java:74: error: cannot find symbol
			System.out.println(w[b]-w[a]);
			                     ^
  symbol:   variable b
  location: class Main
Main.java:74: error: cannot find symbol
			System.out.println(w[b]-w[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[] w;
 
    public static boolean same(int a, int b) {
        return findSet(a) == findSet(b);
    }
 
    public static void unite(int a, int b, int k) {
        int i = findSet(a);
        int j = findSet(b);
	k -= w[b] - w[a];
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = k;
        } else {
            p[i] = p[j];
	    w[i] = -k;
            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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}
 
    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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:83: error: unnamed classes are a preview feature and are disabled by default.
    public static int findSet(int i) {
                  ^
  (use --enable-preview to enable unnamed classes)
Main.java:130: error: class, interface, enum, or record expected
}
^
2 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[] w;
 
    public static boolean same(int a, int b) {
        return findSet(a) == findSet(b);
    }
 
    public static void unite(int a, int b, int k) {
        int i = findSet(a);
        int j = findSet(b);
	k -= w[b] - w[a];
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = k;
        } else {
            p[i] = p[j];
	    w[i] = -k;
            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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    for (int i = 0; i < M; i++) {
		if(scanner.next().equals("!")){
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    int k = scanner.nextInt();
		    
		    a--;
		    b--;
		    unite(a, b, k);
		}else{
		    if(same(a,b)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}
 
    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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:83: error: unnamed classes are a preview feature and are disabled by default.
    public static int findSet(int i) {
                  ^
  (use --enable-preview to enable unnamed classes)
Main.java:130: error: class, interface, enum, or record expected
}
^
2 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[] w;
 
    public static boolean same(int a, int b) {
        return findSet(a) == findSet(b);
    }
    
    public static void unite(int a, int b, int k) {
        int i = findSet(a);
        int j = findSet(b);
	k -= w[b] - w[a];
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = k;
        } else {
            p[i] = p[j];
	    w[i] = -k;
            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];
	w = new int[N];
	
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

 
    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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:84: error: unnamed classes are a preview feature and are disabled by default.
    public static int findSet(int i) {
                  ^
  (use --enable-preview to enable unnamed classes)
Main.java:131: error: class, interface, enum, or record expected
}
^
2 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[] w;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
    
    public static void unite(int a, int b, int k) {
        int i = findSet(a);
        int j = findSet(b);
	k -= w[b] - w[a];
	
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
	    w[j] = k;
        } else {
            p[i] = p[j];
	    w[i] = -k;
            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];
	w = new int[N];
	
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

 
    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];
	w = new int[N];
 
        for (int i = 0; i < N; i++) {
            p[i] = i;
            rank[i] = 0;
	    w[i] = 0;
        }
    }
    
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
	while(true){   
	    N = scanner.nextInt();
	    DisjointSet();
	    M = scanner.nextInt();
	    if(N==0 & M == 0) break;
	    
	    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)==false){
			System.out.println("UNKNOWN");
		    }else{
			System.out.println(w[b]-w[a]);
		    }
		}
	    }
	}	
    }
}

Compiler output:
Main.java:84: error: unnamed classes are a preview feature and are disabled by default.
    public static int findSet(int i) {
                  ^
  (use --enable-preview to enable unnamed classes)
Main.java:131: error: class, interface, enum, or record expected
}
^
2 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[b] - weight[a];

        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(x, y)){
                    System.out.println("UNKNOWN");
                }else{
                    System.out.println(weight[b]-weight[a]);
		}
            }
        }
       }
      }
    }
}

Compiler output:
Main.java:45: error: ';' expected
        weight = new int[N]
                           ^
Main.java:86: error: class, interface, enum, or record expected
}
^
2 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[b] - weight[a];

        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(x, y)){
                    System.out.println("UNKNOWN");
                }else{
                    System.out.println(weight[b]-weight[a]);
		}
            }
        }
       }
      
    }
}

Compiler output:
Main.java:17: error: cannot find symbol
        w -= weight[b] - weight[a];
                    ^
  symbol:   variable b
  location: class Main
Main.java:17: error: cannot find symbol
        w -= weight[b] - weight[a];
                                ^
  symbol:   variable a
  location: class Main
Main.java:76: error: cannot find symbol
               if(same(x, y)){
                       ^
  symbol:   variable x
  location: class Main
Main.java:76: error: cannot find symbol
               if(same(x, y)){
                          ^
  symbol:   variable y
  location: class Main
Main.java:79: error: cannot find symbol
                    System.out.println(weight[b]-weight[a]);
                                              ^
  symbol:   variable b
  location: class Main
Main.java:79: error: cannot find symbol
                    System.out.println(weight[b]-weight[a]);
                                                        ^
  symbol:   variable a
  location: class Main
6 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(x, y)){
                    System.out.println("UNKNOWN");
                }else{
                    System.out.println(weight[b]-weight[a]);
		}
            }
        }
       }
      
    }
}

Compiler output:
Main.java:76: error: cannot find symbol
               if(same(x, y)){
                       ^
  symbol:   variable x
  location: class Main
Main.java:76: error: cannot find symbol
               if(same(x, y)){
                          ^
  symbol:   variable y
  location: class Main
Main.java:79: error: cannot find symbol
                    System.out.println(weight[b]-weight[a]);
                                              ^
  symbol:   variable b
  location: class Main
Main.java:79: 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 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: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 a, int b) {
        return findSet(a) == findSet(b);
    }
 
    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