akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

std::map< int64_t, int > prime_factor(int64_t n) {
  std::map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N;

  auto p = prime_factor(N);

  int ans = 0;
  for(auto&& s: p) {
    ans += (int) ( (std::sqrt( 8*s.second + 1 ) - 1.) / 2. );
  }
  std::cout << ans << std::endl;
  return 0;
}




Measured memory_bytes: 3676
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N,M,L;
int P[301][301];
pair<int,int>D[301][301];
vector<pair<int,int> >G[301];
main()
{
	cin>>N>>M>>L;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	for(int k=1;k<=N;k++)
	{
		for(int i=1;i<=N;i++)
		{
			P[k][i]=-1;
			D[k][i]=make_pair(1e9,0);
		}
		P[k][k]=k;
		D[k][k]=make_pair(0,L);
		priority_queue<pair<pair<int,int>,int> >Q;
		Q.push(make_pair(make_pair(0,L),k));
		while(!Q.empty())
		{
			int u=Q.top().second;
			int cnt=-Q.top().first.first;
			int now=Q.top().first.second;
			Q.pop();
			for(pair<int,int>p:G[u])
			{
				int v=p.first;
				int nxtc=cnt;
				int nxtnow;
				if(now>=p.second)nxtnow=now-p.second;
				else if(L>=p.second)nxtnow=L-p.second,nxtc++;
				else continue;
				if(D[k][v].first>nxtc||D[k][v].first==nxtc&&D[k][v].second<nxtnow)
				{
					D[k][v]=make_pair(nxtc,nxtnow);
					Q.push(make_pair(make_pair(-nxtc,nxtnow),v));
				}
			}
		}
	}
	int Q;
	cin>>Q;
	for(;Q--;)
	{
		int s,t;cin>>s>>t;
		int ans=D[s][t].first;
		if(ans<1e9)cout<<ans<<endl;
		else cout<<-1<<endl;
	}
}


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

int main(){
  ll n,ans=0; cin>>n;
  vector<ll> ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n) ret.push_back(n/i);
    }
  }
  sort(ret.begin(),ret.end());
  for(int i=0;i<ret.size();i++){
    if(n/ret[i]>=1 && (ret[i]-1)>n/ret[i]) ans+=ret[i]-1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int main(){
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    priority_queue<int> que;
    
    rep(i, n){
        rep(j, a[i]) que.push(i+1);
    }

    vector<vector<int>> ans;

    rep(y, h){
        vector<int> tmp;
        rep(x, w){
            int p = que.top();
            que.pop();
            tmp.push_back(p);
        }
        if(y%2 == 1) reverse(tmp.begin(), tmp.end());
        ans.push_back(tmp);
    }

    rep(y, h){
        rep(x, w) cout << ans[y][x] << " ";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
n=int(input())

dic={"AC":0, "WA":0, "TLE":0, "RE":0}

for i in range(n):
    dic[input()]+=1

print("AC x "+str(dic["AC"]))
print("WA x "+str(dic["WA"]))
print("TLE x "+str(dic["TLE"]))
print("RE x "+str(dic["RE"]))

Measured memory_bytes: 9200
N, M = gets.split.map(&:to_i)
G = Array.new(N + 1){ [] }
E = M.times.map{ gets.split.map(&:to_i) }
E.each do |e|
  u,v = *e
  G[u] << v
  G[v] << u
end

def lowlink(s)
  used  = Array.new(N + 1)
  ord = Array.new(N + 1, 2 * N)
  low = Array.new(N + 1, 2 * N)
  parent = Array.new(N + 1)
  
  stack = [s]
  parent[s] = s
  visit_order = []
  
  until stack.empty?
    u = stack.pop
    next if used[u]
    used[u] = true
    
    low[u] = ord[u] = visit_order.size
    visit_order << u
    
    G[u].each do |v|
      next if parent[u] == v
      if used[v]
        low[u] = ord[v] 
        next
      end
      parent[v] = u
      stack << v
    end
  end
  
  visit_order.reverse.each do |u|
    low[u] = G[u].map{|v| v == parent[u] ? low[u] : low[v] }.min
  end
  
  E.select do |e|
    u,v = *e.sort_by{|w| ord[w] }
    ord[u] < low[v] 
  end
end

puts lowlink(1).size

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n>=3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2100000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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

ll mod(ll val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
    return val;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

/* RMQ：[0,n-1] について、区間ごとの最小値を管理する構造体
    update(i,x): i 番目の要素を x に更新。O(log(n))
    query(a,b): [a,b) での最小の要素を取得。O(log(n))
*/
template <typename T>
struct SegmentTree {
    int n;         // 葉の数
    vector<T> dat; // 完全二分木の配列
    SegmentTree(int n_) : n(), dat(n_ * 4, 0) { // 葉の数は 2^x の形
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
    void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
    // the minimum element of [a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return 0;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
    //添字にアクセス
    T operator[](int i) {
        return dat[i + n - 1];
    }
};

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    SegmentTree<int> seg(300010);
    for(int i = 0;i < N;i++) {
        int cnt = seg.query(max(vec.at(i) - K,0),min(vec.at(i) + K + 1,300010)) + 1;
        seg.update(vec.at(i),cnt);
    }
    cout << seg.query(0,300010) << endl;
}

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


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



Measured memory_bytes: 4000
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;

 int main()
 {
   int n;
   while(cin>>n)
   {
     int result=0;
     int l,r;
     while(n--)
     {
       cin>>l>>r;
       result=result+(r-l+1);            
     }              
     cout<<result<<endl;
   }
   return 0;    
 }
 

Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	a,b := scanInt(),scanInt()

	if a+b >= a-b && a+b >= a*b {
		fmt.Println(a+b)
	} else if a-b >= a+b && a-b >= a*b {
		fmt.Println(a-b)
	} else {
		fmt.Println(a*b)
	}
}


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

bool digit(int nm,int mx,int mn){
    int n = 0;
    while(nm){
        n += nm % 10;
        nm /= 10;
        //if(n > mx || n < mn) return 0;
    }
    if(n > mx || n < mn) return 0;
    return 1;
}

int main(){
    int n,sum = 0,a,b;
    cin >> n >> a >> b;
    for(int i = 1;i <= n;++i){
        if(digit(i,max(a,b),min(a,b))){
            //cout << i << "\n";
            sum += i;
        }
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 998244353;
ll dp[200200];
pair<ll,ll> p[200200];
int main()
{
    int n,i,j,k,x,y,ans,temp,curr,m;
    int tc;
    cin >> n;
    for(i=1;i<=n;i++) cin >> p[i].first >> p[i].second;
    sort(p+1, p+n+1);
    vector< pair<ll,ll> > vi;
    vi.push_back({n+1, 1e18});
    dp[n+1] = 1;
    for(i=n;i>0;i--)
    {
        ll sum = p[i].first + p[i].second;
        while(vi.back().second < sum) vi.pop_back();
        ll idx = vi.back().first;
        dp[i] = dp[idx];
        vi.push_back({i, p[i].first});
        dp[i] = (dp[i] + dp[i+1]) % mod;
    }
    cout << dp[1] << endl;
    return 0;
}


Measured memory_bytes: 7156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

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

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<long, long, greater<long> >::iterator;


//1618

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

	// long long?
	long long N;
	cin >> N;

	vector<ll> vA(N, 0);
	vector<ll> vSum(N, 0);

	rep(i, N) cin >> vA[i];
	vSum[0] = vA[0];
	rep(i, N - 1) {
		vSum[i + 1] = vSum[i] + vA[i+1];
	}

	map<ll, ll> mnum;
	rep(i, N) {
		map<ll, ll>::iterator it = mnum.find(vSum[i]);
		if (it == mnum.end()) {
			mnum.insert(make_pair(vSum[i], 1));
		}
		else {
			it->second++;
		}
	}

	long long ans = 0;
	for (map<ll, ll>::iterator it = mnum.begin(); it != mnum.end(); ++it) {
		if (it->first == 0) {
			ans += (it->second + 1) * it->second / 2;
		}
		else {
			ans += (it->second) * (it->second - 1) / 2;
		}
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 15872
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] h = new int[N];
    for (int i = 0; i < N; i++) {
      h[i] = sc.nextInt();
    }
    long[] cost = new long[N];
    cost[0] = 0;
    cost[1] = Math.abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
      cost[i] = Long.MAX_VALUE;
      for (int j = Math.max(0, i - K); j < i; j++) {
        long tmp = cost[j] + Math.abs(h[i] - h[j]);
        if (tmp < cost[i]) {
          cost[i] = tmp;
        }
      }
    }
    System.out.println(cost[N - 1]);
  }
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll a, b, c;

int main() {
    cin >> a >> b >> c;
    cout << min({a + b, b + c, c + a}) << "\n";
}

Measured memory_bytes: 256
H, W, D = [int(i) for i in input().split()]
px = [0] * 90001
py = [0] * 90001

for i in range(H):
    a = [int(i) for i in input().split()]
    for j, v in enumerate(a):
        px[v] = j
        py[v] = i

d = [0] * 90001
for i in range(D + 1, 90001):
    d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D])

Q = int(input())

for i in range(Q):
    L, R = map(int, input().split())
    ans = d[R] - d[L]
    print(ans)

Measured memory_bytes: 9264
table = [0]+[1]+[10**10 for i in range(10**6)]
six = [6 ** i for i in range(1,8)]
nine = [9 ** i for i in range(1,7)]
for i in range(10**5):
    table[i+1] = min(table[i+1],table[i]+1)
    for x in six:
        table[i + x] = min(table[i + x], table[i]+1 )
    for y in nine:
        table[i+y] = min(table[i+y], table[i]+1)
print(table[int(input())])


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


ll N, ans=0;
ll A[1000];
ll solve(ll i, ll sum){
	sum = (sum + 200) % 2;
	if(i >= N) return (sum % 2 == 0);
	ll ret = 0;
	for(int k=-1; k<=1; k++){
		ret += solve(i+1, sum * (A[i]+k));
	}
	return ret;
}

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

	cin >> N;
	rep(i,N) cin >> A[i];

	ll ans = solve(0, 1);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> da(n);
    for(int i=0;i<n;i++){
        cin >> da[i].second >> da[i].first;
    }
    sort(da.begin(),da.end());
    int ti=0;
    bool ju=true;
    for(int i=0;i<n;i++){
        ti+=da[i].second;
        if(ti>da[i].first){
            ju=false;
            break;
        }
    }
    if(ju){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define vi vector<int>
#define vvi vector<vi>

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ***************************CODE**********************//




int c[10][10];
int H,W,a,ans;


int main(){
        _upgrade;
        int H,W;
        cin >> H >> W;

        rep(i,10) rep(j,10) cin >> c[i][j];

        for(int k = 0; k < 10; k++){
                for(int i = 0; i < 10; i++){
                        for(int j = 0; j < 10; j++){
                                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
                        }
                }
        }

        rep(i,H) rep(j,W) {
                cin >> a;
                if(a >= 0){
                        ans += c[a][1];
                }
        }

        cout << ans << endl;

        return 0;
}




Measured memory_bytes: 256
// AOJ 2403: The Enemy of My Enemy is My Friend
// 2018.1.19 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define HASHSIZ 199
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;			// Hash table

void insert(char *s, int id, int w)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
}

int lookup(char *s, int w)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	return -1;
}

int n, ans;
char name[41][18];
int to[41][41], hi[41], b[41];
char our[41], done[41];
char buf[41][700], *top[41];
char done[41];
long long tbl[41];
int sum[41];

void calc(int k, int power, long long mask)
{
	if (power > ans) ans = power;
	if (k == n) return;
	if (power+sum[k] <= ans) return;
	if (done[k]) calc(k+1, power, mask);
	else {
		if (!((mask >> k) & 1)) calc(k+1, power+ b[k], mask|tbl[k]);
		calc(k+1, power, mask);
	}
}

int main()
{
	int i, j, c;
	char s[10], *p, *q;
	long long mask;

	while (fgets(s, 10, stdin) && *s != '0') {
		n = atoi(s);
		memset(hi, 0, sizeof(hi));
		memset(tbl, 0, sizeof(tbl));
		memset(done, 0, sizeof(done));

		for (i = 0; i < n; i++) {
			fgets(p=buf[i], 700, stdin);
			q = p; while (*p > ' ') p++;
			*p = 0, insert(q, i, p-q);
			top[i] = p+1;
		}
		for (i = 0; i < n; i++) {
			b[i] = atoi(top[i]);
			p = top[i]; while (*p > ' ') p++;
			c = atoi(++p); while (*p > ' ') p++; p++;
			while (c--) {
				q = p; while (*p > ' ') p++;
				*p = 0, j = lookup(q, p-q); p++;
				to[i][hi[i]++] = j;
				tbl[i] |= 1LL << j;
			}
		}
		sum[n] = 0;
		for (i = n-1; i >= 0; i--) sum[i] = sum[i+1] + b[i];

		ans = b[0], mask = tbl[0];
		done[0] = 1; for (i = 0; i < hi[0]; i++) done[to[0][i]] = 1;
		for (i = 1; i < n; i++) if (!hi[i]) done[i] = 1, ans += b[i], mask |= tbl[i];

		calc(1, ans, mask);
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;
	int maxd = -2000000000,minv;
	int tmp;

	cin >> n;
	cin >> minv;
	for(int i=1;i<n;i++){
		cin >> tmp;
		maxd = max(maxd,tmp-minv);
		minv = min(minv,tmp);
	}
	cout << maxd << endl;

	return 0;
}

Measured memory_bytes: 3100
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

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

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long LL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int a, b;
  cin >> a >> b;
  // Scan done.

  // Code begin.
  if (a > 8 || b > 8) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for(int i = 0; i < k; i++) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
s = input()
l = len(s)
lst = [0] * (l+1)

for idx in range(l):
    if s[idx] is '<':
        lst[idx+1] = max(lst[idx+1], lst[idx]+1)

for inv in range(1, l+1):
    if s[-inv] is '>':
        lst[-(inv+1)] = max(lst[-(inv+1)], lst[-inv]+1)


print(sum(lst))

Measured memory_bytes: 29048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
const int mxn = 1e5+5;
int T;
vector<PII> v;
ll dp[105][mxn];

ll fn(int i, int w){

    if(w<0) return -(1<<30);
    if(i==T) return 0;
    if(dp[i][w]!=-1) return dp[i][w];
    return dp[i][w] = max((ll) fn(i+1,w),(ll)fn(i+1,w-v[i].first)+v[i].second );
}


void solve(){
    int i,w;
    cin>>T>>w;
    memset(dp,-1,sizeof(dp));

    for(i=0; i<T; i++){
        int w,val;
        cin>>w>>val;
        v.push_back({w,val});
    }

    cout<<fn(0,w)<<"\n";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 82304
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <cstring>
#include <bitset>
#include <stack>
using namespace std;
#define MP make_pair
#define PB push_back
const int INF=1e9;

int n;
pair<int,int> p[100005];
bool del[100005];
priority_queue <pair<int,int> >q1,q2;
long long ans;

inline long long solve(int dir)
{
	int pos=0;
	memset(del,false,sizeof(del));
	long long res=0;
	while (!q1.empty()) q1.pop();
	while (!q2.empty()) q2.pop();
	for (int i=1;i<=n;i++)
	{
		q1.push(MP(p[i].first,i));
		q2.push(MP(-p[i].second,i));
	}
	while (true)
	{
		if (dir==0)
		{
			while (!q1.empty() && del[q1.top().second]) q1.pop();
			if (q1.empty()) break;
			int nxt=q1.top().second;
			if (p[nxt].first<=pos) break;
			del[nxt]=true;
			res+=(long long)(p[nxt].first-pos);
			pos=p[nxt].first;
		}
		else
		{
			while (!q2.empty() && del[q2.top().second]) q2.pop();
			if (q2.empty()) break;
			int nxt=q2.top().second;
			if (p[nxt].second>=pos) break;
			del[nxt]=true;
			res+=(long long)(pos-p[nxt].second);
			pos=p[nxt].second;
		}		
		dir=!dir;
	}
	return res+(long long)abs(pos);
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		p[i]=MP(x,y);
	}
	ans=solve(0);
	ans=max(ans,solve(1));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2932
odd = input()
even =input()
odd_list = []
even_list = []

for i in odd:
    odd_list.append(i)
for j in even:
    even_list.append(j)
even_list.append("")

for i in range(len(odd_list)):
    print(odd_list[i],end = "")
    print(even_list[i],end = "")


Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int ans,n,a,b;
string s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>a>>b;
	if((n*a)<b) cout<<n*a<<endl; else cout<<b<<endl;

	return 0;
}


Measured memory_bytes: 256
import math

n, k = map(int, input().split())
prob = 0
for i in range(1,n+1):
    if i <= k-1:
        x = math.floor(1+math.log2(((k-1)/i)))
       
        prob += (1/2)**x
    else:
        prob += 1
print(prob/n)

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

//////////////////////////////////////////////
int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n; cout << (n+1)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;

using Graph = vector<vector<int>>;
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    bitset<3> ans;
    for(int i=0; i<(1<<3); ++i) {
        bitset<3> bit(i);
        int sum = s[0]-'0';
        for(int j=0; j<3; ++j) {
            if (bit.test(j)) {
                sum -= s[j+1]-'0';
            } else {
                sum += s[j+1]-'0';
            }
        }
        if (sum==7) {
            ans = bit;
            break;
        }
    }
    for(int i=0; i<4; ++i) {
        cout << s[i]-'0';
        if (i==3) break;
        if (ans.test(i)) {
            cout << "-";
        } else {
            cout << "+";
        }
    }
    cout << "=7" << "\n";
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <stack>
typedef long long ll;

using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    
    vector<vector<int>> v = vector<vector<int>>(n, vector<int>(d));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            cin >> v[i][j];
        }
    }
    
    int check[1000] = {0};
    for(int i = 1; i < 1000; i++) {
        check[i] = i * i;
    }
    
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int k = i + 1; k < n; k++) {
            int sum = 0;
            for(int j = 0; j < d; j++) {
                sum += (v[i][j] - v[k][j]) * (v[i][j] - v[k][j]);
            }
            for(int j = 0; j < 1000; j++) {
                if(check[j] == sum) {
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <tuple>

using namespace std;

int main()
{
	int N;
	array<int, 1010> a;

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

	decltype(a.begin()) mn, mx;
	tie(mn, mx) = minmax_element(a.begin(), a.begin() + N);
	cout << (*mx - *mn) << endl;
}


Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
@a = sort { $b <=> $a } @a;

my $ans = 0;
for (my $i=1; $i<$n*2; $i+=2) {
  $ans += $a[$i];
}
say $ans;

Measured memory_bytes: 54436
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline long long in(){long long x=0;char c=getchar();bool neg=false;while(c!='-'&&('0'>c||c>'9')) c=getchar();if(c=='-') neg=true,c=getchar();while('0'<=c&&c<='9') x=10*x+c-'0',c=getchar();if(neg) x=-x;return x;}
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "Z"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define _ putchar(' ')
#define __ putchar('\n')
const int N=200010;
int n,c,top,h,f;
ii st[N];
double I[N];
double G(ii u,ii v){return 1.0*(v.se-u.se)/(u.fi-v.fi);}
main()
{
    fasty;
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin>>n>>c;
    cin>>h;
    st[++top]={-2*h,h*h+c};
    forinc(i,2,n)
    {
        /// hi^2 + hj^2 -2*hi*hj + C
        cin>>h;
        int l=1,m,r=top,o;
        while(l<=r)
        {
            m=(l+r)/2;
            if(I[m]<=h) o=m,l=m+1;
            else r=m-1;
        }
        f=h*h + st[o].fi*h + st[o].se;
        ii T={-2*h,f+h*h+c};
        while(top>=2 && G(st[top],st[top-1])>=G(st[top],T)) top--;
        st[++top]=T;
        I[top]=G(st[top],st[top-1]);
    }
    cout<<f;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;

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

	int H = 1;
	while (1) {
	
		if (H > (X - Z) / (Y + Z)) {
			break;
		}
		H++;
	}

	cout << H-1 << endl;
	
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, c, k; cin >> n >> c >> k;

	vl t(n);
	FOR(i,0,n) cin >> t[i];
	sort(all(t));
	
	ll res = 0;
	FOR(i,0,n) {
		res++;
		ll j = i;
		while (j < i+c && t[j] <= t[i]+k) j++;
		i = j-1;
	}
	cout << res << endl;

}



Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;

#define int long long

int x;

signed main(void){
	scanf("%lld",&x);
	for(int i=1;i<=1000;i++){
		int num1=i*i*i*i*i;
		int num2=num1-x;
//		printf("%d %d %d\n",i,num1,num2);
		if(num2>0){
			for(int j=0;j*j*j*j*j<=num2;j++)
			if(num2==j*j*j*j*j){
				printf("%lld %lld\n",i,j);
				return 0;
			}
		}
		else{
			for(int j=0;j*j*j*j*j>=num2;j--)
			if(num2==j*j*j*j*j){
				printf("%lld %lld\n",i,j);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V, E, F;

struct Edge {
	int from, to, cap, flow, cost;
	Edge(int u, int v, int c, int f, int w) :from(u), to(v), cap(c), flow(f), cost(w) {}
};

struct Graph {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];
	int inq[NUM];
	int d[NUM];
	int a[NUM];
	int p[NUM];

	void init(int n) {
		this->n = n;
		for (int i = 0; i < n; i++)
			G[i].clear();
		edges.clear();
	}

	void AddEdge(int from, int to, int cap, int cost) {
		edges.push_back(Edge(from, to, cap, 0, cost));
		edges.push_back(Edge(to, from, 0, 0, -cost));
		m = edges.size();
		G[from].push_back(m - 2);
		G[to].push_back(m - 1);
	}

	bool BellmanFord(int s, int t, int& flow, ll& cost) {
		for (int i = 0; i < n; i++)
			d[i] = INF;
		memset(inq, 0, sizeof(inq));
		d[s] = 0;
		inq[s] = 1;
		p[s] = 0;
		a[s] = INF;

		queue<int> Q;
		Q.push(s);
		while (!Q.empty()) {
			int u = Q.front();
			Q.pop();
			inq[u] = 0;
			for (int i = 0; i < G[u].size(); i++) {
				Edge& e = edges[G[u][i]];
				if (e.cap > e.flow && d[e.to] > d[u] + e.cost) {
					d[e.to] = d[u] + e.cost;
					p[e.to] = G[u][i];
					a[e.to] = min(a[u], e.cap - e.flow);
					if (!inq[e.to]) {
						Q.push(e.to);
						inq[e.to] = 1;
					}
				}
			}
		}
		if (d[t] == INF)
			return false;
		flow += a[t];
		if (a[t] <= F) {
			cost += (ll)d[t] * (ll)a[t];
			F -= a[t];
		}
		else {
			cost += (ll)d[t] * (ll)(F);
			F = 0;
		}
		for (int u = t; u != s; u = edges[p[u]].from) {
			edges[p[u]].flow += a[t];
			edges[p[u] ^ 1].flow -= a[t];
		}
		return true;
	}
	
	int MincostMaxflow(int s, int t, ll& cost) {
		int flow = 0;
		cost = 0;
		while (BellmanFord(s, t, flow, cost));
		return flow;
	}
};

Graph solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	ll COST;
	int u, v, c, d, f;
	cin >> V >> E >> F;
	f = F;
	solve.init(V);
	for (int i = 0; i < E; i++) {
		scanf("%d%d%d%d", &u, &v, &c, &d);
		solve.AddEdge(u, v, c, d);
	}
	if (solve.MincostMaxflow(0, V - 1, COST) >= f)
		cout << COST << endl;
	else
		cout << "-1" << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 6064
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 998244353;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int first = in.nextInt();
        int[] d = in.nextIntArray(n-1);

        int[] lengthCounts = new int[n];
        for (int dd : d) {
            lengthCounts[dd]++;
        }

        if (first != 0 || lengthCounts[0] != 0) {
            out.println(0);
            return;
        }

        long ans = 1;
        long prev = 1;
        boolean noNext = false;
        for (int i = 1; i < lengthCounts.length; i++) {
            if (lengthCounts[i] == 0) {
                noNext = true;
                continue;
            } else if (lengthCounts[i] > 0 && noNext) {
                ans = 0;
                break;
            }

            for (int j = 0; j < lengthCounts[i]; j++) {
                ans = (ans * prev) % MOD;
            }
            prev = lengthCounts[i];
        }

        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 35736
n,l = map(int,input().split())
li = []
for i in range(n):
    li.append(l+i)
if min(li) >= 0:
    print(sum(li)-li[0])
elif max(li) <= 0:
    print(sum(li)-li[n-1])
else:
    print(sum(li))

Measured memory_bytes: 3060
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val p = List.fill(n)(sc.nextInt)

  val ans = p.foldLeft((0, (None, None, None)): (Int, (Option[Int], Option[Int], Option[Int])))((acc, v) => {
      val current = (acc._2._2, acc._2._3, Some(v))
      current match {
        case (Some(v1), Some(v2), Some(v3)) =>
          if ((v1 < v2 && v2 < v3) || (v3 < v2 && v2 < v1)) (acc._1 + 1, current)
          else (acc._1, current)
        case _ =>
          (0, current)
      }
    }
  )._1

  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)
}

Measured memory_bytes: 25780
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    // Here your code !
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed
         << setprecision(5)
         << sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

Measured memory_bytes: 3268
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let v = get!([i64]);
    let mut dp = vec![0; n + 10];
    dp[1] = (v[0] - v[1]).abs();
    for i in 2..n {
        dp[i] = std::cmp::min(
            dp[i - 1] + (v[i - 1] - v[i]).abs(),
            dp[i - 2] + (v[i - 2] - v[i]).abs(),
        );
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 6396
#include <iostream>

using namespace std;

int main(){

    long long N;
    cin >> N;

    long long h, n, w;

    for (long long i = 1; i <= 3500; i++){
        for(long long j = i; j <= 3500; j++){
            long long a = i * j * N;
            long long b = 4 * i * j - N * i - N * j;
            if (b > 0 && a % b == 0){
                h = i;
                n = j;
                w = a / b;
                break;
            }
        }
    }
    
    cout << h << " " << n << " " << w << endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f

int main()
{
    char s[110];
    while(~scanf("%s",s))
    {
        int l=strlen(s);
        for(int i=1;i<=l;i++)
            printf("x");
        printf("\n");
    }
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $k, $x);
$start = $x - $k + 1;
$end = $x + $k - 1;
$ans = '';
for($start; $start <= $end; $start++) {
    $ans .= ' '. $start;
}
echo trim($ans), PHP_EOL;

Measured memory_bytes: 4604
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int N,Q;
int c[300001];
int q[100001];
int main(){

  cin>>N>>Q;
  for(int i=0;i<N;i++)cin>>c[i];
  for(int i=0;i<Q;i++)cin>>q[i];
  //sort(q,q+Q);
  sort(c,c+N);
  for(int i=0;i<Q;i++){
    int res=0;
    for(int j=q[i];j<=300000;j+=q[i]){
      int pos=lower_bound(c,c+N,j)-c-1;
      if(pos>=0){
        res=max(res,c[pos]%q[i]);
      }
    }
    cout<<res<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 2740
//ABC108C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	int x = 0, y = 0;
	long long int ans;
	if(k%2 == 1){
		for(int i=1;i<=n;i++){
			if(i%k == 0){
				x++;
			}
		}
		ans = pow(x,3);
	}else{
		for(int i=1;i<=n;i++){
			if(i%k == 0){
				x++;
			}else if(i%k == k/2){
				y++;
			}
		}
		ans = pow(x,3) + pow(y,3);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import bisect
import sys
def input(): return sys.stdin.readline().strip()


N, C, K = map(int, input().split())
T = sorted([int(input()) for i in range(N)])

TT = [i + K for i in T]

cnt = 0
i = 0
temp = -1  # temp番まで運び終わった
while True:
    i = bisect.bisect_right(T, TT[i])
    if i - temp > C:
        i = temp + C + 1
        temp += C
    cnt += 1
    temp = i - 1
    if i >= N:
        break
print(cnt)

Measured memory_bytes: 50524
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>


int main() {
    std::string S;
    std::cin >> S;
    std::vector<char> stack;
    for (auto&& c: S) {
        if (!stack.empty()) {
            auto last = *(stack.end() - 1);
            if (last != c) {
                stack.pop_back();
                continue;
            }
        }
        stack.push_back(c);
    }
    std::cout << S.size() - stack.size() << "\n";
    return 0;
}


Measured memory_bytes: 640