akhauriyash/Code-Regression huggingface dataset:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = II()
    dd = MII()
    DIV = 998244353
    if dd[0] != 0:
        print(0)
        return None
    dist = [0]*n
    for d in dd:
        dist[d] += 1
    res = 1
    for d in dd[1:]:
        res *= dist[d-1]
        res %= DIV
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14908
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    string s;
    cin >> s;
    if (s.back() == 's') s += "es";
    else s += "s";
    cout << s << '\n';
}

Measured memory_bytes: 3648
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().ok().unwrap() );
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().ok().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
    ($vec:ty;) => ( get_string().split_whitespace().map(|v| v.parse::<$vec>().ok().unwrap()).collect::<Vec<$vec>>() );
}

use std::collections::HashMap;
fn main() {
    let _n = input!(u64);
    let a = input!(u64;);
    let mut counter = HashMap::new();
    for i in a {
        let data = match counter.get(&i) {
            None => 1,
            Some(x) => x + 1,
        };
        counter.insert(i, data);
    }
    let mut ans = 0;
    for (k, v) in counter {
        if k < v {
            ans += v - k;
        } else if k > v {
            ans += v;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 13560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll ans=0;
    cin>>n;
    vec L(n);
    rep(i,n) cin>>L[i];
    rep(i,n)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++){
        vec A(3);
        A[0]=L[i],A[1]=L[j],A[2]=L[k];
        sort(all(A));
        if(A[0]==A[1]||A[1]==A[2]) continue;
        if(A[0]+A[1]>A[2]) ans++;
    }
    cout<<ans;
}

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

#define fast_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define show(x) cout << #x << " = " << x << '\n'
#define ll long long
#define ull unsigned long long
#define PI 3.1415926535897932384626433832795
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("-ffloat-store")


int main()
{
    fast_IO
    int n, a, b, cnt = 0; cin >> n;
    bool flag = false;
    while (n--)
    {
        cin >> a >> b;
        if (a == b) cnt++;
        else cnt = 0;
        if (cnt == 3) flag = true;
    }
    cout << (flag ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

const int DIR[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int INF = 1e9;

int main() {
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> fld(h);
  int white = 0;
  FOR(f,fld) {
    cin >> f;
    white += count(f.begin(), f.end(), '.');
  }
  queue<PI> que;
  que.push({0, 0});
  vector<VI> dist(h, VI(w, INF));
  dist[0][0] = 0;
  while(!que.empty()) {
    PI p = que.front();
    int i = p.first;
    int j = p.second;
    que.pop();
    REP(d,0,4) {
      int di = i + DIR[d][0];
      int dj = j + DIR[d][1];
      if(!(di >= 0 && di < h && dj >= 0 && dj < w)) {
        continue;
      }
      if(fld[di][dj] == '#' || dist[i][j] + 1 >= dist[di][dj]) {
        continue;
      }
      dist[di][dj] = dist[i][j] + 1;
      que.push({di, dj});
    }
  }
  if(dist[h-1][w-1] == INF) {
    cout << -1 << endl;
  } else {
    cout << white - dist[h-1][w-1] - 1 << endl;
  }
  
  return 0;
}


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

using namespace std;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long
#define lson node<<1
#define rson (node<<1)+1

const int maxn=2e6+10;
const int mod=998244353;
const double pi=-acos(-1);

int v[maxn];
struct Prime
{
    int prime[maxn];
    int s;
    Prime()
    {
        for(int i=2; i<maxn; i++)
        {
            if(!v[i])
            {
                prime[s++]=i;
                for(int j=2; j*i<maxn; j++)
                    v[i*j]=1;
            }
        }
    }
};
Prime p;
ll a[maxn];
int main()
{
//    int n;
//    sint(n);
//    for(int i=0;i<n;i++)
//       sll(a[i]);
//   ll sum=1;
//   for(int i=0;i<n;i++)
//    {
//        sum*=a[i];
//        if(sum>1e18||sum<0)
//        {
//            sum=-1;
//            break;
//        }
//    }
//    printf("%lld\n",sum);
//    double a,b;
//    scanf("%lf %lf",&a,&b);
//    printf("%.0f",a*b);
    ll n;
    sll(n);
    int sum=0;
    for(int i=0; i<p.s&&n>p.prime[i]; i++)
    {
        int s=0,t=1;
        int k=p.prime[i];
        while(n%k==0)
        {
            s++;
            if(s==t)
            {
                sum++;
                t++;
                s=0;
            }
            n/=k;
        }
    }
    if(n!=1)
        sum++;
    printf("%d",sum);
    return 0;
}


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

ll MOD = 1000000007;

int main()
{
  string s;
  int d;
  cin >> s >> d;
  int n = s.size();
  reverse(s.begin(), s.end());
  
  vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(d, vector<ll>(2, 0)));
  
  rep(i, 10) dp[0][i%d][i <= (s[0] - '0')]++;
  for(int i = 1; i < n; i++)
  {
    rep(j, d)
    {
      rep(k, 10)
      {
        int c = s[i] - '0';
        dp[i][(j+k)%d][k < c] = (dp[i][(j+k)%d][k < c] + dp[i - 1][j%d][0]) % MOD;
        dp[i][(j+k)%d][k <= c] = (dp[i][(j+k)%d][k <= c] + dp[i - 1][j%d][1]) % MOD;
      }
    }
  }
  
  cout << (MOD + dp[n-1][0][1] - 1) % MOD << endl;
  
  return 0;
}

Measured memory_bytes: 55296
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 1000000007
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define MOD 1000000007
//vector<int>adj[N];
//vector<bool>vis(N,false);
//const int INF = 1e9;
ll fastpower(ll a, ll b){
    ll res = 1;
    a %= N;
    while(b){
        if(b&1) res = (res * a) % N;
        a *= a; a %= N;
        b >>= 1;
    }
    return res;
}
int main() 
{
	
	    	ll n,i,j,g,temp,sum,ans=0,k;
	    	cin>>n>>k;
	    	ll dp[k+1];
	    	for(i=k;i>=1;i--)
	    	{
	    		g=k/i;
	    		temp=fastpower(g,n);
	    		sum=0;
	    		for(j=2*i;j<=k;j+=i)
	    		{
                   sum+=(dp[j]%N);  
	    		}
	    		dp[i]=temp-sum;
	    		//cout<<sum<<" "<<temp<<" "<<dp[i]<<endl;
	    	}
	    	for(i=1;i<=k;i++)
	    		{
	    			ans+=(dp[i]*i)%N;}
	    	    cout<<ans%N<<endl;
 
}

Measured memory_bytes: 4376
#include<stdio.h>
int main(void){
	double n,syo;
	int sei,ans[12],i;
	for(i=0;i<12;i++){
		ans[i]=0;
	}
	while(1){
		scanf("%lf",&n);
		if(n==-1.0)
			break;
		sei=128;
		for(i=11;i>3;i--){
			if(n>=sei){
				ans[i]=1;
				n-=sei;
			}
			else {
				ans[i]=0;
			}	
			sei/=2;
		}
		if(n>=1.0){
			printf("NA\n");
		}
		else {
			syo=0.5;
			for(i=3;i>=0;i--){
				if(n>=syo){
					ans[i]=1;
					n-=syo;
				}
				else {
					ans[i]=0;
				}
				syo/=2.0;
			}
			if(n>0.0){
				printf("NA\n");
			}
			else {
				for(i=11;i>=0;i--){
					if(i==3){
						printf(".");
					}
					printf("%d",ans[i]);
				}
				printf("\n");
			}
		}
	//	syo=0.5;
	}
	return 0;
}

Measured memory_bytes: 1076
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
typedef pair<int,int> P;
int main(void)
{
	int i,j,k,n,a1,a2,a[50][6],l,cnt,mx;
	P pp[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		for(j=0;j<6;j++)	{
			scanf("%d %d",&a1,&a2);
			a[i][j]=a1*60+a2;
		}
	}
	mx=0;
	for(i=0;i<60*24-1;i++)	{
		for(j=i+1;j<60*24;j++)	{
			l=0;
			for(k=0;k<n;k++)	{
				if(i>=a[k][0] && i<=a[k][1] && j>=a[k][2] && j<=a[k][3])	{
					pp[l].first=a[k][4];	pp[l].second=1;
					pp[l+1].first=a[k][5]+1;	pp[l+1].second=-1;
					l+=2;
				}
			}
			sort(pp,pp+l);
			cnt=0;
			for(k=0;k<l;k++)	{
				cnt+=pp[k].second;
				mx=max(mx,cnt);
			}
		}
	}
	printf("%d\n",mx);
	return 0;
}


Measured memory_bytes: 2768
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 2000000
#define MOD 1000000007
#define endl "\n"
lli N,K;
lli pref[MAX];
string arr[MAX];
lli factorial[MAX];
lli factinv[MAX];
vector <lli> iarr;
lli possum = 0;
lli ms = 0;
#define m 998244353  
// C function for extended Euclidean Algorithm 
lli gcdExtended(lli a, lli b, lli *x, lli *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    lli x1, y1; // To store results of recursive call 
    lli gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
lli modInverse(lli a) 
{ 
    lli x, y,res; 
    lli g = gcdExtended(a, m, &x, &y); 
    res = (x%m + m) % m; 
    return res;
}  
long long binpow(long long a, long long b) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
lli nci(lli n, lli i){
    return factorial[n]*factinv[i]%m*factinv[n-i]%m;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    factorial[0] = 1;
    for (int i = 1; i <= MAX/10; i++) {
        factorial[i] = factorial[i - 1] * i % m;
     }
    for (int i = 1; i <= MAX/10; i++) {
        factinv[i] = modInverse(factorial[i]);
    }
   // cout<<nci(5,0);
   lli ans = 0;
    lli N,M,K;
    cin>>N>>M>>K;
    
    for(lli i = 0; i<=K; i++){
        lli qty = 0;
        qty += M*binpow(M-1,N-i-1);
        qty %=m;
        if(i != 0 && i != N-1)
            qty *= nci(N-1,i);
        qty %=m;
        ans += qty;
        ans %=m;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    

}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BTouitsu {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;
	    in >> n;
	    string a, b, c;
	    in >> a >> b >> c;

	    int cnt = 0;
	    for(int i=0; i<n; i++){
	        if(a[i] == b[i] && b[i] == c[i]) continue;
	        else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) cnt++;
	        else cnt+=2;
	    }

	    out << cnt << enl;
	}
};


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


Measured memory_bytes: 256
'use strict'

function Main(input) {
  const inputList = input.split('\n');
  const n = inputList[0]
  const numberStringList = inputList[1].split(' ')
  let numberList = []
  for (let i=0; i<n; i++) {
    numberList.push(Number(numberStringList[i]))
  }
  const sortedNumberList = bubbleSort(numberList)

  let aliceTotal = 0
  let bobTotal = 0
  for (let i=0; i<n; i++) {
    if (i%2 === 0) {
      aliceTotal += sortedNumberList[n-i-1]
    } else {
      bobTotal += sortedNumberList[n-i-1]
    }
  }

  const result = aliceTotal - bobTotal

  console.log(result)
}

function bubbleSort(array) {
  let sortedArray = array.concat()

  for (let i=0; i<sortedArray.length-1; i++) {
    for (let j=0; j<sortedArray.length-1-i; j++) {
      if (sortedArray[j] > sortedArray[j+1]) {
        const tmp = sortedArray[j]
        sortedArray[j] = sortedArray[j+1]
        sortedArray[j+1] = tmp
      }
    }
  }

  return sortedArray
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7884
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    


int main(){
    int x=0,g=0,n,k,w,l,ans=0,ptr=0;
    string s,s1,s2;
    cin >> n >> k;
    VI a(n);
    rep(i,n){
        cin >> a[i];
	}
    rep(i,n){
        g = gcd(g,a[i]);
	}
    if(k%g==0 && k <= *max_element(ALL(a)))
        cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int n,m;
int md = pow(10,9)+7;
int nx = pow(10,5)+10;
vector<vector<int>> g(nx+1);

vector<int> vis(nx+2);
vector<string>v;

int main() {
    cin>>n>>m;
    string x;
    for(int i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
    }
    vector<vector<ll>> dp(n+2,vector<ll>(m+2,0));
    for(int i=0;i<n;i++){
        if(v[i][0]!='#'){
            dp[i][0]=1;
        }
        else break;
    }
    
    for(int j=0;j<m;j++){
        if(v[0][j]!='#'){
            dp[0][j] = 1;
        }
        else break;
    }
    
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(v[i][j]=='#'){
                dp[i][j]=0;
                continue;
            }
            dp[i][j] = (dp[i-1][j]+dp[i][j-1])%md;
        }
    }
    
    cout<<dp[n-1][m-1];
    return 0;
    
}

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

using lint = int64_t;
#define bit(n) ((lint)1 << n);
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
        cerr << fixed << setprecision(12);
    }
} iosetup;

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << ' ';
    if (x == w / 2 && y == h / 2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	H,W,K = inputMap()
	S = []
	for i in range(H):
		s = input()
		s = list(s)
		s = s[:-1]
		S.append(s)

	cnt = 1
	ans = []
	cpy = 0
	for i,val in enumerate(S):
		tmp = []
		flg1 = False
		flg2 = False

		flg3 = False

		for j,vol in enumerate(val):
			if vol == "#":
				flg2 = True

				if flg1 == False:
					flg1 = True
					tmp.append(cnt)
				else:
					if flg3 == False:
						flg3 = True
						cnt += 1
						tmp.append(cnt)
					else:
						flg3 = False
						cnt += 1
						tmp.append(cnt)
			else:
				tmp.append(cnt)

		#print(flg2)
		if flg2 == False:
			if len(ans) > 0:
				ans.append(ans[-1])
			else:
				cpy += 1
		else:
			ans.append(tmp)
			#print(cpy)
			for i in range(cpy):
				#print("dddd")
				ans.append(tmp)
			cpy = 0
			cnt += 1

	for i in ans:
		print(*i)


if __name__ == "__main__":
	main()


Measured memory_bytes: 51164
"""
5
3 2 2 4 1
1 2 2 2 1
"""

n = int(input())
array = [[int(x) for x in input().split()], [int(x) for x in input().split()]]

res = 0
for i in range(n):
    tmp = sum(array[0][:i+1])+sum(array[1][i:])
    if tmp > res:
        res = tmp
print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int n, m, q;
int a[55], b[55], c[55], d[55];

int rec(int prev, int len, int* ary) {
    if (len == n) {
        int sum = 0;
        for (int i = 0; i < q; i++) {
            if (ary[b[i]] - ary[a[i]] == c[i]) sum += d[i];
        }
        return sum;
    }
    int res = 0;
    for (int i = prev; i <= m; i++) {
        ary[len] = i;
        res = max(res, rec(i, len + 1, ary));
    }
    return res;
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    int ary[n];
    int ans = rec(1, 0, ary);
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main (){
	int n,m; cin >> n >> m;
	cout << (1900*m + 100*(n-m))*pow(2,m) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int answer(int a,int b);

int main(void){
	int num=0;
    int a,b;
    
    scanf("%d",&a);
    scanf("%d",&b);
	num=answer(a,b);
	
	switch(num){
	case 1:
	printf("a < b\n");
	break;
	case 2:
	printf("a > b\n");
	break;
	case 3:
	printf("a == b\n");
	break;
	}
    return 0;
}

int answer(int a, int b){
	
	if(a<b){
	return 1;
	}else if(a>b){
	return 2;
	}else{
	return 3;
	}
}

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

#define fast_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define show(x) cout << #x << " = " << x << '\n'
#define ll long long
#define ull unsigned long long
#define pi 3.141592654

int main()
{
    fast_IO
    int n, m, x, y; cin >> n >> m;
    unordered_map<int, int> mp;
    for (int i = 1; i <= n; i++) mp[i] = 1;
    unordered_set<int> us;
    us.insert(1);
    while (m--)
    {
        cin >> x >> y;
        auto find_x = us.find(x), find_y = us.find(y);
        if (find_x != us.end())
        {
            if (mp[x] == 1) us.erase(find_x);
            if (find_y == us.end()) us.insert(y);
        }
        mp[x]--; mp[y]++;
    }
    cout << us.size() << '\n';
    return 0;
}

Measured memory_bytes: 11444
#include <iostream>
using namespace std;
int main(){
  int isPrime[1000001];
  fill(isPrime,isPrime + 1000001,1); 
  isPrime[0]=isPrime[1]=0;
  for(int i = 2 ; i*i < 1000001 ; i++ ){
    if(isPrime[i])for(int j = i*2 ; j < 1000001 ; j+=i )isPrime[j] = 0;
  }
  int n;
  while(cin >> n,n){
    int cnt = 0;
    for(int i = 2 ; i <= n/2 ; i++){
      if(isPrime[i] == 1 && isPrime[n-i] == 1)cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var Nu = Math.Floor(Math.Floor(N / 1.08)*1.08);
            var Nd = Math.Floor(Math.Ceiling(N / 1.08)*1.08);
            
            if(Nu == N)
            {
                Console.WriteLine(Math.Floor(N / 1.08));
            }else if (Nd ==N)
            {
                Console.WriteLine(Math.Ceiling(N / 1.08));

            }
            else
            {
                Console.WriteLine(":(");

            }



        }

    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int calcmax(vec &A, vec &B, int K){
    int ans = 0;
    REP(i, A.size()) if((A[i] | K) == K) ans += B[i];
    return ans;
}

signed main(){

    int N, K; cin >> N >> K;
    vec A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];

    int ans = calcmax(A, B, K);
    REP(i, 32){
        if((K >> i) % 2 == 0) continue;
        int k = (K >> (i + 1)) << (i + 1);
        k += (1 << i) - 1;
        ans = max(ans, calcmax(A, B, k));
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1920
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

bool isVowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

int main(){ 
    do_not_disturb
    double n, i;
    cin >> n;
    for(i = 1; i <= n; i++){
	if(abs(n-(floor(i*1.08))) <= eps){
	    cout << i;
	    return 0;
	}
    }cout << ":(";
    
    return 0;
} // What is to be written here?


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

#define LEN 100000

int S[LEN];

int main(int argc, char *argv[])
{
	int n = 0, q = 0, sum = 0;
	int key = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", &S[i]);

	cin >> q;
	for (int i = 0; i < q; i++) {
		scanf("%d", &key);
		if (*lower_bound(S, S + n, key) == key)
			sum++;
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 3508
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int[] A = new int[N];
			
			int count =0;
			
			
			for(int i=0;i<N;i++) {//拡張for文は指示できるものと：格納したもの達
				A[i] = scan.nextInt();
			}
			
			Arrays.sort(A);
			
			StringBuffer sb = new StringBuffer();
			
			for(int i = 0;i<N;i++) {
				sb.append(String.valueOf(A[i]));
			}
			
			int start =0;
			int fin =0;
						
			for(int i = 0;i<N-1;i++) {
				
				if(A[i]!=A[i+1]) {
					fin = i+1;
					String sub = sb.toString().substring(start, fin);
					
					if(sub.length()%2==1) {
						count+=1;
					}
					start = i+1;	
					
					if(i==N-2) {
						count+=1;
					}
				}
				
				if(A[i]==A[i+1]&&i==N-2) {
					fin = N;
					String sub = sb.toString().substring(start, fin);
					if(sub.length()%2==1) {
						count+=1;
					}
					
				}
				
				
				
			}
			
			
			System.out.println(count);
						
		}
		
	}

}


Measured memory_bytes: 61124
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

typedef long long ll;
const int maxn=200010;
int n;
int a[maxn][25];
int pre[maxn][25];

void chkmax(int& x,int y){ if(x<y) x=y; }

int main(){

	scanf("%d", &n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d", &x);
		for(int j=0;j<21;j++) if(x & (1<<j)) a[i][j]=1;
	}
	for(int i=1;i<=n;i++) for(int j=0;j<21;j++) pre[i][j]=a[i-1][j] ? i-1 : pre[i-1][j];
	ll ans=0;
	for(int i=1;i<=n;i++){
		int Max=0;
		for(int j=0;j<21;j++){
			int t=i;
			if(!a[i][j]) t=pre[ pre[i][j] ][j];
			else t=pre[i][j];
			chkmax(Max, t+1);
		}
		ans+=i-Max+1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 39168
#include <bits/stdc++.h>
#define LL long long

using namespace std;

template<typename tp> inline void read(tp &x) {
	x = 0; register char c = getchar(); register bool f = 0;
	for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}

int main(){
    int x;
    scanf("%d",&x);
    for(int i = 1; i < 10; ++i) {
        for(int j = 1; j < 10; ++j) {
            if(x == i * j) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    yorn(a % 2 == 1 && b % 2 == 1)
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
 int a[101];

int main()
{
    int n;
    cin >> n;
    int even = 0;
    int even1 = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++){
        if(a[i] %2 == 0){
            even++;
            if(a[i] %3 == 0 || a[i] %5 == 0)
                even1++;
        }
    }
    if(even == even1)
        cout << "APPROVED";
    else 
        cout << "DENIED";
    

}


Measured memory_bytes: 256
object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val data = Iterator.continually {
    val H  = scanner.nextInt()
    val W  = scanner.nextInt()

    (H, W)
  }

  val outputs = data.takeWhile(_ != (0, 0)).map {
    case (h, w) =>
      (1 to h).map { hp =>
        (1 to w).map { wp =>
          if((hp % 2 ^ wp % 2) == 0) "#"
          else                       "."
        }.mkString
      }.mkString("\n") + "\n"
  }

  outputs.foreach(println)
}

Measured memory_bytes: 49396
var
	T1,T2,A1,A2,B1,B2,dif,D,X,Y,ans:int64;
begin
	read(T1,T2,A1,A2,B1,B2);
	X:=A1*T1+A2*T2;
	Y:=B1*T1+B2*T2;
	if X=Y then writeln('infinity')
	else begin
		if X>Y then begin
			dif:=B1*T1-A1*T1;
			D:=X-Y;
		end else begin
			dif:=A1*T1-B1*T1;
			D:=Y-X;
		end;
		if dif<0 then writeln(0)
		else if dif=0 then writeln(1)
		else begin
			ans:=1;
			dec(dif,D);
			if dif>=0 then begin
				inc(ans,dif div D*2);
				dif:=dif mod D;
				inc(ans,2);
				if dif=0 then dec(ans);
			end;
			writeln(ans);
		end;
	end;
end.

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CRectangleCutting {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long w = in.nextLong(), h = in.nextLong(), x = in.nextLong(), y = in.nextLong();
//        if(h*Math.abs(w-2*x) < w*Math.abs(h-2*y)){
//            double ans = Math.min(h*x, h*(w-x));
//            out.println( String.format("%.6f 0",ans));
//        }
//        if(h*Math.abs(w-2*x) == w*Math.abs(h-2*y)){
//            double ans = Math.min(h*x, h*(w-x));
//            out.println( String.format("%.6f 1",ans));
//        }
//        if(h*Math.abs(w-2*x) > w*Math.abs(h-2*y)){
//            double ans = Math.min(w*y, w*(h-y));
//            out.println( String.format("%.6f 0",ans));
//        }
            double area;
            int d;
            area = ((double) w * (double) h) / 2.0d;
            if (w / 2 == x && w % 2 == 0 && h / 2 == y && h % 2 == 0) {
                d = 1;
            } else {
                d = 0;
            }
            out.println(String.format("%.6f %d", area, d));
        }

    }
}



Measured memory_bytes: 21844
N=int(input())
tb=0
xb=0
yb=0
c=0
for n in range(N):
  ta,xa,ya=map(int,input().split())
  td=ta-tb
  xd=abs(xa-xb)
  yd=abs(ya-yb)
  if td>=xd+yd and (td-xd-yd)%2==0:
    tb=ta
    xb=xa
    yb=ya
  else:
    c=1
    break

if c==0:
  print('Yes')
else:
  print('No')


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}





void _main() {
        string s; cin >> s;
        sort(all(s));
        for (char c = 'a'; c <= 'z'; c++) {
                if (!binary_search(all(s), c)) {
                        cout << c;
                        return;
                }
        }

        cout << "None";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

using namespace std;

const int maxn = 1e6 + 5;
const int MOD = 1e9 + 7;

struct mi {
      long long v;
      explicit operator long long() const { return v; }
      mi() { v = 0; }
      mi(long long _v) { v = (-MOD < _v && _v < MOD) ? _v : _v % MOD; if (v < 0) { v += MOD; } }

      friend bool operator == (const mi& a, const mi& b) { return a.v == b.v; }
      friend bool operator != (const mi& a, const mi& b) { return !(a == b); }
      friend bool operator < (const mi& a, const mi& b) { return a.v < b.v; }

      mi& operator += (const mi& m) { if ((v += m.v) >= MOD) { v -= MOD; } return *this; }
      mi& operator -= (const mi& m) { if ((v -= m.v) < 0) { v += MOD; } return *this; }
      mi& operator *= (const mi& m) { v = v * m.v % MOD; return *this; }
      mi& operator /= (const mi& m) { return (*this) *= inv(m); }

      friend mi pow(mi a, long long p) { mi ans = 1; assert(p >= 0); for (; p; p /= 2, a *= a) { if (p & 1) { ans *= a; } } return ans; }
      friend mi inv(const mi& a)       { assert(a.v != 0); return pow(a, MOD - 2); }

      mi operator - () const { return mi(-v); }
      mi& operator ++ () { return *this += 1; }
      mi& operator -- () { return *this -= 1; }
      mi operator ++ (int) { mi temp; temp.v = v++; return temp; }
      mi operator -- (int) { mi temp; temp.v = v--; return temp; }

      friend mi operator + (mi a, const mi& b) { return a += b; }
      friend mi operator - (mi a, const mi& b) { return a -= b; }
      friend mi operator * (mi a, const mi& b) { return a *= b; }
      friend mi operator / (mi a, const mi& b) { return a /= b; }

      friend ostream& operator << (ostream& os, const mi& m) { os << m.v; return os; }
      friend istream& operator >> (istream& is, mi& m) { long long x; is >> x; m.v = x; return is; }
};

int spf[maxn]; 

void sieve() {
	for (int i = 2; i < maxn; i++) {
		spf[i] = i;
	}
	for (int i = 2; i < maxn; i++) {
		for (int j = 1; 1LL * i * j < maxn; j++) {
			spf[i * j] = min(spf[i * j], i);
		}
	}
} 

int maxOcc[maxn];

void primeFactor(int n) {
	map <int, int> mp;
	while (n > 1) {
		int pf = spf[n];
		while (n % pf == 0) {
			mp[pf]++;
			n /= pf;
		}
	}
	for (auto it : mp) {
		maxOcc[it.first] = max(maxOcc[it.first], it.second);
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	
	sieve();
	
	int n;
	cin >> n;
	vector <int> vec(n + 1);
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		vec[i] = x;
		primeFactor(x);
	}
	mi ans = 1;
	for (int i = 1; i < maxn; i++) {
		ans = ans * pow(mi(i), maxOcc[i]);
	}
	mi sum = 0;
	for (int i = 1; i <= n; i++) {
		mi temp = ans;
		int x = vec[i];
		while (x > 1) {
			int pf = spf[x];
			while (x % pf == 0) {
				x /= pf;
				temp /= pf;
			}
		}
		sum += temp;
	}
	cout << sum << endl;
}

Measured memory_bytes: 10036
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
b = list(a)
a.sort(reverse=True)

max_num = max(a)
count = a.count(max_num)

for i in a:
    if i < max_num:
        max_num2 = i
        break

for i in range(n):
    if b[i] == max_num and count == 1:
        print(max_num2)
    else:
        print(max_num)

Measured memory_bytes: 70104
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	map<int, int> mp;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		ans += mp[i - x];
		mp[i + x]++;
	}
	cout << ans;
}

Measured memory_bytes: 20660
def prime(num):
    if num == 0:
        return False
    elif num == 1:
        return False
    elif num == 2:
        return True
    i = 2
    while True:
        if i**2 > num:
            break
        if num%i==0:
            return False
        i += 1
    return True
n = int(raw_input())

nums = []
for _ in range(n):
    a = int(raw_input())
    nums.append(a)

ret = 0
for num in nums:
    if prime(num):
        ret += 1
print ret

Measured memory_bytes: 6880
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w;
  int n;
  cin >> h >> w >> n;
  map<ll, int> mp;
  int dx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
  int dy[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
  rep(i, n) {
    ll a, b;
    cin >> a >> b; a--; b--;
    rep(k, 9) {
      int nx = a+dx[k];
      int ny = b+dy[k];
      if(nx < 1 || nx >= h-1 || ny < 1 || ny >= w-1) continue;
      mp[nx*w+ny]++;
    }
  }
  vector<ll> ans(10);
  for(auto ele: mp) {
    ans[ele.second]++;
  }
  ans[0] = (h-2)*(w-2)-accumulate(all(ans), 0);
  rep(i, 10) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 59908
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
#include <cassert>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

ostream& operator<<(ostream& os, const pair<char, int>& unit) {
  return os << unit.first << "^" << unit.second;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n = 500;
  int val = n * n / 4;
  vector<vector<ll>> ans(n + 2, vector<ll>(n + 2, 1));
  int cnt = 0, l = 3, r = val * 2 + 1;
  set<ll> st;
  for (int i = 3; i <= n * 2; i += 2)
    for (int x = max(1, i - n), y = i - x; x + 1 <= n && y - 1 > 0; x += 2, y -= 2) {
      if (++cnt & 1) {
        ans[x][y] = l;
        ans[x + 1][y - 1] = l * 2;
        st.insert(l); st.insert(l * 2);
        l += 2;
      } else {
        ans[x][y] = r;
        ans[x + 1][y - 1] = r * 2;
        st.insert(r); st.insert(r * 2);
        r -= 2;
      } 
    }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      if (ans[i][j] == 1) {
        ll l = lcm(lcm(ans[i - 1][j], ans[i + 1][j]), lcm(ans[i][j - 1], ans[i][j + 1]));
        ll v = 1;
        while (st.count(v * l + 1)) ++v;
        ans[i][j] += l * v;
        st.insert(ans[i][j]);
      }
//      assert(ans[i][j] <= 1e15);
    }
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cout << vector<ll>(ans[i].begin() + 1, ans[i].begin() + n + 1) << '\n';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 16640
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		Main mySystem = new Main();
		int n = scan.nextInt();
		int s = scan.nextInt();
		while(n != 0 || s != 0){
			if(s > 45){
				System.out.println("0");
			}else{
				System.out.println(mySystem.search(0, 0, 0, s, n, 9));
				//int a = mySystem.puras(num+1 , sum , cnt+1 , s , n)+mySystem.puras(num+1 , sum , cnt , s , n);
			}
			n = scan.nextInt();
			s = scan.nextInt();
		}
	}
	public int search(int num , int sum , int cnt, int target, int maxcount, int maxvalue){
		if(sum == target && cnt == maxcount){
			return 1;
		}else if(num > maxvalue || sum > target || cnt > maxcount){
			return 0;
		}
		
		return search(num+1,sum+num,cnt+1,target,maxcount,maxvalue)+search(num+1,sum,cnt,target,maxcount,maxvalue);
		
		
	}
}

Measured memory_bytes: 26364
unittest
{
	assert( [ "4", "3 1 3 2" ].parse.expand.solve == 1 );
	assert( [ "6", "105 119 105 119 105 119" ].parse.expand.solve == 0 );
	assert( [ "4", "1 1 1 1" ].parse.expand.solve == 2 );
	
	assert( [ "10", "1 1 1 1 1 1 3 2 3 4" ].parse.expand.solve == 5 );		// 追加ケース
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto vs = input.front.split.to!( long[] );
	return tuple( vs );
}

auto solve( long[] vs )
{
	// 偶数番目と奇数番目で分別
	long[ long ] es;
	long[ long ] os;
	foreach( i, v; vs )
	{
		if( i % 2 == 0 ) es[ v ] = es.get( v, 0 ) + 1;
		else             os[ v ] = os.get( v, 0 ) + 1;
	}
	
	// 偶数番目のうち、一番目と二番目に多い数を検索
	auto em1 = tuple( 0L, 0L );
	auto em2 = tuple( 0L, 0L );
	foreach( e; es.byPair )
	{
		if( em1[ 1 ] < e[ 1 ] )
		{
			em2 = em1;
			em1 = e;
		}
		else if( em2[ 1 ] < e[ 1 ] )
		{
			em2 = e;
		}
	}
	
	// 奇数番目のうち、一番目と二番目に多い数を検索
	auto om1 = tuple( 0L, 0L );
	auto om2 = tuple( 0L, 0L );
	foreach( o; os.byPair )
	{
		if( om1[ 1 ] < o[ 1 ] )
		{
			om2 = om1;
			om1 = o;
		}
		else if( om2[ 1 ] < o[ 1 ] )
		{
			om2 = o;
		}
	}
	
	// 偶数番目と奇数番目で一番目に多い数が同じだったら二番目に多い数を使う
	if( em1[ 0 ] == om1[ 0 ] )
	{
		if( em1[ 1 ] + om2[ 1 ] < em2[ 1 ] + om1[ 1 ] ) em1 = em2;
		else                                            om1 = om2;
	}
	
	// 書き換え対象の数を計算
	return vs.length - em1[ 1 ] - om1[ 1 ];
}


Measured memory_bytes: 11964
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i=0;i<n;i++)
		cin>>d[i];
	int k,cnt;
	sort(d.begin(),d.end());

	//{for(k = d[n/2-1]+1;k<=d[n/2];k++)
	//	cnt++;}
	cnt=d[n/2]-d[n/2-1];
if(d[n/2-1]==d[n/2])
		cnt=0;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


int solve(int n, int m, const vector<int64_t> & h, const vector<vector<int> > & g) {
    int cnt = 0;
    REP (i, n) {
        int64_t max_h = INT64_MIN;
        for (int j : g[i]) {
            max_h = max(max_h, h[j]);
        }
        cnt += (max_h < h[i]);
    }
    return cnt;
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int N, M;
    cin >> N;
    vector<int64_t> H(N);
    cin >> M;
    REP (i, N) {
        cin >> H[i];
    }
    vector<vector<int> > g(N);
    REP (i, M) {
        int a, b; cin >> a >> b;
        -- a;
        -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    auto ans = solve(N, M, H, g);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9220