akhauriyash/Code-Regression huggingface dataset:
// -*- coding:utf-8; tab-width:4 -*-
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

// ティツァツ」テァツュツ?
namespace solution {
    using namespace std;
   
    typedef istringstream ISS;
    typedef ostringstream OSS;
    typedef vector<string> VS;
    typedef long long LL;
    typedef int INT;
    typedef vector<INT> VI;
    typedef vector<VI> VVI;
    typedef pair<INT, INT> II;

    struct Comparator {
    bool operator() ( const string& a, const string& b ) {
        if ( a.size() != b.size() )
            return a.size() < b.size();
        return a < b;
    }
    };
    typedef map <string, LL, Comparator> MAP;

    const int SIZE = 100000000;
    int n;
    MAP M;

    struct Solution {
        void init() {
            M.clear();
        }
   
        bool input() {
            return cin >> n;
        }

        MAP solve() {
            MAP res;    
            for ( int i = 0; i < n; ++ i ) {
                string a;
                int b;
                cin >> a >> b;
                res[a] += b;
            }
            return res;
        }

        void output( MAP result ) {
            for ( MAP::iterator it_i = result.begin(); it_i != result.end(); ++ it_i ) {
                cout << (*it_i).first << " " << (*it_i).second << endl;
            }
        }

        int run() {
            while ( init(), input() ) {
                output(solve());
            }
            return 0;
        }
    };
}

int main() {
    return solution::Solution().run();
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    int nt = 0;
    int nx, ny;
    nx = ny = 0;
    while(N--) {
        int t, x, y;
        cin >> t >> x >> y;
        int tmp = abs(x - nx) + abs(y - ny);
        if(tmp > t - nt) {
            cout << "No" << endl;
            return 0;
        }
        if(tmp % 2 != (t - nt) % 2) {
            cout << "No" << endl;
            return 0;
        }
        nt = t;
        nx = x;
        ny = y;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return (!b)?a:gcd(b,a%b);}
int main(){
int n,i,j;
ll d[10],v[10],t[10];
for(;;){
scanf("%d",&n);
if(!n)break;
for(i=0;i<n;i++)scanf("%lld%lld",&d[i],&v[i]);
t[0]=1;
for(i=1;i<n;i++){
ll T=t[i]=t[i-1]*d[i-1]*v[i];
for(j=0;j<i;j++){
t[j] *= d[i]*v[i-1];
T=gcd(T,t[j]);
}
for(j=0;j<=i;j++)t[j]/=T;
}
for(i=0;i<n;i++)printf("%lld\n",t[i]);
}
}

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

int N,A,B,C;
vector<int> l;

int dfs(int cur,int a,int b,int c){
    if(cur == N){
        if(min({a,b,c}) > 0){
            return abs(a-A)+abs(b-B)+abs(c-C)-30;
        }
        else{
            return INF;
        }
    }
    int ret0,ret1,ret2,ret3;
    ret0 = dfs(cur+1,a,b,c);
    ret1 = dfs(cur+1,a+l[cur],b,c)+10;
    ret2 = dfs(cur+1,a,b+l[cur],c)+10;
    ret3 = dfs(cur+1,a,b,c+l[cur])+10;
    return min({ret0,ret1,ret2,ret3});
}

int main(){
    cin >> N >> A >> B >> C;
    l = vector<int>(N);
    for(int i=0;i<N;i++){
        cin >> l[i];
    }
    cout << dfs(0,0,0,0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	string T;
	cin >> T;
	int N = T.size();
	for(int i = 0; i < N; i++)
		if(T[i] == '?') T[i] = 'D';
	cout << T;
	return 0;
}


Measured memory_bytes: 3752
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

const int MAXN = 1e5 + 1;

int n, k;
int a[MAXN];

int main(void) {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);

  int gg = a[0], mx = a[0];
  for (int i = 1; i < n; ++i) {
    gg = __gcd(gg, a[i]);
    mx = max(a[i], mx);
  }

  if (k % gg != 0 || k > mx)
    printf("IMPOSSIBLE\n");
  else
    printf("POSSIBLE\n");
  return 0;
}



Measured memory_bytes: 640
#include "iostream"
using namespace std;

int main() {
	int m, f, r = 0;
	bool flag = true;

	while (flag == true) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) flag = false;
		else {
			if (m == -1 || f == -1) cout << "F";
			else if (m + f >= 80) cout << "A";
			else if (m + f >= 65)cout << "B";
			else if (m + f >= 50) cout << "C";
			else if (m + f >= 30 && r >= 50) cout << "C";
			else if (m + f >= 30)cout << "D";
			else cout << "F";
			
			cout << endl;
		}
	}
}

Measured memory_bytes: 1156
#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))


n_given,k_given =input_multiple_number()
pi_given = input_multiple_number_as_list()

#initial
wk = sum(pi_given[0:k_given])
maxi = wk

for i in range(n_given - k_given):
    wk = wk - pi_given[i] + pi_given[i+k_given]
    maxi = max(maxi,wk)

print((maxi + k_given )/2)


Measured memory_bytes: 24804
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define BUFSIZE 100000	

int main(void){

char s[BUFSIZE] = {0}; 

int cnt = 0;
 scanf("%s",s);
int cnt2 = 0;

for(int i = 0;i < 3;i++){
  if(s[i] == 'R'){ cnt++; cnt2++;
  }else if(i != 2) cnt = 0;
}

if(cnt2 == 1 && cnt == 0) cnt++;

printf("%d\n",cnt);

}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

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

	ll mul_c = b / c - (a-1) / c;
	ll mul_d = b / d - (a-1) / d;
	ll lcm_cd = lcm(c, d);
	ll mul_lcm = b / lcm_cd - (a-1) / lcm_cd;
	cout << (b-a+1) - mul_c - mul_d + mul_lcm << endl;
}



Measured memory_bytes: 256
def bubble_sort_revision(target_list):#?????????????????????

    list_length = len(target_list)
    
    flag = True
    change_count = 0
    
    for top_index in range(1,list_length):
        for i in range(top_index, list_length)[::-1]:
            if target_list[i] < target_list[i - 1] and target_list[top_index] >= target_list[i]:
                tmp = target_list[i]
                target_list[i] = target_list[i - 1]
                target_list[i - 1] = tmp
                change_count += 1
                
    return change_count

def my_add(bit, i, x):
    while i <= len(bit) - 1:
        bit[i] += x
        i += int(bin(i & -i), 2)
        
def my_sum(bit, i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= int(bin(i & -i), 2)
    return s

def merge(l,r):
    global count
    l_index = 0
    r_index = 0
    merge_list = []
    l.append(pow(10,9) + 1)
    r.append(pow(10,9) + 1)

    len_l = len(l) - 1
    for k in range(len(l) + len(r) - 2):
        if l[l_index] < r[r_index]:
            merge_list.append(l[l_index])
            l_index += 1
            len_l -= 1
        else:
            count += len_l
            merge_list.append(r[r_index])
            r_index += 1

    return merge_list
    
def merge_sort(target_list):
    if len(target_list) == 1:
        return target_list
    
    mid = int(len(target_list) / 2)
    
    r = merge_sort(target_list[mid:])
    l = merge_sort(target_list[:mid])
    
    return merge(l, r)

def bit_solve(n, target_list):#???????????§????????????bit?????§?????????????????????
    bit = [0 for i in range(max(target_list) + 2)]
    ans = 0
    for i in range(n):
        ans += i - my_sum(bit, target_list[i] + 1)
        my_add(bit, target_list[i] + 1, 1)
        print(ans, target_list[i], bit)
    return ans

if __name__ == "__main__":
    global count
    count = 0
    l = int(input())
    target_list = [int(i) for i in input().split()]
    merge_sort(target_list)
    print(count)
    

Measured memory_bytes: 30320
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*(a+b);
        System.out.println(area + " " + length);
        sc.close();
    }
}



Measured memory_bytes: 26180
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    string s;
    cin >> s;

    ll r = 0;
    ll b = 0;

    for(char c : s){
        if(c=='R'){
            r++;
        }else{
            b++;
        }
    }

    if(r>b){
        p_yes();
    }else{
        p_no();
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

const LL M = (LL)1e9 + 7;

LL chomp = (1 << 17) - 1;

LL a[3];

LL n;

bool has_bit(int n, int b) {
    return (n & (1 << (b-1))) > 0;
}
bool is_hi(int x) {
    return has_bit(x, a[0] + a[1] + a[2]) &&
        has_bit(x, a[1] + a[2]) &&
        has_bit(x, a[2]);
}

int main() {
    scanf("%lld%lld%lld%lld", &n, &a[0], &a[1], &a[2]);
    LL ans = 0;

    LL dp[2][1 << 17];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int i = 1; i <= n; i++) {
        int w = i % 2;
        memset(dp[w], 0, sizeof(dp[0]));
        for (int st = 0; st < (1 << 17); st++) {
            for (int x = 1; x <= 10; x++) {
                int nst = st << 1;
                nst += 1;
                nst <<= (x - 1);
                nst &= chomp;
                dp[w][nst] += dp[!w][st];
                dp[w][nst] %= M;
            }
        }
        ans *= 10;
        ans %= M;
        for (int st = 0; st < (1 << 17); st++) {
            if (is_hi(st)) {
                ans += dp[w][st];
                ans %= M;
                dp[w][st] = 0;
            }
        }
        // printf("%lld\n", ans);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename Key,typename Value>
class hashmap {
	std::vector<std::pair<Key,Value>> map;
	uint64 mask, temp, count;
public:
	hashmap() :map(8192, std::make_pair(~static_cast<Key>(0), Value())) {
		mask = 8191; count = 0;
	}
	hashmap(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<Key>(0), Value()));
	}
	Value &operator[](Key suf) {
		temp = mask&std::hash<Key>()(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(Key key, const Value &value) {
		temp = mask&std::hash<Key>()(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<Key, Value> mkey;
			uint64 t = mask;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<Key>(0), Value()));
			while (~map[t].first) {
				--t;
			}
			while (++t <= (mask >> 1)) {
				mkey = map[t];
				map[t].first = ~static_cast<Key>(0);
				temp = mask&std::hash<Key>()(mkey.first);
				while (~map[temp].first) {
					temp = mask&(temp + 1);
				}
				map[temp] = mkey;
			}
			for (t = 0;t <= mask >> 1;++t) {
				if (~map[t].first) {
					mkey = map[t];
					map[t].first = ~static_cast<Key>(0);
					temp = mask&std::hash<Key>()(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(Key key) {
		temp = mask&std::hash<Key>()(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap<uint64,uint32> map(100000);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 15048
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))
#print(a)
tmp = 1
isOK = -1
for i in range(1,n+1):
    if a[tmp]==2:
        isOK = i
        break
    tmp = a[tmp]

print(isOK)

Measured memory_bytes: 12780
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vector<ll> all;
  int k;
  cin >> k;
  all.reserve(k + 1);
  queue<ll> q;
  for (int i = 1; i <= 9; ++i)
    q.push(i);
  while (!q.empty()) {
    if (all.size() >= k + 1)
      break;
    ll n = q.front();
    all.push_back(n);
    q.pop();
    for (int i = n % 10 - 1; i <= n % 10 + 1; ++i) {
      if (i < 0 || i > 9)
        continue;
      q.push(n * 10 + i);
    }
  }
  cout << all[k - 1] << '\n';
  return 0;
}


Measured memory_bytes: 2560
import Control.Applicative
import Control.Monad
import Text.Printf

main :: IO ()
main = do
  ls <- map (map read . words) . lines <$> getContents
  forM_ ls $ \xs -> do
    let (x, y) = solveEq (xs!!0) (xs!!1) (xs!!2) (xs!!3) (xs!!4) (xs!!5)
    printf "%.3f %.3f\n" x y

solveEq :: Double -> Double -> Double -> Double -> Double -> Double -> (Double, Double)
solveEq a b c d e f = (x', y')
  where
    det = a*e-b*d
    (x, y) = ((c*e-b*f)/det, (a*f-c*d)/det)
    x' = if x == -0.0 then 0.0 else x
    y' = if y == -0.0 then 0.0 else y

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



int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,n,m,k;
    ll t;  
        cin>>n;
        ll min1,min2,max1,max2;
        min1=min2=INT_MAX;
        max1=max2=INT_MIN;
        for(i=0;i<n;i++)
        {
            ll x,y;
            cin>>x>>y;
            min1=min(min1,x+y);
            max1=max(max1,x+y);
            min2=min(min2,x-y);
            max2=max(max2,x-y);
        }
        cout<<max(max1-min1,max2-min2)<<"\n";
    
}

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

vector<string> split(string str, char del){
    vector<string> ret;
    string cutoff = "";
    for(int i = 0; i < str.length(); i++){
        if(str[i] == del){
            if(cutoff != "")    ret.push_back(cutoff);
            cutoff = "";
        }else{
            cutoff += str[i];
        }
    }
    if(cutoff != "")    ret.push_back(cutoff);
    return ret;
}

struct dict{
    string word;
    int freq;
    dict(string w, int f) : word(w), freq(f) {}
    bool operator<(const dict other) const{
        if(freq == other.freq)  return word < other.word;
        else                    return freq > other.freq;
    }
};

int main(){
    while(1){
        int n;
        scanf("%d\n", &n);
        
        if(n == 0)  break;
        
        map<string, int> appear;
        string s;
        for(int i = 0; i < n; i++){
            getline(cin, s);
            vector<string> line = split(s, ' ');
            for(string x : line)    appear[x]++;
        }
        
        char k;
        cin >> k;
        
        vector<dict> vd;
        for(map<string,int>::iterator it = appear.begin(); it != appear.end(); it++){
            pair<string,int> psi = *it;
            if(psi.first[0] == k)   vd.push_back(dict(psi.first, psi.second));
        }
        
        if(vd.size() == 0){
            cout << "NA" << endl;
            continue;
        }else{
            sort(vd.begin(), vd.end());
            for(int i = 0; i < min(5, (int)(vd.size())); i++){
                if(i)   cout << " ";
                cout << vd[i].word;
            }
            cout << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  string S; cin >> S;
  string T;
  int Q; cin >> Q;
  while (Q--) {
    int type; cin >> type;
    if (type == 1) {
      swap(S, T);
    } else {
      int f; char c; cin >> f >> c;
      if (f == 1) {
        T.push_back(c);
      } else {
        S.push_back(c);
      }
    }
  }
  reverse(range(T));
  cout << T + S << endl;
}

Measured memory_bytes: 1248
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=200005;
const int MOD=998244353;
int n;
int a[N];
long long solve(int T)
{
	static int p[N],q[N];
	for(int i=1;i<=T/2;i++)
		p[i]=a[i],q[i]=a[i]^1;
	static int b[N];
	for(int i=1;i<=n*2;)
	{
		for(int j=1;j<=T/2;j++)
			b[i+j-1]=p[j];
		i+=T/2;
		for(int j=1;j<=T/2;j++)
			b[i+j-1]=q[j];
		i+=T/2;
	}
	long long ans=0;
	for(int i=1;i<=T/2;i++)
		ans=(ans*2+a[i])%MOD;
	ans=(ans+1)%MOD;
	for(int i=1;i<=n;i++)
		if(b[i]<a[i]) break;
		else if(b[i]>a[i])
		{
			ans=(ans-1+MOD)%MOD;
			break;
		}
	return ans;
}
long long f[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%1d",&a[i]);
	for(int i=1;i<=n*2;i++)
		if(n*2%i==0&&n%i!=0) f[i]=solve(i);
	for(int i=1;i<=n*2;i++)
		if(n*2%i==0&&n%i!=0)
			for(int j=i+i;j<=n*2;j+=i)
				if(n*2%j==0&&n%j!=0) f[j]=(f[j]-f[i]+MOD)%MOD;
	long long ans=0;
	for(int i=1;i<=n*2;i++)
		if(n*2%i==0&&n%i!=0) ans=(ans+f[i]*i%MOD)%MOD;
	printf("%lld",ans);
	return 0;
}

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

int main(){
	int K, N, i, j;
	scanf("%d", &K);
	if(K == 1){
		printf("1\n");
		printf("1\n");
		return 0;
	}
	N = (K + 1) / 2;
	if(N % 2 == 1){
		N++;
	}
	int **C = (int **)malloc(sizeof(int *) * N);
	for(i = 0; i < N; i++){
		C[i] = (int *)malloc(sizeof(int) * N);
	}
	for(i = 0; i < N; i++){
		for(j = 0; j < N; j++){
			C[i][j] = (j - i + N) % N;
			if(i % 2 == 0 && C[i][j] + N < K){
				C[i][j] += N;
			}
		}
	}
	printf("%d\n", N);
	for(i = 0; i < N; i++){
		for(j = 0; j < N; j++){
			printf("%d ", C[i][j] + 1);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2048
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
ll mod=1000000007;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};
bool test = 0;

int n,k,sum=0,q,x,y;
map<int,int>m;
void solve()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        m[x]++;
        sum+=x;
    }
    cin>>q;
    while(q--)
    {
        cin>>x>>y;
        if(m.find(x)!=m.end())
        {
            int cnt=m[x];
            m.erase(x);
            m[y]+=cnt;
            sum=sum-cnt*(x-y);
        }
        cout<<sum<<endl;
    }
    
}










signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 7536
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstdlib>
using namespace std;


int main(void){

  int a;
  int b;
  int c;
  int d;
  int e;
  int f;

  float x;
  float y;

  while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)!=EOF){
    x = a * e - b * d ;
    y = b * d - a * e ;

    if ((x == 0) && (y == 0)){
      cerr << "error" << endl;
      exit(1);
    }else if(x == 0){
      cerr << "error" << endl;
      exit(1);
    }else if(y == 0){
      cerr << "error" << endl;
      exit(1);
    }else{

      if(c * e - b * f == 0){
        x = 0;
      }else{
        x = ( c * e - b * f ) / x ;
      }

      if(c * d - a * f == 0){
        y = 0;
      }else{
        y = ( c * d - a * f) / y;
      }

      printf("%.3f %.3f\n",x,y);
    }
  }


  return 0;


}

Measured memory_bytes: 3156
N, K = map(int, input().split())
R, S, P=map(int, input().split())
T = input()
points = []

for i in range(len(T)):
  if T[i] == "r":
    points.append(P)
  if T[i] == "s":
    points.append(R)
  if T[i] == "p":
    points.append(S)
  
  if i >= K and T[i] == T[i-K]:
    if points[i] > points[i-K]:
      points[i-K] = 0
    else:
      points[i] = 0

print(sum(points))

Measured memory_bytes: 4212
N,M = [int(x) for x in input().split()]
S = list(input())
S1 = S[::-1]
ind = 0
ans = []
while ind!=N:
  ind1 = ind
  for i in range(M,0,-1):
    if ind+i<=N and S1[ind+i]=="0":
      ind = ind+i
      ans.append(i)
      break
  if ind1==ind:
    print(-1)
    exit()
print(*ans[::-1])

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int dp[n+1][2];
  for(int i=0;i<=n;i++)dp[i][0] = dp[i][1] = 0;
  dp[1][0] = 1;
  for(int i=1;i<n;i++){
    if(s[i]==s[i-1]){
      dp[i+1][0] = dp[i][1]+1;
      dp[i+1][1] = max(dp[i-1][1],dp[i-1][0]) + 1;
    }else {
      dp[i+1][0] = max(dp[i][0],dp[i][1])+1;
      dp[i+1][1] = dp[i-1][0] + 1;
    }
  }
  cout << max(dp[n][0],dp[n][1]) << endl;
  return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll n,a[100001],odd=0;
    cin >> n;
    rep(i,n) cin >> a[i];
    if(n==2){
        if(a[0]%2==a[1]%2) cout << "YES" << "\n";
        else cout << "NO" << "\n";
        return 0;
    }
    else{
        rep(i,n){
            if(a[i]%2) odd++;
        }
    }
    if(odd%2) cout << "NO" << "\n";
    else cout << "YES" << "\n";
    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}


vl f;
vl invf;
const int MAXVAL = 2e6 + 100;
void init(){
	f.resize(MAXVAL, 1);
	invf.resize(MAXVAL, 1);
	forne(i, MAXVAL-1) f[i] = (f[i-1]*i)%MOD;
	forne(i, MAXVAL-1) invf[i] = modinv(f[i]);
}

ll ncr(ll n, ll r){
	return invf[n-r] * ( f[n] * invf[r] % MOD ) % MOD;
}

void solve(){
	ll k; cin>>k;
	string s; cin>>s;
	ll len = s.size() - 1;
	ll ans = 0;
	ll minv = modinv(25);
	ll factor = modpow(25, k);
	forn(i, k+1)
		ans = ans + (ncr(k - i + len, len)*factor)%MOD,
		factor = (factor*minv)%MOD,
		factor = (factor*26)%MOD;
	cout<<(ans%MOD)<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	init();
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 35528
h, w, k = map(int, input().split())
li = [1]+[0]*(w-1)
if w == 1:
    print(1)
else:
    for i in range(h):
        t = li.copy()
        if w == 2:
            li[0] = (t[0] + t[1]) % 1000000007
            li[1] = (t[0] + t[1]) % 1000000007
        elif w == 3:
            li[0] = (2*t[0] + t[1]) % 1000000007
            li[1] = (t[0] + t[1] + t[2]) % 1000000007
            li[2] = (t[1] + 2 * t[2]) % 1000000007
        elif w == 4:
            li[0] = (3*t[0] + 2*t[1]) % 1000000007
            li[1] = (2*t[0] + 2*t[1] + t[2]) % 1000000007
            li[2] = (t[1] + 2*t[2] + 2*t[3]) % 1000000007
            li[3] = (2*t[2] + 3 * t[3]) % 1000000007
        elif w == 5:
            li[0] = (5 * t[0] + 3*t[1]) % 1000000007
            li[1] = (3 * t[0] + 3*t[1] + 2*t[2]) % 1000000007
            li[2] = (2 * t[1] + 4*t[2] + 2*t[3]) % 1000000007
            li[3] = (2 * t[2] + 3 * t[3] + 3 * t[4]) % 1000000007
            li[4] = (3 * t[3] + 5 * t[4]) % 1000000007
        elif w == 6:
            li[0] = (8 * t[0] + 5 * t[1]) % 1000000007
            li[1] = (5 * t[0] + 5 * t[1] + 3 * t[2]) % 1000000007
            li[2] = (3 * t[1] + 6 * t[2] + 4 * t[3]) % 1000000007
            li[3] = (4 * t[2] + 6 * t[3] + 3 * t[4]) % 1000000007
            li[4] = (3 * t[3] + 5 * t[4] + 5 * t[5]) % 1000000007
            li[5] = (5 * t[4] + 8 * t[5]) % 1000000007
        elif w == 7:
            li[0] = (13 * t[0] + 8 * t[1]) % 1000000007
            li[1] = (8 * t[0] + 8 * t[1] + 5 * t[2]) % 1000000007
            li[2] = (5 * t[1] + 10 * t[2] + 6 * t[3]) % 1000000007
            li[3] = (6 * t[2] + 9 * t[3] + 6 * t[4]) % 1000000007
            li[4] = (6 * t[3] + 10 * t[4] + 5 * t[5]) % 1000000007
            li[5] = (5 * t[4] + 8 * t[5] + 8 * t[6]) % 1000000007
            li[6] = (8 * t[5] + 13 * t[6]) % 1000000007
        else:
            li[0] = (21 * t[0] + 13 * t[1]) % 1000000007
            li[1] = (13 * t[0] + 13 * t[1] + 8 * t[2]) % 1000000007
            li[2] = (8 * t[1] + 16 * t[2] + 10 * t[3]) % 1000000007
            li[3] = (10 * t[2] + 15 * t[3] + 9 * t[4]) % 1000000007
            li[4] = (9 * t[3] + 15 * t[4] + 10 * t[5]) % 1000000007
            li[5] = (10 * t[4] + 16 * t[5] + 8 * t[6]) % 1000000007
            li[6] = (8 * t[5] + 13 * t[6] + 13 * t[7]) % 1000000007
            li[7] = (13 * t[6] + 21 * t[7]) % 1000000007
    print(li[k - 1])


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

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  int kazu=b-a+1;
  int count=0;
  for(int i=a;i<=b;i++){
    count++;
    if(count<=k||count-1>=kazu-k){
      cout<<i<<endl;
    }
  }
  return 0;
}
  

Measured memory_bytes: 3640
import java.util.*;
   
class Main{
   public static void main(String[] args){
     
    int[] len = new int[3];
     Scanner input = new Scanner(System.in);
     
    for(int i=0; i<len.length;i++){  
    len[i] = input.nextInt();
    }
     
    Arrays.sort(len);
    System.out.println(len[0]+" "+len[1]+" "+len[2]);
   }
}
 

Measured memory_bytes: 17300
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int get_id(char c){
	if(c>='a'&&c<='z')return c-'a';
	if(c>='A'&&c<='Z')return c-'A'+26;
	return c-'0'+52;
}
char rev(int x){
	if(x<26)return 'a'+x;
	if(x<52)return 'A'+x-26;
	return '0'+x-52;
}
int cnt[66],func[66],n,tot_ask;
string cmp="";
int dp[199][199];
int dist(string s){
	memset(dp,inf,sizeof dp);
	dp[0][0]=0;tot_ask++; 
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=cmp.size();j++){
			if(j)dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
			if(i)dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
			if(i&&j)dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(s[i-1]!=cmp[j-1]));
		}
	}
	return dp[s.size()][cmp.size()];
}
int ask(string s){
	#ifdef LOCAL
		return dist(s);
	#endif
	cout<<"? "<<s<<endl;
	fflush(stdout);int x;cin>>x;return x;
}
int Get(string ret,string s,int pos,char c){
	int tot=ret.size()+1+s.size()-pos;
	string ss=ret+c+getstr(s,pos,s.size()-1);
	tot=ss.size();
	#ifdef LOCAL
		return dist(ss)==n-tot;
	#endif
	return n-tot==ask(ss);
}
string merge(string s1,string s2){
	int pos=0;
	string ret="";
	if(rand()&1)swap(s1,s2);
	for(int i=0;i<s1.size();i++){
		while(pos<s2.size()&&Get(ret,s2,pos,s1[i])==0)
		ret.push_back(s2[pos]),pos++;
		ret.push_back(s1[i]);
	}
	while(pos<s2.size())ret.push_back(s2[pos++]);
	return ret;
}
int main(){
	srand(time(0));
	for(int i=0;i<128;i++)cmp.push_back(rev(rand()%62));
	for(int i=0;i<62;i++){
		string s="";s.push_back(rev(i));
		for(int i=0;i<7;i++)s=s+s;
		int got=ask(s);
		cnt[i]=128-got;
	}
	for(int i=0;i<128;i++)ask("a");
	for(int i=0;i<62;i++)n+=cnt[i];
	set<pair<int,string> >s;
	for(int i=0;i<62;i++){
		if(cnt[i]){
			string ins="";
			for(int j=0;j<cnt[i];j++)ins.push_back(rev(i));
			s.insert(make_pair(cnt[i],ins));
		}
	}
	while(s.size()>1){
		string s1=s.begin()->second;s.erase(s.begin());
		string s2=s.begin()->second;s.erase(s.begin());
		string s3=merge(s1,s2);
		s.insert(make_pair(s3.size(),s3));
	}
	cout<<"! "<<s.begin()->second<<endl;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  long h[n];
  
  for(int i=0;i<n;i++){
	scanf("%ld",&h[i]);
  }
  for(int i=n-1;i>0;i--){
    if(h[i-1]-h[i]>=2){
      printf("No");
      return 0;
    }
    else if(h[i-1]-h[i]==1)h[i-1]--;

  }
  printf("Yes");
  return 0;
}

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

int main(){
	int x,i,a[7]={},an,aaa;
	double man;
	cin >> x;
	for(i=0;i<x;i++){
		cin >> man;
		if(man<165.0) a[1]++;
		else if(man<170.0) a[2]++;
		else if(man<175.0) a[3]++;
		else if(man<180.0) a[4]++;
		else if(man<185.0) a[5]++;
		else a[6]++;
	}
	
	for(an=1;an<=6;an++){
		cout << an << ':';
		for(aaa=1;aaa<=a[an];aaa++){
			cout << '*';
		}
		cout << endl;
	}
	
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
#define N 1048573

int t[N];
string a,str;

int hash2(int x){
  return 1 + x%(N-1);
}

int hash1(int x){
  return x%N;
}

int hash0(){
  int x=0;
  for(int i=0;i<(int)str.size();i++){
    x*=4;
    if(str[i]=='A')x++;
    else if(str[i]=='T')x+=2;
    else if(str[i]=='G')x+=3;
    else x+=4;
  }
  return x;
}

bool find(){
  int x=hash0();
  int y=hash2(x);
  int i=hash1(x);
  while(1){
    if(t[i]==-1)return false;
    else if(t[i]==x)return true;
    i=hash1(i+y);
  }
}

void insert(){
  int x=hash0();
  int y=hash2(x);
  int i=x%N;
  while(1){
    if(t[i]==x)return;
    if(t[i]==-1){
      t[i]=x;
      return;
    }
    i=(i+y)%N;
  }
}
int main(){
  for(int i=0;i<N;i++)t[i]=-1;
  int Tc;
  cin>>Tc;
  while(Tc--){
    cin>>a>>str;
    if(a=="insert"){
      insert();
    }else{
      cout<<(find()?"yes":"no")<<endl;
    }
  }
  return 0;
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 2e5+5;
int n, a[MX], p, res = 0, acu = 0;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p;
		a[p] = i;
	}

	for (int i = 1; i <= n; i++) {
		if (a[i] > a[i-1]) acu++;
		else acu = 1;
		res = max(res, acu);
	}

	cout << n - res << endl;

	return 0;
}

Measured memory_bytes: 1024
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Convert.ToInt32(Console.ReadLine());

            var val = 0;
            var count = 0;
            while (true)
            {
                count++;
                val += x;
                // 商と余りを求める
                var a = val / 360;
                var b = val % 360;

                if(b == 0) { break; }
                val = b;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27236
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cmath>
#include<memory.h>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<list>
#include<stack>
#include<utility>
#include<iomanip>
#include<bitset>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<cstring>
using namespace std;
typedef long long int ll;
typedef long double ld;
int dx[]={0,0,1,-1,1,1,-1,-1};
int dy[]={1,-1,0,0,1,-1,-1,1};
const int N=1e5+10;
int frq[N];
int main(){
	//freopen("a.txt","r",stdin);
	int n;
	scanf("%d",&n);
	for(int a,i=0;i<n;++i){
		scanf("%d",&a);
		++frq[a];
	}
	ll mx=-1e9;
	for(int i=0;i<N;++i){
		if(i>0&&i<N-1&&mx<frq[i]+frq[i+1]+frq[i-1])
			mx=frq[i]+frq[i+1]+frq[i-1];
	}
	printf("%I64d\n",mx);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,t1,a[200001],g[200001],f[200001],m;
void solve(ll x,ll hh){
	//prllf("%d %d\n",x,hh);
	ll l=1,r=m,y,mid,mx=0;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]<=x)mx=mid,l=mid+1;
		 else r=mid-1;
	}
	//prllf("%d\n",mx);
	if(!mx)f[1]+=hh,f[x+1]-=hh;
	 else{
	 	y=x/a[mx];
	 	g[mx]+=y*hh;
	 	y=x-y*a[mx];
	 	solve(y,hh);
	 }
}
int main(){
	ll i,r,x;
	scanf("%lld%lld",&n,&t1);
	a[1]=n;
	r=1;
	for(i=1;i<=t1;i++){
		scanf("%lld",&x);
		while(r&&x<=a[r])r--;
		a[++r]=x;
	}
	m=r;
	g[m]=1;
	for(i=m;i>1;i--){
		//prllf("%d %d\n",i,g[i]);
		x=a[i]/a[i-1];
		g[i-1]+=x*g[i];
		solve(a[i]-a[i-1]*x,g[i]);
	}
	f[1]+=g[1];f[a[1]+1]-=g[1];
	for(i=1;i<=n;i++)f[i]+=f[i-1];
	for(i=1;i<=n;i++)printf("%lld\n",f[i]);
}

Measured memory_bytes: 4992
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;


public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            a.add(i + l - 1);
        }
        a = a.stream().sorted((b, c) -> {
            return b * b - c * c;
        }).collect(Collectors.toList());
        a.remove(0);
        System.out.println(a.stream().mapToInt(s -> s).sum());

    }

    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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


        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: 26580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define For(i, a, n) for (ll (i) = (a); (i) < (n); (i)++)
#define prl(x) cout << (x) << endl
#define all(v) (v).begin(), (v).end()

int main(void){
    ll n,k,c;string s;cin>>n>>k>>c>>s;
    vector<vl> cnt(2,vl(n+1,0));
    auto func=[&](string& t,vl& cnt){
        ll res = 0;
        For(i,1,n+1){
            cnt[i]=cnt[i-1];
            if(!res&&t[i-1]!='x')cnt[i]++,res=c;
            else if(res)res--;
        }
    };
    func(s, cnt[0]);
    reverse(all(s));
    func(s, cnt[1]);
    rep(i,n)if(cnt[0][i]+cnt[1][n-1-i]<k)prl(i+1);
    return 0;
}

Measured memory_bytes: 8396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int main(void){
    int n,a,b;cin>>n>>a>>b;
    vector<vector<vector<ll>>>dp(n+1,vector<vector<ll>>(410,vector<ll>(410,INF)));
    dp[0][0][0]=0;
    int x,y,z;
    rep(i,n){
        cin>>x>>y>>z;
        rep(j,410)rep(k,410){
            if(dp[i][j][k]!=INF){
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+x][k+y]=min(dp[i+1][j+x][k+y],dp[i][j][k]+z);
            }
        }
    }
    ll ans=INF;
    //rep(i,10){rep(j,10){
      //  cout<<dp[1][i][j]<<' ';
    //}
    //cout<<endl;
    //}
    for(int i=1;i*a<410&&i*b<410;i++){
        ans=min(ans,dp[n][i*a][i*b]);
    }
    if(ans==INF)cout<<-1;
    else cout<<ans;
}

Measured memory_bytes: 56064
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>

int main(){
    int M, N;
    std::vector<int> divisor;
    std::stack<int> stk;
    std::cin >> N >> M;
    for(int i=1; i<sqrt(M); i++){
        if(M%i == 0){
            divisor.push_back(i);
            stk.push(i);
        }
    }
    
    int sqrt_M = round(sqrt(M));
    if(sqrt_M*sqrt_M == M)
        divisor.push_back(sqrt_M);

    while(!stk.empty()){
        divisor.push_back(M/stk.top());
        stk.pop();
    }

    for(auto i = divisor.rbegin(); i!=divisor.rend(); ++i){
        if(M / (*i) >= N){
            std::cout << *i;
            break;
        }
    }
}


Measured memory_bytes: 256
using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif


 int N = 1000010;

int uf[1000010];
int sz[1000010];

void init(void) {
    for (int i = 0; i < N; i++) {
        uf[i] = i;
        sz[i] = 1;
    }
}


int root(int x) {
    if (uf[x] == x) return x;
    return uf[x] = root(uf[x]);
}

/* Union of sets containing x and y */
void join(int x, int y) {
    int a = root(x);
    int b = root(y);
    if (a == b) return;
    uf[a] = uf[b];
    sz[b] += sz[a];
    sz[a] = 0;
}







int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif
    int n;
    int m;
    cin >> n >> m;
    N = n;
    init();

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;

        
        join(x, y);
    }
    int mx = 0;
    for (int i = 0; i < n; i++) mx = max(sz[i], mx);
    cout << mx << endl;
    

}


Measured memory_bytes: 5172
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Y;
    cin >> N >> Y;
    Y /= 1000;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=N-i; j++){
            int k = N-i-j;
            int sm = i*10 + j*5 + k;
            if(sm == Y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 888
a=input()
a=list(a)
b=int(input())
c=[]
for i in range(b):
    c.append(input().split())
    x=int(c[i][1])
    y=int(c[i][2])
    if c[i][0]=="replace":
        a[x:y+1]=c[i][3]
    elif c[i][0]=="reverse":
        z=a[x:y+1]
        z.reverse()
        a[x:y+1]=z
    else:
        w=a[x:y+1]
        print("".join(w))


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int n;
int a[105],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	 for(int j=i+1;j<=n;j++)
	  for(int k=j+1;k<=n;k++)
	  if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
	  {
	  	if(a[i]+a[j]>a[k]&&a[j]-a[i]<a[k]) ans++;
	  }
	  cout<<ans;
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main() {
   long double a,b,c;
   cin>>a>>b>>c;
   long double esp=1.0E-14;
   if(a+b+2*sqrt(a*b)+esp<c){
     cout<<"Yes"<<endl;
   }else
   {
     cout<<"No"<<endl;
   }
   
    return 0;
}


Measured memory_bytes: 256
using System;

class Bubble_Sort
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string str_num = Console.ReadLine();
        string[] tmp_num = str_num.Split(' ');
        bool flag = true;
        int cnt=0;

        int[] numbers = new int[2];
        Array.Resize(ref numbers,n);

        for(int i=0;i<n;i++)
        {
            numbers[i] = int.Parse(tmp_num[i]);
        }

        while(flag)
        {
            flag = false;

            for (int i = 0; i < n - 1; i++)
            {
                if(numbers[i]>numbers[i+1])
                {
                    int tmp = numbers[i + 1];
                    numbers[i + 1] = numbers[i];
                    numbers[i] = tmp;
                    flag = true;
                    cnt++;
                }
            }
        }

        Console.Write("{0}", numbers[0]);
        for(int i=1;i<n;i++)
        {
            Console.Write(" {0}",numbers[i]);
        }

        Console.WriteLine();
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 9148
import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val line = jin.readLine().split(" ").map { it.toInt() }
    println((60 * (line[2] - line[0])) + line[3] - line[1] - line[4])
}

Measured memory_bytes: 36356
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = N / (A+B) * A;
  ans += min(N%(A+B), A);
  cout << ans << '\n';
  return 0;
}

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


int main() {
    int a, b;
    cin >> a >> b;
    if((a + b) % 2 == 0) cout << (a + b) / 2;
    else cout << "IMPOSSIBLE";
}


Measured memory_bytes: 256