Language: C++

//  Suraj Saste
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}
 
int main()
{
	fast;
	ll n,w;cin>>n>>w;
	ll a[n+1][2];
	priority_queue<pi> q;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1];
		double d=a[i][1]*1.0/a[i][0];
		q.push(make_pair(d,i));
	}
	ll sum=0,ans=0;
	while(!q.empty())
	{
		auto x=q.top();q.pop();
		if(sum+a[x.se][0]>w)continue;
		sum+=a[x.se][0];
		ans+=a[x.se][1];
	}
	cout<<ans;
	return 0;
}
//  Suraj Saste

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}

int main()
{
	fast;
	ll n,w;cin>>n>>w;
	ll a[n+1][2];
	priority_queue<pi> q;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1];
		double d=a[i][1]*1.0/a[i][0];
		q.push(make_pair(d,i));
	}
	ll sum=0,ans=0;
	while(!q.empty())
	{
		auto x=q.top();q.pop();
		if(sum+a[x.se][0]>w)continue;
		sum+=a[x.se][0];
		ans+=a[x.se][1];
	}
	cout<<ans;
	return 0;
}
Submission Info

Compiler output:
a.cc:57:4: error: redefinition of 'long long int fpow(long long int, long long int, long long int)'
   57 | ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
      |    ^~~~
a.cc:16:4: note: 'long long int fpow(long long int, long long int, long long int)' previously defined here
   16 | ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
      |    ^~~~
a.cc:58:6: error: redefinition of 'bool isPrime(long long int)'
   58 | bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}
      |      ^~~~~~~
a.cc:17:6: note: 'bool isPrime(long long int)' previously defined here
   17 | bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}
      |      ^~~~~~~
a.cc:60:5: error: redefinition of 'int main()'
   60 | int main()
      |     ^~~~
a.cc:19:5: note: 'int main()' previously defined here
   19 | int main()
      |     ^~~~
a.cc:83:1: error: 'Submission' does not name a type
   83 | Submission Info
      | ^~~~~~~~~~