malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 5005;   short dp[N][N];   int ans[N];   int main() {     string s;     cin >> s;     int n;     n = s.size();     for (int len = 1; len <= n; len++) {       for (int l = 0; l < n - len + 1; l++) {         int r = l + len;         if (len == 1) {           dp[l][r] = 1;           continue;         } else if (len == 2) {           dp[l][r] = (s[l] == s[r - 1] ? 2 : 0);           continue;         }         if (s[l] != s[r - 1] || !dp[l + 1][r - 1]) {           continue;         }         dp[l][r] = 1;         int m = (l + r) >> 1;         if (len & 1) {           if (dp[l][m] && dp[m + 1][r]) {             dp[l][r] = dp[l][m] + 1;           }         } else {           if (dp[l][m] && dp[m][r]) {             dp[l][r] = dp[l][m] + 1;           }         }       }     }     for (int len = 1; len <= n; len++) {       for (int l = 0; l < n - len + 1; l++) {         ans[dp[l][l + len]]++;       }     }     for (int i = n - 1; i >= 1; i--) {       ans[i] += ans[i + 1];     }     for (int i = 1; i <= n; i++) {       cout << ans[i] <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fastpower(long a, long b, long long n = 1000000007) {     long res = 1;     while (b > 0) {       if ((b & 1) != 0) {         res = (res % n * a % n) % n;       }       a = (a % n * a % n) % n;       b = b >> 1;     }     return res;   }   bool isPrime(long long n) {     if (n <= 3) return n > 1;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i += 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   long long gcd(long long a, long long b) {     long long c = a % b;     while (c != 0) {       a = b;       b = c;       c = a % b;     }     return b;   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     long long t = 1;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long count = 1, i = 0;       while (count <= n) {         i++;         count = i * i;         if (count == n) {           i--;           break;         } else if (count > n) {           i--;           break;         }       }       count = i * i;       long long x = 1, y = i + 1;       for (long long j = count + 1; j <= (i + 1) * (i + 1); j++) {         if (j == n) {           cout << x <<     << y <<   n ;           break;         } else {           if (x >= i + 1) y--;           if (x < i + 1) x++;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool compare(pair<pair<long long int, long long int>, long long int> p1,                pair<pair<long long int, long long int>, long long int> p2) {     return p1.first.first < p2.first.first;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long int i, te, j, x, n, m, k, t, y, a, b, r;     te = 1;     while (te--) {       string s;       cin >> s;       n = s.length();       long long int a[n], c[n], ans = 0, cnt = 0, co = 0;       for (i = 0; i < n; i++) {         if (s[i] ==  o ) co++;         c[i] = co;       }       for (i = n - 1; i >= 0; i--) {         if (s[i] ==  o ) {           ans += cnt;         }         if (s[i] ==  v  && s[i - 1] ==  v  && i >= 1) {           cnt++;         }         a[i] = ans;       }       cnt = 0;       for (i = 0; i <= n - 1; i++) {         if (s[i] ==  v  && s[i + 1] ==  v ) {           cnt += a[i];         }       }       cout << cnt <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       long long l = 0, r = n + 1;       while (r - l > 1) {         long long k = (l + r) >> 1;         if ((long long)(n - k) * (n - k - 1) >= 2LL * k)           l = k;         else           r = k;       }       long long ans = 2 * l;       for (int i = l + 1;            i < n && (long long)i + (long long)(n - i) * (n - i - 1) / 2 > ans;            i++)         ans = (long long)i + (long long)(n - i) * (n - i - 1) / 2;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int countBits(long long mask) {     int res = 0;     while (mask) mask &= (mask - 1), ++res;     return res;   }   string toString(long long n) {     stringstream ss;     ss << n;     return ss.str();   }   long long toNumber(string s) {     stringstream ss;     long long n;     ss << s;     ss >> n;     return n;   }   int n, p[1001], dp[1001];   int main() {     while (cin >> n) {       for (int i = (int)(1), _m = (int)(n + 1); i < _m; ++i) cin >> p[i];       for (int i = (int)(1), _m = (int)(n + 1); i < _m; ++i) {         dp[i] = 1;         if (i != p[i])           for (int j = (int)(p[i]), _m = (int)(i); j < _m; ++j)             dp[i] = (dp[i] + dp[j] + 1) % 1000000007;       }       int res = 0;       for (int i = (int)(1), _m = (int)(n + 1); i < _m; ++i)         res = (res + dp[i] + 1) % 1000000007;       cout << res << endl;     }   }
#include <bits/stdc++.h>   const long long mod = 998244853;   long long C[5050][5050], n, m, g[5050], ans;   signed main() {     scanf( %lld%lld , &n, &m);     for (long long i = 0; i <= n + m; i++) {       C[i][0] = 1;       for (long long j = 1; j <= i; j++)         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;     }     for (long long i = 0; i <= n; i++)       if (i <= n - m)         g[i] = C[n + m][n];       else         g[i] = C[n + m][m + i];     for (long long i = 0; i <= n; i++)       (ans += i * ((g[i] - g[i + 1] + mod) % mod) % mod) %= mod;     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 2147383647;   const double pi = 2 * acos(0.0);   const double eps = 1e-9;   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<    ;       return *this;     }   } dbg;   inline long long gcd(long long a, long long b) {     a = ((a) < 0 ? -(a) : (a));     b = ((b) < 0 ? -(b) : (b));     while (b) {       a = a % b;       swap(a, b);     }     return a;   }   int ext_gcd(int a, int b, int& x, int& y) {     if (a == 0) {       x = 0;       y = 1;       return b;     }     int x1, y1;     int d = ext_gcd(b % a, a, x1, y1);     x = y1 - (b / a) * x1;     y = x1;     return d;   }   inline long long modInv(int a, int m) {     int x, y;     ext_gcd(a, m, x, y);     if (x < 0) x += m;     return x;   }   inline long long power(long long a, long long p) {     long long res = 1, x = a;     while (p) {       if (p & 1) res = (res * x);       x = (x * x);       p >>= 1;     }     return res;   }   inline long long bigmod(long long a, long long p, long long m) {     long long res = 1, x = a % m;     while (p) {       if (p & 1) res = (res * x) % m;       x = (x * x) % m;       p >>= 1;     }     return res;   }   char buf[60][30];   long long mask[1 << 20];   int m;   double q;   double memo[1 << 20];   int done[1 << 20];   double dp(int mk) {     int pop = 0;     if (mask[mk]) pop = __builtin_popcountll(mask[mk]);     int pop2 = __builtin_popcountll(mk);     if (pop <= 1) return 0;     if (done[mk]) return memo[mk];     double p = 1.0 / (m - pop2);     double res = 0;     for (int i = (0); i <= (m - 1); ++i) {       if (mk & (1 << i)) continue;       res += p * dp(mk | (1 << i));       long long x = mask[mk | (1 << i)];       x = x ^ mask[mk];       x = __builtin_popcountll(x);       res += p * x * q * (pop2 + 1);     }     done[mk] = 1;     return memo[mk] = res;   }   int main() {     int n;     scanf( %d , &n);     q = 1.0 / n;     for (int i = (0); i <= (n - 1); ++i) {       scanf( %s , &buf[i][0]);     }     m = strlen(&buf[0][0]);     for (int i = (0); i <= (n - 1); ++i) {       for (int j = (i + 1); j <= (n - 1); ++j) {         int tmask = 0;         for (int k = (0); k <= (m - 1); ++k) {           if (buf[i][k] == buf[j][k]) tmask |= (1LL << k);         }         mask[tmask] |= (1LL << i);         mask[tmask] |= (1LL << j);       }     }     int limit = 1 << m;     for (int i = (limit - 1); i >= (0); --i) {       for (int k = (0); k <= (m - 1); ++k) {         if (i & (1 << k)) {           mask[i ^ (1 << k)] |= mask[i];         }       }     }     double res = dp(0);     printf( %.10lf n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using vint = vector<int>;   using pint = pair<int, int>;   using vpint = vector<pint>;   template <typename A, typename B>   inline void chmin(A& a, B b) {     if (a > b) a = b;   }   template <typename A, typename B>   inline void chmax(A& a, B b) {     if (a < b) a = b;   }   template <class A, class B>   ostream& operator<<(ostream& ost, const pair<A, B>& p) {     ost <<  {  << p.first <<  ,  << p.second <<  } ;     return ost;   }   template <class T>   ostream& operator<<(ostream& ost, const vector<T>& v) {     ost <<  { ;     for (int i = 0; i < v.size(); i++) {       if (i) ost <<  , ;       ost << v[i];     }     ost <<  } ;     return ost;   }   inline int topbit(unsigned long long x) {     return x ? 63 - __builtin_clzll(x) : -1;   }   inline int popcount(unsigned long long x) { return __builtin_popcountll(x); }   inline int parity(unsigned long long x) { return __builtin_parity(x); }   const int INF = 1001001001;   const int X = 30000;   int N, D;   int cnt[33333];   const int B = 300;   int dp[X + 1][B];   map<int, int> dp2[X + 1];   signed main() {     cin >> N >> D;     for (int i = 0; i < (N); i++) {       int p;       cin >> p;       cnt[p]++;     }     fill_n(*dp, (X + 1) * B, -INF);     if (D >= B) {       dp2[D][D] = 0;     } else {       dp[D][D] = 0;     }     int ans = 0;     for (int i = D; i <= X; i++) {       for (int j = 1; j < B; j++) {         if (dp[i][j] == -INF) continue;         dp[i][j] += cnt[i];         chmax(ans, dp[i][j]);         for (int k = -1; k <= 1; k++) {           int d = j + k;           if (d <= 0 || i + d > X) continue;           if (d < B)             chmax(dp[i + d][d], dp[i][j]);           else             chmax(dp2[i + d][d], dp[i][j]);         }       }       for (auto& p : dp2[i]) {         p.second += cnt[i];         int j = p.first;         chmax(ans, p.second);         for (int k = -1; k <= 1; k++) {           int d = j + k;           if (d <= 0 || i + d > X) continue;           if (d < B)             chmax(dp[i + d][d], p.second);           else             chmax(dp2[i + d][d], p.second);         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cout << x; }   void __print(long x) { cout << x; }   void __print(long long x) { cout << x; }   void __print(unsigned x) { cout << x; }   void __print(unsigned long x) { cout << x; }   void __print(unsigned long long x) { cout << x; }   void __print(float x) { cout << x; }   void __print(double x) { cout << x; }   void __print(long double x) { cout << x; }   void __print(char x) { cout <<      << x <<     ; }   void __print(const char *x) { cout <<     << x <<    ; }   void __print(const string &x) { cout <<     << x <<    ; }   void __print(bool x) { cout << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cout <<  { ;     __print(x.first);     cout <<  , ;     __print(x.second);     cout <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cout <<  { ;     for (auto &i : x) cout << (f++ ?  ,  :   ), __print(i);     cout <<  } ;   }   void _print() { cout <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cout <<  ,  ;     _print(v...);   }   const int N = 3e6 + 1;   bool prime[N];   int Div[N], num[N];   void sieve(int n) {     vector<int> is_prime(n + 1, 1);     for (int i = 2; i * i <= n; i++)       if (is_prime[i])         for (int j = i + i; j <= n; j += i) is_prime[j] = 0;     int cnt = 1;     for (int i = 2; i <= n; i++)       if (is_prime[i]) prime[i] = 1, num[i] = cnt++;   }   void Divisors() {     for (int i = 1; i < N; i++) {       for (int j = i + i; j < N; j += i) {         Div[j] = i;       }     }   }   void solve() {     int n;     cin >> n;     vector<int> a(2 * n), ans;     map<int, int> m;     for (int i = 0; i <= 2 * n - 1; i++) cin >> a[i], m[a[i]]++;     sort(a.rbegin(), a.rend());     for (int i = 0; i <= 2 * n - 1; i++) {       if (m[a[i]]) {         int x = a[i];         if (prime[x]) {           int y = num[x];           m[x]--, m[y]--;           ans.push_back(y);         } else {           m[a[i]]--, m[Div[x]]--;           ans.push_back(x);         }       }     }     for (auto i : ans) cout << i <<    ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     sieve(N);     Divisors();     int T = 1;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   void exgcd(long long a, long long b, long long& x, long long& y) {     if (b == 0) {       x = 1;       y = 0;       return;     }     exgcd(b, a % b, x, y);     long long p = x - a / b * y;     x = y;     y = p;   }   long long dv(long long a, long long b) {     if (b == 0) return 8e18;     long long u = a / b - 2;     while ((u + 1) * b <= a) ++u;     return u;   }   long long wo(long long p, long long q, long long k, long long b) {     if (k < p) return -1;     k -= p;     long long ua = min(p, k);     if (b <= ua)       ;     else       return -1;     if (n < 900000) {       for (int w = n; w >= 0; --w) {         long long u = w + n, t = (k - ua) / u - 2;         while (u * t < k - ua || t < 0) ++t;         while (u * t <= k - b) {           long long A = k - u * t, B = w - A;           if (b <= A && A <= ua)             ;           else             throw  GG ;           if (0 <= B && B <= q) return w;           ++t;         }       }       return -1;     }     long long aa = -1;     for (long long t = 0; n * t <= k; ++t) {       long long A = t + 1, B = t, C = k - n * t;       if (C == 0) {         if (b <= 0) {           if (t == 0)             aa = max(aa, q);           else             aa = max(aa, 0LL);         }         continue;       }       long long a0, b0;       exgcd(A, B, a0, b0);       a0 *= C;       b0 *= C;       if (B == 0) {         if (b <= a0 && a0 <= p)           ;         else           continue;       }       long long k = min(dv(a0 - b, B), dv(q - b0, A));       if (a0 - k * B <= ua && b0 + k * A >= 0)         ;       else         continue;       aa = max(aa, a0 + b0 + k);     }     return aa;   }   int main() {     long long l, r, k;     cin >> n >> l >> r >> k;     long long g = r - l + 1;     if (g <= 0) g += n;     long long ans = -1;     ans = max(ans, wo(g, n - g, k, 0));     ans = max(ans, wo(g, n - g, k + 1, 1));     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int tt;     cin >> tt;     while (tt--) {       int n;       cin >> n;       cout << (1ll * ((n - 1) / 2) * (((n - 1) / 2) + 1) *                (2 * ((n - 1) / 2) + 1) * 8) /                   6            <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000;   int from[MAXN + 5];   void Gauss(int n, int d, double a[][MAXN + 5], double *Ans) {     for (int i = 1; i <= n; i++) from[i] = i;     for (int i = 1; i <= n; i++) {       if (!a[i][i])         for (int j = i + 1; j <= min(n, i + d); j++)           if (a[i][j]) {             for (int k = max(1, i - d); k <= min(n, i + d); k++)               swap(a[k][i], a[k][j]);             swap(from[i], from[j]);             break;           }       for (int j = i + 1; j <= min(n, i + 2 * d); j++) {         double div = a[j][i] / a[i][i];         for (int k = i; k <= min(n, i + d); k++) a[j][k] -= a[i][k] * div;         a[j][n + 1] -= a[i][n + 1] * div;       }     }     for (int i = n; i >= 1; i--) {       Ans[from[i]] = a[i][n + 1];       for (int j = i + 1; j <= min(i + d, n); j++)         Ans[from[i]] -= Ans[from[j]] * a[i][j];       Ans[from[i]] /= a[i][i];     }   }   int n, m, x, y;   double a[MAXN + 5][MAXN + 5], Ans[MAXN + 5][MAXN + 5];   int main() {     scanf( %d %d %d %d , &n, &m, &x, &y);     if (m == 1) {       printf( %.4f n , 2.0 * (n - x));       return 0;     }     for (int i = n - 1; i >= 1; i--) {       a[1][1] = 2.0 / 3;       a[1][2] = -1.0 / 3;       a[1][m + 1] = 1.0 / 3 * Ans[i + 1][1] + 1;       for (int j = 2; j <= m - 1; j++) {         a[j][j - 1] = -1.0 / 4;         a[j][j] = 3.0 / 4;         a[j][j + 1] = -1.0 / 4;         a[j][m + 1] = 1.0 / 4 * Ans[i + 1][j] + 1;       }       a[m][m - 1] = -1.0 / 3;       a[m][m] = 2.0 / 3;       a[m][m + 1] = 1.0 / 3 * Ans[i + 1][m] + 1;       Gauss(m, 1, a, Ans[i]);     }     printf( %.4f n , Ans[x][y]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void winter_is_coming() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);   }   double k, arr[10001];   int n;   double check(double md, double k) {     double sum = 0;     for (int i = 0; i < n; i++)       if (arr[i] > md) {         double x = arr[i] - md;         sum += (x - (x * k / 100));       } else if (arr[i] < md) {         double x = md - arr[i];         sum -= x;       }     return sum;   }   int main() {     winter_is_coming();     int t = 100;     double mx = 0;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> arr[i], mx = max(mx, arr[i]);     double lo, hi, md, ans = 0;     lo = 0, hi = 1000;     while (t--) {       md = (lo + hi) / 2;       double z = check(md, k);       if (z >= 0) {         ans = md;         lo = md;       } else         hi = md;     }     cout << fixed << setprecision(9) << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b, c;     cin >> a >> b;     if (a.size() > b.size()) {       for (int i = b.size(); i < a.size(); i++) c +=  0 ;       b = c + b;     }     if (a.size() < b.size()) {       for (int i = a.size(); i < b.size(); i++) c +=  0 ;       a = c + a;     }     for (int i = 0; i < a.size(); i++) {       if (a[i] > b[i]) {         cout <<  >  << endl;         return 0;       } else if (a[i] < b[i]) {         cout <<  <  << endl;         return 0;       }     }     cout <<  =  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 65;   const int inf = 1e9;   int n, m, r;   int dp[maxn][maxn][maxn];   int a[maxn][maxn][maxn];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> r;     for (int i = 0; i < m; i++)       for (int j = 0; j < n; j++)         for (int k = 0; k < n; k++) cin >> a[i][j][k];     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++)         for (int k = 0; k < n; k++) dp[i][j][k] = inf;     for (int i = 0; i < m; i++)       for (int j = 0; j < n; j++)         for (int k = 0; k < n; k++)           for (int z = 0; z < n; z++) {             a[i][k][z] = min(a[i][j][z] + a[i][k][j], a[i][k][z]);             dp[0][k][z] = min(dp[0][k][z], a[i][k][z]);           }     for (int i = 1; i < n; i++) {       for (int j = 0; j < n; j++) {         for (int k = 0; k < n; k++) {           for (int z = 0; z < n; z++)             dp[i][k][z] = min(dp[i][k][z], dp[i - 1][k][j] + dp[0][j][z]);         }       }     }     for (int i = 0; i < r; i++) {       int s, t, k;       cin >> s >> t >> k;       s--, t--;       k = min(k, n - 2);       cout << dp[k][s][t] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx )   using namespace std;   const double eps = 0.000001;   const long double pi = acos(-1);   const int maxn = 1e7 + 9;   const int mod = 1e9 + 7;   const long long MOD = 1e18 + 9;   const long long INF = 1e18 + 123;   const int inf = 2e9 + 11;   const int mxn = 1e6 + 9;   const int N = 3e5 + 123;   const int PRI = 555557;   const int pri = 997;   int tests = 1;   int n, m, k;   int a[N];   int now[N];   string s;   long long cnt[N];   long long cur, res;   inline void Solve() {     cin >> n >> k;     long long ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = i + i; j <= n; j += i) {         cnt[j]++;         ans++;       }     }     for (int i = n; i > 0; i--) {       now[i] = 1;     }     for (int i = 1; i <= n; i++) {       long long cur = cnt[i];       for (int j = i + i; j <= n; j += i)         if (now[j]) cur++;       if (ans - cur >= k && cnt[i]) {         now[i] = 0;         ans -= cur;         for (int j = i + i; j <= n; j += i) cnt[j]--;       }     }     if (ans != k) {       cout <<  No ;       exit(0);     }     for (int i = 1; i <= n; i++) {       if (now[i]) {         res++;       }     }     cout <<  Yes n  << res <<   n ;     for (int i = 1; i <= n; i++)       if (now[i]) cout << i <<    ;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     while (tests--) {       Solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:64000000 )   using namespace std;   const double PI = 2 * acos(0.0);   const double eps = 1e-9;   template <class T>   T jog(T a, T b) {     return a + b;   }   template <class T>   T bog(T a, T b) {     return a - b;   }   template <class T>   T gon(T a, T b) {     return a * b;   }   template <class T>   T sq(T x) {     return x * x;   }   template <class T>   T gcd(T a, T b) {     return b == 0 ? a : gcd(b, a % b);   }   template <class T>   T lcm(T a, T b) {     return (a / gcd(a, b)) * b;   }   template <class T>   T power(T a, T p) {     T res = 1, x = a;     while (p) {       if (p & 1) res = res * x;       x = x * x;       p >>= 1;     }     return res;   }   template <class T>   T cordinatlenth(T a, T b, T c, T d) {     return sqrt(sq(a - c) + sq(b - d));   }   template <class T>   string toString(T n) {     ostringstream oss;     oss << n;     oss.flush();     return oss.str();   }   int toInt(string s) {     int r = 0;     istringstream sin(s);     sin >> r;     return r;   }   long long bigmod(long long a, long long p, long long mod) {     long long res = 1, x = a;     while (p) {       if (p & 1) res = (res * x) % mod;       x = (x * x) % mod;       p >>= 1;     }     return res;   }   int diraction1[] = {-1, 0, 0, 1, 1, -1, -1, 1};   int diraction2[] = {0, -1, 1, 0, 1, -1, 1, -1};   int horsed1[] = {-2, -2, -1, 1, 2, 2, 1, -1};   int horsed2[] = {1, -1, -2, -2, -1, 1, 2, 2};   void Input();   const int INF = 2147483647;   const long long LINF = 9223372036854775807ll;   bool isok(long long x);   int n, in[100010], tmp[100010];   int main() {     Input();     return 0;   }   void Input() {     cin >> n;     long long sum = 0;     for (int i = 0; i < n; i++) cin >> in[i], sum += in[i];     long long ans = sum / (n - 1);     ans += (bool)(sum % (n - 1));     for (int i = 0; i < n; i++) ans = ans < in[i] ? in[i] : ans;     cout << ans << endl;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   #pragma warning(disable : 4996)   using namespace std;   const long long INF = 2147483647;   const double PI = acos(-1);   const int mod = 1e9 + 7;   bool vis[3][120000];   int main() {     long long n, q;     cin >> n >> q;     long long obstacles = 0;     for (int j = 1; j <= q; j++) {       long long x, y;       cin >> x >> y;       long long increment = vis[x][y] == 1 ? -1 : 1;       vis[x][y] = 1 - vis[x][y];       long long dx = x == 2 ? 1 : 2;       for (int i = -1; i <= 1; i++) {         if (vis[dx][y + i]) obstacles += increment;       }       if (obstacles)         cout <<  No  << endl;       else         cout <<  Yes  << endl;     }     return 0;   }