Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

C++: #include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	int Adj[101][101] = {{0}};
	for (int i = 0;i < n;i++) {
		int th;
		cin >> th;
		int k;
		cin >> k;
		int adj;
		if(k>0)
		for (int j = 0;j < k;j++) {
			cin >> adj;
			Adj[th-1][adj-1] = 1;
		}
	}

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			if (j) cout << " ";
			cout << Adj[i][j];
		}
		cout << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

bool A[110][110];

int main (){
	int n,a,b,c;
	cin>>n;
	for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				A[i][j]=false;
		}
	}
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		for(int j=1;j<=b;j++){
			cin>>c;
			A[a][c]=true;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cout<<A[i][j]<<(j==n?"\n":" ");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

typedef long long ll;
using namespace std;
const int mod = 1000000007;


int main() {

    int n; cin >> n;
    vector< vector<int> > Adj(n, vector<int>(n, 0));

    for (int i = 0; i < n; i++) {
        int u, k; cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v; cin >> v;
            v--;
            Adj[u][v] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j != n-1) {
                cout << Adj[i][j] << ' ';
            }
            else {
                cout << Adj[i][j] << '\n';
            }
        }
    }

}

C++: #include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;

  int** G = new int*[n+1];
  for (int i = 0; i < n; i++) {
    int u,k,v;
    cin >> u >> k;
    G[u] = new int[n+1];
    for (int j = 0; j < k; j++) {
      cin >> v;
      G[u][v] = 1; 
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << G[i][1];
    for (int j = 2; j <= n; j++) {
      cout << " " << G[i][j];
    }
    cout << endl;
  }

  return 0;
}

C++: #include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0||n==1) return dp[n]=1;
  if(dp[n]!=-1) return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++) dp[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}

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

int main()
{
    int n;
    cin >> n;

    vector<vector<int>> graph(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            graph[u - 1][v - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j > 0) {
                cout << " ";
            }
            cout << graph[i][j];
        }
        cout << endl;
    }

}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n; vector<vector<int> >vec(n, vector<int>(n, 0));
	rep(i, 0, n) {
		int u, k; cin >> u >> k;
		u--;
		rep(j, 0, k) {
			int v; cin >> v; v--;
			vec[u][v] = 1;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, n) {
			if (j)cout << " ";
			cout << vec[i][j];
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main(){
  int M[N][N];
  int n,u,k,v;

  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j <n; j++)M[i][j]=0;
  }

  for(int i = 0;i <n; i++){
    cin >> u >> k;
    u--;
    for(int j =0; j <k; j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  for( int i =0;i<n;i++){
    for(int j =0;i<n;j++){
      if(j)cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
    int n;
    cin >> n;
    int ans[n][n];
    rep (i, n) rep (j, n) ans[i][j] = 0;
    rep (i, n) {
        int a, k;
        cin >> a >> k;
        rep (j, k) {
            int b;
            cin >> b;
            ans[a - 1][b - 1] = 1;
        }
    }
    rep (i, n) {
        rep (j, n) {
            if (j != 0) cout << " ";
            cout << ans[i][j];
        }
        cout << "\n";
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  const int INF = 1e7;  //とても大きい値を無限としておく。
int u,k;
cin >> u>> k;  //Vは与えられた頂点数,Eは辺の数
vector<vector<int>> a(u,vector<int>(u,INF));//V*Vを無限で初期化
for(int i=0;i<k;++i){
    //s→tへの有向辺として入力が与えられたとする。//wは重み
    int s,t;       //,w
    cin >> s >> t; //>>w
    a[s][t] = 1;   //a[s][t] = w;
    //a[t][s] = 1; (s-tの無向辺の場合)
}
  
    
}

C++: #include<iostream>
using namespace std;
int N,n,u,k,v;
int main()
{
    cin>>N;
    int A[N][N];
    for(int p=0;p<N;p++)
        for(int q=0;q<N;q++)
            A[p][q]=0;
    for(n=0;n<N;n++)
    {
        cin>>u>>k;
        for(int i=0;i<k;i++)
        {
            cin>>v;
            A[u-1][v-1]=1;
        }
    }
    for(int p=0;p<N;p++)
    {
        for(int q=0;q<N-1;q++)
        {
            cout<<A[p][q]<<' ';
        }
        cout<<A[p][N-1]<<endl;
    }
    return 0;
}

C++: #include <cstdio>

#define N 100
int main(){
    int a[N+1][N+1] = {};

    int n;
    std::scanf("%d", &n);

    for(int i = 1; i <= n; ++i){
        int id;
        std::scanf("%d", &id);
        int m;
        std::scanf("%d", &m);
        for(int j = 1; j <= m; ++j){
            int x;
            std::scanf("%d", &x);
            a[id][x] = 1;
        }
    }
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            std::printf("%d", a[i][j]);
            if(j != n) std::printf(" ");
            else std::printf("\n");
        }
    }

    return 0;
}