akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        String a = sc.next();
        if ("RRR".equals(a)) {
            pw.println(3);
        } else if (a.startsWith("RR") || a.endsWith("RR")) {
            pw.println(2);
        } else if (a.contains("R")) {
            pw.println(1);
        } else {
            pw.println(0);
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


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

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

    int n;
    cin >> n;

    map<pair<int, int>, int> x;
    vector<set<int>> y(n + 1);
    vector<int> a(n + 1, 2);
    a[1] = 0;

    rep(i, 1, n)
    {
        int u, v, w;
        cin >> u >> v >> w;
        y[u].insert(v);
        y[v].insert(u);
        x[make_pair(min(u, v), max(u, v))] = w;
    }

    stack<int> st;
    st.push(1);

    while (!st.empty())
    {
        stack<int> ss;
        swap(ss, st);

        while (!ss.empty())
        {
            int z = ss.top();
            ss.pop();

            for (auto q : y[z])
            {
                if (a[q] != 2)
                    continue;
                st.push(q);
                if (x[make_pair(min(z, q), max(z, q))] % 2 == 0)
                    a[q] = a[z];
                else
                    a[q] = a[z] ^ 1;
            }
        }
    }

    for (auto z : a)
        if (z != 2)
            cout << z << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    int now = 1;
    for(int i : a) {
        if(i == now) now++;
        else ans++;
    }
    if(ans == n) cout << "-1" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
inline void input(){
    fast_io();
    cin >> N;
}

vector< int > prime_table(int n) {
  vector< int > prime(n + 1, 1);
  if(n >= 0) prime[0] = 1;
  if(n >= 1) prime[1] = 1;
  for(int i = 2; i <= n; i++) {
      prime[i]++;
    for(int j = i + i; j <= n; j += i) {
      prime[j]++;
    }
  }
  return prime;
}


inline int solve(){
    auto pt = prime_table(N);
    ll ans = 0;
    for (int c = 1; c < N; c++)
    {
        ans += pt[N-c];
    }
    cout << ans << endl;
    return 0;
}   

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


Measured memory_bytes: 7128
H, W = map(int, input().split(' '))
A = [list(map(int, input().split(' '))) for i in range(H)]
cnt = 0
ans = []
for i in range(H):
    for j in range(W):
        if A[i][j] % 2 == 0:
            continue
        tmp = ''
        flg = True
        for x, y in [[1, 0], [0, 1]]:
            if 0 <= i+x < H and 0 <= j+y < W:
                if A[i+x][j+y] % 2 != 0:
                    A[i][j] -= 1
                    cnt += 1
                    A[i+x][j+y] += 1
                    ans.append([i, j, i+x, j+y])
                    flg = False
                    break
                else:
                    tmp = [x, y]
        if flg and tmp:
            cnt += 1
            A[i+tmp[0]][j+tmp[1]] += 1
            A[i][j] -= 1
            ans.append([i, j, i+tmp[0], j+tmp[1]])
print(cnt)
for i, j, k, l in ans:
    print(i+1, j+1, k+1, l+1)


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

using namespace std;

int ct[3];
char ss[200000];
int main()
{	
	scanf("%s",ss);
	int n=strlen(ss);
	for(int i=0;i<n;i++)
		ct[0]+=ss[i]=='a',
		ct[1]+=ss[i]=='b',
		ct[2]+=ss[i]=='c';
	sort(ct,ct+3);
	if(ct[2]-ct[0]>1) puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 384
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let d, k = abs @@ n - m, 1000000007
let rec f n a = if n <= 1 then a else f (n - 1) (a * n mod k)
let _ = Printf.printf "%d\n" @@ if d > 1 then 0 else f n 1 * f m 1 mod k * (2 - d) mod k

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
	int m,f,r;
	refrain:
	cin>>m;
	cin>>f;
	cin>>r;
	if(m==-1&&f==-1&&r==-1) return 0;
	
	if(m==-1||f==-1) cout<<'F'<<endl;
	else if(m+f>=80) cout<<'A'<<endl;
	else if(m+f>=65) cout<<'B'<<endl;
	else if(m+f>=50) cout<<'C'<<endl;
	else if(m+f<30)  cout<<'F'<<endl;
	else if(r>=50)   cout<<'C'<<endl;
	else 			 cout<<'D'<<endl;
	goto refrain;
}

Measured memory_bytes: 1152
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(uint[]);
    int[uint] MEMO;
    foreach (a; as) {
        if (a !in MEMO) MEMO[a] = 0;
        ++MEMO[a];
    }
    uint[] ns;
    foreach (k, _; MEMO) ns ~= k;
    if (ns.length == 1) {
        if (ns[0] == 0) {
            writeln("Yes");
        } else {
            writeln("No");
        }
    } else if (ns.length == 2) {
        if (0 in MEMO && MEMO[0] >= N/3 && MEMO[0] <= N/3+1) {
            writeln("Yes");
        } else {
            writeln("No");
        }
    } else if (ns.length == 3) {
        auto a = ns[0];
        auto b = ns[1];
        auto c = ns[2];
        if (a^b^c) goto ng;
        foreach (n; ns) {
            if (MEMO[n] < N/3 || N/3+1 <= MEMO[n]) goto ng;
        }
        writeln("Yes");
        return;
        ng:
        writeln("No");
    } else {
        writeln("No");
    }
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int arr[n+1];
    for(int i = 1; i <= n; i++) cin >> arr[i];

    int diffs = 0;
    for(int i = 1; i <= n; i++) {
        if(arr[i] != i) diffs++;

        if(diffs > 2) {
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (N, K) = readLine()!!.split(" "). map { it.toInt() }
    var p = readLine()!!.split(" "). map { it.toInt() }
    var kitai = DoubleArray(2000)
    for (i in 1 .. 1000) {
        var k = 0.0
        for (l in 1..i) {
            k += l / i.toDouble()
        }
        kitai[i] = k
    }
    var c = 0.0
    var max = 0.0
    for (i in 0 until N) {
        c += kitai[p[i]]
        if (i >= K) {
            c -= kitai[p[i-K]]
        }
        max = Math.max(max, c)
    }
    println(max)
}

Measured memory_bytes: 62112
// Problem : C - 4/N
// Contest : AtCoder - Tenka1 Programmer Contest
// URL : https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	// int T;cin>>T;
	ll N;
	cin>>N;
	for(ll x=3500;x>=1;x--)
	{
		for(ll y=x;y>=1;y--)
		{
			if(4/(ld)N<=1/(ld)x+1/(ld)y)
				continue;
			// bug(y);
			ll v1=N*x/(__gcd(N,x));
			v1=v1*y/__gcd(v1,y);
			ll v2=4*(v1/N)-v1/x-v1/y;
			ld val=1e-20;
			val=v1/(ld)v2;
			// bug(val);
			if(val==(ll)val && val>0 && val<=3500)
			{
				cout<<x<<' '<<y<<' '<<(int)val<<nl;
				return 0;
			}
		}
	}
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX=200000;
 
int main(){
    int R[MAX],n;
     
    cin >> n;
    for(int i=0;i<n;i++)cin >> R[i];
     
    int maxv = -2000000000;
    int minv=R[0];
     
    for(int i=1;i<n;i++){
        //cout <<"debug:MAX R[i]" << R[i] << "??¨minv"<<minv<<endl;
        //if(maxv<R[i]-minv)cout<<"debug:max??´??°"<<R[i]-minv<<endl;
        maxv=max(maxv,R[i]-minv);
         
        //cout <<"debug:min minv" <<minv << "??¨R[i]"<<R[i]<<endl;
        //if(minv>R[i])cout<<"debug:minv??´??°"<<R[i]<<endl;
        minv=min(minv,R[i]);
         
        //cout<<"----"<<endl;
    }
     
    cout<<maxv<<endl;
     
    return 0;
}

Measured memory_bytes: 3900
from typing import List
import sys


def read_data(file_name: str, std_in=True):
    satisfactions_list = list()
    file = sys.stdin if std_in else open(file_name, 'r')
    days = int(file.readline().rstrip())
    satisfaction_decreases = [int(c) for c in file.readline().rstrip().split(" ")]
    for i in range(days):
        satisfactions_list.append([int(c) for c in file.readline().rstrip().split(" ")])
    if not std_in:
        file.close()
    return days, satisfaction_decreases, satisfactions_list


class Contest:
    def __init__(self, _type: int, satisfactions: List[int], satisfaction_decrease: int):
        self.dissatisfaction = 0
        self.type = _type
        self.satisfactions = satisfactions
        self.satisfaction_decrease = -satisfaction_decrease

    def __getitem__(self, key: int):
        return self.satisfactions[key - 1]

    def __str__(self):
        return str(self.type)

    def __repr__(self):
        return f"Contest(_type={self.type}, satisfactions={self.satisfactions}, satisfaction_decrease={self.satisfaction_decrease})"

    def heuristic(self, day):
        return self[day] - (self.dissatisfaction + self.satisfaction_decrease)

    def winner(self):
        self.dissatisfaction = 0

    def loser(self):
        self.dissatisfaction += self.satisfaction_decrease


def get_best(contests: List[Contest], day: int):
    # improve this by optimistically making everyone a loser and then going back to undo that for the winner
    best = contests[0]
    for contest in contests:
        if contest.heuristic(day) > best.heuristic(day):
            best = contest
    return best


def main(file_name="input.txt"):
    contests = list()
    days, satisfaction_decreases, satisfactions_list = read_data(file_name)
    picks = list()

    for (_type, (satisfactions, satisfaction_decrease)) in enumerate(zip(zip(*satisfactions_list), satisfaction_decreases), start=1):
        contests.append(Contest(_type, satisfactions, satisfaction_decrease))

    for day in range(days):
        best = get_best(contests, day + 1)
        for contest in contests:
            if contest.type == best.type:
                contest.winner()
                picks.append(contest)
            else:
                contest.loser()

    return "\n".join([str(pick) for pick in picks])


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 10480
#include <iostream>
#include <cstring>
#include <algorithm>
#define MAX_N 200000
#define MAX_A 200000
using namespace std;

int n, a[MAX_N];

void solve()
{
    int ma1 = 0, ma2 = 0; // 最も大きな値２つ
    int count = 0;        // 最大値のカウンター
    for (int i = 0; i < n; i++)
    {
        if (a[i] > ma2)
        {
            if (a[i] > ma1)
            {
                swap(ma1, ma2);
                ma1 = a[i];
                count = 1;
            }
            else if (a[i] == ma1)
            {
                count++;
            }
            else
            {
                ma2 = a[i];
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] == ma1 && count == 1)
        {
            // a[i]そのものが最大値であるとき
            cout << ma2 << endl;
        }
        else
        {
            cout << ma1 << endl;
        }
    }
}

int main()
{
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    solve();
}


Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

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

int main(){
   int n;
   cin >> n;
   int a[n];
   vector<int> l(n), r(n);
   rep(i, n) cin >> a[i];
   rep(i, n-1){
      int j = n - i -2;
      l[i+1] = gcd(l[i], a[i]);
      r[j] = gcd(r[j+1], a[j+1]);
   }
   int maxi = 1;
	rep(i, n) maxi = max(maxi, gcd(l[i], r[i]));
	cout<< maxi <<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
ll n;
ll min (ll  a, ll b)
{
	if(a < b)return a;
	return b;
}
int main(){
	
    cin >> n;
    ll ans = n-1;

    repA(a,1,sqrt(n)){
    	if(n % a == 0){
    		ans = min(ans,((n/a) + (a) - 2));
    	}
    }

    cout << ans;

    return 0;
}


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

int gcd(int x, int y){
    return y ? gcd(y, x % y) : x;
}

int main(){
    int x,y;
    cin >> x >> y;

    if(x==y){
        cout << x+1 << endl;
    }else{
        cout << x+y-gcd(x,y)+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  vector<int> v;
  for(int i = 0; i < n; i++) {
    int x;
    cin>>x;
    v.push_back(x-1);
  }
  vector<int> ans;
  for(int i = 0; i < n; i++){
    bool checker = false;
    for(int j = v.size()-1; j >= 0; j--){
      if(v[j]==j){
        ans.push_back(v[j]+1);
        v.erase(v.begin()+j);
        checker = true;
        break;
      }
    }
    if(!checker){
      // cout<<i<<endl;
      cout<<-1<<endl;
      return 0;
    }
  }
  reverse(ans.begin(),ans.end());
  for(int i = 0; i < ans.size(); i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <forward_list>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// sanitize: shift + f11
// debug: shift + f9

void A() {
    string S;

    cin >> S;

    if(S == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}

void B() {
    ll N, K;

    cin >> N >> K;

    vi snukes(N, 0);

    R1(K) {
        ll di;
        cin >> di;
        R2(j, di) {
            ll ai;
            cin >> ai;
            snukes[ai-1]++;
        }
    }

    ll tot = 0;
    for(auto e : snukes) {
        if(e == 0) {
            ++tot;
        }
    }

    cout << tot << endl;
}

void C() {
    ll N, M;

    cin >> N >> M;
    vi hi(N);
    vii ri(M);
    vi go(N, 1);

    R1(N)
        cin >> hi[i];

    R1(M) {
        ll s, e;
        cin >> s >> e;
        s-=1;
        e-=1;
        if(hi[s] > hi[e])
            go[e] = 0;
        else if(hi[s] < hi[e])
            go[s] = 0;
        else {
            go[e] = 0;
            go[s] = 0;
        }
    }

    ll tot = 0;
    for(auto e : go) {
        tot += e;
    }

    cout << tot << endl;
}

void D() {
    ll X;

    cin >> X;

    for(ll A = -6207; A < 6207; ++A) {
        for(ll B = -6207; B < 6207; ++B) {
            if((A*A*A*A*A) - (B*B*B*B*B) == X) {
                cout << A << " " << B << endl;
                return;
            }
        }
    }
}

void E() {
    ll N;

    cin >> N;

    vi ai(N);

    R1(N) {
        cin >> ai[i];
    }

    vi pref(N);

    ll tot = 0;

    vector<pair<vector<long long>, vector<long long>>> vals(N);

    for(int i = 0; i < N; ++i) {
        if(i - ai[i] >= 0) {
            vals[i-ai[i]].second.push_back(i);
        }
        if(i + ai[i] < N) {
            vals[i+ai[i]].first.push_back(i);
        }
    }

    for(auto e : vals) {
        tot += (e.first.size() * e.second.size());
    }

    cout << tot << endl;
}

int main()
{
    E();
}

Measured memory_bytes: 24336
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main() {
    string s;
    cin>>s;
    rep(i,3){
        cout<<s.at(i);
    }cout<<endl;
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define Rep( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))
typedef long long ll;
using namespace std;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar ( x % 10 | 48 );
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {
	
	ll n, H[N];
	
	int main() {
		n = read();
		For ( i, 1, n ) H[i] = read();
		Rep ( i, n - 1, 1 ) 
			if (H[i] - 1 > H[i + 1]) return puts("No"), 0;
			else if (H[i] > H[i + 1]) --H[i];
		return puts("Yes"), 0;
	}
	
}

int main()
{
	return Cesare::main();
}

/*

*/



Measured memory_bytes: 1024
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64_t
#endif


const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

pair <int, int> L[MAXN], R[MAXN];
int a[MAXN];

 main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    for (int i = 0; i < n; i++) {
    	a[i] = readInt();
    }
    int tmp1 = 0;
    int tmp2 = 0;
    int r = 0;
    for (int l = 0; l < n; l++) {
    	tmp1 += a[l];
    	while(r <= l && abs(tmp1 - tmp2) >= abs(tmp2 + a[r] - (tmp1 - a[r]))) {
    		tmp2 += a[r];
    		tmp1 -= a[r];
    		r++;
    	}
    	L[l] = {tmp1, tmp2};
    }
    tmp1 = 0;
    tmp2 = 0;
    r = n - 1;
    for (int l = n - 1; l >= 0; l--) {
    	tmp1 += a[l];
    	while(r >= l && abs(tmp1 - tmp2) >= abs(tmp1 - a[r] - (tmp2 + a[r]))) {
    		tmp1 -= a[r];
			tmp2 += a[r];
			r--;
    	}
    	R[l] = {tmp1, tmp2};
    }
	
    int ans = MOD;
    for (int i = 1; i < n - 2; i++) {
		vector <int> tmp = {L[i].F, L[i].S, R[i+1].F, R[i+1].S};
		sort(tmp.begin(), tmp.end());
		ans=min(ans, tmp[3] - tmp[0]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
 
namespace TYC
{
    #define int ll
 
    typedef long long ll;
    const int N = 1e5 + 10;
 
    int n, m, x[N], a[N], ans[N];
    ll K;
 
    inline int read()
    {
        int x = 0, f = 0, ch = getchar();
        while (!isdigit(ch))
            f |= (ch == '-'), ch = getchar();
        while (isdigit(ch))
            x = x * 10 + ch - '0', ch = getchar();
        return f ? -x : x;
    }
 
    inline void calc(int *r, int *x, int *y)
    {
        static int tmp[N], fir[N], to[N];
        memcpy(fir, x, sizeof(int[n]));
        memcpy(to, y, sizeof(int[n]));
        for (int i = 1; i <= n; i++)
            tmp[i] = to[fir[i]];
        memcpy(r, tmp, sizeof(int[n]));
    }
 
    void work()
    {
        n = read();
        for (int i = 0; i < n; i++)
            x[i] = read();
        for (int i = 0; i < n; i++)
            a[i] = ans[i] = i;
        m = read();
        scanf("%lld", &K);
        for (int i = 0; i < m; i++)
        {
            int t = read();
            swap(a[t - 1], a[t]);
        }
        for (; K; K >>= 1, calc(a, a, a))
            if (K & 1)
                calc(ans, a, ans);
        for (int i = 0; i < n; i++)
            a[i] = x[ans[i]] - x[ans[i] - 1];
        for (int i = 0; i < n; ++i, a[i] += a[i - 1])
            printf("%lld.0\n", a[i]);
    }
 
    #undef int
}
 
int main()
{
    TYC::work();
    return 0;
}

Measured memory_bytes: 6144
#include <iostream>

using namespace std;

int main(void){
	int n;
	int man[4][3][10] = {0};

	cin >> n;
	for(int i = 0; i < n; i++){
		int b,f,r,v;

		cin >> b >> f >> r >> v;
		man[b-1][f-1][r-1] += v;
	}

	for(int i = 0; i < 4*3*10; i++){
		if(i){
			if(!(i%10))
				cout << endl;
			if(!(i%30))
				cout << "####################" << endl;
		}

		cout << " " << *((int*)man+i);
	}
				
	cout << endl;
}



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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

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

    int n, c, k;
    cin >> n >> c >> k;
    vector<llong> T(n);
    rep(i, n) cin >> T[i];
    sort(all(T));

    llong res = 1, start = T[0], cnt = 1;
    for (int i = 1; i < n; ++i) {
        ++cnt;
        if (start + k < T[i] || cnt > c) {
            start = T[i];
            cnt = 1;
            ++res;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=(1<<18)+10;
const int inf=2147483647;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
int n,a[Maxn];
int f[Maxn],g[Maxn];
int main()
{
//	freopen("subtask_1_17.txt","r",stdin);
//	freopen("1.txt","w",stdout);
	n=read();
	for(int i=0;i<(1<<n);i++)f[i]=i,a[i]=read();
	g[0]=-1;
	for(int S=1;S<(1<<n);S++)
	{
		g[S]=-1;
		for(int i=0;i<n;i++)
		if((1<<i)&S)
		{
			int t=f[S^(1<<i)];
			if(a[t]>a[f[S]])g[S]=f[S],f[S]=t;
			else if(t!=f[S]&&a[t]>a[g[S]])g[S]=t;
			t=g[S^(1<<i)];
			if(t!=-1&&a[t]>a[g[S]])g[S]=t;
		}
	}
	int ans=0;
	for(int S=1;S<(1<<n);S++)
	{
		ans=max(ans,a[f[S]]+a[g[S]]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;



int main() {
    ll n;
    
    cin>>n;
    vector<int> a(n-1);
    vector<int> b(n);
    
    rep(i, n-1) cin>>a[i];
    
    rep(i, n-1) b[a[i]-1] ++;
    
    rep(i, n) cout<<b[i]<<endl;

    return 0;
}


Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);
 
int main(){
    IOS;
    ll n,m;cin>>n>>m;
    bool a[n][m];
    f(i,0,n){
        f(j,0,m){
            char c;cin>>c;
            a[i][j]=(c=='.');
        }
    }
    ll dx[4]={1,-1,0,0}; ll dy[4]={0,0,1,-1};
    ll ans=0;
    f(ix,0,n){
        f(iy,0,m){
            if(!a[ix][iy])continue;
            ll dist[n][m];f(i,0,n)f(j,0,m)dist[i][j]=-1;
            dist[ix][iy]=0;
            queue<ii>q;q.push({ix,iy});
            while(!q.empty()){
                ii cur=q.front();q.pop();
                ll x=cur.F,y=cur.S;
                f(i,0,4){
                    f(j,0,4){
                        ll newx=x+dx[i];ll newy=y+dy[i];
                        if(newx<0 || newx>=n || newy<0 || newy>=m)continue;
                        if(!a[newx][newy])continue;
                        if(dist[newx][newy]!=-1)continue;
                        dist[newx][newy]=1+dist[x][y];
                        q.push({newx,newy});
                        ans=max(ans,dist[newx][newy]);
                    }
                }
            }
        }
    }
    cout<<ans;
    return 0;
}   

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

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

  bool ok = false;
  for (int i = 0; i <= X; i++) {
    int turu = i;
    int kame = (X - i);
    if (turu * 2 + kame * 4 == Y) {
      ok = true;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int h,w;
  cin >> h >> w;
  int n;
  cin >> n;
  cout << (n+max(h,w)-1)/max(h,w) << endl;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()
ans = 0
for i in range(k):
    dp = [0]*3
    for j in range(i, n, k):
        nxt = [-float("inf")]*3
        nxt[0] = max(dp[1], dp[2])
        if t[j] == "s":
            nxt[0] += r
        nxt[1] = max(dp[0], dp[2])
        if t[j] == "p":
            nxt[1] += s
        nxt[2] = max(dp[1], dp[0])
        if t[j] == "r":
            nxt[2] += p
        dp = nxt
    ans += max(dp)
print(ans)


Measured memory_bytes: 58860
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  string s;
  cin >> s;
  s[5] = s[13] = ' ';
  cout << s << endl;
}


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

using namespace std;

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

	int n = (X + 99) / 100;
	int m = 1000;
	vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= m; ++j) {
			if (dp[i][j] == 0) { continue; }
			for (int k = 0; k <= 5; ++k) {
				if (j + k > m) { continue; }
				dp[i + 1][j + k] = 1;
			}
		}
	}

	bool ok = false;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= m; ++j) {
			if (i * 100 + j == X && dp[i][j] == 1) {
				ok = true;
			}
		}
	}
	cout << (ok ? 1 : 0) << endl;

	return 0;
}


Measured memory_bytes: 4224
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k, x, y = II(),II(),II(),II()
    ans = 0
    for i in range(n):
        if i >= k:
            ans += y
        else:
            ans += x
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39408
N, C, K = map(int, input().split())
T = [0 for _ in range(N)]
for __ in range(N):
    T[__] = int(input())

T.sort()
bus_count = 1
bus_rest = C
bus_depert = T[0]+K

for ix in range(N):

    if T[ix] <= bus_depert and bus_rest > 0:
        bus_rest -= 1

    else:
        bus_count += 1
        bus_depert = T[ix] + K
        bus_rest = C - 1

print(bus_count)

Measured memory_bytes: 13384
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int N, i;
    double x[11], sum=0;
    string u[11];

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> x[i] >> u[i];

        if(u[i] == "JPY"){
            sum += x[i];
        }

        else{
            sum += x[i] * (double)380000;
        }
    }

    cout << setprecision(20) << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];
    ll ans = 0;
    sort(a,a+n,greater<ll>());
    srep(i,1,n)ans += a[i/2];
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5164
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	for i := n - 1; 0 <= i; i-- {
		if i != n-1 {
			fmt.Print(" ")
		}
		fmt.Print(nums[i])
	}
	fmt.Println()
}



Measured memory_bytes: 1116
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}
int main(){
    int N;
    cin >>N;


    int ans=1;

    for(;ans*ans<=N;ans++){
    }
    ans--;
    cout<<ans*ans<<endl;


    return 0;
}

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

int num (const std::string& S, int idx){
	return S.at(idx) - '0';
}

int main(){
	string S;
	cin >> S;
	long long sums = 0;
	long long n = S.size();
	for(int bit=0; bit<(1 << (n-1)); ++bit){
		long long subsum = num(S, 0);
		for(int i=0; i<n-1; ++i){
			if(bit & (1<<i)){
				sums += subsum;
				subsum = num(S, i+1);
			}else{
				subsum *= 10;
				subsum += num(S, i+1);
			}
		}
		sums += subsum;
	}
	cout << sums << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<ll,int>
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=1e5+200;
int dp[N]= {},K,n,h[N]= {};
int solve(int idx)
{
    if (idx>=n)
        return 0;
    int &ret=dp[idx];
    if (~ret)
        return ret;
    ret=(int)2e9;
    lp(k,1,K)
    ret=min(ret,solve(idx+k)+abs(h[idx+k]-h[idx]));
    return ret;
}
int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    memset(dp,-1,sizeof(dp));
    cin>>n>>K;
    lp(i,0,n-1) cin>>h[i];
    lp(i,0,K+3)
    h[n+i]=h[n-1];
    cout<<solve(0)<<"\n";
    return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
  char ch[2000000]={'\0'};
  
  scanf("%s",ch);
  for(int i=0;ch[i]!='\0';i++){
  	if(ch[i]=='?'){
    		ch[i]='D';
            ch[i]='D';
    }
  }
  printf("%s",ch);
  
  return 0;
}

Measured memory_bytes: 4108
N = int(input())
a = list(map(int,input().split()))

cnt2 = 0
cnt4 = 0
cntodd = 0
for i in a:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1
    else:
        cntodd += 1

if cnt2 == 0 and cnt4 + 1 >= cntodd:
    ans = 'Yes'
elif cnt4 >= cntodd:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)    

Measured memory_bytes: 19928
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

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

Measured memory_bytes: 4456
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max<T>(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min<T>(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

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

	cout << ((a < c && c < b) || (b < c && c < a) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3560
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio;
    string s,s2,s3;
    int a,b,x;
    cin>>s>>s2>>s3;
    cout<<s[0]<<s2[1]<<s3[2]<<'\n';
    
    return(0);
}

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

const int INF = 1e9+5;

int main(){
	int n,K;
	scanf("%d%d",&n,&K);
	vector<int> h(n);
	for(int i = 0; i < n; i++){
		scanf("%d", &h[i]);
	}
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i = 0;i  < n; i++){
		for(int j = i+1; j <= i+K; j++){
			if(j < n)
				dp[j] = min(dp[j], dp[i]+ abs(h[i]-h[j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

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

    vector<int> up(n+1,0);

    vector<int> down(n+1,0);

    for(int i=0; i<2; i++){
        for(int j=1; j<=n; j++){
            int a; cin>>a;
            if(i==0){
            up[j] = up[j-1] + a;
            }

            else if(i==1){
                down[j] = down[j-1] + a;
            }
        }
    }

    int ans = 0;

    for(int i=1; i<=n; i++){
        int sum = 0;

        sum = up[i] + down[n] - down[i-1];

        ans = max(ans,sum);
    }

    cout<<ans<<endl;

    return 0;

}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int ret = 1;
	int n, k; cin >> n >> k;
	int c = 1;
	while(true) {
		if (n >= c * k) {
			ret++;
			c *= k;
		} else break;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256