fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. const ll MOD = 1e9 + 7;
  6.  
  7. int n;
  8. ll ans = 0;
  9. int main() {
  10. ios_base::sync_with_stdio(0); cin.tie(0);
  11. freopen("MAGICSUM.inp", "r", stdin);
  12. freopen("MAGICSUM.out", "w", stdout);
  13. int n; cin >> n;
  14. for(int i = 1, x, y; i <= n; i++){
  15. cin >> x >> y;
  16. ans += (y * (y + 1)) / 2;
  17. ans -= (x * (x - 1)) / 2;
  18. }
  19. cout << ans << endl;
  20. }
  21.  
Success #stdin #stdout 0.01s 5348KB
stdin
Standard input is empty
stdout
Standard output is empty