Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
#define all(vec) vec.begin(), vec.end()
#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rep2(i,a,b) for(int i = a; i >= b; i--)
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int>> vvi;
const int INF = 1e9;
const long LINF = 4e18;
// const long MOD = 1e9+7; // 998244353 
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
// long inv[1000003], fac[1000003], ifac[1000003];
// inv[1] = fac[0] = ifac[0] = 1;
// rep(i, 2, 1000000) inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
// rep(i, 1, 1000000) fac[i] = (i*fac[i-1])%MOD, ifac[i] = (inv[i]*ifac[i-1])%MOD;

// long C(int n, int k) { return (k > n)? 0 : ((fac[n]*ifac[n-k])%MOD)*ifac[k]%MOD; }


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int r, f;
	cin >> r >> f;
	int x = f/r;
	int rem = f - x*r;
	// cout << x << " " << rem << "\n";
	if(rem > r-rem) x++;
	if(x&1) cout << "down\n";
	else cout << "up\n";
}





Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
#define all(vec) vec.begin(), vec.end()
#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rep2(i,a,b) for(int i = a; i >= b; i--)
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int>> vvi;
const int INF = 1e9;
const long LINF = 4e18;
// const long P1 = 1+7*17*(1<<23), P2 = 1+7*(1<<26); // PRIME FOR FFT
// const long MOD = 1e9+7; // 998244353 
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
// long inv[1000003], fac[1000003], ifac[1000003];
// inv[1] = fac[0] = ifac[0] = 1;
// rep(i, 2, 1000000) inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
// rep(i, 1, 1000000) fac[i] = (i*fac[i-1])%MOD, ifac[i] = (inv[i]*ifac[i-1])%MOD;

// long C(int n, int k) { return (k > n)? 0 : ((fac[n]*ifac[n-k])%MOD)*ifac[k]%MOD; }


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int t; cin >> t;
	while(t--)
	{
		int n, l, r; cin >> n >> l >> r;
		vector<int> L, R, C;
		rep(i, 1, l-1)
		{
			int x; cin >> x;
			L.push_back(x);
		}
		rep(i, l, r)
		{
			int x; cin >> x;
			C.push_back(x);
		}
		rep(i, r+1, n)
		{
			int x; cin >> x;
			R.push_back(x);
		}
		sort(L.begin(), L.end());
		sort(R.begin(), R.end());
		sort(C.begin(), C.end());
		reverse(C.begin(), C.end());

		long res = LINF, sum = 0, dif = 0;
		for(int x : C) sum += x;
		res = sum;
		for(int i = 0; i < min(C.size(), L.size()); i++)
		{
			dif += -C[i]+L[i];
			res = min(res,sum+dif);
		}
		for(int i = 0; i < min(C.size(), R.size()); i++)
		{
			dif += -C[i]+R[i];
			res = min(res,sum+dif);
		}
		cout << res << "\n";
	}
	
}