akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a(m);
    vector<int> s(2 * m);
    int c = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> a.at(i).first >> a.at(i).second;
        if (a.at(i).first == 1)
        {
            s.at(c) = (a.at(i).second);
            c++;
        }
        if (a.at(i).second == n)
        {
            s.at(c) = (a.at(i).first);
            c++;
        }
    }
    sort(s.rbegin(), s.rend());
    int nnn = s.size();
    int count = 0;
    for (int i = 0; i < nnn - 1; i++)
    {

        if (s[i + 1] == 0)
        {
            break;
        }
        if (s[i] == s[i + 1])
        {
            count++;
        }
    }
    if (count == 0)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << "POSSIBLE" << endl;
    }
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int mx(int a,int b,int c){
  int d,e;
  d=max(a,b);
  e=max(d,c);
  return e;
  }
int main(){
  int a,b,c,sum,x;
  cin>>a>>b>>c;
  sum=a+b+c;
  x=sum-mx(a,b,c);
  cout<<x;
  return 0;
}

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

int main(int argc, char const *argv[]) {
  char A;
  string a;
  for(int i = 0;i < 3;i++) {
    cin >> a;
    if(i == 1) {
      A = a.at(0);
    }
  }
  cout << "A" << A << "C" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>           // printf(), scanf(), getc()
#include <cctype>           // isdigit()
#include <vector>
#include <queue>
#include <algorithm>        // max()

using namespace std;

static const int MAX_N = 100000;
static const int INFTY = 1 << 30;

class edge
{
public:
	int t, w;
	edge() {}
	edge(int t, int w): t(t), w(w) {}
};

vector<edge> G[MAX_N];
int n;
int d[MAX_N];

bool vis[MAX_N];
int count;

void
bfs(int s)
{
	for (int i = 0; i < n; ++i)
		d[i] = INFTY;

	queue<int> Q;
	Q.push(s);
	d[s] = 0;
	while(!Q.empty())
	{
		int u = Q.front(); Q.pop();
		for (unsigned int i = 0; i < G[u].size(); ++i)
		{
			edge e = G[u][i];
			if (d[e.t] == INFTY)
			{
				d[e.t] = d[u] + e.w;
				Q.push(e.t);
			}
		}
	}
}

int
solve()
{
	// ??????????????? s ???????????????????????? tgt ????±???????
	bfs(0);
	int maxv = 0;
	int tgt = 0;
	for (int i = 0; i < n; ++i)
	{
		if (d[i] != INFTY && d[i] > maxv)
		{
			maxv = d[i];
			tgt = i;
		}
	}

	// tgt ????????????????????????????????¢ maxv ????±???????
	bfs(tgt);
	maxv = 0;
	for (int i = 0; i < n; ++i)
	{
		if (d[i] != INFTY)
			maxv = max(maxv, d[i]);
	}

	return maxv;
}

int
main(int argc, char** argv)
{
	int s, t, w;
	int x;
	int c;

	scanf("%d", &n);
	c = getc(stdin);
	for (int i = 0; i < n - 1; ++i)
	{
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		x = 0;
		while (isdigit(c))
		{
			x = x * 10 + c - '0';
			c = getc(stdin);
		}

		s = x;
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		x = 0;
		while (isdigit(c))
		{
			x = x * 10 + c - '0';
			c = getc(stdin);
		}

		t = x;
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		x = 0;
		while (isdigit(c))
		{
			x = x * 10 + c - '0';
			c = getc(stdin);
		}

		w = x;
		G[s].push_back(edge(t, w));
		G[t].push_back(edge(s, w));
	}

	printf("%d\n", solve());
	return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


bool isprime(int  n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;
    else
        for (int i = 3; i*i <= n; i++)
            if (n%i == 0) return false;

    return true;
}

signed main(){
    int X;
    cin >> X;
    for(int n=X;; n++){
        if(isprime(n)){cout << n << endl; return 0;}
    }
}


Measured memory_bytes: 256
p,a,b = map(int,input().split())
if(a<=b):
  if(a>=p):
    print(1)
  else:
  	print(-1)
else:
  p-=a
  up=a-b
  if(p<=0):
    print(1)
  else:
  	num=p//up+(p%up!=0)
  	print(num*2+1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,ans;
  cin>>N>>K;
  ans=N; 
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
  }
  sort(h.begin(),h.end());
  for(int i=0;i<N;i++){
    if(h.at(i)<K){
      ans--;
    }
    else{
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i]!=s[j]:
            x = 2*j-i
            if x<n and s[i]!=s[x] and s[j]!=s[x]:
                ans -= 1
print(ans)

Measured memory_bytes: 9180
N = int(input())
d = {}
for i in range(1, N+1):
  i = str(i)[0] + str(i)[-1]
  d[i] = d.get(i, 0) + 1
ans = 0
for i in map(str, range(1, 10)):
  for j in map(str, range(1, 10)):
    ans += d.get(i+j, 0) * d.get(j+i, 0)
print(ans)

Measured memory_bytes: 3064
for $*IN.lines() -> $line { 
    if ($line == 25) {
    say "Christmas";
	}
	if ($line == 24) {
    	say "Christmas Eve";
	}
	if ($line == 23) {
    	say "Christmas Eve Eve";
	}
	if ($line == 22) {
    	say "Christmas Eve Eve Eve";
	}
} 


Measured memory_bytes: 65696
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int q = Integer.parseInt(sc.next());
        Integer[] l = new Integer[q];
        Integer[] r = new Integer[q];
        for (int i = 0; i < q; i++) {
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int[] count = new int[100001];
        for (int i = 1; i <= 100000; i++) {
            count[i] = count[i - 1];
            if (isPrime(i) && isPrime((i + 1) / 2)) {
                count[i]++;
            }
        }

        // 出力
        for (int i = 0; i < q; i++) {
            System.out.println(count[r[i]] - count[l[i] - 1]);
        }
    }

    public static boolean isPrime(long num) {
        if (num == 2) {
            return true;
        } else if (num < 2 || num % 2 == 0) {
            return false;
        }
        double sqrtNum = Math.sqrt(num);
        for (long i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 64640
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)3e5 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = 1000000007;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

int count_bit(int x) {
    int ret = 0;
    while (x > 0) {
        if (x&1) {
            ++ret;
        }
        x >>= 1;
    }
    return ret;
}
int main() {
//    freopen("../in.txt", "r", stdin);
    int n, a[18], x[18][18], y[18][18];
    read(n);
    for (int i = 0; i < n; ++i) {
        read(a[i]);
        for (int j = 0; j < a[i]; ++j) {
            read(x[i][j]);
            --x[i][j];
            read(y[i][j]);
        }
    }
    int ans = 0;
    int sit[18];
    bool vis[18];
    for (int i = (1<<n)-1; i >= 1; --i) {
        int tmp = count_bit(i);
        if (tmp <= ans) {
            continue;
        }
        memset(sit, -1 , sizeof(sit));
        memset(vis, 0, sizeof(vis));
        queue<int> Q;
        bool flag = true;
        for (int j = 0; j < n; ++j) {
            if ((i>>j)&1) {
                vis[j] = true;
                Q.push(j);
                sit[j] = 1;
            }
        }
        while (!Q.empty() && flag) {
            int j = Q.front(); Q.pop();
            for (int k = 0; k < a[j]; ++k) {
                if (sit[x[j][k]]==-1) {
                    sit[x[j][k]] = y[j][k];
                    if (y[j][k] == 1 && !vis[x[j][k]]) {
                        Q.push(x[j][k]);
                        vis[x[j][k]] = true;
                    }
                } else if (sit[x[j][k]] != y[j][k]) {
                    flag = false;
                    break;
                }
            }
        }
        if (!flag) {
            continue;
        }
        if (flag) {
            ans = tmp;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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


void solve()  
{
	ll n; cin>>n;
	ll ans=n*(n-1)/2;
	cout<<ans<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T; 
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

class AServalVsMonster {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		int a,b;cin >> a >> b;
		cout << (a+b-1)/b << endl;
	}
};


int main() {
	AServalVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a % b << " ";
	printf("%.10f", (double)a / (double)b);
	cout << endl;
}


Measured memory_bytes: 3232
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    k = int((N*2)**(1/2))
    if N*2 != k*(k+1):
        print("No")
    else:
        print("Yes")
        l = [[0 for _ in range(k)] for _ in range(k+1)]
        for i in range(k):
            for j in range(k-i):
                if i == 0:
                    l[i][j] = j+1
                    l[j+1][i] = j+1
                else:
                    l[i][i+j] = 1+(k+1)*i-i*(i+1)//2+j
                    l[i+j+1][i] = 1+(k+1)*i-i*(i+1)//2+j
        print(k+1)
        for i in range(k+1):
            print(k,*l[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 12484
/*
ABHIJEET BISWAS
CSE 4th SEM 
MNNIT ALLAHBAD
https://atcoder.jp/contests/dp/tasks/dp_b
VER : AC
*/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define f first
#define s second
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ld pi=2.0*acos(0.0);
ll dp[MAX];
ll arr[MAX];
int n,k;
ll solve(int v)
{
	if(v>n)
	return INF;
	if(v==n)
	return 0;
	if(dp[v]!=-1)
	return dp[v];
	dp[v]=INF;
	for(int i=1;i<=k;i++)
	if(v+i<=n)
	dp[v]=min(dp[v],abs(arr[v]-arr[v+i])+solve(v+i));
	return dp[v];
}
int main() {
	fastIO
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>arr[i];
	for(int i=0;i<=n;i++)
	dp[i]=-1;
	cout<<solve(1);
	return 0;
}

Measured memory_bytes: 9856
N=int(input())
h=list(map(int,input().split()))
ans=0
flag=True
f=-1
e=N-1

for i in range(N):
    if h[i]>0:
        f=0
if f<0:
    print(0)
    exit()

while(flag):
    F=False
    E=False
    for i in range(N):
        if not F:
            if h[i]>0:
                f=i
                F=True
    for i in range(f,N):
        if not E:
            if h[i]==0:
                e=i-1
                E=True

    #print(f)
    #print(e)
    if f>e:
        e=N-1
    for i in range(f,e+1):
        h[i]-=1
    ans+=1
    #print(h)
    flag=False
    for i in range(N):
        if h[i]>0:
            flag=True
print(ans)


Measured memory_bytes: 42092
import java.util.Scanner;

public class Main {
public static void main(String args[])
{
	Scanner scan=new Scanner(System.in);
	int n=scan.nextInt();
	int h[]=new int[n];
	for(int i=0;i<n;i++)
	{
		h[i]=scan.nextInt();
	}
	long dp[]=new long[n];
	dp[0]=0;
	dp[1]=Math.abs(h[1]-h[0]);
	//dp[2]=Math.min(Math.abs(h[2]-h[1]+dp[1]),Math.abs(h[2]-h[0]+dp[0]));
	for(int i=2;i<n;i++)
	{
		dp[i]=Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
//		System.out.println(dp[i]);
	}
	System.out.println(dp[n-1]);
	
}
}


Measured memory_bytes: 51132
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    auto N = in.read<std::uint64_t>();

    auto res = std::numeric_limits<std::uint64_t>::max();
    for (auto i : boost::irange(std::uint64_t{1}, static_cast<std::uint64_t>(std::ceil(std::sqrt(N)) + 1))) {
        if (N % i) continue;
        res = std::min(res, (N / i) + i - 2);
    }
    out << res;

    return 0;
}


Measured memory_bytes: 256
dm = {'N': (0, 1), 'S': (0, -1), 'E': (1, 0), 'W': (-1, 0)}

while True:
    n = int(input())
    if not n:
        break
    plain = [[False] * 21 for _ in range(21)]
    for _ in range(n):
        x, y = map(int, input().split())
        plain[x][y] = True

    cx, cy = 10, 10
    plain[10][10] = False

    m = int(input())
    for _ in range(m):
        d, l = input().split()
        dx, dy = dm[d]
        for _ in range(int(l)):
            cx += dx
            cy += dy
            plain[cx][cy] = False

    for p in plain:
        if any(p):
            print('No')
            break
    else:
        print('Yes')

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    vector<string> C(2);
    cin>>C[0]>>C[1];
    vector<string> R = C;
    reverse(ALL(R[0]));
    reverse(ALL(R[1]));
    reverse(ALL(R));
    if (C == R) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
# F - Sugoroku
N, M = map(int, input().split())
S = str(input())

disable = False
answer = []
i = N
while i > 0:
    if i <= M:
        answer.append(i)
        break
        
    move = M
    while S[i - move] == "1":
        move -= 1

    if move == 0:
        disable = True
        break
        
    answer.append(move)
    i -= move
    
if disable:
    print(-1)
else:
    L = len(answer)
    for j in range(L):
        print(answer[L - j - 1], end=" ")

Measured memory_bytes: 4848
function main(input){
  const lines = input.split('\n');
  const R = lines[0].split(' ').map(x => parseInt(x))[0];
  const G = lines[0].split(' ').map(x => parseInt(x))[1];
  const B = lines[0].split(' ').map(x => parseInt(x))[2];
  const N = lines[0].split(' ').map(x => parseInt(x))[3];

  var result = 0;
  const R_limit=Math.max(Math.ceil(N/R),1);
  const G_limit=Math.max(Math.ceil(N/G),1);
  const B_limit=Math.max(Math.ceil(N/B),1);
  for(var r=0;r<=R_limit;r++){
    for(var g=0;g<=G_limit;g++){
      if(r*R + g*G>N){break;}
        if((N-(r*R + g*G))%B==0){result++;}
//        if((N-(r*R + g*G))%B==0){console.log([r,g,(N-(r*R + g*G))/B]);}
    }
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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


int main() {
    int n;
    ll a, min = 10000000, max = -10000000, sum = 0;
    char op;
    cin >> n;
    rep(i,n) {
      cin >> a;
      if (a < min) min = a;
      if (a > max) max = a;
      sum += a;
    }
    cout << min << " " << max << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3116
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    s = min(s, 2 * h, 4 * q)
    d = min(d, s * 2)
    print((n // 2) * d + (n % 2) * s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import math
N, K = map(int, input().split())
BCs = [(b,a*b) for a,b in zip(sorted(list(map(int, input().split()))), sorted(list(map(int, input().split())))[::-1])]

def f(target):
    return sum(math.ceil(max(0, c - target)/b)for b, c in BCs)<=K

if __name__ == '__main__':
    min_i, max_i, index = 0, 10**12, 1
    while True:
        index, max_i, min_i = ((index-1 + min_i)//2, index-1, min_i) if f(index) else ((index+1 + max_i)//2, max_i, index+1)
        if min_i > max_i:
            print(min_i)
            break

Measured memory_bytes: 123212
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

template <class T> void dump(const vector<T>& vec) {
  for(const T& value : vec) {
    cout << value << " ";
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  
  // できるだけ大きい色を塗りたい
  // 1 100 2 101 3 103 だと
  // 1 100 101 102, 2 3 の2色にする
  // 2分探索して、
  // 1. 最小の末尾より小さい場合は、新しい色
  // 2. それ以外は、見つかる中で最大の末尾に追加
  
  vector<int> colors; // 各色の現在の最大値を保管。降順に並ぶ
  int a;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    auto ite = upper_bound(colors.begin(), colors.end(), a, greater<>());
    if (ite == colors.end()) {
      colors.push_back(a);
    } else {
      *ite = a;
    }
    
    // dump(colors);
  }

  cout << colors.size() << endl;

  return 0;
}

Measured memory_bytes: 892
import sys
import numpy as np

def fft_convolve(f, g):
    """
    数列 (多項式) f, g の畳み込みの計算．上下 15 bitずつ分けて計算することで，
    30 bit以下の整数，長さ 250000 程度の数列での計算が正確に行える．
    """
    fft = np.fft.rfft
    ifft = np.fft.irfft
    Lf = len(f)
    Lg = len(g)
    L = Lf + Lg - 1
    fft_len = 1 << L.bit_length()
    fl = f & (1 << 15) - 1
    fh = f >> 15
    gl = g & (1 << 15) - 1
    gh = g >> 15

    def conv(f, g):
        return ifft(fft(f, fft_len) * fft(g, fft_len))[:L]

    x = conv(fl, gl)
    y = conv(fl + fh, gl + gh)
    z = conv(fh, gh)
    a, b, c = map(lambda x: (x + .5).astype(np.int64), [x, y, z])
    return (a + ((b - a - c) << 15) + (c << 30))


ROOT=2
P=200003
pw=[1]*(P-1)
lg=[-1]*P

for i in range(1,len(pw)):
    pw[i]=ROOT*pw[i-1]%P
for i in range(len(pw)):
    lg[pw[i]]=i

N=int(input())
A=np.array([int(x) for x in input().split()],dtype=np.int64)
B=[0]*P
for a in A:
    if a==0:
        continue
    B[lg[a]]+=1
B=np.array(B,dtype=np.int64)
C=fft_convolve(B,B)
for i in range(P-1,len(C)):
    C[i%(P-1)]+=C[i]
C=C[:P-1]

ans=0
for i in range(len(B)):
    C[2*i%(P-1)]-=B[i]*B[i]
    ans+=B[i]*(B[i]-1)//2*pw[2*i%(P-1)]
for i in range(len(C)):
    C[i]//=2

for i in range(len(C)):
    ans+=pw[i]*C[i]

print(ans)

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

int main() {
  int a, b ,c;
  cin >> a >> b >> c;
  
  if ((a+b == c) || (a+c == b) || (b+c == a)) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s[1002];

const int MOD=1e9+7;
int dp[1002][1002];
int main()
{
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;i++)
   cin>>s[i];
  dp[0][0]=1;
  for(int i=0;i<h;i++)
  {
     for(int j=0;j<w;j++)
     {
       if(s[i][j]=='#')
       {
          dp[i][j]=0;
         continue;
       }
      if(i>0) dp[i][j]+=dp[i-1][j];
       dp[i][j]%=MOD;
      if(j>0) dp[i][j]+=dp[i][j-1];
       dp[i][j]%=MOD;
       
     }
  }
  cout<<dp[h-1][w-1];
  
}

Measured memory_bytes: 9480
INF=10**30
def Belman_Ford(s,N,Edge):
    dist=[INF]*N
    neg=[False]*N
    dist[s]=0
    for i in range(N-1):
        for f,t,c in Edge:
            if dist[t]>dist[f]+c and dist[f]!=INF:
                dist[t]=min(dist[t],dist[f]+c)
    for i in range(N):
        for f,t,c in Edge:
            if dist[t]>dist[f]+c and dist[f]!=INF:
                dist[t]=dist[f]+c
                neg[t]=True
            if neg[f]:
                neg[t]=True
    return dist,neg
                
N,M=map(int,input().split())
Edge=[]
for i in range(M):
    a,b,c=map(int,input().split())
    Edge.append((a-1,b-1,-c))
dist,neg=Belman_Ford(0,N,Edge)

if(neg[N-1]):
    print('inf')
else:
    print(-dist[N-1])

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

template <unsigned m> struct Mint {
    Mint():val(0){}
    Mint(int raw):val((raw%m+m)%m){}
    Mint(long long raw):val((raw%m+m)%m){}
    Mint(unsigned raw):val(raw%m){}
    Mint(unsigned long long raw):val(raw%m){}
    friend Mint operator+(Mint a, Mint b) { return a.val + b.val; }
    friend Mint operator-(Mint a, Mint b) { return m + a.val - b.val; }
    friend Mint operator*(Mint a, Mint b) { return 1ll * a.val * b.val; }
    friend Mint operator/(Mint a, Mint b) { return a * qpow(b, m-2); }
    friend Mint& operator+=(Mint& a, Mint b) { return a = a + b; }
    friend Mint& operator-=(Mint& a, Mint b) { return a = a - b; }
    friend Mint& operator*=(Mint& a, Mint b) { return a = a * b; }
    friend Mint& operator/=(Mint& a, Mint b) { return a = a / b; }
    friend bool operator==(Mint a, Mint b) { return a.val == b.val; }
    friend bool operator!=(Mint a, Mint b) { return a.val != b.val; }
    friend ostream& operator<<(ostream& out, Mint x) { return out << x.val; }
    unsigned val;
};

struct Dummyf { template <typename... Ts> void operator()(Ts&&...) {} };

struct Graph {
	Graph(int n):edges(n){}
	void addEdge1(int a, int b) { edges[a].push_back(b); }
	void addEdge2(int a, int b) { addEdge1(a, b); addEdge1(b, a); }
	int size() const { return (int)edges.size(); }
    template <typename Pre=Dummyf, typename Post=Dummyf, typename PreE=Dummyf, typename PostE=Dummyf, typename FailE=Dummyf> void DFS(int source, Pre pre, Post post, PreE pree, PostE poste, FailE faile) const {
        auto visit = vector<bool>(size(), false);
        implDFS(source, visit, pre, post, pree, poste, faile);
    }
    template <typename Pre=Dummyf, typename Post=Dummyf, typename PreE=Dummyf, typename PostE=Dummyf, typename FailE=Dummyf> void implDFS(int v, vector<bool>& visit, Pre pre, Post post, PreE pree, PostE poste, FailE faile) const {
        visit[v] = true;
        pre(v);
        for (auto u : edges[v])
            if (not visit[u])
                pree(v, u), implDFS(u, visit, pre, post, pree, poste, faile), poste(v, u);
            else
                faile(v, u);
        post(v);
    }
	vector<vector<int>> edges;
};

using M = Mint<1'000'000'000 + 7>;

Graph loadEdges(int n, int m) {
    auto g = Graph(n);
    for (auto i=0; i<m; ++i)
        g.addEdge2(load<int>()-1, load<int>()-1);
    return g;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto n = load<int>();
    auto tree = loadEdges(n, n-1);    
    auto dyn = vector<array<M, 2>>(n, {1, 1});
    tree.DFS(0, {}, {}, {}, [&](int v, int u){
        dyn[v][0] *= dyn[u][0] + dyn[u][1];
        dyn[v][1] *= dyn[u][0];
    }, {});
    auto answer = dyn[0][0] + dyn[0][1];
    cout << answer << '\n';
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
int x[150][150][2],n,m,l,a,b,c,d,i,j,k,o,minx,INF=1<<25,dp[150][150];
int DP(int p,int v){
    memset(dp,127,sizeof(dp));
    dp[0][v]=0;
    for(i=0;i<p;i++){
        for(j=0;j<n;j++){
            for(k=0;k<n;k++){
                if(x[j][k][0]<INF){
                    for(o=0;o<=v;o++){
                        if(dp[j][o]<INF){
                            dp[k][o]=min(dp[k][o],dp[j][o]+x[j][k][1]);
                            if(o>=x[j][k][0]){
                                dp[k][o-x[j][k][0]]=min(dp[k][o-x[j][k][0]],dp[j][o]);
                            }
                        }
                    }
                }
            }
        }
    }
    minx=INF;
    for(i=0;i<=v;i++){
        minx=min(minx,dp[p-1][i]);
    }
    return minx;
}
main(){
    while(1){
        memset(x,127,sizeof(x));
        cin>>n>>m>>l;
        if(!n){break;}
        for(i=0;i<m;i++){
            cin>>a>>b>>c>>d;
            a--;
            b--;
            x[a][b][0]=c;
            x[a][b][1]=d;
            x[b][a][0]=c;
            x[b][a][1]=d;
        }
        cout<<DP(n,l)<<endl;
    }
}

Measured memory_bytes: 1432
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let n = get!(i64);

    if n == 1 {
        println!("Hello World");
    } else {
        let a = get!(i64);
        let b = get!(i64);
        println!("{}", a + b);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
	int count=0;
	unsigned long money=100,X=0;
	cin>>X;
	while(1){
		count++;
		money *= 1.01;
		if(money>=X) break;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
typedef unsigned long long ull;
ull B=5575777;
ull ans=0;
int n,a,b;
vector<int> G[MAX_N];
map<ull,ull> mp;

ull dfs(int pos){
  ull res=0;
  for(int i=0;i<(int)G[pos].size();i++)
    res+=dfs(G[pos][i]);
  res=res*B+1;
  ans+=mp[res];
  mp[res]++;
  return res;
}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n-1;i++){
    scanf("%d %d",&a,&b);
    G[a].push_back(b);
  }
  dfs(1);
  printf("%lld\n",ans);
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n;
    string s;
    cin >> n >> s;
    
    vector<int> B(n+1), W(n+1);
    rep(i, n) {
        if(s[i] == '#') B[i+1] = B[i]+1;
        else B[i+1] = B[i];
    }
    for(int i = n-1; i >= 0; i--) {
        if(s[i] == '.') W[i] = W[i+1]+1;
        else W[i] = W[i+1];
    }
    int ans = INF;
    rep(i, n+1) ans = min(ans, W[i]+B[i]);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 2196
import math
while 1:
    r0,w0,c,r=map(int,input().split())
    if r0==w0==c==r==0:break
    r1=w0*c
    if r1<=r0:print("0")
    else:
        nw=r1-r0
        print(math.ceil(nw/r))


Measured memory_bytes: 5660
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint p(int n, int k)
    {
        return fact[n] * ifact[n - k];
    }
} c(1000005);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int S;
    cin >> S;
    mint ans = 0;
    for (int i = 0; i < S / 3; i++)
    {
        int boxNum = i + 1;
        int newS = S - 3 * boxNum;
        mint tmp = c(newS + boxNum - 1, boxNum - 1);
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18636
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int W, H, i;
	scanf("%lld%lld", &W, &H);
	vector<int> p(W), q(H);
	for(i = 0; i < W; i++){
		scanf("%lld", &p[i]);
	}
	for(i = 0; i < H; i++){
		scanf("%lld", &q[i]);
	}
	vector<pair<int, pair<int, int>>> es(0);
	for(i = 0; i < W; i++){
		es.push_back(pair<int, pair<int, int>>(p[i], pair<int, int>(0, i)));
	}
	for(i = 0; i < H; i++){
		es.push_back(pair<int, pair<int, int>>(q[i], pair<int, int>(1, i)));
	}
	sort(es.begin(), es.end());
	int connect_num[2] = {W + 1, H + 1};
	int ans = 0;
	for(i = 0; i < W + H; i++){
		int cost = es[i].first, d = es[i].second.first, k = es[i].second.second;
		ans += connect_num[1 - d] * cost;
		connect_num[d]--;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 10096
N = int(input())
A = list(map(int, input().split()))
avg = [0] * N

avg[0] = sum(A) - 2 * (sum([A[i] for i in range(N) if i % 2 == 1]))

for i in range(N - 1):
    avg[i + 1] = 2 * A[i] - avg[i]

print(" ".join(map(str, avg)))


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

int main() {
int a,b,c,d;
  cin>>a>>b>>c>>d;
  int m,n;
  n=(c+b-1)/b;
  m=(a+d-1)/d;
  if(n<=m){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

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

  vector<int> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }

  int result = gcd(A[0], A[1]);
  for (int i = 2; i < N; i++)
  {
    result = gcd(result, A[i]);
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 640
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, h[100010];

signed main() {
    cin >> N;
    rep(i,0,N) cin >> h[i];
    h[N] = 0;
    int ans = 0;

    // height, position
    stack<pii> S;
    rep(i,0,N+1) {
        if(S.empty()) S.push(pii(h[i], i));

        pii temp = S.top();
        if(temp.first < h[i]) S.push(pii(h[i], i));
        else if(temp.first > h[i]) {
            int lastpos = 0;
            while(!S.empty() && S.top().first >= h[i]) {
                lastpos = S.top().second;
                chmax(ans, S.top().first * (i-lastpos));
                // printf("width = %lld, height = %lld\n", i-lastpos, S.top().first);
                S.pop();
            }
            S.push(pii(h[i], lastpos));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5260
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int N, M;
int G[205][205];
map<string, int> mp;
vector<int> g[205];
int V;
bool used[205];
int color[205];

bool dfs(int v, int t)
{
	used[v] = true;
	if(v == t) return true;
	
	bool ret = false;
	for(int i = 0; i < g[v].size(); i++){
		if(used[g[v][i]]) continue;
		ret |= dfs(g[v][i], t);
	}
	return ret;
}

void color_dfs(int v, int c)
{
	color[v] = c;
	for(int i = 0; i < g[v].size(); i++){
		if(color[g[v][i]]) continue;
		color_dfs(g[v][i], -c);
	}
}

int main(void)
{
	while(1){
		cin >> N;
		if(N == 0) break;
		for(int i = 1; i <= 200; i++){
			for(int j = 1; j <= 200; j++){
				G[i][j] = 0;
			}
		}
		
		int id = 1;
		string s, t;
		mp.clear();
		for(int i = 0; i < N; i++){
			cin >> s;
			for(int j = 0; j < s.size(); j++){
				if(s[j] == '-'){
					t = s.substr(j+1);
					s = s.substr(0, j);
					break;
				}
			}
			if(mp.count(s) == 0) mp[s] = id++;
			if(mp.count(t) == 0) mp[t] = id++;
			G[mp[s]][mp[t]] = 1;
		}
		V = id-1;
		cout << V << endl;
		
		for(int i = 1; i <= V; i++) g[i].clear();
		for(int i = 1; i <= V; i++){
			for(int j = 1; j <= V; j++){
				if(G[i][j]){
					g[i].push_back(j);
					g[j].push_back(i);
				}
			}
		}
		
		for(int i = 1; i <= V; i++) color[i] = 0;
		for(int i = 1; i <= V; i++){
			if(!color[i]) color_dfs(i, 1);
		}
		
		for(int i = 1; i <= V; i++){
			for(int j = 1; j <= V; j++){
				if(i >= j) continue;
				if(G[i][j]) continue;
				
				bool flag = false;
				for(int k = 1; k <= V; k++){
					if(G[i][k] == 1 && G[j][k] == 1){
						flag = true;
						break;
					}
					if(G[k][i] == 1 && G[k][j] == 1){
						flag = true;
						break;
					}
				}
				if(!flag) continue;
				
				flag = true;
				for(int k = 1; k <= V; k++){
					if(G[i][k] == 1 && G[k][j] == 1){
						flag = false;
						break;
					}
					if(G[k][i] == 1 && G[j][k] == 1){
						flag = false;
						break;
					}
				}
				if(flag) G[i][j] = G[j][i] = 2;
			}
		}
		
		for(int i = 1; i <= V; i++){
			g[i].clear();
			for(int j = 1; j <= V; j++){
				if(G[i][j]) g[i].push_back(j);
			}
		}
		
		cin >> M;
		for(int i = 0; i < M; i++){
			cin >> s;
			for(int j = 0; j < s.size(); j++){
				if(s[j] == '-'){
					t = s.substr(j+1);
					s = s.substr(0, j);
					break;
				}
			}
			if(mp.count(s) == 0 || mp.count(t) == 0){
				cout << "NO" << endl;
				continue;
			}
			int S = mp[s], T = mp[t];
			
			if(color[S] == color[T]){
				cout << "NO" << endl;
				continue;
			}
			
			for(int i = 1; i <= V; i++) used[i] = false;
			if(dfs(S, T)) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 3388
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author koneko096
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    EThisMessageWillSelfDestructIn5s solver = new EThisMessageWillSelfDestructIn5s();
    solver.solve(1, in, out);
    out.close();
  }

  static class EThisMessageWillSelfDestructIn5s {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();

      Map<Integer, Integer> L = new HashMap<>();

      long ans = 0;
      for (int i = 0; i < n; i++) {
        int h = in.nextInt();
        int cnt = L.getOrDefault(i - h, 0);
        ans += cnt;
        L.put(i + h, L.getOrDefault(i + h, 0) + 1);
      }
      out.println(ans);
    }

  }


  static class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

  }
}



Measured memory_bytes: 56608
#include "bits/stdc++.h"

using namespace std;

int main()
{
    int n;
    cin >>n;
    vector<pair<int ,int> > p(n);
    int a[n];
    for(int i=0;i<n;i++){
        cin >>a[i];
        p[i]=make_pair(a[i],i+1);
    }
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++){
        cout << p[i].second<< endl;
    }
    return 0;
}


Measured memory_bytes: 2048
// template {{{

#include <bits/stdc++.h>

// #define int long long

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP2(i, n) REP3(i, 0, n)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += s)
#define RREP2(i, n) RREP3(i, 0, n)
#define RREP3(i, a, b) for (int i = (b) - 1; i >= (int)(a); i--)

#define rep(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__,, RREP3, RREP2)(__VA_ARGS__)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

template<typename T>
using maxpq = std::priority_queue<T, std::vector<T>, std::less<T>>;

template<typename T>
using minpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

using namespace std;

// }}}

int main()
{
	int dp[400];
	fill_n(dp, 400, -INF);
	dp[0] = 0;

	int n;
	cin >> n;
	rep(i, n){
		int a, b, c;
		cin >> a >> b >> c;
		rep(j, a, b + 1){
			rep(k, 400 - j){
				chmax(dp[k + j], dp[k] + c);
			}
		}
	}

	int m;
	cin >> m;
	vi res;
	rep(i, m){
		int w;
		cin >> w;
		if (dp[w] < 0){
			res.clear();
			res.eb(-1);
			break;
		}
		res.eb(dp[w]);
	}

	for (int x : res) cout << x << endl;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
long long p[200005],q[200005];
main()
{
	int t;
    scanf("%d",&t);
    for(int i = 1;i <= t;i++)
    {
        scanf("%lld",&p[i]);
        q[i]=p[i]+q[i-1];
        p[i]^=p[i-1];
        //printf("%lld %lld\n",p[i],q[i]);
    }
    long long co=0;
    int st=0;
    for(int i  = 1;i <= t;i++)
    {
        // printf("%lld %lld\n",p[i]^p[st],q[i]-q[st]);
        if((p[i]^p[st])!=q[i]-q[st])
        {
            while((p[i]^p[st])!=q[i]-q[st])
            {
                //printf("%d %d\n",i,st);
                st++;
            }
        }
        co+=i-st;
    }
    printf("%lld",co);
}


Measured memory_bytes: 3328