codeparrot/codecomplex huggingface dataset:
// Problem: 16_E. Fish
// Time complexity: np
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;


public class Main implements Runnable {	
	
	int n;
	double[] prob;
	double[][] a;
	
	void solve() throws IOException {
		n = nextInt();
		a = new double[n][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				a[i][j] = nextDouble();
			}
		}
		prob = new double[1<<n];
		Arrays.fill(prob, 0.0);
		prob[(1<<n)-1] = 1.0;
		for (int i = (1<<n)-1; i > 1; --i) {
			int c = 0;
			for (int bit = 0; bit < n; ++bit) {
				if (((1<<bit) & i) > 0) {
					++c;
				}
			}
			double k = c * (c - 1) / 2.0;
			for (int f = 0; f < n; ++f) {
				if (((1<<f) & i) > 0) {
					for (int s = f+1; s < n; ++s) {
						if (((1<<s) & i) > 0) {
							prob[i^(1<<f)] += prob[i] * a[s][f] / k;
							prob[i^(1<<s)] += prob[i] * a[f][s] / k;
						}
					}
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			writer.printf(Locale.US, "%.6f ", prob[1<<i]);
		}
	}

	public static void main(String[] args) throws InterruptedException {
		 new Thread(null, new Runnable() {
            public void run() {
                new Main().run();
            }
	     }, 
	     "1", 
	     1 << 25).start();
	}
	
	@Override
	public void run() {
		try {
			boolean fromStandart = true;
			reader = new BufferedReader(fromStandart ? new InputStreamReader(System.in) : new FileReader(INFILE));
            writer = new PrintWriter(new BufferedWriter(fromStandart ? new OutputStreamWriter(System.out) : new FileWriter(OUTFILE)));
			tokenizer = null; 
			solve();
			writer.flush();
		} catch (Exception error) {
			error.printStackTrace();
			System.exit(1);
		}
	}
	
	static final String INFILE = "input.txt";
	static final String OUTFILE = "output.txt";
	
	BufferedReader reader;
	StringTokenizer tokenizer;
    PrintWriter writer;

	int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    
    String nextString() throws IOException {
    	return reader.readLine();
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    } 	

}
// Problem: 16_E. Fish
// Time complexity: np
import java.util.Locale;
import java.util.Scanner;

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

	private void run() {
		Locale.setDefault(Locale.US);
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[][] p = new double[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				p[i][j] = sc.nextDouble();
		}
		sc.close();
		double[] w = new double[1 << n];
		int max = (1 << n) - 1;
		w[max] = 1;
		for (int mask = max; mask > 0; mask--) {
			int count = 0;
			for (int i = 0; i < n; i++)
				if (((mask >> i) & 1) > 0)
					for (int j = i + 1; j < n; j++)
						if (((mask >> j) & 1) > 0) {
							count++;
						}
			if (count > 0)
				for (int i = 0; i < n; i++)
					if (((mask >> i) & 1) > 0)
						for (int j = i + 1; j < n; j++)
							if (((mask >> j) & 1) > 0) {
								w[mask ^ (1 << j)] += w[mask] * p[i][j] / count;
								w[mask ^ (1 << i)] += w[mask] * (1 - p[i][j])
										/ count;
							}
		}
		for (int i = 0; i < n; i++) {
			if (i != 0)
				System.out.print(' ');
			System.out.printf("%.6f", w[1 << i]);
		}
		System.out.println();
	}
}
// Problem: 16_E. Fish
// Time complexity: np
import java.io.*;
import java.util.*;
 

public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader kek = new BufferedReader(new InputStreamReader(System.in));
		//Scanner skek = new Scanner(System.in);
		PrintWriter outkek = new PrintWriter(System.out);

		int N = Integer.parseInt(kek.readLine());
		double[][] lake = new double[N][N];
		
		for(int i = 0; i < N; i++){
			String[] input = kek.readLine().split(" ");
			for(int j = 0; j < N; j++){
				lake[i][j] = Double.parseDouble(input[j]);
			}
		}
		
		int pow = (int)Math.pow(2, N);
		double[] res = new double[pow];
		res[pow - 1] = 1.0;
		
		for(int i = pow - 1; i >= 0; i--){
			int ones = Integer.bitCount(i); // So this is apparently a thing
			int possibleCombos = ones * (ones - 1) /2;
			
			for(int j = 0; j < N; j++){
				if((i >> j) % 2 == 0){ // (X >> Y) literally does the same thing as divis func. Bit operators are weird.
					continue;
				}
				for(int k = j + 1; k < N; k++){
					if((i >> k) % 2 == 0){
						continue;
					}
					res[i ^ (1 << k)] += res[i] * lake[j][k]/possibleCombos;
					res[i ^ (1 << j)] += res[i] * lake[k][j]/possibleCombos;
				}
			}
			
		}
		
		for(int i = 0; i < N; i++){
			outkek.print(res[1 << i] + " ");
		}
		
		kek.close();
		outkek.close();
	}	
	
	/*static int divis(int n, int a){
		for(int i = 0; i < a; i++){
			n /= 2;
		}
		return n;
	}*/
		
}
// Problem: 16_E. Fish
// Time complexity: np
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main implements Runnable {
    
    // ////////////////////////////////////////////////////////////////////
    // Solution

    private int n;
    private int nn;
    private double[][] a;
    private double[] dp;

    private void solve() throws Throwable {
        n = nextInt();
        nn = 1 << n;
        a = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = nextDouble();
            }
        }
        dp = new double[nn];
        Arrays.fill(dp, -1.0);
        dp[nn - 1] = 1.0;
        for (int j = 0; j < n; j++) {
            pw.format(Locale.US, "%.7f ", Dp(1 << j));
        }
    }

    private double Dp(int i) {
        if (dp[i] >= 0.0)
            return dp[i];
        
        double ans = 0;
        int count = Integer.bitCount(i);
        for (int j = 0; j < n; j++) {
            int jj = 1 << j;
            if ((jj & i) == 0) {
                double p = Dp(jj | i);
                double pPair = 2.0 / (double)((count + 1) * count);
                double s = 0;
                for (int l = 0; l < n; l++) {
                    int ll = 1 << l;
                    if ((ll & i) != 0) {
                        s += a[l][j];
                    }
                }
                ans += p * pPair * s;
                
            }
        }
        dp[i] = ans;
        return dp[i];
    }

    // ////////////////////////////////////////////////////////////////////
    // Utility functions

    PrintWriter pw;
    BufferedReader in;
    StringTokenizer st;

    void initStreams() throws FileNotFoundException {
        //System.setIn(new FileInputStream("1"));
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
    }

    String nextString() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextString());
    }

    long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextString());
    }

    double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextString());
    }

    static Throwable sError;

    public static void main(String[] args) throws Throwable {
        Thread t = new Thread(new Main());
        t.start();
        t.join();
        if (sError != null) {
            throw sError;
        }
    }

    public void run() {
        try {
            initStreams();
            solve();
        } catch (Throwable e) {
            sError = e;
        } finally {
            if (pw != null)
                pw.close();
        }
    }
}
// Problem: 16_E. Fish
// Time complexity: np
import java.util.Locale;
import java.util.Scanner;

public class E {
    public static void main(String[] args) {
        new E().solve();
    }
    
    private int c(int n) {
        return n * (n - 1) / 2;
    }
    
    public void solve() {
        Locale.setDefault(Locale.US);
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[][] pb = new double[n][n];
        for (int i=0; i<n; ++i)
            for (int j=0; j<n; ++j)
                pb[i][j] = sc.nextDouble();
        
        int m = (1<<n);
        double[] dp = new double[m];
        dp[0] = 1.0f;
        for (int i=1; i<m; ++i)
            for (int j=0; j<n; ++j) if ((i & (1<<j)) != 0)
                for (int k=0; k<n; ++k) if ((i & (1<<k)) == 0)
                    dp[i] += pb[k][j] * dp[i & ~(1<<j)] / c(n - Integer.bitCount(i) + 1);
        
        int w = (1<<n) - 1;
        for (int i=0; i<n-1; ++i)
            System.out.printf("%.6f ", dp[w & ~(1<<i)]);
        System.out.printf("%.6f\n", dp[w & ~(1<<(n-1))]);
    }
}
// Problem: 16_E. Fish
// Time complexity: np
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileReader;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.Arrays;

public class Fish extends Thread {

    public Fish() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }


    private void solve() throws Throwable {
        int n = nextInt();
        double[][] a = new double[n][n];
        double[] dp = new double[(1 << n)];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                a[i][j] = nextDouble();
            }
        }
        int limit = (1 << n) - 1;
        //dp[mask] = probability of current subset (mask) to remain in the end
        dp[limit] = 1.0;
        for (int mask = limit; mask > 0; --mask) {
            int cardinality = Integer.bitCount(mask);
            int probability = cardinality * (cardinality - 1) / 2;
            for (int first = 0; first < n; ++first) {
                if ((mask & powers[first]) != 0) {
                    for (int second = first + 1; second < n; ++second) {
                        if ((mask & powers[second]) != 0) {
                            dp[mask - powers[first]] += dp[mask] * a[second][first] / probability;
                            dp[mask - powers[second]] += dp[mask] * a[first][second] / probability;
                        }

                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            output.printf("%.10f ", dp[powers[i]]);
        }
    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }


    public static void main(String[] args) {
        new Fish().start();
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    static int powers[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}
// Problem: 16_E. Fish
// Time complexity: np
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class Main {
    
    public static void main(String[] args) throws Exception { 
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter pw = new PrintWriter(System.out);
        
        in.nextToken();
        int n = (int) in.nval;
        double[][] a = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                in.nextToken();
                a[i][j] = in.nval;
            }
        }
        
        double[] dp = new double[1 << n];
        dp[(1 << n) - 1] = 1.0;
        
        for (int mask = (1 << n) - 2; mask > 0; mask--) {
            int count = Integer.bitCount(mask);
            double pPair = 2.0 / ((double) count * (count + 1));
            double ans = 0.0;
            
            for (int j = 0; j < n; j++) {
                int jj = 1 << j;
                if ((jj & mask) != 0) continue;
                double p = dp[mask | jj];
                double s = 0;
                for (int k = 0; k < n; k++) {
                    int kk = 1 << k;
                    if ((kk & mask) == 0) continue;
                    s += a[k][j];
                }
                ans += s * pPair * p;
            }
            dp[mask] = ans;
        }
        
        for (int i = 0; i < n; i++) {
            pw.print(dp[1 << i]);
            pw.print(' ');
        }
        
        pw.close();
    }
}
// Problem: 16_E. Fish
// Time complexity: np
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class E {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static double[][] p;
	static DecimalFormat format = new DecimalFormat("0.000000");

	public static void main(String[] args) throws Exception {
		N = sc.nextInt();
		p = new double[N][N];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				p[i][j] = sc.nextDouble();
			}
		}
		double[] memo = new double[1 << N];
		memo[memo.length - 1] = 1;
		for (int i = N; i >= 2; --i) {
			int[] live = new int[N];
			for (int j = 0; j < i; ++j) {
				live[N - 1 - j] = 1;
			}
			do {
				int n = toInt(live);
				double norm = 2.0 / i / (i - 1);
				for (int f1 = 0; f1 < N; ++f1) {
					if (live[f1] == 0) continue;
					for (int f2 = f1 + 1; f2 < N; ++f2) {
						if (live[f2] == 0) continue;
						memo[n - (1 << f1)] += memo[n] * p[f2][f1] * norm;
						memo[n - (1 << f2)] += memo[n] * p[f1][f2] * norm;
					}
				}
			} while (nextPermutation(live));
			//			System.out.println(Arrays.toString(memo));
		}
		for (int i = 0; i < N; ++i) {
			System.out.print(format.format(memo[1 << i]));
			if (i < N - 1) {
				System.out.print(" ");
			}
		}
	}

	static int toInt(int[] a) {
		int ret = 0;
		for (int i = 0; i < N; ++i) {
			ret += (1 << i) * a[i];
		}
		return ret;
	}

	public static boolean nextPermutation(int[] a) {
		for (int i = a.length - 1; i > 0; --i) {
			if (a[i - 1] < a[i]) {
				int swapIndex = find(a[i - 1], a, i, a.length - 1);
				int temp = a[swapIndex];
				a[swapIndex] = a[i - 1];
				a[i - 1] = temp;
				Arrays.sort(a, i, a.length);
				return true;
			}
		}
		return false;
	}

	private static int find(int dest, int[] a, int s, int e) {
		if (s == e) {
			return s;
		}
		int m = (s + e + 1) / 2;
		return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);
	}
}
// Problem: 16_E. Fish
// Time complexity: np
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	
	public Main() {
		super();
	}
	
	public static void main(String... args) {
		Main main = new Main();
		main.start();
	}
	
	public void start() {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		double a[][] = new double[n][n];
		for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = Double.parseDouble(in.next());
		
		int nn = 1 << n;
		double p[] = new double[nn];
		Arrays.fill(p, -1.0);
        p[nn - 1] = 1.0;

		DecimalFormat f = new DecimalFormat();
		f.applyPattern("0.000000");
		for (int i = 0; i < n; i++) {
			if (i != 0) System.out.print(" ");
			System.out.print(f.format(this.probability(a, p, 1 << i)));
		}
	}
	
	private double probability(double a[][], double p[], int i) {
        if (p[i] >= 0.0) return p[i];
        double ans = 0;
        int count = Integer.bitCount(i);
        int n = a.length;
        for (int j = 0; j < n; j++) {
            int jj = 1 << j;
            if ((jj & i) == 0) {
                double d = this.probability(a, p, jj | i);
                double dPair = 2.0 / (double)((count + 1) * count);
                double s = 0;
                for (int l = 0; l < n; l++) {
                    int ll = 1 << l;
                    if ((ll & i) != 0) s += a[l][j];
                }
                ans += d * dPair * s;
            }
        }
        p[i] = ans;
        return p[i];
    }


	
}
// Problem: 16_E. Fish
// Time complexity: np
import java.util.Scanner;

public class Fishes {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        double[][] p = new double[n][n];
        double[] dp = new double[1 << 18];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                p[i][j] = Double.parseDouble(s.next());
            }
        }
        int last = 1 << n;
        dp[last - 1] = 1.0;
        for (int i = last - 2; i > 0; i--) {
            int res = 0;
            for (int j = 0; j < n; j++) {
                if (((1 << j) & i) > 0) res++;
            }
            res++;
            res = res * (res - 1) / 2;
            for (int j = 0; j < n; j++) {
                if (((1 << j) & i) == 0) {
                    for (int z = 0; z < n; z++) {
                        if (((1 << z) & i) > 0) {
                            dp[i] += dp[i | (1 << j)] * 1.0 / res * p[z][j];
                        }
                    }
                }
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.print(dp[1 << i] + " ");
        }
    }

}
// Problem: 16_E. Fish
// Time complexity: np
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;


public class Task16e {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[][] prob = new double[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				prob[i][j] = sc.nextDouble();
			}
		}
		double[] var = new double[1 << n];
		boolean[] was = new boolean[1 << n];
		Arrays.fill(var, 0.0);
		Arrays.fill(was, false);
		was[0] = true;
		var[(1 << n) - 1] = 1.0;
		Set<Integer> cr = new HashSet<Integer>();
		Set<Integer> nx = new HashSet<Integer>();
		nx.add((1 << n) - 1);
		boolean[] fish = new boolean[n];
		for (int cnt = 0; cnt < n -1; cnt++) {
			cr.clear();
			cr.addAll(nx);
			nx.clear();
			for (Iterator<Integer> iterator = cr.iterator(); iterator.hasNext();) {
				int curr = iterator.next();
				for (int i = 0; i < n; i++) {
					fish[i] = ((1 << i) & curr) != 0;
				}
				int fishn = 0;
				for (int i = 0; i < n; i++) {
					if (fish[i]) fishn++;
				}
				if (fishn == 1) continue;
				
				for (int i = 0; i < n; i++) {
					if (!fish[i]) continue;
					for (int j = i + 1; j < n; j++) {
						if (!fish[j]) continue;
						int woi = curr & ~(1 << i);
						int woj = curr & ~(1 << j);
						var[woi] += var[curr] * prob[j][i];
						var[woj] += var[curr] * prob[i][j];
						nx.add(woi);
						nx.add(woj);
					}
				}
			}
		}
		double sum = 0.0;
		for (int i = 0; i < n; i++) {
			sum += var[1 << i];
		}
		for (int i = 0; i < n; i++) {
			System.out.printf("%.6f ", var[1 << i] / sum);
		}
	}

}
// Problem: 1209_E1. Rotate Columns (easy version)
// Time complexity: np
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class E {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int T = Integer.parseInt(bf.readLine());
        for(int t=0; t<T; t++) {
          StringTokenizer st = new StringTokenizer(bf.readLine());
          int n = Integer.parseInt(st.nextToken());
          int m = Integer.parseInt(st.nextToken());
          int[][] a = new int[n][m];
          for(int i=0; i<n; i++) {
            st = new StringTokenizer(bf.readLine());
            for(int j=0; j<m; j++) a[i][j] = Integer.parseInt(st.nextToken());

          }
          // small case
          int[] max = new int[m];
          for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
              if(a[i][j] > max[j]) max[j] = a[i][j];
            }
          }
          int[][] pos = new int[m][2];
          for(int i=0; i<m; i++) {
            pos[i][0] = max[i];
            pos[i][1] = i;
          }
          Arrays.sort(pos, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
              return Integer.compare(o2[0], o1[0]);
            }
          });

          int[][] new_a = new int[n][Math.min(n,m)];
          for(int i=0; i<n; i++) {
            for(int j=0; j<Math.min(n,m); j++) {
              new_a[i][j] = a[i][pos[j][1]];
            }
          }
          int exp = 1; for(int i=0; i<Math.min(n,m); i++) exp *= n;
          int maxval = -1;
          for(int i=0; i<exp; i++) {
          //  int val = i;
            int sum = 0;
            for(int j=0; j<n; j++) {
              int toAdd = 0;
              int val = i;
              for(int k=0; k<Math.min(n,m); k++) {
                int tooAdd = new_a[(j+val)%n][k];
                val /= n;
                if(tooAdd > toAdd) toAdd = tooAdd;
              }
              sum += toAdd;
            }
            if(sum > maxval) maxval = sum;
          }
          out.println(maxval);

        }

        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
}