akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//試してて御免

const int cm = 1 << 17;
char ci[cm];
char *cn = ci + cm;
inline char getcha() { 
	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }
	char ret = *cn;
	cn++;
	return ret;
}
inline char getcha2() {
	char ret = *cn;
	cn++;
	return ret;
}

inline int getint() {
	if (cn - ci + 25 > cm) {
		char C = getcha();
		int A = C - '0';
		while (isdigit(C = getcha())) A = A * 10 + C - '0';
		return A;
	}
	else {
		char C = getcha2();
		int A = C - '0';
		while (isdigit(C = getcha2())) A = A * 10 + C - '0';
		return A;
	}
}

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


	int N, X;
	N = getint();
	X = getint();

	int A = 0;
	ll kotae = 0;
	rep(i, N) {
		int B = getint();
		if (A + B > X) {
			kotae += A + B - X;
			B = X - A;
		}
		A = B;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
####################################### ###############          #   #      
######################################## ################     ##            
################ #####################  # ##################     #          
#################  ################## #    #######   ##########      #      
################### ################  #   #######  #      ####  ####        
############# ## #    #########        # #        ## ###                    
##############    #     ###           # ###    #  ##  ########              
###### ########                        #########  #   ########   ###        
##  ###  ####     #####                  #######       ## ####  #    #      
##      #   ########### #                 ####         #  ###           #   
##       #####    #                                  #    ##               #
##     ########                                    ##    #                  
##     ##############                      #          #                     
####  ###############                                      #                
#####       #####                                          #                
#######                                    ###                              
##########                          #  ########                             
######### #  #                  ###############         #                   
############                  #################        #                    
###############                ###############       #                      
#    ###########                 ##########                                 
#################                                                           
################# ##                           #                            

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    if v[i] - c[i] > 0:
        ans += v[i] - c[i]

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.exceptions(cin.failbit)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define endl '\n'  
#define show(a) for(auto i:a) cout<<i<<" ";cout<<endl
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <int> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const int mod=1000000007;
const int inf=1e9+100;
const int N=2e6+10;

mypair digit_sum(ll a,ll b)
{
	ll steps=1;
	ll sum=a+b;
	while(sum>=10)
	{
		steps++;
		a=sum%10;
		b=sum/10;
		sum=a+b;
	}
	return mp(sum,steps);

}

mypair add(mypair a,mypair b)
{
	auto now=digit_sum(a.ff,b.ff);
	return mp(now.ff,now.ss+a.ss+b.ss);
}


mypair fast(ll c,ll d)
{
	mypair last=mp(c,ll(0));
	mypair ans=mp(ll(-1),ll(-1));
	while(d)
	{
		if(d&1ll)
		{
			if(ans!=mp(ll(-1),ll(-1)))ans=add(ans,last);
			else ans=last;
		}	
		d>>=1;
		last=add(last,last);
	}
	return ans;
}

int main()
{
	boost;
	int n;
	cin>>n;
	mypair a[n];
	for(int i=0;i<n;i++)
	{
		ll c,d;
		cin>>c>>d;
		a[i]=fast(c,d);
	}
	mypair ans=a[0];
	for(int i=1;i<n;i++) ans=add(ans,a[i]);
	cout<<ans.ss;	
	return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    ll ans = 0;

    for (int i = 0; i < N; ++i)
        for (int j = i + 1; j < N; ++j)
            ans += (xs[i] * xs[j]);

    return ans;
}

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

    int N;
    cin >> N;

    vector<ll> xs(N);

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

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int a,b,c,d,tc,ac;
  cin>>a>>b>>c>>d;
  tc=(a-1)/d;
  tc=tc*2;
  ac=(c-1)/b;
  ac=ac*2-1;
  if(tc>ac){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// #define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_H = 500;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

ll MOD(ll x, ll y) { return (x % y + y) % y; }
ll DIV(ll x, ll y) { return (x - MOD(x, y)) / y; }

string COLOR = "RGBY";

int H, W, D;
char MAP[MAX_H][MAX_H + 1];

void solve() {
  for (int i = 0; i < H; i++)
    for (int j = 0; j <= W; j++) MAP[i][j] = '\0';

  for (int r = 0; r < H; r++) {
    for (int c = 0; c < W; c++) {
      int x = r + c, y = r - c;
      int z = DIV(2 * x + D - 1, 2 * D);
      int w = DIV(2 * y + D - 1, 2 * D);
      z = MOD(z, 2);
      w = MOD(w, 2);
      #ifdef DEBUG
      cout << r << " " << c << endl;
      cout << x << " " << y << endl;
      cout << z << " " << w << endl;
      cout << endl;
      #endif
      int k = 2 * z + w;
      MAP[r][c] = COLOR[k];
    }
  }

  for (int i = 0; i < H; i++)
    cout << MAP[i] << endl;
}

int main() {
  cin >> H >> W >> D;

  solve();

  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int main() {
	int no, score;
	multimap<int, int> r;
	while (1) {
		scanf("%d,%d", &no, &score);
		if (!no && !score)
			break;
		r.insert( multimap<int, int>::value_type(score, no) );
	}
	while (cin >> no) {
		int ranking = -1;
		int upper;
		map<int, int>::reverse_iterator it = r.rbegin();
		while (it != r.rend()) {
			if (ranking == -1) {
				ranking = 1;
				upper = it->first;
			}
			if (upper > it->first) {
				ranking++;
				upper = it->first;
			}
			if (it->second == no) {
				cout << ranking << endl;
				break;
			}
			it++;
		}
	}
	return 0;
}

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

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ');

            string S = strArray[0];
            string T = strArray[1];

            Console.WriteLine(T + S);
        }
    }
}


Measured memory_bytes: 11092
package main

import (
	"fmt"
	"sort"
)

type pair struct {
	price int64
	stock int64
}

type Int64Slice []pair

func (p Int64Slice) Len() int           { return len(p) }
func (p Int64Slice) Less(i, j int) bool { return p[i].price < p[j].price }
func (p Int64Slice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

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

	order := make(Int64Slice, 0, n)
	for index := 0; index < n; index++ {
		var a, b int64
		fmt.Scan(&a)
		fmt.Scan(&b)

		order = append(order, pair{price: a, stock: b})
	}

	sort.Sort(order)

	var re int64
	var c int
	for _, item := range order {
		if c == m {
			break
		}
		var index int64
		for index = 0; index < item.stock; index++ {
			if c < m {
				re += item.price
				c++
			}
		}
	}
	fmt.Println(re)
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
//#define int ll
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 998244353;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

struct BIT {
  int sz;
  vi node;
  BIT(int n): sz(n+1), node(vi(n+1)) {}

  void add(int idx, int val) {
    idx++;
    while(idx < sz) {
      node[idx] += val;
      idx += idx & -idx;
    }
  }

  int sum(int idx) {
    idx++;
    int res = 0;
    while(idx) {
      res += node[idx];
      idx -= idx & -idx;
    }
    return res;
  }

};

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi x(n), y(n);
  set<int> stx, sty;
  map<int, int> ztx, zty;
  for(int i=0;i<n;++i) {
    cin >> x[i] >> y[i];
    stx.insert(x[i]);
    sty.insert(y[i]);
  }
  sty.insert(INF+1);

  int idx = 0;
  for(auto &e: stx) {
    ztx[e] = idx;
    idx++;
  }

  int idy = 0;
  for(auto &e: sty) {
    zty[e] = idy;
    idy++;
  }

  vector<P> v1;
  for(int i=0;i<n;++i) {
    v1.push_back({ztx[x[i]], zty[y[i]]});
    //cout << v1[i].first << " " << v1[i].second << endl;
  }
  sort(v1.begin(), v1.end());


  vi a1(n), a2(n), a3(n), a4(n);
  BIT bit1(n+2), bit2(n+2);
  for(int i=0;i<n;++i) {
    
    a2[i] = bit1.sum(v1[i].second);
    a1[i] = bit1.sum(zty[INF+1]) - bit1.sum(v1[i].second);
    bit1.add(v1[i].second, 1);
    //printv(bit1.node);
  }
  for(int i=n-1;i>=0;--i) {
    a4[i] = bit2.sum(v1[i].second);
    a3[i] = bit2.sum(zty[INF+1]) - bit2.sum(v1[i].second);
    bit2.add(v1[i].second, 1);
  }
/*   printv(a1);
  printv(a2);
  printv(a3);
  printv(a4); */
  
  map<int, bool> ok;
  ok[6] = true;
  ok[7] = true;
  ok[9] = true;
  ok[11] = true;
  ok[13] = true;
  ok[14] = true;
  ok[15] = true;

  ll ans = 0;
  for(int i=0;i<n;++i) {
    ans += mod_pow<ll>(2, n-1, MOD);
    ans %= MOD;
    for(int j=0;j<(1<<4);++j) {
      if(!ok[j]) continue;
      ll tmp = 1;
      if((j>>0)&1) {
        tmp *= (mod_pow<ll>(2, a1[i], MOD) + MOD - 1) % MOD;
        tmp %= MOD;
      }
      if((j>>1)&1) {
        tmp *= (mod_pow<ll>(2, a2[i], MOD) + MOD - 1) % MOD;
        tmp %= MOD;
      }
      if((j>>2)&1) {
        tmp *= (mod_pow<ll>(2, a3[i], MOD) + MOD - 1) % MOD;
        tmp %= MOD;
      }
      if((j>>3)&1) {
        tmp *= (mod_pow<ll>(2, a4[i], MOD) + MOD - 1) % MOD;
        tmp %= MOD;
      }
      ans += tmp;
      ans %= MOD;
    }
    
  }
  cout << ans << endl;

}


Measured memory_bytes: 45552
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using TP = tuple<int,int,int,int>;

void dfs(vector<int> v, const int& pre, const int& n, const int& m, const vector<TP>& abcd, int& ans) {
    if (v.size() >= n) {
        int cnt = 0;
        for (auto [a,b,c,d] : abcd) {
            if (v[b-1] - v[a-1] == c) cnt+=d;
        }
        ans = max(ans, cnt);
        return;
    }

    for (int i=pre; i<=m; i++) {
        v.push_back(i);
        dfs(v,i,n,m, abcd,ans);
        v.pop_back();
    }
}

int main() {
    int n,m,q;
    cin >> n >> m >> q;

    vector<TP> abcd;
    for (int i=0; i<q; i++) {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        abcd.emplace_back(a,b,c,d);
    }

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

    vector v = {1};
    int ans = 0;
    dfs(v,1,n,m, abcd, ans);

    cout << ans << endl;
}

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

signed main() {
  string s;
  cin >> s;

  int N = s.size();
  vector<int> l(N, 0), r(N, 0), ans(N, 0);

  int cnt_R = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (s[i] == 'R') {
      cnt_R++;
    } else {
      cnt_R = 0;
    }
    r[i] = cnt_R;
  }

  int cnt_L = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'L') {
      cnt_L++;
    } else {
      cnt_L = 0;
    }
    l[i] = cnt_L;
  }

  for (int i = 0; i < N; i++) {
    if (s[i] == 'R') {
      ans[i + r[i] - r[i] % 2]++;
    } else if (s[i] == 'L') {
      ans[i - l[i] + l[i] % 2]++;
    }
  }

  for (int i = 0; i < N; i++) {
    if (i != 0) {
      cout << " ";
    }
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
#define MAX 1000000000
pair<int,int> Array[1005];
int dp[10005];

int main(){
    int H , N , i , j;
    scanf( "%d%d" , &H , &N );

    for( i = 1 ; i <= N ; ++i )
        scanf( "%d%d" , &Array[i].first , &Array[i].second );
    
    for( i = 1 ; i <= H ; ++i ){
        dp[i] = MAX;

        for( j = 1 ; j <= N ; ++j ){
            if( i - Array[j].first <= 0 ) dp[i] = min( dp[i] , Array[j].second );
            else dp[i] = min( dp[i] , Array[j].second + dp[i - Array[j].first] );
        }
    }

    printf( "%d\n" , dp[H] );
    return 0;
}

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

d = {}
for a in A:
    d.setdefault(a, 0)
    d[a] += 1
#print(d)

A = sorted(set(A))
#print(A)
t = [True] * (10 ** 6 + 1)
for a in A:
    if d[a] != 1:
        t[a] = False
    for i in range(a + a, 10 ** 6 + 1, a):
        t[i] = False
print(sum(1 for a in A if t[a]))

Measured memory_bytes: 44436
import numpy as np
n = int(input())
A = [0]+list(map(int, input().split()))+[0]
a = []
for i in range(n+1):
    a.append(abs(A[i]-A[i+1]))
ans = sum(a)
for i in range(i):
    print(ans-a[i]-a[i+1]+abs(A[i]-A[i+2]))

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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define pf push_front
#define pb push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int n;
  cin >> n;
  int l[n * 2];
  int cnt = 0;

  rep(i, n * 2) cin >> l[i];
  sort(l, l + n * 2);
  for (int i = 0; i < n * 2; i += 2) cnt += min(l[i], l[i + 1]);

  cout << cnt << endl;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    cin >> n;

    std::cout << 800*n - 200*(n/15) << '\n';

    return 0;
}


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

int main(){
	std::array<char, 20>str;
	
	for(int i=0; i<20; ++i){
		std::cin >> str[i];
	}
	
	for(int i=str.size()-1; i>=0; --i){
		std::cout << str[i];
	}
	std::cout << std::endl;
	
	return 0;
}

Measured memory_bytes: 1132
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>

using namespace std;


int main()
{
    int n,m;
    vector<string> s, t;
    string str;
    set<string> a;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> str;
        a.insert(str);
        s.push_back(str);
    }
    cin >> m;
    for(int i=0;i<m;i++)
    {
        cin >> str;
        a.insert(str);
        t.push_back(str);
    }
    int max_yen = 0;
    for(set<string>::iterator i=a.begin(); i!=a.end(); i++)
    {
        int yen = 0;
        for(int j=0;j<s.size();j++)
            if(s[j]==*i)
                yen++;
        for(int j=0;j<t.size();j++)
            if(t[j]==*i)
                yen--;
        if(yen > max_yen)
            max_yen = yen;
    }
    cout << max_yen;
    return 0;
}


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

using namespace std;

int main()
{
  
  int x,n;cin >> x>> n;set<int> st;
  while(n--)
  {
      int i;
      cin>>i;
      st.insert(i);
  }
  int ans = 0;int dmin = 0x3f3f3f3f;
  for(int i = 0;i <= 101;i++)
  {
	if(dmin > abs(i - x) &&st.count(i) == 0)
    {
      dmin = abs(i-x);
      ans = i;
    }
  }
  cout <<ans;
  return 0;
}
    


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    vv<int> c(3, v<int>(3, 0));

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }

    for (int a0 = -500; a0 < 500; a0++)
    {
        int b0 = c[0][0] - a0;
        int b1 = c[1][0] - a0;
        int b2 = c[2][0] - a0;

        int a1_1 = c[0][1] - b0;
        int a2_1 = c[0][2] - b0;
        int a1_2 = c[1][1] - b1;
        int a2_2 = c[1][2] - b1;
        int a1_3 = c[2][1] - b2;
        int a2_3 = c[2][2] - b2;

        if (a1_1 == a1_2 && a1_2 == a1_3 && a1_3 == a1_1 && a2_1 == a2_2 && a2_2 == a2_3 && a2_3 == a2_1)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>n;
    vi p(n);
    int cnt=0;
    cin>p;
    REP(i,n-2){
        if((p[i]<p[i+1] && p[i+1]<p[i+2]) || (p[i]>p[i+1] && p[i+1]>p[i+2]))cnt++;
    }
    cout<cnt<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;

int main(){
    unsigned long long N;
    cin >> N;
    unsigned long long A[200000], B[200000];
    unsigned long long tmp;
    for(int i=0;i<N;i++){
        cin >> tmp;
        A[i] = tmp;
        B[i] = tmp;
    }
    //memcpy(B, A, sizeof(unsigned long) * N);

    //昇順ソート
    sort(B, B+N);

    int flag = 0, count = 0;
    unsigned long long num, center;
    center = N/2 - 1;

    //i=1~N(A[0]~A[N-1])
    for(int i=0;i<N;i++){
        if(B[center] < A[i])
            num = B[center];
        else
            num = B[center + 1];

        cout << num << endl;
    }

    return 0;
}

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

const int Max_n = 103;
int F[Max_n][10];
int P[Max_n][10];

int main(){
    int N;
    long long ans = -1000000000000;
    cin >> N;

    for(int i =0; i < N; i++){
        for(int j=0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i =0; i < N; i++){
        for(int j=0; j <= 10; j++){
            cin >> P[i][j];
        }
    }
    for(int i =1; i < 1024; i++){
        int state = i;
        int c[N];
        for(int n=0; n < N; n++) c[n]=0;
        
        long long temp_ans = 0;
        for(int j=0; j < 10; j++){
            if((state %2) == 1){
                for(int n =0; n < N; n++){
                    c[n] += F[n][j];
                }
            }
            state /= 2;
        }
        for(int n=0; n < N; n++){
            temp_ans += P[n][c[n]];
        }
        ans = max(ans, temp_ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main (){
	char S[10];
	scanf("%s", S);
	for(int i = 0; S[i + 1]; ++i){
		if(S[i] == 'A' && S[i + 1] == 'C'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 3644
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

template <class T> std::vector<T> enum_div(const T &n) {
  std::vector<T> ret;
  T i = static_cast<T>(1);
  while (i * i < n) {
    if (n % i == static_cast<T>(0)) {
      ret.push_back(i);
      ret.push_back(n / i);
    }
    ++i;
  }
  if (i * i == n) {
    ret.push_back(i);
  }
  std::sort(ret.begin(), ret.end());
  ret.shrink_to_fit();
  return std::move(ret);
}

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

  ll n, m;
  cin >> n >> m;

  vector<ll> yakusu = enum_div(m);
  ll ans = 0;
  for(auto i : yakusu){
    if(i <= (m/n)){
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	String S;
	String[] split;
	Character[][] board;
	int a,b,c,d;
	public void solve() {
		while(true){
			S = next();

			if(S.equals("#"))break;

			split = S.split("/");
			a = nextInt() - 1;
			b = nextInt() - 1;
			c = nextInt() - 1;
			d = nextInt() - 1;

			board = new Character[split.length][];
			for(int i = 0;i < split.length;i++){
				char[] chars = split[i].toCharArray();
				ArrayList<Character> list = new ArrayList<Character>();
				for(char c : chars){
					if(c == 'b'){
						list.add('b');
					}else{
						for(int j = 0;j < c - '0';j++){
							list.add('.');
						}
					}
				}
				board[i] = (Character[])list.toArray(new Character[0]);
			}

			board[a][b] = '.';
			board[c][d] = 'b';

			StringBuilder sb = new StringBuilder();
			for(int i = 0;i < split.length;i++){
				if(i != 0)sb.append("/");
				int j = 0;
				for(;j < board[i].length;){
					if(board[i][j] == 'b'){
						sb.append(board[i][j]);
						j++;
					}else{
						int cnt = 0;
						while(j < board[i].length && board[i][j] == '.'){
							cnt++;
							j++;
						}
						sb.append(cnt);
					}
				}
			}
			out.println(sb);
		}
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

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

int main() {
	long long n = 50, k, a[50];
	cin >> k;
	for (int i = 0; i < n; i++) {
		a[i] = n - 1 + k / n;
	}
	k %= n;
	for (int i = 0; i < k % n; i++) {
		a[i] += n - k + 1;
	}
	for (int i = k % n; i < n; i++) {
		a[i] -= k;
	}
	cout << n << endl;
	for (auto&& x : a)cout << x << ' ';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

w, h, x, y = gets.chomp.split(/ /).map(&:to_i)

menseki = w.to_f * h.to_f / 2.0
ans = 0
if ((w.to_f / 2.0) == x.to_f && (h.to_f / 2.0) == y.to_f)
  ans = 1
end
print menseki
print " "
puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define MAX_N 1002
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<P1,ll> P2;
typedef pair<double,int> Pdi;
const ll INF=100000000000000001;
int dp1[MAX_N][MAX_N]={};
int dp2[MAX_N][MAX_N]={};
bool d[MAX_N]={};
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
priority_queue<Pdi,vector<Pdi>,greater<Pdi>> que;
vector<P1> v;
P2 xy[MAX_N]={};

double calc(int xx1,int xx2,int yy1,int yy2){
	double f=pow((double)xx1-(double)xx2,2)+pow((double)yy1-(double)yy2,2);
	return pow(f,0.5);
}
int main() {
	int h,w;
	cin>>h>>w;
	rep(i,h*w){
		string s;
		cin>>s;
		if(s=="snuke"){
			char c=i%w+'A';
			cout<<c<<i/w+1<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 30

void swap(int *, int *);

int main(void) {
    int i = 0, a, b, w, ary[MAX] = {};
    for(scanf("%d %*d", &w); i < w; ary[i] = -~i++);
    for(; ~scanf("%d%*c%d", &a, &b); swap(&ary[~-a], &ary[~-b]));
    for(i = 0; i < w; printf("%d\n", ary[i++]));
    return 0;
}

void swap(int *a, int *b) {
    *a ^= *b;
    *b ^= *a;
    *a ^= *b;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		String op = scanner.next();
		int b = scanner.nextInt();
		
		while (!op.equals("?")) {
			switch (op) {
				case "+":
					System.out.println(a + b);
					break;
				case "-":
					System.out.println(a - b);
					break;
				case "*":
					System.out.println(a * b);
					break;
				case "/":
					System.out.println(a / b);
					break;
			}
			
			a = scanner.nextInt();
			op = scanner.next();
			b = scanner.nextInt();
		}
	}
}



Measured memory_bytes: 26196
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> B(N);
	vector<int> T(N, 0);
	for (int i = 0; i < N; i++) {
		int t = A[i];
		B[i] = 0;
		while (t > 1) {
			if (t % 2 == 1) {
				T[i] = 1;
			}
			t /= 2;
			B[i]++;
		}
	}

	/*for (int i = 0; i < N; i++) {
		cerr << B[i] << " ";
	}
	cerr << endl;
	for (int i = 0; i < N; i++) {
		cerr << T[i] << " ";
	}
	cerr << endl;
*/
	int cur = 0;
	for (int i = 0; i < N; i++) {
		if (T[i] == 1) {
			if (cur <= B[i]) {
				res += abs(B[i] + 1 - cur);
				cur = B[i] + 1;
			}
			else {
				res += abs(B[i] - cur);
				cur = B[i];
			}
		}
		else {
			res += abs(B[i] - cur);
			cur = B[i];
		}
		//cerr << i << " " << cur << endl;

	}
	res += cur;
	//cerr << res << endl;
	res /= 2;
	cout << res << endl;
}

Measured memory_bytes: 2560
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
 
func arrayEqual(A []int, B []int, N int) bool {
	for i := 0; i < N; i++ {
		if A[i] != B[i] {
			return false
		}
	}
	return true
}
 
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
 
func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
 
	N, K := nextInt(), nextInt()
	A := make([]int, N+1)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}
 
	for k := 0; k < K; k++ {
		B := make([]int, N+1)
 
		for i := 0; i < N; i++ {
			B[max(i-A[i], 0)] += 1
			B[min(i+A[i]+1, N)] -= 1
		}
 
		for i := 0; i < N; i++ {
			B[i+1] += B[i]
		}
 
		if arrayEqual(A, B, N) {
			break
		}
 
		for i := 0; i < N; i++ {
			A[i] = B[i]
		}
		A = B
	}
 
	for i := 0; i < N; i++ {
		fmt.Fprintf(out, "%d ", A[i])
	}
}

Measured memory_bytes: 12980
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
  cin>>N>>K; 
  reps(i,2,1e+6){ 
    ll temp = 0, n=N; 
    while(n>0){ 
      temp += n%i; 
      n /= i; 
    } 
    if(temp == K){ 
      cout<<i<<endl;
      return 0; 
    } 
  } 
  ll ans = INF;
  Rreps(i,N/(1e+6) + 1, 1){ 
    if(K-i >= 0){ 
      ll rest = K - i; 
      if((N-rest)%i == 0 && (N-rest)/i > rest){ 
        ans = min(ans, (N-rest)/i); 
      } 
    } 
  } 
  if(K == N) ans = min(ans, N+1);
  cout<<(ans == INF ? -1 : ans)<<endl; 
}


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

using namespace std;
typedef long long ll;

int main()
{
  string s;
  ll k;
  cin >> s >> k;

  if (k == 1 || s.length() == 1 || s[0] != '1')
  {
    cout << s[0] << endl;
  }
  else
  {
    for (ll i = 1; i < k; i++)
    {
      if (s[i] != '1')
      {
        cout << s[i] << endl;
        return 0;
      }
    }

    cout << s[k - 1] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
 	int A, B;
	cin >> A >> B;
  
  	int nCoin = 0;
	for(int i = 0; i < 2; ++ i)
    {
    	if(A > B){
        	nCoin += A;
          	-- A;
        }else{
      		nCoin += B;
      		-- B;
	    }
    }
  
  	cout << nCoin;
	return 0; 
}

Measured memory_bytes: 256
import itertools
n = int(input())
xy = [[int(i) for i in input().split()] for _ in [0]*n]
it = list(itertools.permutations(xy, n))
ans = 0
for i in it:
    for j in range(len(list(i))-1):
        ans += ((i[j][0] - i[j+1][0])**2 + (i[j][1] - i[j+1][1])**2)**0.5
print(ans/len(it))

Measured memory_bytes: 8180
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] p = new int[n];
		for (int i=0; i<n; i++) {
			p[i] = sc.nextInt();
		}

		int max = p[0];
		int index = 0;
		for (int i = 0; i < n; i++) {
			if (p[i] > max) {
				max = p[i];
				index = i;
			}
		}

		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (i == index) {
				sum += p[i]/2;
				continue;
			}

			sum += p[i];
		}

		System.out.println(sum);
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long
#define W V<L>
#define R(n)for(L i;i<n;i++){
L E=70;W S(V<W>p){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}R(2)L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=Q+1;}if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p);A[0]--;return A;}int main(){L M=2e17,n,a,b;cin>>n;V<W>p(n);R(n)cin>>a>>b;p[i]={a+M,b+M};}W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

Measured memory_bytes: 62908
#include<stdio.h>
#define INF -1000000000000000000
#define ll long long

int main() {
  int n, m, f;
  int i, j;
  ll score[1010] = {};
  scanf("%d %d", &n, &m);
  ll a[2010] = {};
  ll b[2010] = {};
  ll c[2010] = {};
  for (i = 1; i < m+1; i++) {
    scanf("%lld %lld %lld", &a[i], &b[i], &c[i]);
  }
  for (i = 2; i < n+1; i++) {
    score[i] = INF;
  }
  for (i = 1; i < n+1; i++) {
    f = 0;
    for (j = 1; j < m+1; j++) {
      int from = a[j];
      int to = b[j];
      /*基本的に、修正が入ったらf=1
        i==n(n steps目)の時だけは、ゴールに達する修正だけがf=1*/
      if (score[to] < score[from] + c[j]) {
	score[to] = score[from] + c[j];
	if (i >= n) {
	  if (b[j] == n) {
	    f = 1;
	  }
	} else {
	  f = 1;
	}
      }
    }
    /*修正が入らなくなれば(f==0)そこで終わり*/
    if (f == 0) {
      break;
    }
    /*修正が入り続け、最後もゴール以外の修正が起こればinf*/
    if (i == n) {
      printf("inf\n");
      return 0;
    }
  } 
  printf("%lld\n", score[n]);
  return 0;
}
  
  
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  int a = n/100;
  int b = n - 100*a;
  double c = (double)b/(double)a;
  if(c <= 5){cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  

}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = input()
T = input()


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x * y // gcd(x, y)


n_lcm = lcm(len(S), len(T))
gcd_nm = gcd(N, M)

s_step = N // gcd_nm
t_step = M // gcd_nm

for i in range(gcd_nm):
    if S[i * N // gcd_nm] != T[i * M // gcd_nm]:
        print(-1)
        exit()
print(n_lcm)



Measured memory_bytes: 9284
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int N, L;
	cin >> N >> L;

	int sum = 0;
	int abs_min = 1e9;
	int eat_taste = 0;
	for (int i = 1; i <= N; i++) {
		int taste = L + i - 1;
		sum += taste;
		if (abs_min > abs(taste)) {
			abs_min = abs(taste);
			eat_taste = taste;
		}
	}

	int ans = sum - eat_taste;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100010];
int main()
{
	int i,qz,nn,rt,n;
	scanf("%s",s+1);n=strlen(s+1);
	if(s[n]=='1'||s[1]=='0'){printf("-1");return 0;}
	for(i=1;i<n;i++)
	{
		if(s[i]!=s[n-i]){printf("-1");return 0;}
	}
	if(n%2==0)nn=n/2;
	else nn=n/2+1;
	qz=0;for(i=1;i<=nn;i++)if(s[i]=='1')qz++;else break;
	for(i=2;i<=nn;i++)if(s[i]=='1')printf("%d %d\n",i-1,i);else break;
	rt=qz;
	for(i=qz+1;i<=nn;i++)
	{
		if(s[i]=='0')
		{
			if(s[i-1]=='1')
			{
				printf("%d %d\n",rt,i);
				rt=i;
			}
			else
			{
				printf("%d %d\n",rt,i);
			}
		}
		else
		{
			if(s[i-1]=='0')
			{
				printf("%d %d\n",rt,i);
			}
			else
			{
				printf("%d %d\n",rt,i);
				rt=i;
			}
		}
	}
	if(s[nn]=='0')
	{
		for(i=nn+1;i<=n;i++)printf("%d %d\n",rt,i);
	}
	else
	{
		printf("%d %d\n",rt,nn+1);
		for(i=nn+2;i<=n;i++)printf("%d %d\n",nn+1,i);
	}
	return 0;
}

Measured memory_bytes: 1536
float f;
int a[7];
main(n,i){
  for(scanf("%d",&n);n--;a[i]++)
    scanf("%f",&f),i=f<165?1:f<170?2:f<175?3:f<180?4:f<185?5:6;
  for(i=1;i<7;puts(""),i++)
    for(printf("%d:",i);a[i]--;putchar('*'));
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	double e;

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

	c = a / b;
	d = a % b;
	e = (double)a / b;
	printf("%d %d %.5f",c,d,e);

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;


int main() {
	vector<int> a(100,0);
	int n,ans=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	sort(a.rbegin(), a.rend());
	

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			ans += a[i];
		}
		else {
			ans -= a[i];
		}
}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>

int main(){
    long x[5];
    std::cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for(long i=0; i<5; i++){
        if(x[i]==0){
            std::cout << i+1 << std::endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

// int n; 

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	char c;
	cin>>c;
	if(islower(c)) cout<<'a'<<endl;
	else cout<<'A'<<endl;
	return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((ll)2e5+5)
#define MOD ((ll)1e9 + 7)
#define INF ((ll)1e9 + 9)
#define prime 37
#define prime2 101
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<ll,ll>
#define mid ((l+r)/2)

string s;
ll n;
vector <ll> h;
ll p_[MAXN];
ll invp[MAXN];

vector <ll> h2;
ll p2_[MAXN];
ll invp2[MAXN];

ll C(char c)
{
	return (c - 'a');
}

ll M(ll a)
{
	return a%MOD;
}

void mul(ll& a,ll b)
{
	a *= b;
	a%=MOD;
}
ll modInverse(ll a)
{
	ll m = MOD;
	ll y = 0, x = 1;
	if (m == 1)
		return 0;
	while (a > 1)
	{
		ll q = a / m;
		ll t = m;
		m = a % m, a = t;
		t = y;
		y = x - q * y;
		x = t;
	}
	if (x < 0)
		x += MOD;
	return x;
}
void setup()
{
	h[0] = C(s[0]) % MOD;
	ll p = 1;
	p_[0] = 1;
	invp[0] = 1;
	for (ll i = 1; i < n; ++i)
	{
		h[i] = M(h[i-1] + M(p * C(s[i])));
		mul(p,prime);
		p_[i] = p;
		invp[i] = modInverse(p_[i]);
	}
}

void setup2()
{
	h2[0] = C(s[0]) % MOD;
	ll p2 = 1;
	p2_[0] = 1;
	invp2[0] = 1;
	for (ll i = 1; i < n; ++i)
	{
		h2[i] = M(h2[i-1] + M(p2 * C(s[i])));
		mul(p2,prime2);
		p2_[i] = p2;
		invp2[i] = modInverse(p2_[i]);
	}
}

ll ext(ll l, ll r)
{
	if(l)
		return M(M(h[r] - h[l-1] + MOD) * invp[l-1]);

	return M(h[r]);
}

ll ext2(ll l, ll r)
{
	if(l)
		return M(M(h2[r] - h2[l-1] + MOD) * invp2[l-1]);

	return M(h2[r]);
}


bool check(ll sz)
{
	if(sz == 0) return true;
	map <pair<ll,ll>,vector<ll>> mp;

	for (ll i = 1; i < n-sz+1; ++i)
	{// l : i  , r : i+sz-1
		// cout << i _ sz _ ext(i,i+sz-1) << endl;
		// TRACE2(ext(i,i+sz-1),ext2(i,i+sz-1));
		mp[{ext(i,i+sz-1),ext2(i,i+sz-1)}].pb(i);
	}

	for (auto i : mp)
	{
		if(i.second.back() - i.second.front() >= sz)
			return true;
	}

	return false;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> s;
	s = '#' + s;
	n = n+1;
	h.resize(n);
	h2.resize(n);
	setup();
	setup2();
	

	// TRACE(n);
	// for (ll i = 0; i < n; ++i)
	// 	TRACE2(i, h[i]);

	// return 0;
	ll l = 0;
	ll r = n/2;
	ll result = 0;

	TRACE(check(2));

	// return 0;
	while(l <= r)
	{
		TRACE2(l,r);
	
		if(check(mid))
		{
			result = mid;
			l = mid+1;
		}
		else
		{
			r = mid-1;
		}
	}

	cout << result << endl;
}

Measured memory_bytes: 5120
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[100002];
int main()
{
	ll n,m,sum=0,c=0;
	cin>>n>>m;

	forn(i,m){
		ll b;
		string s;
		cin>>b>>s;
		if(a[b]==-1) continue;
		if(s=="AC"){
			sum+=a[b];
			a[b]=-1;
			c++;
		}
		else a[b]++;
	}
	cout<<c<<" "<<sum;
}

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

#define int				long long
#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )		FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )		(a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int N, M;
	while( cin >> N, N ) {
		P mato[300] = {};
		int dp[300] = {};

		int cnt = 0;
		REP( i, N ) {
			cin >> mato[cnt].first >> mato[cnt].second;
			cnt++;
		}
		cin >> M;
		REP( i, M ) {
			cin >> mato[cnt].first >> mato[cnt].second;
			cnt++;
		}

		sort( mato, mato + 300, greater<>() );

		REP( i, N + M ) {
			dp[i] = 1;
			REP( j, i ) {
				if( mato[j].first > mato[i].first && mato[j].second > mato[i].second ) {
					chmax( dp[i], dp[j] + 1 );
				}
			}
		}

		cout << dp[N + M -1] << endl;
	}
}



Measured memory_bytes: 3112
l,r = map(int, input().split())
if l//2019 != r//2019:
  print(0)
  exit(0)
l = l%2019
r = r%2019
a = 2019
for i in range(l,r+1):
  for j in range(l,i):
    a = min(a,(i*j)%2019)
    if a == 0:
      print(0)
      exit(0)
print(a)

Measured memory_bytes: 9112