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

#include <stdio.h>
 
int main(void){
  int min = 0;
  int inter = 0;
  int max = 0;
  int i,j,q,r;
  int n[30];
  
  if( scanf("%d", &r) == 1);
  
  for(i = 0; i < r; i++){
    scanf("%d", &n[i]);
  }
  
  for(j = 0; j < r; j++){
    for(q = 1; q < r; q++){
    	if(n[j] < n[q]){
          max = n[q];
          if(min < n[j]){
            inter = n[j];
          }else{
            min = n[j];
          }
        }else{
          max = n[j];
          if(min < n[q]){
            inter = n[q];
          }else{
            min = n[q];
          }
        }
    }
  }
 return (0);
}
#include <stdio.h>
 
int main(void){
  int min = 0;
  int inter = 0;
  int max = 0;
  int i,j,q,r;
  int n[30];
  
  if( scanf("%d", &n) == 1);
  
  for(i = 0; i < r; i++){
    scanf("%d", &n[i]);
  }
  
  for(j = 0; j < r; j++){
    for(q = 1; q < r; q++){
    	if(n[j] < n[q]){
          max = n[q];
          if(min < n[j]){
            inter = n[j];
          }else{
            min = n[j];
          }
        }else{
          max = n[j];
          if(min < n[q]){
            inter = n[q];
          }else{
            min = n[q];
          }
        }
    }
  }
 return (0);
}
提出情報
#include <stdio.h>
 
int main(void){
  int min = 0;
  int inter = 0;
  int max = 0;
  int i,j,q,r;
  int n[30];
  
  if( scanf("%d", &r) == 1);
  
  for(i = 0; i < r; i++){
    if( scanf("%d", &n[i]) == 1);
  }
  
  for(j = 0; j < r; j++){
    for(q = 1; q < r; q++){
    	if(n[j] < n[q]){
          max = n[q];
          if(min < n[j]){
            inter = n[j];
          }else{
            min = n[j];
          }
        }else{
          max = n[j];
          if(min < n[q]){
            inter = n[q];
          }else{
            min = n[q];
          }
        }
    }
  }
 return (0);
}
#include <stdio.h>
 
int main(void){
  int min = 0;
  int inter = 0;
  int max = 0;
  int i,j,q,r;
  int n[30];
  
  if( scanf("%d", &n) == 1);
  
  for(i = 0; i < r; i++){
    scanf("%d", &n[i]);
  }
  
  for(j = 0; j < r; j++){
    for(q = 1; q < r; q++){
    	if(n[j] < n[q]){
          max = n[q];
          if(min < n[j]){
            inter = n[j];
          }else{
            min = n[j];
          }
        }else{
          max = n[j];
          if(min < n[q]){
            inter = n[q];
          }else{
            min = n[q];
          }
        }
    }
  }
 return (0);
}

Compiler output:
main.c:39:5: error: redefinition of 'main'
   39 | int main(void){
      |     ^~~~
main.c:3:5: note: previous definition of 'main' with type 'int(void)'
    3 | int main(void){
      |     ^~~~
main.c:73:9: error: expected ';' before 'int'
   73 | 提出情報
      |         ^
      |         ;
......
   76 | int main(void){
      | ~~~      
main.c:76:5: error: redefinition of 'main'
   76 | int main(void){
      |     ^~~~
main.c:3:5: note: previous definition of 'main' with type 'int(void)'
    3 | int main(void){
      |     ^~~~
main.c:112:5: error: redefinition of 'main'
  112 | int main(void){
      |     ^~~~
main.c:3:5: note: previous definition of 'main' with type 'int(void)'
    3 | int main(void){
      |     ^~~~
Language: C

#include <stdio.h>
 
int main(void){
  int min = 0;
  int inter = 0;
  int max = 0;
  int i,j,q,r;
  int n[30];
  
  if( scanf("%d", &r) == 1);
  
  for(i = 0; i < r; i++){
    scanf("%d", &n[i]);
  }
  
  for(j = 0; j < r; j++){
    for(q = 1; q < r; q++){
    	if(n[j] < n[q]){
          max = n[q];
          if(min < n[j]){
            inter = n[j];
          }else{
            min = n[j];
          }
        }else{
          max = n[j];
          if(min < n[q]){
            inter = n[q];
          }else{
            min = n[q];
          }
        }
    }
  }
 return (0);
}
#include <stdio.h>
 
int main(void){
  int min = 0;
  int inter = 0;
  int max = 0;
  int i,j,q,r;
  int n[30];
  
  if( scanf("%d", &n) == 1);
  
  for(i = 0; i < r; i++){
    scanf("%d", &n[i]);
  }
  
  for(j = 0; j < r; j++){
    for(q = 1; q < r; q++){
    	if(n[j] < n[q]){
          max = n[q];
          if(min < n[j]){
            inter = n[j];
          }else{
            min = n[j];
          }
        }else{
          max = n[j];
          if(min < n[q]){
            inter = n[q];
          }else{
            min = n[q];
          }
        }
    }
  }
 return (0);
}
提出情報


Compiler output:
main.c:39:5: error: redefinition of 'main'
   39 | int main(void){
      |     ^~~~
main.c:3:5: note: previous definition of 'main' with type 'int(void)'
    3 | int main(void){
      |     ^~~~
main.c:73:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
   73 | 提出情報
      | ^~~~~~~~
Language: C++

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	bool increasing = true;
	for(int i = 1; i < n; ++i){
		if(a[i] <= a[i - 1]){ increasing = false; }
	}
	if(increasing){
		cout << 1 << endl;
		return 0;
	}
	int lo = 2, hi = n;
	while(lo < hi){
		const int mid = lo + (hi - lo) / 2;
		bool accept = true;
		map<int, int> nonzero;
			if(a[i] > a[i - 1]){ continue; }
			nonzero.erase(nonzero.lower_bound(a[i]), nonzero.end());
			int index = a[i] - 1;
			auto it = nonzero.end();
			while(index >= 0){
				if(it == nonzero.begin()){
					nonzero.emplace(index, 1);
					break;
				}
				--it;
				if(it->first < index){
					nonzero.emplace(index, 1);
					break;
				}
				if(it->second + 1 < mid){
					it->second += 1;
					break;
				}
				it = nonzero.erase(it);
				--index;
			}
			if(index < 0){
				accept = false;
			}
		}
		if(accept){
			hi = mid;
		}else{
			lo = mid + 1;
		}
	}
	cout << lo << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:28:30: error: 'i' was not declared in this scope; did you mean 'hi'?
   28 |                         if(a[i] > a[i - 1]){ continue; }
      |                              ^
      |                              hi
a.cc:29:61: error: 'i' was not declared in this scope; did you mean 'hi'?
   29 |                         nonzero.erase(nonzero.lower_bound(a[i]), nonzero.end());
      |                                                             ^
      |                                                             hi
a.cc:53:20: error: 'accept' was not declared in this scope
   53 |                 if(accept){
      |                    ^~~~~~
a.cc:54:30: error: 'mid' was not declared in this scope
   54 |                         hi = mid;
      |                              ^~~
a.cc:56:30: error: 'mid' was not declared in this scope
   56 |                         lo = mid + 1;
      |                              ^~~
a.cc: At global scope:
a.cc:59:9: error: 'cout' does not name a type
   59 |         cout << lo << endl;
      |         ^~~~
a.cc:60:9: error: expected unqualified-id before 'return'
   60 |         return 0;
      |         ^~~~~~
a.cc:61:1: error: expected declaration before '}' token
   61 | }
      | ^
Language: C++

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

struct tr{
    ll x,y;
};

bool operator < (tr a, tr b){
    return a.x < b.x;
}

ll h,w,n;
vector<tr> a;

main(){
    cin >> h >> w >> n;
    ll f1,f2;
    a.resize(n);
    for(int i=0;i<n;++i){
        cin >> f1 >> f2;
        a[i] = {f1,f2};
    }
    sort(a.begin(),a.end());

    set<pair<ll,ll>> no_points;
    ll ans = h;
    for(int i=0;i<n;++i){
        if(no_points.count({a[i].x,a[i].y}) == 0 && a[i].x-1>=a[i].y){
            ans = a[i].x-1;
            //cout << "ans_p" << a[i].x << ' ' << a[i].y << "\n";
            break;
        }
        else{
            for(int j=0;j<min(1000,h-a[i].x,w-a[i].y);++j){
                //cout << a[i].x+j+1 << ' ' << a[i].y+j << "\n";
                if(no_points.count({a[i].x+j+1,a[i].y+j})){
                    break;
                }
                no_points.insert({a[i].x+j+1,a[i].y+j});
            }
        }
    }

    cout << ans;

}


Compiler output:
a.cc:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:35:30: error: no matching function for call to 'min(int, ll, ll)'
   35 |             for(int j=0;j<min(1000,h-a[i].x,w-a[i].y);++j){
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
a.cc:35:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   35 |             for(int j=0;j<min(1000,h-a[i].x,w-a[i].y);++j){
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 3 provided
Language: C++

#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
std::vector<int>a[maxn];
int h[maxn];
int n,m,k;
int check(int x,int y)
{
	if(x<1||x>n||y<1||y>m)return 0;
	int pos=std::lower_bound(a[y].begin(),a[y].end(),x)-a[y].begin();
	if(pos==a[y].size())return 0;
	else return (x==a[y][pos]);
}
int main()
{
	n=read(); m=read(); k=read();
	for(int i=1;i<=k;i++){
		int x=read(),y=read();
		a[y].push_back(x);
	}
	for(int i=1;i<=m;i++)
		std::sort(a[i].begin(),a[i].end());
	int x=1,y=1;
	for(int i=1;i<=m;i++){
		// printf("%d %d\n",x,y);
		h[y]=x;
		if(check(x+1,y))break;
		else ++x;
		// puts("A");
		while(x<=n&&check(x,y+1))++x;
		++y;
		if(check(x,y))break;
	}
	int ans=n;
	for(int i=1;i<=m;i++)
		for(int j=0;j<a[i].size();j++)
			if(a[i][j]>h[i])ans=std::min(ans,a[i][j]-1);
	writeln(ans);
	// for(int i=1;i<=m;i++)
	// 	writesp(h[i]);
	// putchar('\n');
	return 0;
}

Compiler output:
a.cc:27:6: error: 'vector' in namespace 'std' does not name a template type
   27 | std::vector<int>a[maxn];
      |      ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include<algorithm>
  +++ |+#include <vector>
    6 | #define ll long long
a.cc: In function 'int check(int, int)':
a.cc:33:34: error: 'a' was not declared in this scope
   33 |         int pos=std::lower_bound(a[y].begin(),a[y].end(),x)-a[y].begin();
      |                                  ^
a.cc: In function 'int main()':
a.cc:42:17: error: 'a' was not declared in this scope
   42 |                 a[y].push_back(x);
      |                 ^
a.cc:45:27: error: 'a' was not declared in this scope
   45 |                 std::sort(a[i].begin(),a[i].end());
      |                           ^
a.cc:59:31: error: 'a' was not declared in this scope
   59 |                 for(int j=0;j<a[i].size();j++)
      |                               ^
Language: C++

/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const int INF = 1e9;
main(){
   int h, w, n;
   cin >> h >> w >> n;
    vector<int> mn(h, INF);
    int x, y;
	for (int i = 0; i < n; i++)
        cin >> x >> y,mn[x]=min(mn[x],y);
    int i, y;
	for (i = 2,y = 1;i <= H; i++){
		if(y >= mn[i])
            break;
		y += (y+1<mn[i]);
	}
	cout << i - 1;
	return 0;

}


Compiler output:
a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:12: error: redeclaration of 'int y'
   29 |     int i, y;
      |            ^
a.cc:26:12: note: 'int y' previously declared here
   26 |     int x, y;
      |            ^
a.cc:30:31: error: 'H' was not declared in this scope
   30 |         for (i = 2,y = 1;i <= H; i++){
      |                               ^
Language: C++

/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const int INF = 1e9;
main(){
   int h, w, n;
   cin >> h >> w >> n;
    vector<int> mn(h, INF);
	for (int i = 0; i < n; i++)
        cin >> x >> y,mn[x]=min(mn[x],y);
    int i, y;
	for (i = 2,y = 1;i <= H; i++){
		if(y >= mn[i])
            break;
		y += (y+1<mn[i]);
	}
	cout << i - 1;
	return 0;

}


Compiler output:
a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:27:16: error: 'x' was not declared in this scope
   27 |         cin >> x >> y,mn[x]=min(mn[x],y);
      |                ^
a.cc:27:21: error: 'y' was not declared in this scope
   27 |         cin >> x >> y,mn[x]=min(mn[x],y);
      |                     ^
a.cc:29:31: error: 'H' was not declared in this scope
   29 |         for (i = 2,y = 1;i <= H; i++){
      |                               ^
Language: C++

using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace AtTest.AGC_029
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] hwn = ReadInts();
            int h = hwn[0];
            int w = hwn[1];
            int n = hwn[2];
            var obsPos = new int[n][];
            for (int i = 0; i < n; i++)
            {
                obsPos[i] = ReadInts();
            }
            obsPos = obsPos.OrderBy(a => a[0]).ToArray();
            obsPos = obsPos.OrderBy(a => a[1]).ToArray();
            var xList = new List<int>[h];
            for (int i = 0; i < h; i++)
            {
                xList[i] = new List<int>();
                xList[i].Add(0);
            }
            for (int i = 0; i < n; i++)
            {
                xList[obsPos[i][1] - 1].Add(obsPos[i][0]);
            }
            for (int i = 0; i < h; i++) xList[i].Add(w + 1);

            int res = w;
            int min = 0;
            for (int i = 0; i < h; i++)
            {
                min++;
                int j = 0;
                while (j < xList[i].Count && xList[i][j] <= min)
                {
                    if (xList[i][j] == min) min++;
                    j++;
                }
                if (j < xList[i].Count) res = Math.Min(res, xList[i][j] - 1);
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Text;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Linq;
      |       ^~~~~~
a.cc:6:17: error: expected '{' before '.' token
    6 | namespace AtTest.AGC_029
      |                 ^
a.cc:6:17: error: expected unqualified-id before '.' token
Language: C++

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

using namespace std;

typedef pair<int, int> Pii;

set<int> mp[200000];

int main() {
    int h,w,n,x,y;
    cin >> h >> w >> n;
    
    for(int i=0;i<n;++i) {
        cin >> x >> y;
        mp[y].insert(x);
    }

    for(int i=1;i<=w;++i) mp[i].insert(h+1);

    vector<Pii> v;
    int j_lower_lim = 1;
    for(int i=1;i<=w;++i) {
        while(mp[i].find(j_lower_lim) != mp[i].end()) ++j_lower_lim;
        set<int>::iterator j_itr = mp[i].upper_bound(j_lower_lim);
        if(j_itr != mp[i].end()) {
            v.emplace_back(*j_itr, i);
        }
        ++j_lower_lim;
    }
    sort(v.begin(), v.end());

    cout << v[0].first-1 << "\n";
}

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

// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12


struct ten_t {
	int x;
	int y;
};

int compare_ten(const void *a, const void *b) {
	struct ten_t *A = (struct ten_t *)a;
	struct ten_t *B = (struct ten_t *)b;
	return A->x - B->x;
}

int main(void)
{
	//変数の宣言
	int h, w, n;
	static struct ten_t ten[200010];

	//よく使う変数
	int i, j, k, l;
	int flag = 0;
	int ans = 0;
	int count = 0;
	int temp, temp1, temp2;
	int max, min;
	int len;
	int sum = 0;

	//データの読み込み
	//scanf("%d %d %d",&h,&w,&n);
	scanf_s("%d %d %d", &h, &w, &n);

	for(i=0;i<n;i++){
		//scanf("%d %d", &ten[i].x, &ten[i].y);
		scanf_s("%d %d", &ten[i].x, &ten[i].y);
	}
	


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
		//実際の処理
	qsort(ten, n, sizeof(struct ten_t), compare_ten);


	j = 0;
	temp = 1;
	for (i = 1;i <= h;i++) {
		while (ten[j].x == i) {
			if (ten[j].y < temp) {
				printf("%d", i - 1);
				return 0;
			}
			else if (ten[j].y == temp) {
				flag = 1;
			}
			j++;
		}
		if (flag == 1) {
			flag = 0;
		}
		else {
			temp++;
		}
	}

	//	printf("計算部分終了\n");
		//出力
	printf("%d", h);


	//	printf("結果の出力終了\n");

	return 0;

}



// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   45 |         scanf_s("%d %d %d", &h, &w, &n);
      |         ^~~~~~~
      |         scanf
Language: C++

// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12


struct ten_t {
	int x;
	int y;
};

int compare_ten(const void *a, const void *b) {
	struct ten_t *A = (struct ten_t *)a;
	struct ten_t *B = (struct ten_t *)b;
	return A->x - B->x;
}

int main(void)
{
	//変数の宣言
	int h, w, n;
	static struct ten_t ten[200010];

	//よく使う変数
	int i, j, k, l;
	int flag = 0;
	int ans = 0;
	int count = 0;
	int temp, temp1, temp2;
	int max, min;
	int len;
	int sum = 0;

	//データの読み込み
	//scanf("%d %d %d",&h,&w,&n);
	scanf_s("%d %d %d", &h, &w, &n);

	for(i=0;i<n;i++){
		//scanf("%d %d", &ten[i].x, &ten[i].y);
		scanf_s("%d %d", &ten[i].x, &ten[i].y);
	}
	


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
		//実際の処理
	qsort(ten, n, sizeof(struct ten_t), compare_ten);


	j = 0;
	temp = 1;
	for (i = 1;i <= h;i++) {
		while (ten[j].x == i) {
			if (ten[j].y < temp) {
				printf("%d", i - 1);
				return 0;
			}
			else if (ten[j].y == temp) {
				flag = 1;
			}
			j++;
		}
		if (flag == 1) {
			flag = 0;
		}
		else {
			temp++;
		}
	}

	//	printf("計算部分終了\n");
		//出力
	printf("%d", h);


	//	printf("結果の出力終了\n");

	return 0;

}



// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Compiler output:
a.cc:3:10: fatal error: pch.h: No such file or directory
    3 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <cstdint>
#include <string.h>
#include <queue>
#include <bitset>
#include <limits>

using namespace std;

std::bitset<2 * 100001> map;
int H, W, N;
struct Answer {
    int X, Y;
    size_t takahashiCount=0, aokiCount= numeric_limits<size_t>::max();

    inline void update(int X, int Y, size_t takahashiCount, size_t aokiCount)
    {
        if (aokiCount < this->aokiCount) {
            this->aokiCount = aokiCount;
            this->takahashiCount = takahashiCount;
            this->X = X;
            this->Y = Y;
        } else if (aokiCount == this->aokiCount) {
            this->takahashiCount = max(this->takahashiCount, takahashiCount);
            this->X = X;
            this->Y = Y;
        }
        //answers.push_back(Answer{ X, Y, takahashiCount - 1,  aokiCount });
    }
};

std::list<Answer> answers;
Answer bestAnswer;

void pred(int X, int Y, size_t takahashiCount, size_t aokiCount)
{
    if (X >= H) {
        bestAnswer.update(X, Y, takahashiCount-1, aokiCount);
        return;
    }
    if (Y >= W) {
        bestAnswer.update(X, Y, takahashiCount, aokiCount-1);
        return;
    }

    if (map[X * H + Y]) {
        bestAnswer.update(X, Y, takahashiCount-1, aokiCount);
    } else {
        //下移動したときの処理
        if (!map[X*H + Y + 1]) {
            pred(X, Y+1, takahashiCount, aokiCount+1);
        }
        //移動しなかった時の処理
        pred(X + 1, Y, takahashiCount + 1, aokiCount);
    }
}

int main()
{
    cin >> H >> W >> N;

    for (int i = 0; i < N; ++i) {
        int X, Y;
        cin >> X >> Y;
        X--;
        Y--;
        map[X * H + Y] = true;
    }

    pred(1, 0, 1, 0);
    cout << bestAnswer.takahashiCount << endl;
    //cout << "best: aoki=" << bestAnswer.aokiCount
    //    << ", X=" << bestAnswer.X << ", Y=" << bestAnswer.Y << endl;

    //マップ表示
    //for (int x = 0; x < H; ++x) {
    //    for (int y = 0; y < W; ++y) {
    //        cout << (map[x*H + y] ? '#' : '.');
    //    }
    //    cout << endl;
    //}

    //cout << "answer" << endl;
    //for (auto& ans : answers) {
    //    cout << " X=" << ans.X << ", Y=" << ans.Y
    //        << ", takahashi=" << ans.takahashiCount
    //        << ", aoki=" << ans.aokiCount
    //        << endl;
    //}
    return 0;
}

Compiler output:
a.cc:38:6: error: 'list' in namespace 'std' does not name a template type
   38 | std::list<Answer> answers;
      |      ^~~~
a.cc:12:1: note: 'std::list' is defined in header '<list>'; this is probably fixable by adding '#include <list>'
   11 | #include <bitset>
  +++ |+#include <list>
   12 | #include <limits>
Language: C++

#include <bits/stdc++.h>
typedef long long ll;

bool visited[10000 + 10];
unordered_map<ll, ll> mp;

//-------------------------↓↓↓↓↓↓------------------------

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

    int h, w, n, x[100000 + 10], y[100000 + 10], ans, lim = 1;

    cin >> h >> w >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        if(!visited[x[i]])mp[x[i]] = y[i], visited[x[i]] = true;
        else mp[x[i]] = min(mp[x[i]], y[i]);
    }

    ans = h;
    for(int i = 2; i <= h; i++){
        if(!visited[i])lim++;
        else{
            if(lim + 1 == mp[i])continue;
            else if(lim + 1 < mp[i])lim++;
            else{
                ans = i - 1;
                break;
            }
        }
    }
    
    cout << ans << "\n";
    return 0;
}


Compiler output:
a.cc:5:1: error: 'unordered_map' does not name a type
    5 | unordered_map<ll, ll> mp;
      | ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:10:8: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |        cin.tie(0);
      |        ^~~
      |        std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:5: error: 'ios' has not been declared
   11 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:18:27: error: 'mp' was not declared in this scope
   18 |         if(!visited[x[i]])mp[x[i]] = y[i], visited[x[i]] = true;
      |                           ^~
a.cc:19:14: error: 'mp' was not declared in this scope
   19 |         else mp[x[i]] = min(mp[x[i]], y[i]);
      |              ^~
a.cc:19:25: error: 'min' was not declared in this scope; did you mean 'std::min'?
   19 |         else mp[x[i]] = min(mp[x[i]], y[i]);
      |                         ^~~
      |                         std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:26:27: error: 'mp' was not declared in this scope
   26 |             if(lim + 1 == mp[i])continue;
      |                           ^~
a.cc:35:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   35 |     cout << ans << "\n";
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<set<int>> st(h + 1);
	int n;
	cin >> n;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		st[a].insert(b);
	}
	REP(i, w)st[h].insert(i);
	int m = 0;
	REP(i, h) {

		if (!st[i + 1].empty() && s[i + 1].begin() <= m) {
			cout << i + 1 << endl;
			return 0;
		}

		if (st[i + 1].count(m + 1) == 0)m++;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:43: error: 's' was not declared in this scope
   46 |                 if (!st[i + 1].empty() && s[i + 1].begin() <= m) {
      |                                           ^
Language: C++

#include<iostream>
#include<map>
#define lol(i,n) for(int i=0;i<n;i++)
#define fi first
#define sc second
typedef long long ll;

using namespace std;
#define N 200010
ll h,w,n;
pair<ll,ll> d[N];
int main(){
    cin>>h>>w>>n;
    lol(i,n)cin>>d[i].fi>>d[i].sc;
    sort(d,d+n);
    ll k=0;
    lol(i,n){
	ll x=d[i].fi,y=d[i].sc;
	if(y<x+k)return cout<<x-1<<endl,0;
	if(y==x+k)k--;
    }
    cout<<h<<endl;
    return 0;
}


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

#include<string>
using namespace std;
int main(){
    long h,w,n;
    cin>>h>>w>>n;
    long a[h][w],y[n],x[n];
    for (int i=0; i<n; i++) {
        cin>>x[i]>>y[i];
    }
    for (int i=0; i<n; i++) {
        if (y[i]-x[i]<=0) {
            for (int j=0; j<w-x[i]; j++) {
                a[y[i]+j][x[i]+1+j]=1;
            }
        }
    }
    long min=w;
    for (int i=0; i<n; i++) {
        if (y[i]-x[i]<0){
            if (a[y[i]][x[i]]!=1 && x[i]<min) {
            min=x[i];
        }
        }
    }
    cout<<min-1<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin>>h>>w>>n;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<string>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:25:5: error: 'cout' was not declared in this scope
   25 |     cout<<min-1<<endl;
      |     ^~~~
a.cc:25:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:25:18: error: 'endl' was not declared in this scope
   25 |     cout<<min-1<<endl;
      |                  ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<string>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#include <iostream>
#include <string>

#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

#include <algorithm>

struct POS {
	int x;
	int y;
};

bool operator<(const struct POS& a, const struct POS& b)
{
	if (a.x < b.x)
		return true;
	if (a.x > b.x)
		return false;
	return a.y < b.y;
}

int main()
{
	int H, W;
	int N;
	std::set<POS> poss;
	std::list<POS> pos

	std::cin >> H >> W >> N;
	for (int i = 0; i < N; ++i) {
		int x, y;
		std::cin >> x >> y;
		--x;
		--y;
		if (y <= x)
			poss.insert(POS{x, y});
	}
	for (auto it = poss.begin(); it != poss.end(); ++it) {
		pos.push_back(*it);
	}

	int aoki_pass = 0;
	while (!pos.empty()) {
		auto it = pos.begin();
		if (it->y == it->x - aoki_pass) {
			for (auto jt = pos.begin(); jt != pos.end();) {
				if (jt->y == jt->x - aoki_pass) {
					pos.erase(jt++);
				} else {
					++jt;
				}
			}
			++aoki_pass;
		} else {
			std::cout << it->x << "\n";
			return 0;
		}
	}
	std::cout << H << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: expected initializer before 'std'
   35 |         std::cin >> H >> W >> N;
      |         ^~~
a.cc:45:17: error: 'pos' was not declared in this scope; did you mean 'poss'?
   45 |                 pos.push_back(*it);
      |                 ^~~
      |                 poss
a.cc:49:17: error: 'pos' was not declared in this scope; did you mean 'poss'?
   49 |         while (!pos.empty()) {
      |                 ^~~
      |                 poss
Language: C++

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

	int32 H, W, N;
	cin >> H >> W >> N;
	vector<PII> v(N);
	REP(i, v.size()){
		cin >> v[i].fs >> v[i].sc;
	}
	sort(all(v));
	int32 nowy = 1;
	int32 res = W;
	REP(i, N){
		if(i > 0){
			nowy += max(v[i].fs-v[i-1].fs-1, (int32)0);
		}else{
			nowy += max(v[i].fs-2, (int32)0);
		}
		if(nowy >= v[i].sc){
			res = min(res, v[i].fs-1);
		}
		bool ok = v[i].sc-1 != nowy;
		while(v[i].fs == v[i+1].fs){
			i++;
			ok = ok && (v[i].sc-1 != nowy);
		}
		if(ok && x[i].fs > 0) nowy++;
	}
	cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:26: error: 'x' was not declared in this scope
   51 |                 if(ok && x[i].fs > 0) nowy++;
      |                          ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int h, w, n;
  cin >> h >> w >> n;
  P z[200005];
  map<int, map<int, int> > mp;
  rep(i, 0, n) {
    cin >> z[i].first >> z[i].second;
    mp[z[i].first][z[i].second] = 1;
  }
  int x = 1, y = 1;
  int s[200005];
  rep(i, 0, w + 1) s[i] = 1145141919;
  s[1] = 1;
  int ans = 1145141919;
  while(x <= w && y <= h) {
    if(!mp[x + 1][y]) x++;
    else {
      break;
    }
    if(!mp[x][y + 1]) {
      y++;
      s[y] = x;
    }
  }
  int ans = w;
  rep(i, 0, n) {
    if(s[z[i].second] < z[i].first) {
      ans = min(ans, z[i].first - 1);
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:7: error: redeclaration of 'll ans'
   51 |   int ans = w;
      |       ^~~
a.cc:40:7: note: 'll ans' previously declared here
   40 |   int ans = 1145141919;
      |       ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=2e5+20;

vector<int>ed[maxn];

int n,fa[maxn];
int mx[maxn],cmx[maxn],son[maxn];

void dfs(int u)
{
	for(int v:ed[u])
	{
		if(v==fa[u])continue;
		mx[v]=mx[u]; cmx[v]=cmx[u];
		if(v>mx[v])cmx[v]=mx[v],mx[v]=v;
		else if(v>cmx[v])cmx[v]=v;
		fa[v]=u;

		if(mx[v]==v);
		else if(mx[u]==u)son[v]=v;
		else son[v]=son[u];
		
		dfs(v);
	}
}


inline void init()
{
	n=read();
	REP(i,1,n-1)
	{
		int u=read(),v=read();
		ed[u].push_back(v);
		ed[v].push_back(u);
	}
	mx[1]=1; cmx[1]=0;
	dfs(1);
}

struct Node {
	int s1,s2,ls,rs;
};
Node c[maxn<<5];
int ctot;

int rt[maxn];

void update(int x,int d1,int d2,int &o,int l,int r)
{
	if(!o)o=++ctot;
	c[o].s1+=d1; c[o].s2+=d2;
	if(l==r)return;
	int mid=l+r>>1;
	if(x<=mid)update(x,d1,d2,c[o].ls,l,mid);
	else update(x,d1,d2,c[o].rs,mid+1,r);
}

int Merge(int x,int y)
{
	if(!x || !y)return x|y;
	c[x].s1+=c[y].s1; c[x].s2+=c[y].s2;
	c[x].ls=Merge(c[x].ls,c[y].ls);
	c[y].rs=Merge(c[x].rs,c[y].rs);
	return x;
}

struct Query {
	int x,op,id;
};

int query1(int x,int o,int l,int r)
{
	if(!o)return 0;
	if(l==r)return c[o].s1;
	int mid=l+r>>1;
	if(x<=mid)return query1(x,c[o].ls,l,mid);
	else return query1(x,c[o].rs,mid+1,r);
}

int query2(int x,int o,int l,int r)
{
	if(!o)return 0;
	if(l==r)return c[o].s2;
	int mid=l+r>>1;
	if(x<=mid)return query2(x,c[o].ls,l,mid);
	else return query2(x,c[o].rs,mid+1,r);
}

int ans[maxn];
vector<Query>Qu[maxn];

void dfs1(int u)
{
	if(mx[u])update(mx[u],1,0,rt[u],1,n);
	if(cmx[u])update(cmx[u],0,1,rt[u],1,n);
	for(int v:ed[u])
	{
		if(v==fa[u])continue;
		dfs1(v);
		rt[u]=Merge(rt[u],rt[v]);
	}
	for(Query t:Qu[u])
	{
		int x=t.x,op=t.op,id=t.id;
		if(op)ans[id]+=op*query2(x,rt[u],1,n);
		else ans[id]+=query1(x,rt[u],1,n);
	}
}

void dfs2(int u)
{
	ans[u]+=ans[fa[mx[u]]];
	for(int v:ed[u])if(v!=fa[u])dfs2(v);
}

void doing()
{
	REP(u,2,n)
	{
		if(mx[u]==u)
		{
			Qu[u].push_back((Query){cmx[u],1,u});
		}else
		{
			Qu[son[u]].push_back((Query){cmx[mx[u]],-1,u});
			Qu[son[u]].push_back((Query){mx[u],0,u});
			Qu[mx[u]].push_back((Query){cmx[mx[u]],1,u});
		}
	}
	dfs1(1);
	dfs2(1);
	REP(i,2,n)printf("%d ",ans[i]);
}

int main()
{
#endif
	init();
	doing();
	return 0;
}


Compiler output:
a.cc:158:2: error: #endif without #if
  158 | #endif
      |  ^~~~~
Language: C++

#include <bits/stdc++.h>
#define LL long long
#define X first
#define PB push_back
#define Y second
using namespace std;
int ans[200005];
int calculated[200005];
vector<int> comp;
void dfs2(int u , int pp , int p = -1)
{
    comp.PB(u);
    for(auto v : g[u])
    {
        if(v != p && v < pp)
        {
            dfs2(v , pp , p);
        }
    }
}
void dfs(int u , int p = -1)
{
    if(!calculated[u])
    for(auto v : g[u])
    {
        if(v > u && v != p)
        {
            ans[v] = ans[u] + 1;
            dfs(v , u);
        }
        else
        {
            dfs2(v , p ,  p);
            for(auto v : comp)
            {
                calculated[v] = 1;
                ans[v] = ans[p] + comp.size();
            }
            comp.clear();
        }
    }
    else
        for(auto v : g[u])
            if(v != p)
                dfs(v , u);
    
}
int main() 
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int u , v;
        cin >> u >> v;
        u--;v--;
        g[u].PB(v);
        g[v].PB(u);
    }
    dfs(0);
    for(int i = 1; i < n; i++)
    {
        cout << ans[i] << " ";
    }
    return 0;
}

Compiler output:
a.cc: In function 'void dfs2(int, int, int)':
a.cc:13:18: error: 'g' was not declared in this scope
   13 |     for(auto v : g[u])
      |                  ^
a.cc: In function 'void dfs(int, int)':
a.cc:24:18: error: 'g' was not declared in this scope
   24 |     for(auto v : g[u])
      |                  ^
a.cc:43:22: error: 'g' was not declared in this scope
   43 |         for(auto v : g[u])
      |                      ^
a.cc: In function 'int main()':
a.cc:58:9: error: 'g' was not declared in this scope
   58 |         g[u].PB(v);
      |         ^
Language: C++

#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100005,INF=1e9;
namespace flows{
	const int M=N*(2+2)*2;
	struct Edge{
		int x,y,cap,nxt;
		Edge(){}
		Edge(int _x,int _y,int _cap,int _nxt){
			x=_x,y=_y,cap=_cap,nxt=_nxt;
		}
	}e[M];
	int cnt,n,S,T;
	int fst[N],dis[N],cur[N];
	void clear(int _n,int _S,int _T){
		n=_n,S=_S,T=_T,cnt=1;
		clr(fst);
	}
	void Add(int x,int y,int cap){
		e[++cnt]=Edge(x,y,cap,fst[x]),fst[x]=cnt;
		e[++cnt]=Edge(y,x,0,fst[y]),fst[y]=cnt;
	}
	int bfs(){
		static int q[N];
		int head=0,tail=0;
		memset(dis,-1,sizeof dis);
		dis[0]=0;
		q[++tail]=S;
		while (head<tail){
			int x=q[++head];
			for (int i=fst[x];i;i=e[i].nxt){
				int y=e[i].y;
				if (!~dis[y]&&e[i].cap){
					dis[y]=dis[x]+1;
					q[++tail]=y;
				}
			}
		}
		return vis[T];
	}
	int dfs(int x,int Lim){
		if (x==T||!Lim)
			return Lim;
		int now=Lim;
		for (int &i=cur[x];i;i=e[i].nxt){
			int y=e[i].y;
			if (e[i].cap&&dis[x]+1==dis[y]){
				int d=dfs(y,min(Lim,e[i].cap));
				e[i].cap-=d,e[i^1].cap+=d;
				now-=d;
				if (!now)
					break;
			}
		}
		return Lim-now;
	}
	int Dinic(){
		int flow=0;
		while (bfs()){
			For(i,1,n)
				cur[i]=fst[i];
			flow+=dfs(S,INF);
		}
		return flow;
	}
}
int n;
vector <int> s[N],e[N];
int q[N],mat[N],fa[N],vis[N];
int main(){
	n=read();
	int S=(n-1)*2+1,T=S+1;
	flows::clear(T,S,T);
	For(i,1,n-1){
		flows::Add(S,i,1);
		flows::Add(i+n-1,T,1);
		int k=read();
		while (k--){
			int j=read();
			s[i].pb(j);
			e[j].pb(i);
			if (j!=n){
				flows::Add(j,i+n-1,1);
			}
		}
	}
//	outtag(1);
	if (flows::Dinic()<n-1)
		return puts("-1"),0;
//	outtag(2);
	For(i,2,flows::cnt){
		int x=flows::e[i].x,y=flows::e[i].y;
		if (!flows::e[i].cap&&1<=x&&x<=n-1&&n<=y&&y<=n*2-2){
			mat[y-(n-1)]=x;
//			printf("Mat[%d] = %d\n",y-(n-1),x);
		}
	}
	int head=0,tail=0;
	q[++tail]=n;
	while (head<tail){
		int x=q[++head];
		for (auto y : e[x]){
			if (vis[y])
				continue;
			vis[y]=1;
			fa[y]=x;
			q[++tail]=mat[y];
		}
	}
//	outtag(3);
	if (tail<n)
		return puts("-1"),0;
	For(i,1,n-1)
		printf("%d %d\n",fa[i],mat[i]);
	return 0;
}

Compiler output:
a.cc: In function 'int flows::bfs()':
a.cc:62:24: error: 'vis' was not declared in this scope; did you mean 'dis'?
   62 |                 return vis[T];
      |                        ^~~
      |                        dis
Language: C++

#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100005*2,INF=1e9;
namespace flows{
	const int M=N*(2+2)*2;
	struct Edge{
		int x,y,cap,nxt;
		Edge(){}
		Edge(int _x,int _y,int _cap,int _nxt){
			x=_x,y=_y,cap=_cap,nxt=_nxt;
		}
	}e[M];
	int cnt,n,S,T;
	int fst[N],vis[N],dis[N],cur[N];
	void clear(int _n,int _S,int _T){
		n=_n,S=_S,T=_T,cnt=1;
		clr(fst);
	}
	void Add(int x,int y,int cap){
		e[++cnt]=Edge(x,y,cap,fst[x]),fst[x]=cnt;
		e[++cnt]=Edge(y,x,0,fst[y]),fst[y]=cnt;
	}
	int bfs(){
		static int q[N];
		int head=0,tail=0;
		clr(vis);
		memset(dis,-1,sizeof dis);
		dis[0]=0;
		q[++tail]=S;
		while (head<tail){
			int x=q[++head];
			for (int i=fst[x];i;i=e[i].nxt){
				int y=e[i].y;
				if (!vis[y]&&e[i].cap){
					dis[y]=dis[x]+1;
					q[++tail]=y;
					vis[y]=1;
				}
			}
		}
		return vis[T];
	}
	int dfs(int x){
		if (x==T)
			return 1;
		for (int &i=cur[x];i;i=e[i].nxt){
			int y=e[i].y;
			if (e[i].cap&&dis[x]+1==dis[y]){
				if (dfs(y)){
					e[i].cap^=1,e[i^1].cap^=1;
					return 1;
				}
			}
		}
		return 0;
	}
	int Dinic(){
		int flow=0;
		while (bfs()){
			For(i,1,n)
				cur[i]=fst[i];
			clr(vis),flow+=dfs(S,INF);
//			outval(flow);
		}
		return flow;
	}
}
int n;
vector <int> s[N],e[N];
int q[N],mat[N],fa[N],vis[N];
int main(){
	n=read();
	int S=(n-1)*2+1,T=S+1;
	flows::clear(T,S,T);
	For(i,1,n-1){
		flows::Add(S,i,1);
		flows::Add(i+n-1,T,1);
		int k=read();
		while (k--){
			int j=read();
			s[i].pb(j);
			e[j].pb(i);
			if (j!=n){
				flows::Add(j,i+n-1,1);
			}
		}
	}
//	outtag(1);
	if (flows::Dinic()<n-1)
		return puts("-1"),0;
//	outtag(2);
	For(i,2,flows::cnt){
		int x=flows::e[i].x,y=flows::e[i].y;
		if (!flows::e[i].cap&&1<=x&&x<=n-1&&n<=y&&y<=n*2-2){
			mat[y-(n-1)]=x;
//			printf("Mat[%d] = %d\n",y-(n-1),x);
		}
	}
	int head=0,tail=0;
	q[++tail]=n;
	while (head<tail){
		int x=q[++head];
		for (auto y : e[x]){
			if (vis[y])
				continue;
			vis[y]=1;
			fa[y]=x;
			q[++tail]=mat[y];
		}
	}
//	outtag(3);
	if (tail<n)
		return puts("-1"),0;
	For(i,1,n-1)
		printf("%d %d\n",fa[i],mat[i]);
	return 0;
}

Compiler output:
a.cc: In function 'int flows::Dinic()':
a.cc:85:43: error: too many arguments to function 'int flows::dfs(int)'
   85 |                         clr(vis),flow+=dfs(S,INF);
      |                                        ~~~^~~~~~~
a.cc:66:13: note: declared here
   66 |         int dfs(int x){
      |             ^~~