Language: C

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


typedef long long llong ;
struct Data
{
	llong size ;
	llong value ;
} ;

#define N_MAX 500000
Data art[ N_MAX ] ;

int cmp( const void *a ,const void *b )
{
	if( (( Data* )a )->size == (( Data* )b )->size )
	{
		return (( Data* )b )->value - (( Data* )a )->value ;
	}
	
	return (( Data* )a )->size - (( Data* )b )->size ;
}

inline llong max( llong a ,llong b )
{
	return a > b ? a : b ;
}


int main( void )
{
	int N ;
	scanf( "%d" ,&N ) ;

	int i ;
	for( i = 0 ; i < N ; ++i )
	{
		scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
	}

	qsort( art ,N ,sizeof( Data ) ,cmp ) ;

	
	llong min_size	= art[ 0 ].size		;
	llong sum_value	= art[ 0 ].value	;

	llong ans = art[ 0 ].value ;
	for( i = 1 ; i < N ; ++i )
	{
		llong value	= art[ i ].value	;
		llong size	= art[ i ].size		;

		llong tmp =  sum_value + value  - ( size -  min_size ) ;
		if( tmp < value )
		{
			ans = max( ans ,value ) ;

			sum_value	= value	;
			min_size	= size	;
		}

		else
		{
			ans = max( ans ,tmp ) ;

			sum_value += value ;
		}
	}

	printf( "%lld\n" ,ans ) ;

	return 0 ;
}


Compiler output:
main.c:13:1: error: unknown type name 'Data'; use 'struct' keyword to refer to the type
   13 | Data art[ N_MAX ] ;
      | ^~~~
      | struct 
main.c: In function 'cmp':
main.c:17:16: error: 'Data' undeclared (first use in this function)
   17 |         if( (( Data* )a )->size == (( Data* )b )->size )
      |                ^~~~
main.c:17:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:17:22: error: expected expression before ')' token
   17 |         if( (( Data* )a )->size == (( Data* )b )->size )
      |                      ^
main.c:17:45: error: expected expression before ')' token
   17 |         if( (( Data* )a )->size == (( Data* )b )->size )
      |                                             ^
main.c:19:33: error: expected expression before ')' token
   19 |                 return (( Data* )b )->value - (( Data* )a )->value ;
      |                                 ^
main.c:19:56: error: expected expression before ')' token
   19 |                 return (( Data* )b )->value - (( Data* )a )->value ;
      |                                                        ^
main.c:22:25: error: expected expression before ')' token
   22 |         return (( Data* )a )->size - (( Data* )b )->size ;
      |                         ^
main.c:22:47: error: expected expression before ')' token
   22 |         return (( Data* )a )->size - (( Data* )b )->size ;
      |                                               ^
main.c: In function 'main':
main.c:39:46: error: request for member 'size' in something not a structure or union
   39 |                 scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
      |                                              ^
main.c:39:62: error: request for member 'value' in something not a structure or union
   39 |                 scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
      |                                                              ^
main.c:42:32: error: 'Data' undeclared (first use in this function)
   42 |         qsort( art ,N ,sizeof( Data ) ,cmp ) ;
      |                                ^~~~
main.c:45:35: error: request for member 'size' in something not a structure or union
   45 |         llong min_size  = art[ 0 ].size         ;
      |                                   ^
main.c:46:35: error: request for member 'value' in something not a structure or union
   46 |         llong sum_value = art[ 0 ].value        ;
      |                                   ^
main.c:48:29: error: request for member 'value' in something not a structure or union
   48 |         llong ans = art[ 0 ].value ;
      |                             ^
main.c:51:43: error: request for member 'value' in something not a structure or union
   51 |                 llong value     = art[ i ].value        ;
      |                                           ^
main.c:52:43: error: request for member 'size' in something not a structure or union
   52 |                 llong size      = art[ i ].size         ;
      |                                           ^