Language: C++

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

int main(){
    long long n, i, g1 = 0, b1 = 0, s1 = 0;
    float g[2] = {}, s[2] = {}, b[2] = {};
    float ab[3] = {}, ba[3] = {};
    cin >> n;
    cin >> g[0] >> g[1] >> s[0] >> s[1] >> b[0] >> b[1];
    ab[0] = g[1]/g[0]; ab[1] = s[1]/s[0]; ab[2] = b[1]/b[0];
    ba[0] = g[0]/g[1]; ab[1] = s[0]/s[1]; ab[2] = b[0]/b[1];
    if(ab[0] > ab[1] && ab[0] > ab[2]){
        if(ab[0] > 1){
            g1 = n/g[0];
            n %= g[0];
            if(ab[1] > ab[2] && ab[1] > 1){
                s1 = n/s[0];
                n %= s[0];
                if(ab[2] > 1){
                    b1 = n/b[0];
                    n %= b[0];
                }
            }else if(ab[2] > 1){
                b1 = n/b[0];
                n %= b[0];
                if(ab[1] > 1){
                    s1 = n/s[0];
                    n %= s[0];
                }
            }
        }
    }else if(ab[1] > ab[0] && ab[1] > ab[2]){
        if(ab[1] > 1){
            s1 = n/s[0];
            n %= s[0];
            if(ab[0] > ab[2] && ab[0] > 1){
                g1 = n/g[0];
                n %= g[0];
                if(ab[2] > 1){
                    b1 = n/b[0];
                    n %= b[0];
                }
            }else if(ab[2] > 1){
                b1 = n/b[0];
                n %= b[0];
                if(ab[0] > 1){
                    g1 = n/g[0];
                    n %= g[0];
                }
            }
        }
    }else{
        if(ab[2] > 1){
            b1 = n/b[0];
            n %= b[0];
            if(ab[0] > ab[1] && ab[0] > 1){
                g1 = n/g[0];
                n %= g[0];
                if(ab[1] > 1){
                    s1 = n/s[0];
                    n %= s[0];
                }
            }else if(ab[1] > 1){
                s1 = n/s[0];
                n %= s[0];
                if(ab[0] > 1){
                    g1 = n/g[0];
                    n %= g[0];
                }
            }
        }
    }
    n += g1*g[1] + s1*s[1] + b1*b[1];
    if(ba[0] > ba[1] && ba[0] > ba[2]){
        if(ba[0] > 1){
            g1 = n/g[1];
            n %= g[1];
            if(ba[1] > ba[2] && ba[1] > 1){
                s1 = n/s[1];
                n %= s[1];
                if(ba[2] > 1){
                    b1 = n/b[1];
                    n %= b[1];
                }
            }else if(ba[2] > 1){
                b1 = n/b[1];
                n %= b[1];
                if(ba[1] > 1){
                    s1 = n/s[1];
                    n %= s[1];
                }
            }
        }
    }else if(ba[1] > ba[0] && ba[1] > ba[2]){
        if(ba[1] > 1){
            s1 = n/s[1];
            n %= s[1];
            if(ba[0] > ba[2] && ba[0] > 1){
                g1 = n/g[1];
                n %= g[1];
                if(ba[2] > 1){
                    b1 = n/b[1];
                    n %= b[1];
                }
            }else if(ba[2] > 1){
                b1 = n/b[1];
                n %= b[1];
                if(ba[0] > 1){
                    g1 = n/g[1];
                    n %= g[1];
                }
            }
        }
    }else{
        if(ba[2] > 1){
            b1 = n/b[1];
            n %= b[1];
            if(ba[0] > ba[1] && ba[0] > 1){
                g1 = n/g[1];
                n %= g[1];
                if(ba[1] > 1){
                    s1 = n/s[1];
                    n %= s[1];
                }
            }else if(ba[1] > 1){
                s1 = n/s[1];
                n %= s[1];
                if(ba[0] > 1){
                    g1 = n/g[1];
                    n %= g[1];
                }
            }
        }
    }
    n += g1*g[0] + s1*s[0] + b1*b[0];
    cout << n;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:15: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   15 |             n %= g[0];
      |             ~~^~~~~~~
a.cc:15:15: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:18:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   18 |                 n %= s[0];
      |                 ~~^~~~~~~
a.cc:18:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:21:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   21 |                     n %= b[0];
      |                     ~~^~~~~~~
a.cc:21:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:25:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   25 |                 n %= b[0];
      |                 ~~^~~~~~~
a.cc:25:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:28:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   28 |                     n %= s[0];
      |                     ~~^~~~~~~
a.cc:28:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:35:15: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   35 |             n %= s[0];
      |             ~~^~~~~~~
a.cc:35:15: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:38:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   38 |                 n %= g[0];
      |                 ~~^~~~~~~
a.cc:38:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:41:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   41 |                     n %= b[0];
      |                     ~~^~~~~~~
a.cc:41:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:45:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   45 |                 n %= b[0];
      |                 ~~^~~~~~~
a.cc:45:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:48:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   48 |                     n %= g[0];
      |                     ~~^~~~~~~
a.cc:48:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:55:15: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   55 |             n %= b[0];
      |             ~~^~~~~~~
a.cc:55:15: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:58:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   58 |                 n %= g[0];
      |                 ~~^~~~~~~
a.cc:58:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:61:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   61 |                     n %= s[0];
      |                     ~~^~~~~~~
a.cc:61:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:65:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   65 |                 n %= s[0];
      |                 ~~^~~~~~~
a.cc:65:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:68:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   68 |                     n %= g[0];
      |                     ~~^~~~~~~
a.cc:68:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:77:15: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   77 |             n %= g[1];
      |             ~~^~~~~~~
a.cc:77:15: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:80:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   80 |                 n %= s[1];
      |                 ~~^~~~~~~
a.cc:80:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:83:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   83 |                     n %= b[1];
      |                     ~~^~~~~~~
a.cc:83:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:87:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   87 |                 n %= b[1];
      |                 ~~^~~~~~~
a.cc:87:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:90:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   90 |                     n %= s[1];
      |                     ~~^~~~~~~
a.cc:90:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:97:15: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
   97 |             n %= s[1];
      |             ~~^~~~~~~
a.cc:97:15: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:100:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  100 |                 n %= g[1];
      |                 ~~^~~~~~~
a.cc:100:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:103:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  103 |                     n %= b[1];
      |                     ~~^~~~~~~
a.cc:103:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:107:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  107 |                 n %= b[1];
      |                 ~~^~~~~~~
a.cc:107:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:110:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  110 |                     n %= g[1];
      |                     ~~^~~~~~~
a.cc:110:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:117:15: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  117 |             n %= b[1];
      |             ~~^~~~~~~
a.cc:117:15: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:120:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  120 |                 n %= g[1];
      |                 ~~^~~~~~~
a.cc:120:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:123:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  123 |                     n %= s[1];
      |                     ~~^~~~~~~
a.cc:123:23: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:127:19: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  127 |                 n %= s[1];
      |                 ~~^~~~~~~
a.cc:127:19: note:   in evaluation of 'operator%=(long long int, float)'
a.cc:130:23: error: invalid operands of types 'long long int' and 'float' to binary 'operator%'
  130 |                     n %= g[1];
      |                     ~~^~~~~~~
a.cc:130:23: note:   in evaluation of 'operator%=(long long int, float)'