Language: C++

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define rep(i,n) for(auto i=0;i<n;++i)
#define repr(i,n) for(auto i=n;i>=0;--i)
#define repi(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define repir(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define for(i,a,b) for(auto i=a;i<b;++i)
#define sort(v,n) sort(v, v+n)
#define sortv(v) sort(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define inf 999999999
#define mod 1000000007
#define pb push_back
#define pf push_front
#define mp make_pair
#define sv(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, x;
  scanf("%d %d", &n, &x);

  vector<int> a(n);
  rep(i,n){
    scanf("%d", &a[i]);
  }

  sort(all(a));

  int ans = 0;
  rep(i,n){
    if(i == n - 1){
      if(x == a[i]) ans++;
      break;
    }

    if(x >= a[i]){
      x -= a[i];
      ans++;
    }else{
      break;
    }
  }

  printf("%d\n", ans);
  return 0;
}



Compiler output:
a.cc:46:10: error: macro "for" requires 3 arguments, but only 1 given
   46 |   rep(i,n){
      |          ^
a.cc:20:9: note: macro "for" defined here
   20 | #define for(i,a,b) for(auto i=a;i<b;++i)
      |         ^~~
a.cc:50:14: error: macro "sort" requires 2 arguments, but only 1 given
   50 |   sort(all(a));
      |              ^
a.cc:21:9: note: macro "sort" defined here
   21 | #define sort(v,n) sort(v, v+n)
      |         ^~~~
a.cc:53:10: error: macro "for" requires 3 arguments, but only 1 given
   53 |   rep(i,n){
      |          ^
a.cc:20:9: note: macro "for" defined here
   20 | #define for(i,a,b) for(auto i=a;i<b;++i)
      |         ^~~
a.cc: In function 'int main()':
a.cc:46:11: error: expected '(' before '{' token
   46 |   rep(i,n){
      |           ^
      |           (
a.cc:46:11: error: expected primary-expression before '{' token
a.cc:50:3: error: cannot resolve overloaded function 'sort' based on conversion to type 'bool'
   50 |   sort(all(a));
      |   ^~~~
a.cc:52:3: error: expected primary-expression before 'int'
   52 |   int ans = 0;
      |   ^~~
a.cc:50:16: error: expected ')' before 'int'
   50 |   sort(all(a));
      |                ^
      |                )
   51 | 
   52 |   int ans = 0;
      |   ~~~           
a.cc:46:11: note: to match this '('
   46 |   rep(i,n){
      |           ^
a.cc:53:11: error: expected '(' before '{' token
   53 |   rep(i,n){
      |           ^
      |           (
a.cc:53:11: error: expected primary-expression before '{' token
a.cc:67:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   67 |   printf("%d\n", ans);
      |                  ^~~
      |                  abs
a.cc:68:3: error: expected primary-expression before 'return'
   68 |   return 0;
      |   ^~~~~~
a.cc:67:23: error: expected ')' before 'return'
   67 |   printf("%d\n", ans);
      |                       ^
      |                       )
   68 |   return 0;
      |   ~~~~~~               
a.cc:53:11: note: to match this '('
   53 |   rep(i,n){
      |           ^