akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fios ios_base::sync_with_stdio(false); cin.tie(0);
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define ll long long
#define nl "\n"
using namespace std;


int main()
{
    int a,b;
    cin>>a>>b;

    cout<<6-(a+b)<<nl;

    return 0;
}



Measured memory_bytes: 384
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    string s,t;
    std::cin >> s>>t;
    ll n = s.size();
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        if(s[i]!=t[i])cnt++;
    }
    std::cout << cnt << std::endl;
}


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

int main() {
int a[3],t,k,l;
a[0]=1;
a[1]=0;
a[2]=0;
char q,w,e;
while(cin>>q>>e>>w){
	if(q=='A'){
		k=0;
	}
	if(q=='B'){
		k=1;
	}
	if(q=='C'){
		k=2;
	}
	if(w=='A'){
		l=0;
	}
	if(w=='B'){
		l=1;
	}
	if(w=='C'){
		l=2;
	}
	t=a[k];
	a[k]=a[l];
	a[l]=t;
}
if(a[0]==1){
	cout<<"A"<<endl;
}
if(a[1]==1){
	cout<<"B"<<endl;
}
if(a[2]==1){
	cout<<"C"<<endl;
}
return 0;
}

Measured memory_bytes: 1136
#include <iostream>

using namespace std;

int main(){
  int x;cin>>x;
  string str;
  switch (x%7){
  case 4:
    str="mon";
    break;
  case 5:
    str="tue";
    break;
  case 6:
    str="wed";
    break;
  case 0:
    str="thu";
    break;
  case 1:
    str="fri";
    break;
  case 2:
    str="sat";
    break;
  case 3:
    str="sun";
    break;
  default:
    break;
  }
  cout<<str<<endl;
}


Measured memory_bytes: 3224
def solve(n, m, arr):
    ans = n - sum(arr)
    if ans >= 0:
        print(ans)
    else:
        print(-1)
if __name__ == "__main__":
    n, m = map(int, input().split(' '))
    arr = [int(s) for s in list(input().split())]
    solve(n, m, arr)

Measured memory_bytes: 10056
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 250000;
const int K = 19;
int n, q;
int mod = 998244353;
int  f[N], invf[N], used[N], d[N];
vector < int > g[N];
int p[N], tin[N], tout[N], t;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    if (k < 0) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
void dfs(int v, int pr = -1){
    t++;
    tin[v] = t;
    tout[v] = 1e9;
    for (auto u: g[v]){
        if (u == pr) continue;
        if (p[u] == 0){
            p[u] = v;
            dfs(u, v);
        }
        else
        {
            int ver = p[u];
            if (tin[v] > tin[ver] && tin[v] < tout[ver]) p[u] = v;
        }
    }
    t++;
    tout[v] = t;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n - 1 + m; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        d[v]++;
    }
    int r;
    for (int i = 1; i <= n; i++){
        if (d[i] == 0){
            r = i;
            p[i] = 0;
        }
    }
    dfs(r);
    for (int i = 1; i <= n; i++) cout << p[i] << endl;
}


Measured memory_bytes: 19712
#include<iostream>
using namespace std;
#define ll long long
int main(){
  ll mx=0;
  ll tmp=0;
  ll H1,H2;
  ll N;
  cin >> N >> H1;
  for(ll i=0;i<N-1;i++){
    cin >> H2;
    if(H1>=H2)tmp++;else tmp=0;
    mx=max(tmp,mx);
    H1=H2;
  }
  cout << mx;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    bool flag = true;
    int m = a.size();
    if(a[0] == 0 && m % 2 == 1){
        for(int i=1; i<m; i++){
            if(a[i] != (i+1) / 2 * 2){
                flag = false;
                break;
            }
        }
    }
    else if(a[0] == 1 && m % 2 == 0){
        for(int i=0; i<m; i++){
            if(a[i] != i / 2 * 2 + 1){
                flag = false;
                break;
            }
        }
    }
    else flag = false;

    long long int count = 1;
    for(int i=1; i<=m/2; i++){
        count *= 2;
        count %= MOD;
    }
    
    if(flag == true)  cout << count << endl;
    if(flag == false) cout << 0 << endl;
    return 0;
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int a, b;
	cin >> a >> b;
	cout << max(a - 2 * b, 0) << '\n';
}


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

def solve(n):
    if n%2 == 1:
        return 0
    sum_num = 0
    for i in range(1000):
        m = n//2 // (5**(i+1))
        if m == 0:
            break
        sum_num += m
        # print(m)
    return sum_num

print(solve(N))

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 105

int n;

int main()
{
    _FastIO;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; i++){
        int k = (n - 1) / i;
        ans += k;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N,K;
  string S;
  cin >> N;
  cin >> S;
  cin >> K;
  for(int i = 0;i < N;i++) {
    if(S.at(i) != S.at(K - 1)) {
      S.at(i) = '*';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_106
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nmq = ReadInts();
            int n = nmq[0];
            int m = nmq[1];
            int q = nmq[2];
            int[,] pat = new int[n, n];
            for(int i = 0; i < m; i++)
            {
                int[] lr = ReadInts();
                int l = lr[0]-1;
                int r = lr[1]-1;
                pat[l, r]++;
            }
            for(int i = 1; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    if (j + i >= n) break;
                    pat[j, j + i] += pat[j, j + i - 1] + pat[j + 1, j + i];
                    if (i > 1)
                    {
                        pat[j, j + i] -= pat[j + 1, j + i - 1];
                    }
                }
            }
            int[] res = new int[q];
            for(int i = 0; i < q; i++)
            {
                int[] pq = ReadInts();
                res[i] = pat[pq[0] - 1, pq[1] - 1];
            }
            for (int i = 0; i < q; i++) Console.WriteLine(res[i]);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 16920
type tree = Br of int * tree * tree | Lf

module IntSet = Set.Make
                  (
                    struct
                      type t = int
                      let compare (x : int) y = compare x y
                    end
                  )

let drop_chars str n =
  let len = String.length str in
  assert (n <= len);
  String.sub str n (len - n)

let parse_tree expr =
  let rec parse_tree expr n =
    if expr.[0] <> '(' then (Lf, expr)
    else
      let expr = drop_chars expr 1 in
      let lhs, expr = parse_tree expr (n * 2) in
      assert (expr.[0] = ',');
      let expr = drop_chars expr 1 in
      let rhs, expr = parse_tree expr (n * 2 + 1) in
      assert (expr.[0] = ')');
      (Br (n, lhs, rhs), drop_chars expr 1) in
  fst @@ parse_tree expr 1

let node_numbers tree =
  let rec node_numbers set = function
    | Lf -> set
    | Br (n, lhs, rhs) ->
       let set = IntSet.add n set in
       let set = node_numbers set lhs in
       node_numbers set rhs in
  node_numbers IntSet.empty tree

let encode_node_numberes set =
  let rec encode n =
    let lhs = if IntSet.mem (n * 2) set then encode (n * 2) else "" in
    let rhs = if IntSet.mem (n * 2 + 1) set then encode (n * 2 + 1) else "" in
    Printf.sprintf "(%s,%s)" lhs rhs in
  encode 1

let rec loop () =
  try
    let line = read_line () in
    let encoded =
      Scanf.sscanf
        line
        "%c %s %s"
        (fun c t1 t2 ->
         let t1, t2 =
           (node_numbers @@ parse_tree t1), (node_numbers @@ parse_tree t2) in
         let op = if c = 'i' then IntSet.inter else IntSet.union in
         encode_node_numberes (op t1 t2)) in
    print_endline encoded;
    loop ()
  with End_of_file -> ()

let () = loop ()

Measured memory_bytes: 2508
from collections import defaultdict

def prime(n): #O(√n)で素因数分解結果を返す
    dic = defaultdict(int)
    i=2
    while i*i<=n:
        while n%i==0:
            n//=i
            dic[i]+=1
        i+=1
    if n!=1: dic[n]=1
    return dict(dic)

n=int(input())
cnt=0
for i in range(1,n+1,2):
    res=prime(i)
    temp=1
    for val in res.values(): temp*=val+1
    if temp==8: cnt+=1
print(cnt)

Measured memory_bytes: 9400
#include <iostream>

using namespace std;

int main() {
  string s;
  int k;
  cin >> s >> k;
  int tmp = 1, buf = 0;
  long long ans = 0;
  for (int i = 1; i < s.size(); i++) {
    if (s[i-1] == s[i]) {
      tmp += 1;
    }
    else {
      if (!buf) buf = tmp;
      ans += tmp / 2;
      tmp = 1;
    }
  }
  if (!buf) {
    ans = tmp;
    ans = ans * k / 2;
    cout << ans << endl;
    return 0;
  }
  ans += tmp / 2;
  ans *= k;
  if (s.front() == s.back() && buf % 2 && tmp % 2) {
    ans += (k - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, X = list(map(int, sys.stdin.readline().split()))
    MAX = 1000000
    MIN = -1000000

    ret = [X]
    for i in range(1, K):
        if X + i <= MAX:
            ret.append(X+i)
        else:
            ret.append(X - K)

        if X - i >= MIN:
            ret.append(X-i)
        else:
            ret.append(X + K)

    print(*sorted(set(ret)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
class UF{
public:
  vi value;
  vi over; // When over < 0, 'over' keep number of node(using negative number). -1 means this tree is a node.
  int root(int index){
    int t = index;
    stack<int> stack_i;
    while(over[t] >= 0){
      stack_i.push(t);
      t = over[t];
    }
    while(!stack_i.empty()){
      int i = stack_i.top(); stack_i.pop();
      over[i] = t;
    }// reconnect
    return t;
  }
  void merge(int a,int b){
    if(this->root(a) == this->root(b)) return;
    over[root(a)] += over[root(b)]; // over have a number of nodes.
    over[root(b)] = root(a);
  }
  int NumNode(int a){
    return -over[root(a)];
  }
  UF(int Nodes){
    value.resize(Nodes);
    over.resize(Nodes);
    rep(i,Nodes)
      over[i] = -1;
  }
};
UF uf(100001);
bool used[100001];
int main(){
  int n,m; cin >> n >> m;
  rep(i,m){
    int x,y,z; cin >> x >> y >> z;
    uf.merge(x,y);
  }
  int ans = -1;
  rep(i,n+1){
    if(uf.root(i) == i) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool id(vector<int> a)
{
	vector<int>b=a;
	sort(b.begin(),b.end());
	if(b==a)
		return 1;
	return 0;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	vector<int>a(n),b(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	if(id(a))
	{
		cout<<"YES";
		return 0;
	}
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			b=a;
			swap(b[i],b[j]);
			if(id(b))
			{
				cout<<"YES";
				return 0;
			}
		}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll limitLL = 3234566667;
priority_queue<ll, vector<ll>, greater<ll>> que;

void dfs(ll current) {
    if(current > limitLL) return;
    que.push(current);
    int lastDidit = current % 10;
    ll newLL = current * 10 + lastDidit;
    dfs(newLL);

    if (lastDidit > 0) {
        dfs(newLL - 1);
    }

    if (lastDidit < 9) {
        dfs(newLL + 1);
    }
}

int main() {
    int K;
    cin >> K;
    for (int i = 1; i <= 9; i++)
    {
        dfs(i);
    }

    vector<ll> LL;
    while (!que.empty()) {
        LL.pb(que.top());
        que.pop();
    }
    cout << LL[K - 1] << endl;
}


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

int main(){
	int n,k;
	cin>>n>>k;
	
	//必殺技を使える回数が敵の数以上ならすぐに解答可能
	if(n<=k){
		cout<<0<<endl;
		return 0;
	}
	
	vector<int> vec(n);
	for(int i=0;i<n;i++) cin>>vec.at(i);
	
	long long ans=0;
	if(k==0){
		for(int i=0;i<n;i++) ans+=vec.at(i);
	} else {
		sort(vec.begin(),vec.end());
		for(int i=n-1;i>n-k-1;i--) vec.pop_back();
		for(int i=0;i<vec.size();i++) ans+=vec.at(i);
	}
	//for some reason, this doesn't work
	//ans = accumulate(vec.begin(),vec.end(),0);
	
	cout<<ans<<endl;
	return 0;	
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

using Row = vector<i64>;
using Board = vector<Row>;

i64 search(Board &board, i64 i, i64 j, i64 t) {
  if (t > 10) {
    return inf<i64>;
  }
  i64 res = inf<i64>;
  i64 I[4] = {0, 1, 0, -1};
  i64 J[4] = {1, 0, -1, 0};
  for (i64 d = 0; d < 4; ++d) {
    i64 di = I[d];
    i64 dj = J[d];
    i64 k = 1;
    while (true) {
      if (i + di * k < 0 || board.size() <= i + di * k) break;
      if (j + dj * k < 0 || board[i].size() <= j + dj * k) break;
      if (board[i + di * k][j + dj * k] == 1) {
        if (k == 1) break;
        board[i + di * k][j + dj * k] = 0;
        res = min(res, search(board, i + di * (k - 1), j + dj * (k - 1), t + 1));
        board[i + di * k][j + dj * k] = 1;
        break;
      } else if (board[i + di * k][j + dj * k] == 3) {
        return t;
      }
      k += 1;
    }
  }
  return res;
}

signed main() {
  while (true) {
    i64 w, h;
    cin >> w >> h;
    if (w == 0) break;
    Board board(h, Row(w));
    i64 si, sj;
    REP(i, h) {
      REP(j, w) {
        cin >> board[i][j];
        if (board[i][j] == 2) {
          board[i][j] = 0;
          si = i;
          sj = j;
        }
      }
    }
    i64 res = search(board, si, sj, 1);
    cout << (res == inf<i64> ? -1 : res) << endl;
  }
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    int k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    /*if(k==0){
        sort(all(a));
        cout<<a[n-1]<<endl;
        return 0;
    }*/
    int ng=0,ok=1000000001;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        int cnt=0;
        rep(i,n){
            cnt+=a[i]/mid;
            if(a[i]%mid==0) cnt--;
        }
        if(cnt<=k) ok=mid;
        else ng=mid;
    }

    cout<<ok<<endl;
}

Measured memory_bytes: 4048
"use strict"
function main(arg) {
    let [a,b,c,d] = arg.trim().split("\n")[0].split(" ").map(e => BigInt(e))
    let max = a*c
    if (a*d > max) max = a*d
    if (b*c > max) max = b*c
    if (b*d > max) max = b*d
    console.log(max.toString())
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29680
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

int main()
{
    stack <int> stk;
    string str;
    getline(cin, str);
    int len = str.size();
    rep(i, 0, len-1)
    {
        if (str[i]>='0' && str[i]<='9')
        {
            int num = str[i]-'0';
            while (str[++i]>='0' && str[i]<='9')
                num = num*10 + str[i]-'0';
            stk.push(num);
        }
        else if (str[i] == '+' || str[i] == '-' || str[i] == '*')
        {
            int b = stk.top(); stk.pop();
            int a = stk.top(); stk.pop();
            switch (str[i])
            {
                case '+': stk.push(a+b); break;
                case '-': stk.push(a-b); break;
                case '*': stk.push(a*b); break;
            }
        }
    }
    cout << stk.top() << endl;

    return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, K, A[100000];

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll judge() {
  ll d = A[0];
  REP(i, 1, N) d = gcd(d, A[i]);
  return d;
}

int main(void) {
  cin >> N >> K;
  REP(i, 0, N) cin >> A[i];

  sort(A, A + N);

  ll d = judge();
  cout << (A[N - 1] >= K && K % d == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 1024
// Problem : B - Trick or Treat
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;


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

    long n, k;
    cin >> n >> k;
    vector<long> a(n+1, 0);
    for (long  i = 0; i < k; i++) {
        long d;
        cin >> d;
        for (long j = 0; j < d; j++) {
            long x;
            cin >> x;
            a[x]++;
        }
    }
    long count = 0;
    for (long i = 1; i <= n; i++) {
        if (a[i] == 0) count++;
    }
    cout << count << "\n";
    
    return 0;
}


Measured memory_bytes: 3660
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	X, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	Y, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	p := make([]int, a)

	sc.Scan()
	b, _ := strconv.Atoi(sc.Text())
	q := make([]int, b)

	sc.Scan()
	c, _ := strconv.Atoi(sc.Text())
	r := make([]int, c)

	for i := 0; i < a; i++ {
		sc.Scan()
		p[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(p)

	for i := 0; i < b; i++ {
		sc.Scan()
		q[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(q)

	for i := 0; i < c; i++ {
		sc.Scan()
		r[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(r)

	var x, y, z, res int
	for (x + y + z) < X+Y {
		pX := 0
		if x < X && len(p) > x {
			pX = p[len(p)-1-x]
		}

		qY := 0
		if y < Y && len(q) > y {
			qY = q[len(q)-1-y]
		}

		rZ := 0
		if len(r) > z {
			rZ = r[len(r)-1-z]
		}

		if rZ > pX && rZ > qY {
			res += rZ
			z++
		} else if pX > qY {
			res += pX
			x++
		} else {
			res += qY
			y++
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>p(m), y(m);
	vector<vector<ll>>town(n + 1);
	rep(i, m) {
		cin >> p[i] >> y[i];
		town[p[i]].push_back(y[i]);
	}
	rep(i, n+1) {
		sort(town[i].begin(), town[i].end());
	}
	rep(i, m) {
		ll res = lower_bound(town[p[i]].begin(), town[p[i]].end(), y[i]) - town[p[i]].begin();
		res++;
		printf("%.6d", p[i]);
		printf("%.6d\n", res);
	}
	return 0;
}


Measured memory_bytes: 10216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define FORD(i, a, b) for (int i = (a), i##_len = (b); i > i##_len; i--)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
    int n, q;
    cin >> n;
    vector<tuple<int, int>> vw(n);
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        vw[i] = make_tuple(a, b);
    }
    cin >> q;
    vector<tuple<int, int>> vl(q);
    REP(i, q) {
        int a, b;
        cin >> a >> b;
        vl[i] = make_tuple(a, b);
    }

    int former = min(2048, n);
    vector<vector<int>> former_dp(former, vector<int>(100001, -1));
    vector<set<int>> former_set(former);

    former_dp[0][0] = 0;
    former_dp[0][get<1>(vw[0])] = get<0>(vw[0]);
    former_set[0].insert(0);
    former_set[0].insert(get<1>(vw[0]));

    FOR(i, 1, former) {
        int v, w;
        tie(v, w) = vw[i];
        auto& anc_dp = former_dp[(i - 1) / 2];
        auto& now_dp = former_dp[i];
        auto& anc_set = former_set[(i - 1) / 2];
        auto& now_set = former_set[i];
        for (auto j : anc_set) {
            now_dp[j] = anc_dp[j];
            now_set.insert(j);
        }
        for (auto j : anc_set) {
            if (w + j <= 100000) {
                now_dp[w + j] = max(now_dp[w + j], anc_dp[j] + v);
                now_set.insert(w + j);
            }
        }
    }

    REP(i, former) {
        int m = 0;
        auto& now_dp = former_dp[i];
        FOR(j, 1, 100001) {
            m = max(m, now_dp[j]);
            now_dp[j] = m;
        }
    }

    for (auto temp : vl) {
        int v, l;
        tie(v, l) = temp;
        if (v <= former) {
            cout << former_dp[v - 1][l] << endl;
            continue;
        }
        vector<tuple<int, int>> later;
        int vv = v;
        while (vv > former) {
            later.push_back(vw[vv - 1]);
            vv >>= 1;
        }
        auto& anc_dp = former_dp[vv - 1];
        int m = later.size();
        int ans = 0;
        REP(i, pow(2, m)) {
            int v_sum = 0;
            int w_sum = 0;
            int ii = i;
            for (auto temp : later) {
                int j, k;
                tie(j, k) = temp;
                if (ii & 1) {
                    v_sum += j;
                    w_sum += k;
                }
                ii >>= 1;
            }
            if (w_sum > l) { continue; }
            ans = max(ans, v_sum + anc_dp[l - w_sum]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 937956
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


Int calc(string &s){
  Int N = s.size();
  Int i = 0;
  Int res = 0;
  Int cnt = 0;
  while(i < N){
    cnt++;
    if(s[i] == 'A' && s[i+1] == 'D'){
      s[i] = 'D';
      s[i+1] = 'A';
      i--;
      res++;
    }
    else i++;
  }
  return res;
}

Int count(Int &i,string &s, char target){
  Int cnt = 0;
  while(s[i] == target) i++, cnt++;
  return cnt;
}
  

Int calc2(string &s){
  Int N = s.size();
  Int i = 0;
  Int res = 0;
  while(i < N){
    Int ni = i;
    Int cnt = count(ni, s, 'D');
    if(cnt){
      for(Int j=0;j<cnt;j++) s[i+j] = 'D';
      for(Int j=0;j<cnt;j++) s[i + cnt + j] = 'A';
      res += (1 + cnt) * (cnt) / 2;
      i = ni - 1;
    }
    else i++;
  }
  return res;
}

Int calc3(string s){
  Int N = s.size();
  Int cnt = 0;
  Int res = 0;
  for(Int i=N-1;i>=0;i--){
    if(s[i] == 'D') cnt++;
    if(s[i] == 'A') res += cnt;
  }
  return res;
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;
  string tmp = "";
  s += "XXXXXX";
  for(Int i=0;i<(Int)s.size();i++){
    if(s[i] == 'B' && s[i+1] == 'C') tmp += 'D', i++;
    else tmp += s[i];
  }
  s = tmp;
  Int ans = 0;
  {
    Int i = 0;
    Int N = s.size();
    while(i < N){
      string t = "";
      while(i < N && (s[i] == 'A'  || s[i] == 'D')) t += s[i], i++;
      ans += calc3(t);
      i++;
    }
  }

  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  string s;
  while(getline(cin,s)) {
    if(s=="0") break;
    int sum=0,k=0,x;
    stringstream ss;
    ss << s;
    while(ss >> x) {
      if(x>10) x=10;
      sum+=x;
      if(x==1) {
	k++;
	sum+=10;
      }
    }
    while(sum>21 && k--) sum-=10;
    if(sum>21) sum=0;
    pr(sum);
  }
  return 0;
}


Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
map<int, int> M;

void solve() {
	cin >> N;
	rep(i, 0, N) {
		int a; cin >> a;
		M[a]++;
	}
	ll ans = 0;
	for(pi p : M) {
		int a = p.fst, c = p.sec;
		if(c >= a) ans += c - a;
		else ans += c;
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 4736
use std::collections::BinaryHeap;

fn main() {
    let vs = read_vec::<usize>();
    let n = vs[0];
    let m = vs[1];
    let a_vec = read_vec::<usize>();
    println!("{}", solve(n, m, a_vec));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn solve(n: usize, m: usize, a_vec: Vec<usize>) -> usize {
    let mut heap = BinaryHeap::with_capacity(n);
    for i in a_vec {
        heap.push(i);
    }
    for _i in 0..m {
        let v = heap.pop().unwrap();
        heap.push(v / 2);
    }
    heap.iter().fold(0, |sum, &i| sum + i)
}

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

long long int x, y, a, i;

int main(){
    scanf("%lld%lld", &x, &y);
    if(abs(x) > abs(y)){
        if(x > 0){
            a++;
        }else{
            x = -x;
        }
        if(y > 0){
            a++;
        }else{
            y = -y;
        }
        a += x - y;
    }else{
        if(x < 0){
            a++;
            x = -x;
        }
        if(y < 0){
            a++;
            y = -y;
        }
        a += y - x;
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        int n = sc.nextInt();
        boolean[][] b = new boolean[3][3];
        for (int i = 0; i < n; i++) {
            int c = sc.nextInt();
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if(a[j][k] == c) b[j][k] = true;
                }
            }
        }
        boolean ans = false;
        for (int i = 0; i < 3; i++) {
            if(b[i][0] && b[i][1] && b[i][2]){
                ans = true; break;
            }
            if(b[0][i] && b[1][i] && b[2][i]){
                ans = true; break;
            }
        }
        if(b[0][0] && b[1][1] && b[2][2]) ans = true;
        if(b[2][0] && b[1][1] && b[0][2]) ans = true;
        System.out.println(ans ? "Yes" : "No");
        sc.close();

    }

}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
  int A;
  cin>>A;
  cout<<A+A*A+A*A*A<<endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

template<typename T>
struct WeightedUnionFind {
    vector<int> data;
    vector<T> ws;
    WeightedUnionFind(int sz) : data(sz, -1), ws(sz) { }
    bool merge(int x, int y, T w) {             // ws(y) = ws(x) + w
        w += weight(x); w -= weight(y);
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y), w = -w;
        data[x] += data[y]; data[y] = x; ws[y] = w;
        return true;
    }
    bool find(int x, int y) { return root(x) == root(y); }
    T diff(int x, int y) { return weight(y) - weight(x); }
    T weight(int t) { root(t); return ws[t]; }
    int root(int k) {
        if (data[k] < 0) return k;
        int par = root(data[k]);
        ws[k] += ws[data[k]];
        return data[k] = par;
    }
};

int main() {
    int n, q; cin >> n >> q;
    WeightedUnionFind<int> wuf(n);
    while (q--) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) {
            int z; cin >> z;
            wuf.merge(x, y, z);
        } else {
            if (wuf.find(x, y)) {
                cout << wuf.diff(x, y) << endl;
            } else {
                cout << "?" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3624
import math
a, b = map(int,input().split())
ans = []
for i in range(1001):
    price_8 = math.floor(i * 0.08)
    price_10 = math.floor(i * 0.1)
    if price_8 == a and price_10 == b:
        ans.append(i)

if len(ans) != 0:
    print(min(ans))
else:
    print(-1)

Measured memory_bytes: 3060
n,m = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)
s = sum(A)
cnt = 0
for a in A:
    if a*4*m >= s:
        cnt += 1
    if cnt >= m:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 61628
#include <iostream>
#include <cassert>
#include <cmath>
#include <complex>
using namespace std;


typedef complex<double> P;

#define EPS			(1e-10)
#define PI			(3.14159265358979323846)


#define X(a)		( (a).real() )
#define Y(a)		( (a).imag() )
#define EQ(a,b)		( -EPS<(a)-(b) && (a)-(b)<EPS )
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )


int hitStateCC(P a, double ra, P b, double rb)
{	
	double cc=abs(a-b);

	if( EQ(cc,ra+rb) )	return  1;	// OÚ
	if( EQ(cc,abs(ra-rb)) )
	{
		if(EQ(ra,rb))	return -1;	// àÚ Ca==Cb
		if(ra>rb)		return  3;	// àÚ Ca>=Cb
		else			return -3;	// àÚ Ca<=Cb
	}

	if(cc>ra+rb)		return  0;	// £êÄ¢é
	if(cc<abs(ra-rb))
	{
		if(ra>rb)		return  4;	// àï Ca>Cb
		else			return -4;	// àï Ca<Cb
	}

	return 2;						// ð·
}

int main()
{
	int n; double a,b,c,d,e,f;
	
	cin >> n;
	while(n--)
	{
		cin >> a >> b >> c >> d >> e >> f;
		switch(hitStateCC(P(a,b),c,P(d,e),f))
		{
			case 0:
			cout << 0 << endl; break;

			case 1: case -1: case 2: case 3: case -3:
			cout << 1 << endl; break;

			case  4: cout <<  2 << endl;  break;
			case -4: cout << -2 << endl;  break;
		}
	}
}

Measured memory_bytes: 0
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;
#define LOCAL
#define ff first
#define se second
#define all(a) begin(a), end(a)
#define mod 1e9 + 7
#define rep(i, n) for (int i = 0; i < )
typedef vector<int> VI;
typedef long long ll;

ll gcd(ll a, ll b) {
    a = abs(a), b = abs(b);
    while (b != 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

#ifdef LOCAL

void solve() {
    ll n;
    cin >> n;
    unordered_map<ll, ll> h;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        h[t]++;
        sum += t;
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        sum -= h[b] * b;
        sum += h[b] * c;
        h[c] += h[b];
        h[b] = 0;
        cout << sum << endl;
    }

}

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

#endif


Measured memory_bytes: 8072
import java.util.Scanner;
public class Main {
	
	
	void main() {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] a = new int[n];
	for(int i = 0; i < a.length; i++) {
		a[i] = sc.nextInt();
	
	}
	System.out.print(a[a.length-1]);
	for(int i = a.length-2; i>=0; i--) {
		System.out.print(" "+a[i]);
	}
	System.out.println();
	}
	
	public static void main(String[] args) {
		new Main().main();
	}
	
	}

	
	


Measured memory_bytes: 26164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    vector<int> arr(3*n);
    for(int i = 0; i < 3*n; ++i)
        scanf("%d",&arr[i]);
    sort(arr.begin(),arr.end());
    ll ans = 0;
    for(int i = 3*n-2; i >= n; i-=2)
        ans += arr[i];
    cout << ans << '\n';
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using vpi = vector<pair<int, int>>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int n; cin >> n;
    vi a(n);
    F0R (i, n) cin >> a[i];

    ll ans = 0;
    map<int, int> count;
    count[a[0]] = 1;
    FOR (i, 1, n - 1) {
        ans += count[i - a[i]];
        count[i + a[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21056
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
        cout<<fixed;
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
typedef vector<V> VV;
VV G;
int a[112345];
int b[112345];
double c[112345];
double f[112345];
double g[112345];
double P;
double dfs1(int v,int p){
    double& res=f[v];
    res=0;
    for(auto &e:G[v]){
            int u=a[e]^b[e]^v;
            if(u==p)continue;
            res+=dfs1(u,v)+c[e];
        }
    res*=P;
    return  res;
}
double dfs2(int v,int p){
    double &res=g[v];
    res=0;
    for(auto &e:G[v]){
            int u=a[e]^b[e]^v;
            if(u==p)continue;
            res+=dfs2(u,v)+c[e];
        }
    res*=P;
    res+=f[1];

    return  res;
}

int main(){
    cin>>P;
    int N;
    cin>>N;
    G.resize(N+1);
    REP(i,N-1){
        cin>>a[i]>>b[i]>>c[i];
        G[a[i]].pb(i);
        G[b[i]].pb(i);
    }
    dfs1(1,1);
    cout<<dfs2(1,1)<<endl;
    return 0;
}

Measured memory_bytes: 16052
import java.util.Scanner

object Main extends App {

  def readALine(c:Int, ac:List[Int]=Nil):List[Int] =
    if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse
  // def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =
  //   if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse
  val sc = new Scanner(System.in)
  val N = sc.nextLong

  def power(base:Int, exp:Int):Long = {
    def iter(f:Long, e:Int, ac:Long):Long = {
      if (e==0) ac else {
        val e_ = e >> 1
        val f_ = f*f
        if ((e & 1) > 0) iter(f_, e_, ac*f) else iter(f_, e_, ac)
      }
    }
    iter(base, exp, 1)
  }

  val divisor = 26

  def solver(n:Long, al:List[Int]):List[Int] = {
    // println(s"debug n:$n al:$al")
    if (n < divisor && n / divisor ==0)
      (n % divisor).toInt::al
    else
      solver((n-divisor)/divisor, ((n-divisor) % divisor).toInt::al)
  }

  println(solver(N-1, Nil).map((x)=>(x+97).toChar).mkString(""))

}

Measured memory_bytes: 55392
public class Main {
  public static void main(String[] args) {
    String S = new java.util.Scanner(System.in).nextLine();
    switch (S) {
      case "ABC":
       System.out.println("ARC");
       break;
      case "ARC":
       System.out.println("ABC");
       break;
    }
  }
}


Measured memory_bytes: 35500
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define D deque
#define PII pair<int, int>
#define P pair
#define DB double
#define LDB long double
#define FOR(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define FFOR(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define RFOR(i, n) for (int(i) = (n)-1; (i) >= 0; --(i))
#define all(grid) (grid).begin(), (grid).end()
#define rall(grid) (grid).rbegin(), (grid).rend()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

template <typename T>
void read(T& a) {
  a = 0;
  char c;
  while ((c = cin.peek()) < 48 or c > 57) cin.get();
  while ((c = cin.get()) > 47 and c < 58) a = (a << 3) + (a << 1) + c - 48;
}

template <typename T, typename... Args>
void read(T& a, Args&&... args) {
  read(a);
  read(forward<Args>(args...)...);
}

template <typename T>
void write(const S& sep, const S& end, T n) {
  char c[128] = {0};
  int i = 0;
  for (; n; ++i, n /= 10) c[i] = n % 10;

  for (--i; i >= 0; --i) cout.put(c[i] + 48);

  cout.write(end.c_str(), end.size() * sizeof(char));
}

template <typename T, typename... Args>
void write(const S& sep, const S& end, T n, Args&&... args) {
  char c[128] = {0};
  int i = 0;
  for (; n; ++i, n /= 10) c[i] = n % 10;

  for (--i; i >= 0; --i) cout.put(c[i] + 48);

  cout.write(sep.c_str(), sep.size() * sizeof(char));
  write(sep, end, forward<Args>(args...)...);
}
void solve() {
  int p, n;
  cin >> p >> n;
  int prev, first;
  cin >> prev;
  first = prev;
  VI v;
  FOR(i, n - 1) {
    int t;
    cin >> t;
    v.push_back(t - prev);
    prev = t;
  }
  v.push_back(p - prev + first);
  cout << accumulate(all(v), 0) - *max_element(all(v)) << "\n";
}

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


Measured memory_bytes: 4276
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	long long sum=0;
	long long n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;i++){
		sum+=a[i];
	}
	cout<<sum;

}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll G[100010];
    ll N,K;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>K;
    REP(i,N){
        int a,b;
        cin>>a>>b;
        G[a]+=b;
    }
    ll yui=0;
    REP(i,100010){
        yui+=G[i];
        if(K<=yui){
            cout<<i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<ll,ll> a;
    ll s=0;
    rep(i,n){
        int x; cin >> x;
        ++a[x];
    }
    for(auto p:a){
        s+=p.first*p.second;
    }
    int q;
    cin >> q;
    vector<ll> b(q);
    vector<ll> c(q);
    rep(i,q) cin >> b[i] >> c[i];
    rep(i,q) {
        s=s-a[b[i]]*(b[i]-c[i]);
        cout << s << "\n";
        a[c[i]]+=a[b[i]];
        a[b[i]]=0;
    }
    return 0;
}

Measured memory_bytes: 10808
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int h=a[0];
    int l=a[0];
    long t=0;
    for(int i=0;i<n;i++){
        t=t+a[i];
        if(i>0){
            if(a[i]<l){
                l=a[i];
            }
            if(a[i]>h){
                h=a[i];
            }
        }
    }
    cout<<l<<" "<<h<<" "<<t<<endl;
}


Measured memory_bytes: 3144