akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

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

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() 
{
    int n;
    double d;
    cin>>n;
    cin>>d;
    vector<pair<double,double>> points(n);
    for(int i=0;i<n;i++)
    {
        cin>>points[i].first;
        cin>>points[i].second;
    }
    int count = 0;
    for(int i=0;i<n;i++)
    {
        if(d*d >= points[i].first*points[i].first + points[i].second*points[i].second)
        {
            count++;
        }
    }
    cout<<count<<'\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc=1; 
    //cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


Measured memory_bytes: 6424
#include<iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	if(N==4||N==7){cout<<"Yes"<<endl;
	return 0;}
	if(N%4==0||N%7==0||N%11==0){cout<<"Yes"<<endl;
	return 0;}
	for(int i=4;i<=100;i+=4){
		if(i==N){cout<<"Yes"<<endl;
		return 0;}
		for(int j=7;j<=100;j+=7){
			if(j==N&&i==4){cout<<"Yes"<<endl;
			return 0;}
			if(j+i==N){cout<<"Yes"<<endl;
			return 0;}
			for(int k=11;k<=100;k+=11){
			if(k==N&&i==4&&j==7){cout<<"Yes"<<endl;
			return 0;}
			if(j+k==N){cout<<"Yes"<<endl;
			return 0;}
			if(j+i+k==N){cout<<"Yes"<<endl;
			return 0;}
			if(k+i==N){cout<<"Yes"<<endl;
			return 0;}
		}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef long long ll;
#define IMF 1000000007

int main(void){
  int n;
  scanf("%d",&n);

  ll a[n];
  for(int i = 0;i < n;i ++){
    scanf("%lld",&a[i]);
  }

  ll ans = 0 , tas = 0;
  for(int i = 0;i < n;i ++){
    tas += a[i];
    tas %= IMF;
  }

  for(int i = 0;i < n-1;i ++){
    if(tas < a[i]){
      tas += IMF-a[i];
    }
    else{
      tas -= a[i];
    }
    ans += a[i]*tas;
    ans %= IMF;
  }
  

  printf("%lld\n",ans);

  return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  vector<int> X(H), Y(W);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A.at(i).at(j) == '#') X.at(i)++;
    }
  }
  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if (A.at(i).at(j) == '#') Y.at(j)++;
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (X.at(i) != 0) {
      for (int j = 0; j < W; j++) {
        if (Y.at(j) != 0) cout << A.at(i).at(j);
      }
      cout << endl;
    }
  }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  VL a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  sort(rall(a)); sort(rall(b)); sort(rall(c));
  VL tmp;
  rep(i, min(x, k)) rep(j, min(y, k)) {
    tmp.push_back(a[i] + b[j]);
  }
  sort(rall(tmp));
  VL tmp2;
  int s = min<ll>(k, tmp.size());
  rep(i, s) rep(j, min(k, z)) {
    tmp2.push_back(tmp[i] + c[j]);
  }
  sort(rall(tmp2));
  rep(i, k) out(tmp2[i]);


  return 0;
}


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

using namespace std;

int a[10];

int main()
{

	string s;
	cin >> s;

	if (s[0] == s[1] && s[1] == s[2]) {
                cout << "Yes";
                return 0;
	}
	if (s[1] == s[2] && s[2] == s[3]) {
                cout << "Yes";
                return 0;
	}

        cout << "No";

}


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

int main() {
    int N;
    double xi = 0.0;
    double sum = 0.0;
    char ui[5];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> xi >> ui;
        if (strcmp(ui, "JPY") == 0) sum += xi;
        else sum += xi * 380000.0;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
inputlist = list(map(int, input().split()))

a = inputlist[0]
b = inputlist[1]
c = inputlist[2]

oishii = b + c
gedoku = a + b
doku = c

if doku - gedoku > 1 :
    tabereru_doku = gedoku + 1
else :
    tabereru_doku = doku

tabereta_doku = tabereru_doku

print(tabereta_doku + b)


Measured memory_bytes: 3060
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
  s = str(input())
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  else:
    re += 1
    
print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)

Measured memory_bytes: 9204
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int n;
	cin >> n;
	long double hoge = 0;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		hoge += (long double)(1.0 / (long double)tmp);
	}
	cout << (long double)(1 / hoge);
}


Measured memory_bytes: 31488
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main(){

		while(1){
			int N,M,E=0;
			cin >> N>>M;
			if(N==0 &&M ==0) break;
			vector<pair<int,int> > data(N);
			for(int i = 0; i< N; i++) {
				cin >> data[i].second;//distance
				cin >> data[i].first;//P
			}
		sort(data.begin(),data.end());//sort by P
		int k,flag=0 ;
		for(int j = N-1;j>=0;j--){
				M -= data[j].second;
				if(M<=0){
					k = j;
					M+=data[j].second;
					break;
				}
				if(j ==0){
					k = 0;
					flag =1;
				}
			}
		for(int m = 0;m <k;m++){
			E +=data[m].first * data[m].second;
		}
		if(flag !=1){
			E += data[k].first * (data[k].second-M);
		} 
		cout << E <<endl;
		}


		return 0;
}

Measured memory_bytes: 1276
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, A: "List[int]"):
    ans = [0]*N
    for i in range(N):
        ans[A[i]-1]=str(i+1)
    print(" ".join(ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31504
#include <iostream>
#include <vector>
#include <set>
#include <cassert>

#define int long long
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    set<pair<int, int>> t;
    for (int i = 0; i < n; ++i)
        t.insert({b[i], i});
    long long ans = 0;
    while (!t.empty()) {
        auto now = --t.end();
        int pos = now->second;
        t.erase(now);
        int f = (pos - 1 + n) % n, s = (pos + 1) % n;
        if (b[pos] == a[pos])
            continue;
        if (b[pos] - b[f] - b[s] < a[pos]) {
            cout << -1 << endl;
            return 0;
        }
        int del1 = b[pos] - a[pos];
        int del2 = b[pos] - max(b[f], b[s]);
        int minus = b[f] + b[s];
        int nw = min(del1 / minus, (del2 + minus - 1) / minus);
        ans += nw;
        b[pos] -= nw * minus;
        if (b[pos] != a[pos])
            t.insert({b[pos], pos});
        assert(b[pos] >= a[pos]);
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)



int main() {
	ll M1, D1, M2, D2;
	cin >> M1 >> D1 >> M2 >> D2;
	if (M1 != M2) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

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

class Main {

	void solve() {

		int n = inint();
		if (n%2 == 0) out.println(n);
		else out.println(2*n);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	vs ss;
	ll k;
	cin >> s >> k;
	ll n=s.length();
	for(ll i=0;i<n;i++){
		for(ll j=1;j<=min(n-i,k);j++){
			string tmp="";
			for(ll k=0;k<j;k++){
				tmp+=s[i+k];
			}
			ss.pb(tmp);
		}
	}
	sort(all(ss));
	Eunique(ss);
	cout << ss[k-1] << endl;
	return 0;
}


Measured memory_bytes: 1660
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    int N;
    int a;
    int table[8] = {1, 2, 6, 24, 120, 720, 5040, 40320};
    int p, q;
    int it;
    vector<int> num1, num2;
    int ans;

    cin >> N;

    for(int i = 0; i < N; i++){
        num1.push_back(i+1);
        num2.push_back(i+1);
    }
    p = 0;
    for(int i = 0; i < N - 1; i++){
        cin >> a;
        it = 0;
        for(int j = 0; j < N - i; j++){
            if(num1[j] != a){
                it++;
            }else{
                break;
            }
        }
        p += table[N - i - 2] * it;
        num1.erase(num1.begin() + it);
    }cin >> a;
    q = 0;
    for(int i = 0; i < N - 1; i++){
        cin >> a;
        it = 0;
        for(int j = 0; j < N - i; j++){
            if(num2[j] != a){
                it++;
            }else{
                break;
            }
        }
        q += table[N - i - 2] * it;
        num2.erase(num2.begin() + it);
    }cin >> a;

    if(p > q){
        ans = p - q;
    }else{
        ans = q - p;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

/**
 * C - Otoshidama
 */
public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Y = sc.nextInt();
    int res10000 = -1, res5000 = -1, res1000 = -1;

    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= N - i; j++) {
        int cntRest = N - i - j; 
        // 残りのお札は全部1000円だから、3重ループしなくても金額が分かる
        int total = 10000 * i + 5000 * j + 1000 * cntRest;
        if (total == Y) {
          res10000 = i;
          res5000 = j;
          res1000 = cntRest;
        }
      }
    }

    System.out.println(res10000 + " " + res5000 + " " + res1000);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

    int a,b,c;
    cin >> a >> b >> c;
    
    if(a!=b || b!=c || c!=a){
        cout << "No";
        return 0;
    }
    cout << "Yes";
	return 0;
}

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

int main() {
    int a, b;  cin >> a >> b;
    printf("%d %d %lf\n", a/b, a%b, (double)a/b);
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  long long n,k,h[200001],ans=0;
  cin>>n>>k;
  rep(i,n) cin>>h[i];
  sort(h,h+n);
  rep(i,n-k) ans+=h[i];
  cout<<ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define NB 100001
int abs(int a) {
	if(a<0) return -a;
	return a;
}

int pos[NB][3];
int posmax[NB][3];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 3; ++j) {
			cin>>pos[i][j];
		}
	}
	for(int j = 0; j < 3; ++j) {
		posmax[0][j] = pos[0][j];
	}
	for(int i = 0; i < n - 1; ++i) {
		for(int j = 0; j < 3; ++j) {
			int m = -1;
			for(int k = 0; k < 3; ++k) {
				if(k != j) m = max(m, posmax[i][k]);
			}
			posmax[i+1][j] = pos[i+1][j] + m;
		}
	}
	int m = -1;
	for(int j = 0; j < 3; ++j) {
		m = max(m, posmax[n-1][j]);
	}
	cout<<m<<"\n";
	return 0;
}


Measured memory_bytes: 5996
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define MAX_N 50
using namespace std;

int main() {
  int n, m, sum;
  scanf("%d", &n);
  m=n;
  sum=0;
  while(m){
    sum+=m%10;
    m/=10;
  }
  printf("%s\n", n%sum?"No":"Yes");
  return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;



int main() {

	int n;
	cin >> n;
	VI a(n);
	REP(i, n)cin >> a[i];

	if (a[0] != 0) {
		cout << -1 << endl;
		return 0;
	}

	REP(i, n - 1) {
		if (a[i + 1] - a[i] >= 2) {
			cout << -1 << endl;
			return 0;
		}
	}
	REP(i, n) {
		if (a[i] > i) {
			cout << -1 << endl;
			return 0;
		}
	}

	if (n == 2) {
		cout << a[1] << endl;
		return 0;
	}


	ll ans = a[n - 1];


	REP(i, n - 1) {
		if (a[i] + 1 == a[i + 1])continue;
		ans += a[i];
	}



	cout << ans << endl;




	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> p(n);
    for(int i = 0;i < n;i++)cin >> p[i].first >> p[i].second;
    ll res = 0;
    
    vector<ll> a(n);
    for(int i = 0;i < n;i++)a[i] = p[i].first + p[i].second;
    sort(a.begin(),a.end());
    vector<ll> b(n);
    for(int i = 0;i < n;i++)b[i] = -1 * (a[i]);
    sort(b.begin(),b.end());
    res = max(res,a[n - 1] + b[n - 1]);

    vector<ll> c(n);
    for(int i = 0;i < n;i++)c[i] = p[i].first - p[i].second;
    sort(c.begin(),c.end());
    vector<ll> d(n);
    for(int i = 0;i < n;i++)d[i] = -1 * (c[i]);
    sort(d.begin(),d.end());
    res = max(res,c[n - 1] + d[n - 1]);
    res = max(res,c[0] + d[n - 1]);
    res = max(res,c[n - 1] + d[0]);
    res = max(res,c[0] + d[0]);

    cout << res << endl;
}

Measured memory_bytes: 12684
import numpy as np
import itertools
n, m, x = list(map(int, input().split()))
c = np.array([list(map(int, input().split())) for _ in range(n)])
pre = np.arange(n)
l = []
rem = []
ans = 0
for i in pre + 1:
    for j in itertools.combinations(pre, i):
        l.append(list(j))
for i in range(1, m + 1):
    for j, k in enumerate(l):
        ca = 0
        for ii in k:
            ca += c[ii, i]
        if ca < x:
            rem.insert(0, j)
        else:
            pass
    if len(rem) > 0:
        for j in rem:
            l.pop(j)
        rem = []
    if len(l) == 0:
        print(-1)
        break
else:
    for i in l:
        ca = 0
        for j in i:
            ca += c[j, 0]
        if ans == 0:
            ans = ca
        else:
            ans = min(ans, ca)
    print(ans)

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

#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];
int right(int i){return 2*i + 1;};
int left(int i){return 2*i;};
void swap(int& a, int& b){
	int tmp = a;
	a = b;
	b = tmp;
}

void maxHeapify(int A[],int i) {
	int l = left(i), r = right(i);
	int maximum;
	if(l <=H && A[l] > A[i]) maximum = l;
	else maximum = i;
	if(r <=H && A[r] > A[maximum]) maximum = r;
	if(maximum != i){
		swap(A[maximum], A[i]);
		maxHeapify(A,maximum);
	}
}

int extract() {
	int maxv;
	if (H < 1) return -INFTY;
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(A,1);
	return maxv;
}

void increaseKey(int i, int key) {
	if(key < A[i]) return;
	A[i] = key;
	while( i > 1 && A[i/2] < A[i] ) {
		swap(A[i], A[i/2]);
		i/=2;
	}
}

void insert(int key) {
	H++;
	A[H] = -INFTY;
	increaseKey(H, key);
}

int main(){
	int key;
	char com[10];

	while (1) {
		scanf("%s", com);
		if( com[0] == 'e' && com[1] == 'n') break;
		if( com[0] == 'i') {
			scanf("%d", &key);
			insert(key);
		} else {
			printf("%d\n", extract());
		}
	}
	return 0;
}



Measured memory_bytes: 7112
from collections import deque
k = int(input())

Q = deque(range(1, 10)) #るんるん数を格納するキュー
# Q: 1 2 3 4 5 6 7 8 9

for i in range(k):
  x = Q.popleft()
  #x = 1 <--  Q: 2 3 4 5 6 7 8 9
  last_digit = x % 10 # 1 一番目の桁の値
  z = 10*x + last_digit #11

  if last_digit != 0:
    Q.append(z-1)
    # Q: 2 3 4 5 6 7 8 9 <--10
  Q.append(z)
  # Q: 2 3 4 5 6 7 8 9 10 <--11
  if last_digit != 9:
    Q.append(z+1)
    # Q: 2 3 4 5 6 7 8 9 10 11 <--12
print(x)

Measured memory_bytes: 11880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string t;
    cin >> t;

    ll ans = 2 * n;
    rep(i, n) {
        // cout << s.substr(i) << ' ' << t.substr(0, n - i) << endl;
        if(s.substr(i) == t.substr(0, n - i)) {
            // cout << n + i << endl;
            ans = min(ans, n + i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin


def main():
    M_1, D_1 = [int(x) for x in stdin.readline().rstrip().split()]
    M_2, D_2 = [int(x) for x in stdin.readline().rstrip().split()]

    if not M_1 == M_2:
        print(1)
    else:
        print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import itertools
N = int(input())
F, P = [], []
for _ in range(N):
    F.append(list(map(int, input().split())))
for _ in range(N):
    P.append(list(map(int, input().split())))
combinations = list(itertools.product((0, 1), repeat=10))[1:]
c = [0] * N
max_profit = -1000000001
for comb in combinations:
    profit = 0
    for i in range(N):
        c[i] = sum([F[i][jk] * comb[jk] for jk in range(10)])
        profit += P[i][c[i]]
    max_profit = max(max_profit, profit)
print(max_profit)

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

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

    sort(p, p + n);

    int cnt[3] = {0};
    for(int i = 0; i < n; i++)
    {
        if(p[i] <= a)
        {
            cnt[0]++;
        }

        if(p[i] >= a + 1 && p[i] <= b)
        {
            cnt[1]++;
        }

        if(p[i] >= b + 1)
        {
            cnt[2]++;
        }
    }

    sort(cnt, cnt + 3);

    cout << cnt[0] << endl;

    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $w);
$line1 = fgets(STDIN);
$line2 = fgets(STDIN);
$maxI = 0;
$maxSum = 0;

$nums1 = explode(" ", $line1);
$nums2 = explode(" ", $line2);
for($i = 0; $i < $w; $i++){
	$sum = 0;
	for($j = 0; $j < $w; $j++){
		if($j <= $i)$sum+=$nums1[$j];
		if($j >= $i)$sum+=$nums2[$j];
	}
	$maxSum = max($sum, $maxSum);
}
echo $maxSum;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<char> S(N);rep(i,N)cin >> S[i];
    bool P = false;
    bool W = false;
    bool G = false;
    bool Y = false;

    rep(i,N){
        char t = S[i];
        if(t =='P')P = true;
        if(t =='W')W = true;
        if(t =='G')G = true;
        if(t =='Y')Y = true;
    }

    int ct = 0;
    if(P)ct++;
    if(W)ct++;
    if(G)ct++;
    if(Y)ct++;

    if(ct == 3)cout << "Three" << endl;
    if(ct == 4)cout << "Four" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 100005, inf = 1e18, mod = 1e9+7;

ll n, m, s, t, d[2][N], c[2][N];
vector<pll> adj[N];
priority_queue<pll> pq;

void calc (ll I, ll S) {
	for(ll i=1;i<=n;i++) d[I][i] = inf;
	d[I][S] = 0; c[I][S] = 1;
	pq.push({0, S});
	while(!pq.empty()) {
		ll A, B; tie(A, B) = pq.top(); A *= -1; pq.pop();
		if(d[I][B] != A) continue;
		for(auto &T : adj[B]) {
			ll X, Y; tie(X, Y) = T;
			if(d[I][X] > A + Y) {
				d[I][X] = A + Y;
				c[I][X] = 0;
				pq.push({-A-Y,X});
			}
			if(d[I][X] == A + Y) {
				c[I][X] += c[I][B];
				c[I][X] %= mod;
			}
		}
	}
}

int main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&s,&t);
	for(ll i=1;i<=m;i++) {
		ll A, B, C;
		scanf("%lld%lld%lld",&A,&B,&C);
		adj[A].push_back({B, C});
		adj[B].push_back({A, C});
	}
	calc(0, s); calc(1, t);
	ll ans = c[0][t] * c[0][t] % mod;
	for(ll i=1;i<=n;i++) {
		if(d[0][i] + d[1][i] != d[0][t]) continue;
		if(d[0][i] == d[1][i]) ans = (ans + mod - c[0][i] * c[1][i] % mod * c[0][i] % mod * c[1][i] % mod) % mod;
		for(auto &T : adj[i]) {
			ll A, B; tie(A, B) = T;
			if(d[0][i] + B != d[0][A] || d[1][A] + B != d[1][i] || d[0][A] <= d[1][A] || d[1][i] <= d[0][i]) continue;
			ans = (ans + mod - c[0][i] * c[1][A] % mod * c[0][i] % mod * c[1][A] % mod) % mod;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 17392
#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <std::uint_fast64_t Modulus>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 a;

    constexpr ModInt(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator-(const ModInt rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator*(const ModInt rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator/(const ModInt rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

using mint = ModInt<MOD>;

long long modPow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }

    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

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

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

template <typename T>
using Vec = vector<T>;
template <typename T>
using VVec = vector<vector<T>>;
using i64 = long long;
int main() {
    i64 N, K;
    cin >> N >> K;
    i64 tmp = N % K;
    cout << min(tmp, abs(K - tmp)) << endl;
    return 0;
}

Measured memory_bytes: 256
n, m, Q = map(int, input().split())
lr = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    lr[l][r] += 1

rui = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, n + 1):
        rui[i][j] = lr[i][j] + rui[i - 1][j] + rui[i][j - 1] - rui[i - 1][j - 1]
    
for _ in range(Q):
    p, q = map(int, input().split())
    p -= 1
    ans = rui[q][q] - rui[p][q] - rui[q][p] + rui[p][p]
    print(ans)

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

int main(){
    int N, S=0;
    int tmp;
    int ans = 0;

    cin >> N;
    tmp = N;

    while (tmp != 0){
        S = S + tmp % 10;
        tmp = tmp / 10;
        }

    if (N % S == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char S[200005];
int main() {
	scanf("%s", S);
	int n = strlen(S);
	string t;
	auto solve = [](string s) {
		int m = s.size();
		int cnt = 0;
		ll ret = 0;
		for (char c : s) {
			if (c == 'X') ret += cnt;
			else {
				assert(c == 'A');
				cnt++;
			}
		}
		return ret;
	};
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		if (S[i] == 'B' && S[i + 1] != 'C') {
			ans += solve(t);
			t = "";
		} else if (S[i] == 'C') {
			ans += solve(t);
			t = "";
		} else if (S[i] == 'B' && S[i + 1] == 'C') {
			t += "X";
			++i;
		} else {
			t += 'A';
		}
	}
	ans += solve(t);
	printf("%lld\n", ans);
}


Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = (1e9) + 7;
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), T(N);
  REP(i, N) cin >> T[i];
  REP(i, N) cin >> A[i];
  if (N == 1) {
    if (T[0] != A[0]) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  for (int i = 1; i < N - 1; i++) {
    if (T[i] == T[i - 1] && A[i] == A[i + 1]) {
      ans *= min<ll>(A[i], T[i]);
      ans %= mod;
      continue;
    }
    if (T[i - 1] < T[i] && A[i + 1] < A[i]) {
      if (T[i] == A[i]) continue;
    }
    if (T[i - 1] < T[i]) {
      if (A[i] < T[i]) {
        ans = 0;
      }
    }
    if (A[i] > A[i + 1]) {
      if (A[i] > T[i]) {
        ans = 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4792
#include <stdio.h>

int main() {
    int n;

    do{
        scanf("%d", &n);
    }while(n<0 || n>100);


    int page;
    if (n%2 == 0) {
        page = n / 2;
    } else {
        page = n / 2 + 1;
    }

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

    return 0;
}


Measured memory_bytes: 2152
#include <stdio.h>
#define MAX(a,b) ((a) > (b) ? (a) : (b));
int countTree(int a,int b,int c,int d,int e[101][101]);


int main(){
	int N,H,W,S,T,x,y;
	int i,j;
	while(1){
		int maxNumber=0;
		scanf("%d",&N); if(N==0) break;
		scanf("%d%d",&W,&H);
		int map[101][101]={};
		for(i=0;i<N;i++){
			scanf("%d%d",&x,&y);
			map[y][x]=1;
		}
		scanf("%d%d",&S,&T);
		for(i=1;i<=H-T+1;i++){
			for(j=1;j<=W-S+1;j++) maxNumber=MAX(maxNumber,countTree(i,j,T,S,map));
		}
		printf("%d\n",maxNumber);
	}
	return 0;
}

int countTree(int a,int b,int c,int d,int e[101][101]){
	int k,l;
	int countSum=0;
	//printf("[%d,%d]",b,a);
	for(k=a;k<a+c;k++){
		for(l=b;l<b+d;l++){
		if(e[k][l]==1) countSum++;
		}
	}
	//printf("%d\n",countSum);
	return countSum;
}

Measured memory_bytes: 644
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if (n==1)
	{
		cout<<"Hello World"<<endl;
		return 0;
	}
	if (n==2)
	{
		long long a,b;
		cin>>a>>b;
		cout<<a+b;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define For(i,n) for(ll i=0; i<n; ++i)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define deb(x) cout<<"For debug : "<<x<<endl;
typedef long long ll;
#define ld long double

void solve()
{
    char x;
    cin>>x;
    if(x>='a' && x<='z') cout<<'a';
    else cout<<'A'<<endl;
}

int main(){
    optimize();
    ll T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

vector<ll> aa, pp;

ll f(ll n, ll x){
    if(n==0) return 1; //iru?
    if(x==1) return 0;
    if(2<=x && x<=aa[n-1]+1) return f(n-1, x-1);
    if(x == aa[n-1]+2) return pp[n-1]+1;
    if(aa[n-1]+3 <= x && x <= 2*aa[n-1]+2) return f(n-1, x-aa[n-1]-2)+1+pp[n-1];
    if(x >= 2*aa[n-1]+3) return pp[n-1]*2+1;
}

void init(ll n) {
    for(int i=1;i<=n;i++){
        aa[i] = aa[i-1]*2 + 3;
        pp[i] = pp[i-1]*2 + 1;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x; cin>>n>>x;
    aa.resize(n+1); pp.resize(n+1);
    aa[0] = 1; pp[0] = 1;
    init(n);
    ll ans = f(n, x); 
    cout << ans << endl;
}



Measured memory_bytes: 256
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    h, w = LI()
    grid = SRL(h)
    v = [[-1] * w for i in range(h)]
    v[0][0] = 1
    q = deque()
    q.append((1, 1))

    while q:
        i, j = q.popleft()
        grid[i - 1][j - 1] = "*"
        for x, y in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            if i + x < 1 or i + x > h or j + y < 1 or j + y > w or grid[i + x - 1][j + y - 1] != "." or v[i + x - 1][j + y - 1] > 0:
                continue
            v[i + x - 1][j + y -
                         1] = v[i - 1][j - 1] + 1
            q.append((i + x, j + y))

    if v[h-1][w-1] < 0:
        print(-1)
        return
    print(h*w-v[h-1][w-1]-list(chain.from_iterable(grid)).count("#"))


if __name__ == "__main__":
    main()


Measured memory_bytes: 74668
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
using namespace std;

int main(void){
  int A, B;
  cin >> A >> B;
  if(A==1)A = 14;
  if(B == 1)B = 14;
  cout << ((A<B)?"Bob":(A>B)?"Alice":"Draw") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int min = 0;
		int sum = 0;
		for(int i = 0; i < a; i++) {
			list.add(b);
			b++;
			sum += list.get(i);
		}
		min = list.get(0);
		for(int i = 0; i < list.size() - 1; i++) {
			if(Math.abs(list.get(i)) > Math.abs(list.get(i + 1))) {
				min = list.get(i + 1);
			}
		}
		System.out.println(sum - min);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int r=0;
    rep(i,s.size()) {
        if(s[i]=='R') r++;
    }
    if(r==2) {
        if(s[0]=='R'&&s[1]=='S'&&s[2]=='R') {
            cout << 1 << endl;
            return 0;
        }
        else{
            cout << r << endl;
            return 0;
        }
    } 
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

struct Edge
{
    int target;
    int id;
};

ll solve()
{
    int N, M;

    cin >> N >> M;

    string s;
    cin >> s;

    int counterOnes = 0;

    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] == '1')
        {
            ++counterOnes;
            if (counterOnes >= M)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        else
        {
            counterOnes = 0;
        }
    }

    stack<int> st;
    int index = s.length() - 1;

    while (index > 0)
    {
        for (int j = std::max(0, index - M); j < index; ++j)
        {
            if (s[j] == '1') continue;

            st.push(index - j);
            index = j;
            break;
        }
    }

    while (st.size() > 1)
    {
        cout << st.top() << " ";
        st.pop();
    }

    cout << st.top() << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 876
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x << endl, 0;
#define all(v) v.begin(),v.end()

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi( lli n, lli m=mod ){ 
    n%=m;
    n+=m;
    n%=m;
    return n;
}

lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

const lli MIN=-1*1e18;
const lli INF=1e18+999999999999999999;
const lli N=2e5+5;
const ldb pi=4*atan(1);

string sortString(string &str){
    lli i = 0, j = 0, k = 0;
    lli charCount[26] = {0};
    loop(i, 0, str.length())
        charCount[str[i] - 'a']++;
    loop(i, 0, 26){
        loop(j, 0, charCount[i]){
            str[k++] = char('a' + i);
        }
    }
    return str;
}

int32_t main(){
    fast_io
    lli i = 0,j = 0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout << fixed << setprecision(22);

    string s,t;
    cin >> s >> t;
    lli n=s.size();
    bool fl=1;
    loop(i,0,n){
        if(s[i]!=t[i]) fl=0;
    }

    if(fl) cout << "Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 3656
inf = 1 << 28
while 1:
    n = int(raw_input())
    if n == 0: break
    pt = [map(int,raw_input().split()) for i in xrange(n)]
    p = [0]+[ele[0] for ele in pt]
    t = [0]+[ele[1] for ele in pt]

    dp = [[inf]*4 for i in xrange(n+1)]
    dp[0][0] = 0
    
    for i in xrange(1,n+1):
        for j in xrange(1,4):
            if (j+1)*p[i-1]+p[i] <= t[i]-t[i-1]:
                dp[i][1] = min(dp[i][1], dp[i-1][j]+p[i-1]+p[i])
            if abs(p[i-1]-p[i])*j <= t[i]-t[i-1]:
                dp[i][j] = min(dp[i][j], dp[i-1][j-1]+abs(p[i-1]-p[i]))
        if min(dp[i]) == inf:
            print "NG",i
            break
    else:
        for j in xrange(1,4):
            dp[-1][j] += p[-1]
        print "OK",min(dp[n])

Measured memory_bytes: 4304
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  const int N = 50;
  vector<vector<int>> cnt(N,vector<int>(N));
  for (int i = 1; i <= n; i++) {
  	long double x ;
  	cin >> x;
  	long long a = (long long)(x * 1e9 + 0.5);
  	int n1 = 0,n2 = 0;
  	while (a % 2 == 0) {
  		a /= 2;
  		n1 += 1;
		}
		while (a % 5 == 0) {
			a /= 5;
			n2 += 1;
		}
		++cnt[n1][n2];
	}
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int ii = 0; ii < N; ii++) {
				for (int jj = 0; jj < N; jj++) {
					if (min(i + ii,j + jj) >= 18) {
						if (i != ii || j != jj) {
							ans += 1ll * cnt[i][j] * cnt[ii][jj];
						}
						else {
							ans += 1ll * cnt[i][j] * (cnt[i][j] - 1);
						}
					}
				}
			}
		}
	}
	cout << ans / 2;
} 

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


int main() {
  int N, a, b;
  cin >> N;
  if(N == 10){
    cout << 10 << endl;
    return 0;
  }
  int sum=0;
  while(true){
    sum += N%10;
    N = N/10;
    if(N == 10){
      sum = 10;
      break;
    }
    else if(N == 0){
      break;
    }
  }
    
  cout << sum << endl;    
}


Measured memory_bytes: 256