akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  string s;
  cin >> s;
  int res = 0;
  int ile = 0;
  s += 'X';
  R(i,SZ(s) - 1){
    if(s[i] == 'A'){
      ile ++;
    }else if(s[i] == 'B'){
      if(s[i + 1] == 'C'){
        res += ile;
        i++;
      }else{
        ile = 0;
      }
    }else{
      ile = 0;
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 720
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
  s = input()
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  else:
    re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))


Measured memory_bytes: 69880
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> v(m);
    for (int i = 0; i < m; ++i) {
        scanf("%d", &v[i]);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int e = c;
        for (int j = 0; j < m; ++j) {
            int x;
            cin >> x;
            e += v[j]*x;
        }
        if(e > 0) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012

int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll v[n+1];
    for(i=1;i<=n;i++){
        ll a;
        cin>>a;
        v[a]=i;
    }
    for(i=1;i<=n;i++){
        cout<<v[i];
        if(i!=n) cout<<" ";
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 1536
<?php
$str = trim(fgets(STDIN));

switch ($str) {
    case 'SUN':
        echo 7;
        break;
    case 'MON':
        echo 6;
        break;
    case 'TUE':
        echo 5;
        break;
    case 'WED':
        echo 4;
        break;
    case 'THU':
        echo 3;
        break;
    case 'FRI':
        echo 2;
        break;
    case 'SAT':
        echo 1;
        break;
}

Measured memory_bytes: 4732
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n,k;
  string s;

  cin >> n >> k;
  cin >> s;

  if(s[k-1] == 'A') s[k-1] = 'a';
  else if(s[k-1] == 'B') s[k-1] = 'b';
  else s[k-1] = 'c';

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int N, M, R;
int r[8];
int d[200][200];

int main() {
	cin >> N >> M >> R;
	REP(i, R) scanf("%d", r + i), r[i]--;
	
	fill(d[0], d[N], INF);
	REP(i, M) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		chmin(d[a][b], c);
		chmin(d[b][a], c);
	}
	REP(i, N) d[i][i] = 0;
	
	REP(k, N) REP(i, N) REP(j, N) chmin(d[i][j], d[i][k] + d[k][j]);
	
	int ans = INF;
	sort(r, r + R);
	
	do {
		int now = 0;
		REP(i, R - 1) now += d[r[i]][r[i + 1]];
		chmin(ans, now);
	} while (next_permutation(r, r + R));
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define MAX 100000
#define INF 1000000
#define M 1000000007
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std; 
int main(){
    fast_io 
    ll l,r,d;
    cin>>l>>r>>d;
    ll ans = 0;
    for(ll i = l;i<=r;i++){
        if(i%d == 0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  if (n == 1 && m == 1)
    cout << "1\n";
  else if (n == 1) 
    cout << max(0ll, m - 2) << '\n';
  else if (m == 1)
    cout << max(0ll, n - 2) << '\n';
  else {
    long long down = n * m - (2 * n + 2 * (m - 2));
    cout << down << '\n';
  }
  // borders have    
  return 0;
}

Measured memory_bytes: 3548
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

constexpr double EPS = 1e-9;

struct point {
	double x, y;
	explicit point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {}
	point(const point &p):x(p.x), y(p.y) {}

	point operator+(const point &p) const {
		return point(x + p.x, y + p.y);
	}

	point operator-(const point &p) const {
		return point(x - p.x, y - p.y);
	}

	point operator*(double s) const {
		return point(x * s, y * s);
	}
};

point rotate90(const point &p) {
	return point(-p.y, p.x);
}

point rotate(const point &p, double theta) {
	const double s = sin(theta), c = cos(theta);
	return point(c * p.x - s * p.y, s * p.x + c * p.y);
}

int sign(double d) {
	return d > EPS ? 1 : d < -EPS ? -1 : 0;
}

double spin_dist(double speed, double time) {
	return (M_PI / 180.0) * speed * time;
}

double calc_radius(double d, double small, double large) {
	const double as = abs(small);
	const double al = abs(large);

	if(as == al) {
		return d;
	}
	else if(sign(small) != sign(large)) {
		return 2 * d * al / (al + as);
	}
	else {
		return 2 * d * al / (al - as);
	}
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	for(int q, d; cin >> q >> d && q;) {
		point v(0, 1);
		point p(0, 0);

		while(q--) {
			int L, R, T;
			cin >> L >> R >> T;

			if(L == R) {
				p = p + v * spin_dist(L, T);
			}
			else if(abs(L) < abs(R)) {
				const double r = calc_radius(d, L, R);
				const double theta = spin_dist(R, T) / r;
				const point c = p + rotate90(v) * (r - d);
				p = rotate(p - c, theta) + c;
				v = rotate(v, theta);
			}
			else {
				const double r = calc_radius(d, R, L);
				const double theta = spin_dist(L, T) / r;
				const point c = p + rotate90(v) * (d - r);
				p = rotate(p - c, -theta) + c;
				v = rotate(v, -theta);
			}

		}

		cout << p.x << endl;
		cout << p.y << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int a, b;
    cin >> a >> b;
    int x = (b-a-1)*(b-a)/2 - a;
    cout << x << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main(void){
    ll n, r;
    cin >> n >> r;
    if(n >= 10)
        cout << r << endl;
    else if(n < 10)
        cout << r + 100*(10-n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N, A, B;
    cin >> N >> A >> B;

    vi vals(N), loc(N);
    for (int i = 0; i < N; i++) {
        cin >> vals[i];
        loc[vals[i] - 1] = i;
    }

    vvll dp(N + 1, vll(N + 1, LLONG_MAX));
    dp[0][0] = 0;

    auto put_min = [&](ll &a, ll b) {
        a = min(a, b);
    };

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            if (dp[i][j] == LLONG_MAX) continue;

            if (loc[i] < j) {
                put_min(dp[i+1][j], dp[i][j] + A);
            } else if (loc[i] >= j) {
                put_min(dp[i+1][j], dp[i][j] + B);
                put_min(dp[i+1][loc[i]+1], dp[i][j]);
            }
        }
    }

    ll ans = LLONG_MAX;
    for (ll v : dp[N])
        ans = min(ans, v);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 195840
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int main() {
  int x, y;
  cin >> x >> y;

  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      if (i + j == x && 2*i + 4*j == y) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>

int abs_diff(int x, int y) {
    if (x >= y)
        return x - y;
    else
        return y - x;
}

int doit(int A, int B, int C) {
    return A * 0 + abs_diff(A, B) + abs_diff(B, C);
}

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;
    
    int ans = std::min({
        doit(A, B, C),
        doit(A, C, B),
        doit(B, A, C),
        doit(B, C, A),
        doit(C, A, B),
        doit(C, B, A),
    });
    
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    h = LI()
    dp = [0 for i in range(n)]
    dp[1] = abs(h[0] - h[1])
    for i in range(2,n):
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
    print(dp[n-1])
    return

#B
def B():
    n, K = LI()
    h = LI()
    dp = [float("INF") for i in range(n + K + 1)]
    dp[0] = 0
    for i in range(n):
        for k in range(1, K + 1):
            if i + k >= n:
                break
            dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]))
    print(dp[n-1])
    return

#C
def C():
    n = II()
    abc = LIR(n)
    dp = [0 for i in range(3 * n + 1)]
    dp[0] = abc[0][0]
    dp[1] = abc[0][1]
    dp[2] = abc[0][2]
    for i in range(1,n):
        dp[3 * i] = max(dp[3 * i], dp[3 * (i - 1) + 1] + abc[i][0], dp[3 * (i - 1) + 2] + abc[i][0])
        dp[3 * i + 1] = max(dp[3 * i + 1], dp[3 * (i - 1) + 2] + abc[i][1], dp[3 * (i - 1)] + abc[i][1])
        dp[3 * i + 2] = max(dp[3 * i + 2], dp[3 * (i - 1) + 1] + abc[i][2], dp[3 * (i - 1)] + abc[i][2])
    dp[3 * n] = max(dp)
    print(dp[3*n])

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I():
    return 
#J

#K

#L

#M
#N
# O
# P
# Q
# R
# S
# T
# U
# V
# W
# X
# Y
# Z


#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 82396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a[i];
  double ans = 0;
  rep(i, n) {
    ans += 1 / a[i];
  }
  printf("%.5f\n", 1 / ans);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static final FS sc = new FS();
    static final PrintWriter out = new PrintWriter(System.out);
    static final int mod = 1000000007;

    public static void main(String[] args) {

        solve();
        out.close();

    }

    static void solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a == b) out.println(c);
        else if (b == c) out.println(a);
        else out.println(b);
    }
}


Measured memory_bytes: 32460
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n,a,b;
   string s;
   cin >> s;
   int f = 0;
   a = stoi(s);
   rep(i,s.size()){
      f+=stoi(s.substr(i,1));
   }
   if (a%f == 0) cout << "Yes" << endl;
   else cout << "No" << endl;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    
    if(b<a){
        cout << a - 1 << endl;
    }else{
        cout << a << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

int main(){

  int n;

  cin >> n;

  vector<int> a(n);
  
  for(int i = 0;i < n;++i)
	cin >> a[i];

  for(int i = 100;i >= 0;--i){
	int sum = 0;
	for(int j = 0;j < n;++j){
	  sum += a[j];
	  sum -= i;
	  if(sum < 0)
		break;
	}
	if(sum >= 0){
	  cout << i << endl;
	  break;
	}
  }

}



Measured memory_bytes: 3100
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<set>
#include<string.h>
#define ll long long
using namespace std;
const int MAX = 100;
int main() {
	ll a;
	int n;
	cin >> n;
	ll ans=1;
	priority_queue<ll> Q;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (a == 0) {
			cout << 0;
			return 0;
		}
		else if (a > 1e18) {
			cout << -1;
			return 0;
		}
		else Q.push(a);
	}
	for (int i = 0; i < n; i++) {
		if (!Q.empty()) {
			a = Q.top();
			Q.pop();
			if (ans >(ll)1e18/a||ans<0) {
				cout << -1;
				return 0;
			}
			ans *= a;
			if (ans >(ll) 1e18 || ans < 0) {
				cout << -1;
				return 0;
			}

		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int a, b; std::cin >> a >> b;
    int ans = inf;
    rrep(x, 2000) {
        if (int(x*0.08) != a || int(x*0.1) != b) 
            continue;
        ans = x;
        break;
    }
    std::cout << (ans != inf ? ans : -1) << "\n";
}


Measured memory_bytes: 256
N = int(input())

S = input()

w = [0]*(N+1)
e = [0]*(N+1) 

for i in range(N):
    if S[i] == "W":
        w[i+1] = 1
    
    if S[i] == "E":
        e[i+1] = 1

for i in range(N):
    w[i+1] += w[i]
    e[i+1] += e[i]

ans = N
for i in range(1,N+1):
    d = w[i-1] + e[N]-e[i]
    ans = min(ans,d)

print(ans)


Measured memory_bytes: 27040
#include <iostream>
#include <cstdio>
using namespace std;

double cutup(double x) {
  if (x - (double)((int)x / 1000) * 1000 > 0) {
    x = (double)((((int)x / 1000) + 1) * 1000);
  }
  return x;
}

double money(double x, int target, int depth = 0) {
  if (target == depth) { return x; }
  return money(cutup(x * 1.05), target, depth + 1);
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n, x;
  cin >> n;

  printf("%.0f\n", money(100000., n));

  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
const int mod=1e9+9;
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define si(a) a.size()
#define pii pair<int,int>
using namespace std;
void fail(){cout<<"IMPOSSIBLE\n";exit(0);}

int32_t main() {
   std::ios::sync_with_stdio(false);cin.tie(NULL);
   int a,b;
   cin>>a>>b;
   if(a<b)swap(a,b);
   if(a%2 != b%2)fail();
   cout<<(a+b)/2<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<ll,ll>
#define endl "\n"
#define MAXN 200005
using namespace std;

ll n,arr[MAXN];
map<ll,ll> m,m1;

void solve()
{
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>arr[i];
		m[i+arr[i]]++;
		m1[i-arr[i]]++;
	}
	ll cnt=0;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ll p=it->ss;
		ll q=m1[it->ff];
		cnt+=(p*q);
	}
	cout<<cnt<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
}


Measured memory_bytes: 39452
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,m;
vi a;

int main(){
	cin>>n>>m;
	ll t=0,x=0;
	a=vi(n);
	for(auto &i:a) cin>>i;
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++){
		if(a[i]>a[j]) t++;
		if(a[i]<a[j]) x++;
	}
	cout<<(m*(m+1)/2%mod*t%mod+m*(m-1)/2%mod*x%mod)%mod<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#include<vector>
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define mod 1000000007
using namespace std;


int main(){
	string a,b;
	cin>>a>>b;
	int flag=0;
	int temp=a.length();
	for(int i=0;i<temp;i++){
		if(a[i]!=b[i]){
			flag=1;
			break;
		}
	}
	if(flag==1){
		cout<<"No"<<endl;
	}
	else
	cout<<"Yes"<<endl;
return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

#define MAX_N 100000

// int N = 3;
// int x = 3;
// int a[MAX_N] = {2, 2, 2};
int N;
long long x;
long long a[MAX_N];

int main() {
    cin >> N >> x;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    long long res = 0;
    if (a[0] > x) {
        res = a[0] - x;
        a[0] = x;
    }

    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] <= x) {
            continue;
        }
        
        // while (a[i] + a[i+1] > x) {
        //     res++;
        //     a[i + 1]--;
        // }
        long long tmp = a[i + 1] + a[i] - x;
        a[i + 1] -= tmp;
        res += tmp;
    }
    printf("%lld\n", res);
    // cout << res << endl;
}

Measured memory_bytes: 1024
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

a = readInt()
print(a+a**2+a**3)

Measured memory_bytes: 9456
from sys import stdin
from collections import deque
def main():
  _map, _readline, _int = map, stdin.readline, int
  n, q = _map(_int, _readline().rstrip().split())
  values = [0] * n
  links = [[] for _ in range(n)]
  for _ in range(n - 1):
    a, b = _map(_int, _readline().rstrip().split())
    links[a - 1].append(b - 1)
    links[b - 1].append(a - 1)
  for _ in range(q):
    p, x = _map(_int, _readline().rstrip().split())
    values[p - 1] += x
  d = deque()
  d.append((0, -1))
  while len(d) != 0:
    i, p = d.popleft()
    for j in links[i]:
      if j == p:
        continue
      values[j] += values[i]
      d.append((j, i))
  print(*values)
main()

Measured memory_bytes: 62132
#include <bits/stdc++.h>
using namespace std;

int main()
{
string S;
cin >> S;
int Q;
cin >> Q;
int q[Q],f[Q];
string c[Q];
int Flag = 1;

for (int i = 0; i < Q; i++){
    cin >> q[i];
    if (q[i]==1){
        Flag = Flag*(-1);
    }
    else{
        cin >> f[i] >> c[i];
        if ((f[i]==1 && Flag==1) || (f[i]==2 && Flag==-1) ){
            S.insert(0,c[i]);
        }
        else{
            S.append(c[i]);
        }
    }
}
if (Flag == -1) reverse(S.begin(),S.end());

cout << S << endl;
}

Measured memory_bytes: 13312
# include <cstdio>
#include <iostream>
#include <iomanip>

# include <vector>
# include <algorithm>
using namespace std;
typedef long long ll ;
# define rep (i , n ) for ( int i =0; i < n ; i ++)
int N , M ;
int P [100000] , Y [100000];
vector < int > yd [100001];
int main ()
{
      cout.fill('0');

cin >> N >> M;
for ( int i =0; i < M ; i ++) {cin >> P[i] >> Y[i]; yd[P[i]].push_back(Y[i]);};
for ( int i =0; i < N ; i ++) sort(yd[i+1].begin(), yd[i+1].end());
for ( int i =0; i < M ; i ++) cout << setw(12) << (ll ( P [ i ])*1000000+ int ( lower_bound ( yd [ P [ i ]].
begin () , yd [ P [ i ]]. end () , Y [ i ]) - yd [ P [ i ]]. begin ())+1) << endl;
}

Measured memory_bytes: 7808
//#pragma comment(linker,"/STACK:102400000,102400000")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define PI 3.14159265357979823846
#define mod(x) ((x)%MOD)
using namespace std;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};
int s[105];
int main(){
//	freopen("C:\\Users\\wz\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\wz\\Desktop\\out.txt","w",stdout);
	ios_base::sync_with_stdio(0);
    int a,b,c,d;

    while(cin>>a>>b>>c>>d){
    memset(s,0,sizeof(s));

    for(int i = a;i<=b;i++)s[i]++;
    for(int i = c;i<=d;i++)s[i]++;
    int ans = 0;
    for(int i = 0;i <= 100;i++)if(s[i] == 2)ans++;
    if(ans == 0)cout<<0<<endl;
    else
    cout<<ans-1<<endl;}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, t;
    cin >> n >> t;

    ll min_cost = INF;
    REP(i, n) {
        ll cn, tn;
        cin >> cn >> tn;
        if (tn > t) continue;
        min_cost = min(min_cost, cn);
    }
    if (min_cost == INF) {
        P("TLE")
    }
    else {
        P(min_cost)
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

string L;
vector<vector<llong>> dp;

llong solve(llong now, bool free) {
	if (now == -1) return 1;
	if (dp[now][free] != -1) return dp[now][free];

	if (free) {
		return dp[now][free] = (3ll * solve(now-1, true)) % mod;
	} else {
		if (L[now] == '1') {
			return dp[now][free] = (solve(now-1, true) + 2ll * solve(now-1, false)) % mod;
		} else {
			return dp[now][free] = solve(now-1, false);
		}
	}
}

int main() {
	cin >> L;
	reverse(ALL(L));

	dp.resize(L.size(), vector<llong>(2, -1));
	cout << solve(L.size()-1, false) << endl;

	return 0;
}

Measured memory_bytes: 10496
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000003;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

ll fact[MOD], rfact[MOD];

ll perm(ll n, ll r){
    return (fact[n] * rfact[r]) % MOD;
}

ll comb(ll n, ll r){
    return (perm(n, r) * rfact[n-r]) % MOD;
}

void init(ll n){
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(int i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }
}

ll modpow(ll a, ll t) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= MOD;
        }
        a *= a;
        a %= MOD;
        t >>= 1;
    }
    return ret;
}

ll solve(ll x, ll d, ll n) {
    if(d == 0) return modpow(x, n);
    if(n >= MOD) return 0LL; // 項が MOD 個以上あったらy-1からy-1+nまでにMODの倍数がある
    ll y = (x * modpow(d, MOD-2)) % MOD;
    if((y-1+MOD)%MOD >= (y+n-1+MOD)%MOD) return 0LL;
    ll ret = (fact[(y+n-1+MOD)%MOD] * rfact[(y-1+MOD)%MOD]) % MOD;
    ret = (ret * modpow(d, n)) % MOD;
    return ret;
}

int main() {
    init(MOD-1);

    int q;
    cin >> q;
    ll x, d, n;
    while(q--) {
        cin >> x >> d >> n;
        cout << solve(x, d, n) << endl;
    }

}


Measured memory_bytes: 16512
from collections import Counter
import sys


N, K = map(int, input().split())
C = Counter()
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    C[a] += b

keys = list(C.keys())
keys.sort()
cnt = 0
for k in keys:
    cnt += C[k]
    if cnt >= K:
        break
print(k)


Measured memory_bytes: 17896
#include <bits/stdc++.h>
#include<cmath> 

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;




int main()
{
    fastio 
    // SUBL
  	int n;
  	ll a[100005];
  	// bool is[100005]={};
  	cin >> n;
  	FI(i,1,n) cin >> a[i];
  	RFI(i,n,2)
  	{
  		if(a[i]>=a[i-1]) continue;
  		if(a[i-1] == a[i] + 1)
  		{
  			a[i-1]--;
  			continue;
  		} 
  		cout << "No";
  		return 0;
  	}
  	cout << "Yes";
    return 0;
}         	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 1e5+5;

bool solve(int k,vector<int>&dp, vector<int>&a, int mini)
{
    assert(k>=0);
    if(k<mini)
        return false;
    if(dp[k]!=-1)
        return dp[k];
    bool ans= false;
    for(int j:a)
    {
        if(j>k)
        {
            break;
        }
        if(solve(k-j,dp,a,mini)==0)
        {
            ans = true;
            break;
        }
    }
    return dp[k]= ans;
}
void TEST_CASES(int cas)
{
    int n,k;
    scanf("%d %d",&n,&k);
    vector<int>a(n),dp(k+1, -1);
    for(int &i:a)
    {
        scanf("%d",&i);
    }
    int mini = a[0];

    if(solve(k,dp,a,mini))
    {
        printf("First\n");
    }
    else{
        printf("Second\n");
    }


}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 11460
h,w=map(int,input().split())
while h!=0 or w!=0:
    for j in range(h):
        for i in range(w):
            if i==0:
                print("#",end="")
            elif j==0:
                print("#",end="")
            elif j==h-1:
                print("#",end="")  
            elif i==w-1:
                print("#",end="")
            else:
                print(".",end="")
        print()
            
    print()
    h,w=map(int,input().split())
        
        
        
    
    
        
        
        
    
    
    
        


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 205
#define MAXH 20
#define MAXM 52
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	string s[2];
	cin >> s[0] >> s[1];
	int rsum[max(s[0].length(),s[1].length()) + 1][2][2] = {};
	cu(i,0,2){
		cu(j,0,2){
			cu(k,0,s[i].length()){
				rsum[k+1][j][i] = rsum[k][j][i] + (s[i][k] == ('A' + j));
			}
		}
	}
	int q;
	cin >> q;
	int x,y,l,r;
	while(q--){
		cin >> x >> y >> l >> r;	
		int a1 = (rsum[y][0][0] - rsum[x-1][0][0]) % 3;
		int b1 = (rsum[y][1][0] - rsum[x-1][1][0]) % 3;
		int a2 = (rsum[r][0][1] - rsum[l-1][0][1]) % 3;
		int b2 = (rsum[r][1][1] - rsum[l-1][1][1]) % 3;
		bool ans = (b1 - a1 + 3) % 3 == (b2 - a2 + 3) % 3;
		cout << (ans?"YES":"NO") << '\n';
	}
}


Measured memory_bytes: 2512
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int r = 0;
	scanf("%d", &r);
	printf("%d\n", r*r);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
typedef vector<vector<int>> Graph;
 
vector<ll> cnt;
void dfs(const Graph &g, int a, int b, ll num) {
    cnt[a] = num;
    for(auto na : g[a]) {
        if(na == b)
            continue;
        dfs(g, na, a, num + cnt[na]);
    }
}
 
int main() {
    int N, Q;
    cin >> N >> Q;
    Graph g(N);
    cnt.assign(N, 0);
    for(int i = 1; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 0; i < Q; ++i) {
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    dfs(g, 0, -1, cnt[0]);
    for(int i = 0; i < N; ++i)
        cout << cnt[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 27392
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	string s;
	cin >> s;
	string ans = "";
	for (int i = 0; i < s.length(); i++) {
		if (s.at(i) == 'B') {
			if (ans.length() > 0) ans.pop_back();
		}
		else ans.push_back(s.at(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,k,a[N];
int main()
{
    scanf("%d%d",&n,&k);for(int i=1;i<=n;i++) scanf("%d",&a[i]);long long ans=0;sort(a+1,a+1+n);for(int i=1;i<=k;i++)ans+=a[i];printf("%lld\n",ans);
}



Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, sum =0;
    cin >>N;
    vector<int> price(N);
    for (int i = 0; i < N; i++){
    cin >> price.at(i);
    }
    sort(price.begin(),price.end());
    for(int i =0;i<N;i++){
        if(i!=N-1)
        sum += price.at(i);
        if(i ==N-1){
            sum += price.at(i)/2;
        }
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 256
a, b, c, d = input()

#print(a)

for i in range(2 ** 3):
    lis = ['-'] * 3
    for j in range(3):
        if ((i >> j) & 1):
            lis[j] = '+'
    if eval(a+lis[0]+b+lis[1]+c+lis[2]+d) == 7:
        print(a+lis[0]+b+lis[1]+c+lis[2]+d+'=7')
        exit()
    #print(lis)


Measured memory_bytes: 3060
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] B = new int[N-1];
		for (int i=0;i<N-1;i++) {
			B[i] = Integer.parseInt(sc.next());
		}
		int ans = 0;
		ans += B[0];
		for (int i=0;i<N-2;i++) {
			ans += Math.min(B[i], B[i+1]);
		}
		ans += B[N-2];
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100005][3];
ll minimum_height(ll arr[],ll n,ll last)
{
    ll ans;
    if(n==1)
    return 0;
    if(n==2)
    return abs(arr[n-1]-arr[n-2]);
    if(dp[n][last]!=-1)
    return dp[n][last];
    else
    return dp[n][last]=min(minimum_height(arr,n-1,1)+abs(arr[n-1]-arr[n-2]),minimum_height(arr,n-2,2)+abs(arr[n-1]-arr[n-3]));
}
int main() 
{
    memset(dp,-1,sizeof(dp));
	ll n,i,arr[100005];
	cin>>n;
	for(i=0;i<n;i++)
	cin>>arr[i];
	cout<<minimum_height(arr,n,0);
	return 0;
}

Measured memory_bytes: 10616
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-8;

class Princess {
public:
  int pos;
  int money;
  int attacked_count;
  Princess(int _p,int _m,int _atk) :pos(_p), money(_m), attacked_count(_atk){}
  bool operator<(const Princess& p) const {
    return attacked_count < p.attacked_count;
  }
  bool operator>(const Princess& p) const {
    return attacked_count > p.attacked_count;
  }
};

int main(){
  int total_inns,total_roads,total_money;
  while(~scanf("%d %d %d",&total_inns,&total_roads,&total_money)){
    if(total_inns == 0 && total_roads == 0 && total_money == 0) break;

    int cost[101][101];
    int robber[101][101];
    int dp[101][101];
    memset(cost,0x3f,sizeof(cost));
    memset(robber,0x3f,sizeof(robber));
    memset(dp,0x3f,sizeof(dp));

    for(int road_idx=0;road_idx<total_roads;road_idx++){
      int from,to;
      int dist,robber_num;
      scanf("%d %d %d %d",&from,&to,&dist,&robber_num);
      cost[from][to] = dist;
      cost[to][from] = dist;
      robber[from][to] = robber_num;
      robber[to][from] = robber_num;
    }

    priority_queue<Princess,vector<Princess>,greater<Princess> > que;
    que.push(Princess(1,total_money,0));
    

    while(!que.empty()){
      Princess pr = que.top();
      int from = pr.pos;
      int remaining_money = pr.money;
      int attacked_count = pr.attacked_count;
      que.pop();

      for(int to=2;to<=total_inns;to++){
	if(to == from) continue;
	if(cost[from][to] == INF) continue;


	if(cost[from][to] <= remaining_money){
	  //use_money
	  int next_atk = attacked_count;
	  int next_money = remaining_money - cost[from][to];

	  if(dp[to][next_money] > next_atk){
	    dp[to][next_money] = next_atk;
	    Princess next(to,next_money,next_atk);
	    que.push(next);
	  }

	  //dont use
	  int next_atk2 = attacked_count + robber[from][to];
	  int next_money2 = remaining_money;

	  if(dp[to][next_money2] > next_atk2){
	    dp[to][next_money2] = next_atk2;
	    Princess next2(to,next_money2,next_atk2);
	    que.push(next2);
	  }
	}
	else{
	  //dont use
	  int next_atk2 = attacked_count + robber[from][to];
	  int next_money2 = remaining_money;

	  if(dp[to][next_money2] > next_atk2){
	    dp[to][next_money2] = next_atk2;
	    Princess next2(to,next_money2,next_atk2);
	    que.push(next2);
	  }
	}
      }
    }

    int res = INF;
    for(int money=0;money<=100;money++){
      res = min(res,dp[total_inns][money]);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
int dp[2][3];
int ans;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	FOR(i, 0, 3) dp[1][i] = 0;
	FOR(i, 0, N)
	{
		FOR(j, 0, 3) dp[i & 1][j] = 0;
		int a[3];
		FOR(j, 0, 3) cin >> a[j];
		FOR(j, 0, 3)
		{
			FOR(k, 0, 3)
			{
				if (j == k) continue;
				ckmax(dp[i & 1][k], dp[i & 1 ^ 1][j] + a[k]);
			}
		}
	}
	FOR(i, 0, 3)
	{
		ckmax(ans, dp[(N + 1) & 1][i]);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int INF = 1000000000;
const int N_MAX = 40;
const int A_MAX = 10;
const int B_MAX = 10;
const int AN_MAX = A_MAX * N_MAX;
const int BN_MAX = B_MAX * N_MAX;

int N, Ma, Mb;
int a[N_MAX];
int b[N_MAX];
int c[N_MAX];

int dp[N_MAX + 1][AN_MAX + 1][BN_MAX + 1];

void solve() {
  fill(dp[0][0], dp[N][AN_MAX + 1], INF);
  dp[0][0][0] = 0;
  REP(i, N) FOR(ca, 0, AN_MAX) FOR(cb, 0, BN_MAX) {
    dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
    if (ca >= a[i] && cb >= b[i]) {
      dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca - a[i]][cb - b[i]] + c[i]);
    }
  }
  int ans = INF;
  FOR(ca, 0, AN_MAX) FOR(cb, 0, BN_MAX) {
    if (ca == 0 && cb == 0) continue;
    if (ca * Mb != cb * Ma) continue;
    ans = min(ans, dp[N][ca][cb]);
  }
  if (ans < INF) printf("%d\n", ans);
  else puts("-1");
}

void input() {
  scanf("%d%d%d", &N, &Ma, &Mb);
  REP(i, N) scanf("%d%d%d", a + i, b + i, c + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i, m) { cin >> x[i]; }

  if (n >= m) {
    cout << 0 << endl;
  } else {
    sort(x.begin(), x.end());
    vector<int> diffs(m-1);
    rep(i, m-1) {
      diffs[i] = x[i+1] - x[i];
    }
    sort(diffs.begin(), diffs.end());
    ll ans = 0;
    rep(i, m-n) {
      ans += diffs[i];
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  long long int i,j;
  long long int n,ans=1e9+1,sum;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  for(i=1;i<101;++i){
    sum=0;
    for(j=0;j<n;++j){
      sum+=pow(a.at(j)-i,2);
      //cout<<sum<<' ';
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256