func_code_string: #include <bits/stdc++.h>   struct book {     int t, w;     bool operator<(const book &b) const { return w < b.w; }   } ones[102], twos[102];   int main() {     int n;     scanf( %d , &n);     int nOnes = 0;     int tWidthOnes = 0;     int nTwos = 0;     int tWidthTwos = 0;     for (int i = 0; i < n; i++) {       int t, w;       scanf( %d %d , &t, &w);       if (t == 1) {         ones[nOnes].t = t;         ones[nOnes++].w = w;         tWidthOnes += w;       } else {         twos[nTwos].t = t;         twos[nTwos++].w = w;         tWidthTwos += w;       }     }     std::sort(ones, ones + nOnes);     std::sort(twos, twos + nTwos);     int best = 1 << 30;     for (int i = 1; i <= 1 * nOnes + 2 * nTwos; i++) {       for (int j = 0; j <= i; j++) {         if (j <= nOnes && (i - j) <= nTwos) {           int botWidth = 1 * j + 2 * (i - j);           int topWidth = 0;           for (int k = 0; k < nOnes - j; k++) {             topWidth += ones[k].w;           }           for (int k = 0; k < nTwos - (i - j); k++) {             topWidth += twos[k].w;           }           if (topWidth <= botWidth) {             if (botWidth < best) best = botWidth;           }         }       }     }     printf( %d n , best);   }   