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

int solve(int T, int * r) {
	int count = 0;
	for (int i = 1; i <= T; i++) {
		if (i == r[r[i - 1]])
			count++;

	}

	return count /2;
}

int main() {

	int T;
	int * rabbits;

	cin >> T;

	rabbits = new int[T];
	for (int i = 0; i < T; i++) {
		cin >> rabbits[i];
	}
	cout << solve(T, rabbits) << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'cin' was not declared in this scope
   17 |         cin >> T;
      |         ^~~
a.cc:23:9: error: 'cout' was not declared in this scope
   23 |         cout << solve(T, rabbits) << endl;
      |         ^~~~
a.cc:23:38: error: 'endl' was not declared in this scope
   23 |         cout << solve(T, rabbits) << endl;
      |                                      ^~~~
Language: C++

#include <vector>
#include <iostream>
using namespace std;
 
int countPairs() {
    int total;
    cin >> total;
    
    vector<int> rabbits;
    int r;
    int count = 0;
    
    for (int i = 0; i < total; i++) {
        cin >> r;
        rabbits.push_back(r);
    }
    
    for (int i = 0; i < total; i++) {
        if (rabbits[rabbits[i]-1] == i+1) {
            count++;
        }
    }
    
    return count/2;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>

#define INT unsigned long long int
#define FOR1(n) for(int i=0;i<n;i++)
#define FOR2(j, n) for(int j=0;j<n;j++)
#define FOR3(i, m, n) for(int i=m;i<=n;i++)
#define PINT(d) printf("%d\n", d);
#define PDOUBLE(lf) printf("%lf\n", lf);
#define PSTR(s) printf("%s\n", s);
#define ALL(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX_N 100000

using namespace std;

main(){
	int n;
	scanf("%d", &n);
	int a[n+1];
	FOR1(n){
		scanf("%d", &a[i+1]);
	}
	int ans = 0, check = 0;
	FOR1(n){
		int tmp = a[i+1];
		if(tmp == -1){
			continue;
		}
		if(a[tmp] == i+1){
			ans++;
		}
		check++;
		a[tmp] = -1;
		if(check >= (float)n/2) break;
	}
	printf("%d\n", ans);

Compiler output:
a.cc:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:45:29: error: expected '}' at end of input
   45 |         printf("%d\n", ans);
      |                             ^
a.cc:25:7: note: to match this '{'
   25 | main(){
      |       ^
Language: C++

#include <vector>
 
using namespace std;
 
int countPairs() {
    int total;
    std::cin >> total;
    
    vector<int> rabbits;
    int r;
    int count = 0;
    
    for (int i = 0; i < total; i++) {
        std::cin >> r;
        rabbits.push_back(r);
    }
    
    for (int i = 0; i < total; i++) {
        if (rabbits[rabbits[i]-1] == i+1) {
            count++;
        }
    }
    
    return count/2;
}

Compiler output:
a.cc: In function 'int countPairs()':
a.cc:7:10: error: 'cin' is not a member of 'std'
    7 |     std::cin >> total;
      |          ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <vector>
  +++ |+#include <iostream>
    2 | 
a.cc:14:14: error: 'cin' is not a member of 'std'
   14 |         std::cin >> r;
      |              ^~~
a.cc:14:14: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <vector>

using namespace std;

int countPairs() {
    int total;
    cin >> total;
    
    vector<int> rabbits;
    int r;
    int count = 0;
    
    for (int i = 0; i < total; i++) {
        cin >> r;
        rabbits.push_back(r);
    }
    
    for (int i = 0; i < total; i++) {
        if (rabbits[rabbits[i]-1] == i+1) {
            count++;
        }
    }
    
    return count/2;
}

Compiler output:
a.cc: In function 'int countPairs()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin >> total;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <vector>
  +++ |+#include <iostream>
    2 |
Language: C++

#include <vector>
int countPairs() {
    int total;
    cin >> total;
    
    vector<int> rabbits;
    int r;
    int count = 0;
    
    for (int i = 0; i < total; i++) {
        cin >> r;
        rabbits.push_back(r);
    }
    
    for (int i = 0; i < total; i++) {
        if (rabbits[rabbits[i]-1] == i+1) {
            count++;
        }
    }
    
    return count/2;
}

Compiler output:
a.cc: In function 'int countPairs()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> total;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int> rabbits;
      |     ^~~~~~
a.cc:6:5: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> rabbits;
      |            ^~~
a.cc:12:9: error: 'rabbits' was not declared in this scope
   12 |         rabbits.push_back(r);
      |         ^~~~~~~
a.cc:16:13: error: 'rabbits' was not declared in this scope
   16 |         if (rabbits[rabbits[i]-1] == i+1) {
      |             ^~~~~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
  int size;
  cin >> size;
  vector<int> arr(size);
  for(int i = 0; i < size; i++){
    cin >> arr[i]; 
  }

  int res = 0;
  for(int i = 0; i < size; i++){
    if(arr[i] > 0 && arr[i] <= size && i + 1 == arr[arr[i] - 1]){
      res++;
      arr[i] = 0;
    }
  }
  cout << res;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> arr(size);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> arr(size);
      |          ^~~
a.cc:8:12: error: 'arr' was not declared in this scope
    8 |     cin >> arr[i];
      |            ^~~
a.cc:13:8: error: 'arr' was not declared in this scope
   13 |     if(arr[i] > 0 && arr[i] <= size && i + 1 == arr[arr[i] - 1]){
      |        ^~~
Language: C++

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl "\n"
#define mod 1000000007
#define INF 100000000

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

bool fri[100000][100000];
int a;

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

  int n, ct = 0;
  cin >> n;

  for (int i = 1; i <= n; i++){
    cin >> a;
    if (fri[i][a] || fri[a][i]) ct++;
    fri[i][a] = true;
  }
  cout << ct << endl;
}


Compiler output:
/tmp/ccsJuXBR.o: in function `main':
a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccsJuXBR.o
a.cc:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccsJuXBR.o
a.cc:(.text+0x93): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccsJuXBR.o
a.cc:(.text+0xc0): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccsJuXBR.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
using namespace std;
int main(){
  int size;
  cin >> size;
  vector<int> arr(size);
  for(int i = 0; i < size; i++){
    cin >> arr[i]; 
  }

  int res = 0;
  for(int i = 0; i < size; i++){
    if(arr[i] > 0 && arr[i] <= size && i + 1 == arr[arr[i] - 1]){
      res++;
    }
  }
  cout << res;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> arr(size);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> arr(size);
      |          ^~~
a.cc:8:12: error: 'arr' was not declared in this scope
    8 |     cin >> arr[i];
      |            ^~~
a.cc:13:8: error: 'arr' was not declared in this scope
   13 |     if(arr[i] > 0 && arr[i] <= size && i + 1 == arr[arr[i] - 1]){
      |        ^~~
Language: C++

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl "\n"
#define mod 1000000007
#define INF 100000000

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

bool fri[100000][100000];
int a[100001];
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, ct = 0;
  cin >> n;
  for (int i = 1; i <= n; i++){
    cin >> a[i];
    if (fri[i][a[i]] || fri[a[i]][i]) ct++;
    fri[i][a[i]] = true;
  }
  cout << ct << endl;
}


Compiler output:
/tmp/ccU4xWZW.o: in function `main':
a.cc:(.text+0x5f): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccU4xWZW.o
a.cc:(.text+0x88): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccU4xWZW.o
a.cc:(.text+0xc2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccU4xWZW.o
a.cc:(.text+0x100): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccU4xWZW.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N = 0, tmp = 0, count = 0;
    vector<int> rabbits;

    cin >> N;

    for(int i = 0; i < N; i++) {
        cin >> tmp;
        rabbits.push_back(tmp);
    }

    for(int i = 0; i < N; i++) {
        tmp = rabbits[i];

        if(rabbits[tmp] == -1)
            continue;

        if(rabbits[tmp]-1 == i) {
            count++;
            rabbits[i] == -1:
            rabbits[tmp] == -1;
        }
    }

    cout << count << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:29: error: expected ';' before ':' token
   25 |             rabbits[i] == -1:
      |                             ^
      |                             ;
Language: C++

#include <stdio.h>

int main(void)
{
	int N = 0,a[200000] = {0},i = 0,j = 0,k = 0
	long long int ans = 0;
	scanf("%d",&N);
	for(i = 0;i < N;i++)
		scanf("%d",&a[i]);
	for(i = 0;i < N;i++){
		if(a[a[i]] == i){
			a[a[i]] = -1;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: expected ',' or ';' before 'long'
    6 |         long long int ans = 0;
      |         ^~~~
a.cc:13:25: error: 'ans' was not declared in this scope
   13 |                         ans++;
      |                         ^~~
a.cc:16:23: error: 'ans' was not declared in this scope
   16 |         printf("%d\n",ans);
      |                       ^~~
Language: C++

#include<iostream>
#include<math.h>
#include<fstream>
#include<string.h>
using namespace std;

int solve(int T, int * r) {

	bool * fix = new fix[T];
	int count = 0;
	for (int i = 0; i < T; i++) {

		for (int j = 0; j < T; j++) {
			if (j != i) {
				if (fix[i] == j && fix[j] == i) {
					count++;
				}
			}
		}
	}

	return count / 2;
}

int main() {

	int T;
	int * rabbits;

	cin >> T;

	rabbits = new int[T];
	for (int i = 0; i < T; i++) {
		cin >> rabbits[i];
	}
	cout << solve(T, rabbits) << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int solve(int, int*)':
a.cc:9:26: error: 'fix' does not name a type
    9 |         bool * fix = new fix[T];
      |                          ^~~
Language: C

#include <stdio.h>

int main(void) {
	int n, i, a[999999]={}, sum=0;
	
	scanf("%d", &n);
	
	for(i=1;i<=n;i++)
	scanf("%d", &a[i]);
	
	for(i=1;i<=n;i++){
			sum++;
		}
	}
	
	printf("%d\n", sum/2);
	return 0;
}


Compiler output:
main.c:16:16: error: expected declaration specifiers or '...' before string constant
   16 |         printf("%d\n", sum/2);
      |                ^~~~~~
main.c:16:24: error: unknown type name 'sum'
   16 |         printf("%d\n", sum/2);
      |                        ^~~
main.c:17:9: error: expected identifier or '(' before 'return'
   17 |         return 0;
      |         ^~~~~~
main.c:18:1: error: expected identifier or '(' before '}' token
   18 | }
      | ^
Language: C

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int N = 0;
    int *a = NULL;

    scanf("%d", &N);

    a = calloc(sizeof(int) * N);

    int i;
    for (i = 0; i < N; i++) {
        scanf("%d", &(a[i]));
    }

    int friend = 0;

    for (i = 0; i < N; i++) {
        if (a[a[i]] == i) {
            friend++;
        }
    }

    friend /= 2;

    printf("%d\n", friend);

    return EXIT_SUCCESS;
}


Compiler output:
main.c: In function 'main':
main.c:10:9: error: too few arguments to function 'calloc'
   10 |     a = calloc(sizeof(int) * N);
      |         ^~~~~~
In file included from main.c:2:
/usr/include/stdlib.h:675:14: note: declared here
  675 | extern void *calloc (size_t __nmemb, size_t __size)
      |              ^~~~~~
Language: C

int main(){
	
	int num;
	int counter=0;
	scanf("%d",num);
	int array[num];
	for (int i=0;i<num;i++){
		scanf("%d",array[i]);
	}
	for (int i=0;i<num;i++){
		if(array[array[i]]=array[i])
		count++;
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |         scanf("%d",num);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(){
main.c:5:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |         scanf("%d",num);
      |         ^~~~~
main.c:5:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:12:17: error: 'count' undeclared (first use in this function); did you mean 'counter'?
   12 |                 count++;
      |                 ^~~~~
      |                 counter
main.c:12:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main(){
        int N;
        int a[10000]={0};
        int result2=0;
        int result=0;


        cin >> N;
        for(int i=0;i<N;i++){
                cin >> a[i];
        }

        for(int i=0;i<N;i++){
                if(a[a[i]]==i){
                        result2++;
                }
        }
        result=result2/2;


        cout << result << endl; 
        return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'cin' was not declared in this scope
   12 |         cin >> N;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <string>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:25:9: error: 'cout' was not declared in this scope
   25 |         cout << result << endl;
      |         ^~~~
a.cc:25:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:25:27: error: 'endl' was not declared in this scope
   25 |         cout << result << endl;
      |                           ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <string>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

#include <iostream>
using namespace std;

int main(int argc, char *argv[]){
  int N;
  cin >> N;
  int i;
  int a[N];
  for(i=0; i<N; ++i){
    cin >> a[i];
  }
  int ans = 0;
  for(i=0; i<N; ++i){
    if(a[a[i]-1] == i+1){
      ans++;
    }
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}
ogin

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

#include <iostream>

#define reep(i,n,m) for(int i<(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

int a[100000];

int main(){
	rep(i,100000){
		a[i] = -1;
	}
	int N;
	cin >> N;
	int ans=0;
	rep(i,N){
		int c;
		cin >> c;
		c--;
		if(a[c]==i){
			ans++;
		}
		a[i]=c;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:30: error: expected ';' before '<' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                              ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:11:9: note: in expansion of macro 'rep'
   11 |         rep(i,100000){
      |         ^~~
a.cc:3:30: error: expected primary-expression before '<' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                              ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:11:9: note: in expansion of macro 'rep'
   11 |         rep(i,100000){
      |         ^~~
a.cc:3:40: error: expected ')' before ';' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                        ~               ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:11:9: note: in expansion of macro 'rep'
   11 |         rep(i,100000){
      |         ^~~
a.cc:11:13: error: 'i' was not declared in this scope
   11 |         rep(i,100000){
      |             ^
a.cc:3:41: note: in definition of macro 'reep'
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                                         ^
a.cc:11:9: note: in expansion of macro 'rep'
   11 |         rep(i,100000){
      |         ^~~
a.cc:3:30: error: expected ';' before '<' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                              ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:17:9: note: in expansion of macro 'rep'
   17 |         rep(i,N){
      |         ^~~
a.cc:3:30: error: expected primary-expression before '<' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                              ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:17:9: note: in expansion of macro 'rep'
   17 |         rep(i,N){
      |         ^~~
a.cc:3:40: error: expected ')' before ';' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                        ~               ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:17:9: note: in expansion of macro 'rep'
   17 |         rep(i,N){
      |         ^~~
Language: C++

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>a#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int n;
int a[100010];

int main() {
    while (cin >> n) {
        int ans = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            --a[i];
        }
        for (int i = 0; i < n; i++) {
            if (a[a[i]] == i) {
                ++ans;
            }
        }
        cout << ans / 2 << endl;
    }
}


Compiler output:
a.cc:32:26: warning: extra tokens at end of #include directive
   32 | #include <unordered_set>a#include <cstdlib>
      |                          ^
a.cc:32:10: fatal error: unordered_set>: No such file or directory
   32 | #include <unordered_set>a#include <cstdlib>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool int a[100001];
int main(){
	int n;
	cin >> n;
	REP(i,n) cin >> a[i];
	int cnt = 0;
	REP(i,n) if(a[a[i]] == i) cnt++;
	cout << cnt /2 << endl;
}

Compiler output:
a.cc:17:1: error: two or more data types in declaration of 'a'
   17 | bool int a[100001];
      | ^~~~
a.cc: In function 'int main()':
a.cc:21:25: error: 'a' was not declared in this scope
   21 |         REP(i,n) cin >> a[i];
      |                         ^
a.cc:23:21: error: 'a' was not declared in this scope
   23 |         REP(i,n) if(a[a[i]] == i) cnt++;
      |                     ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  string s; cin >> s;
  int k; cin >> k;
  int n = (int)s.size();
  for(int i = 0; i < n && k > 0; ++i){
    int need = (26 - (s[i] - 'a'))%26;
    if(need <= k){
      k -= need;
      s[i] = 'a';
    }
  }
  s.back() = 'a'+(s.back()-'a'+k)%26
}




Compiler output:
a.cc: In function 'int main()':
a.cc:58:37: error: expected ';' before '}' token
   58 |   s.back() = 'a'+(s.back()-'a'+k)%26
      |                                     ^
      |                                     ;
   59 | }
      | ~
Language: C++

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

// function implementing greedy approach
void smallest_string(string s , int m)
{
    int  n = s.size();   // size of the given string
    int a[n];        // declaring an array a 
    
    // for each i , a[i] contain number of operations to update s[i] to 'a' 
    for(int i = 0; i < n ; i++)
    {
        int distance = s[i]-'a';
        if(distance == 0)
        {
            a[i]=0;
        }
        else
        {
            a[i] = 26 - distance;
        }
    }
    
    for(int i = 0 ; i < n ; i++)
    {
        // if k >= ar[i] , then update s[i] to 'a' decrement k by a[i]
        if(k >= a[i])
        {
            s[i] = 'a';
            k = k - a[i];
        }
        
    }
    
    //cycle of 26 
    k = k % 26;
    
    // update last element of string with the s[i] + (k % 26) 
    s[n-1] = s[n-1] + k;
    
    cout<<s<<endl;
    
}

//driever code
int main()
{
    //string str = "bazzzx";
    //int m = 10;
    string str;
    cin>>str;
    int m;
    cin>>m;
    smallest_string(str , m);
    return 0;
}


Compiler output:
a.cc: In function 'void smallest_string(std::string, int)':
a.cc:27:12: error: 'k' was not declared in this scope
   27 |         if(k >= a[i])
      |            ^
a.cc:36:5: error: 'k' was not declared in this scope
   36 |     k = k % 26;
      |     ^
Language: C++

ragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s;
cin >> s;
ll n;
cin >> n;
n %= 26;
rep(i,s.size()){
    if(('{' - s[i]) <= n){
        n -= ('{' - s[i]);
        s[i] = 'a';
    }
}
ll k = 'z' - s.back();
if(k >= n)
    s.back() = char((ll)(s.back()) + n);
else
{
    k--;
    k -= n;
    s.back() = char((ll)('a') + k);
}
cout << s << endl;
}

Compiler output:
a.cc:1:1: error: 'ragma' does not name a type; did you mean '_Pragma'?
    1 | ragma GCC target("avx")
      | ^~~~~
      | _Pragma
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    int K;
    cin >> S >> K;
    for(int i=0;i<S.size();i++){
        if(S[i]+K>'z'){
            K -= 'z' - S[i] + 1;
            S[i]='a';
        }
    }
    if(K>0){
        K%=26;
        if(S[n-1]=='z'){
            S[n-1]='a';
        }else{
            S[n-1] = S[n-1]+1;
        }
    }
    cout << S << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:14: error: 'n' was not declared in this scope
   20 |         if(S[n-1]=='z'){
      |              ^
Language: C++

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}

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


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    string s;cin >> s;
    int k;cin >> k;
    rep(i,s.size()){
        if('z'+1-s[i]<=k&&a[i]!='a'){
            k-=('z'+1-s[i]);
            s[i]='a';
        }
    }
    k%=26;
    s[(int)s.size()-1]+=k;
    cout << s << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:27: error: 'a' was not declared in this scope
   39 |         if('z'+1-s[i]<=k&&a[i]!='a'){
      |                           ^
Language: Java

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length() - 1; i++) {
            char c = s.charAt(i);
            if (c == 'a' || 'z' - c + 1 > k) {
                sb.append(c);
                continue;
            }
            sb.append('a');
            k -= 'z' - c + 1;
        }
        char c = s.charAt(s.length() - 1);
        if (k == 0) {
            sb.append(c);
        } else {
            k %= 26;
            sb.append((char) (((c - 'a' + k) % 26) + 'a'));
        }
        System.out.println(sb);
    }

}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
////////////////////////////////////////////////
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
const ll MOD = 1000000007;  // 1e9+7
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  string s;
  int k;
  cin >> s >> k;
  REP(i, s.size()) {
    if (s[i] == 'a') continue;
    int tmp = 'z' - s[i] + 1;
    if (tmp <= k) {
      k -= tmp;
      s[i] = 'a';
    }
    if (k == 0) {
      break;
    }
  }
  // if (k == 0) {
  //   cout << s << endl;
  // }
  k %= 26
  s.back() += k;
  cout << s << endl;
}
//////////////////////////////////////////////


Compiler output:
a.cc: In function 'int main()':
a.cc:57:10: error: expected ';' before 's'
   57 |   k %= 26
      |          ^
      |          ;
   58 |   s.back() += k;
      |   ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

bool allA(string s){
    for(char c : s){
        if(c != 'a')return false;
    }
    return true;
}

int main() {
    string s ; cin>>s;
    int n ; cin>>n;
    int m = s.size();
    for(int i = 0 ; i < m; ++i){
        int pos = s[i] - 'a';
        if(26 - pos <= n && s[i] != 'a'){
            n -= (26 - pos);
            s[i] = 'a';
        }
    }
    if(allA(s)){
        int norm = n % 26;
        while(norm--){
            s[m - 1] = char(s[m - 1] + 1);
        }
        cout<<s<<"\n";
        return 0;
    }
    int norm = n % 26;
    for(;norm--){
        s[m - 1]++;
        if(s[m - 1] > 'z')s[m - 1] = 'a';
    }
    cout<<s<<"\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:16: error: expected ';' before ')' token
   32 |     for(;norm--){
      |                ^
      |                ;
Language: C++

#include <bits/stdc++.h>

using namespace std;

bool allA(string s){
    for(char c : s){
        if(c != 'a')return false;
    }
    return true;
}

int main() {
    string s ; cin>>s;
    int n ; cin>>n;
    int m = s.size();
    for(int i = 0 ; i < m; ++i){
        int pos = s[i] - 'a';
        if(26 - pos <= n){
            n -= (26 - pos);
            s[i] = 'a';
        }
    }
    int norm = n % 26;
    for(int i = 0 ; i < norm; ++){
        s[m - 1]++;
        if(s[m - 1] > 'z')s[m - 1] = 'a';
    }
    cout<<s<<"\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:33: error: expected primary-expression before ')' token
   24 |     for(int i = 0 ; i < norm; ++){
      |                                 ^
Language: C++

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

void solve(std::string s, long long K) {
    for(int i= 0;i<s.size();i++){
      if(i == s.size()-1){K%=26;while(K--)if(s.back == 'z')s.back = 'a'; else s.back++;}
      else if(s[i] == 'a')continue;
      else if('z'+1-s[i]<=K){
        K-='z'+1-s[i];
        s[i] = 'a';
        if(K == 0)break;
       // cout<<K;
      }
    }
    cout<<s;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string s;
  std::cin >> s;
  long long K;
  scanf("%lld", &K);
  solve(s, K);
  return 0;
}


Compiler output:
a.cc: In function 'void solve(std::string, long long int)':
a.cc:6:53: error: invalid operands of types '<unresolved overloaded function type>' and 'char' to binary 'operator=='
    6 |       if(i == s.size()-1){K%=26;while(K--)if(s.back == 'z')s.back = 'a'; else s.back++;}
      |                                              ~~~~~~ ^~ ~~~
      |                                                |       |
      |                                                |       char
      |                                                <unresolved overloaded function type>
a.cc:6:62: error: invalid use of member function 'std::__cxx11::basic_string<char>::back' (did you forget the '()' ?)
    6 |       if(i == s.size()-1){K%=26;while(K--)if(s.back == 'z')s.back = 'a'; else s.back++;}
      |                                                            ~~^~~~
a.cc:6:81: error: no post-increment operator for type
    6 |       if(i == s.size()-1){K%=26;while(K--)if(s.back == 'z')s.back = 'a'; else s.back++;}
      |                                                                               ~~^~~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  ll k;
  cin>>k;
  rep(i,sz(s)){
   
    if('z'-s[i]+1<=k){
      k-=(ll)('z'-s[i]+1);
      s[i]='a';
    }
  }
  if(k>0){
    ll rem = k % 26;
		for(int i=0;i<rem;i++){
			s[sz(s)-1]++;
			if( s[sz(s)-1] == 'z'+1 ) s[n-1] = 'a';
		}
  }
  COUT(s);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:53: error: 'n' was not declared in this scope
   58 |                         if( s[sz(s)-1] == 'z'+1 ) s[n-1] = 'a';
      |                                                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int mod = 'z' - 'a' + 1;

char next_alphabet(char p, int step) {
    return char((p -'a' + step)%mod + 'a');
}

int distance(char a, char b) { // a -> bまでの距離(剰余環)
    return (b - a + mod)%mod;
}

int main()
{
    string S;
    int K;
    cin >> S >> K;
  　// 大きいビットから、'a'にする余力があるのなら'a'にしていく
    // さらに余力(K)が余ったら、最下位ビットに全振りする
    for(int i = 0, i_len = S.size(); i < i_len; ++i) {
        int dist = distance(S[i], 'a');
        if(K < dist) { continue; }
        K -= dist;
        S[i] = next_alphabet(S[i], dist);
    }
    S[S.size()-1] = next_alphabet(S[S.size()-1], K);
    cout << S << endl;
    return 0;
}

Compiler output:
a.cc:21:3: error: extended character 　 is not valid in an identifier
   21 |   　// 大きいビットから、'a'にする余力があるのなら'a'にしていく
      |   ^
a.cc: In function 'int main()':
a.cc:21:3: error: '\U00003000' was not declared in this scope
   21 |   　// 大きいビットから、'a'にする余力があるのなら'a'にしていく
      |   ^~
a.cc:23:38: error: 'i' was not declared in this scope
   23 |     for(int i = 0, i_len = S.size(); i < i_len; ++i) {
      |                                      ^
a.cc:23:42: error: 'i_len' was not declared in this scope
   23 |     for(int i = 0, i_len = S.size(); i < i_len; ++i) {
      |                                          ^~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

string &func(int index,int left,string &s){
	char nowC = s.at(index);

	if(left>='z'-nowC+1)
	{
		if(s[index]=='a')continue;
		left -= ('z'-nowC+1);
		s[index]='a';
	}
	if(index == s.size()-1){
		if(left)left%=26;
		s[index]+=left;
		return s;
	}
	else{
		return func(index+1,left,s);
	}
}

signed main(){
	string s;
	cin>>s;
	lli k;
	cin>>k;
	cout<<func(0,k,s)<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'std::string& func(int, int, std::string&)':
a.cc:20:34: error: continue statement not within a loop
   20 |                 if(s[index]=='a')continue;
      |                                  ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
    string s;cin >> s;
    vector<Int> a(s.size());
    for(Int i=0;i<s.size();i++) a[i] = s[i]-'a';
    Int k;cin >> k;
    for(Int i=0;i<s.size();i++){
        if(a[i]+k>25){
            k-=(26-a[i]);
            a[i] = 0;
        }
    }
    k%=26;
    a[s.size()-1]+=k;
    a[s.size()-1]%=26
    for(Int i=0;i<s.size();i++) cout << (char)(a[i]+'a');
    cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:22: error: expected ';' before 'for'
   27 |     a[s.size()-1]%=26
      |                      ^
      |                      ;
   28 |     for(Int i=0;i<s.size();i++) cout << (char)(a[i]+'a');
      |     ~~~               
a.cc:28:17: error: 'i' was not declared in this scope
   28 |     for(Int i=0;i<s.size();i++) cout << (char)(a[i]+'a');
      |                 ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	string s; int k;
    int n = (int)s.size();
    cin >> s >> k;
    int i = 0;
    while(k > 0) {
        if(i == n - 1) {
            s[i] = 'a' + ((s[i] - 'a' + k ) % 26);
            break;
        }
        if(s[i] == 'a') ++i, continue;
        else {
            int c = 26 - (s[i] - 'a');
            if(c <= k) {
                k -= c;
                s[i] = 'a';
            }
            ++ i;
        }
    }
    cout << s << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:62:30: error: expected primary-expression before 'continue'
   62 |         if(s[i] == 'a') ++i, continue;
      |                              ^~~~~~~~
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	string s; int k;
    cin >> s >> k;
    int i = 0;
    while(k > 0) {
        if(i == n - 1) {
            s[i] += k;
            break;
        }
        if(s[i] == 'a') continue;
        else {
            int c = 26 - (s[i] - 'a');
            if(c <= k) {
                k -= c;
                s[i] = 'a';
            }
        }
    }
    cout << s << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:57:17: error: 'n' was not declared in this scope
   57 |         if(i == n - 1) {
      |                 ^
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){

    string S;
    cin >> S;
    ll K;
    cin >> K;

    REP(i,S.size())
    {
        //bが25になるa-> 0 z -> 1
        int sa = 'a' - s[i] + 26;
        if(K >= sa)
        {
            K -= sa;
            s[i] = 'a';
        }
    }
    

    cout << s << endl;  

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:24: error: 's' was not declared in this scope
   27 |         int sa = 'a' - s[i] + 26;
      |                        ^
a.cc:36:13: error: 's' was not declared in this scope
   36 |     cout << s << endl;
      |             ^
Language: C++

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

int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;
  
  for (int i = 0; i < s.size(); ++i) {
    if (K <= 0) break;
    if (s[i] + K > 'z') {
      K -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
  
  s[s.size() - 1] += K;
  
  cout << s << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: error: expected '}' at end of input
   20 |   cout << s << endl;
      |                     ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.length();
    int k; cin >> k;
    REP(i,n) {
        if(k-('z'-s[i])>0) {
            k -= ('z'-s[i])+1;
            s[i]='a';
        }
    }
    int idx = n-1;
    while(k>0 && s[idx]<'z' && idx>0) {
        ++ s[i];
        --k;
        if(s[idx]=='z') --idx;
    }
    cout << s << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:14: error: 'i' was not declared in this scope
   28 |         ++ s[i];
      |              ^
Language: C++

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

int main()
{
    string s;
    long long int k, size;
    cin >> s >> k;
    size = s.long();
    for(long long int i = 0;i < size;i++){
        if(k >= 'z' - s[i] + 1){
            k -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
    }

    if(k > 0){
        k %= 26;
        s[size - 1] += k;
    }

    cout << s;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: expected unqualified-id before 'long'
    9 |     size = s.long();
      |              ^~~~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
  string s;
  cin >> s;
  int sz=s.size();
  vector<int> n(sz);
  rep(i,sz){
    n[i]= 26 - s[i] + 'a';
    n[i]%=26
  } 

  int k;
  cin >> k;

  rep(i,sz-1){
    if(k>=n[i]){
      s[i] = 'a';
      k -= n[i];
    }
  }
  
  if (k>0){
    k%=26;
    if(k>'z'-s[sz-1]) s[sz-1] += k-26;
    else s[sz-1] += k;

  } 

  cout << s;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: expected ';' before '}' token
   17 |     n[i]%=26
      |             ^
      |             ;
   18 |   }
      |   ~