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



  
int main(){
  

  int n;
  cin>>n;
  
  vector<int> data(3*n);
  
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    
    data.at(3*i)=tmp-1;
    data.at(3*i+1)=tmp;
    data.at(3*i+2)=tmp+1;
   

  }
  
  
  sort(data.begin(),data.end());
  
 
  vector<int> count(3*n);
  
  count.at(0)=1;
  
  int answer=1;
  
  
  for (int i=1;i<3*n;i++){
    if (data.at(i)==data.at(i-1)){
      count.at(i)=count.at(i-1)+1;
    }
    else {
      count.at(i)=1;
    }
    
    answer=max(answer,count.at(i));
    
    
  }
  
  cout<<answer<<endl;
  

  
}

    











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

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<ll> a{};
    for(int i=0;i<n;i++){
        ll j;
        cin>>j;
        a.push_back(j);
    }
    bool flag=true;
    ll count=0;
    while(flag){
        flag=false;
        for(int i=0;i<n;i++){
            if(a.at(i)>=n){
                count+=a.at(i)/n;
                for(int j=0;j<n;j++){
                    if(j!=i){
                        a.at(j)+=a.at(i)/n;
                    }
                }
                a.at(i)=a.at(i)%n;
                flag=true;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    return i + 1;
}

int main() {
    int i, q;

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

    q = partition(0, n - 1);

    for (i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
bool is[40][21];
double eps=1e-9;
int main(){
	while(true){
		int r,n;
		cin>>r>>n;
		if(r==0) break;
		rep(i,40) rep(j,21) is[i][j]=0;
		rep(i,n){
			int a,b,h;
			cin>>a>>b>>h;
			a+=20,b+=20;
			for(int x=a;x<b;x++) rep(y,h) is[x][y]=true;
		}
		vector<double> vc;
		rep(x,r) rep(y,22){
			if(x*x>=r*r) continue;
			double t=y-sqrt(r*r-x*x);
			vc.pb(t);
		}
		sort(all(vc));
		rep(i,vc.size()){
			double h=vc[i];
			bool can=true;
			for(int x=-r;x<r;x++) rep(y,21){
				if(is[x+20][y]) continue;
				if(x*x+(y-h)*(y-h)<r*r+eps) can=false;
				if((x+1)*(x+1)+(y-h)*(y-h)<r*r+eps) can=false;
			}
			if(!can){
				printf("%.4f\n",h+r);
				break;
			}
		}
	}
}

Measured memory_bytes: 1252
import java.util.*;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean [] seat =new boolean[100000];
        int ans =0;
        Arrays.fill(seat,false);
        for(int i=0;i<N;i++){
            int start =sc.nextInt();
            int end =sc.nextInt();
            for(int j=start-1;j<end;j++){
                seat[j]=true;
            }
        }
        for(int i =0;i<100000;i++){
            if(seat[i]==true){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27856
#include <iostream>
#include <string>
using namespace std;
int main() {
	// 整数の入力
	int a;
	cin >> a;

	int check = 1;
	int ret = 0;
	while (check != 0) {
		if (a >= check) {
			int max = check * 10 - 1;
			int next = 100;
			if (max >= a) {
				next = 0;
			}
			ret += ((max < a ? max : a) - (check - 1));
			check *= next;
		}
		else {
			break;
		}
	}
	cout << ret;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

ll cnt = 0;

int arr[1010], dp[1010][1010];

int main()
{
   int t1 = 0;

   int n, a, b;
   cin >> n >> a >> b;

   cout << min(n*a, b);


}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long ans = Math.min(n%k, k-(n%k));
        System.out.println(ans);
    }

}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define eb emplace_back
#define mp make_pair
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b+c>=22?"bust":"win")<<endl;
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc128b.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<tuple<string, int, int>> S;
	for(int i = 0; i < N; ++i){
		string s;
		int x;
		cin >> s >> x;

		S.push_back(make_tuple(s, x, i + 1));
	}


	for(int i = 0; i < N; ++i){
		for(int j = i + 1; j < N; ++j){
			if(get<0>(S[j]) < get<0>(S[i])){
				swap(S[j], S[i]);
			}
			else if(get<0>(S[j]) == get<0>(S[i])){
				if(get<1>(S[i]) < get<1>(S[j])){
					swap(S[j], S[i]);
				}
			}
		}
	}

	for(int i = 0; i < N; ++i){
		cout << get<2>(S[i]) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int[] x=new int[5];
	    for (int i=0; i<5;i++) {
	    	x[i]=gi();
	    	if (x[i]==0) {
	    		System.out.print(i+1);
	    	}
	    }
        

	    //System.out.print(nr*2*Math.PI);
//	    if (n%10==3) {
//	    	System.out.print("bon");
//	    }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
//	    	System.out.print("pon");
//	    } else {
//	    	System.out.print("hon");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int main(){
    ll x, y;
    cin >> x >> y;
    for(int i=1; ;i++){
        x*=2LL;
        if(x>y){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


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

int main() {
	string a, b, c; cin >> a >> b >> c;
	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
		cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
} 

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

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

    ll x[n], y[n], h[n];
    rep(i, n)
        cin >> x[i] >> y[i] >> h[i];

    rep(i, 101){
        rep(j, 101){
            bool check = true;
            ll H;
            bool init = false;
            rep(k, n){
                if(init == false && h[k] != 0){
                    H = h[k] + abs(x[k] - i) + abs(y[k] - j);
                    init = true;
                    k = 0;
                }
                if(init == true && h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), ll(0))){
                        check = false;
                        break;
                }
            }
            if(check == true){
                cout << i << " " << j  << " " << H << " " << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int v;
  int w;
  char t;
  long long d;
  string s;
  vector<tuple<int, int, char, long long, string>> A(n);
  for (int i = 0; i < n; i++){
    cin >> v >> w >> t >> d >> s;
    A[i] = make_tuple(v, w, t, d, s);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < n; i++){
    tie(v, w, t, d, s) = A[i];
    cout << v << ' ' << w << ' ' << t << ' ' << d << ' ' << s << endl;
  }
}


Measured memory_bytes: 12192
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    for(int k = 1;;k++){
        string s = to_string(k);
        if(s[0] == s[1] and s[1] == s[2]){
            if(k >= n){
                cout << k << endl;
                return 0;
            }
        }
    }
}






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

map<char, int> dm;
int H, W;
string s;
string b[50];
int dp[50][50][4][1010];
int gx, gy;
int nx, ny;
int dir = 3;
int ans;
int c;

// E, S, W, N
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };


void GO() {
	//cerr << "GO" << endl;
	int x = nx + dx[dir], y = ny + dy[dir];
	if(b[y][x] == '#') return;
	nx = x, ny = y;
}
void BACK() {
	//cerr << "BACK" << endl;
	int x = nx - dx[dir], y = ny - dy[dir];
	if(b[y][x] == '#') return;
	nx = x, ny = y;
}

void TURN_L() {
	//cerr << "TURN_L" << endl;
	dir = (dir + 3) % 4;
}

void TURN_R() {
	//cerr << "TURN_R" << endl;
	dir = (dir + 1) % 4;
}

void P();
void IF();
void WHILE();
bool COND(string s);

void IF() {
	c++; // [
	string cond;
	if(s[c] == '~') cond += s[c++];
	cond += s[c++];
	if(COND(cond)) {
		P();
		assert(s[c] == ']');
		c++;
	}
	else {
		int t = 1;
		while(t > 0) {
			if(s[c] == ']') t--;
			if(s[c] == '[') t++;
			c++;
		}
	}
}

void WHILE() {
	c++; // {
	int tc = c;
	while(c < s.size() && !(nx == gx && ny == gy)) {
		string cond;
		if(s[c] == '~') cond += s[c++];
		cond += s[c++];
		if(COND(cond)) {
			do {
				P();
			} while(s[c] != '}');
			c = tc;
			continue;
		}
		else {
			int t = 1;
			while(t > 0) {
				if(s[c] == '}') t--;
				if(s[c] == '{') t++;
				c++;
			}
			break;
		}
	}
}

void P() {
	if(c < s.size() && !(nx == gx && ny == gy)) {
		//cerr << s[c] << endl;
		if(dp[ny][nx][dir][c]) throw - 1;
		dp[ny][nx][dir][c] = 1;

		if(s[c] == '^') {
			GO();
			c++;
			ans++;
			if(nx == gx && ny == gy) throw ans;
			if(ans == 1000000) throw - 1;
			P();
		}
		if(s[c] == 'v') {
			BACK();
			c++;
			ans++;
			if(nx == gx && ny == gy) throw ans;
			if(ans == 10000000) throw - 1;
			P();
		}
		if(s[c] == '<') {
			TURN_L();
			c++;
			ans++;
			if(ans == 10000000) throw - 1;
			P();
		}
		if(s[c] == '>') {
			TURN_R();
			c++;
			ans++;
			if(ans == 10000000) throw - 1;
			P();
		}
		if(s[c] == '{') {
			WHILE();
			P();
		}
		if(s[c] == '[') {
			IF();
			P();
		}
	}
}

bool COND(string s) {
	bool NOT = false;
	if(s.size() == 2) {
		NOT = true;
		s = s.substr(1, 1);
	}

	if(s == "T") return true ^ NOT;
	if(s == "C") {
		int x = nx + dx[dir], y = ny + dy[dir];
		return (b[y][x] == '#') ^ NOT;
	}
	return (dm[s[0]] == dir) ^ NOT;
}

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

	dm['E'] = 0;
	dm['S'] = 1;
	dm['W'] = 2;
	dm['N'] = 3;

	cin >> H >> W;
	for(int i = 0; i < H; i++) {
		cin >> b[i];
		for(int j = 0; j < W; j++) {
			if(b[i][j] == 'g') {
				gx = j, gy = i;
				b[i][j] = '.';
			}
			if(b[i][j] == 's') {
				nx = j, ny = i;
				b[i][j] = '.';
			}
		}
	}
	cin >> s;

	dir = dm['N'];
	try {
		P();
	}
	catch(int x) {
		cout << x << endl;
		return 0;
	};
	cout << -1 << endl;
}

Measured memory_bytes: 39148
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
#define mod 1000000007
#define x first
#define y second
#define codec ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef vector<int> vi;
typedef vector<long long int> vl;
#define deb cout<<"Heelo"<<endl;
typedef pair<int, int> pi;
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ma=-1000000000000000000;
     ma=max(ma,a*c);
     ma=max(ma,a*d);
     ma=max(ma,b*c);
     ma=max(ma,b*d);
     cout<<ma;
}

Measured memory_bytes: 3636
# input here
_INPUT = """\
4
141421356 17320508 22360679 244949
"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cumsum = list(itertools.accumulate(a))

    sum1 = 0
    for i in range(len(a)):
        mult = a[i] * (cumsum[n-1] - cumsum[i])
        sum1 += mult

    print((sum1 % (10**9 + 7)))


if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 110800
#include <iostream>
#include <string>
using namespace std;
int main(){
  string A,B,C;
  cin >> A >> B >> C;
  if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 5;
int n, k, ans[N];
int x[N], y[N], a[N], b[N];
inline int read () {
    int tot = 0, f = 1; char c = getchar ();
    while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar (); }
    while (c >= '0' && c <= '9') { tot = tot * 10 + c - '0'; c = getchar (); }
    return tot * f;
}
signed main () {
    n = read ();
    for (int i = 1; i <= n; i++) {
        x[i] = read (); y[i] = read ();
        a[x[i]] = y[i];
    }
    int m = n + 1;
    for (int i = 1; i <= n; i++) {
        m = min (m, a[i]);
        if (m == n - i + 1) b[++k] = i;
    }
    for (int i = 1; i <= k; i++)
        for (int j = b[i]; j > b[i - 1]; j--)
            ans[j] = b[i] - b[i - 1];
    for (int i = 1; i <= n; i++) printf ("%d\n", ans[x[i]]);
    return 0;
}


Measured memory_bytes: 6848
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
node=[list() for _ in range(N+1)]
for _ in range(N-1):
    a,b,c=mint()
    node[a].append([b,c])
    node[b].append([a,c])
Q,K=mint()
cost=[-1]*(N+1)
cost[K]=0
q=deque([K])
while q:
    u=q.popleft()
    for v,c in node[u]:
        if cost[v]<0:
            cost[v]=cost[u]+c
            q.append(v)
for _ in range(Q):
    x,y=mint()
    print(cost[x]+cost[y])

Measured memory_bytes: 115584
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	double res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	for (int i = 0; i < N; i++) {
		res += 1.0 / A[i];
	}
	res = 1 / res;
	cout << fixed << setprecision(15) << res << endl;
}

Measured memory_bytes: 256
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

double N;

// [1][2][3]
double reach[305][305][305];
double expct[305][305][305];

void work(int x, int y, int z) {
    if(reach[x][y][z] < 1e-12) return;
    expct[x][y][z] /= reach[x][y][z];
    double stuck = N/(x+y+z);
    if(x) {
        double p = reach[x][y][z] * x / (x+y+z);
        reach[x-1][y][z] += p;
        expct[x-1][y][z] += p * (stuck + expct[x][y][z]);
    }
    if(y) {
        double p = reach[x][y][z] * y / (x+y+z);
        reach[x+1][y-1][z] += p;
        expct[x+1][y-1][z] += p * (stuck + expct[x][y][z]);
    }
    if(z) {
        double p = reach[x][y][z] * z / (x+y+z);
        reach[x][y+1][z-1] += p;
        expct[x][y+1][z-1] += p * (stuck + expct[x][y][z]);
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n; N = n;
    int x=0,y=0,z=0;
    rep(i, n) {
        int v; cin >> v;v--;
        if(!v)x++;
        else if(v==1)y++;
        else z++;
    }
    reach[x][y][z] = 1;
    for(int tot=n; tot>=0; tot--)
        rep(x, tot+1)
            rep(y, tot-x+1)
                work(x, y, tot-x-y);
    cout << setprecision(12) << fixed << expct[0][0][0] << endl;
}



Measured memory_bytes: 436480
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  if (a + b >= 10) cout << "error" << endl;
  else cout << a + b << endl;

  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int N, K;
    std::cin >> N >> K;

    int res = N - (K - 1);
    std::cout << res << std::endl;
}


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


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

    for(int x = 0; x <= n; x++){
        for(int y = 0; y <= n - x; y++){
            int z = n - x - y;
            int tmp = 10000 * x + 5000 * y + 1000 * z;
            if(tmp == Y){
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string> a(H);
  for(int i=0;i<H;i++){
    cin>>a.at(i);}
  for(int i=0;i<W+2;i++){
    cout<<'#';}
  cout<<endl;
  for(int i=0;i<H;i++){
    cout<<'#'<<a.at(i)<<'#'<<endl;}
    for(int i=0;i<W+2;i++){
    cout<<'#';}
  cout<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static char[] field;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if(!sc.hasNext()) return false;
		field = sc.next().toCharArray();
		return true;
	}
	
	static void solve(){
		System.out.println(field[0] == field[field.length-1] && field[0] == 'x' ? 'x' : 'o');
	}

}

Measured memory_bytes: 17272
#include<bits/stdc++.h>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(){
int N;
cin >> N;
cout << (1+N)*N/2 << endl;
}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<P> vl, vr;
    rep(i, N) {
        string S;
        cin >> S;
        int low = 0, sum = 0;
        for (auto &i : S) {
            if (i == ')') low = min(low, --sum);
            else sum++;
        }
        if (0 < sum) vl.emplace_back(low, sum);
        else vr.emplace_back(low - sum, -sum);
    }

    sort(vl.begin(), vl.end(), greater<P>());
    sort(vr.begin(), vr.end(), greater<P>());

    bool ans = true;
    int cur = 0;
    for (auto &i : vl) {
        if (cur + i.first < 0) {
            ans = false;
            break;
        }
        cur += i.second;
    }

    int cur2 = 0;
    for (auto &i : vr) {
        if (cur2 + i.first < 0) {
            ans = false;
            break;
        }
        cur2 += i.second;
    }

    ans &= cur == cur2;

    cout << (ans ? "Yes" : "No") << endl;
}

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

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

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = (1 << 20);
const int K = 300000;
int a[N], n;
map < int, int > m;
int ok(int x){
    m.clear();
    for (int i = 2; i <= n; i++){
        if (a[i] > a[i - 1]) continue;
        int p = a[i];
        while(1){
            if (m[p] < x - 1){
                m[p]++;
                auto it = m.upper_bound(p);
                vector < pair < int, int > > v;
                while(it != m.end()){
                    v.pb(*it);
                    it++;
                }
                for (auto j: v) m.erase(j.F);
                break;
            } else{
                m.erase(p);
                p--;
            }
            if (p <= 0){
                return 0;
            }
        }
    }
    return 1;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int f = 1;
    for (int i = 2; i <= n; i++){
        if (a[i] <= a[i - 1]) f = 0;
    }
    if (f){
        cout << 1;
        return 0;
    }
    int l = 1;
    int r = n;
    while(r - l > 1){
        int mid = (r + l) / 2;
        if (ok(mid)) r = mid; else l = mid;
    }
    cout << r;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main dice = new Main(sc);
		int count = sc.nextInt();


		for(int i = 0;i < count;i++){
			int ansTop = sc.nextInt();
			int ansSouth = sc.nextInt();

			if(ansTop == dice.south || ansTop == dice.north || ansTop == dice.bottom) {
				while(ansTop != dice.top) {
					dice.goNorth();
				}
			} else {
				while(ansTop != dice.top) {
					dice.goEast();
				}
			}

			while(ansSouth != dice.south) {
				dice.spin();
			}

			System.out.println(dice.getEast());

		}


	}

	int top;
	int south;
	int east;
	int west;
	int north;
	int bottom;


	public Main(Scanner sc) {
		this.top = sc.nextInt();
		this.south = sc.nextInt();
		this.east = sc.nextInt();
		this.west = sc.nextInt();
		this.north = sc.nextInt();
		this.bottom = sc.nextInt();
	}

	public void goNorth() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = s;
		this.south = b;
		this.north = t;
		this.bottom = n;
	}

	public void goSouth() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = n;
		this.south = t;
		this.north = b;
		this.bottom = s;
	}

	public void goEast() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = w;
		this.east = t;
		this.west = b;
		this.bottom = e;
	}

	public void goWest() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = e;
		this.east = b;
		this.west = t;
		this.bottom = w;
	}

	public void spin() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;


		this.south = w;
		this.east = s;
		this.west = n;
		this.north = e;


	}


	public int getTop() {
		return this.top;
	}

	public int getEast() {
		return this.east;
	}
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

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

int main(){

  // ll a[3],b[3];
  map<ll,ll>mp;
  bool e=true;
  rep(i,0,3){
    ll a,b;cin>>a>>b;
    mp[a]++;
    mp[b]++;
    if(mp[a]>=3||mp[b]>=3)e=false;
  }




  if(e)out("YES");
  else out("NO");



  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  long long n, i, max = -10e11, min = 10e11, sum = 0, t;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &t);
    sum += t;
    if(max < t) max = t;
    if(min > t) min = t;
  }
  printf("%lld %lld %lld\n", min, max, sum);
  return 0;
}


Measured memory_bytes: 2752
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
//       int N = sc.nextInt();
//       int M = sc.nextInt();
       String S = sc.next();
       String T = sc.next();
       char[] s = S.toCharArray();
       char[] t = T.toCharArray();
       int f=-1;
       for (int i=s.length-t.length ; i>=0; i--) {
    	   boolean flg=false;
    	   for(int j=0;j<t.length;j++) {
    		   if(s[i+j]!=t[j]&&s[i+j]!='?') {
    			   flg=true;
    			   break;
    		   }
    	   }
    	   if(flg==false) {
    		   f=i;
    		   break;
    	   }
       }
       String ans;
       if(f==-1) {
    	   ans="UNRESTORABLE";
       } else {
		   ans=S.substring(0,f) + T + S.substring(f+T.length());
       }
       ans=ans.replace("?", "a");
       System.out.println(ans);
   }
      

}

Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
  Scanner input = new Scanner(System.in);
  String num = input.next();
  String inputLast = num.substring(num.length()-1);
  //System.out.println(inputLast);
    //(inputLast.equals("3")){
    //System.out.println("bon");
    //se if()
    switch(inputLast){
      case "3":
        System.out.println("bon");
        break;
      case "0":
      case "1":
      case "6":
      case "8":
        System.out.println("pon");
        break;
      default:
        System.out.println("hon");
  }
}
}

Measured memory_bytes: 35720
package main

import (
	"fmt"
	"io"
	"os"
	"sort"

)

func main() {
	solve(os.Stdin, os.Stdout)
}

type inInfo struct {
	in    int
	after int
}

type inInfoSorter []inInfo

func (a inInfoSorter) Len() int      { return len(a) }
func (a inInfoSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a inInfoSorter) Less(i, j int) bool {
	switch {
	case a[i].in > a[j].in:
		return true
	case a[i].in < a[j].in:
		return false
	case a[i].after > a[j].after:
		return true
	default:
		return false
	}
}

func sum(w []int) int {
	s := 0
	for _, v := range w {
		s += v
	}
	return s
}

type ptr []int

func (x ptr) top(i int) int {
	ptrs := []int(x)
	var his []int
	cur := i
	for ; cur >= 0 && ptrs[cur] != cur; cur = ptrs[cur] {
		his = append(his, cur)
	}
	for _, v := range his {
		ptrs[v] = cur - 1
	}
	if cur >= 0 {
		ptrs[cur] = cur - 1
	}
	return cur
}

func solve(stdin io.Reader, stdout io.Writer) {
	var n, m int
	var infos []inInfo

	fmt.Fscanln(stdin, &n, &m)

	for i := 0; i < n; i++ {
		var info inInfo
		fmt.Fscanln(stdin, &info.after, &info.in)
		infos = append(infos, info)
	}

	sort.Sort(inInfoSorter(infos))

	var ans = make([]int, m)
	var p = make([]int, m)
	for i := range p {
		p[i] = i
	}
	ptrs := ptr(p)

	for _, w := range infos {
		i := ptrs.top(m - w.after)
		if i >= 0 {
			ans[i] = w.in
		}
	}

	fmt.Fprintln(stdout, sum(ans))

}



Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000000

ll solve(ll *a, ll n, ll k) {
    ll dp[n + 1] = {0};
    dp[1] = 0;
    for(int i = 2; i <= n; ++i) {
        dp[i] = (ll)inf;
        for(int j = i - 1; (j >= 1) && (i - j) <= k; --j) {
            dp[i] = min(dp[i], abs(a[i] - a[j]) + dp[j]);
        }
    }
    return dp[n];
}

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n + 1] = {0};
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    cout << solve(a, n, k);
}


Measured memory_bytes: 5136
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    int K, X;
    cin>>K>>X;
    if(500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/numeric>
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))
#define     pii       pair<int,int>
#define     N         3000000
using namespace std;


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n,a,b,ans;

    cin >> n >> a;

    int l[n+5];
    l[0]=0;
    ans=n+1;

    for(int i=1;i<=n;i++)
    {
        cin >> b;

        l[i] = l[i-1]+b;
    }

    for(int i=0;i<=n;i++)
    {
        if(l[i]>a){
            ans=i;
            break;
        }
    }

    cout << ans;

    return 0;
}



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

bool isPalin(string s,int a,int n)
{
	while(a<n)
	{
		if(s[a]!=s[n])
			return false;
		a++;
		n--;
	}
	return true;
}
int main()
{
 long long int n,m;
 string s;
 cin>>s;
 n=s.length();
 //cout<<isPalin(s,0,(n-1)/2-1);
 //cout<<isPalin(s,0,n-1);
 //cout<<isPalin(s,(n+3)/2-1,n-1);

 if(isPalin(s,0,(n-1)/2-1)&&isPalin(s,0,n-1)&&isPalin(s,(n+3)/2-1,n-1))
 	cout<<"Yes";
 else
 	cout<<"No";

  
}

Measured memory_bytes: 256
def main():
    a, b, c, k = map(int, input().split())

    if k % 2 == 0:
        ans = a - b
        if abs(ans) > 10 ** 18:
            print("Unfair")
        else:
            print(ans)
    else:
        ans = b - a
        if abs(ans) > 10 ** 18:
            print("Unfair")
        else:
            print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  vector<char> N;
  N = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  char a;
  int b = 0;
  cin >> a;
  for(int i = 0; i < N.size(); i++) {
    if(N.at(i) == a) {
      b = 1;
        break;
    }
  }
  if(b == 1) {
    cout << 'a' << endl;
  }
  else {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int A[] = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();
		int ans = 0;
		sc.close();
		int max;
		int ind = 0;
		
		for(int i=0; i<N; i++) {
			max = 0;
			for(int j=0; j<N; j++) {
				if(max < A[j]) {
					max = A[j];
					ind = j;
				}
			}
			A[ind] = 0;
			if(i%2 == 0) ans += max;
			else 		 ans -= max;
		}
		System.out.println(ans);
	}
}

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

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;
 
public:
  u64 a;
 
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=998244353,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll f[ohara],fr[ohara];
ll dep[ohara];
    
//------ Believe yourself as a genius!!!!!! ------

ll mypow(ll a,ll n,ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}  

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

    using mint=modint<MOD>;

    cin>>n;
    rep(i,n)cin>>a[i],dep[a[i]]++;
    if(a[0]!=0){
        Cout(0);
        return 0;
    }
    sort(a,a+n);
    rrep(i,1,n){
        if(a[i]==0){
            Cout(0);
            return 0;
        }
    }
    mint ans=mint(1);
    rrep(i,1,n+10){
        //if(dep[i]==0)break;
        //ans*=mypow(dep[i-1],dep[i],MOD);
        rep(j,dep[i])ans*=dep[i-1];
    }
    Cout(ans.value());
    return 0;
}


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

int solve(int n) {
  int a;
  int f = 1;
  set<int> numeros;
  while (n--) {
    cin >> a;
    if (numeros.count(a)) f = 0;
    numeros.insert(a);
  }
  return f;
}
int main() {
  int n;
  cin >> n;
  if (solve(n))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;}


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

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

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

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

long int M = 1e+9+7;
int main(void){
    int n;
    cin >> n;
    vi a(n+1);
    rrep(i,n){
        cin >> a[i];
    }
    map<int,int> mp;
    rrep(i,n){
        mp[a[i]+i]++;
    }
    /*
    for(const auto& [key, value] : mp){
        cout << key << " " << value << endl;
    }
    */
    ll ans=0;
    rrep(i,n){
        if(mp.count(i-a[i])){
            ans+= mp[i-a[i]];            
        }
    }
    cout << ans << endl;


    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

ull dp[MAXN];

string s[2];

void solve(){
	int n;
	cin >> n >> s[0] >> s[1];
	int c = 0;
	if (s[0][0] == s[1][0]){
		dp[0] = 3;
		c = 1;
	} else {
		dp[1] = 6;
		c = 2;
	}
	for(; c < n; ){
		if (s[0][c] == s[1][c]){
			if (s[0][c - 1] == s[1][c - 1]){
				dp[c] = (dp[c - 1] * 2ll) % MOD;
			} else {
				dp[c] = dp[c - 1];
			}
			c++;
		} else {
			if (s[0][c - 1] == s[1][c - 1]){
				dp[c + 1] = (dp[c - 1] * 2ll) % MOD;
			} else {
				dp[c + 1] = (dp[c - 1] * 3ll) % MOD;
			}
			c += 2;
		}
	}
	cout << dp[n - 1] << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

int a, b, k;
vector<int> gcd;

int main()
{
  cin >> a >> b >> k;
  for(int i = 1; i <= max(a,b); i++) {
    if(a % i == 0 && b % i == 0)
      gcd.push_back(i);
  }
  sort(gcd.begin(), gcd.end(), greater<int>());
  
  cout << gcd[k-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE 100100
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, a, b;

int main() {
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	double T,X;
	cin>>T>>X;
	cout<<(T/X);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
unsigned int countSetBits(unsigned int n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}
int main()
{
    Fast;
    long long t,n,m,i,j,k,x=0,y=0,z;
    cin>>n;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    vector<long long>v;
    k=n;
    while(k!=0){
        k=k/2;
        y++;
    }
    //cout<<y<<endl;
    for(i=0;;i++){
        if(pow(2,i)>1000000000000){
            break;
        }
        x=pow(2,i);
        v.push_back(x);

    }
    x=0;
    for(i=0;i<y;i++){
        x=x+v[i];
    }
    cout<<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 3e5 + 1;

int a[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, a, b, c;
    cin >> n >> a >> b;
    if (a > b) {
        cout << 0;
        return 0;
    }
    if (n == 1 && a != b) {
        cout << 0;
        return 0;
    }
    cout << (a + b * (n - 1)) - (b + a * (n - 1)) + 1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N, Y;
	cin >> N >> Y;

	for (int i = 0; i <= N; i++)
	{
		for (int j = 0; j <= N; j++)
		{
			if (i + j <= N)
			{
				int k = N - (i + j);
				if (i * 10000 + j * 5000 + k * 1000 == Y)
				{
					cout << i << " " << j << " " << k;
					return 0;
				}
			}
		}
	}

	cout << "-1 -1 -1";

	return 0;
}


Measured memory_bytes: 256