akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem100c(n, a))
}

fun problem100c(n: Int, a: List<Int>): Int {
    /**
     * 何回割り切れるか
     */
    fun log(num: Long, base: Long): Long {
        var count = 0L
        var tmp = num
        while (tmp % 2 == 0L) {
            tmp /= 2
            count++
        }
        return count
    }
    val array = IntArray(n) { -1 }
    for (i in 0 until n) {
        array[i] = log(a[i].toLong(), 2L).toInt()
    }
    return array.sum()
}

Measured memory_bytes: 46040
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
vector<int> a[100010];
int dp[100010];
int dfs(int u){
    //cout<<u<<" "<<a[u].size()<<endl;
    if(dp[u])return dp[u];
    dp[u]=1;
    for(int i=0;i<a[u].size();i++)
            dp[u]=max(dp[u],dfs(a[u][i])+1);
    return dp[u];
}
void solve(){
    int u,v,n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        a[u].push_back(v);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!dp[i])dfs(i);
        //cout<<dp[i]<<" ";
        ans=max(ans,dp[i]-1);
    }
    cout<<ans;
}
main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);cout.tie(0);

    //freopen("FORMMAU.inp","r",stdin);
    //freopen("FORMMAU.out","w",stdout);

    //srand(time(0));

    //cout << setprecision(6) <<fixed;

    //int t;cin>>t;while(t--)
    solve();
}


Measured memory_bytes: 8192
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

dp = [(0, 0)] * (n+1)
ma = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

for i in range(n):
    if i!=0 and dp[i] == (0, 0):
        continue
    for j in a:
        t = dp[i]
        k = i + ma[j]
        if k <= n:
            dp[k] = max(dp[k], (t[0] + j * 10 ** t[1], t[1] + 1))
            dp[k] = max(dp[k], (t[0]*10 + j, t[1] + 1))

print(dp[-1][0])


Measured memory_bytes: 54568
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
typedef short int si;
typedef long long int ll;
typedef long int li;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<li,li> pli;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define linf LONG_MAX 
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mkp make_pair
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define endl '\n'
const ll N=11;
ll mod=1e9+7;
signed main()
{
    fast;
    ll pro=1,temp,n,m,k,t,i,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=0,i1=-1,i2=-1;
    cin>>n;
    ll a[n];
    multiset<ll> ms;
    multiset<ll>::iterator it;
    rep(i,0,n-1)
    {
        cin>>a[i];
        it=ms.lb(a[i]);
        if(it==ms.begin())
        {
            ms.insert(a[i]);
        }
        else
        {
            ms.erase(--it);
            ms.insert(a[i]);
        }
    }
    cout<<ms.size();
    return 0;
} 
 

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
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; }

int main(){
int N,M;
cin>>N>>M;
vector<ll>A(N),B(M),C(M);
vector<P> Q;
for(int s=0;s<N;s++){
        cin>>A.at(s);
}
for(int t=0;t<M;t++){
        cin>>B.at(t)>>C.at(t);
        Q.push_back(P(C.at(t),B.at(t)));
}
sort(Q.begin(),Q.end());
reverse(Q.begin(),Q.end());
sort(A.begin(),A.end());
ll sum=0,S=0,T=0;
int j=0;
for(int i=0;i<M;i++){
      S=Q.at(i).second;
      T=Q.at(i).first;
      if(j>=N || A.at(j)>T) break;
      while(S>0){
          if(j<N && A.at(j)<T){
              A.at(j)=T;
              S--;
          }
          else break;
          j++;
      }
}
for(int k=0;k<N;k++){
    sum+=A.at(k);
}
cout<<sum<<endl;
return 0;
}


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

int main() {

    int N;
    string S;
    cin >> N >> S;

    int cnt = 0;

    rep(i, N-2) {
        if (S.substr(i, 3) == "ABC") cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3604
def v():
 for e in iter(input,'0 0'):
  r=int(e.split()[0])
  d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
  a=0
  for m in range(1<<~-r):
   t=0
   for s in d:
    c=bin(m^s).count('1')
    t+=c if c>r/2 else r-c
   if a<t:a=t
  print(a)
if'__main__'==__name__:v()


Measured memory_bytes: 6920
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
   string s; cin >> s;
   if(s[1] == 'B') s[1] = 'R';
   else s[1] = 'B';
   cout << s << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


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

int main(){  
    ll N, M;  cin >> N >> M;
    vector<ll> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    sort(A.begin(), A.end());

    ll lo = 0, hi = 1e9;
    while(hi - lo > 1){
        ll mid = (hi + lo)/2;
        ll cnt = 0;
        for(int i=0; i<N; i++){
            cnt += A.end() - lower_bound(A.begin(), A.end(), mid - A[i]);
        }
        if(cnt >= M)
            lo = mid;
        else
            hi = mid;
    }

    ll thres = lo;
    ll remain = M;
    vector<ll> sum(N+1, 0);
    for(int i=1; i<=N; i++)
        sum[i] += sum[i-1] + A[i-1];
    
    ll ans = 0;
    for(int i=0; i<N; i++){
        ll lower = upper_bound(A.begin(), A.end(), thres - A[i]) - A.begin();
        remain -= N - lower;
        ans += A[i]*(N-lower) + sum[N] - sum[lower];
    }
    cout << ans + thres*remain << endl;
}

Measured memory_bytes: 1792
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
s = input()

from bisect import bisect_left as bl
b = []
r = []
g = []
gg = 0
rr = 0
bb = 0
for i in range(n):

    if s[i] == "G":
        gg += 1
    elif s[i] == "B":
        bb += 1
    else:
        rr += 1
    
    r.append(rr)
    b.append(bb)
    g.append(gg)

brg = [b,r,g]
ans = 0
for i in range(1,n-1):
    if s[i] == "B":
        ima1 = 1
        ima2 = 2
    elif s[i] == "R":
        ima1 = 0
        ima2 = 2
    else:
        ima1 = 0
        ima2 = 1
    ans += brg[ima1][i-1]*(brg[ima2][n-1]- brg[ima2][i])
    ans += brg[ima2][i-1]*(brg[ima1][n-1]- brg[ima1][i])
for i in range(1,n-1):
    for k in range(i):
        tmp = i-k
        if i + tmp > n-1:
            continue
        if s[k] == s[i]:
            continue
        if s[i] == s[i+tmp]:
            continue
        if s[k] == s[i+tmp]:
            continue
        ans -= 1

print(ans)
        

        

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define rjm	rep(j,m)


#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}


#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define INF bit(60)

int main(int argc, char *argv[]) {
	string s;
	li k;
	cin >> s >> k;
	li n = sz(s);
	rep(i, n - 1) {
		if (s[i] == 'a')continue;
		li needed = 'z' - s[i] + 1;
		if (needed <= k) {
			k -= needed;
			s[i] = 'a';
		}
	}
	li last = s[n - 1] - 'a';
	last = (last + k) % 26;
	s[n - 1] = last + 'a';
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	basicIO "io"
	"os"
	"sort"
	"strconv"
)

func main() {
	protagonist(os.Stdin, os.Stdout)
}

type BC []struct {
	B int
	C int
}

func (bc BC) Len() int { return len(bc) }
func (bc BC) Swap(i, j int) {
	bc[i], bc[j] = bc[j], bc[i]
}
func (bc BC) Less(i, j int) bool { return bc[i].C > bc[j].C }

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	N := io.nextInt()
	M := io.nextInt()
	A := make([]int, N)
	bc := make(BC, M)

	for i := 0; i < N; i++ {
		A[i] = io.nextInt()
	}
	sort.Ints(A)

	for i := 0; i < M; i++ {
		bc[i].B = io.nextInt()
		bc[i].C = io.nextInt()
	}
	sort.Sort(bc)

	ap := 0

	for n := 0; n < M; n++ {
		for i := 0; i < bc[n].B; i++ {
			if ap >= N || A[ap] > bc[n].C {
				goto end
			}
			A[ap] = bc[n].C
			ap++
		}
	}
end:

	sol := 0
	for i := 0; i < N; i++ {
		sol += A[i]
	}

	io.PutInt(sol)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() int {
	io.Scanner.Scan()
	i, _ := strconv.Atoi(io.Scanner.Text())
	return i
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 4992
N,X,Y = map(int,input().split())
ans = [0]*(N-1)
for i in range(1,N+1):
  for j in range(i+1,N+1):
    ans[min(j-i,abs(X-i)+1+abs(Y-j))-1] += 1
for i in ans:
  print(i)

Measured memory_bytes: 9304
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

cnt = [0] * (n)
for i in range(0, n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        cnt[i + 1] = cnt[i] + 1
    else:
        cnt[i + 1] = cnt[i]

for i in range(q):
    ll = lr[i][0] - 1
    rr = lr[i][1] - 1
    print(cnt[rr] - cnt[ll])


Measured memory_bytes: 29872
h, n = map(int, input().split())
magics = sorted(list(map(int, input().split())) for _ in range(n))
max_cost = max(magic[1] for magic in magics)

dp = [float('inf')] * (h+max_cost)
dp[0] = 0
for i in range(h+max_cost):
    for at, cost in magics:
        if at <= i:
            dp[i] = min(dp[i], dp[i-at] + cost)
        else:
            break
print(min(dp[h:]))



Measured memory_bytes: 43484
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <cstring>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;
const int INF=100000000;

int A[110][110],d[100];

int main(){
    int n,u,k,v;
    cin>>n;
    LP(i,n){
        cin>>u>>k;
        LP(j,k){
            cin>>v;
            A[u-1][v-1]=1;
        }
    }
    queue<int> q;
    q.push(0);
    LP(i,n) d[i]=INF;
    d[0]=0;
    int x=0;
    while(!q.empty()){
        x=q.front();
        q.pop();
        LP(i,n){
            if(A[x][i]==0) continue;
            if(d[i]!=INF) continue;
            d[i]=d[x]+1;
            q.push(i);
        }
    }
    LP(i,n){
        cout<<i+1<<" "<<((d[i]==INF)?(-1):d[i])<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>

 int main(void){

    int a,b,c,t;

    scanf("%d %d %d",&a,&b,&c);

    if(a>b){ 
    t=a; 
    a=b;
    b=t;
    }

    if(b>c){
    t=b; 
    b=c; 
    c=t; }

    if(a>b){ 
    t=a; 
    a=b; 
    b=t; }

    printf("%d %d %d\n",a,b,c); 

   return 0; 

}  


Measured memory_bytes: 2048
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	cout << pow(n, 2) - a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const int INF = int(1e9);
const int MAX = 100;

string s;

int main()
{
    cin>>s;
    int t = s.size();
    int l = 0,r = t-1;
    int sum = 0;
    int flag = 1;
    while(l<r)
    {
        if(s[l]==s[r])
            l+=1,r-=1;
        else if(s[l]!=s[r]&&s[l]!='x'&&s[r]!='x')
        {
            flag = 0;
            break;
        }
        else
        {
            if(s[l]=='x'){
                sum++;
                l++;
            }
            else{
                sum++;
                r--;
            }
        }
    }
    if(flag==1)
        cout<<sum<<endl;
    else
        cout<<-1<<endl;


    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	ll h,w; cin >> h >> w;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}

	vector<vector<int>> ans(h, vector<int>(w,-1));
	rep(i, h) rep(j,w) {
	  if (s[i][j] == '#') continue;
	  int cnt = 0;
		if (i - 1 >= 0) {
			if (j-1 >= 0) cnt += s[i-1][j-1] == '#';
			cnt += s[i-1][j] == '#';
			if (j+1 < w) cnt += s[i-1][j+1] == '#';
		}
		if (j - 1 >= 0) cnt += s[i][j - 1] == '#';
		if (j + 1 < w) cnt += s[i][j + 1] == '#';
		if (i + 1 < h) {
			if (j - 1 >= 0) cnt += s[i + 1][j - 1] == '#';
			cnt += s[i + 1][j] == '#';
			if (j + 1 < w) cnt += s[i + 1][j + 1] == '#';
		}

		ans[i][j] = cnt;
	}

	rep(i, h) { rep(j, w) {
		if (ans[i][j] < 0) cout << '#';
		else cout << ans[i][j];
	}
	cout << endl;
	}
}

Measured memory_bytes: 256
//package atcoder.dpContest;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(1, in, out);

//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for(int qq = 0; qq < q; qq++) {
            int n = in.nextInt(), k = in.nextInt();
            int[] h = new int[n];
            for(int i = 0; i < n; i++) {
                h[i] = in.nextInt();
            }
            int[] dp = new int[n];
            dp[0] = 0;
//            dp[1] = Math.abs(h[1] - h[0]);
//            for(int i = 2; i < n; i++) {
//                dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
//            }
            for(int i = 1; i < n; i++) {
                dp[i] = Integer.MAX_VALUE;
                for(int j = 1; j <= Math.min(i, k); j++) {
                    dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
                }
            }
            out.println(dp[n - 1]);
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                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;
        }
    }
}




Measured memory_bytes: 34972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int a[maxn];
int cnt[maxn];

 int getSum(int n) 
    {  
    int sum = 0; 
    while (n != 0) 
    { 
     sum = sum + n % 10; 
     n = n/10; 
    }  
 return sum; 
 }

int countDigit(long long n) 
{ 
    int count = 0; 
    while (n != 0) { 
        n = n / 10; 
        ++count; 
    } 
    return count; 
} 

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int a,b;
	cin >> a >> b;
	cout << 6 - a -b << "\n";
}




/*void solve(){
        int n,m,x,y;
        cin>>n>>m>>x>>y;
        cout<<x<<" "<<y<<"\n";
        for(int i=1;i<=n;i++){
            if(i!=x)
                cout<<i<<" "<<y<<"\n";
        }
        int dir=0;
        for(int i=1;i<=m;i++){
            if(i==y)
                continue;
            if(dir==0){
                cout<<n<<" "<<i<<"\n";
                for(int j=n-1;j>=1;j--)
                    cout<<j<<" "<<i<<"\n";
                dir=1;
            }
            else{
                cout<<1<<" "<<i<<"\n";
                for(int j=2;j<=n;j++)
                    cout<<j<<" "<<i<<"\n";
                dir=0;
            }
        }
    }
    */

Measured memory_bytes: 3584
import java.io.*;
import java.util.*;

class Main {

    // Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        double[] p = new double[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                p[i] = sc.nextDouble();
        }
        solve(N, p);
    }

    static void solve(long N, double[] p){
        double[][] dp = new double[(int)(N+1)][(int)(N+1)];
        dp[1][1] = p[0];
        dp[1][0] = 1 - p[0];

        for (int i = 2; i <= N; i++){
            for (int j = 0; j <= i; j++){
                if (j == 0){
                    dp[i][j] = dp[i-1][j] * (1 - p[i-1]);
                }else{
                    dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1 - p[i-1]);
                }
            }
        }

        double rst = 0;
        for (int i = (int)(N / 2 + 1); i <= N; i++){
            rst += dp[(int)N][i];
        }
        System.out.print(rst);

    }
}


Measured memory_bytes: 125048
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define LL long long
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
struct UnionFind{
public:
    vector<int> par;
    vector<int> rank;
    vector<int> s;
    int cnt;
 
    UnionFind(int n){
        rep(i,n){
            par.push_back(i);
            rank.push_back(0);
            s.push_back(1);
        }
        cnt=n;
    }
 
    int find(int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    }
 
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            s[y]+=s[x];
        }else{
            par[y]=x;
            s[x]+=s[y];
            if(rank[x]==rank[y]) rank[x]++;
        }
        cnt--;
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }

    int size(int x){
        return s[find(x)];
    }
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        uf.unite(a,b);
    }
    ll ans=0;
    rep(i,n){
        chmax(ans,ll(uf.size(i)));
    }
    cout<<ans<<endl;
}

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

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

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

    ll K; cin >> K;
    string S; cin >> S;

    for (int i = 0;i < K && i < S.size();i++){
        cout << S[i];
        if(i == K-1 && i != S.size()-1) cout << "...";
    }

    cout << endl;

    return 0;

}

Measured memory_bytes: 3612
S, T = input(), input()

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    if len(S[i:i + len(T)]) == len(T):
        same = True
        for j, s in enumerate(S[i:i + len(T)]):
            if not (s == T[j] or s == '?'):
                same = False
        if same:
            rep = (S[:i] + T + S[i + len(T):]).replace('?', 'a')
            ans = rep if ans == "UNRESTORABLE" else min(ans, rep)

print(ans)


Measured memory_bytes: 3064
//0072
//vñFÅ¬SæØ
//QlFhttp://www.deqnotes.net/acmicpc/prim/

#include<stdio.h>
#include<vector>
#include<queue>
#include<utility>
#include<functional>
using namespace std;


int main(void)
{
	int n, m;
	const int N = 100;
	const int INVALID_VALUE = -1;
	int cost[N][N];

	while(scanf("%d", &n), n)
	{
		scanf("%d", &m);
		int a, b, d;
		int i, j;
		//¢Á½ñ·×ÄÌ¹Ìèðú»·é
		//©ª©gÖÌ¹ÌèÍ0¾¯ÇA¡ñÍl¶·éKvÍ³¢H
		for(i = 0; i < N; ++i)
			for(j = 0; j < N; ++j)
				cost[i][j] = INVALID_VALUE;
		for(i = 0; i < m; ++i)
		{
			scanf("%d,%d,%d", &a, &b, &d);
			cost[a][b] = cost[b][a] = d;
		}

		typedef pair<int, int> P;	//<distance, toIndex>@£Å\[g·é½ßOÉ
		//¸ÉDæxÂ«ÌL[
		//½ÅftHgÍ~ÈÌæ
		priority_queue<P, vector<P>, greater<P> > q;	//>>¾ÆAOJÉG[Hç¢Üµ½BÆ¢¤©AÊÍG[Hç¤àÌ¶áH
		//»Ì¸_ÍÚ±³êÄ¢Ü·©H
		bool isConnected[N] = {false};

		int totalDistance = 0;	//Å¬ØÌ£

		//Æè ¦¸ê0©çnßæ¤
		q.push(P(0, 0));	//make_pairÅâÁ½çB¾Æ¢íê½B0Ì¹¢H
		while(!q.empty())
		{
			P p = q.top();
			q.pop();
			//·ÅÉÂÈªÁÄ¢é¸_¾Á½ç½àµÈ¢
			if(isConnected[p.second])
				continue;
			//»ÌÓðÚ±µÜ·
			isConnected[p.second] = true;
			totalDistance += p.first;
			//ÌÓðÚ±µÜ·
			for(i = 0; i < N; ++i)
			{
				if(cost[p.second][i] != INVALID_VALUE)	//»ÌæÖÌ¹Í¶ÝµÜ·©
					q.push( P(cost[p.second][i], i) );	//±±Ímake_pair()ÅàG[ÉÈçÈ¢¯êÇ
			}
		}

		//UÌÂÍAijÕÌÓ|1jÂ­È­A»µÄ100m¨«ÉÉu©êÄ¢é
		printf("%d\n", (totalDistance/100)-(n-1));
	}
	return 0;
}

Measured memory_bytes: 0
n,k=[int(x) for x in input().split()]
l=set([x for x in range(1,n+1)])
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for i in range(len(a)):
        l.discard(a[i])
print(len(list(l)))

Measured memory_bytes: 9196
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

vector<string>vec;
ll rec(vector<string>vec){
    if('0' <= vec[0][0] && vec[0][0] <= '9') return vec[0][0]-'0';
    bool type = (vec[0][0] == '+');
    vector<ll>vecv;
    for(int i=1;i<vec.size();i++){
        string s = vec[i];
        reverse(s.begin(),s.end());
        s.pop_back();
        reverse(s.begin(),s.end());
        if('0'<=s[0] && s[0] <= '9'){
            vecv.pb(s[0]-'0');
        }
        else{
            vector<string>V; V.pb(s);
            i++;
            while(i<vec.size()){
                string s = vec[i];
                reverse(s.begin(),s.end());
                s.pop_back();
                reverse(s.begin(),s.end());
                if(s[0] == '.') V.pb(s);
                else{
                    vecv.pb(rec(V));
                    i--; goto nxt;
                }
                i++;
            }
            vecv.pb(rec(V)); nxt:;
        }
    }
    if(type){
        ll ans = 0; rep(i,vecv.size()) ans += vecv[i]; return ans;
    }
    else{
        ll ans = 1; rep(i,vecv.size()) ans *= vecv[i]; return ans;
    }
}
int main(){
    while(1)
    {
        int n; cin>>n; if(n == 0) return 0;
        vec.clear();
        rep(i,n){
            string x; cin >> x; vec.pb(x);
        }
        ll val = rec(vec); cout << val << endl;
    }
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define maxn 20000010
long long a[maxn];
int n;
void maxheap(int i)
{
    int l,r,largest;
    l=2*i;
    r=2*i+1;
    if (l<=n&&a[l]>a[i]) largest=l;
    else largest=i;
    if (r<=n&&a[r]>a[largest]) largest=r;
    if (largest!=i)
    {
        swap(a[i],a[largest]);
        maxheap(largest);
    }
}
int main()
{
    cin >> n;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for (int i=n/2+1;i>0;i--)
    {
        maxheap(i);
    }
    for (int i=1;i<=n;i++)
    {
        cout << " " << a[i] ;
    }
    cout << endl;
    return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  string temps;
  
  for (int j = 0; j <= W + 1; j++) {
    cout << '#';
  }
  cout << endl;
  
  for (int i = 1; i <= H; i++) {
    cin >> temps;
    cout << "#" + temps + "#" << endl;
  }
  
  for (int j = 0; j <= W + 1; j++) {
    cout << '#';
  }
  cout << endl;
}

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

int main(){
    ll n, cnt = 0, m = 1<<18, ans = 0;
    cin >> n;
    rep(i, n){
        ll tmp = 0;
        cin >> tmp;
        if (tmp < 0) cnt ++;
        ans += abs(tmp);
        m = min(abs(tmp), m);
    }
    if (cnt % 2 == 0) cout << ans << endl;
    else cout << ans - 2 * m << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 n;
  while(cin >> n, n) {
    vector<i64> a(n);
    rep(i,0,n) cin >> a[i];
    i64 sum = 0;
    rep(i,0,n) sum += a[i];
    sum /= n;
    i64 ans = 0;
    rep(i,0,n) ans += !!(a[i] <= sum);
    cout << ans << endl;
  }
}



Measured memory_bytes: 3096
n,m,x = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(n)]
p = 12*(10**5)+1
for i in range(2**n):
    di= [0]*(m+1)
    for j in range(n):
        if (i>>j)&1:
            for k in range(m+1):
                di[k] += ls[j][k]
    for l in range(1,m+1):
        if di[l] < x:
            break
    else:
        if p > di[0]:
            p = di[0]
if p <= 12*(10**5):
    print(p)
else:
    print(-1)

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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  for(int i=a;i<=b;i++){
    int tmp_i = i;
    if(((tmp_i-tmp_i/10000)%10)!=0)continue;
    else{
      tmp_i -= (tmp_i/10000)*10000;
      tmp_i /= 10;
      if(((tmp_i-tmp_i/100)%10)!=0)continue;
	  else{
      	ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
h,n=map(int,input().split())
a=[]
b=[]
for i in range(n):
  A,B=map(int,input().split())
  a.append(A)
  b.append(B)
M=[]
M.append(0)
for i in range(h):
  M.append(10000000000000)
for i in range(0,h+1):
  for j in range(n):
    c=min(h,a[j]+i)
    if M[c]>M[i]+b[j]:
      M[c]=M[i]+b[j]
print(M[h])


Measured memory_bytes: 41820
import collections
N=list(map(int, input()))
c = collections.Counter(N)
if len(set(N)) >= 3:
  print('No')
elif len(set(N)) == 1:
    print('Yes')
else: 
  idx=N.index(c.most_common()[1][0])
  if idx==1 or idx==2:
    print('No')
  else:
    print('Yes')
    

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main()
{
     int a, b;
     cin >> a >> b;
     if(a > b)
         cout << "a > b" << endl;
     else if (a < b)
         cout << "a < b" << endl;
     else
         cout << "a == b" << endl;
         
}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main() {
  int N; cin >> N;
  int ans = 0;
  for (int i = 1; i < N; i++) {
    int num = N - i;
    int tmp = 0;
    int j = 1;
    while (j * j < num) {
      if (num % j == 0) tmp++;
      j++;
    }
    tmp *= 2;
    if (j * j == num) tmp++;
    ans += tmp;
  }
  cout << ans << endl;
}

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

#define llint long long int

using namespace std;

int main(){
    llint a, b, c;

    cin >> a >> b >> c;

    if(c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  for(int i = a; i <= b; ++i){
  	if(i % k == 0){
  		cout << "OK" << endl;
  		return 0;
  	}
  }

  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
A = tuple(map(int, input().split()))
A = sorted(A, reverse=True)
from collections import Counter
CA = Counter(A)

b = 0
for a in A:
    if CA[a] >= 2:
        CA[a] -= 2
        b = a
        break

c = 0
for a in A:
    if CA[a] >=2:
        c = a
        break
print(b*c)


Measured memory_bytes: 21880
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    int changes = 10000;
    getline(cin, s);
    getline(cin, t);
    int count = s.length() - t.length() + 1;
    //cout << count << endl;
    for (int i = 0; i < count; ++i){
        int a = i;
        int c = 0;
        for (int j = 0; j < t.length(); ++j){
            if (s[a] != t[j]){
                c++;
            }
            a++;
        }
        //cout << c << endl;
        changes = min(changes, c);
        //cout << changes << endl;
    }
    cout << changes;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;
int main() {
	ll a, b = 0;
	unsigned ll ans = 1;

	cin >> a;
	b = a;
	for (int i = 0;;i++) {
		if (b == 1) {
			a = pow(2,i);
			break;
		}
		b /= 2;
	}
	for (;;) {
		if (a == 1)break;
		ans += a;
		a /= 2;
	}
	
	cout << ans << endl;
	
	please AC;
}

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

using namespace std;

int main(){
  string s;
  cin>>s;
  string ans="";
  for(int i=0; i<s.length()-2; i++){
    if(s[i] != s[i+1] and s[i+1] != s[i+2] and s[i] != s[i+2]){
      ans += s[i];
      ans += s[i+1];
      ans += s[i+2];
   		break;
    }
  }
  	if(ans.length() != 0)
    	cout<<ans<<endl;
 	else{
      cout<<s[0]<<s[1]<<s[2]<<endl;
    }
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    REP(i,s.size()) {
        cout << s[i];
        if (i == 3) cout << " ";
    }
    cout << endl;

    return 0;
}


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

using namespace std;

/* alias */
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

/* repetition */
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)

int main() {
    string S,ans;
    cin >> S;
    rep(i,S.size()){
        if (i%2==0){
            if (S.at(i) == 'L'){
                ans = "No";
                break;
            }
        }else
        {
            if (S.at(i) == 'R'){
                ans = "No";
                break;
            }
        }
        
    }

    if (ans != "No"){
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int a,i,j=0,v,A[N],b;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  for(b=0;b<a-1;b++) printf("%d ",A[b]);
  printf("%d",A[a-1]);
  printf("\n"); 
  for(i=1;i<a;i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v)
      {
	A[j+1] = A[j];
	j--;
      }
    A[j+1] = v;
    for(b=0;b<a-1;b++)printf("%d ",A[b]);
    printf("%d",A[a-1]);
    printf("\n");
  }
  return 0; 
}



Measured memory_bytes: 2084
n, l = [int(x) for x in input().split()]

d_list = [l + i - 1 for i in range(1, n + 1)]
d_sum = sum(d_list)

temp_list = sorted([(abs(d), d) for d in d_list])

ans = d_sum - temp_list[0][1]
print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int A, B;
	cin >> A >> B;
	swap(A, B);
	int H = 100;
	int W = 100;

	--A;
	vector<vector<bool>> F(H, vector<bool>(W, false));
	for (int h = 0; h < 20; h+=2) {
		for (int w = 0; w < W; w += 2) {
			if (A) {
				F[h][w] = true;
				--A;
			}
		}
	}
	for (int h = 20; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (w == 0 && h<=79) {
				F[h][w] = false;
			}
			else {
				F[h][w] = true;
			}
		}
	}
	for (int h = 79; h<H; h += 2) {
		for (int w = 0; w < W; w += 2) {
			if (B > 0) {
				F[h][w] = false;
				--B;
			}
		}
	}
	cout << H << " " << W << endl;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (F[h][w]) {
				cout << "#";
			}
			else {
				cout << ".";
			}
		}
		cout << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()

lists = [str(i) for i in range(0, 10)]

for i in range(a + b + 1):
    if s[i] != '-' and a == i:
        print('No')
        exit()
    if i != a and s[i] not in lists:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3060
import std.stdio : writeln, writefln;
import std.array;
import std.range;
import std.algorithm : filter;
import std.math : sqrt;


void main(){
	double[2][1000+1] LUT;
	LUT[2][0] = 1.00;
	LUT[2][1] = 1.00;
	for(int i=3; i<=1000; ++i){
		double x = LUT[i-1][0];
		double y = LUT[i-1][1];
		double[2] v = [-y, x];				// 直行するベクトル
		double r = 1.0/sqrt(v[0]*v[0] + v[1]*v[1]);	// 単位ベクトル用の係数
		
		LUT[i][0] = r*v[0] + x;
		LUT[i][1] = r*v[1] + y;
	}
	debug(1){
	for(int i=2; i<=6; ++i){
		writefln("%f, %f", LUT[i][0], LUT[i][1]);
	}
	}
	
	while(true){
		int n = next!int();
		if(n==-1){ break; }
		
		writefln("%.2f", LUT[n][0]);
		writefln("%.2f", LUT[n][1]);
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long

using namespace std;

const int N = 2e5 + 5;

int main()
{
    int mn = 100, c = 0, xx;
    int n;
    scanf("%d", &n);
    while(n--)
    {
        c = 0;
        scanf("%d", &xx);
        while(xx % 2 == 0) c++, xx/=2;
        mn = min(mn, c);
    }
    printf("%d\n", mn);
    return 0;
}


Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}
int x;

int Spow(int i){
	if(i * i > x) return 0;
	int p = i;
	i *= p;
	while(true){
		if(i * p > x) return i;
		i *= p;
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> x;
	int maxv = 1;
	for(int i = 2;i * i <= x;++i){
		maxv = max(maxv,Spow(i));
	}
	cout << maxv << '\n';
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int N;
    cin >> N;

    vector<int> A;
    int temp = 0;
    for(int i=0; i<N; i++){
        cin >> temp;
        A.emplace_back(temp);
    }

    sort(A.begin(), A.end());

    FOR(i,1,N){
        if(A[i-1] == A[i]){
            cout << "NO" << "\n";
            return 0;
        }
    }

    cout << "YES" << "\n";

return 0;
}

Measured memory_bytes: 1400
//C++初期コード

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int a[114514] = {0};
    int c = 0;
    rep(i, n) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            c++;
            a[i + 1] = c;
        } else {
            a[i + 1] = c;
        }
    }
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << a[r - 1] - a[l - 1] << endl;
    }
    r0
}


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

int getmd(int a,int b,int c,int d){
    return abs(a-c)+abs(b-d);
}

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

    if(a>=13)   cout << b << endl;
    if(a>=6&&a<=12) cout << b/2 << endl;
    if(a<=5)    puts("0");

    return 0;
}

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

int main()
{
    int n,m,x,s1,s2,i,j;
    int a[102]={0};
    scanf("%d%d%d",&n,&m,&x);
    for(i=1;i<=m;i++)
    {
        scanf("%d",&j);
        a[j-1]=1;
    }
    s1=0;
    for(i=x-1;i<n;i++)
    {
        s1+=a[i];
    }
    s2=0;
    for(i=0;i<x-1;i++)
        s2+=a[i];
    if(s1>s2)
        printf("%d",s2);
    else printf("%d",s1);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod=1e9+7;

int main(){
	int n;
  cin >> n;
  vector<ll> a(n);
	ll sum=0, abmin=INT_MAX;
	int cnt=0;
  rep(i,n){
  	cin >> a[i];
  	if(a[i]<0)
  	  cnt++;
  	sum+=abs(a[i]);
  	abmin=min(abmin,abs(a[i]));
  }
  if(cnt%2)
  	cout << sum-2*abmin << endl;
  else
  	cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024