Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)

int A[3],B[3];
float kati[3];

bool cmp(int i , int j){
    return kati[i] < kati[j];
}



signed main(){
    int n;
    cin >> n;
    REP(i,3) cin >> A[i];
    REP(i,3) cin >> B[i];
    REP(i,3) kati[i] = B[i] / A[i];
    int hairetu[3] = {0,1,2};
    sort(hairetu,hairetu + 3,cmp);


    int tugin = 0;
    if(kati[hairetu[2]] >1){
    tugin = A[hairetu[2]]* int(n /A[hairetu[2]]) * B[hairetu[2]];
    n = n % A[hairetu[2]];
    int kosu = 0;
    int tmp = 0;
    if(kati[hairetu[1]] > 1){
    while(1){
        if( n < kosu * A[hairetu[2]] ) break;
        int tmpkosu = 0;
        int tmpma = 0;
        while(1){
            if( n < kosu * A[hairetu[2]] + tmpkosu * A[hairetu[1]]) break;
            tmpma = max(tmpma,tmpkosu * B[hairetu[1]] + int((n - kosu * A[hairetu[2]] - tmpkosu * A[hairetu[1]])/A[hairetu[0]]) * B[hairetu[0]]     );
            tmpkosu ++;
        }
        tmp = max(tmp,tmpma + kosu * B[hairetu[2]]); 

        kosu ++;
    }
    n = tmp + tugin;
    }
    }



    int c[3];
    REP(i,3) c[i] = A[i];
    REP(i,3) A[i] = B[i];
    REP(i,3) B[i] = c[i];
    REP(i,3) kati[i] = B[i] / A[i];
    sort(hairetu,hairetu + 3,cmp);
    if(kati[hairetu[1]] > 1){
    while(1){
        if( n < kosu * A[hairetu[2]] ) break;
        int tmpkosu = 0;
        int tmpma = 0;
        while(1){
            if( n < kosu * A[hairetu[2]] + tmpkosu * A[hairetu[1]]) break;
            tmpma = max(tmpma,tmpkosu * B[hairetu[1]] + int((n - kosu * A[hairetu[2]] - tmpkosu * A[hairetu[1]])/A[hairetu[0]]) * B[hairetu[0]]     );
            tmpkosu ++;
        }
        tmp = max(tmp,tmpma + kosu * B[hairetu[2]]); 

        kosu ++;
    }
    n = tmp + tugin;
    }

    cout << n << endl;
    

}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:17: error: 'kosu' was not declared in this scope
   78 |         if( n < kosu * A[hairetu[2]] ) break;
      |                 ^~~~
a.cc:82:21: error: 'kosu' was not declared in this scope
   82 |             if( n < kosu * A[hairetu[2]] + tmpkosu * A[hairetu[1]]) break;
      |                     ^~~~
a.cc:83:66: error: 'kosu' was not declared in this scope
   83 |             tmpma = max(tmpma,tmpkosu * B[hairetu[1]] + int((n - kosu * A[hairetu[2]] - tmpkosu * A[hairetu[1]])/A[hairetu[0]]) * B[hairetu[0]]     );
      |                                                                  ^~~~
a.cc:86:9: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   86 |         tmp = max(tmp,tmpma + kosu * B[hairetu[2]]);
      |         ^~~
      |         tm
a.cc:86:31: error: 'kosu' was not declared in this scope
   86 |         tmp = max(tmp,tmpma + kosu * B[hairetu[2]]);
      |                               ^~~~
a.cc:90:9: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   90 |     n = tmp + tugin;
      |         ^~~
      |         tm