akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        H: usize,
        W: usize,
        h: usize,
        w: usize,
    }

    println!("{}", H*W+h*w-h*W-H*w);

}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef pair<int, int> pii;
pii operator+(const pii& a, const pii& b){
    return make_pair(a.first +b.first, a.second +b.second);
}
pii operator-(const pii& a, const pii& b){
    return make_pair(a.first -b.first, a.second -b.second);
}
int len(const pii& a){
    return a.first*a.first +a.second*a.second;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        set<pii> a;
        for(int i=0; i<n; i++){
            int x,y;
            cin >> x >> y;
            a.insert(make_pair(x, y));
        }

        int ans = 0;
        for(pii p: a){
            for(pii q: a){
                pii diff((p-q).second, -(p-q).first);
                if(a.find(p+diff) != a.end() && a.find(q+diff) != a.end()){
                    ans = max(ans, len(diff));
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3220
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int main()
{
long long int n,d,x,y,ans=0;
scanf("%lld %lld",&n,&d);
for(int i=0;i<n;i++)
{
 scanf("%lld %lld",&x,&y);
 if((x*x+y*y)<=d*d){ans++;}
}
printf("%d",ans);
}

Measured memory_bytes: 3824
import java.util.*;

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

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();

      int ans = 0;

if(a+b>=c-1){
//////////////////////////////////////////////
ans = b + c;
//////////////////////////////////////////////
}
else{
//////////////////////////////////////////////
for(int i=1;i<c;i++){
  if(a+b>=c-1-i){
    ans = c-i+b;
    break;
  }
}
//////////////////////////////////////////////
}


      System.out.println(ans);

    }
}


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

using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin >> n;
    if(n & 1)
    {
        cout << 0 << "\n";
        exit(0);
    }
    n /= 2;
    ll br = 0;
    for(ll i = 5; i <= n; i *= 5)
    {
        br += n / i;
    }

    cout << br << "\n";
}


Measured memory_bytes: 3572
while 1:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        a += b
    elif op == '-':
        a -= b
    elif op == '*':
        a *= b
    elif op == '/':
        a //= b
    print(a)


Measured memory_bytes: 5596
# Edit: 2014/09/09
# Lang: Python3
# Time: .00s

from math import factorial

if __name__ == "__main__":
    # a, b, c, d, e, f = map(int, input().strip("\n").split(" "))
    r, c, ar, ac, br, bc = map(int, input().strip("\n").split(" "))
    maxans = 100000007  # 100,000,007
    # maxn =   100000007

    # tate Row
    dr = min(abs(br - ar), r - abs(br - ar))
    if 2 * dr == r:
        gainr = 2
    else:
        gainr = 1

    # yoko Column
    dc = min(abs(bc - ac), c - abs(bc - ac))
    if 2 * dc == c:
        gainc = 2
    else:
        gainc = 1

    #dr = int(dr)
    #dc = int(dc)
    #gainr = int(gainr)
    #gainc = int(gainc)

    # print(dr, dc)
    # print(gainr, gainc)

    ans1 = factorial(dr+dc)
    #print("ans1",ans1)
    #print("type",type(ans1))

    ans2 = factorial(dr)
    #print("ans2",ans2)
    #print("type",type(ans2))

    ans3 = factorial(dc)
    #print("ans3",ans3)
    #print("type",type(ans3))

    ans4 = ans1//ans2//ans3*gainr*gainc
    #print("ans4",ans4)
    #print("type",type(ans4))

    ans = ans4
    ## ans = factorial(dr + dc) / factorial(dr) / factorial(dc) # * gainr * gainc
    # python overflow error integer division result too large for a float

    #ans = factorial(dr + dc) // factorial(dr) // factorial(dc) * gainr * gainc


    # t = 1
    #for i in range(dr, dr + dc):
    #print(t)
    #    t *= i
    #ans = t / factorial(dc) * gainr * gainc

    #print(ans)
    #print(ans, type(ans))
    print(ans % maxans)

    # print("34807775")
    #67,352,549

Measured memory_bytes: 6796
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char (ord, isDigit)
import Data.Bits
import Data.Int
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import GHC.IO.Handle (hGetChar)
import System.IO (stdin)

-- Assume that input has non-digit symbol at the end.
readIONat :: (Bits a, Integral a) => IO a
readIONat = do
  let reader ch = fromIntegral $ ord ch - ord '0'

  digit0 <- fix
    (\(!f) (!_) -> do
      ch <- hGetChar stdin
      if isDigit ch then return ch else f ch
    )
    ' '
  flip fix (return $ reader digit0) $ \(!f) (!acc) -> do
    s <- hGetChar stdin
    if not (isDigit s)
      then acc
      else do
        a <- acc
        let a' = shiftL a 1 + shiftL a 3 + reader s
        a' `seq` f (return a')

solve :: Int -> VU.Vector Int16 -> Int32
solve !n !hs = fst dp
 where
  -- dp[i]: minimal cost of moving from 1st to i-th place
  dp :: (Int32, Int32)
  dp = VU.foldl'
    (\(!dp1, !dp2) (!i, !v) -> if i == 0
      then (0, dp1)
      else if i == 1
        then (dp1 + abs (fromIntegral $ v - hs VU.! 0), dp1)
        else
          ( min (dp1 + abs (fromIntegral $ v - hs VU.! (i - 1)))
                (dp2 + abs (fromIntegral $ v - hs VU.! (i - 2)))
          , dp1
          )
    )
    (-1, -1)
    (VU.indexed hs)

main = do
  n  <- readIONat
  hs <- VU.replicateM n readIONat
  print $ solve n hs


Measured memory_bytes: 1148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();

        int answer = a * b / 2;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13268
// H.cpp
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
const int mod = 1e9 + 7;
ll h, w, dp[1001][1001];
char map[1001][1001];
int main()
{
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++)
        scanf("%s", map[i] + 1);
    dp[1][1] = 1;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
        {
            if (map[i - 1][j] == '.')
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            if (map[i][j - 1] == '.')
                dp[i][j] = (dp[i][j - 1] + dp[i][j]) % mod;
        }
    printf("%lld", dp[h][w]);
    return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	
	int ans = 0;
	REP(i,N){
		int a; cin >> a;
		if((i+1)%2 == 1 and a%2 == 1) ans++;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3552
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        
        String result = "";
        for(int i=0; i<line.length(); i++){
            char c = line.charAt(i);
            if (Character.isUpperCase(c) ) {
                result += Character.toLowerCase(c);
            } else if (Character.isLowerCase(c) ) {
                result += Character.toUpperCase(c);
            } else {
                result += c;
            }
        }
        System.out.println(result);
        
    }
}



Measured memory_bytes: 29472
#include<stdio.h>
void t(int A[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
int main(){
  int i,j,n,key,A[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  t(A,n);
  for(i=1;i<n;i++){
    key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
    }
     A[j+1]=key;
      t(A,n);
  }
  return 0;
}



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

int main()
{
  unsigned long long a[3];

  for(int i=0;i<3;i++)cin>>a[i];

  sort(a,a+3);

  if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0)cout<<0<<endl;
  else cout<<a[0]*a[1]<<endl;

  return 0;
}

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}

 
/*CODE START HERE*/
int main() {
  int n,k,q;
  cin >> n >> k >> q;
  vector <int> a(q);
  forn(i,q){
    cin >> a.at(i) ;
  }
  vector <int> p(n,0);
    forn(j,q){
      p.at(a.at(j)-1)++ ;
    }
  forn(i,n){
      if ( p.at(i)>q-k){
        cout << "Yes" << endl;
      }else {
        cout << "No" << endl;
      }
  }
}

Measured memory_bytes: 4068
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 4/28/2018

 10:15-10:33 analysis
 
 Edigorials:
 
 */

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
int N;
const int MAX_N=100001;
LL A[MAX_N];
LL solve() {
  sort(A,A+N);
  LL sum=A[0];
  int res=1;
  FOR(i,1,N) {
    if(2*sum<A[i]) res=1;
    else res+=1;
    sum+=A[i];
  }
  return res;
}

int main() {
//  ios_base::sync_with_stdio(false);
//  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdlib>
#include<math.h>
#include <algorithm>
using namespace std;
vector<int>array;

int main() {
	long long dis;
	cin >> dis;
	for(long long n = 1;n <= dis;n++) {
		long long a;
		cin >> a;
		array.push_back(a - n);
	}
	sort(array.begin(),array.end());
	long long ave;
	if(dis%2 == 0) {
		ave = round((array[array.size()/2 -1 ]+array[array.size()/2])/2);
	}else{
		ave = array[array.size()/2];
	}

	long long ans;
	for(long long n = 0;n < dis;n++) {
		ans += abs(array[n]-ave);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int curmx = 0; long long ans = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] < curmx) ans += curmx - a[i];
		else curmx = a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4372
Scanf.scanf "%d %d %d" (fun n m l ->
    let dummy = max_int / 3 in
    let wf mat =
        for i = 0 to n - 1 do
            mat.(i).(i) <- 0;
            for j = 0 to n - 1 do
                for k = 0 to n - 1 do
                    mat.(j).(k) <- min mat.(j).(k) (mat.(j).(i) + mat.(i).(k))
                done
            done
        done;
    in
    let mat = Array.make_matrix n n dummy in
    for i = 1 to m do
        Scanf.scanf " %d %d %d" (fun a b c ->
            let a, b = a - 1, b - 1 in
            mat.(a).(b) <- c;
            mat.(b).(a) <- c;
        )
    done;
    wf mat;
    let fuel = Array.make_matrix n n dummy in
    for i = 0 to n - 1 do
        for j = 0 to n - 1 do
            if i = j then fuel.(i).(j) <- 0 else
            if mat.(i).(j) <= l then fuel.(i).(j) <- 1
        done
    done;
    wf fuel;
    Scanf.scanf " %d" (fun q ->
        for i = 1 to q do
            Scanf.scanf " %d %d" (fun s t ->
                let s, t = s - 1, t - 1 in
                Printf.printf "%d\n" (if fuel.(s).(t) = dummy then -1 else fuel.(s).(t) - 1)
            )
        done
    )
)

Measured memory_bytes: 7380
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> p(n);
    for(auto &I:p){cin>>I;}
    vector<ll> used(n,E);
    used[0]=0;
    deque<ll> A;
    A.push_back(0);
    while(!A.empty()){
        ll w=A[0];
        A.pop_front();
        if(p[w]){
            if(used[w+p[w]]<=used[w]){continue;}
            A.push_front(w+p[w]);
            used[w+p[w]]=used[w];
        }
        else{
            for(int i=1;i<=6;i++){
                if(w+i>=n-1){used.back()=min(used[w]+1,used.back());}
                else if(used[w+i]==E){
                    used[w+i]=used[w]+1;
                    A.push_back(w+i);
                }
            }
        }
    }
    cout<<used.back()<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
bool compare(pair<ll,string> p1,pair<ll,string> p2){
return p2.fi>p1.fi;
}
void solve(){
  ll n;
  cin>>n;
  ll a[n];
  map<ll,ll> ma,mb;
  ll ans=0;
  fr(i,0,n){
  cin>>a[i];
  ma[i+a[i]]++;
  mb[i-a[i]]++;
  }
  tr(ma,it){
     // cout<<it->se<<" "<<mb[it->fi]<<endl;
  ans+=(mb[it->fi])*(it->se);
  }
  cout<<ans<<endl;
}
int main()
{   fast;
    ll t=1;
    //cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


Measured memory_bytes: 39456
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define MAXN (int)(2e5+5)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define start first
#define score second
const ll INF=1e18L+5;
vector< pair<ll,ll> >interval[MAXN];
vll t(4*MAXN,INF),lazy(4*MAXN,0);
void push(ll v) {
	if(!lazy[v])return;
    t[v*2] += lazy[v];
    lazy[v*2] += lazy[v];
    t[v*2+1] += lazy[v];
    lazy[v*2+1] += lazy[v];
    lazy[v] = 0;
}
ll query(ll v, ll tl, ll tr, ll l, ll r){
	if(l>r)
		return INF;
	if(l==tl and r==tr)
		return t[v];
	push(v);
	ll tm = (tl + tr)/2;
	return min(query(v*2, tl, tm, l, min(r, tm)),query(v*2+1, tm+1, tr, max(l, tm+1), r));
}
void update(ll v, ll tl, ll tr, ll l, ll r, ll addend) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] += addend;
        lazy[v] += addend;
    } else {
        push(v);
        ll tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), addend);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, addend);
        t[v] = min(t[v*2], t[v*2+1]);
    }
}	
//initially score contains all intervals
//we want to remove intervals(i.e place zeroes there) such that their score is minimum
//this score is either zero(dont remove any interval) or negative
//dp[i]-considering this is ith place is one 
//iterate over indices less than i ,say j
//and dp[i]=min(dp[j]+score of all intervals inactivated between (j,i));
int main()
{
	fastio;
	ll n,m;
	cin>>n>>m;
	ll score=0;
	for(ll i=0;i<m;i++)
	{
		ll a,b,c;
		cin>>a>>b>>c;
		interval[b].pb(mp(a,c));
		score+=c;
	}
	update(1,0,n+2,0,0,-INF);
	ll best=INF;
	for(ll i=1;i<=n+1;i++)
	{
		for(auto p:interval[i-1])
		{
			update(1,0,n+2,0,p.start-1,p.score);
		}
		best=min(best,query(1,0,n+2,0,i));
		update(1,0,n+2,i,i,best-INF);
	}
	cout<<score-best<<endl;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	int a,b,n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		ans+=(b-a+1);
	}
	cout << ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	char str[10];
	int a,p=0,q=0,r=0,s=0;
while(scanf("%d,%s",&a,str)!=EOF){
	if(strcmp(str,"A")==0){
			p++;
		}else if(strcmp(str,"B")==0){
			q++;
		}else if(strcmp(str,"AB")==0){
			r++;
		}else if(strcmp(str,"O")==0){
			s++;
		}}
printf("%d\n%d\n%d\n%d\n",p,q,r,s);
	return 0;
}

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

int main()
{
  string input;
  int a=0;
  cin >> input;

  for (int i=0; i<4; ++i) {
    if(input[i] == '-')
      --a;
    else if(input[i] =='+') 
      ++a;
  }
  cout << a << endl;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
	string s;
	std::cin >> s;
	int ans = 0;
	for (size_t i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			ans++;
		}
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<long,long>mp;
int main()
{
    long i,j,t,a,b,n,c,y,m,prev,sum,ans=1,count;
    t=1;
    // cin>>t;
    while(t--)
    {
           cin>>n>>m;
          cout<<n*n-m;
       
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>

int main()
{
	int a, b;
	std::cin >> a >> b;
	if(b % a == 0){
		std::cout << a + b << std::endl;
	}else{
		std::cout << b - a << std::endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	string S;
	char *s;

	cin >> N ;
	cin >> S;
	s = (char*)S.c_str();

	int ans = 1;
	char c1 = s[0], c2;
	for(char *p = s; *p != '\0'; p++){
		c2 = *p;
		if(c1 != c2){
			ans++;
		}
		c1 = c2;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<utility>
#include<tuple>
#include<algorithm>
#include<set>
using namespace std;

typedef vector< set<int> > sets;

int main(){
    int N, M;
    int a, b, cnt = 0;
    cin >> N >> M;
    sets E(N+1);
    vector<int> vi;
    bool flag = true;
    for(int i = 1; i <= M; i++){
        cin >> a >> b;
        E[a].insert(b);
        E[b].insert(a);
    }
    for(int i = 2; i <= N; i++){
        vi.push_back(i);
    }
    // cout << vi.size()<< endl;;
    do{
        flag = true;
        if(E[1].count(vi[0]) == 0)continue;
        for(int i = 0; i < N-2; i++){
            if(E[vi[i]].count(vi[i+1]))continue;
            else flag = false;
        }
        // cout << "flag:" <<flag << endl;
        // " vi:" << vi << endl;
        if(flag)cnt++;
    }while(next_permutation(vi.begin(), vi.end()));
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254 より

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 998244353;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let (d,t,s) = read!(i64,i64,i64);
    let a = (d+t-1)/t;
    if a<=s {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

fn run() {
    solve();
}


Measured memory_bytes: 2248
#include<cmath>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<stack>
#include<vector>
#include<string.h>
#include<string>
#include<iomanip>
#include <sstream>
#include<map>
#include<complex>
#include<set>
using namespace std;
#define rep(i,t,n)  for(ll i =(t);i<=(n);++i)
#define per(i,n,t)  for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define Decimal fixed<<setprecision(20)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 5;
typedef double db;
const db pi = acos(-1.);
ll n, k;

int d[maxn];
int main() {
	FAST_IO;

	int n;
	cin >> n;
	rep(i, 1, n)cin >> d[i];
	int ans = 0;
	rep(i, 1, n)rep(j, i + 1, n) {
		ans += d[i] * d[j];
	}
	cout << ans << endl;
}         
/*
2
A 0 0 2
B 1 0 2


*/


Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define PI             acos(-1.0)
#define IOS            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ms(a,b)         memset(a, b, sizeof(a))
#define filein      freopen("input.txt", "r", stdin);
#define fileout     freopen("output.txt", "w", stdout);
#define debug       cout<<"Hello, i am in here."<<endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u,v,x,y) sqrt((x*1.0-u*1.0)*(x*1.0-u*1.0)+(y*1.0-v*1.0)*(y*1.0-v*1.0))
using namespace std;
const int MOD = (int)1e9+7;
/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/
void solve()
{
  unordered_map<string,int>mp;
  ll n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    string x;
    cin>>x;
    mp[x]++;
  }
  cout<<"AC x "<<mp["AC"]<<endl;
   cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
     cout<<"RE x "<<mp["RE"]<<endl;

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


Measured memory_bytes: 3660
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------


int main() {
  string s, t;
  cin >> s >> t;

  // tの方が長い時、絶対に文字列を当てはめられない
  int sl = s.length(), tl = t.length();
  if(sl < tl) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  string ans = "";
  rep(i, sl-tl+1) {
    // 当てはめられるか
    bool enabled_replace = true;
    rep(j, tl) {
      if(s[i+j]!='?' && s[i+j]!=t[j]) { // この時、置き換えできない
        enabled_replace = false;
        break;
      }
    }
    if(enabled_replace) {
      string tmp = "";
      rep(k, sl) {
        if(k == i) {
          tmp += t;
          k += (tl-1);
        } else {
          tmp += (s[k]=='?' ? 'a' : s[k]);
        }
      }
      ans = (ans=="" || ((tmp<ans) > 0) ? tmp : ans);
    }
  }

  if(ans != "") {
    cout << ans << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
arX = [list(map(int, input().split()))[:D] for n in range(N)]

import math

count = 0
for x in range(len(arX)):
    xp = arX[x]
    for y in range(x, len(arX)):
        if x == y:
            continue
        
        yp = arX[y]
        
        powSum = 0
        for d in range(D):
            powSum += (xp[d] - yp[d]) ** 2
        
        #print(x, y, sqPowSum)
            
        sqPowSum = math.sqrt(powSum)
        if sqPowSum == int(sqPowSum):
            count += 1

print(count)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
int n , m;
int a[N] , b[N];
vector < int > v[N];
int comp[N];
int col[N];
int rekt[N];
int sz[N];
int cur;
long long ans;
void dfs(int node){
    comp[node] = cur;
    ++sz[cur];
    for(int next : v[node]){
        if(comp[next]){
            if(col[next] == col[node]){
                rekt[cur] = 1;
            }
        }
        else{
            col[next] = col[node] ^ 1;
            dfs(next);
        }
    }
}
int main(){
    scanf("%d %d" , &n , &m);
    for(int i = 1 ; i <= m ; ++i){
        scanf("%d %d" , a + i , b + i);
        v[a[i]].emplace_back(b[i]);
        v[b[i]].emplace_back(a[i]);
    }
    for(int i = 1 ; i <= n ; ++i){
        rekt[i] = 0;
        col[i] = -1;
        comp[i] = 0;
        sz[i] = 0;
    }
    cur = 0;
    ans = 0;
    int big = 0;
    int bip = 0;
    int tot = n;
    for(int i = 1 ; i <= n ; ++i){
        if(!comp[i]){
            col[i] = 0;
            ++cur;
            dfs(i);
            if(sz[cur] > 1){
                ++big;
                if(!rekt[cur]){
                    ++bip;
                }
            }
            else{
                --tot;
            }
        }
    }
    for(int i = 1 ; i <= cur ; ++i){
        if(sz[i] == 1){
            ans += n + tot;
        }
        else if(rekt[i]){
            ans += big;
        }
        else{
            ans += big + bip;
        }
    }
    printf("%lld\n" , ans);
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int x;
    cin >> x;
    int N = MAX*2;
    int *arr;
    arr = new int[MAX*2];

    for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 2; i < N; i++){
		if(arr[i] && i >= x){
			cout << i << endl;
            break;
		}
	}
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[310][310][310][2];
std::string s;

int main(void){
	int n,m,i,j,k,l;
	ll ans=0ll;
	std::cin >> s;
	std::cin >> l;
	n = s.l_ength();
	l = std::min(l,n);
	std::reverse(s.begin(),s.end());
	dp[0][0][0][0] = 1ll;
	for(i=0; i<n; ++i){
		if(s[i]=='0'){
			for(j=0; j<=l; ++j){
				for(k=0; k<=j; ++k){
					add_mod(dp[i+1][j][k][0],dp[i][j][k][0]);
					if(k){
						add_mod(dp[i+1][j][k][0],dp[i+1][j][k-1][0]);
					}
				}
			}
			for(j=0; j<=l; ++j){
				for(k=0; k<=j; ++k){
					add_mod(dp[i+1][j][k][0],dp[i][j][k][1]);
				}
			}
		}else{
			for(j=0; j<=l; ++j){
				for(k=0; k<=j; ++k){
					add_mod(dp[i+1][j][k][0],dp[i][j][k][0]);
					if(j+1<=l){
						add_mod(dp[i+1][j+1][k][1],dp[i][j][k][0]);
						add_mod(dp[i+1][j+1][k][1],dp[i][j][k][1]);
					}
				}
			}
		}
		/*
		for(j=0; j<=l; ++j){
			for(k=0; k<=j; ++k){
				printf("%d %d %d: %lld, %lld,;\n",i,j,k,dp[i+1][j][k][0],dp[i+1][j][k][1]);
			}
		}
		printf("\n");
		*/
	}
	for(j=0; j<=l; ++j){
		for(k=0; k<=j; ++k){
			add_mod(ans,dp[n][j][k][0]);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 432112
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
using ll = long long;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int dp[33][33][4];
int W, H;

void init() {
    REP(i, H) {
        REP(j, W) {
            REP(k, 4) { dp[i][j][k] = 1e9; }
        }
    }
    dp[0][0][0] = 0;
}

int A[55][55];

using arr4 = array<int, 4>;
int C[5];
bool solve() {
    cin >> W >> H;
    if (W == 0) return false;
    init();
    REP(i, H) {
        REP(j, W) { cin >> A[i][j]; }
    }
    REP(i, 4) cin >> C[i];
    priority_queue<arr4, vector<arr4>, greater<arr4>> que;
    que.push({0, 0, 0, 0});
    while (!que.empty()) {
        arr4 ar = que.top();
        que.pop();
        int c = ar[0], x = ar[1], y = ar[2], dir = ar[3];
        if (c > dp[x][y][dir]) continue;
        if (A[x][y] != 4) {
            int nx = x + dx[(dir + A[x][y]) % 4];
            int ny = y + dy[(dir + A[x][y]) % 4];
            if (nx < H && nx >= 0 && ny < W && ny >= 0) {
                int nd = (dir + A[x][y]) % 4;
                if (dp[nx][ny][nd] > dp[x][y][dir]) {
                    dp[nx][ny][nd] = dp[x][y][dir];
                    que.push({dp[nx][ny][nd], nx, ny, nd});
                }
            }
        }
        REP(i, 4) {
            int nd = (dir + i) % 4;
            int nx = x + dx[nd];
            int ny = y + dy[nd];
            if (nx < H && nx >= 0 && ny < W && ny >= 0) {
                if (dp[nx][ny][nd] > dp[x][y][dir] + C[i]) {
                    dp[nx][ny][nd] = dp[x][y][dir] + C[i];
                    que.push({dp[nx][ny][nd], nx, ny, nd});
                }
            }
        }
        //
    }
    int ans = 1e9;
    REP(i, 4) { ans = min(ans, dp[H - 1][W - 1][i]); }
    cout << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}



Measured memory_bytes: 3336
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE p(n), q(n); rep(i, n)cin >> p[i];
	rep(i, n)cin >> q[i];
	vector<int>v;
	rep(i, n)v.push_back(i + 1);
	int t = 0;
	int u = 0;
	int i = 1;
	do {
		bool ok1 = true;
		bool ok2 = true;
		rep(i, n) {
			if (v[i] != p[i])ok1 = false;
			if (v[i] != q[i])ok2 = false;
		}
		if (ok1)t = i;
		if (ok2)u = i;
			i++;
	} while (next_permutation(ALL(v)));
	cout << abs(t - u) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int maxn[1200001];
int query(int p, int l, int r, int l0, int r0) {
	if (l >= l0 && r <= r0) return maxn[p];
	int mid = (l + r) / 2, ans = 0;
	if (l0 <= mid) ans = max(ans, query(p * 2, l, mid, l0, r0));
	if (r0 > mid) ans = max(ans, query(p * 2 + 1, mid + 1, r, l0, r0));
	return ans;
}
void modify(int p, int l, int r, int x, int num) {
	maxn[p] = max(maxn[p], num);
	if (l == r) return;
	int mid = (l + r) / 2;
	if (x <= mid) modify(p * 2, l, mid, x, num);
	else modify(p * 2 + 1, mid + 1, r, x, num);
}
int main() {
	int n, k, w = 300000;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		modify(1, 1, w, a, query(1, 1, w, a-k, a+k) + 1);
	}
	cout << query(1, 1, w, 1, w) << endl;
}

Measured memory_bytes: 7732
Module Program
  Sub Main
    Dim s=GetInts()
    Dim a=s(0)
    Dim ans=If(a>88 Or a Mod 10=9,"Yes","No")
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int h = 2, w;
	cin >> w;
	char c[3][56];
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
		}
	}
	int now = 0, ans = 1;
	while (now < w) {
		if (now < w - 1&&c[0][now]==c[0][now+1]) {
			if (now == 0) ans *= 6;
			else if (c[0][now - 1] == c[1][now - 1]) ans *= 2;
			else ans *= 3;
			ans %= MOD;
			now += 2;
		}
		else if (c[0][now] == c[1][now]) {
			if (now == 0) ans *= 3;
			else if (c[0][now - 1] == c[1][now - 1]) ans *= 2;
			ans %= MOD;
			now++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256