akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int n,k,b[4],cnt=0,ans=1;
struct num{int val,sign;}a[maxn];
bool flag;

bool comp(num i, num j){return i.val>j.val;}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> k;
    rep(n) cin >> a[i].val;
    rep(n){
        if(a[i].val>0) a[i].sign=1;
        else if(a[i].val<0) a[i].sign=-1,a[i].val*=-1;
        else a[i].sign=0;
    }
    sort(a,a+n,comp);
    if(a[k-1].val==0){
        print1(0);
        return 0;
    }
    rep(k) if(a[i].sign==-1) cnt++;
    if(cnt%2==0){
        rep(k) ans=ans*a[i].val%MOD;
        print1(ans);
        return 0;
    }
    b[0]=b[1]=b[2]=b[3]=-1;
    rep(k) if(a[i].sign==1) b[0]=i;
    if(b[0]!=-1) rep2(i,k,n) if(a[i].sign!=1){b[1]=i;break;}
    rep(k) if(a[i].sign==-1) b[2]=i;
    if(b[2]!=-1) rep2(i,k,n) if(a[i].sign!=-1){b[3]=i;break;}
    if(b[1]==-1&&b[3]==-1){
        rep3(i,n-1,n-k) ans=ans*a[i].val%MOD;
        ans=(MOD-ans)%MOD;
        print1(ans);
        return 0;
    }
    if(b[1]==-1) flag=false;
    else if(b[3]==-1) flag=true;
    else if(a[b[1]].val*a[b[2]].val>a[b[0]].val*a[b[3]].val) flag=true;
    else flag=false;
    if(flag){
        rep(k) if(i!=b[0]) ans=ans*a[i].val%MOD;
        ans=ans*a[b[1]].val%MOD;
    }
    else{
        rep(k) if(i!=b[2]) ans=ans*a[i].val%MOD;
        ans=ans*a[b[3]].val%MOD;
    }
    print1(ans);
    return 0;
}


Measured memory_bytes: 6664
#include<bits/stdc++.h>
#define Mx 1000000000005 
#define ll long long  
#define pi 3.141592653
#define vi vector<ll>
#define Mo 1000000007
#define mp make_pair
#define M map<ll,ll>
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define vii vector<pair<ll,ll> > 
#define fi first
#define se second
#define pb push_back
#define ld long double
#define fill(a,x) memset(a,x,sizeof(a))
using namespace std;
bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
  return a.second<b.second;
}
/*vi b=v;
   sort(b.begin(), b.end());
  b.resize(unique(b.begin(), b.end()) - b.begin());
  ll t; cin>>t; fr(f,0,t){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 */
void topo(vi v[],ll s,bool vis[], stack<ll> &st)
{
  vis[s]=1;
  fr(i,0,v[s].size())
    if(!vis[v[s][i]])
      topo(v,v[s][i],vis,st);
  st.push(s);
}
int main()
{
  ll V,E,x,y; cin>>V>>E;

  vi v[V+1];
  fr(i,0,E)
  {
    cin>>x>>y;
    v[x].pb(y);
  }

  bool vis[V+1]={0};
  stack<ll> st;
  fr(i,1,V+1)
    if(!vis[i])
      topo(v,i,vis,st);
  
  ll p[V+1]={0},ans=0;

  while(!st.empty())
  {
    x=st.top(); st.pop();
    fr(i,0,v[x].size())
    {
      p[v[x][i]]=max(p[v[x][i]], 1+p[x]);
      ans=max(ans,p[v[x][i]]);
    }
  }

  cout<<ans;




}

Measured memory_bytes: 12516
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

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

#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

const int borne = 17;
const int ph = (1 << borne);
int n;

int a[borne][borne];
int g[ph], dp[ph];

signed main()
{
    sl(n);
    fin(i, n) fin(j, n) sl(a[i][j]);
    fin(b, (1<<n)) fin(i, n) if (b&(1<<i)) fin2(j, i+1, n) if (b&(1<<j)) g[b] += a[i][j];
    fin(b, (1<<n)) {
        for (int sb = b; sb > 0; sb=(sb-1)&b) {
            chmax(dp[b], g[sb] + dp[b&(~sb)]);
        }
    }
    pl(dp[(1<<n)-1]);
}


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

int main() {
  string n;
  cin >> n;
  while ( !(n[0] == n[1] && n[1] == n[2]) ) {
    n = to_string( stoi(n) + 1 );
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
   ll a,b;
   cin>>a>>b;
   if(2*b>=a)cout<<0<<endl;
   else cout<<a-2*b<<endl;
}


Measured memory_bytes: 4992
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);
    if (a < b && b < c) {
        console.log('Yes');
    } else {
        console.log('No');
    }
});

process.stdin.resume();
process.stdin.setEncoding('utf8');

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

vector<int> primes;

void sieve(int x=100100){
    vector<bool> is_prime(x, true);
    is_prime[0] = is_prime[1] = false;
    
    for(int i=2; i<x; i++) if(is_prime[i]){
        primes.push_back(i);
        for(int j=2*i; j<x; j+=i)
            is_prime[j] = false;
    }
}
void factor(int x){
    cout << x << ":";
    
    bool is_prime = true;
    for(auto p: primes){
        while(x%p == 0){
            cout << " " << p;
            x /= p;
            is_prime = false;
        }
    }
    if(is_prime)
        cout << " " << x;
    cout << endl;
}

int main(){
    sieve();
    
    int N; cin >> N;
    factor(N);
    
    return 0;
}

Measured memory_bytes: 3256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cassert>
#include<climits>
#include<algorithm>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<sstream>
#include<cstring>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

#define MAX 110
int n,T[MAX],m,P[MAX],X[MAX];

int main() {
  cin >> n;
  int sum = 0;
  rep(i,n) {
    cin >> T[i];
    sum += T[i];
  }
  cin >> m;
  rep(i,m) {
    cin >> P[i] >> X[i];
    cout << sum - T[P[i]-1] + X[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vii A(N);
  vi B(N);
  rep(i,1,N){
    int X; cin>>X;
    A[i].pb(X-1);
    B[X-1]++;
  }
  stack<int> S;
  rep(i,0,N){
    if(B[i]==0) S.push(i);
  }
  vi C;
  while(S.size()>0){
    int X=S.top(); S.pop();
    C.pb(X);
    rep(i,0,A[X].size()){
      int Y=A[X][i];
      B[Y]--;
      if(B[Y]==0) S.push(Y);
    }
  }
  vii D(N);
  vi dp(N);
  rep(i,0,N){
    sort(ALL(D[C[i]]));
    int X=D[C[i]].size();
    rep(j,0,X){
      dp[C[i]]=max(dp[C[i]],D[C[i]][j]+X-j);
    }
    rep(j,0,A[C[i]].size()){
      D[A[C[i]][j]].pb(dp[C[i]]);
    }
  }
  int ans=0;
  rep(i,0,N) ans=max(ans,dp[i]);
  cout<<ans<<endl;
  }




Measured memory_bytes: 13556
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,m;
  long long int a = 1000000007;
  cin >> n >> m;
  if(abs(n-m) > 1){
    cout << 0 << endl;
    return 0;
  }
  long long int nkai=1,mkai=1;
  for(long long int i=1; i<=n; i++){
    nkai = (nkai*i)%a;
  }
  for(long long int i=1; i<=m; i++){
    mkai = (mkai*i)%a;
  }
  if(n==m){
    cout << (nkai*mkai*2)%a << endl;
  }else{
    cout << (nkai*mkai)%a << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ***********************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ***********************************/
/******* Main ****************************************/
void Main() {
  int H, W;
  while (cin >> H >> W) {
    if (H == 0 && W == 0) break;
    int h = H;
    while (h--) {
      int w = W;
      if (h == H - 1 || h == 0) {
        while (w--) {
          cout << '#';
        }
        cout << '\n';
      } else {
        while (w--) {
          if (w == W - 1 || w == 0) {
            cout << '#';
          } else {
            cout << '.';
          }
        }
        cout << '\n';
      }
    }
    cout << '\n';
  }
}

/*********************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                      How`s it going?
                              |＼
                      　／￣＼　ヽ
                      ／　　　ヽ |_
                      ￣＼　　　　 ＼
                      ／￣　/|/| /ﾚ､ ヽ＿
                      ￣＼ Yヘ |/ヘ幺　∠
                      　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                      　　／厂ヽ／￣/＼
                      　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

************************************************************/
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>
using namespace std;
int main() {
    int n;
    string ans;
    cin >> n;
    int a = n % 10;
    if (a == 3) {
        ans = "bon";
    }
    else if (a == 0 || a == 1 || a == 6 || a == 8) {
        ans = "pon";
    }
    else {
        ans = "hon";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
N = int(input())
A = list(map(int,input().split()))

ans = 'APPROVED'
for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3 != 0 and A[i]%5 != 0:
            ans = 'DENIED'
            break
print(ans)


Measured memory_bytes: 2940
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N);
            var sorted = A.OrderByDescending(_ => _);
            var max = sorted.ElementAt(0);
            var max2 = sorted.ElementAt(1);
            for (int i = 0; i < N; i++)
            {
                if (A[i] == max)
                {
                    Console.WriteLine(max2);
                }
                else
                {
                    Console.WriteLine(max);
                }
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 24376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		char s[] = scan.next().toCharArray();
		char t[] = scan.next().toCharArray();
		
		int count = 0;
		
		for(int i = 0; i < s.length; i++) {
			if(s[i] == t[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22612
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let mut a: Vec<i64> = (0..n).map(|_| input()).collect();
    a.sort_by_key(|a| -a);
    let mut bc: Vec<(usize, i64)> = (0..m)
        .map(|_| {
            let b = input();
            let c = input();
            (b, c)
        })
        .collect();
    bc.sort_by_key(|&(_, c)| -c);

    let mut k = 0;
    let mut i = 0;
    let mut j = 0;
    let mut ans = 0;
    while k < n {
        let (b, c) = if j < m { bc[j] } else { (0, 0) };
        if i < n && a[i] >= c {
            ans += a[i];
            k += 1;
            i += 1;
        } else {
            let cnt = std::cmp::min(b, n - k) as i64;
            ans += cnt * c;
            k += b;
            j += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
    //#define ll long long
    using namespace std;
    #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
    #define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
    #define ll long long
    #define pb push_back
    #define pll pair<ll,ll>
    #define ff first
    #define ss second
    #define mp make_pair
    #define N 2000001
    #define M 998244353
    #define INF 1000000000000000
  ll gcd(ll a,ll b)
  {
    if(b==0)return a;
    else return(gcd(b,a%b));
  }
  vector<pll> adj[100001];
  vector<ll> tim[100001];

int main()
{
  SPEED;
 ll n,m;
 cin>>n>>m;
 ll a[n];
 ll i,j,k;
 for (i = 0; i < n; ++i)
 {
   cin>>a[i];
 }
 ll ans[n]={0};
 for ( i = 0; i < n; ++i)
 {
   /* code */ans[i]=1;
 }
 for(i=0;i<m;i++)
 {
   ll x,y;
   cin>>x>>y;x--;y--;
   if(a[x]<a[y]){ans[x]=0;}
   else if(a[y]<a[x])
    {ans[y]=0;}
  else {ans[x]=0;ans[y]=0;}
 }

ll sum=0;
 for(i=0;i<n;i++)
 {
   if(ans[i]==1)sum++;
 }
 cout<<sum;
}



Measured memory_bytes: 9896
import math
n=int(input())
#generate all the primes 
def chk_prime(n):
  for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
      return False
  return True
primes=[]
for i in range(2,n+1):
  if chk_prime(i):
    primes.append(i)
cc=[0]*len(primes)
for i in range(2,n+1):
  num=i
  for j in range(len(primes)):
    cnt=0
    while num%primes[j]==0:
      num//=primes[j]
      cnt+=1
    cc[j]+=cnt
ans=0
#count how many are of the type 75
for i in cc:
  if i>=74:
    ans+=1
#count how many are of the type 25,3
cnt_24=0
cnt_2=0
for i in cc:
  if i>=24:
    cnt_24+=1
  if i>=2:
    cnt_2+=1
ans+=cnt_24*(cnt_2-1)
#count how many are of the type 15,5
cnt_14=0
cnt_4=0
for i in cc:
  if i>=14:
    cnt_14+=1
  if i>=4:
    cnt_4+=1
ans+=cnt_14*(cnt_4-1)
#count how many are of the type 5,5,3
cnt_4=0
for i in cc:
  if i>=4:
    cnt_4+=1
ans+=((cnt_4*(cnt_4-1))//2)*(cnt_2-2)
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//10min
int main(void){
  int x, y;
  int a[7] = {1, 3, 5, 7, 8, 10, 12};
  int b[4] = {4, 6, 9, 11};
  int cnt = 0;

  scanf("%d%d", &x, &y);

  if(x == y){
    printf("Yes\n");
    return 0;
  }
  
  for(int i = 0; i < 7; i++){
    if(a[i] == x){
      cnt++;
    }
    if(a[i] == y){
      cnt++;
    }
  }
  if(cnt == 2){
    printf("Yes\n");
    return 0;
  }

  cnt = 0;
  for(int i = 0; i < 4; i++){
    if(b[i] == x){
      cnt++;
    }
    if(b[i] == y){
      cnt++;
    }    
  }

  if(cnt == 2){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, a;
  cin >> N;

  map<int,int>m;
  for (int i = 1; i <= N; i++) {
    cin >> a;
    m[a] = i;
  }

  for(auto i = m.begin(); i != m.end(); i++) {
    cout << i->second << " ";
  }
  cout << "" << endl;

  return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

int N, H, W;

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

  cin >> N >> H >> W;

  int a = N - H + 1;
  int b = N - W + 1;
  cout << (a * b) << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf std::numeric_limits<double>::infinity()
#define DECI(n) fixed<<showpoint<<setprecision(n)
#define MOD 1000000007LL
#define FOR(i,start,end) for (int i=start;i<end;i++)
#define FORR(i,end,start) for(int i=end-1;i>start;i--)
#define INPUT(arr,n) FOR(i,0,n) cin>>arr[i];
#define INPUT2d(arr,n,k) FOR(i,0,n) FOR(j,0,k) cin>>arr[i][j];
#define SIZE 100005
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))









int main(){
int a,b,c;
cin>>a>>b>>c;
vector<int>v;
v.push_back(c);
v.push_back(a);
v.push_back(b);
FOR(i,0,v.size()){
cout<<v[i]<<" ";
}

return 0;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
const ll mx = 1e5 + 5;
vector<ll> great(mx);
vector<ll> height(mx);
vector<ll> indegree(mx);
int main() {
    ll N, M, from, to, num;
    fast_io;
    cin >> N >> M;
    unordered_map<string, bool> umap;
    for(int i = 1; i <= N; ++i) {
        cin >> num;
        height[i] = num;
    }
    for(int i = 1; i <= M; ++i) {
        cin >> from >> to;
        if(from > to)
            swap(from, to);
        ll tfrom = from, tto = to;
        string sear = to_string(tfrom) + '-' + to_string(tto);
        if(umap.find(sear) == umap.end()) {
            if(height[from] > height[to]) {
                ++great[from];
                --great[to];
            }
            else if(height[to] > height[from]){
                --great[from];
                ++great[to];
            }
            ++indegree[from];
            ++indegree[to];
        }
    }
    ll ans = 0;
    for(int i = 1; i <= N; ++i) {
        if(indegree[i] != 0 && great[i] == indegree[i]) {
            ++ans;
        }
        if(indegree[i] == 0) {
            ++ans;
        }
        //cout << great[i] << " " << indegree[i] << "\n";
    }
    cout << ans;
}


Measured memory_bytes: 5388
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
int main() {
  int n; cin >> n;
  while (n--) {
    vector<int> v;
    long l; cin >> l;
    while (l != 0) { v.push_back(l % 10); l /= 10; }
    sort(v.begin(), v.end());
    long a = 0, b = 0;
    for (auto it = v.begin(); it != v.end(); it++) a = a * 10 + *it;
    for (auto it = v.rbegin(); it != v.rend(); it++) b = b * 10 + *it;
    cout << b - a << endl;
  }
}

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

int main(){
  vector<ll> v;
  ll n, x;
    cin >> n;
  for(int i=0; i<n; i++){
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  ll cnt=1, ans=0;
  for(int i=0; i<n-1; i++){
    if(v[i]==v[i+1]){
      cnt += 1;
      continue;
    }
    //cout << cnt %2 << endl;
    ans += cnt%2;
    cnt = 1;
  }
  ans += cnt%2;
  
  cout << ans << endl;

}

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

namespace ABC
{

    class ABC170
    {

        static ulong N;
        static char[] answers;
        static List<char> result;

        static void Main(String[] args)
        {
            init();

            // 26進数
            // 再帰 base: i < 26
            proc(N);

            result.Reverse();

            Console.WriteLine(string.Join("", result.ToArray()));
            Console.ReadLine();

        }

        static void proc(ulong n)
        {
            if (n == 0) { return; }
            if (n < 26)
            {
                result.Add(answers[n-1]);
                return;
            }
            
            ulong quotient = n / 26;
            ulong remainder = n % 26;

            if (remainder == 0)
            {
                result.Add(answers[25]);
                quotient--;
            }
            else
            {
                result.Add(answers[remainder-1]);
            }

            proc(quotient);

        }

        static void init()
        {
            N = ulong.Parse(Console.ReadLine());

            string alphabet = "abcdefghijklmnopqrstuvwxyz";
            answers = alphabet.ToCharArray();

            result = new List<char>();
        }

    }
}


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n;
int a[1000][1000];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  cin >> n;
  int ii;
  for (ii = 1; ii * (ii + 1) / 2 < n; ii++) {}
  if (ii * (ii + 1) / 2 == n) {
    cout << "Yes" << endl;
    int now = 1;
    for (int i = 0; i < ii; i++) {
      for (int j = 0; j <= i; j++) {
        a[i][j] = now;
        now++;
      }
    }
    cout << ii + 1 << endl;
    for (int cor = 0; cor < ii; cor++) {
      cout << ii << " ";
      for (int j = 0; j < cor; j++) {
        cout << a[cor][j] << " ";
      }
      for (int j = cor; j < ii; j++) {
        cout << a[j][cor] << " ";
      }
      cout << endl;
    }
    cout << ii << " ";
    for (int i = 1; i <= ii; i++) {
      cout << i * (i + 1) / 2 << " ";
    }
    cout << endl;
  } else {
    cout << "No" << endl;
  }
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

Measured memory_bytes: 3200
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n,m = map(int,readline().split())
c = set()
v = {}
for i in range(m):
  a,b = map(int,readline().split())
  d = list(map(int,readline().split()))
  e = 0
  for j in d:
    e += 2**(j-1)
  if i >= 1:
    s = list(c)
    for k in s:
      if not k|e in c:
        c.add(k|e)
        v[k|e] = a+v[k]
      else:
        v[k|e] = min(v[k|e],a+v[k])
  if not e in c:
    c.add(e)
    v[e] = a
  else:
    v[e] = min(v[e],a)
    
if 2**n-1 in c:
  print(v[2**n-1])
else:
  print(-1)


Measured memory_bytes: 3952
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, X, Y;
  char s[101]={};
  char s_temp[101]={};
  char t[101]={};
  int len=0;
  int N, M;
  int A[20000]={};
  int B[20000]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=101;
  int cnt=0;
  int max=0;
  int ans=0;

//  long cnt =0;
  long long A_temp;
//    int k=0;

  scanf("%s", s);
// printf("%d\n", a);

  for(i=0;i<strlen(s);i++){
    if(i==0){
      if(s[i] != 'A'){
        printf("WA\n");
        return 0;
      }
      else{
        flag==1;
      }
    } else {
      if(s[i] == 'C' && flag==1){
        printf("WA\n");
        return 0;
      }
      else if(s[i] == 'C' && flag==0 ){
        cnt=1;
        flag=1;
      }
      else if((s[i] < 'a') || (s[i] > 'z')){
        printf("WA\n");
        return 0;
      }
    }
    if(i==(strlen(s)-2)) flag=1;
    else if(i==0) flag=1;
    else if(i==1) flag=0;
  }
  
  if(cnt==1)printf("AC\n");  
  else printf("WA\n");  
  
return 0;
}


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

int main(){
  int N;
  string A;
  cin >> N;
  cin >> A;
  
  if(N >= 3200){
  	cout << A << endl;
  }else{
  	cout << "red" << endl;
  }
  
  
  return 0;
}





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

const int N = (int)1e5 + 10;
const double eps = 1e-8;

template <typename T> inline T gcd(T a, T b) { a = abs(a), b = abs(b); while ( b ) { a %= b; swap(a, b); } return a; }
vector <pair <int, int> > adj[N + 7];


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int len = (int)s.length();
	queue <char> q;
	int cnt = 0;
	for ( int i = 0; i < len; ++i ) {
		if ( q.empty() ) {
			q.push(s[i]);
			continue;
		}
		if ( q.front() != s[i] ) {
			q.pop();
			++cnt;
			continue;
		}
		q.push(s[i]);
	}
	cout << cnt * 2 << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n;cin >> n;
    int a[n+1];
    rep(i,n) cin >> a[i+1];
    int count=0;
    for(int i=1;i<=n;i++){
        if(i==a[a[i]] and a[i]==a[a[a[i]]]){
            count++;
        }
    }
    cout << count/2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int i;
	int x=tx-sx;
	int y=ty-sy;
	for (i=0;i<y;i++){
		cout<<"U";
	}
	for (i=0;i<x;i++){
		cout<<"R";
	}
	for (i=0;i<y;i++){
		cout<<"D";
	}
	for (i=0;i<x;i++){
		cout<<"L";
	}
	cout<<"L";
	for (i=0;i<y+1;i++){
		cout<<"U";
	}
	for (i=0;i<x+1;i++){
		cout<<"R";
	}
	cout<<"D";
	cout<<"R";
	for (i=0;i<y+1;i++){
		cout<<"D";
	}
	for (i=0;i<x+1;i++){
		cout<<"L";
	}
	cout<<"U"<<endl;
	return 0;

}

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

int main() {
	long a; long b; long x;
	cin >> a >> b >> x;
	if (a == 0) {
		cout << b/x + 1 << endl;
	} else {
		cout << b/x - (a-1)/x << endl;
	}
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p[] = new int[n];
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
            a[i] = p[i];
        }
        Arrays.sort(a);
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] != p[i]) {
                cnt++;
            }
        }
        if (cnt <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        sc.close();
    }
}


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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair



int main() {
    int N; cin >> N;
    if (N % 10 == 3) PRINT("bon");
    else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) PRINT("pon");
    else PRINT("hon");
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

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

    int N;
    cin >> N;
    int dp[N + 1];

    dp[0] = 0;
    FOR(i, 1, N + 1) {
        dp[i] = INF32;

        int power = 1;
        while (power <= i) {
            chmin(dp[i], dp[i - power] + 1);
            power *= 6;
        }
        power = 1;
        while (power <= i) {
            chmin(dp[i], dp[i - power] + 1);
            power *= 9;
        }
    }
    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 640
a=['dream','dreamer','erase','eraser']
def check(c):
    if c=='':
        return True
    size=len(c)
    n=len(c)
    while n>0:
        tmp=n
        for i in a:
            #print(-n-len(i),-n)
            if size>=len(i) and c[n-len(i):n]==i:
                n-=len(i)
        if tmp==n:
            return False
    return True

print('YES' if check(input()) else 'NO')


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

int main(void) {
  string S;
  cin >> S;
  string word[4] = {"dream", "dreamer", "erase", "eraser"};
  reverse(S.begin(), S.end());
  for(int i = 0; i < 4; i++)reverse(word[i].begin(), word[i].end());
  
  bool flag = false;
  for(int i = 0; i < S.size();){
    bool flag_word = false;
    for(int j = 0; j < 4; j++){
      if(word[j] == S.substr(i, word[j].size())){
        i += word[j].size();
        flag_word = true;
        if(i == S.size())flag = true;
        break;
      }
    }
    if(!flag_word){
      break;
    }
  }
  
  if(flag)cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 512
<?php
  $n = trim(fgets(STDIN));
  $min = PHP_INT_MAX;
  $min = min($min,trim(fgets(STDIN)));
  $min = min($min,trim(fgets(STDIN)));
  $min = min($min,trim(fgets(STDIN)));
  $min = min($min,trim(fgets(STDIN)));
  $min = min($min,trim(fgets(STDIN)));
  
  $ans = 5+intdiv($n,$min);
  if($min == 1 || $n%$min==0){
      $ans--;
  }else if($min == $n){
      $ans = 5;
  }
  echo $ans;

Measured memory_bytes: 4604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        // ans: 最長減少部分列(広義)
        
        // 符号を反転させれば減少にできる
        for (int i = 0; i < n; i++) {
            array[i] *= -1;
        }
        
        int[] lis = new int[n];
        int INF = 1001001009;
        Arrays.fill(lis, INF);
        
        for (int i = 0; i < n; i++) {
            int val = array[i];
            
            int index = upperBound(lis, val);
            lis[index] = val;
            // System.out.println(Arrays.toString(lis));
        }
        
        int length = lowerBound(lis, INF);
        System.out.println(length);
    }
    
    public static int lowerBound(int[] array, int target) {
        // target"以上の"初めての場所を返す
        // {1, 3, 3, 7} target: 3 -> 1
        
        int left = 0;
        int right = array.length;
        
        while (left < right) {
            int center = (left + right) / 2;
            if (array[center] < target) {
                left = center + 1;
            } else {
                right = center;
            }
        }
        
        return left;
    }
    
    public static int upperBound(int[] array, int target) {
        // target"より大きい"初めての場所を返す
        // {1, 3, 3, 7} target: 3 -> 3
        
        int left = 0;
        int right = array.length;
        
        while (left < right) {
            int center = (left + right) / 2;
            if (array[center] <= target) {
                left = center + 1;
            } else {
                right = center;
            }
        }
        
        return left;
    }
}


Measured memory_bytes: 59960
#pragma GCC optimize(2)
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int maxn = 2e5 + 5;
int n, d, a[maxn];
ll dp[maxn];

int main() {
	scanf("%d %d", &n, &d);
	for (int i = 0; i < n; ++ i)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; ++ i) dp[i] = a[i];
	for (int i = 0; i + 1 < n; ++ i)
		dp[i + 1] = min(dp[i + 1], dp[i] + d);
	for (int i = n - 1; i; -- i)
		dp[i - 1] = min(dp[i - 1], dp[i] + d);
	ll ans = 0;
	for (int i = 0; i < n; ++ i) ans += a[i];
	for (int i = 1; i < n - 1; ++ i) ans += dp[i];
	printf("%lld\n", ans + 1LL * d * (n - 1));
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
int main(){
  int s_len,t_len,i,j,tmp,min=1000;
  char s[1001],t[1001];
  
  scanf("%s",s);
  scanf("%s",t);
  s_len=strlen(s);
  t_len=strlen(t);
  
  for(i=0;i<=(s_len-t_len);i++){
    tmp=0;
    for(j=0;j<t_len;j++){
      if(s[i+j]!=t[j]){
        tmp++;
      }
    }
    if(tmp<min){
      min=tmp;
    }
  }
  
  printf("%d",min);
}


Measured memory_bytes: 1724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		
		int[] a = new int[N+1];
		
		for (int i = 1; i < N+1; i++) {
			a[i] = in.nextInt();
	
		}
		
		int pairs = 0;
		for (int i = 1; i < N+1; i++) {
			if (a[i]>0&&a[a[i]]==i) {
				pairs++;
				a[i] = 0;
				a[a[i]] = 0;
			}
		}
		
		System.out.println(pairs);
		
	}
}


Measured memory_bytes: 32144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int num = 0;
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) == '+') {
				num++;
			} else {
				num--;
			}
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 21844
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 input = br.readLine();
			if (input.equals("a") ||input.equals("e")|| input.equals("i") || input.equals("o") || input.equals("u")) {
           	        System.out.println("vowel");
 
            }else{
       	        System.out.println("consonant");
 
            }
       
     
     
     }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    string s = is();
    if(s[0] < 'a'){
        ose("A");
    }else{
        ose("a");
    }

    return 0;
}

Measured memory_bytes: 3572
s = input()
t = input()

from collections import defaultdict

td = defaultdict(set)
sd = defaultdict(set)
for i in range(len(s)):
        td[t[i]].add(s[i])
        sd[s[i]].add(t[i])

for tv, sv in zip(td.values(), sd.values()):
    if (len(tv) > 1) or (len(sv) > 1):
        print("No")
        break
else:
    print('Yes')

Measured memory_bytes: 3776
#include<stdio.h>


int main(){
  int i,n,f[46];
  scanf("%d",&n);
  f[0]=0;
  f[1]=1;
  for(i=2;i<46;i++)
    f[i]=f[i-2]+f[i-1];
  
  printf("%d\n",f[n+1]);



return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long int
#define inf 1000000000000
#define MOD 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define for0(i, n) for (int i = 0; i < n; i++)
#define tc(t) int t; cin >> t; while (t--)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ps(x,y)         fixed<<setprecision(y)<<x
using namespace std;
using namespace __gnu_pbds;
ll arr[105];
int n;
ll k;
ll cnt = 0;
ll dp[103][100005];
/*int candies(int pos, ll rem)
{
	if (pos == n)
	{
		if (rem == 0)
		{
			return 1;
		}
		else
			return 0;
	}
	if (dp[pos][rem] != 0)
		return dp[pos][rem] %= MOD;
	for (int i = 0; i <= min(arr[pos], rem); i++)
	{
		dp[pos][rem] += candies(pos + 1, rem - i);
		dp[pos][rem] %= MOD;
	}
	return dp[pos][rem] %= MOD;
}*/
int main()
{
	IOS
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	cin >> n >> k;
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= n; i++)
		cin >> arr[i];
	//ll res = candies(0, k, 0);
	//cout << res << endl;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		vi sum(k + 1);
		sum[0] = dp[i - 1][0];
		for (int j = 1; j <= k ; j++)
			sum[j] = (sum[j - 1] + dp[i - 1][j]) % MOD;
		for (int j = 0; j <= k; j++)
		{
			if (j <= arr[i])
				dp[i][j] = sum[j];
			else
			{
				dp[i][j] = (sum[j] - sum[j - arr[i] - 1] + MOD) % MOD;
			}
		}
	}
	cout << dp[n][k] << endl;
	/*for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
}


Measured memory_bytes: 81152
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define AC(x,t) accumulate(ALL(x),t)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cnt{};
    REP( i, 100 )
    {
        if( i >= a && i < b && i >= c && i < d )
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
  int n;
  double s[1000]={};
  while(cin >> n,n!=0) {
      double s[1000]={},sum=0,a=0;
      for(int i=0; i<n; i++) {
          cin >> s[i];
          sum+=s[i];
      }
      for(int i=0; i<n; i++) {
          a+=(s[i]-sum/n)*(s[i]-sum/n)/n;
      }
      cout << fixed <<setprecision(10) << sqrt(a) << endl;
  }
  
}


Measured memory_bytes: 3276
n=int(input())
monster=list(map(int,input().split()))
yusha=list(map(int,input().split()))
moto=sum(monster)

for i in range(1, n+1):
    if yusha[-i]<=monster[-i]:
        monster[-i]-=yusha[-i]
    else:
        monster[-i-1]=monster[-i-1]-yusha[-i]+monster[-i]
        monster[-i]=0
        if monster[-i-1]<0:
            monster[-i-1]=0



ans=moto-sum(monster)

print(ans)

Measured memory_bytes: 82020