malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   char st[100005];   int vis[100005];   int main() {     long l, cnt = 0;     scanf( %ld , &l);     scanf( %s , st);     if (l > 26) {       cout << -1;       return 0;     }     for (long i = 0; i < l + 10; i++) vis[i] = 0;     for (long i = 0; i < l; i++) {       if (vis[i] == 0) {         vis[i] = 1;         for (long j = i + 1; j < l; j++) {           if (st[i] == st[j] && vis[j] == 0) {             cnt++;             vis[j] = 1;           }         }       }     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<pair<int, int>, int> cntmp;   int n;   struct Point {     int x, y;   } pt[200005];   bool cpx(const Point &a, const Point &b) {     if (a.x != b.x) {       return a.x < b.x;     }     return a.y < b.y;   }   bool cpy(const Point &a, const Point &b) {     if (a.y != b.y) {       return a.y < b.y;     }     return a.x < b.x;   }   long long dcs(long long sx, long long mx) {     return (sx + mx) * (mx - sx + 1) / 2;   }   int main() {     scanf(  %d , &n);     cntmp.clear();     for (int i = 1; i <= n; i++) {       scanf(  %d %d , &pt[i].x, &pt[i].y);       cntmp[make_pair(pt[i].x, pt[i].y)]++;     }     sort(pt + 1, pt + 1 + n, cpx);     long long res = 0;     for (int i = 1; i <= n; i++) {       int j = i;       long long cnt = 0;       while (pt[j].x == pt[i].x && j <= n) {         cnt++;         j++;       }       j--;       if (cnt > 1) {         res += dcs(1, cnt - 1);       }       i = j;     }     sort(pt + 1, pt + 1 + n, cpy);     for (int i = 1; i <= n; i++) {       int j = i;       long long cnt = 0;       while (pt[j].y == pt[i].y && j <= n) {         cnt++;         j++;       }       j--;       if (cnt > 1) {         res += dcs(1, cnt - 1);       }       i = j;     }     for (map<pair<int, int>, int>::iterator it = cntmp.begin(); it != cntmp.end();          it++) {       if (it->second > 1) {         res -= dcs(1, it->second - 1);       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   const int N = 1e6 + 10;   const int M = 9699690;   const int mod = 1e9 + 7, Gi = 332748118;   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3fll;   const int SIZE = 1 << 21;   char ibuf[SIZE], *iS, *iT;   using std::pair;   template <class T>   void read(T &x) {     x = 0;     int f = 0;     char c = getchar();     while (!isdigit(c)) f |= c ==  - , c = getchar();     while (isdigit(c)) x = x * 10 + c -  0 , c = getchar();     if (f) x = -x;   }   int random(int i) { return rand() % i + 1; }   template <class T>   void ckmax(T &x, T y) {     x = x > y ? x : y;   }   template <class T>   void ckmin(T &x, T y) {     x = x < y ? x : y;   }   template <class T>   T Abs(T x) {     return x > 0 ? x : -x;   }   inline int plus(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }   int qp(int d, int k) {     int f = 1;     while (k) {       if (k & 1) f = (1ll * (f) * (d) % mod);       d = (1ll * (d) * (d) % mod), k >>= 1;     }     return f;   }   int n, m, a[N], b[N], tmp[N];   pair<int, int> p[N];   long long ans;   void msort(int l, int r) {     if (l == r) return;     int mid = l + r >> 1;     msort(l, mid), msort(mid + 1, r);     int lp = l, rp = mid + 1, ct = 0;     while (lp <= mid && rp <= r) {       if (a[lp] <= a[rp])         tmp[++ct] = a[lp++], ans += rp - 1 - mid;       else         tmp[++ct] = a[rp++];     }     while (lp <= mid) tmp[++ct] = a[lp++], ans += rp - 1 - mid;     while (rp <= r) tmp[++ct] = a[rp++];     for (int i = (l); i <= (r); i++) a[i] = tmp[i + 1 - l];   }   int tag[N << 2], mi[N << 2];   void build(int id, int l, int r) {     tag[id] = 0;     if (l == r) {       mi[id] = l - 1;       return;     }     int mid = l + r >> 1;     build(id << 1, l, mid), build(id << 1 | 1, mid + 1, r);     mi[id] = std::min(mi[id << 1], mi[id << 1 | 1]);   }   void pushdown(int id) {     if (tag[id]) {       tag[id << 1] += tag[id];       tag[id << 1 | 1] += tag[id];       mi[id << 1] += tag[id];       mi[id << 1 | 1] += tag[id];       tag[id] = 0;     }   }   void upt(int id, int L, int R, int l, int r, int d) {     if (l <= L && R <= r) {       tag[id] += d;       mi[id] += d;       return;     }     if (l > R || r < L) return;     int Mid = L + R >> 1;     pushdown(id);     upt(id << 1, L, Mid, l, r, d);     upt(id << 1 | 1, Mid + 1, R, l, r, d);     mi[id] = std::min(mi[id << 1], mi[id << 1 | 1]);   }   void work() {     read(n), read(m);     for (int i = (1); i <= (n); i++) read(a[i]), p[i] = std::make_pair(a[i], i);     ans = 0;     msort(1, n);     for (int i = (1); i <= (m); i++) read(b[i]);     std::sort(p + 1, p + 1 + n);     std::sort(b + 1, b + 1 + m);     build(1, 1, n + 1);     int ld = 1, lu = 1;     for (int i = (1); i <= (m); i++) {       while (ld <= n && p[ld].first <= b[i])         upt(1, 1, n + 1, p[ld++].second + 1, n + 1, -1);       while (lu <= n && p[lu].first < b[i])         upt(1, 1, n + 1, 1, p[lu++].second, 1);       ans += mi[1];     }     printf( %lld n , ans);   }   int main() {     int T = 1;     read(T);     while (T--) work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, s, e, t, r;     cin >> n >> m;     vector<pair<int, int> > sections(n + 1);     for (int i = 1; i <= n; i++) sections[i].first = 0x3f3f3f3f;     while (m--) {       cin >> s >> e >> t >> r;       for (int i = s; i <= e; i++) {         if (t < sections[i].first) {           sections[i].first = t;           sections[i].second = r;         }       }     }     int ans = 0;     for (int i = 1; i <= n; i++) {       ans += sections[i].second;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   struct item {     long long val;     int ind;     bool operator<(const item& o) const { return val < o.val; }   };   long long n, m, k, s;   vector<long long> dollar, pound, dday, pday;   vector<item> ditems, pitems;   void readIt() {     cin >> n >> m >> k >> s;     long long minn = 1e7;     long long v, mday = 0;     dollar.push_back(1e16);     pound.push_back(1e16);     pday.push_back(-1);     dday.push_back(-1);     for (int i = 1; i <= n; ++i) {       cin >> v;       if (minn > v) {         minn = v;         mday = i;       }       dollar.push_back(minn);       dday.push_back(mday);     }     minn = 1e7;     mday = 0;     for (int i = 1; i <= n; ++i) {       cin >> v;       if (minn > v) {         mday = i;         minn = v;       }       pound.push_back(minn);       pday.push_back(mday);     }     int type;     for (int i = 0; i < m; ++i) {       cin >> type >> v;       if (type == 1) ditems.push_back({v, i + 1});       if (type == 2) pitems.push_back({v, i + 1});     }     sort(ditems.begin(), ditems.end());     sort(pitems.begin(), pitems.end());   }   bool isPossible(int days, bool verbose) {     long long d = dollar[days];     long long p = pound[days];     int dit = 0, pit = 0;     long long total = 0;     for (int i = 0; i < k; ++i) {       if (dit == ditems.size()) {         if (verbose) cout << pitems[pit].ind <<     << pday[days] <<   n ;         total += pitems[pit++].val * p;         continue;       } else if (pit == pitems.size()) {         if (verbose) cout << ditems[dit].ind <<     << dday[days] <<   n ;         total += ditems[dit++].val * d;         continue;       }       if (ditems[dit].val * d < pitems[pit].val * p) {         if (verbose) cout << ditems[dit].ind <<     << dday[days] <<   n ;         total += ditems[dit++].val * d;       } else {         if (verbose) cout << pitems[pit].ind <<     << pday[days] <<   n ;         total += pitems[pit++].val * p;       }     }     if (total <= s) return true;     return false;   }   int getDay() {     int l = 0, r = n;     while (l < r) {       int m = (l + r + 1) / 2;       if (isPossible(m, false)) {         r = m - 1;       } else {         l = m;       }     }     if (l == n) return -1;     return l + 1;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     readIt();     int day = getDay();     if (day == -1) {       cout << -1 << endl;     } else {       cout << day <<   n ;       isPossible(day, true);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 255;   int parent[N];   int ra[N];   void make_set(int v) {     parent[v] = v;     ra[v] = 0;   }   int find_set(int v) {     if (v == parent[v]) return v;     return parent[v] = find_set(parent[v]);   }   void union_sets(int a, int b) {     a = find_set(a);     b = find_set(b);     if (a != b) {       if (ra[a] < ra[b]) swap(a, b);       parent[b] = a;       if (ra[a] == ra[b]) ++ra[a];     }   }   string s[N];   int main() {     cout.sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> s[i];     }     for (int i = 0; i < n; i++) make_set(i);     for (int j = 0; j < m; j++) make_set(100 + j);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (s[i][j] ==  # ) {           union_sets(i, 100 + j);         }       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (s[i][j] ==  #  && find_set(i) != find_set(100 + j)) {           cout <<  No ;           return 0;         }         if (s[i][j] !=  #  && find_set(i) == find_set(100 + j)) {           cout <<  No ;           return 0;         }       }     }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9;   const int mod = inf + 7;   const double eps = 1e-9;   const double pi = acos(-1.0);   int n, a[300300];   int dp[33][300300];   int calc(int bon, int ind) {     if (ind == n) return 0;     int &res = dp[bon][ind];     if (res != -1) return res;     res = a[ind] + calc(min(bon + a[ind] / 10, 31), ind + 1);     for (int i = 1; i <= bon && i <= a[ind]; i++) {       res = min(res, a[ind] - i + calc(bon - i, ind + 1));     }     return res;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , a + i);       a[i] /= 100;     }     memset(dp, -1, sizeof dp);     printf( %d n , calc(0, 0) * 100);     return 0;   }
#include <bits/stdc++.h>   int n, sum;   int a[16];   int b[4][4];   int cmp(const void *a, const void *b) { return *((int *)a) - *((int *)b); }   int dfs(int x, int y, int z) {     int p, q, i, j;     if (x == n && y == 0) return 1;     p = x;     q = y + 1;     if (q == n) {       p = x + 1;       q = 0;     }     for (i = 0; i < n * n; i++) {       if ((z >> i) & 1) continue;       if (x == n - 1) {         int s = 0;         for (j = 0; j < n - 1; j++) s += b[j][y];         if (s + a[i] != sum) continue;       }       if (y == n - 1) {         int s = 0;         for (j = 0; j < n - 1; j++) s += b[x][j];         if (s + a[i] != sum) continue;       }       if (x == n - 1 && y == 0) {         int s = 0;         for (j = 0; j < n - 1; j++) s += b[j][n - j - 1];         if (s + a[i] != sum) continue;       }       if (x == n - 1 && y == n - 1) {         int s = 0;         for (j = 0; j < n - 1; j++) s += b[j][j];         if (s + a[i] != sum) continue;       }       b[x][y] = a[i];       if (dfs(p, q, z | (1 << i)) == 1) return 1;       for (j = i + 1; j < n * n; j++) {         if (a[i] != a[j]) break;       }       i = j - 1;     }     return -1;   }   int main() {     int i, j;     scanf( %d , &n);     for (i = 0; i < n * n; i++) {       scanf( %d , &a[i]);       sum += a[i];     }     sum /= n;     printf( %d n , sum);     qsort(a, n * n, sizeof(int), cmp);     dfs(0, 0, 0);     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++) {         if (j > 0) putchar(   );         printf( %d , b[i][j]);       }       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFF = 1e18;   const double pi = acos(-1.0);   const double inf = 1e18;   const double eps = 1e-9;   const long long mod = 1e9 + 7;   const int maxmat = 10;   const unsigned long long BASE = 133333331;   inline void RI(int &x) {     char c;     while ((c = getchar()) <  0  || c >  9 )       ;     x = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) x = (x << 3) + (x << 1) + c -  0 ;   }   const int dy[3] = {-1, 0, 1};   char maze[3][105];   bool vis[3][105][105];   int sx, sy;   int N, k;   struct Node {     int x, y, t;   };   bool valid(int x, int y, int t) {     return (x >= 0 && x < 3 && y >= 0 && y < N &&             (maze[x][y + 2 * t] ==  .  || maze[x][y + 2 * t] == 0));   }   bool bfs(int x, int y) {     queue<Node> q;     q.push((Node){x, y, 0});     while (!q.empty()) {       Node tmp = q.front();       q.pop();       if (tmp.y == N - 1) return true;       if (maze[tmp.x][tmp.y + 1 + 2 * tmp.t] >=  A  &&           maze[tmp.x][tmp.y + 1 + 2 * tmp.t] <=  Z )         continue;       for (int k = 0; k < 3; k++) {         int tmpx = tmp.x + dy[k];         int tmpy = tmp.y + 1;         if (valid(tmpx, tmpy, tmp.t) && valid(tmpx, tmpy, tmp.t + 1) &&             !vis[tmpx][tmpy][tmp.t + 1]) {           vis[tmpx][tmpy][tmp.t + 1] = true;           q.push((Node){tmpx, tmpy, tmp.t + 1});         }       }     }     return false;   }   int main(int argc, char const *argv[]) {     int T;     cin >> T;     while (T--) {       scanf( %d%d , &N, &k);       memset(maze, 0, sizeof(maze));       memset(vis, false, sizeof(vis));       for (int i = 0; i < 3; i++) {         char s[105];         scanf( %s , s);         for (int j = 0; j < N; j++) {           maze[i][j] = s[j];           if (maze[i][j] ==  s ) sx = i, sy = j;         }       }       cout << (bfs(sx, sy) ?  YES  :  NO ) << endl;     }     return 0;   }
# include<bits/stdc++.h>   using namespace std;      int main()   {     int a,b,c=0;set<int>s;     cin>>a>>b;        while(a)     {       c++;       s.insert(a%b);       a/=b;     }     if(c==s.size())       cout<< YES <<endl;       else       cout<< NO <<endl;        return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double E = 2.71828182845904523536;   const long double pi = acos(-1);   const double eps = 1e-9;   const long long mod = 1e9 + 7;   const long long inf = 1LL << 30;   const int N = 500500;   vector<int> adj[N];   vector<int> v;   int dep[N];   void DFS(int u, int p) {     dep[u] = 1 + dep[p];     for (auto v : adj[u])       if (v != p) DFS(v, u);     if (adj[u].size() == 1) v.push_back(dep[u]);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d%d , &u, &v);       adj[u].push_back(v);       adj[v].push_back(u);     }     dep[1] = 0;     int ans = 0;     for (auto u : adj[1]) {       v.clear();       DFS(u, 1);       sort(v.begin(), v.end());       for (int i = 1; i < v.size(); i++)         if (v[i] <= v[i - 1]) v[i] = v[i - 1] + 1;       ans = max(ans, v.back());     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int c[500005], n, nm[500005], g[321];   vector<int> v[55];   char s[500005], p[500005];   inline int qr() {     int x = 0, w = 1;     char a = 0;     while (a <  0  || a >  9 ) {       if (a ==  - ) w = -1;       a = getchar();     }     while (a <=  9  && a >=  0 ) {       x = (x << 3) + (x << 1) + (a ^ 48);       a = getchar();     }     return x * w;   }   inline int lowbit(int x) { return x & -x; }   void add(int x, int d) {     while (x <= n) {       c[x] += d;       x += lowbit(x);     }   }   long long qu(int x) {     long long ans = 0;     while (x) {       ans += c[x];       x -= lowbit(x);     }     return ans;   }   int main() {     n = qr();     cin >> s + 1;     for (register int i = 1; i <= n; i++) p[i] = s[n - i + 1];     for (register int i = 1; i <= n; i++) v[p[i] -  a  + 1].push_back(i);     for (register int i = 1; i <= n; i++) {       int ch = s[i] -  a  + 1;       nm[i] = v[ch][g[ch]];       ++g[ch];     }     long long ans = 0;     for (register int i = 1; i <= n; i++) {       add(nm[i], 1);       ans += qu(n) - qu(nm[i]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   const int maxn = 500;   int v[maxn + 5];   long long vv[maxn + 5];   int ans[maxn + 5];   int r[maxn + 5];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &v[i]);     scanf( %d , &k);     for (int i = 0; i < k; i++) scanf( %I64d , &vv[i]);     memset(ans, -1, sizeof ans);     bool ok = true;     long long sum = 0;     int vvi = 0;     for (int i = 0; i < n; i++) {       sum += v[i];       if (sum == vv[vvi]) {         sum = 0;         r[vvi] = i;         vvi++;       } else if (sum > vv[vvi]) {         ok = false;         break;       }     }     ok = ok && (vvi == k);     if (!ok) {       printf( NO n );       return 0;     }     vvi = 0;     int prev = -1;     int maxval = -1;     for (int i = 0; i < n; i++) {       if (i > r[vvi]) {         if (r[vvi] - prev == 1) {           ans[vvi] = r[vvi];         }         if (ans[vvi] == -1) {           ok = false;           break;         }         prev = r[vvi];         maxval = -1;         vvi++;       }       if (i - 1 > prev && v[i] > v[i - 1] && v[i] > maxval) {         maxval = v[i];         ans[vvi] = i;       }       if (i + 1 <= r[vvi] && v[i] > v[i + 1] && v[i] > maxval) {         maxval = v[i];         ans[vvi] = i;       }     }     if (ans[vvi] == -1) {       if (r[vvi] - prev == 1) {         ans[vvi] = r[vvi];       } else {         ok = false;       }     }     ok = ok && (vvi == k - 1);     if (!ok) {       printf( NO n );       return 0;     }     printf( YES n );     prev = -1;     for (int i = 0; i < k; i++) {       int idx = ans[i];       int pidx = ans[i] - prev + i;       if (idx - 1 > prev && v[idx] > v[idx - 1]) {         for (int j = 0; j < ans[i] - prev - 1; j++) {           printf( %d L n , pidx--);         }         for (int j = 0; j < r[i] - ans[i]; j++) {           printf( %d R n , i + 1);         }       } else {         for (int j = 0; j < r[i] - ans[i]; j++) {           printf( %d R n , pidx);         }         for (int j = 0; j < ans[i] - prev - 1; j++) {           printf( %d L n , pidx--);         }       }       prev = r[i];     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   typedef long long int ll;   void solve(void);   int main(){   int t;   cin>>t;   while(t--){    solve();   }         return 0;}   void solve(){   ll n,i;   cin>>n;   ll a[n+1];   for(i=1;i<=n;i++)   {cin>>a[i];      }   cout<<3*n<<endl;   for(i=1;i<n;i++)   {      cout<< 1 <<   <<i<<   <<i+1<<endl;       cout<< 2 <<   <<i<<   <<i+1<<endl;       cout<< 1 <<   <<i<<   <<i+1<<endl;       cout<< 2 <<   <<i<<   <<i+1<<endl;       cout<< 1 <<   <<i<<   <<i+1<<endl;   cout<< 2 <<   <<i<<   <<i+1<<endl;   i++;      }      }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   enum { MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009 };   int a[200000];   long long ft[200000];   int t[800000];   int n;   void inc(int index, int val) {     while (index < n) {       ft[index] += val;       index |= index + 1;     }   }   long long sum(int r) {     long long ret = 0;     for (; r >= 0; r &= r + 1, --r) {       ret += ft[r];     }     return ret;   }   long long sum(int l, int r) { return sum(r) - (l ? sum(l - 1) : 0); }   void build(int x = 0, int L = 0, int R = n - 1) {     if (L == R) {       t[x] = a[L];       return;     }     int M = (L + R) / 2;     build(2 * x + 1, L, M);     build(2 * x + 2, M + 1, R);     t[x] = max(t[2 * x + 1], t[2 * x + 2]);   }   void upd(int index, int val, int x = 0, int L = 0, int R = n - 1) {     if (L == R) {       t[x] = val;       return;     }     int M = (L + R) / 2;     if (index <= M) {       upd(index, val, 2 * x + 1, L, M);     } else {       upd(index, val, 2 * x + 2, M + 1, R);     }     t[x] = max(t[2 * x + 1], t[2 * x + 2]);   }   int get(long long val, int from, int x = 0, int L = 0, int R = n - 1) {     if (t[x] < val || R < from) {       return n;     } else if (L == R) {       return L;     }     int M = (L + R) / 2;     if (M < from) {       return get(val, from, 2 * x + 2, M + 1, R);     } else if (t[2 * x + 1] >= val) {       int s = get(val, from, 2 * x + 1, L, M);       if (s < n) {         return s;       }     }     return get(val, from, 2 * x + 2, M + 1, R);   }   int get_ans() {     long long cur = 0;     int index = 0;     if (a[0] == 0) {       return 1;     }     while (index < n) {       cur += a[index];       index = get(cur, index + 1);       cur = sum(index - 1);       if (a[index] == cur) {         break;       }     }     return index >= n ? -1 : index + 1;   }   int main() {     int q;     cin >> n >> q;     for (int i = 0; i < n; ++i) {       cin >> a[i];       inc(i, a[i]);     }     build();     while (q--) {       int p, x;       cin >> p >> x;       --p;       inc(p, x - a[p]);       a[p] = x;       upd(p, x);       cout << get_ans() <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, min, max;     std::cin >> n >> m >> min >> max;     int a[m];     int maxHit = 0;     int minHit = 0;     for (int i = 0; i < m; ++i) {       std::cin >> a[i];       if (a[i] == min) {         minHit = 1;       } else if (a[i] == max) {         maxHit = 1;       }       if (a[i] > max || a[i] < min) {         std::cout <<  Incorrect ;         return 0;       }     }     if (minHit != 1 && maxHit != 1) {       if (n - m < 2) {         std::cout <<  Incorrect ;       } else {         std::cout <<  Correct ;       }     } else if (minHit != 1 || maxHit != 1) {       if (n - m < 1) {         std::cout <<  Incorrect ;       } else {         std::cout <<  Correct ;       }     } else {       std::cout <<  Correct ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   double dp[5010], f[5010];   int main() {     int T, i, j, k, ca = 0, n, m;     while (~scanf( %d%d , &n, &T)) {       for (i = 0; i <= T; i++) dp[i] = 0;       dp[0] = 1;       double ans = 0;       for (i = 0; i < n; i++) {         int p1, t;         scanf( %d%d , &p1, &t);         double p = 1. * p1 / 100, q = 1;         for (j = 1; j < t; j++) q *= (1 - p);         f[0] = dp[0];         for (j = 1; j <= T; j++) f[j] = f[j - 1] * (1 - p) + dp[j];         for (j = T; j >= 1; j--) {           double c = 0;           if (j >= t) c = f[j - t];           dp[j] = (f[j - 1] - c * q) * p;           if (j >= t) dp[j] += q * dp[j - t];         }         dp[0] = 0;         for (j = 1; j <= T; j++) ans += dp[j];       }       printf( %lf n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     cin >> a >> b;     int x = abs(a - b);     if (x % 2 == 0) {       x /= 2;       cout << x * (x + 1) << endl;     } else {       x /= 2;       cout << x * (x + 1) + x + 1 << endl;     }   }