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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> X(N);
  const int MAX_N = 100;
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; ++i)
  {
    cin >> X[i];
  }
  int ans = 0;
  for (int i = 0; i < N; ++i)
  {
    int tmp = min(X[i], K - X[i]);
    ans += tmp;
  }
  cout << ans * 2 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:7: error: redeclaration of 'int N'
   11 |   int N, K;
      |       ^
a.cc:7:7: note: 'int N' previously declared here
    7 |   int N, K;
      |       ^
a.cc:11:10: error: redeclaration of 'int K'
   11 |   int N, K;
      |          ^
a.cc:7:10: note: 'int K' previously declared here
    7 |   int N, K;
      |          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const int MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
	int N,K;
  	cin >> N>>K;
  	vi x(N);
  	rep(i,N) cin >> x[i];
  	int ans = 0;
  	for(int x:x){
    	sum += min(x,K-x);
    }
  	cout << 2*sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'sum' was not declared in this scope
   26 |         sum += min(x,K-x);
      |         ^~~
a.cc:28:19: error: 'sum' was not declared in this scope
   28 |         cout << 2*sum << endl;
      |                   ^~~
Language: C

#include <stdio.h>

int main()
{
	int i, N, K, x[101];
	scanf("%d", &X);
	scanf("%d", &K);
	for (i = 1; i <= N; i++) scanf("%d", &(x[i]));
	
	int sum = 0;
	for (i = 1; i <= N; i++) {
		if (x[i] <= K / 2) sum += x[i];
		else sum += K - x[i];
	}
	printf("%d\n", sum);
	fflush(stdout);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:22: error: 'X' undeclared (first use in this function)
    6 |         scanf("%d", &X);
      |                      ^
main.c:6:22: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main() {
	int N,K;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		int x;
		cin>>x;
		if(x>=abs(K-x)){
			sum+=2*abs(K-x);
		}
		else{
			sum+=2*x;
		}
	}
	cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: 'sum' was not declared in this scope
   11 |                         sum+=2*abs(K-x);
      |                         ^~~
a.cc:14:25: error: 'sum' was not declared in this scope
   14 |                         sum+=2*x;
      |                         ^~~
a.cc:17:15: error: 'sum' was not declared in this scope
   17 |         cout<<sum<<endl;
      |               ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  double x = K/2;
  int z;
  for(int i=0; i<N; i++){
    int y;
    cin >> y;
    if(x=>y){
      z+=y;
    }
    else{
      z+=K-y;
    }
  }
  cout << z << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:10: error: expected primary-expression before '>' token
   12 |     if(x=>y){
      |          ^
Language: C++

#include <bits/stdlibc++.h>
using namespace std;
int main()
{
  int N, x, K, sum=0;
  cin>>N>>K;
  for(int i=1;i<=N;i++) {
    cin>>x;
    sum+=min(x*2, (K > x ? K - x : x - K) * 2);
  }
  cout << sum << endl;
}

Compiler output:
a.cc:1:10: fatal error: bits/stdlibc++.h: No such file or directory
    1 | #include <bits/stdlibc++.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
  int n,k,a;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i=0;i<n;i++)
    cin >> vec.at(i);
  a=0;
  
  for(int i=0;i<n;i++){
    a+=min(k-vec.at(i),vec.at(i))
  }
  cout << a << endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:13:34: error: expected ';' before '}' token
   13 |     a+=min(k-vec.at(i),vec.at(i))
      |                                  ^
      |                                  ;
   14 |   }
      |   ~
Language: C++

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

int main() {
  int N, K;
  cin >> N >> K;
  int distance = 0;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (K >= (2 * x)) {
      distance += 2 * x;
    }
    
    else if (K > x && K < (2 * x)) {
      distance += 2 * (K - x);
    }
    
    else {
      distance += 2 * (x - K);
  }
  
  cout << distance << endl;
}
      


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

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

int main() {
	int N , K;
  	cin >> N >> K;
    int x;
  	int sum = 0;
	fir(int i = 0; i < N; i++){
        cin >> x;
    	if( 2 * x > 2 * (x - K)){
        	sum += 2 * (x - K);
        }else{
        	sum += 2 * x;
        }
    }
    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: expected primary-expression before 'int'
    9 |         fir(int i = 0; i < N; i++){
      |             ^~~
a.cc:9:24: error: 'i' was not declared in this scope
    9 |         fir(int i = 0; i < N; i++){
      |                        ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
int n,k,x[105],ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
		int b=min(x[i],k-x[i]),a=1e4;
		a=min(a,min(x[i],b*2);
		ans+=a;
	} 
	cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:38: error: expected ')' before ';' token
   12 |                 a=min(a,min(x[i],b*2);
      |                      ~               ^
      |                                      )
Language: C++

#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
int n,k,x[105],ans,x=1e4;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) 
	    cin>>x[i],x=min(x,min(x[i],k-x[i])*2),ans+=x;
	cout<<ans;
    return 0;
}

Compiler output:
a.cc:5:20: error: conflicting declaration 'int x'
    5 | int n,k,x[105],ans,x=1e4;
      |                    ^
a.cc:5:9: note: previous declaration as 'int x [105]'
    5 | int n,k,x[105],ans,x=1e4;
      |         ^
a.cc: In function 'int main()':
a.cc:9:28: error: no matching function for call to 'min(int [105], int)'
    9 |             cin>>x[i],x=min(x,min(x[i],k-x[i])*2),ans+=x;
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:9:28: note:   deduced conflicting types for parameter 'const _Tp' ('int [105]' and 'int')
    9 |             cin>>x[i],x=min(x,min(x[i],k-x[i])*2),ans+=x;
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 3 arguments, 2 provided
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, 2 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:   template argument deduction/substitution failed:
a.cc:9:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int*'
    9 |             cin>>x[i],x=min(x,min(x[i],k-x[i])*2),ans+=x;
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:9:54: error: invalid conversion from 'int*' to 'int' [-fpermissive]
    9 |             cin>>x[i],x=min(x,min(x[i],k-x[i])*2),ans+=x;
      |                                                   ~~~^~~
      |                                                      |
      |                                                      int*
Language: C++

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

int main() {
   int N,K;
   cin>>N>>K;
   int sum=0;
  int x;
  for(int i=0;i<N;i++){
  
    cin>>x;
    if (x<=K-x){
      sum+=2x;
    }
    else if(x>K-x){
      sum+=2(K-x);
    }
  }
  cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: unable to find numeric literal operator 'operator""x'
   13 |       sum+=2x;
      |            ^~
a.cc:16:13: error: expression cannot be used as a function
   16 |       sum+=2(K-x);
      |            ~^~~~~
Language: C++

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

int main() {
   int N,K;
   cin>>N>>K;
   int sum=0;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    if (x<=K-x){
      sum+=2x;
    }
    else if(x>K-x){
      sum+=2(K-x);
    }
  }
  cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: unable to find numeric literal operator 'operator""x'
   12 |       sum+=2x;
      |            ^~
a.cc:15:13: error: expression cannot be used as a function
   15 |       sum+=2(K-x);
      |            ~^~~~~
Language: C++

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

int main(){
  int n,k,sum=0;
  cin>>n>>k;
  int arr[100];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  for(int i=0;i<n;i++)
  {
    int d=arr[i];
    int c=abs(arr[i]-k);
    int sum+=min(d,c);
  }
  cout<<sum<<endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:16:12: error: expected initializer before '+=' token
   16 |     int sum+=min(d,c);
      |            ^~
Language: C++

n = int(input())
k = int(input())
x = list(map(int,input().split()))

dis = 0
for i in range(n):
    if x[i] <= k -x[i]:
        dis += 2*x[i]
    else:
        dis += 2*(k-x[i])
print(dis)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

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

int main() {
  int n,k;
  vector<int> vec(n)
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(vec.at(i)<=k-vec.at(i)){
      sum+=vec.at(i);
  }
  else{
    sum+=k-vec.at(i);
  }
  cout<<sum<<endl;
}
  
    



  


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected ',' or ';' before 'for'
    7 |   for(int i=0;i<n;i++){
      |   ^~~
a.cc:7:15: error: 'i' was not declared in this scope
    7 |   for(int i=0;i<n;i++){
      |               ^
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

int main() {
  int n,k;
  vector<int> vec(n)
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(vec.at(i)<=k-vec.(i))
      sum+=vec.at(i);
  }
  else{
    sum+=k-vec.at(i);
  }
  cout<<sum<<endl;
}
  
    



  

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected ',' or ';' before 'for'
    7 |   for(int i=0;i<n;i++){
      |   ^~~
a.cc:7:15: error: 'i' was not declared in this scope
    7 |   for(int i=0;i<n;i++){
      |               ^
a.cc:12:25: error: expected unqualified-id before '(' token
   12 |     if(vec.at(i)<=k-vec.(i))
      |                         ^
a.cc:15:3: error: 'else' without a previous 'if'
   15 |   else{
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,a = 0,b,c = 0;
  cin >> N >> K;
  a = K / 2 + 1;
  for(int i = 0; i < N){
  	cin >> b;
    if(b < a){
      c += b;
    } else {
      c += K - b;
    }
  }
  cout << c << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:23: error: expected ';' before ')' token
    8 |   for(int i = 0; i < N){
      |                       ^
      |                       ;
Language: C++

#include<iostream>
#include<vector>
#define ve vector
using namespace std;

int main()
{
    int N,K,Ans = 0;
    ve<int> x(N);
    cin >> N >> K;
    
    for(int c = 0;c < N;++c)
    {
        cin >> x(c);
        if(x(c)*x(c) < (x(c) - K)*(x(c) - K))
        {
            Ans += x(c);
        }
        else
        {
            if(x(c) - K >= 0)
                Ans += x(c) - K;
            else 
                Ans -= x(c) - K;
        }
        
        
    }
    cout << Ans << endl;
    
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: no match for call to '(std::vector<int>) (int&)'
   14 |         cin >> x(c);
      |                ~^~~
a.cc:15:13: error: no match for call to '(std::vector<int>) (int&)'
   15 |         if(x(c)*x(c) < (x(c) - K)*(x(c) - K))
      |            ~^~~
a.cc:15:18: error: no match for call to '(std::vector<int>) (int&)'
   15 |         if(x(c)*x(c) < (x(c) - K)*(x(c) - K))
      |                 ~^~~
a.cc:15:26: error: no match for call to '(std::vector<int>) (int&)'
   15 |         if(x(c)*x(c) < (x(c) - K)*(x(c) - K))
      |                         ~^~~
a.cc:15:37: error: no match for call to '(std::vector<int>) (int&)'
   15 |         if(x(c)*x(c) < (x(c) - K)*(x(c) - K))
      |                                    ~^~~
a.cc:17:21: error: no match for call to '(std::vector<int>) (int&)'
   17 |             Ans += x(c);
      |                    ~^~~
a.cc:21:17: error: no match for call to '(std::vector<int>) (int&)'
   21 |             if(x(c) - K >= 0)
      |                ~^~~
a.cc:22:25: error: no match for call to '(std::vector<int>) (int&)'
   22 |                 Ans += x(c) - K;
      |                        ~^~~
a.cc:24:25: error: no match for call to '(std::vector<int>) (int&)'
   24 |                 Ans -= x(c) - K;
      |                        ~^~~
Language: C++

#include<iostream>
#include<vector>
#define ve vector
using namespace std;

int main()
{
    int N,K,Ans = 0;
    ve<int> x(N);
    cin >> N >> K;
    
    for(int c = 0;c < N;++c)
    {
        cin >> x(N);
        if(x(N)*x(N) < (x(N) - K)*(x(N) - K))
        {
            Ans += x(N);
        }
        else
        {
            if(x(N) - K >= 0)
                Ans += x(N) - K;
            else 
                Ans -= x(N) - K;
        }
        
        
    }
    cout << Ans << endl;
    
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: no match for call to '(std::vector<int>) (int&)'
   14 |         cin >> x(N);
      |                ~^~~
a.cc:15:13: error: no match for call to '(std::vector<int>) (int&)'
   15 |         if(x(N)*x(N) < (x(N) - K)*(x(N) - K))
      |            ~^~~
a.cc:15:18: error: no match for call to '(std::vector<int>) (int&)'
   15 |         if(x(N)*x(N) < (x(N) - K)*(x(N) - K))
      |                 ~^~~
a.cc:15:26: error: no match for call to '(std::vector<int>) (int&)'
   15 |         if(x(N)*x(N) < (x(N) - K)*(x(N) - K))
      |                         ~^~~
a.cc:15:37: error: no match for call to '(std::vector<int>) (int&)'
   15 |         if(x(N)*x(N) < (x(N) - K)*(x(N) - K))
      |                                    ~^~~
a.cc:17:21: error: no match for call to '(std::vector<int>) (int&)'
   17 |             Ans += x(N);
      |                    ~^~~
a.cc:21:17: error: no match for call to '(std::vector<int>) (int&)'
   21 |             if(x(N) - K >= 0)
      |                ~^~~
a.cc:22:25: error: no match for call to '(std::vector<int>) (int&)'
   22 |                 Ans += x(N) - K;
      |                        ~^~~
a.cc:24:25: error: no match for call to '(std::vector<int>) (int&)'
   24 |                 Ans -= x(N) - K;
      |                        ~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 int N,K,i,sum=0;
  
 for(i=0;i<N;i++)
 {
   int x;
   cin>>x;
   
   if(x>K/2)
   {
     x= K-x;
   }
   
   sum+=x*2;
 }
  
  cout<<sum<<endll;
  
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: 'endll' was not declared in this scope
   21 |   cout<<sum<<endll;
      |              ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){int n,k,x,d=0;cin>>n>>k;for(int i=0;i<n;i++)cin>>x;if(x*2<k)d+=x*2;else d+=(k-x)*2;}cout<<d<<endl;}

Compiler output:
a.cc:3:96: error: 'cout' does not name a type
    3 | int main(){int n,k,x,d=0;cin>>n>>k;for(int i=0;i<n;i++)cin>>x;if(x*2<k)d+=x*2;else d+=(k-x)*2;}cout<<d<<endl;}
      |                                                                                                ^~~~
a.cc:3:110: error: expected declaration before '}' token
    3 | int main(){int n,k,x,d=0;cin>>n>>k;for(int i=0;i<n;i++)cin>>x;if(x*2<k)d+=x*2;else d+=(k-x)*2;}cout<<d<<endl;}
      |                                                                                                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int k;
  cin >> n >> k;
  int sum = 0;
  
  for (int i = 0; i < n; i++){
    int xi;
  	cin >> xi;
    
    if(xi < K){
    	if(K - xi > xi) {
        	sum += 2 * xi;
        } else {
        	sum += 2 * (K - xi);
        }
    } else {
      sum += 2 * (xi - K);
    }
  }
  cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'K' was not declared in this scope
   14 |     if(xi < K){
      |             ^
Language: C++

#include<cstdio> #include<algorithm>
using namespace std;
const int MAX_N = 100;
int N, K; int X[MAX_N];
int main(){ scanf("%d", &N); scanf("%d", &K); for(int i = 0; i < N; ++i){ scanf("%d", X + i); } int ans = 0; for(int i = 0; i < N; ++i){ int tmp = min(X[i], K - X[i]); ans += tmp; } printf("%d\n", ans * 2); return 0; }


Compiler output:
a.cc:1:18: warning: extra tokens at end of #include directive
    1 | #include<cstdio> #include<algorithm>
      |                  ^
a.cc: In function 'int main()':
a.cc:5:148: error: 'min' was not declared in this scope; did you mean 'main'?
    5 | int main(){ scanf("%d", &N); scanf("%d", &K); for(int i = 0; i < N; ++i){ scanf("%d", X + i); } int ans = 0; for(int i = 0; i < N; ++i){ int tmp = min(X[i], K - X[i]); ans += tmp; } printf("%d\n", ans * 2); return 0; }
      |                                                                                                                                                    ^~~
      |                                                                                                                                                    main
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int ans=0;
  for(int i=0;i<N;i++){
  	int x;
    cin >> x;
    ans+=max(x,K-x);
  }
  cout << x << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'x' was not declared in this scope
   13 |   cout << x << endl;
      |           ^
Language: C++

def chmin(a, b)
  a > b ? b : a
end
n = gets.to_i
k = gets.to_i
x = gets.split.map(&:to_i)

sum = 0
(0..n - 1).each do |i| 
    l = chmin(x[i] * 2, (x[i] - k).abs * 2)
    sum += l
end
puts sum

Compiler output:
a.cc:9:2: error: too many decimal points in number
    9 | (0..n - 1).each do |i|
      |  ^~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def chmin(a, b)
      | ^~~
Language: Java

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum =0;
		for (int i=0;i<N;i++) {
			int a= sc.nextInt();
			if (K-a<a) {
				sum = sum + (K-a)*2;
			} else {
				sum = sum + 2*a;
			}
		}
		System.out.println(sum);
	}
}


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 <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int A[N];
  rep(i,N){
    int x;
    cin >> x;
    A[i] = x;
  }
  int dist;
  rep(i,n){
    dist += max(A[i],K-A[i]);
  }
  cout << dist * 2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'n' was not declared in this scope
   14 |   rep(i,n){
      |         ^
a.cc:2:38: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
      |                                      ^
Language: C++

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int ans = 0;
        while (n-- > 0) {
            int num = sc.nextInt();
            int tmp = Math.min(k-num, num);
            ans += tmp;
        }
        System.out.println(ans*2);
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

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

int main() {
  int N,K,x,sum=0;
  cin >> N>>K;
  int i=1;
  
  for(i;i<=N;i++){
    cin>>x;
      if(x<K-x){
        sum+=2*x
      }else{
        sum+=2*(K-x)
      }
  }
    cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: expected ';' before '}' token
   12 |         sum+=2*x
      |                 ^
      |                 ;
   13 |       }else{
      |       ~          
a.cc:14:21: error: expected ';' before '}' token
   14 |         sum+=2*(K-x)
      |                     ^
      |                     ;
   15 |       }
      |       ~
Language: C++

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

int main() {
  int N,K,x,min=0;
  cin >> N>>K;
  int i=1;
  
  for(i;i<=N;i++){
    cin>>x
      if(x<K-x){
        //min
        if(2*x>min)min=2*x;
      }else{
        //min
        if(2*(K-x)>min)min=2*(K-x);
      }
  }
    cout<<min<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: expected ';' before 'if'
   10 |     cin>>x
      |           ^
      |           ;
   11 |       if(x<K-x){
      |       ~~   
a.cc:14:8: error: 'else' without a previous 'if'
   14 |       }else{
      |        ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int K;
  cin>>N>>K;
  int sum=0;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    if(abs(x-k)<x){
      sum=sum+abs(x-k);
    }
    else{
      sum=sum+x;
    }
  }
  cout<<sum<<endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: 'k' was not declared in this scope
   11 |     if(abs(x-k)<x){
      |              ^
Language: C++

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

int main() {
  int N,K,X,x;
  cin>>N>>K;
  X=0;
  for(int i=0;i<N;i++){
    cin>>x;
    if(x<K/2){
      X+=x
    }
    else{
      X+=(K-x)
    }
  }
    cout<<2*X<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: error: expected ';' before '}' token
   11 |       X+=x
      |           ^
      |           ;
   12 |     }
      |     ~      
a.cc:14:15: error: expected ';' before '}' token
   14 |       X+=(K-x)
      |               ^
      |               ;
   15 |     }
      |     ~
Language: C++

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

int main() {
  int N,K,X,x;
  cin>>N>>K;
  X=0;
  for(int i=0;i<N;i++){
    cin>>x;
    if(x<K/2){
      X+=x
    }
    else{
      X+=(K-x)
    }
  }
    cout<<X<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: error: expected ';' before '}' token
   11 |       X+=x
      |           ^
      |           ;
   12 |     }
      |     ~      
a.cc:14:15: error: expected ';' before '}' token
   14 |       X+=(K-x)
      |               ^
      |               ;
   15 |     }
      |     ~
Language: C++

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

int main() {
  int N,K,X,x;
  cin>>N>>K,
  X=0;
  for(int i=0;i<N;i++){
    cin>>x;
    if((K-x)*(K-x)<x*x){
      if(K>x){
        X+=(K-x);
      }
      if(K<=x){
        X-=(K-x);
      }
    }
    if((K-x)*(K-x)>=x*x){
      X+=x
    }
  }
    cout<<X<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:11: error: expected ';' before '}' token
   19 |       X+=x
      |           ^
      |           ;
   20 |     }
      |     ~
Language: C++

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

int main() {
  int N,K,X,x;
  cin>>N>>K,
  X=0;
  for(int i=0;i<N;i++){
    cin>>x;
    if((K-x)*(K-x)<x*x){
      if(K>x){
        X+=(K-x);
      }
      if else{
        X-=(K-x);
      }
    else{
      X+=x
    }
  }
    cout<<X<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: expected '(' before 'else'
   14 |       if else{
      |          ^~~~
      |          (
a.cc:17:5: error: expected '}' before 'else'
   17 |     else{
      |     ^~~~
a.cc:10:24: note: to match this '{'
   10 |     if((K-x)*(K-x)<x*x){
      |                        ^
a.cc:18:11: error: expected ';' before '}' token
   18 |       X+=x
      |           ^
      |           ;
   19 |     }
      |     ~
Language: C++

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

int x[110];
int main(){
  int N,K;
  cin >> N >> K;
  
  for (int i=0;i<K;i++) cin >> x[i];
  
  int sum=0;
  for (int i=0;i<K;i++){
     sum+=2*min(x[i],K-x[i])
  }
  cout << sum << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:29: error: expected ';' before '}' token
   13 |      sum+=2*min(x[i],K-x[i])
      |                             ^
      |                             ;
   14 |   }
      |   ~
Language: C++

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

int x[110];
int main(){
  int N,K;
  cin >> N >> K;
  
  for (int i=0;i<110;i++) cin >> x[i];
  
  int sum=0;
  for (int i=0;i<110;i++){
     cout << sum+=2*min(x[i],K-x[i]) << endl;
     return 0;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:38: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   13 |      cout << sum+=2*min(x[i],K-x[i]) << endl;
      |                   ~~~~~~~~~~~~~~~~~~~^~~~~~~
Language: C++

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

int x[110];
int main(){
  int N,K;
  cin >> N >> K;
  
  for (int i=0;i<110;i++) cin >> x[i];
  
  cout << 2*min(x[i],K-x[i]) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:19: error: 'i' was not declared in this scope
   11 |   cout << 2*min(x[i],K-x[i]) << endl;
      |                   ^
Language: Java

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int sum = 0;
        for (int i = 0; i < N; i++) {
            int x = Integer.parseInt(sc.next());
            sum += Math.min(x * 2, Math.abs(x - K) * 2);
        }
        out.println(sum);

        out.flush();
    }
}

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

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

int main() {
  int n,k,sum=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(x*2>k)
      sum+=(k-x)*2;
    else
      sum+=x*2
  }
  cout<<sum<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: expected ';' before '}' token
   13 |       sum+=x*2
      |               ^
      |               ;
   14 |   }
      |   ~
Language: C++

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		int N=sc.nextInt();//p("N"+N);
		int K=sc.nextInt();//p("K"+K);
		int ans=0;
		int tmp;
		for(int i=0;i<N;i++) {
			tmp=sc.nextInt();//p("tmp"+tmp);
			ans+=Math.min(Math.abs(K-tmp), tmp)*2;
		}
		p(ans);
		
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.ArrayList;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Collections;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
    7 | public class Main {
      | ^~~~~~
Language: C++

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

int main() {
 int N ,  K , com;
 com = 0;
 cin >> N >> K;
 vector<int> x(N);
 for(int i = 0; i < N; i++) {
  cin >> x[i];
  com = min(x[i],abs(K - x[i]))
}

cout << com * 2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:32: error: expected ';' before '}' token
   11 |   com = min(x[i],abs(K - x[i]))
      |                                ^
      |                                ;
   12 | }
      | ~
Language: C++

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

int main() {
 int N ,  K , com;
 com = 0;
 cin >> N >> K;
 vector<int> x(N);
 for(int i = 0: i < N; i++) {
  cin >> x[i];
  com = min(x[i],abs(K - x[i]))
}

cout << com * 2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: initializer in range-based 'for' loop
    9 |  for(int i = 0: i < N; i++) {
      |            ^
a.cc:9:22: error: expected ')' before ';' token
    9 |  for(int i = 0: i < N; i++) {
      |     ~                ^
      |                      )
a.cc:9:24: error: 'i' was not declared in this scope
    9 |  for(int i = 0: i < N; i++) {
      |                        ^
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int arr[101];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}	
	int ans=0;
	for(int i=0;i<n;i++){
		ans+=2*min(x[i],k-x[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:28: error: 'x' was not declared in this scope
   57 |                 ans+=2*min(x[i],k-x[i]);
      |                            ^
Language: C++

int main() {
int A , B , C;
cin >> B >> A;// kazoerukazu
int D = 0;
for (int i = 0; i < B; i++){
  cin >> C ;
  if (C < A * 2 < 2 * C ){
    D += C < A * 2;
  }else{
    D += 2 * C;
  }
}
cout << D << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:1: error: 'cin' was not declared in this scope
    3 | cin >> B >> A;// kazoerukazu
      | ^~~
a.cc:13:1: error: 'cout' was not declared in this scope
   13 | cout << D << endl;
      | ^~~~
a.cc:13:14: error: 'endl' was not declared in this scope
   13 | cout << D << endl;
      |              ^~~~
Language: C++

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

int main() {
int A , B , C;
cin >> B >> A;// kazoerukazu
int D = 0;
for (int i = 0; i < B; i++){
  cin >> C ;
  if (C < A * 2 < 2 * C ){
    D += C < A * 2
  }else{
    D += 2 * C
  }
}
cout << D << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:19: error: expected ';' before '}' token
   11 |     D += C < A * 2
      |                   ^
      |                   ;
   12 |   }else{
      |   ~                
a.cc:13:15: error: expected ';' before '}' token
   13 |     D += 2 * C
      |               ^
      |               ;
   14 |   }
      |   ~
Language: C++

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

int main() {

  int N,K,x,n=0;
  cin >> N >> K;
  for(int i=0;K>i;i++){
    cin >> x;
    if(x<K/2) n+=x*2;
    else n+=(K-x)*2
  }
  cout << n << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: expected ';' before '}' token
   11 |     else n+=(K-x)*2
      |                    ^
      |                    ;
   12 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,k,ans=0;
  cin>>n>>k;
  rep(i,n){
  int x;
  cin>>x;
  int d1=|x|,d2=|k-x|;    
  ans += (d1<d2 ? d1 : d2);
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: expected primary-expression before '|' token
   11 |   int d1=|x|,d2=|k-x|;
      |          ^
a.cc:11:13: error: expected primary-expression before ',' token
   11 |   int d1=|x|,d2=|k-x|;
      |             ^
a.cc:12:14: error: 'd2' was not declared in this scope; did you mean 'd1'?
   12 |   ans += (d1<d2 ? d1 : d2);
      |              ^~
      |              d1
Language: C++

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

int main() {
  int n,k,x,tot;
  cin >> n;
  cin >> k;
  tot=0;
  for(int i = 0; i < N; i++){
     cin >> x;
    if(x>=k-x){
      tot+=k-x;
    }
    else{
      tot+=x;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: 'N' was not declared in this scope
    9 |   for(int i = 0; i < N; i++){
      |                      ^
Language: C++

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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  int i = 0;
  for (; i < N;) {
    int x;
    cin >> x;
    if (K-x =< x) 
      sum+=2*(K-x);
    else
      sum+=2*x;
    i++;
  }
  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: expected primary-expression before '<' token
   12 |     if (K-x =< x)
      |              ^
Language: C++

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

int main(){
	int C,N,K,x;
	C = 0;
	cin >> N >> K;
	
	for(int i = 0; N > i;i++){
		cin >> x;
		int A,B;
		A = x;
		B = x - K;
		if(B<0)
			B = (-1)*B;
		if(A>B)
			C = C+2*B
		else
			C = C+2*A;
	}
	
	cout << C <<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:34: error: expected ';' before 'else'
   17 |                         C = C+2*B
      |                                  ^
      |                                  ;
   18 |                 else
      |                 ~~~~
Language: C++

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

int main(){
	int C,N,K,X;
	C = 0;
	cin >> N >> K;
	
	for(int i = 0; N > i;i++){
		cin >> x;
		int A,B;
		A = x;
		B = x - K;
		if(B<0)
			B = (-1)*B;
		if(A>B)
			C = 2*B+A;
		else
			C = 2*A+B;
	}
	
	cout << C <<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:10:24: error: 'x' was not declared in this scope
   10 |                 cin >> x;
      |                        ^
Language: C++

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

int main() {
  int N, K, x, S;
  cin >> N >> K;
  S = 0;
  for (int i = 0; i < N; i++){
    cin >> x;
    if (K - x > x)
      S += x;
    else
      S += k - x;
  }
  cout << S << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: 'k' was not declared in this scope
   13 |       S += k - x;
      |            ^
Language: C++

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

int main() {
  int N, K, x, S;
  cin >> N >> K;
  S = 0;
  for (int i = 0; i < N; i++){
    cin >> x
    if (K - x > x)
      S += K - x;
    else
      S += x
  }
  cout << S << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: expected ';' before 'if'
    9 |     cin >> x
      |             ^
      |             ;
   10 |     if (K - x > x)
      |     ~~       
a.cc:12:5: error: 'else' without a previous 'if'
   12 |     else
      |     ^~~~
a.cc:13:13: error: expected ';' before '}' token
   13 |       S += x
      |             ^
      |             ;
   14 |   }
      |   ~
Language: C++

#include <iostream>
using namespace std;
int main(){
int a,b;
int sum = 0;
  cin >> a >> b;
  for(int i = 0;i<a;i++){
    cin >> n;
    if(n>=b-n){
    sum += 2*(b-n);
    }else{
    sum += 2*n;
    }
  }
  cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: 'n' was not declared in this scope
    8 |     cin >> n;
      |            ^
Language: C++

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

int main() {
  int N,K,x,sum;
  cin >>N>>K;
  for (i = 0;i < N;i++) {
    cin >> x;
    if (x >= K - x) {
      sum += 2 * x
    }
    else if (x <= K - x) {
      sum += 2 * (K - x)
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: 'i' was not declared in this scope
    7 |   for (i = 0;i < N;i++) {
      |        ^
a.cc:10:19: error: expected ';' before '}' token
   10 |       sum += 2 * x
      |                   ^
      |                   ;
   11 |     }
      |     ~              
a.cc:13:25: error: expected ';' before '}' token
   13 |       sum += 2 * (K - x)
      |                         ^
      |                         ;
   14 |     }
      |     ~                    
a.cc:15:2: error: expected '}' at end of input
   15 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

int main(){
	int n, k, x, min;
	cin >> n >> k >> x;
	min = 2*x + (x-k) ? x-k : k-x;
	for(int i=2; i <= n; i++) {
		cin >> x;
		int t = 2*x + (x-k) ? x-k : k-x;
		if(min > t)
			min = t;
	}
	cuot << min << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'cuot' was not declared in this scope
   14 |         cuot << min << endl;
      |         ^~~~
Language: C++

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

int main() {
  int N, A, b, c;
  cin >> N >> A;
  c = 0;
  for (int i = 0; i < N; i++) {
    cin >> b >>;
    if (b * 2 < (A - b) * 2 ) {
      c = c + b * 2;
    }
    else {
      c = (c + A - b) * 2;
    }
  }
  cout << c << endl;
      
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:16: error: expected primary-expression before ';' token
    9 |     cin >> b >>;
      |                ^
Language: C++

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

int main() {
  int N, A, b, c;
  cin >> N >> A;
  c = 0
  for (int i = 0; i < N; i++) {
    cin >> b >>;
    if (b * 2 < (A - b) * 2 ) {
      c = c + b * 2;
    }
    else {
      c = (c + (A - b)) * 2;
    }
  }
  cout << c << endl;
      
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: expected ';' before 'for'
    7 |   c = 0
      |        ^
      |        ;
    8 |   for (int i = 0; i < N; i++) {
      |   ~~~   
a.cc:8:19: error: 'i' was not declared in this scope
    8 |   for (int i = 0; i < N; i++) {
      |                   ^
Language: C++

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

int main() {
  int N, A, b, c;
  cin >> N >> A;
  c = 0
  for (int i = 0; i < N; i++) {
    cin >> b >>;
    if (b <= A - b) {
      c = c + b * 2;
    }
    else {
      c = c + (A - b);
    }
  }
  cout << c << endl;
      
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: expected ';' before 'for'
    7 |   c = 0
      |        ^
      |        ;
    8 |   for (int i = 0; i < N; i++) {
      |   ~~~   
a.cc:8:19: error: 'i' was not declared in this scope
    8 |   for (int i = 0; i < N; i++) {
      |                   ^
Language: C++

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

int main() {

  int N,K,x;
  
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if(k-x>x){
    	x+=2*x;
    }else{
    	x+=(k-x)*2;
    }
  }
	cout << x;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: 'k' was not declared in this scope
   12 |     if(k-x>x){
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int k;
  cin >> k;
  int sum=0;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x>=k-x && k-x>=0) {    
      sum+=k-x;}
    else if(x>=x-k && x-k>=0){　
      sum+=x-k;}
    else if(x<=k-x && k-x>=0){　　
      sum+=x;}
    else if(x<=x-k && x-k>=0){　　
      sum+=x;}
    }
  cout << sum << endl;
  }
    


Compiler output:
a.cc:14:31: error: extended character 　 is not valid in an identifier
   14 |     else if(x>=x-k && x-k>=0){　
      |                               ^
a.cc:16:31: error: extended character 　 is not valid in an identifier
   16 |     else if(x<=k-x && k-x>=0){　　
      |                               ^
a.cc:16:31: error: extended character 　 is not valid in an identifier
a.cc:18:31: error: extended character 　 is not valid in an identifier
   18 |     else if(x<=x-k && x-k>=0){　　
      |                               ^
a.cc:18:31: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:14:31: error: '\U00003000' was not declared in this scope
   14 |     else if(x>=x-k && x-k>=0){　
      |                               ^~
a.cc:16:31: error: '\U00003000\U00003000' was not declared in this scope
   16 |     else if(x<=k-x && k-x>=0){　　
      |                               ^~~~
a.cc:18:31: error: '\U00003000\U00003000' was not declared in this scope
   18 |     else if(x<=x-k && x-k>=0){　　
      |                               ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int k;
  cin >> k;
  int sum=0;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x>=k-x && k-x>=0) {    
      sum+=k-x;}
   else if(x>=x-k && x-k>=0){　
      sum+=x-k;}
   else if(x<=k-x && k-x>=0) {　　
      sum+=x;}
   else if(x<=x-k && x-k>=0) {　　
      sum+=x;}
    }
  cout << sum << endl;
  }
    


Compiler output:
a.cc:14:30: error: extended character 　 is not valid in an identifier
   14 |    else if(x>=x-k && x-k>=0){　
      |                              ^
a.cc:16:31: error: extended character 　 is not valid in an identifier
   16 |    else if(x<=k-x && k-x>=0) {　　
      |                               ^
a.cc:16:31: error: extended character 　 is not valid in an identifier
a.cc:18:31: error: extended character 　 is not valid in an identifier
   18 |    else if(x<=x-k && x-k>=0) {　　
      |                               ^
a.cc:18:31: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:14:30: error: '\U00003000' was not declared in this scope
   14 |    else if(x>=x-k && x-k>=0){　
      |                              ^~
a.cc:16:31: error: '\U00003000\U00003000' was not declared in this scope
   16 |    else if(x<=k-x && k-x>=0) {　　
      |                               ^~~~
a.cc:18:31: error: '\U00003000\U00003000' was not declared in this scope
   18 |    else if(x<=x-k && x-k>=0) {　　
      |                               ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int k;
  cin >> k;
  int sum=0;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x>=k-x && k-x>=0) {    
      sum+=k-x;}
    else if(x>=x-k && x-k>=0){　
      sum+=x-k;}
    else if(x<=k-x && k-x>=0) {　　
      sum+=x;}
    else if(x<=x-k && x-k>=0) {　　
      sum+=x;}
    }
  cout << sum << endl;
  }
    


Compiler output:
a.cc:14:31: error: extended character 　 is not valid in an identifier
   14 |     else if(x>=x-k && x-k>=0){　
      |                               ^
a.cc:16:32: error: extended character 　 is not valid in an identifier
   16 |     else if(x<=k-x && k-x>=0) {　　
      |                                ^
a.cc:16:32: error: extended character 　 is not valid in an identifier
a.cc:18:32: error: extended character 　 is not valid in an identifier
   18 |     else if(x<=x-k && x-k>=0) {　　
      |                                ^
a.cc:18:32: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:14:31: error: '\U00003000' was not declared in this scope
   14 |     else if(x>=x-k && x-k>=0){　
      |                               ^~
a.cc:16:32: error: '\U00003000\U00003000' was not declared in this scope
   16 |     else if(x<=k-x && k-x>=0) {　　
      |                                ^~~~
a.cc:18:32: error: '\U00003000\U00003000' was not declared in this scope
   18 |     else if(x<=x-k && x-k>=0) {　　
      |                                ^~~~