criyle/codenet-compile-errors huggingface dataset:
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:32: 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:32: 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) {　　
      |                                ^~~~
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) {    //Bをうごかす条件１
      sum+=k-x;}
    else if(x>=x-k && x-k>=0) {　//Bをうごかす条件２
      sum+=x-k;}
    else if(x<=k-x && k-x>=0) {　　//Aをうごかす条件１
      sum+=x;}
    else if(x<=x-k && x-k>=0) {　　//Aをうごかす条件２
      sum+=x;}
    }
  cout << sum << endl;
  }
    

Compiler output:
a.cc:14:32: error: extended character 　 is not valid in an identifier
   14 |     else if(x>=x-k && x-k>=0) {　//Bをうごかす条件２
      |                                ^
a.cc:16:32: error: extended character 　 is not valid in an identifier
   16 |     else if(x<=k-x && k-x>=0) {　　//Aをうごかす条件１
      |                                ^
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をうごかす条件２
      |                                ^
a.cc:18:32: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:14:32: error: '\U00003000' was not declared in this scope
   14 |     else if(x>=x-k && x-k>=0) {　//Bをうごかす条件２
      |                                ^~
a.cc:16:32: error: '\U00003000\U00003000' was not declared in this scope
   16 |     else if(x<=k-x && k-x>=0) {　　//Aをうごかす条件１
      |                                ^~~~
a.cc:18:32: error: '\U00003000\U00003000' was not declared in this scope
   18 |     else if(x<=x-k && x-k>=0) {　　//Aをうごかす条件２
      |                                ^~~~
Language: C++

#include <bits/stdc++.h>
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;
      if(x*2<k){
          ans+= x*2;
      }
      else{
          ans+=(k-x)*2;
      }
  }
  cout << ans << endl;
}


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,t,sum = 0;
  cin >> N >> K;
  
  for (int i = 0;i < N;++i){
    cin t;
    int dist1,dist2;
    dist1 = std::abs(K-t);
    dist2 = std::abs(t);
    if (dist1 < dist2)
      sum += dist1;
    else
      sum += dist2;
  }
  cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: expected ';' before 't'
    9 |     cin t;
      |        ^~
      |        ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){

  int N,K,x,sum = 0;
  cin >> N >> K;
  
  for (int i = 0;i < N;++i){
    cin x;
    int dist1,dist2;
    dist1 = std::abs(K-x);
    dist2 = std::abs(x);
    if (dist1 < dist2)
      sum += dist1;
    else
      sum += dist2;
  }
  cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: expected ';' before 'x'
    9 |     cin x;
      |        ^~
      |        ;
Language: C++

#include <iostream>

int main() {
  	int N, K;
	std::cin >> N;
  	std::cin >> K;
  	int X[N] = {};
  	for (int i = 0; i < N; i++) {
   		std::cin >> X[i];
    }
  	int result = 0;
	
  	for (int i = 0; i < N; i++) {
      	result += (X[i] < (K-X[i])) ? X[i] : K - X[i];
    }
  
  	std::out >>  result;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: 'out' is not a member of 'std'; did you mean 'oct'?
   17 |         std::out >>  result;
      |              ^~~
      |              oct
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,x,sum=0;
  cin >> N >> K;
  
  rep(i,N){
    cin >> x;
    
    if(K-x>x)
      sum += 2*x;
    else
      sum += 2*(K-x);
  }
  cout << sum << endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:3:44: error: expected ';' before ')' token
    3 | #define rep(i,n) for(int i=0;i<(int)(n),i++)
      |                                            ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,N){
      |   ^~~
Language: C++

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

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

#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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

}

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

#include<iostream>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   rep(i,N){
      |       ^
a.cc:3:22: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(i=0;i<n;i++)
      |                      ^
a.cc:17:19: error: 'X' was not declared in this scope
   17 |       sum += 2*(K-X)
      |                   ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: expected initializer before 'K'
    5 |   int N K;
      |         ^
a.cc:6:10: error: 'N' was not declared in this scope
    6 |   cin >> N >> K;
      |          ^
a.cc:6:15: error: 'K' was not declared in this scope
    6 |   cin >> N >> K;
      |               ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: 'k' was not declared in this scope
   13 |     if (x < k/2) distance += x;
      |             ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: expected initializer before 'K'
    5 |   int N K;
      |         ^
a.cc:6:10: error: 'N' was not declared in this scope
    6 |   cin >> N >> K;
      |          ^
a.cc:6:15: error: 'K' was not declared in this scope
    6 |   cin >> N >> K;
      |               ^
a.cc:13:13: error: 'k' was not declared in this scope
   13 |     if (x < k/2) distance += x;
      |             ^
Language: C++

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

int main(){
  int n, k, a;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++){
    cin >> a;
    ans += min(abs(k-a), abs(a));
  }
  ans *= 2
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: expected ';' before 'cout'
   12 |   ans *= 2
      |           ^
      |           ;
   13 |   cout << ans << endl;
      |   ~~~~
Language: C++

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

int main() {
  int N,K,x,a;
  cin >> N >>K;
  a=0;

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


Compiler output:
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: C++

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

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


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

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected ',' or ';' before 'for'
    9 |   for(int i=0; i<n ;i++){
      |   ^~~
a.cc:9:16: 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;

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

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

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

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

Compiler output:
a.cc:21:1: error: expected declaration before '}' token
   21 | }
      | ^
Language: C++

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

Compiler output:
a.cc:1:1: error: 'clude' does not name a type
    1 | clude <bits/stdc++.h>
      | ^~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> N >> K;
      |   ^~~
a.cc:18:3: error: 'cout' was not declared in this scope
   18 |   cout << distance << endl;
      |   ^~~~
a.cc:18:23: error: 'endl' was not declared in this scope
   18 |   cout << distance << endl;
      |                       ^~~~
Language: C++

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

Compiler output:
a.cc:23:5: error: redefinition of 'int main()'
   23 | int main() {
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main() {
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int distance = 0;
  int x;
  for (int i = 0; i < N; i++){
    cin >> x;
    if (x < (K - x)){
      distance += x;
    }
    else {
      distance += (K - x);
    }
  }
  cout << distance << endl;
}
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int distance = 0;
  int x;
  for (int i = 0; i < N; i++){
    cin >> x;
    if (x < (K - x)){
      distance += 2*x;
    }
    else {
      distance += 2*(K - x);
    }
  }
  cout << distance << endl;
}
提出情報

Compiler output:
a.cc:23:5: error: redefinition of 'int main()'
   23 | int main() {
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main() {
      |     ^~~~
a.cc:39:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
   39 | 提出情報
      | ^~~~~~~~
Language: C++

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



Compiler output:
a.cc: In function 'int main()':
a.cc:16:2: error: expected '}' at end of input
   16 | }
      |  ^
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, sum=0;
  cin >> N>>K;
  for(int i=0;i<N;i++){
    cin >> x;
    if(K > 2*x){
      sum += 2*x;
    }else{
      sum += 2*(K-x)
       
  }
  cout << sum << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:21: error: expected ';' before '}' token
   12 |       sum += 2*(K-x)
      |                     ^
      |                     ;
   13 | 
   14 |   }
      |   ~                  
a.cc:16:2: error: expected '}' at end of input
   16 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: expected ';' before 'if'
    9 |     cin>>xi
      |            ^
      |            ;
   10 |     if(xi > k-xi)s+=2*(xi);
      |     ~~      
a.cc:11:5: error: 'else' without a previous 'if'
   11 |     else s+=2*(k-xi);
      |     ^~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: expected ';' before 'if'
    9 |     cin>>xi
      |            ^
      |            ;
   10 |     if(x > k-x)s+=2*(x);
      |     ~~      
a.cc:11:5: error: 'else' without a previous 'if'
   11 |     else s+=2*(k-x);
      |     ^~~~
a.cc:11:18: error: 'x' was not declared in this scope
   11 |     else s+=2*(k-x);
      |                  ^
Language: C++


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

               cout << sum << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:44: error: expected ')' before ';' token
   16 |         sum += min(2*x.at(i), 2*(K-x.at(i));
      |                   ~                        ^
      |                                            )
Language: C++

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

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


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

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

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


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

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

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

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #incluce; did you mean #include?
    1 | #incluce <bits/stdc++.h>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> N >> K;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #incluce <bits/stdc++.h>
a.cc:17:3: error: 'cout' was not declared in this scope
   17 |   cout << res << endl;
      |   ^~~~
a.cc:17:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:17:18: error: 'endl' was not declared in this scope
   17 |   cout << res << endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #incluce <bits/stdc++.h>
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int d;
  int e;
  e = b/2;
  while(a > 0){
    int c;
    int f;
    cin >> c;
    f = b - c;
    if(e > c)
      d += c*2;
    else if(f > 0)
      d += f*2;
    else
      d += (-f)*2;
    a--
  }
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: expected ';' before '}' token
   20 |     a--
      |        ^
      |        ;
   21 |   }
      |   ~
Language: C++

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

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

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

#include<stdio.h>
int main(){
  int n,k,x,i,ans = 0;
  scanf("%d",&n);
  scanf("%d",&k);
  for (i=0;i<n;i++){
    scanf("%d",&x);
    if (x > K/2) {
      ans += K - x;
    }else {
      ans += x;
    }
  }
  printf("%d\n",ans);
  return 0 ;
}
    

Compiler output:
main.c: In function 'main':
main.c:8:13: error: 'K' undeclared (first use in this function)
    8 |     if (x > K/2) {
      |             ^
main.c:8:13: 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, x, l=0;
  cin >> N >> K;
     
  for (int i=1; i<=N; i++){
    cin >> x;
    A=x*2;
    B=((K-x)^2)^(1/2)*2;
    if(A<=B)
      l+=A;
    else
      l+=B;
  }
    cout << l << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'A' was not declared in this scope
   10 |     A=x*2;
      |     ^
a.cc:11:5: error: 'B' was not declared in this scope
   11 |     B=((K-x)^2)^(1/2)*2;
      |     ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'A' was not declared in this scope
   10 |     A=x*2;
      |     ^
a.cc:11:5: error: 'B' was not declared in this scope
   11 |     B=|K-x|*2;
      |     ^
a.cc:11:7: error: expected primary-expression before '|' token
   11 |     B=|K-x|*2;
      |       ^
a.cc:11:12: error: invalid type argument of unary '*' (have 'int')
   11 |     B=|K-x|*2;
      |            ^~
Language: C++

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

int main() {

	int N,K,sum=0,dis;
	cin>>N>>K;
  vector<int> x(N);
  for(int i=0;i<N;i++){
	cin>>x.at(i);}
  
  for(int i=0;i<N;i++){
    if(K<x.at(i)){dis=x.at(i)-K;}
    else{dis=K-x.at(i);}
    if(x.at(i)>=dis){sum+=dis;}
    else{sum+=x.a(i);}
	cout<<sum<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:16:17: error: 'class std::vector<int>' has no member named 'a'; did you mean 'at'?
   16 |     else{sum+=x.a(i);}
      |                 ^
      |                 at
a.cc:18:2: error: expected '}' at end of input
   18 | }
      |  ^
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,sum=0,dis;
	cin>>N>>K;
  vector<int> x(N);
  for(int i=0;i<N,i++){
	cin>>x.at(i);}
  
  for(int i=0;i<N;i++){
    if(K<x.at(i)){dis=x.at(i)-K;}
    else{dis=K-x.at(i);}
    if(x.at(i)>=dis){sum+=dis;}
    else{sum+=x.a(i);}
	cout<<sum<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: expected ';' before ')' token
    9 |   for(int i=0;i<N,i++){
      |                      ^
      |                      ;
a.cc:16:17: error: 'class std::vector<int>' has no member named 'a'; did you mean 'at'?
   16 |     else{sum+=x.a(i);}
      |                 ^
      |                 at
a.cc:18:2: error: expected '}' at end of input
   18 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
//#include<vector>
using namespace std;
int main(){
  int n,k;
  std::cin>>n>>k;
  //vector<int>b;
  int j;
  int s=0;
  int i;
  for(i=0;i<n;i++)
  {
    std::cin>>j;
    //b.push_back(j);
    int t=min(x,abs(k-x));
    s+=t;
  }
  s*=2;
  std::cout<<s;
  return 0;
}
  
    


Compiler output:
a.cc: In function 'int main()':
a.cc:15:15: error: 'x' was not declared in this scope
   15 |     int t=min(x,abs(k-x));
      |               ^
Language: C++

#include<bits/stdc++.h>
//#include<vector>
using namespace std;
int main{
  int n,k;
  std::cin>>n>>k;
  //vector<int>b;
  int j;
  int s=0;
  int i;
  for(i=0;i<n;i++)
  {
    std::cin>>j;
    //b.push_back(j);
    int t=min(x,abs(k-x));
    s+=t;
  }
  s*=2;
  std::cout<<s;
  return 0;
}
  
    


Compiler output:
a.cc:4:5: error: cannot declare '::main' to be a global variable
    4 | int main{
      |     ^~~~
a.cc:5:3: error: expected primary-expression before 'int'
    5 |   int n,k;
      |   ^~~
a.cc:5:3: error: expected '}' before 'int'
a.cc:4:9: note: to match this '{'
    4 | int main{
      |         ^
a.cc:6:8: error: 'cin' in namespace 'std' does not name a type
    6 |   std::cin>>n>>k;
      |        ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:3: error: expected unqualified-id before 'for'
   11 |   for(i=0;i<n;i++)
      |   ^~~
a.cc:11:11: error: 'i' does not name a type
   11 |   for(i=0;i<n;i++)
      |           ^
a.cc:11:15: error: 'i' does not name a type
   11 |   for(i=0;i<n;i++)
      |               ^
a.cc:18:3: error: 's' does not name a type
   18 |   s*=2;
      |   ^
a.cc:19:8: error: 'cout' in namespace 'std' does not name a type
   19 |   std::cout<<s;
      |        ^~~~
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:20:3: error: expected unqualified-id before 'return'
   20 |   return 0;
      |   ^~~~~~
a.cc:21:1: error: expected declaration before '}' token
   21 | }
      | ^
Language: C++

#include<iostream>
//#include<vector>
using namespace std;
int main{
  int n,k;
  cin>>n>>k;
  //vector<int>b;
  int j;
  int s=0;
  int i;
  for(i=0;i<n;i++)
  {
    cin>>j;
    //b.push_back(j);
    if(j>=k)
    {
      s+=(j-k)*2;
    }
    else
    {
      s+=(k-j)>j?(j*2):((k-j)*2);
    }
  }
  cout<<s;
  return 0;
}
  
    


Compiler output:
a.cc:4:5: error: cannot declare '::main' to be a global variable
    4 | int main{
      |     ^~~~
a.cc:5:3: error: expected primary-expression before 'int'
    5 |   int n,k;
      |   ^~~
a.cc:5:3: error: expected '}' before 'int'
a.cc:4:9: note: to match this '{'
    4 | int main{
      |         ^
a.cc:6:3: error: 'cin' does not name a type
    6 |   cin>>n>>k;
      |   ^~~
a.cc:11:3: error: expected unqualified-id before 'for'
   11 |   for(i=0;i<n;i++)
      |   ^~~
a.cc:11:11: error: 'i' does not name a type
   11 |   for(i=0;i<n;i++)
      |           ^
a.cc:11:15: error: 'i' does not name a type
   11 |   for(i=0;i<n;i++)
      |               ^
a.cc:24:3: error: 'cout' does not name a type
   24 |   cout<<s;
      |   ^~~~
a.cc:25:3: error: expected unqualified-id before 'return'
   25 |   return 0;
      |   ^~~~~~
a.cc:26:1: error: expected declaration before '}' token
   26 | }
      | ^
Language: C++

#include<iostream>
//#include<vector>
using namespace std;
int main{
  int n,k;
  std::cin>>n>>k;
  //vector<int>b;
  int j;
  int s=0;
  int i;
  for(i=0;i<n;i++)
  {
    std::cin>>j;
    //b.push_back(j);
    if(j>=k)
    {
      s+=(j-k)*2;
    }
    else
    {
      s+=(k-j)>j?(j*2):((k-j)*2);
    }
  }
  std::cout<<s;
  return 0;
}
  
    


Compiler output:
a.cc:4:5: error: cannot declare '::main' to be a global variable
    4 | int main{
      |     ^~~~
a.cc:5:3: error: expected primary-expression before 'int'
    5 |   int n,k;
      |   ^~~
a.cc:5:3: error: expected '}' before 'int'
a.cc:4:9: note: to match this '{'
    4 | int main{
      |         ^
a.cc:6:8: error: 'cin' in namespace 'std' does not name a type
    6 |   std::cin>>n>>k;
      |        ^~~
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:3: error: expected unqualified-id before 'for'
   11 |   for(i=0;i<n;i++)
      |   ^~~
a.cc:11:11: error: 'i' does not name a type
   11 |   for(i=0;i<n;i++)
      |           ^
a.cc:11:15: error: 'i' does not name a type
   11 |   for(i=0;i<n;i++)
      |               ^
a.cc:24:8: error: 'cout' in namespace 'std' does not name a type
   24 |   std::cout<<s;
      |        ^~~~
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:25:3: error: expected unqualified-id before 'return'
   25 |   return 0;
      |   ^~~~~~
a.cc:26:1: error: expected declaration before '}' token
   26 | }
      | ^
Language: C++

#include<iostream>
//#include<vector>
using namespace std;
int main{
  int n,k;
  std::cin>>n>>k;
  //vector<int>b;
  int j;
  int s=0;
  for(int i=0;i<n;i++)
  {
    std::cin>>j;
    //b.push_back(j);
    if(j>=k)
    {
      s+=(j-k)*2;
    }
    else
    {
      s+=(k-j)>j?(j*2):((k-j)*2);
    }
  }
  std::cout<<s;
  return 0;
}
  
    

Compiler output:
a.cc:4:5: error: cannot declare '::main' to be a global variable
    4 | int main{
      |     ^~~~
a.cc:5:3: error: expected primary-expression before 'int'
    5 |   int n,k;
      |   ^~~
a.cc:5:3: error: expected '}' before 'int'
a.cc:4:9: note: to match this '{'
    4 | int main{
      |         ^
a.cc:6:8: error: 'cin' in namespace 'std' does not name a type
    6 |   std::cin>>n>>k;
      |        ^~~
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:10:3: error: expected unqualified-id before 'for'
   10 |   for(int i=0;i<n;i++)
      |   ^~~
a.cc:10:15: error: 'i' does not name a type
   10 |   for(int i=0;i<n;i++)
      |               ^
a.cc:10:19: error: 'i' does not name a type
   10 |   for(int i=0;i<n;i++)
      |                   ^
a.cc:23:8: error: 'cout' in namespace 'std' does not name a type
   23 |   std::cout<<s;
      |        ^~~~
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:24:3: error: expected unqualified-id before 'return'
   24 |   return 0;
      |   ^~~~~~
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^
Language: C++

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

int main() {

  int N, K, x, d;
  cin >> N >> K;
  d = 0;
  for (int i = 0; i < N; i++) {
    cin >> x;
    int tmp =min(x,K-x)
    d += tmp * 2;
  }
  cout << d << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: expected ',' or ';' before 'd'
   12 |     d += tmp * 2;
      |     ^
Language: C++

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

int main() {

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

}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   for(i=0; i<N; i++) cin >> x[i];
      |       ^
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   for(i=0; i<N; i++){
      |       ^
Language: C++

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

int x[110];
int main(void) {
  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++) {
	ans += 2 * min(x[i], k-x[i]);
  }
  cout << ans << endl;
  return 0;
}

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

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

int x[110];
int main(void) {
	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++) {
		ans += 2 * min(x[i], k-x[i]);
	}
	cout << ans << endl;
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K,x,ans;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    ans+=(x<abs(K-x)?x;abs(K-x));
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:23: error: expected ':' before ';' token
    7 |     ans+=(x<abs(K-x)?x;abs(K-x));
      |                       ^
      |                       :
a.cc:7:23: error: expected primary-expression before ';' token
a.cc:7:23: error: expected ')' before ';' token
    7 |     ans+=(x<abs(K-x)?x;abs(K-x));
      |          ~            ^
      |                       )
a.cc:7:32: error: expected ';' before ')' token
    7 |     ans+=(x<abs(K-x)?x;abs(K-x));
      |                                ^
      |                                ;
Language: C++

#include <iostream>
int main(){int n,k,a=0;x[100]={};
           std::cin>>n>>k;
           for(int i=0;i!=n;++i){
             std::cin>>x[i];
             a+=(x[i]<k-x[i]?2*x[i]:2*(k-x[i]));
           }
           std::cout<<a<<"\n";
          }
           

Compiler output:
a.cc: In function 'int main()':
a.cc:2:24: error: 'x' was not declared in this scope
    2 | int main(){int n,k,a=0;x[100]={};
      |                        ^
Language: C++

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

int main() {
	int num, K;
    cin >> num >> K;
    
    int ans = 0;
    for (int i = 0; i < num; i++){
    	int p;
        cin >> p;
        int a = K - 0;
        int b = K - p;
        
        if(a < 0) a = -a;
        if(b < 0) b = -b
        
        if(a < b) {
			ans += (a * 2);        	
        } else {
        	ans += (b * 2);
        }        
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: error: expected ';' before 'if'
   16 |         if(b < 0) b = -b
      |                         ^
      |                         ;
   17 | 
   18 |         if(a < b) {
      |         ~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
 
int main(){
    int n;
    int k;
    cin>>n>>k;
    vector<int> x(n);
    rep(i,n) cin>>x[i];
    int ans=0;
    rep(i,n){
        ans += min(x[i],k-x[i])
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:32: error: expected ';' before '}' token
   14 |         ans += min(x[i],k-x[i])
      |                                ^
      |                                ;
   15 |     }
      |     ~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: expected ';' before 'if'
    8 |         cin >> x
      |                 ^
      |                 ;
    9 |         if (x < K - x)
      |         ~~       
a.cc:11:9: error: 'else' without a previous 'if'
   11 |         else
      |         ^~~~
a.cc:12:29: error: expected ';' before '}' token
   12 |                 sum += K - x
      |                             ^
      |                             ;
   13 |     }
      |     ~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:14: error: 'i' was not declared in this scope
    7 |         for (i = 0 ; i < N ; i++){
      |              ^
a.cc:8:17: error: expected ';' before 'if'
    8 |         cin >> x
      |                 ^
      |                 ;
    9 |         if (x < K - x)
      |         ~~       
a.cc:11:9: error: 'else' without a previous 'if'
   11 |         else
      |         ^~~~
a.cc:12:29: error: expected ';' before '}' token
   12 |                 sum += K - x
      |                             ^
      |                             ;
   13 |     }
      |     ~
Language: C++

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

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

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

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

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

}


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

#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  int K;
  cin >> N >> K;
  
  int num;
  int num2;
  
  vector<int> x(N);
  
  int num3 = 0;
  
  for(int i = 0;i < N;++i){
    cin >> x[i];
  }
  
  for(int i = 0;i < N;++i){
    num = abs(X[i] - 0) * 2;
    num2 = abs(X[i] - K) * 2;
    if(num >= num2){
      num3 = num2 + num3;
    }
    else{
      num3 = num2 + num3;
    }
  }
  
  cout << num3 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:15: error: 'X' was not declared in this scope
   21 |     num = abs(X[i] - 0) * 2;
      |               ^
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;
 int A =0;
  cin >> N >> K ;
  rep(i, N) {
 int x;
 cin >> x;
 if(K-x>=x){
 A += x;
 }
 else {
  A+= K-x;
 }
cout  << A*2 << endl;
}

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

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

int main() {
  int N,K,s;
  cin >> N>>K;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:19: error: expected ';' before '}' token
   15 |       s += (K-x)*2
      |                   ^
      |                   ;
   16 |     }
      |     ~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: unable to find numeric literal operator 'operator""a'
   18 |   cout<<2a<<endl;
      |         ^~
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 a,x;
    a=0;
    cin>>x;
    if(x<K-x){
      a +=x;
    }
    else{
      a +=K-x;
    }
  }
  cout<<a<<endl;
}
        

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: expected primary-expression before '|' token
   11 |       sum+=|K-x[i]|;
      |            ^
a.cc:11:20: error: expected primary-expression before ';' token
   11 |       sum+=|K-x[i]|;
      |                    ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: expected primary-expression before '|' token
   11 |       sum+=|k-x[i]|;
      |            ^
a.cc:11:13: error: 'k' was not declared in this scope
   11 |       sum+=|k-x[i]|;
      |             ^
a.cc:11:20: error: expected primary-expression before ';' token
   11 |       sum+=|k-x[i]|;
      |                    ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:12: error: 'K' was not declared in this scope
    5 |    cin>>N>>K;
      |            ^
a.cc:6:12: error: expected ';' before '-' token
    6 |   for(int i-0;i<N;i++){
      |            ^
      |            ;
a.cc:6:18: error: expected ')' before ';' token
    6 |   for(int i-0;i<N;i++){
      |      ~           ^
      |                  )
a.cc:6:19: error: 'i' was not declared in this scope
    6 |   for(int i-0;i<N;i++){
      |                   ^
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 - k)^2 >= x^2){
    	sum += 2 * x;
    }else if(x >= k){
    	sum += 2 * (x - k);
    }else{
    	sum += 2 * (k - x);
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:19: error: expected ';' before '<' token
    7 |   for(int i = 0, i < n, i++){
      |                   ^~
      |                   ;
a.cc:7:20: error: expected primary-expression before '<' token
    7 |   for(int i = 0, i < n, i++){
      |                    ^
a.cc:7:28: error: expected ';' before ')' token
    7 |   for(int i = 0, i < n, i++){
      |                            ^
      |                            ;
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: 'n' was not declared in this scope
    6 |   cin >> n >> k;
      |          ^
a.cc:7:19: error: expected ';' before '<' token
    7 |   for(int i = 0, i < n, i++){
      |                   ^~
      |                   ;
a.cc:7:20: error: expected primary-expression before '<' token
    7 |   for(int i = 0, i < n, i++){
      |                    ^
a.cc:7:28: error: expected ';' before ')' token
    7 |   for(int i = 0, i < n, i++){
      |                            ^
      |                            ;
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:4:18: error: array must be initialized with a brace-enclosed initializer
    4 |   int N,K,x[100]=0,i,sum=0;
      |                  ^
Language: C++

#include<bits/stdc++>
using namespace std;
int main(){
  int N,K,x[100]=0,i,sum=0;
  cin>>N>>K;
  for(i=0;i<N;i++){
    cin>>x[i];
    if(K/2>x[i])
      sum+=x[i];
    else
      sum+=K-x[i];
  }
  cout<<sum<<endl;
}

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

int main() {
  int N, K, x;
  int sum;
  
  cin >> N >> K;
  
  rep(i, N){
    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:5:3: error: 'cin' was not declared in this scope
    5 |   cin >> N >> K;
      |   ^~~
a.cc:7:7: error: 'i' was not declared in this scope
    7 |   rep(i, N){
      |       ^
a.cc:7:3: error: 'rep' was not declared in this scope
    7 |   rep(i, N){
      |   ^~~
a.cc:16:3: error: 'cout' was not declared in this scope
   16 |   cout << sum << endl;
      |   ^~~~
a.cc:16:18: error: 'endl' was not declared in this scope
   16 |   cout << sum << endl;
      |                  ^~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; 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;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n.k;
  cin >> n >> k;
  int ans = 0;
  REP(i,n){
    int x;
    cin >> x;
    ans += min(x,k-x);
  }
  cout << ans*2 << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:8: error: expected initializer before '.' token
   13 |   int n.k;
      |        ^
a.cc:14:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   14 |   cin >> n >> k;
      |          ^
      |          yn
a.cc:14:15: error: 'k' was not declared in this scope
   14 |   cin >> n >> k;
      |               ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: expected ';' before '-' token
    8 |   for(int i-0;i<N;i++){
      |            ^
      |            ;
a.cc:8:18: error: expected ')' before ';' token
    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 nameprace std;

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

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'nameprace'
    2 | using nameprace std;
      |       ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> N >> K;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:12: error: expected ';' before '-' token
    8 |   for(int i-0;i<N;i++){
      |            ^
      |            ;
a.cc:8:18: error: expected ')' before ';' token
    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++){
      |                   ^
a.cc:16:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |   cout << sum;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

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

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

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