akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

ll dp[200][2][4]={};

int main(void){
    ll k;
    string s;
    cin>>s>>k;
    dp[0][0][0]=1;
    ll n=s.size();
    for(int i=0;i<n;i++){
        ll x=s[i]-'0';
        for(int a=0;a<=9;a++){
            for(int z=0;z<=3;z++){
                if(a==0){
                    dp[i+1][1][z]+=dp[i][1][z];
                    if(a==x) dp[i+1][0][z]+=dp[i][0][z];
                    else if(a<x) dp[i+1][1][z]+=dp[i][0][z];
                }
                else if(z<3){
                    dp[i+1][1][z+1]+=dp[i][1][z];
                    if(a==x) dp[i+1][0][z+1]+=dp[i][0][z];
                    else if(a<x) dp[i+1][1][z+1]+=dp[i][0][z];
                }
            }
        }
    }
    cout<<dp[n][0][k]+dp[n][1][k]<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define chmax(n, m) n = max((n), (m))
using namespace std;
using ll = long long;


int main()
{
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    vector<vector<int>> dp(n+1, vector<int>(n+1, 0));
    rrep(i, n, 0)
        for (int j = n-1; i<j; j--)
        {
            if (s[i] == s[j])
                dp[i][j] = min(j-i, 1 + dp[i+1][j+1]);
            else
                dp[i][j] = 0;

            chmax(ans, dp[i][j]);
            // cout << i << ' ' << j << ' ' << dp[i][j] << endl;
        }
    
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,j;
  string str;
  cin >> n;
  getline(cin, str);
  for(int i = 0; i<n;i++){

    getline(cin, str);

    j = 0;
    while(str.size() >= 7 && str[j+6] != '\0'){
      if(str[j] == 'H' && str[j+1] == 'o' && str[j+2] == 's' && str[j+3] == 'h' && str[j+4] == 'i' && str[j+5] == 'n' && str[j+6] == 'o') str[j+6] = 'a';
      j++;
    }
    cout << str << endl;
  }
    
  return 0;
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;




void one_case() {
    char a, b, c, d;
    cin >> a >> d >> d >> d >> b >> d >> d >> d >> c;
    cout << a << b << c;

}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


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

typedef long long ll;

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((ll)(x).size())
#define inf          1<<25

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

int main() {
    string s;
    cin >> s;
    
    string ans = "";
    rep(i, sz(s)) if (i % 2 == 0) ans += s[i];
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
#from numpy import matrix, eye, dot
def productMatrix(N, A, B):
    Ret = [[0]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            for k in range(N):
                Ret[i][j] += A[i][k]*B[k][j]
    return Ret
def modMatrix(N, A, Q): #N×N行列のmod
    for i in range(N):
        for j in range(N):
            A[i][j] %= Q
    return

def powOfMatrix(N, X, n, Q): #N×N行列のn乗
    Ret = [[1,0,0],[0,1,0],[0,0,1]]
    power = '{:060b}'.format(n)[::-1] #log2(pow(10,18)) < 60
    for p in power:
        if p == "1":
            Ret = productMatrix(N,Ret, X)
            modMatrix(N, Ret, Q)
        X = productMatrix(N,X,X)
        modMatrix(N, X, Q)
    return Ret

def main():
    L, A, B, M = map( int, input().split())
    s = A
    ANS = [[1,0,0],[0,1,0],[0,0,1]]
    for i in range(1, 37):
        if s >= pow(10,i):
            continue
        P = [[pow(10, i, M), 0, 0], [1,1,0], [0,B,1]]
        step = (pow(10,i)-s+B-1)//B
        if L <= step:
            ANS = productMatrix(3,ANS,powOfMatrix(3,P,L,M))
            modMatrix(3,ANS,M)
            break
        ANS = productMatrix(3,ANS, powOfMatrix(3,P, step,M))
        modMatrix(3,ANS, M)
        L -= step
        s += step*B
    print( (ANS[1][0]*A + ANS[2][0])%M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44396
#include <stdio.h>

int main(){
	int R, G, B, N, ans = 0, i,j,N_R,N_G,b;
  	scanf("%d %d %d %d\n", &R, &G, &B, &N);
  	N_R = N/R;
  	N_G = N/G;
  	for(i = 0; i <= N_R; i++){
    	for(j = 0; j <= N_G; j++){
          b = N - R*i - G*j;
            	if(b % B == 0 && b >= 0){
                	ans++;
                }
        }
    }
  	printf("%d\n",ans);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())

ans = True
for i in range(N):
    dt = t[i + 1] - t[i]
    dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if dl > dt or (dl <= dt and dl % 2 != dt % 2):
        ans = False

print(('No', 'Yes')[ans])


Measured memory_bytes: 11636
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n , ans;
    cin >> n;
    ans = n % 1000;
    ans = 1000 - ans;
    if(ans == 1000){
        cout << 0 <<"\n";
    }else{
        cout << ans <<"\n";
    }
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>

int main()
{
  int S;
  std::cin >> S;

  // hours = 60 secs * 60 mins * n
  int h = S / 60 / 60;

  // S - hours
  S = S - h * 60 * 60;

  // mins = 60 secs * n
  int m = S / 60;

  // secs = S - mins
  int s = S - m * 60;

  std::cout << h << ":" << m << ":" << s << std::endl;
  return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int n,x,t;
    int ans{0};
    cin >> n >> x >> t;
    while(n>0)
    {
        ans+=t;
        n-=x;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3168
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (unmatched-close 0)
         (unmatched-open 0)
         (s (read-line)))
    (dotimes (i n)
      (if (char= #\( (aref s i))
          (incf unmatched-open)
          (if (zerop unmatched-open)
              (incf unmatched-close)
              (decf unmatched-open))))
    (dotimes (i unmatched-close)
      (write-char #\())
    (write-string s)
    (dotimes (i unmatched-open)
      (write-char #\)))
    (terpri)))

#-swank(main)


Measured memory_bytes: 16480
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      val A = List(N) ++ List.fill[Int](4)(sc.nextInt)
      if (A.groupBy(x => x).size == 2) {
        if (A.filter(_ == 1).size == 0) {
          A.map(a => a - 1).map(x => println(x))
        } else if (A.filter(_ == 2).size == 0) {
          A.map(a => if (a == 3) (1) else (2)).map(x => println(x))
        } else {
          A.map(x => println(x))
        }
      } else {
        A.map(_ => println(3))
      }
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 47264
N = int(input())
for h in range(1, 3501):
    for n in range(h, 3501):
        waru = 4 * h * n - N * n - N * h
        if waru > 0 and (N * h * n) % waru == 0:
                print("{} {} {}".format(h, n, (N * h * n) // waru))
                exit()

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
using namespace std;

#define ll long long
#define MAX 100005

const ll INF = 1LL << 60;

int N;
ll h[MAX];
ll dp[MAX];

int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }

    for(int i = 0; i < MAX; i++) {
        dp[i] = INF;
    }

    dp[0] = 0;
    for(int i = 1; i < N; i++) {
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1)
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    printf("%lld\n", dp[N - 1]);
}

Measured memory_bytes: 1792
#include <iostream>

int main()
{
    int x;
    std::cin >> x;

    if (x == 3 | x == 5 | x == 7)
    {
        std::cout << "YES" << std::endl;
    }
    else
    {
        std::cout << "NO" << std::endl;
    }

    return 0;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve() {
    string S, T;
    cin >> S >> T;

    vector<vector<int>> p(26), q(26);
    rep(i, 0, S.size()) {
        p[S[i] - 'a'].push_back(i);
        q[T[i] - 'a'].push_back(i);
    }

    rep(i,0,26){
        bool f=false;
        rep(j,0,26){
            if(p[i]==q[j]){
                f=true;
                break;
            }
        }
        if(!f){
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3092
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int k;
    cin>>k;
    int n=50;
    int memo=k/50;
    int alla=memo+n-1;
    k%=50;

    int hitotu=alla+(n-(k-1));

    alla-=k;

    cout<<n<<endl;
    rep(i,50-k){
        cout<<alla<<" ";
    }
    rep(j,k){
        cout<<hitotu<<" ";
    }
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
long long a[200005], b[200005];
long long sum[200005];

int max(int a,int b){ return a>b?a:b; }

int main(){
    int n,m;
    long long k;
    scanf("%d%d%lld",&n,&m,&k);
    for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
    for(int i = 1; i <= m; i++) scanf("%lld",&b[i]);
    int p = 0; long long left = k;
    while(p+1<=m && left-b[p+1]>=0){ 
        p++;
        left -= b[p];
    }
    int ans = p;
    for(int i = 1; i <= n; i++){
        left -= a[i];
        while(p>=1 && left<0){
            left += b[p];
            p--;
        }
        if(left<0) break;
        else{ 
            //printf("i = %d, p = %d\n",i,p);
            ans = max(ans,i+p);
        }
    } 
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4852
#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;

ll gcd(ll a,ll b){
    while(a%b){a%=b; swap(a,b);}
    return b;
}




int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(auto &I:a){cin>>I;}
    if(n==1){assert(a[0]==1); cout<<"Second"<<endl;}
    else if(n==2){
        cout<<((a[0]&1)==(a[1]&1)?"Second":"First")<<endl;
    }
    else{
        string F="First";
        string S="Second";
        while(1){
            ll cnt=0;
            ll cnt2=0;
            ll one=0;
            for(auto &I:a){cnt+=I-1; cnt2+=(I&1); one+=(I==1);}
            if(one){cout<<(cnt&1?F:S)<<endl;}
            else if(cnt&1){cout<<F<<endl;}
            else if(cnt2>1){cout<<S<<endl;}
            else{
                for(auto &I:a){if(I&1){I--;}}
                ll g=a[0];
                for(auto &I:a){g=gcd(g,I);}
                cnt=0;
                for(auto &I:a){I/=g;}
                swap(F,S);
                continue;
            }
            break;
        }
    }
    
    
    
    return 0;
}


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

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

            string answer = "";

            for(int i = 0; i < 50000; i++)
            {
                if(Math.Floor(i * 1.08) == N)
                {
                    answer = i.ToString();
                    break;
                }
            }

            if(String.IsNullOrEmpty(answer))
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine(answer);
            }
        }
    }
}

Measured memory_bytes: 11092
N=int(input())
if 1<=N and N<10:
	print(N)
elif 10<=N and N<100:
	print("9")
elif 100<=N and N<1000:
	print(9+N-99)
elif 1000<=N and N<10000:
	print("909")
elif 10000<=N and N<100000:
	print(909+N-9999)
else:
	print("90909")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    
    vector<int> ans(n,0);
    
    int cnt=0;
    rep(i,0,n){
        if(s.at(i)=='R') cnt++;
        else{
            ans.at(i-1)+=(cnt%2==0?cnt/2:cnt/2+1);
            ans.at(i)+=cnt/2;
            cnt=0;
        }
    }
    
    cnt=0;
    rrep(i,n,0){
        if(s.at(i)=='L') cnt++;
        else{
            ans.at(i+1)+=(cnt%2==0?cnt/2:cnt/2+1);
            ans.at(i)+=cnt/2;
            cnt=0;
        }
    }
    
    rep(i,0,n){
        cout<<ans.at(i);
        if(i==n-1) cout<<endl;
        else cout<<" ";
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int degit(int a);
int main(){
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; i++){
        cin>>p[i];
    }
    int c = 0;
    for(int i=0; i<N;i++){
        if(i+1!=p[i]) c++;
    }
    cout << ((c==2 || c==0) ? "YES" : "NO") << endl;
}

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

int main(void){
    int A, B, K;
    std::cin >> A >> B >> K;
    std::vector<int> C;

    for (int i=0; i<K; ++i){
        int a = A + i;
        int b = B - i;
        if (a < b) {
            C.emplace_back(a);
            C.emplace_back(b);
        } else if (a == b){
            C.emplace_back(a);
        } else {
            break;
        }
    }

    std::sort(C.begin(), C.end());

    for (int i: C){
        std::cout << i << std::endl;
    }

    return 0;
}


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

int main(){
	int cards[4][13];
	char a;
	int n,b;
	cin >> n;
	//?????????
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			cards[i][j] = 0;
		}
	}
	
	for (int k = 0; k < n; k++){
		cin >> a >> b;
		if (a == 'S'){
			cards[0][b - 1] = 1;
		}
		if (a == 'H'){
			cards[1][b - 1] = 1;
		}
		if (a == 'C'){
			cards[2][b - 1] = 1;
		}
		if (a == 'D'){
			cards[3][b - 1] = 1;
		}
	}

	for (int i = 0; i < 4; i++){
		for (int m = 0; m < 13; m++){
			if (cards[i][m] == 0){
				if (i == 0){
					cout << "S " << m + 1 << endl;
				}
				if (i == 1){
					cout << "H " << m + 1 << endl;
				}
				if (i == 2){
					cout << "C " << m + 1 << endl;
				}
				if (i == 3){
					cout << "D " << m + 1 << endl;
				}
				
			}
			
		}
	}

	return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

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 temp;
		if (a > b) {
			temp = a; a = b; b = temp;
		}
		if (b > c) {
			temp = b; b = c; c = temp;
		}
		if (a > b) {
			temp = a; a = b; b = temp;
		}
		
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 17172
# coding: utf-8
# Your code here!

N = int(input())
H = list(map(int, input().rstrip().split(' ')))

dp = [0] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
    
print(dp[N-1])

Measured memory_bytes: 13928
import sys
import math
ta,ao,N= map(int,input().split())
#li = [int(x) for x in input().split()]
N=N-ta
if N>0:
  ta=0
  N=N-ao
  if N>0:
    print("0 0")
    sys.exit()
  else:
    ao=abs(N)
else:
  ta=abs(N)

    
print(str(ta)+" "+str(ao))

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	int w, a, b;
	
	scanf("%d %d %d", &w, &a, &b);
	
	if(a <= b){
		if(a+w < b) printf("%d", b - (a+w));
		else printf("0");
	}
	else{
		if(b+w < a) printf("%d", a - (b+w));
		else printf("0");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#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 all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1001001001;

int main() {
    ll A;
    long double B;

    cin >> A >> B;

    ll ans = A*(ll)(B*100+0.001)/100;

    cout << ans << endl;
}


Measured memory_bytes: 3720
data = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

i = gets.to_i

print data[i - 1]


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

ll func(ll n)
{
    ll L = 0;
    rep(i, n){
        int p;
        cin >> p;
        L += p;
    }
    
    vi j(n-1);
    rep(i, n-1){
        cin >> j[i];
    }
    sort(j.rbegin(), j.rend());
    
    ll ans = n*L;
    for(int l : j){
        if(n*l > L+1){
            L += l;
            --n;
            ans = max(ans, n*L);
        }
        else{
            break;
        }
    }
    
    return ans;
}

int main()
{
    int n;
    while(cin >> n, n){
        cout << func(n) << endl;
    }
}

Measured memory_bytes: 1448
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (530010)
#define P (998244353)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,S,INV,Lim,p[N],q[N];
int ksm(int a,int p){
	int res=1;
	for(;p;p>>=1,a=1ll*a*a%P)if(p&1)res=1ll*res*a%P;
	return res;
}
void FWT(int *a,int tp){
	for(int i=1;i<Lim;i<<=1)
	for(int R=i<<1,j=0;j<Lim;j+=R)
	for(int k=j;k<j+i;k++){
		int x=a[k],y=a[k+i];
		a[k]=(x+y)%P,a[k+i]=(x-y+P)%P;
	}
	if(tp==-1)for(int i=0;i<Lim;i++)a[i]=1ll*a[i]*INV%P;
}
int main(){
	read(n),Lim=1<<n,INV=ksm(Lim,P-2);
	for(int i=0;i<Lim;i++)read(p[i]),S+=p[i]; S=ksm(S,P-2);
	for(int i=0;i<Lim;i++)p[i]=1ll*p[i]*S%P,q[i]=P-1;q[0]=Lim-1,p[0]--,FWT(p,1),FWT(q,1);
	for(int i=1;i<Lim;i++)q[i]=1ll*q[i]*ksm(p[i],P-2)%P; FWT(q,-1);
	for(int i=0;i<Lim;i++)printf("%d\n",(q[i]-q[0]+P)%P);
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;

typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n,m;
int main(){
    cin >> n >> m;
    vector<ll> a(n);
    double sum = 0;
    rep(i,0,n){
        cin >> a[i];
        sum += a[i];
    }
    // ll sum = accumulate(all(a), 0);
    sort(all(a));
    reverse(all(a));
    // rep(i,0,n)cout << a[i] << " ";
    // cout << endl;
    // cout << sum << " " << sum/(4 * m) << endl;
    string ans = "Yes";
    rep(i,0,m){
        if(a[i] < sum/(4*m))ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())


int main(int argc, char const *argv[]) {
  int n,k;
  cin >> n >> k;
  int ans=0;
  rep(i,n){
    int h;
    cin >> h;
    if(h>=k) ans++;
  }
  cout << ans << endl;
  return 0;
}


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


int main(void){
    int n, x;
    while(true){
    cin >> n >> x;
    if(!n && !x) break;
    
    int i, j, k;
    int count = 0;
    
    for(i = 1; i <= n - 2; i++){
        for(j = i + 1; j <= n - 1; j++){
            for(k = j + 1; k <= n; k++){
                if(i + j + k == x) count++;
                
            }
        }
    }
    
    cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int main(){
	string S;
	cin >> S;
	int num[200000] = {0};
	long long sum = 0;
	char c;
	for (int i = 0; i < S.length(); i++) {
		c = S[i];
		num[i] = c - '0';
		//cout << c << "\n";
	}

	for (int i = 0; i < S.length(); i++) {
		sum += num[i];
	}

	// for (int i = 0; i < S.length(); i++) {
	// 	cout << "num[" << i << "] = " << num[i] << "\n";
	// }

	if(sum % 9 == 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

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

int main() {
  char c;
  cin >> c;

      if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
      }
      else { 
        cout << "consonant" << endl;
      }
}


Measured memory_bytes: 256
N, W = map(int, input().split())

dp = [[0] * (W+1) for _ in range(N+1)]

for i in range(1, N+1):
    w, v = map(int, input().split())
    for w_k in range(1, W+1):
        if w_k >= w:
            dp[i][w_k] = max(dp[i-1][w_k-w] + v, dp[i-1][w_k])
        else:
            dp[i][w_k] = dp[i-1][w_k]

print(max(dp[N]))


Measured memory_bytes: 119916
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil
(defun main ()
  (declare #.OPT
           (inline set-difference))
  (let* ((n (read))
         (x (read))
         (end (- (* 2 n) 1))
         (seq (loop for i from 1 to end collect i))
         (res (make-array end :element-type 'uint32)))
    (declare (uint32 n x))
    (cond ((or (= x 1) (= x end))
           (println "No"))
          ((= n 2)
           (format t "Yes~%1~%2~%3~%"))
          (t
           (let ((fixed (if (> x 2)
                            (list (- x 2) x (+ x 1) (- x 1))
                            (list (+ x 2) x (- x 1) (+ x 1)))))
             (setf (aref res (- n 2)) (elt fixed 0)
                   (aref res (- n 1)) (elt fixed 1)
                   (aref res n) (elt fixed 2)
                   (aref res (+ n 1)) (elt fixed 3))
             (setf seq (set-difference seq fixed
                                       :test (lambda (x y)
                                               (declare (uint32 x y))
                                               (= x y))))
             (loop for i from 0 below (- n 2)
                   for a = (pop seq)
                   do (setf (aref res i) a))
             (loop for i from (+ n 2) below end
                   for a = (pop seq)
                   do (setf (aref res i) a))
             (println "Yes")
             (loop for a across res
                   do (println a)))))))

#-swank(main)



Measured memory_bytes: 18152
#include <stdio.h>
#include <stdlib.h>

int main()
{
	
	int H, W;
   	while(1)
   	{
		scanf("%d%d", &H, &W);
		if(H == 0 && W == 0)
		{
			break;
		}
		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}


	return 0;
}


Measured memory_bytes: 2024
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n%2==0){
      System.out.println(n/2);
    }else{
      System.out.println(n/2+1);
    }
  }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ld long double
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
ll mod2=998244353;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 300005
// Comment this out for interactive problem
#define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

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

    ll k;
    cin>>k;

    string s = "";
    string s1 = "ACL";
    for (int i = 0; i < k; ++i)
    {
        s+=s1;
    }
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 3640
n, a, b, c, d = map(int, input().split())
s = input()
a-=1
b-=1

index1 = s[a:c].find("##")
index2 = s[b:d].find("##")

ans = "No"

if index1 == -1 and index2 == -1:
  if c < d :
    ans = "Yes"
  elif s[max(b-1,0):d+1].find("...") != -1 :
    ans = "Yes"
  
print(ans)


Measured memory_bytes: 40816
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int n, m; cin >> n >> m;
  vector<set<int> > to(n);
  vector<set<int> > from(n);
  vector<int> topo, dist(n, 0);
  vector<bool> source(n, true);
  for (int i = 0; i < m; i++) {
    int s, e; cin >> s >> e;
    to[s-1].insert(e-1); from[e-1].insert(s-1);
    source[e-1] = false;
  }
  set<int> head;
  for (int i = 0; i < n; i++) {
    if (source[i]) head.insert(i);
  }
  while(!head.empty()) {
    auto here = head.begin();
    topo.push_back(*here);
    for (auto it = to[*here].begin(); it != to[*here].end(); it++) {
      from[*it].erase(*here);
      if (from[*it].empty()) head.insert(*it);
    }
    head.erase(here);
  }
  int ans = 0;
  for (int i : topo) {
    for (auto it = to[i].begin(); it != to[i].end(); it++) {
      dist[*it] = max(dist[*it], dist[i]+1);
      ans = max(ans, dist[*it]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 21888
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N)
	fmt.Scan(&M)
	A := make([]int, M)
	sum := 0
	for i := 0; i < M; i++ {
		fmt.Scan(&A[i])
		sum += A[i]
	}
	if ans := N - sum; ans < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

Measured memory_bytes: 2464
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
last = [-1]*26
ans = 0
for i in range(D):
  t = int(input())
  ans += s[i][t-1]
  last[t-1] = i
  ans -= sum([c[j]*(i-last[j]) for j in range(26)])
  print(ans)

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

using namespace std;

int n;

void dfs(string s, char mx) {
    if (s.length() == n) {
        printf("%s\n", s.c_str());
    } else {
        for (char c='a';c<=mx;c++) {
            dfs(s+c, (c==mx) ? (char) (mx + 1) : mx);
        }
    }
    return;

}

int main() {
    cin >> n;
    dfs("", 'a');
    return 0;
}

Measured memory_bytes: 1536
import sys
import math
input = sys.stdin.readline

A, B, H, M = map(int, input().split())

degA = H * 30 + M * 0.5
degA = degA % 360
degB = H * 360 + M * 6
degB = degB % 360
xa, ya = math.sin(math.radians(degA)) * A, math.cos(math.radians(degA)) * A
xb, yb = math.sin(math.radians(degB)) * B, math.cos(math.radians(degB)) * B
ans = math.sqrt((xa - xb) ** 2 + (ya - yb) ** 2)
print(ans)

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
int  x, sushi[4];
double n, memo[301][301][301];

double dp(int i, int j, int k){
	if(i+j+k==0){
		return 0.0;
	}
	if(memo[i][j][k]!=-1){
		return memo[i][j][k];
	}
	double operasi=n/(i+j+k);
	double ans=0;
	if(i){
		ans+=(dp(i-1, j, k)+operasi)*i/(i+j+k);
	}
	if(j){
		ans+=(dp(i+1, j-1, k)+operasi)*j/(i+j+k);
	}
	if(k){
		ans+=(dp(i, j+1, k-1)+operasi)*k/(i+j+k);
	}
	memo[i][j][k]=ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		sushi[x]++;
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				memo[i][j][k]=-1;
			}
		}
	}
	double res=dp(sushi[1], sushi[2], sushi[3]);
	cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 213376
def main():
    N = int(input())

    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0 and i != n//i:
                divs.append((i, n//i))
            elif n % i == 0 and i == n//i:
                divs.append((i, i))
        return divs
    ans = 10**13
    divs = trial_division(N)
    for a, b in divs:
        ans = min(ans, max(len(str(a)), len(str(b))))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39664
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private static long MOD = 1_000_000_007;
 
    private void solve(Scanner sc) {
        int N = sc.nextInt();
 
        long p = 1;
        for (int i = 0; i < N; ++i) {
            p = (p * (i + 1) % MOD);
        }
 
        _out.println(p);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int f(unordered_map<int, unordered_set<int>>& um) {
    unordered_set<int> us;
    int c = 0;
    for (auto p : um) {
        int now = p.first;
        if (us.find(now) == us.end()) {
            c++;
            us.insert(now);
            vector<int> v(1, now);
            while(v.size() > 0) {
                int index = v.back();
                v.pop_back();
                for (auto next : um[index]) {
                    if (us.find(next) == us.end()) {
                        us.insert(next);
                        v.push_back(next);
                    }
                }
            }
        }
    }
    return c;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> vp;
    unordered_map<int, unordered_set<int>> um;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        vp.emplace_back(a, b);
        um[a].insert(b);
        um[b].insert(a);
    }
    int res = 0;
    for (auto p : vp) {
        int a = p.first, b = p.second;
        um[a].erase(b);
        um[b].erase(a);
        if (f(um) > 1) res++;
        um[a].insert(b);
        um[b].insert(a);
    }
    cout << res << endl;
}




Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[4][3][10];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				a[i][j][k] = 0;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		int a1, a2, a3, a4;
		cin >> a1 >> a2 >> a3 >> a4;
		a[a1-1][a2-1][a3-1] += a4;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout <<" "<< a[i][j][k];
			}
			cout << endl;
		}
		if (i == 3) {
			continue;
		}
		cout << "####################" << endl;
	}
}




Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

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

    map<ll, ll> L, R;

    rep (i, N)
    {
        ll a;
        cin >> a;

        ++L[i + a];
        ++R[i - a];
    }

    ll ans = 0;

    for (const auto& l : L)
    {
        const auto lv = l.second;
        const auto rv = R[l.first];
        ans += lv * rv;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 37932
I = input().split()
A = int(I[0])
B = int(I[1])
ana = 0
i = 0
while(True):
  if B == 1:
    break
  if i == 0:
  	ana += A
  else:
    ana += (A-1)
  i += 1
  if ana >= B:
    break
print(i)

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

int main() {
    int w,a,b,ans;
    cin>>w>>a>>b;
    if (b+w<a) ans=a-b-w;
    else if (a+w<b) ans=b-a-w;
    else ans=0;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
const Main = input => {
  const inp = input.split(" ");
  let a = parseInt(inp[0], 10);
  const b = parseInt(inp[1], 10);
  let c = parseInt(inp[2], 10);
  const d = parseInt(inp[3], 10);
  
  let takahashiWin = false;
  let i = 0;
  while(true) {//attack
    if(i % 2 === 0) {
      c -= b;
    } else {
      a -= d;
    }
    
    if(a <= 0) {//takahashi lose
      console.log("No");
      break;
    }
    if(c <= 0) {//takahashi win
      console.log("Yes");
      break;
    }
    
    i++;
  }
}

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

Measured memory_bytes: 29628
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#include <unordered_set>
#include <unordered_map>

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
typedef set<LL> SLL;
typedef unordered_set<LL> USLL;
typedef string STR;

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;

int main() {
  LL a;
  R(a);
  W(a + a * a + a * a * a);
  return 0;
}


Measured memory_bytes: 3828
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=0;
  string s;
  ll a[5]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    if(s[0]=='M') {
      a[0]++;
    }
    else if(s[0]=='A') {
      a[1]++;
    }
    else if(s[0]=='R') {
      a[2]++;
    }
    else if(s[0]=='C') {
      a[3]++;
    }
    else if(s[0]=='H') {
      a[4]++;
    }
  }
  for(int i=0; i<5; i++) {
    for(int j=i+1; j<5; j++) {
      for(int k=j+1; k<5; k++) {
        ans+=a[i]*a[j]*a[k];
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define ll long long

int main()
{
	ll N;
	vector < ll > A(5);
	cin >> N;
	for (int i = 0; i < 5; i++) {
		cin >> A[i];
	}

	ll min = *min_element(A.begin(), A.end());

	ll ans = 5;

  ans += ceil((double)N / min) - 1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int n;
long long dp[401][401];
//long long sum[402][402];
int a[401];
long long smasm[401];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		smasm[i] = smasm[i-1]+a[i];
	}
	
	memset(dp,0x7f,sizeof dp);
	
	//for(int i=1;i<=n;i++){
	//	for(int j=i;j<=n;j++){
	//		sum[i][j] = sum[i][j-1] + a[j];
	//	}
	//}
	
	for(int j=1;j<=n;j++){
		dp[j][j] = 0;
		for(int i=j-1;i>0;i--){
			for(int k=i+1;k<=j;k++){
				dp[i][j] = min(dp[i][j], dp[i][k-1]+dp[k][j]);
			}
			//dp[i][j] += sum[i][j];
			dp[i][j] += smasm[j] - smasm[i-1];
		}
	}
	
	cout<<dp[1][n];
	
	return 0;
}


Measured memory_bytes: 1536