akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll answer = 0;
    if(c*2 >= a+b){
        cout << a*x + b*y << endl;
        return 0;
    }
    answer += min(x,y)*2*c;
    ll larger_price;
    ll amari = max(x,y) - min(x,y);
    if(x > y){
        larger_price = a;
    }
    else{
        larger_price = b;
    }
    if(larger_price <= 2*c){
        answer += amari*larger_price;
    }
    else{
        answer += amari*2*c;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n, a[100000]= {0}, x;
    int i, j, t, d, p=1;

    scanf("%d", &n);
    for( i=1; i<=n; i++)
    {
        scanf("%d", &x);
        if(a[x] == x)
            a[x+1]=x;
        else
            a[x]=x;
    }

    if(n%2)
        d=0;
    else
        d=1;
    for( i=1; i<=n; i++)
    {
        if(a[i] != d)
        {
            p=0;
            break;
        }
        if(n%2)
        {
            if(i%2==1)
                d += 2;
        }
        else
        {
            if(i%2==0)
                d += 2;
        }
        if(i%2==0)
            p = p * 2 %1000000007;
    }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin>>N;
    ll pts = 0;
    set<int> problems;
    for (size_t i = 1; i <= N; i++)
    {
        problems.insert(i);
        pts += i;
        if(pts >= N)
        {
            int j = pts-N;
            problems.erase(j);
            for (auto &&k : problems)
            {
                cout<<k<<endl;
            }
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	cin >> n;
	int t = 0;
	rep(i, 1000001) {
		t *= 10;
		t += 7;
		if(t % n == 0) {
			cout << i+1 << endl;
			return 0;
		}
		//cout << t << endl;
		t %= n;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
 
int main (void){
   int num1,num2,i;
   int count=0;
   scanf("%d %d",&num1,&num2);
   int high[num1];
   for(i=0;i<num1;i++){
       scanf("%d",&high[i]);
       if(high[i]>=num2){
           count++;
       }
   }
   printf("%d",count);
   return 0;
}

Measured memory_bytes: 512
import math
a,b = map(int,input().split())
while b!= 0:
  a,b = b,a%b
n = a
rn = int(math.sqrt(n))
cnt = 1
for i in range(2,rn+1):
    if n%i == 0:
        while n%i == 0:
            n = n//i
        cnt += 1
if n == 1:
    print(cnt)
else:
    print(cnt+1)

Measured memory_bytes: 3064
X = list(map(int,input().split()))
cou5 = 0
cou7 = 0
for i in X:
    if i ==5:
        cou5 +=1
    if i ==7:
        cou7 +=1

if cou5 == 2 and cou7 ==1:
    print("YES")
else:
    print("NO")

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int s[10];
    char c[10];
    rep(i,M) cin >> s[i] >> c[i];
    string s_num;
    int flag = 0;
    queue<int> que;
  	int UPPER = 1;
  	int LOWER = 1;

    rep(i,N-1) LOWER *= 10;
    rep(i,N) UPPER *= 10;
    
    for(int i = 0; i < 1000; i++){
        s_num = to_string(i);
        flag = 1;
        rep(j,M){
            if(s_num[s[j]-1] != c[j]) flag = 0;
        }
        if(i != 0 && i < LOWER) flag = 0;
        if(i == 0 && N != 1) flag = 0;
        if(UPPER <= i) flag = 0;
        if(flag) que.push(i);
    }
    if(que.size()) cout << que.front() << endl;
    else cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, m, l;
    cin >> n >> m >> l;
    vector<vector<PII>> g(n);
    REP(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        if(c > l) continue;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }

    vector<vector<PII>> dist(n, vector<PII>(n, PII(INF, -INF)));
    REP(s, n) {
        using P = pair<PII, ll>;
        priority_queue<P, vector<P>, greater<P>> que;
        dist[s][s] = PII(0, -l);
        que.push({dist[s][s], s});
        while(que.size()) {
            ll mi, rest, v;
            auto temp = que.top(); que.pop();
            tie(mi, rest) = temp.first;
            rest *= -1;
            v = temp.second;
            if(dist[s][v] < PII(mi, -rest)) continue;
            for(auto to: g[v]) {
                PII np(mi, rest);
                if(-dist[s][v].second < to.second) {
                    np.first++;
                    np.second = l - to.second;
                } else {
                    np.second -= to.second;
                }
                np.second *= -1;
                if(dist[s][to.first] > np) {
                    dist[s][to.first] = np;
                    que.push({np, to.first});
                }
            }
        }
    }

    dump(dist);

    ll q;
    cin >> q;
    while(q--) {
        ll s, t;
        cin >> s >> t;
        s--, t--;

        if(dist[s][t].first == INF) cout << -1 << "\n";
        else cout << dist[s][t].first << "\n";
    }
    cout << flush;

    return 0;
}

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...)
#define dump(x)
#define debug(x)
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

class AHarmony {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int A, B;
	    in >> A >> B;
	    if (A > B) swap(A, B);
	    if ((B - A) % 2 == 0) {
	        out << (B + A) / 2 << "\n";
	    } else {
	        out << "IMPOSSIBLE" << "\n";
	    }
	}
};


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


Measured memory_bytes: 256
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 10 ** 9

for i in range(n - k + 1):
    a, b = x[i], x[i + k - 1]
    d = b - a + min(abs(a), abs(b))
    ans = min(ans, d)

print(ans)



Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n , k;
	cin >> n >> k;
	int cnt = 0;
	while(n > 0){
		cnt++;
		n = n / k;
	}
	cout << cnt;
}

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

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main() {

  int N,M;
  
  cin >> N >> M; 
  
  int n = nCr(N,2);

  int m = nCr(M,2);
  
  cout << n+m;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int r = cin.Int();
			Console.WriteLine(r * r);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main(){
  string s;
  cin >> s;
  map<char,bool> mp;
  for(auto i:s){
    mp[i]=true;
  }
  for(char c='a';c<='z';++c){
    if(mp[c]) continue;
    else {
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
char s[262144];
int dp[262144];
int pre[262144];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	scanf("%s",s);
	bool fir=true;
	int num=0;
	int mx=n;
	for(int i=0;i<m;i++)
	{
		if(s[i]==s[0])
		{
			num++;
		}
		else
		{
			if(fir||(num&1))
			{
				if(num<mx)
				{
					mx=num;
				}
			}
			fir=false;
			num=0;
		}
	}
	if(fir)
	{
		for(int i=2;i<=n;i++)
		{
			dp[i]=i;
			dp[i]+=pre[i-2];
			if(dp[i]>=1000000007)
			{
				dp[i]-=1000000007;
			}
			pre[i]=pre[i-1]+dp[i];
			if(pre[i]>=1000000007)
			{
				pre[i]-=1000000007;
			}
		}
		int ans=dp[n]+1;
		if(ans>=1000000007)
		{
			ans-=1000000007;
		}
		printf("%d\n",ans);
		return 0;
	}
	if(n&1)
	{
		printf("0\n");
		return 0;
	}
	if(!(mx&1))
	{
		mx++;
	}
	mx++;
	n>>=1;
	mx>>=1;
	for(int i=1;i<=n;i++)
	{
		dp[i]=pre[i-1];
		if(i<=mx)
		{
			dp[i]+=(i<<1);
			if(dp[i]>=1000000007)
			{
				dp[i]-=1000000007;
			}
		}
		else
		{
			dp[i]-=pre[i-mx-1];
			if(dp[i]<0)
			{
				dp[i]+=1000000007;
			}
		}
		pre[i]=pre[i-1]+dp[i];
		if(pre[i]>=1000000007)
		{
			pre[i]-=1000000007;
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1920
N = int(input())
S = [int(input()) for _ in range(N)]
s = sum(S)
S.sort()
cnt = 0
while s % 10 == 0 and cnt < N:
    if S[cnt] % 10 != 0:
        s -= S[cnt]
    cnt += 1
if cnt == N:
    s = 0
print(s)


Measured memory_bytes: 3060
// AOJ ALDS1_5_A Exhaustive Search
// 2018.4.30 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char f[2002];
short que[2002]; int top, end;

int main()
{
	int n, a, q;
	int stop, x;
	
	n = in(), que[0] = 0, end = 1;
	while (n--) {
		stop = end;
		a = in();
		for (top = 0; top < stop; top++) {
			x = que[top] + a;
			if (f[x]) continue;
			f[x] = 1, que[end++] = x;
		}
	}

	q = in();
	while (q--) {
		puts(f[in()]? "yes": "no");
	}
	return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, m;
  scanf("%d %d", &n, &m);
  int flag1[200000] = {}, flagN[200000] = {};
  int a, b;
  for(int i = 0; i < m; i++){
    scanf("%d %d", &a, &b);
    if(a == 1 || b == 1) flag1[a + b - 2]++;
    if(a == n || b == n) flagN[a + b - n - 1]++;
  }

  int flag = 0;
  for(int i = 0; i < n; i++){
    if(flag1[i] > 0 && flagN[i] > 0){
      flag++;
      break;
    }
  }

  if(flag > 0) printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");

  return 0;
}


Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		List<Integer> list = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			list.add(a[i]);
		}
		Collections.sort(list);
		Collections.reverse(list);
		for(int i = 0; i < n; i++) {
			if(a[i] == list.get(0)) {
				System.out.println(list.get(1));
			} else {
				System.out.println(list.get(0));
			}
		}
	}

}


Measured memory_bytes: 99776
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

int H, W;

const int maxn = 2005;
char s[maxn][maxn];

bool check(int i, int j){
    int cnt = 0;
    if(s[i][j] == '#')
        cnt++;
    if(s[i - 1][j] == '#')
        cnt++;
    if(s[i][j - 1] == '#')
        cnt++;
    if(s[i - 1][j - 1] == '#')
        cnt++;
    return cnt % 2 == 0;
}

int g[maxn][maxn];
int pre[maxn][maxn];
int a[maxn], L[maxn], R[maxn];
int st[maxn], tot;

int main(){
    cin >> H >> W;
    int ans = max(H, W);
    for(int i = 0;i < H;i++){
        scanf("%s", s[i]);
    }
    for(int i = 1;i < H;i++){
        for(int j = 1;j < W;j++){
            g[i][j] = check(i, j);
        }
    }
    H--, W--;
    for(int i = 1;i <= H;i++){
        pre[i][0] = 0;
        for(int j = 1;j <= W;j++){
            if(g[i][j] == 0)
                pre[i][j] = 0;
            else{
                pre[i][j] = pre[i][j - 1] + 1;
            }
        }
    }
    for(int j = 1;j <= W;j++){
        for(int i = 1;i <= H;i++){
            a[i] = pre[i][j];
        }
        a[0] = -1, a[H + 1] = -1;
        tot = 0;
        st[++tot] = 0;
        for(int i = 1;i <= H;i++){
            while(a[i] <= a[st[tot]]){
                tot--;
            }
            L[i] = st[tot] + 1;
            st[++tot] = i;
        }
        tot = 0;
        st[++tot] = H + 1;
        for(int i = H;i >= 1;i--){
            while(a[i] <= a[st[tot]]){
                tot--;
            }
            R[i] = st[tot] - 1;
            st[++tot] = i;
        }
        for(int i = 1;i <= H;i++){
            //cout << R[i] << " " << L[i] << " " << a[i] << endl;
            int tmp = (R[i] - L[i] + 2) * (a[i] + 1);
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
#include<stdio.h>
int main()
{
   int a,b,c;
   scanf("%d %d %d",&a,&b,&c);
   if(1<=a && a<=100 && 1<=b && b<=100 && 1<=c && c<=100)
   {
    if(b-a == c-b) printf("\nYES");
    else printf("\nNO");

   }
return 0;
}

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

int main(){
	int n,m;
  	cin >> n >> m;
  	int i,j,c = 0, a[m+1] = {0},x,y;
  	for(i = 0; i < n; i ++)
    {
      cin >> x;
      for(j = 0; j < x; j ++)
      {
        cin >> y;
        a[y] ++;
      }
    }
  	for(i = 1; i <= m; i ++)
    	if(a[i] >= n)
          c++;
 	cout << c;
}


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

const int N = 1000100;
int prime[N];
int a[1000100] = {0};
int cnt = 1;
bool vis[N];

void prepare(int n)
{
	for(int i = 2;i<=n;++i){
		if(vis[i] == 0){
			prime[cnt] = i;
			cnt++;
		}
		for(int j = 1;j<cnt;++j){
			if(i*prime[j]>n) break;
			vis[i*prime[j]] = 1;
			if(i*prime[j] == 0) break;
		}
	}
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
	prepare(N);
	int n;
	cin>>n;
	for(int i = 1;i<=n;++i){
		int x;
		cin>>x;
		int ex = x;
		if(vis[x] == 0) a[x]++;
		for(int i = 1;i<cnt;++i){			
			if(prime[i]*prime[i]<=x && x%prime[i] == 0){
				a[prime[i]]++;				
				while(x%prime[i] == 0) x /= prime[i];
			}
			if(prime[i]*prime[i]>x) break;
		}
		if(vis[x] == 0 && x != ex) a[x]++;
	}
	int flag = 0,flagn = 0;
//	for(int i = 1;i<=15;++i) cout<<a[i]<<" ";
//	cout<<endl;
	
	for(int i = 2;i<1000100;i++){
		if(a[i]>=2) flag++;
		if(a[i] == n) flagn++;
	}
	
	if(flag == 0) cout<<"pairwise coprime"<<endl;
	else if(flagn == 0) cout<<"setwise coprime"<<endl;
	else cout<<"not coprime"<<endl;
//	for(int i = 1;i<cnt;++i)  cout<<prime[i]<<endl;
	return 0; 
} 

Measured memory_bytes: 8844
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <tuple>
typedef long long ll;

using namespace std;
int main(){
    string s,t;
    cin >> s>>t;
    int count=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i])count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int A, B;
int a;
int ans;

int main(){
	cin >> A >> B;

	for (int i = 0; a < B - 1; i++){
		a += A - 1;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

typedef struct{
  int c,w[10],p,tID;
} score;

void init_score(vector <score> &s, int T, int P){
  rep(i,T){
    s[i].c=1;
    rep(j,P){
      s[i].w[j]=0;
    }
    s[i].p=0;
    s[i].tID=i+1;
  }
}
    
    bool comp(const score &a, const score &b){
  if(a.c==b.c){
    if(a.p==b.p)
      return a.tID < b.tID;
    else
      return a.p < b.p;
  }
  else{
    return a.c > b.c; 
  }
}

int main(){
  for(;;){
    int T,P,R;
    cin >> T >> P >> R;
    if(!(T+P+R)) break;
    vector <score> s(50);

    init_score(s,T,P);

    rep(i,R){
      int tID,pID,time;
      string message;
      cin >> tID >> pID >> time >> message;
      if(message=="WRONG")
	s[tID-1].w[pID-1]++;
      else{
	s[tID-1].c++;
	s[tID-1].p += (s[tID-1].w[pID-1]*1200 + time);
      }
    }
    
    sort(all(s),comp);
    
    rep(i,T){
      cout << s[i].tID << " " << s[i].c-1 << " " << s[i].p << endl;
    } 
  }
}

Measured memory_bytes: 1240
#include <iostream>

using namespace std;

//from https://www.programiz.com/cpp-programming/examples/hcf-gcd
int find_gcd(int n1, int n2) {
    while(n1 != n2)
    {
        if(n1 > n2)
            n1 -= n2;
        else
            n2 -= n1;
    }
    return n1;
}

int main() {
    int k, gcd;
    cin >> k;
    gcd = (int)(k*(k + 1) / 2);
    for (int i = 1; i <= k; i++) {
        for(int j = i + 1; j <= k; j++) {

            int temp = find_gcd(i, j);

            for(int s = 1; s <= min(i, j); s++) {
                if (s == i || s == j) {
                    gcd += 6*temp;
                }
                else if (temp % s == 0) {
                    gcd += 6*s;
                }
                else {
                    gcd += 6*find_gcd(s, temp);
                }
            }

        }
    }
    cout << gcd << endl;
    return 0;
}

Measured memory_bytes: 3636
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    A=list(map(int,input().split()))
    h=0
    for i in range(N-1):
        if A[i]>A[i+1]:
            h += A[i]-A[i+1]
            A[i+1]=A[i]
    
    print(h)



if __name__ == '__main__':
    main()


Measured memory_bytes: 32344
#include <iostream>

using namespace std;

int main()
{
    long long A,B;
    cin >> A >> B;
    
    long long sub=B-A;
    long long ans;
    
    if(A%2==0){
    
        if(sub==0)ans=B;
        else if(sub%4==1)ans=1;
        else if(sub%4==2)ans=B^1;
        else if(sub%4==3)ans=0;
        else ans=B^0;
    
    }else{
        
        if(sub==0)ans=B;
        else if((sub-1)%4==1)ans=1^A;
        else if((sub-1)%4==2)ans=B^1^A;
        else if((sub-1)%4==3)ans=0^A;
        else ans=B^0^A;
    
        
        
    }
    
    
   cout << ans << endl; 
   
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, x[100], y,i;
	double d1 = 0, d2 = 0, d3 = 0, d4 = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		scanf("%d", &x[i]);

	for (i = 0; i < n; i++) {
		scanf("%d", &y);
		d1 += fabs(x[i] - y);
		d2 += pow(fabs(x[i] - y), 2);
		d3 += pow(fabs(x[i] - y), 3);
		if (d4 < fabs(x[i] - y)) d4 = fabs(x[i] - y);
	}

	d2 = sqrt(d2);
	d3 = cbrt(d3);

	printf("%lf\n%lf\n%lf\n%lf\n", d1, d2, d3, d4);

	return 0;
}

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

using namespace std;

long gcd(long a, long b){
    long x;
    if(a < b) swap(a, b);
    if(b == 0){
	x = a;
    }else{
	x = gcd(b, a % b);
    }
    return x;
}

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

    vector<long> A(N);

    for(int i = 0; i < N; i++){
	cin >> A.at(i);
    }

    if(N == 2){
	cout << max(A.at(0), A.at(1)) << endl;
	return 0;
    }

    vector<long> L(N), R(N);

    L.at(0) = A.at(0);
    for(int i = 1; i < N; i++){
	L.at(i) = gcd(L.at(i-1), A.at(i));
    }
    R.at(N-1) = A.at(N-1);
    for(int i = N-2; i >= 0; i--){
	R.at(i) = gcd(R.at(i+1), A.at(i));
    }

    long ans = 1;
    for(int i = 0; i < N; i++){
	long x;
	if(i == 0){
	    x = R.at(1);
	}else if(i == N-1){
	    x = L.at(N-2);
	}else{
	    x = gcd(L.at(i-1), R.at(i+1));
	}
	ans = max(ans, x);
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	int r, g; cin >> r >> g;
	printf("%d\n", 2 * g - r);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll ans = a - 1;
  if(b >= a) ans++;

  cout << ans << endl;
  
  return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    string S[H];
    for(int i = 0;i < H;i++){
        cin >> S[i];
    }

    if(H * W == 1){
        cout << 0 << endl;
        return 0;
    }else if(H * W == 2){
        cout << 1 << endl;
        return 0;
    }

    int d[H][W][H][W];

    rep(tate1, H){
        rep(yoko1, W){
            rep(tate2, H){
                rep(yoko2, W){
                    d[tate1][yoko1][tate2][yoko2] = 100000000;
                }
            }
        }
    }

    rep(tate1, H){
        rep(yoko1, W){
            if(S[tate1][yoko1] == '#') continue;
            if(tate1 + 1 != H && S[tate1 + 1][yoko1] != '#'){
                d[tate1][yoko1][tate1 + 1][yoko1] = 1;
                d[tate1 + 1][yoko1][tate1][yoko1] = 1;
            }
            if(yoko1 + 1 != W && S[tate1][yoko1 + 1] != '#'){
                d[tate1][yoko1][tate1][yoko1 + 1] = 1;
                d[tate1][yoko1 + 1][tate1][yoko1] = 1;
            }
        }
    }

    rep(tate1, H){ rep(yoko1, W){
        if(S[tate1][yoko1] == '#') continue;
        rep(tate2, H){ rep(yoko2, W){
            if(S[tate2][yoko2] == '#') continue;
            rep(tate3, H){ rep(yoko3, W){
                if(S[tate3][yoko3] == '#') continue;
                if(d[tate2][yoko2][tate3][yoko3] > d[tate2][yoko2][tate1][yoko1] + d[tate1][yoko1][tate3][yoko3]){
                    d[tate2][yoko2][tate3][yoko3] = d[tate2][yoko2][tate1][yoko1] + d[tate1][yoko1][tate3][yoko3];
                }
            }}
        }}
    }}

    int ans = 0;
    rep(tate1, H){ rep(yoko1, W){
        if(S[tate1][yoko1] == '#') continue;
        rep(tate2, H){ rep(yoko2, W){
            if(S[tate2][yoko2] == '#') continue;
            ans = max(ans, d[tate1][yoko1][tate2][yoko2]);
            // cout << d[tate1][yoko1][tate2][yoko2] << endl;
        }}
    }}

    cout << ans << endl;   

}

Measured memory_bytes: 896
#include<stdio.h>
#include<limits.h>
#define MAX 105
#define WHITE 0
#define GRAY 1
#define BLACK 2
void BFS(void);
void Enqueue(int);
int Dequeue(void);
 
int G[MAX][MAX];
int Q[MAX];
int d[MAX];
int f[MAX];
int color[MAX];
int n;
int time;
int s;
int head=0;
int tail=0;
 
int main(){
 
  int i,j,u,k,next;
 
    scanf("%d",&n);
      for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            G[i][j] = 0;
        }
    }
    for(i = 1; i <= n;i++){
        scanf("%d%d",&u,&k);
	if(i == 1)
	  s = u;
        for(j = 1; j <= k; j++){
            scanf("%d",&next);
            G[i][next] = 1;
        }
    }
    BFS();
    for(i = 1; i <= n; i++){
        printf("%d %d\n",i,d[i]);
    }
 
    return 0;
}

void BFS(void){

  int u,v;

  for(u = 1; u <= n; u++){
    color[u] = WHITE;
    d[u] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  Enqueue(s);
  while(head != tail){
    u = Dequeue();
    for(v = 1; v <= n; v++){
      if(color[v] == WHITE && G[u][v] == 1){
	color[v] = GRAY;
	d[v] = d[u] + 1;
	Enqueue(v);
      }
    }
    color[u] = BLACK;
  }
}

void Enqueue(int in){

  Q[tail] = in;
  tail++;
}

int Dequeue(void){

  int ans;

  ans = Q[head];
  head++;

  return ans;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define ones(n) __builtin_popcount(n)
#define ONES(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 3003, M = 102, mod = 1000000007, mxLog = 20;
int a[N], n;
long long memo[N][N][2];

long long solve(int i, int j, int turn) {
    if (i > j)
        return 0;
    long long &ret = memo[i][j][turn];
    if (~ret)
        return ret;
    ret = 0;
    if (turn) {
        long long x = -a[i] + solve(i + 1, j, !turn);
        long long y = -a[j] + solve(i, j - 1, !turn);
        if (x > y)
            return ret = y;
        else
            return ret = x;
    } else {
        long long x = a[i] + solve(i + 1, j, !turn);
        long long y = a[j] + solve(i, j - 1, !turn);
        if (x > y)
            return ret = x;
        else
            return ret = y;
    }
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    memset(memo, -1, sizeof memo);
    cout << solve(0, n - 1, 0);

    return 0;
}

Measured memory_bytes: 141312
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    cout<<(n + 1) * n / 2 <<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
*L, = map(int, input().split())
L.sort()
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[k] < L[i] + L[j] and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                cnt += 1
print(cnt)


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

int A[MAX];

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

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, k;
	scanf("%d%d", &n, &k);
	int g = 0;
	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
		g = gcd(A[i], g);
	}

	FOR (i, 0, n)
	{
		if (k > A[i]) continue;
		int diff = A[i] - k;
		if (diff % g == 0)
		{
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}

	cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 640
/*
 ------------------------------------------------------Read question very carefully------------------------------------------------------
 
                       In every question first approach must be basic, atleast give 15 mins for try to solve in basic approach
*/
 #include<iostream>
 #include<cstring>
 #include<string>
 #include<vector>
 #include<utility>
 #include<stdlib.h>
 #include<limits.h>
 #include<cmath>
 #include<set>
 #include<initializer_list>
 #include<unordered_set>
 #include<unordered_map>
 #include<map>
 #include<iomanip>
 #include<algorithm>
 #include<queue>
 #include<stack>
#include <cstdint>
  
 #define sze 1000005
 #define ld long double
 //#define ll unsigned long long
 #define ll long long
 #define endl "\n"
 #define pb push_back
 #define mkp make_pair
 #define mod 1000000007
 #define ff first
 #define ss second
 #define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
 #define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
 #define all(c) (c).begin(),(c).end()
 #define pi                   pair<int,int>
 #define pll                  pair<ll,ll>
 #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
 using namespace std;

//cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
 //const ll inf=1ll<<60;
 //const double pi = 3.14159265358979323846;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod * a%mod)%mod;
        a = (a%mod * a%mod)%mod;
        b >>= 1;
    }
    return res;
}
const ll int  N=2e5+5;
/*vector<ll> adj[N];
vector<ll> vis(N,0);
*/
//int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

ll n,k;
ll arr[N];
ll helper(ll x,ll curr)
{
    ll ans=0;
    F(i,1,n)
    {
        if(!curr)
        {
            ans++;
            curr^=1;
        }
        else
        {
            if(arr[i]<=x)
            {
                ans++;
                curr^=1;
            }
        }
    }
    return ans>=k;
}

 int main()
 {
     IOS;
     ll n; cin>>n;
     ll arr[n+2],sum=0;
     vector<ll> hash(1e5+5,0);
     F(i,0,n-1)
     {
         cin>>arr[i];
         hash[arr[i]]++;
         sum += arr[i];
     }
     ll q; cin>>q;
     while(q--)
     {
         ll b,c; cin>>b>>c;
         sum += c*hash[b];
         hash[c]+= hash[b];
         sum -= b*hash[b];
         hash[b]=0;
         cout<<sum<<endl;
     }
 }



Measured memory_bytes: 4784
from collections import deque, Counter

N = int(input())

edge =  [[] for i in range(N-1)]
to = [[] for i in range(N)]
color = {}
edge_list = []

for i in range(N-1):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)
    edge[i] = [a-1, b-1]
    edge_list.append(a-1)
    edge_list.append(b-1)

K = Counter(edge_list).most_common()[0][1]

q = deque([])
q.append([0,-1])

is_visited = [False] * N

while(len(q) != 0):
    cur_node, pre_col = q.popleft()

    is_visited[cur_node] = True
    col_use = 0

    for next_node in to[cur_node]:
        if not is_visited[next_node]:
            if col_use == pre_col:
                col_use += 1

            color[(cur_node,next_node)] = col_use
            q.append([next_node, col_use])
            col_use += 1

print(K)

for i in range(N-1):
    print(color[tuple(edge[i])] + 1)



Measured memory_bytes: 65600
#include<iostream>
#include<vector>
#include<math.h>
#include <algorithm>
using namespace std;
int main(){
  vector<long> input;
  long k;
  long max;
  long sum;
  input.resize(3);

  cin >> input[0];
  cin >> input[1];
  cin >> input[2];
  cin >> k;

  sort(input.begin(),input.end());

  max = input[2];

  //cout << input [0] << " " << input[1] << " " << input[2] << endl;

  sum = input[0] + input[1] + input[2]*pow(2,k);

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define R register
#define EN printf("\n")
#define LL long long
inline LL read(){
	LL x=0,y=1;
	char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=-1;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return x*y;
}
LL a,b,k;
int main(){
	a=read();b=read();k=read();
	if(k>=a+b) return std::puts("0 0"),0;
	if(k>=a) return std::printf("0 %lld",b-(k-a)),0;
	std::printf("%lld %lld",a-k,b);
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int A[200005];
int cc=0;
vector<int> V;
int B[200005];

int main(){
    int n;
    ll ans=0;
    cin >> n;
    rep(i,n){
        cin >> A[i];
        B[i]=A[i]-i;
        if(-200005<B[i]&&B[i]<0){
            V.push_back(-B[i]);
        }
    }
    sort(V.begin(),V.end());
    rep(i,n){
        int k=A[i]+i;
        if(200005>k){
            int temp=upper_bound(V.begin(),V.end(),k)-lower_bound(V.begin(),V.end(),k);
            ans+=temp;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5696
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    REP(i,n){
        cin >> d[i];
    }
    vector<int> t(13,0);
    REP(i,n){
        t[d[i]]++;
    }
    bool flag = false;
    REP(i,12){
        if(t[i]>2){
            flag = true;
        }
    }
    if(t[12]>1){
        flag = true;
    }
    if(t[0]>=1){
        flag = true;
    }
    if(flag){
        put(0);
        return 0;
    }
    int res = 0;
    for(int bit=0;bit<(1<<n);++bit){
        vector<int> a(n+1);
        a[0]=0;
        REP(i,n){
            if(bit&(1<<i)){
                a[i+1]=d[i];
            }else{
                a[i+1]=24-d[i];
            }
        }
        SORT(a);
        int dif = 100;
        REP(i,n){
            chmin(dif,a[i+1]-a[i]);
        }
        chmin(dif,24+a[0]-a[n]);
        chmax(res,dif);
        if(res>=1&&n>15){
            break;
        }
    }
    put(res);
    return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        // 入力
        MyScanner sc = new MyScanner(System.in);
        String[] line1 = sc.nextStringArray();
        String[] line2 = sc.nextStringArray();
        String[] line3 = sc.nextStringArray();

        // 初期化
        int[] a = new int[3];
        int[] b = new int[3];
        int[][] c = new int[3][3];
        boolean ansFlg = false;

        for (int i = 0; i < 3; i++) {
            c[0][i] = Integer.parseInt(line1[i]);
            c[1][i] = Integer.parseInt(line2[i]);
            c[2][i] = Integer.parseInt(line3[i]);
        }

        // 主処理
        for (int i = 0; i <= 100; i++) {
            // a1の値を仮で決める
            a[0] = i;
            // b1,b2,b3を決める(bj = c1,j - a1)
            b[0] = c[0][0] - a[0];
            b[1] = c[0][1] - a[0];
            b[2] = c[0][2] - a[0];
            // b1を利用してa2,a3を決める(ai = ci,1 - b1)
            a[1] = c[1][0] - b[0];
            a[2] = c[2][0] - b[0];
            // ci,j = ai + bj が成立しているかチェックする
            // System.out.println("a=" + Arrays.toString(a));
            // System.out.println("b=" + Arrays.toString(b));
            boolean checkOk = true;
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (c[j][k] != a[j] + b[k]) {
                        checkOk = false;
                        break;
                    }
                }
            }
            if (checkOk == true) {
                ansFlg = true;
                break;
            }
        }

        // 出力
        System.out.println(ansFlg ? "Yes" : "No");
    }

    static class MyScanner {
        BufferedReader br;
        // 標準入力から入力値を取得
        MyScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }
        // 標準入力を文字列で取得
        public String nextString() throws IOException {
            return br.readLine();
        }
        // 標準入力を文字列の配列で取得
        public String[] nextStringArray() throws IOException {
            return nextString().split(" ");
        }
        // 標準入力を数値で取得
        public int nextInt() throws IOException {
            return Integer.parseInt(nextString());
        }
        // 標準入力を数値の配列で取得
        public int[] nextIntArray() throws IOException {
            String[] strArr = nextStringArray();
            int[] intArr = new int[strArr.length];
            for(int i = 0; i < strArr.length; i++) {
                intArr[i] = Integer.parseInt(strArr[i]);
            }
            return intArr;
        }
    }

}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	LL x = 7;
	int ile = -1;
	if(x % n == 0)
		ile = 1;
	else {
		for(int i=0; i<2000004; i++) {
			x*=10;
			x+=7;
			x%=n;
			if(x == 0) {
				ile = i+2;
				break;
			}
		}
	}
	cout<<ile;
}


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	int n=s.length();
	int t=s.length();
	for(int i=0;i<n-1;i++){
		if(s[i]!=s[i+1]) {
			t=min(t,max(i+1,n-(i+1)));
		}
	}
	cout << t << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <memory.h>
using namespace std;
int main(void) {
	int n, a, b; scanf("%d %d %d", &n, &a, &b);
	printf("%d\n", (n - a + 1)*(n - b + 1));
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

map<P, int> memo;
vector<int> E[110000];
vector<P> vp;
int ans = 0;

void func(int pos, int pre, int col){
	ans = max(ans, col);
	int cnt = 1;
	for(int to : E[pos]){
		if(pre != to){
			if(cnt == col){
				cnt += 1;
			}
			memo[P(pos, to)] = cnt;
			func(to, pos, cnt);
			cnt += 1;
		}
	}
}

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N - 1; i++){
		int a, b;
		cin >> a >> b;
		vp.push_back(P(a, b));
		E[a].push_back(b);
		E[b].push_back(a);
	}
	func(1, -1, -1);
	cout << ans << endl;
	for(P p : vp){
		if(memo.find(p) != memo.end()){
			cout << memo[p] << endl;
		}else{
			swap(p.first, p.second);
			cout << memo[p] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 14836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
ll a[200010];
ll c[200010];
ll sum=1;
ll q=1;
int main()
{
    ll n,k;
    cin>>n>>k;
    for(long long int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }

    while(!c[q])
    {
        c[q]=sum;
        q=a[q];
        sum++;
    }
    sum=sum-c[q];
    if(k<=c[q])
    {
        long long int p=1;
        while(k--)
        {
            p=a[p];
        }
        //p=a[p];
        cout<<p<<endl;
    }
    else
    {
        long long int t=(k-c[q])%sum;

        long long int p=a[q];
        while(t--)
        {
            p=a[p];
        }
        cout<<p<<endl;
    }

    return 0;
}


Measured memory_bytes: 6888
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <stack>

using namespace std;

int cost(int x, int y) {
	return (x - y)*(x - y);
}

bool q(vector<int> r) {
	for (int i = 0; i < r.size(); i++)
	{
		if (r[i] != r[0]) { return true; }
	}
	return false;
}

int main(void) {
	vector<int> a;
	int n;
	cin >> n;
	int sum=0;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		a.push_back(t);
		sum += t;
	}

	if (q(a)==true) {
		double tmpa = (double)sum / n;
		int ave;
		if (tmpa < 0) { ave = tmpa - 0.5; }
		else { ave = tmpa + 0.5; }
		int ans = 0;

		for (int i = 0; i < n; i++)
		{
			ans += cost(a[i], ave);
		}
		cout << ans << endl;
	}
	else { cout << 0 << endl; }

	return 0;

}


Measured memory_bytes: 256