malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m;   char cmd[(100000 + 10)];   int vis[510][510], path[(100000 + 10)];   const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};   int convert(char ch) {     if (ch ==  R )       return 0;     else if (ch ==  L )       return 1;     else if (ch ==  D )       return 2;     else       return 3;   }   bool Inborder(int x, int y) {     if (x < 0 || x >= n || y < 0 || y >= m) return false;     return true;   }   int main() {     int x0, y0;     scanf( %d%d%d%d , &n, &m, &x0, &y0);     scanf( %s , cmd);     memset(vis, 0, sizeof(vis));     int cnt = 0, pos = 0, len = strlen(cmd), ans = n * m;     path[cnt++] = 1;     ans--;     int x = x0 - 1, y = y0 - 1;     vis[x][y] = 1;     while (pos < len - 1) {       int dir = convert(cmd[pos++]);       if (!Inborder(dx[dir] + x, dy[dir] + y)) {         path[cnt++] = 0;         continue;       }       x += dx[dir];       y += dy[dir];       if (vis[x][y]) {         path[cnt++] = 0;       } else {         ans--;         path[cnt++] = 1;         vis[x][y] = 1;       }     }     for (int i = 0; i < cnt; i++) {       printf( %d  , path[i]);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     scanf( %d , &q);     while (q--) {       int n;       scanf( %d , &n);       int cnt = 0;       int aa[1000];       for (int i = 1; i <= n; i++) {         scanf( %d , &aa[i]);       }       sort(aa + 1, aa + 1 + n);       int flag = 1;       for (int i = 2; i <= n; i++) {         if (aa[i] == aa[i - 1] + 1) {           flag = 0;         }       }       if (!flag)         printf( 2 n );       else         printf( 1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     long long x, y;   };   istream &operator>>(istream &in, point &p) {     in >> p.x >> p.y;     return in;   }   ostream &operator<<(ostream &out, point &p) {     out << p.x <<     << p.y;     return out;   }   double len(struct point a, struct point b) {     return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));   }   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     cout.tie(NULL);     long long r;     point a, b;     cin >> r;     cin >> a >> b;     cout << ceil(len(a, b) / (r * 2));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, long long> m;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     vector<pair<long long, long long> > v = {         make_pair(1989, 1998),           make_pair(1999, 2098),         make_pair(2099, 3098),           make_pair(3099, 13098),         make_pair(13099, 113098),        make_pair(113099, 1113098),         make_pair(1113099, 11113098),    make_pair(11113099, 111113098),         make_pair(111113099, 1111113098)};     for (int i = 1989; i <= 1998; i++) {       string s =   ;       long long temp = i;       s += (temp % 10 + 48);       m[s] = i;     }     for (int i = 1999; i <= 2098; i++) {       string s =   ;       long long temp = i;       for (int j = 0; j < 2; j++) {         s += (temp % 10 + 48);         temp /= 10;       }       reverse(s.begin(), s.end());       m[s] = i;     }     for (int i = 2099; i <= 3098; i++) {       string s =   ;       long long temp = i;       for (int j = 0; j < 3; j++) {         s += (temp % 10 + 48);         temp /= 10;       }       reverse(s.begin(), s.end());       m[s] = i;     }     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       string s;       cin >> s;       string work =   ;       int sz = s.size();       for (int j = 4; j < sz; j++) {         work += s[j];       }       sz = work.size();       if (sz <= 3) {         cout << m[work] <<   n ;       } else {         long long temp = v[sz - 1].first;         string s1 =   ;         while (temp) {           s1 += (temp % 10 + 48);           temp /= 10;         }         reverse(s1.begin(), s1.end());         if (work < s1) {           cout << 1 << work <<   n ;         } else {           cout << work <<   n ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, res;     scanf( %lld %lld , &n, &k);     if (k <= n) {       if (k % 2 == 0)         res = (k - 1) / 2;       else if (k % 2 == 1)         res = k / 2;     } else if (k > n) {       if (k - n <= n)         res = (n - (k - n) + 1) / 2;       else if (k - n > n)         res = 0;     } else if (n == k)       res = (n - 1) / 2;     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100005], p[100005];   long long cost;   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i] >> p[i];     }     int mn = p[0];     for (int i = 0; i < n; ++i) mn = min(p[i], mn), cost += mn * 1LL * a[i];     cout << cost << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 210;   int n, k, m;   long long a[N];   int b[N];   int f[N][6010];   int ans = 0;   int c[N], d[N];   int main() {     scanf( %d%d , &n, &m);     for (int i(1); i <= (n); ++i) scanf( %lld , a + i);     for (int i(1); i <= (n); ++i) {       for (; a[i] % 2 == 0; a[i] /= 2) ++d[i];       for (; a[i] % 5 == 0; a[i] /= 5) ++c[i];     }     for (int j(0); j <= (m); ++j)       for (int k(0); k <= (5200); ++k) f[j][k] = -(1 << 30);     f[0][0] = 0;     for (int i(1); i <= (n); ++i) {       for (int j(m); j >= (1); --j) {         for (int k(c[i]); k <= (5200); ++k)           f[j][k] = max(f[j][k], f[j - 1][k - c[i]] + d[i]);       }     }     for (int j(0); j <= (5200); ++j) ans = max(ans, min(f[m][j], j));     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, d, sum = 0, ans = 0;     cin >> n >> d;     string *s = new string[d];     for (int i = 0; i < d; i++) cin >> s[i];     for (int i = 0; i < d; i++) {       int flag = 0;       for (int k = 0; k < n; k++) {         if (s[i][k] ==  0 ) {           flag = 1;           break;         }       }       if (flag)         ans++;       else         ans = 0;       sum = max(sum, ans);     }     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1e5 + 5;   const long long mod = 1e9 + 7;   long long fact[MAXN];   long long invfact[MAXN];   bool sieve[MAXN];   long long powe(long long x, long long y, long long mod) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % mod;       y = y >> 1;       x = (x * x) % mod;     }     return res;   }   void makesieve() {     for (long long i = 0; i < MAXN; ++i) {       sieve[i] = 1;     }     sieve[0] = 0;     sieve[1] = 0;     for (long long i = 2; i * i <= MAXN; ++i) {       for (long long j = 2 * i; j < MAXN; j += i) {         sieve[j] = 0;       }     }   }   void pre() {     fact[0] = 1;     invfact[0] = 1;     for (long long i = 1; i < MAXN; ++i) {       fact[i] = (fact[i - 1] * i) % mod;       invfact[i] = powe(fact[i], mod - 2, mod);     }     makesieve();   }   long long comb(long long n, long long r) {     if (r == 0 || n == r) return 1;     if (r > n) return 0;     long long A = (fact[n] * invfact[r]) % mod;     return (A * invfact[n - r]) % mod;   }   long long gcde(long long a, long long b) {     if (a == 0) return b;     return gcde(b % a, a);   }   long long gcdExtended(long long a, long long b, long long *x, long long *y) {     if (a == 0) {       *x = 0, *y = 1;       return b;     }     long long x1, y1;     long long gcd = gcdExtended(b % a, a, &x1, &y1);     *x = y1 - (b / a) * x1;     *y = x1;     return gcd;   }   long long modInverse(long long a, long long m) {     long long x, y;     long long g = gcdExtended(a, m, &x, &y);     return (x % m + m) % m;   }   bool ifcontains(string str, string smlstr) {     if (str.length() < smlstr.length()) return false;     for (long long i = 0; i < str.length(); ++i) {       bool fg = 0;       for (long long j = 0; j < smlstr.length(); ++j) {         if (i + j >= str.length()) {           fg = 1;           break;         }         if (smlstr[j] != str[i + j]) {           fg = 1;           break;         }       }       if (!fg) return true;     }     return false;   }   int main() {     pre();     long long n, k;     cin >> n >> k;     long long ans = 0;     for (long long i = 0; i <= n; ++i) {       for (long long j = 0; j <= n; ++j) {         long long sign;         if ((i + j) % 2 == 0)           sign = 1;         else           sign = -1;         long long total_cells = (i + j) * n - i * j;         long long rest_cells = n * n - total_cells;         long long temp =             (powe(k - 1, total_cells, mod) * powe(k, rest_cells, mod)) % mod *             sign;         temp = (temp + mod) % mod;         temp *= (comb(n, i) * comb(n, j)) % mod;         temp %= mod;         ans += temp;         ans %= mod;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m;     cin >> n >> m;     int count = 0;     int a[n + 1][m + 1];     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) cin >> a[i][j];     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (a[1][j] == 1 || a[n][j] == 1) {           cout <<  2 ;           count++;           return;         }       }       if (a[i][1] == 1 || a[i][m] == 1) {         cout <<  2 ;         count++;         return;       }     }     if (count == 0) cout <<  4 ;   }   int main() {     ios_base::sync_with_stdio(false);     int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char mat[100][100];   int main(void) {     int minyX = (1 << 30), minyY = (1 << 30), maxyX = 0, maxyY = 0;     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %s , mat[i]);       for (int j = 0; j < m; ++j) {         if (mat[i][j] !=  * ) continue;         if (i < minyX) minyX = i;         if (i > maxyX) maxyX = i;         if (j < minyY) minyY = j;         if (j > maxyY) maxyY = j;       }     }     for (int row = minyX; row <= maxyX; ++row) {       for (int col = minyY; col <= maxyY; ++col) {         printf( %c , mat[row][col]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   char s[N];   int m, n;   void sol() {     int b[26] = {0};     scanf( %d %d , &n, &m);     int a[N] = {0};     scanf( %s , s);     int t;     for (int i = 0; i < m; i++) {       scanf( %d , &t);       a[t - 1]++;     }     a[n - 1] = 1;     for (int i = n - 1; i >= 0; i--) {       if (i < n - 1) a[i] += a[i + 1];       int num = s[i] -  a ;       b[num] += a[i];     }     for (int i = 0; i < 26; i++) {       if (i != 25)         printf( %d  , b[i]);       else         printf( %d n , b[i]);     }   }   int main() {     int T;     scanf( %d , &T);     while (T--) sol();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 201;   const int logn = 20;   struct matrix {     double a[maxn][maxn];     int n;     bool is_vec;     matrix() {}     void init(int n) {       this->n = n;       is_vec = 0;       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           a[i][j] = 0;         }       }     }     matrix operator*(const matrix &m2) const {       matrix ans;       ans.init(n);       if (is_vec) {         ans.is_vec = 1;         for (int j = 1; j <= n; j++) {           for (int k = 1; k <= n; k++) {             ans.a[1][j] += a[1][k] * m2.a[j][k];           }         }         return ans;       }       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           for (int k = 1; k <= n; k++) {             ans.a[i][j] += a[i][k] * m2.a[k][j];           }         }       }       return ans;     }   };   matrix A[logn];   int n;   int px[maxn], py[maxn];   vector<int> p[maxn][maxn];   int cnt[maxn];   bool vis[maxn][maxn];   void init();   double cal(int t, int m);   bool is_line(int a, int b, int c);   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &px[i], &py[i]);     }     init();     int q;     scanf( %d , &q);     while (q--) {       int t, m;       scanf( %d%d , &t, &m);       printf( %.7lf n , cal(t, m));     }     return 0;   }   double cal(int t, int m) {     m--;     matrix f;     f.init(n);     f.is_vec = 1;     f.a[1][t] = 1;     for (int i = 0; i < logn; i++) {       if ((m >> i) & 1) {         f = f * A[i];       }     }     double max_ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= cnt[i]; j++) {         double cur_ans = 0;         for (int u : p[i][j]) {           cur_ans += f.a[1][u];         }         cur_ans /= p[i][j].size();         max_ans = max(max_ans, cur_ans);       }     }     return max_ans;   }   void init() {     vector<int> cur;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i == j || vis[i][j]) continue;         cur.clear();         cur.push_back(i);         cur.push_back(j);         for (int k = 1; k <= n; k++) {           if (i == k || j == k || !is_line(i, j, k)) continue;           cur.push_back(k);         }         for (int a : cur) {           vis[i][a] = 1;         }         p[i][++cnt[i]] = cur;       }     }     A[0].init(n);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= cnt[i]; j++) {         for (int a : p[i][j]) {           A[0].a[i][a] += 1.0 / cnt[i] / p[i][j].size();         }       }     }     for (int i = 1; i < logn; i++) {       A[i] = A[i - 1] * A[i - 1];     }   }   bool is_line(int a, int b, int c) {     int x1 = px[b] - px[a];     int x2 = px[c] - px[a];     int y1 = py[b] - py[a];     int y2 = py[c] - py[a];     return (long long)x1 * y2 - (long long)x2 * y1 == 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a;   int gcd(int a, int b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       a.clear();       a.resize(n + 1);       bool can = true;       for (int i = 1; i <= n; i++) {         cin >> a[i];         if (a[i] % (i + 1) == 0) {           bool updated = false;           int max = (a[i] < i + 1) ? a[i] : i;           for (int j = 1; j + 1 <= max; j++) {             if (a[i] % (j + 1) != 0) {               updated = true;               break;             }           }           if (!updated) {             can = false;           }         }       }       if (can) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, c1, c2;   int dp[505][505], fact[1000005], inv[1000005];   int po(int a, int b) {     int c = 1, d = a;     while (b) {       if (b & 1) c = 1LL * c * d % 1000000007;       d = 1LL * d * d % 1000000007;       b >>= 1;     }     return c;   }   int ncr(int N, int R) {     if (R > N || R < 0) return 0;     int ret = fact[N];     ret = 1LL * ret * inv[R] % 1000000007;     ret = 1LL * ret * inv[N - R] % 1000000007;     return ret;   }   int f(int a, int b) {     if (a == 0) return dp[a][b] = fact[b];     if (dp[a][b] != -1) return dp[a][b];     dp[a][b] = 0;     for (int i = (0); i <= (b); i++)       dp[a][b] =           (dp[a][b] + 1LL * ncr(b, i) * fact[i] % 1000000007 * f(a - 1, b - i)) %           1000000007;     if (a > 1) {       for (int i = (0); i <= (b); i++)         dp[a][b] = (dp[a][b] + 1LL * ncr(b, i) * (a - 1) % 1000000007 *                                    fact[i + 1] % 1000000007 * f(a - 2, b - i)) %                    1000000007;     }     return dp[a][b];   }   void solve() {     memset(dp, -1, sizeof(dp));     printf( %d n , f(c1, c2));   }   int main() {     fact[0] = 1;     for (int i = (1); i <= (1000000); i++)       fact[i] = 1LL * fact[i - 1] * i % 1000000007;     for (int i = (0); i <= (1000000); i++) inv[i] = po(fact[i], 1000000007 - 2);     scanf( %d , &n);     for (int i = (1); i <= (n); i++) {       int x;       scanf( %d , &x);       if (x == 1)         c1++;       else         c2++;     }     solve();     return 0;   }
#include <bits/stdc++.h>   #define fi first   #define se second   #define mp make_pair   using namespace std;      typedef pair <int, int> pii;      struct UF {    int fa[3010];    void clear(int n) {     for (int i = 1; i <= n; i++) {      fa[i] = i;     }    }    int find(int x) {     if (fa[x] == x) return x;     return fa[x] = find(fa[x]);    }    void merge(int x, int y) {     x = find(x), y = find(y);     if (x == y) return ;     fa[y] = x;    }   }uf;      vector <int> ans;   vector <pii> all;   int G[3010][3010], in[3010], cnt[3010], nin[3010];   int n, m;      void dfs(int x) {    for (int i = 1; i <= n; i++) {     if (!G[x][i]) continue;     G[x][i] = G[i][x] = 0;     dfs(i);    }    ans.push_back(x);   }      void print() {    reverse(ans.begin(), ans.end());    printf( %d n , ans.size());    for (int i = 0; i < ans.size(); i++) {     printf( %d  , ans[i]);    }    printf(  n );   }      int main() {    scanf( %d%d , &n, &m);    for (int i = 0; i < m; i++) {     int x, y; scanf( %d%d , &x, &y);     G[x][y] = G[y][x] = 1, in[x]++, in[y]++;     all.push_back(mp(x, y));    }    int tot = 0;    for (int i = 1; i <= n; i++) {     tot += in[i] & 1;    }    if (tot <= 2) {     int rt = 1;     for (int i = 1; i <= n; i++) {      if (in[i] & 1) {       rt = i;       break;      }     }     dfs(rt);     print();     return 0;    }    for (int i = 1; i <= n; i++) {     if (in[i] % 2 == 0) continue;     for (int j = 1; j <= n; j++) {      if (G[i][j] || i == j) cnt[j]++;     }    }    for (int i = 1; i <= n; i++) {     if (cnt[i] < tot - 1) continue;     for (int j = 1; j <= n; j++) {      if (i == j) continue;      if (cnt[i] == tot - 1 && G[i][j]) continue;      if (in[j] % 2 == 0) continue;      uf.clear(n);      for (int i = 1; i <= n; i++) {       nin[i] = 0;      }      for (int k = 0; k < all.size(); k++) {       int x = all[k].fi, y = all[k].se;       if ((x == i || y == i) && x + y - i != j && in[x + y - i] & 1) continue;       uf.merge(x, y);       nin[x]++, nin[y]++;      }      int eq = -1;      for (int k = 1; k <= n; k++) {       if (!nin[k]) continue;       int val = uf.find(k);       if (eq == -1) eq = val;       if (eq != val) goto END;      }      for (int k = 1; k <= n; k++) {       if (k == i || k == j) continue;       if (in[k] & 1) {        G[i][k] = G[k][i] = 0;        ans.push_back(i);        ans.push_back(k);       }      }      ans.push_back(-1);      dfs(j);      print();      return 0;      END:;     }    }    printf( 0 n );    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int A = 1e6 + 5;   const int N = 5e4 + 5;   const int M = 5005;   int dp[A], a[N], l[M], r[M], b[N], ans[M];   int32_t main() {     for (int i = 1; i < A; i++) dp[i] = dp[i - 1] ^ i;     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 0; i < m; i++) scanf( %d%d , l + i, r + i);     for (int i = 1; i <= n; i++) {       b[i - 1] = 0;       for (int j = i; j <= n; j++)         b[j] = max(b[j - 1], a[i] < a[j] ? dp[a[j]] ^ dp[a[i] - 1]                                          : dp[a[i]] ^ dp[a[j] - 1]);       for (int j = 0; j < m; j++)         if (l[j] <= i) ((ans[j]) = max((ans[j]), (b[r[j]])));     }     for (int i = 0; i < m; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int x[n], y[n];     for (int i = 0; i < n; i++) cin >> x[i];     for (int i = 0; i < n; i++) cin >> y[i];     int de = 0, in = 0;     for (int i = 0; i < n; i++) {       if (x[i] > y[i]) de = de + x[i] - y[i];       if (y[i] > x[i]) in = in + y[i] - x[i];     }     if (de >= in)       cout <<  Yes ;     else       cout <<  No ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long cnt1, cnt2, x, y;     cin >> cnt1 >> cnt2 >> x >> y;     long long low = 1, high = 4000000000LL;     if (x == y) {       while (low < high) {         long long mid = low + (high - low) / 2;         if (mid - mid / x >= cnt1 + cnt2)           high = mid;         else           low = mid + 1;       }     } else {       while (low < high) {         long long mid = low + (high - low) / 2;         if (mid - mid / x >= cnt1 && mid - mid / y >= cnt2 &&             mid - mid / (x * y) >= cnt1 + cnt2)           high = mid;         else           low = mid + 1;       }     }     cout << low;   }
#include <bits/stdc++.h>   using namespace std;   map<pair<int, int>, pair<int, int> > tab;   int main() {     int n, v[3];     pair<int, int> ans;     int maior = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &v[0], &v[1], &v[2]);       sort(v, v + 3);       for (int j = 0; j < 3; j++)         for (int k = j + 1; k < 3; k++) {           pair<int, int> x = tab[make_pair(v[j], v[k])];           int ind = 3 - j - k;           int aux[3] = {v[0], v[1], v[2]};           aux[ind] += x.first;           sort(aux, aux + 3);           if (aux[0] > maior) {             maior = aux[0];             ans.first = i;             ans.second = x.second;           }         }       if (tab[make_pair(v[0], v[1])].first < v[2])         tab[make_pair(v[0], v[1])] = make_pair(v[2], i);       if (tab[make_pair(v[0], v[2])].first < v[1])         tab[make_pair(v[0], v[2])] = make_pair(v[1], i);       if (tab[make_pair(v[1], v[2])].first < v[0])         tab[make_pair(v[1], v[2])] = make_pair(v[0], i);     }     if (ans.first > ans.second) swap(ans.first, ans.second);     if (ans.first)       printf( 2 n%d %d n , ans.first, ans.second);     else       printf( 1 n%d n , ans.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   int a[N];   int main() {     int t;     cin >> t;     while (t--) {       int n, x;       cin >> n >> x;       int ok = 0;       for (int i = 1; i <= n; i++) {         cin >> a[i];         if (a[i] == x) {           ok = 1;         }       }       if (ok == 1) {         cout << 1 <<   n ;         continue;       }       sort(a + 1, a + 1 + n);       int b = a[n];       if (x < b) {         cout << 2 <<   n ;       } else if (x % b == 0) {         cout << x / b <<   n ;       } else {         cout << x / b + 1 <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c, i, j;     cin >> a >> b >> c;     long long s = min(a / 3, min(b / 2, c / 2));     a -= s * 3;     b -= s * 2;     c -= s * 2;     set<long long> sett;     for (i = 1; i <= 7; i++) {       long long cnt = 0;       long long x = a, y = b, z = c;       for (j = i; j < (i + 7); j++) {         if (j % 7 == 1 || j % 7 == 4 || j % 7 == 0) {           if (!x)             break;           else             x--;           cnt++;         } else if (j % 7 == 2 || j % 7 == 6) {           if (!y)             break;           else             y--;           cnt++;         } else if (j % 7 == 3 || j % 7 == 5) {           if (!z)             break;           else             z--;           cnt++;         }       }       sett.insert(cnt);     }     auto it = sett.end();     it--;     long long ans = *it + s * 7;     cout << ans << endl;   }