akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
using namespace std;

#define N 200002
int a[N],b[N];
void solve() {
  int n;scanf("%d",&n);
  for(int i=0;i<n;++i) {
    scanf("%d",&a[i]);
  }
  long long ret = 0;
  priority_queue<pair<int,int> >pq;
  for(int i=0;i<n;++i) {
    scanf("%d",&b[i]);
    if(a[i]>b[i]) {
      printf("-1\n");
      return;
    }
    pq.push(make_pair(b[i],i));
  }
  while(!pq.empty()) {
    int ind = pq.top().second;
    int val = b[ind];
    pq.pop();
    if(val==a[ind]) {
      continue;
    }
    int maxi = max(b[(ind+n-1)%n], b[(ind+1)%n]);
    maxi = max(maxi,a[ind]);
    int g = b[(ind+n-1)%n] + b[(ind+1)%n];
    int diff = val - maxi;
    if(b[ind]-g<a[ind]) {
      continue;
    }
    long long add = max(1,diff/g);
    long long tmp = b[ind] - add*g;
    if(tmp<a[ind]) {
      break;
    }
    b[ind] -= g*add;
    ret += add;
    pq.push(make_pair(b[ind],ind));
  }
  for(int i=0;i<n;++i) {
    if(a[i]!=b[i]) {
      ret = -1;
      break;
    }
  }
  printf("%lld\n", ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 3828
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Node {
  int y;
  int x;

  Node(int y = -1, int x = -1) {
    this->y = y;
    this->x = x;
  }
};

int main() {
  queue<Node> que;

  int H, W;
  cin >> H >> W;

  int a, b;
  int gridR[H][W];
  int diff[H][W];

  for (int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      cin >> a;

      gridR[y][x] = a;
    }
  }

  for (int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      cin >> b;

      diff[y][x] = abs(gridR[y][x] - b);
    }
  }

  int geta = 160 * 80 + 10;
  int limit = 2 * geta;
  bool dp[H][W][geta * 2];
  memset(dp, false, sizeof(dp));
  dp[0][0][0 + geta] = true;

  que.push(Node(0, 0));
  bool visited[H][W];
  memset(visited, false, sizeof(visited));

  int ans = 99999999;

  while (!que.empty()) {
    Node node = que.front();
    que.pop();
    int d = diff[node.y][node.x];

    if (visited[node.y][node.x]) {
      continue;
    }
    visited[node.y][node.x] = true;

    for (int i = 0; i < limit; ++i) {
      if (!dp[node.y][node.x][i]) continue;

      int v1 = i - d;
      int v2 = i + d;

      if (node.y + 1 < H) {
        dp[node.y + 1][node.x][v1] = true;
        dp[node.y + 1][node.x][v2] = true;
      }

      if (node.x + 1 < W) {
        dp[node.y][node.x + 1][v1] = true;
        dp[node.y][node.x + 1][v2] = true;
      }

      if (node.y == H - 1 && node.x == W - 1) {
        int a1 = abs(v1 - geta);
        int a2 = abs(v2 - geta);

        if (a1 < ans) {
          ans = a1;
        }
        if (a2 < ans) {
          ans = a2;
        }
      }
    }

    if (node.y == H - 1 && node.x == W - 1) {
      break;
    }

    if (node.y + 1 < H) {
      que.push(Node(node.y + 1, node.x));
    }

    if (node.x + 1 < W) {
      que.push(Node(node.y, node.x + 1));
    }
  }

  cout << ans << endl;

  return 0;
}


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

mat = [[0]*n for _ in range(n)]

for _ in range(n):
    In = list(map(int, input().split()))
    u, k, vs = In[0], In[1], In[2:]
    for v in vs:
        mat[u - 1][v - 1] = 1

for i in range(n):
    print(*mat[i])


Measured memory_bytes: 6380
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
using ll = unsigned long long;

int A[100000] = {0};
int n, k;

bool check(ll limit)
{
  int truck = 1;
  ll carried = 0;
  for(int i =0; i<n;++i) {
    if (A[i] > limit) return false;
    if(carried + A[i] <= limit) carried += A[i];   
    else {
      if (truck == k) return false;
      ++truck;
      carried = A[i];
    }
  }
  return true;
}

int main()
{
  // problem: pick k-1 breakpoints from among n objects
  // to minimize the maximum value of the objects contained
  // within a particular group of the objects
  // algorithm:
  // opt(k, n) = min_{i_k} max(opt(k-1, i_k), sum_{j=i_k, ..., n-1} A_j)
  // -> Binary search over 0..sum(A), see if there's a way to do it with that

  ll l=0, u=100000000000ULL;  // not my idea; comes from the #1 solution

  cin >> n >> k;
  
  for(int i = 0; i<n; ++i) cin >> A[i];

 // int it=0;

  while(u!=l) {
//    ++it; if (it>100) {cout << "Fail: " << u << " " << l; return 1; }
//    cout << u << " " << l << endl;
    ll m = (u+l)/2;
    if (!check(m)) l = m+1;
    else u = m;
  }

  cout << u << endl;
}


Measured memory_bytes: 3488
#include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<int> v(32);
  v[0]=1,v[1]=1,v[2]=1,v[3]=2,v[4]=1,v[5]=2,v[6]=1,v[7]=5,
  v[8]=2,v[9]=2,v[10]= 1,v[11]=5,v[12]=1,v[13]=2,v[14]=1,v[15]=14,
  v[16]=1,v[17]=5,v[18]=1,v[19]=5,
  v[20]=2,v[21]=2,v[22]=1,v[23]=15,v[24]=2,v[25]=2,v[26]=5,
  v[27]=4,v[28]=1,v[29]=4,v[30]=1,v[31]=51;
  int k;
  cin >> k;
  cout << v[k-1] << endl;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N,K;
    cin >> N >> K;

    int ans=1;
    rep(i,0,N) ans=min(ans*2,ans+K);

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j);a×b行列の入力
 
int main() {
  ll a,b;
  ci(a>>b);
  vector<vector<double>> c(a,vector<double>(b));
  for(i,0,a)
    for(j,0,b)
      ci(c[i][j]);
  ll e=0;
  double d=0;
  for(i,0,a-1)
    for(j,i+1,a){
      for(k,0,b)
        d+=pow(c[i][k]-c[j][k],2);
      d=sqrt(d);
      double f=floor(d);
      if(f==d)
        e++;
      d=0;
    }
  co(e);
}

Measured memory_bytes: 256
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
n = int(input())
kotae = num2alpha(n)
print(kotae.lower())

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

int main(int argc, char *argv[])
{
	int a, b;
    cin >> a >> b;

	if (a + b == 15) {
		cout << "+";
	} else if (a * b == 15) {
		cout << "*";
	} else {
		cout << "x";
	}

	return 0;
}


Measured memory_bytes: 256
import math
n,d = map(int, input().split())
x = [0] * n
y = [0] * n
for i in range(n):
	x[i],y[i] = map(int,input().split())
count = 0
for i in range(n):
	if math.sqrt(x[i]**2+y[i]**2) <= d:
		count += 1

print(count)

Measured memory_bytes: 24776
#include <stdio.h>
#include <math.h>


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

    int x[n], y[n];
    for (int i=0; i < n; i++){
        scanf("%d", &x[i]);
        scanf("%d", &y[i]);
    }

    double sum = 0;
    for (int i=0; i < n-1; i++){
        for (int j = i+1; j < n; j++){
            sum += pow( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) , 0.5);
        }
    }

    


    printf("%f\n", sum/n*2);

    
    return 0;
} 



Measured memory_bytes: 128
# Problem D - Replacing

# input
N = int(input())
a_nums = list(map(int, input().split()))
Q = int(input())

# initialization
nums = [0] * (10**5 + 1)
cur_sum = sum(a_nums)
for a in a_nums:
    nums[a] += 1

# count
for i in range(Q):
    b, c = map(int, input().split())
    b_count = nums[b]
    cur_sum = cur_sum - b_count*b + b_count*c
    print(cur_sum)
    nums[b] = 0
    nums[c] += b_count


Measured memory_bytes: 84428
import sys
input = sys.stdin.readline
MOD = 10**9 + 7


def main():
    S = input().rstrip()
    DP = [0] * 13
    n = len(S)
    DP[0] = 1

    for i in range(0, n):
        preDP = DP
        DP = [0] * 13
        if S[i] == '?':
            for k in range(13):
                for x in range(10):
                    t = (x + 10*k) % 13
                    DP[t] += preDP[k]
                    DP[t] %= MOD
        else:
            y = int(S[i])
            for k in range(13):
                t = (y+10*k) % 13
                DP[t] += preDP[k]
                DP[t] %= MOD

    ans = DP[5]
    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;
long long  a[100005],dp[100003];
long long n,k;
long long mincost(int x)
{
	if(x==n)
	{
		dp[x]=0;
		return dp[x];
	}
	for (int i = 1; i <=k && x+i<=n ; ++i)
	{
		if(dp[x+i]==-1)
			dp[x+i]=mincost(x+i);
	}
	long long int  mini=1000000000;
	for (int i = 1; i <=k && x+i<=n ; ++i)
	{
		mini=min(dp[x+i]+abs(a[x+i]-a[x]),mini);
	}
	dp[x]=mini;
	return dp[x];
}
int main()
{
	cin>>n>>k;
	for (int i = 1; i <=n; ++i)
	{
		cin>>a[i];
	}
	for (int i = 0; i < 100002; ++i)
	{
		dp[i]=-1;
	}
	
	cout<<mincost(1)<<'\n';
	// for (int i = 1; i <= n; ++i)
	// {
	// 	cout<<dp[i]<<' ';
	// }
	// cout<<'\n';

}

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

vector<int> adj[100001];

int dfs(vector<int> &visited , int i){
	if(visited[i]!=-1){
		return visited[i];
	}
	if(adj[i].size() == 0){
		visited[i] = 0;
		return visited[i];
	}
		for(int j = 0 ; j < adj[i].size() ; j++){
				visited[i] = max(visited[i] , 1 + dfs(visited,adj[i][j]));
		}
	return visited[i];
}

signed main(){
	int n , m;
	cin>> n >> m;
	vector<int> visited(n,-1);
	for(int i = 0 ; i < m ; i++){
		int a,b;
		cin>>a>>b;
		adj[a-1].push_back(b-1);
	}
	for(int i = 0 ; i < n ; i++){
		if(visited[i]==-1){
			visited[i] = dfs(visited,i);
		}
	}
	int ans = 0;
	for(int i = 0 ; i < n ; i++){
		ans = max(ans , visited[i]);
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll N;
  cin >> N;

  ll ans = 1e13;
  for(ll i = 1; i * i <= N; i++){

    if(N % i == 0){
      chmin(ans, i + N/i - 2);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define ll unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
 
using namespace std;
 
// Factorial
// need init
ll factorial_memo[5001];
ll factorial(ll n) {
  factorial_memo[0] = 1;
  if(factorial_memo[n] != -1) return factorial_memo[n];
  factorial_memo[n] = (factorial(n-1) * n) % MOD;
  return factorial_memo[n];
}
 
// Combination(nCr)
// need init
ll nCr_memo[5001][5001];
ll nCr(ll n, ll r) {
  if(r*2 > n) r = n-r;
  if(r == 1) return n;
  if(r == 0) return 1;
  if(nCr_memo[n][r] != -1) return nCr_memo[n][r];
  nCr_memo[n][r] = (nCr(n-1, r) + nCr(n-1, r-1)) % MOD;
  return nCr_memo[n][r];
}
 
void solve() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  REP(i, tx-sx) cout << "R";
  REP(i, ty-sy) cout << "U";
  REP(i, tx-sx) cout << "L";
  REP(i, ty-sy) cout << "D";
  cout << "D";
  REP(i, tx-sx+1) cout << "R";
  REP(i, ty-sy+1) cout << "U";
  cout << "LU";
  REP(i, tx-sx+1) cout << "L";
  REP(i, ty-sy+1) cout << "D";
  cout << "R\n";
}
 
int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n, a;
int x[55];
ll dp[55][2505][55];
ll ans;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a;
    rep(i, n) cin >> x[i];
    dp[0][0][0] = 1;
    rep(i, n)rep(j, 2505)rep(k, n + 1) {
        dp[i + 1][j][k] += dp[i][j][k];
        if (k - 1 >= 0 && j - x[i] >= 0) {
            dp[i + 1][j][k] += dp[i][j - x[i]][k - 1];
        }
    }
    rep(j, 2505)rep2(k, 1, n + 1) {
        if (j == k * a) ans += dp[n][j][k];
    }
    cout << ans << endl;
}


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

int main(void){

    
    double ans,v,t,y;
    
    while(cin >> v){

        t = v / 9.8;
        y = t * t * 4.9;
        ans = y / 5 + 1;
        cout << (int)(ans+1) << endl; 
    }
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000005;
const int MAX = 300000;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    // code here
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> a(A), b(B), c(C);
    for (int i = 0; i < A; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < B; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < C; i++) {
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    vector<int> AB;
    for (int i = A - X; i < A; i++) {
        AB.push_back(a[i]);
    }
    for (int i = B - Y; i < B; i++) {
        AB.push_back(b[i]);
    }
    sort(AB.begin(), AB.end());
    int pos = 0;
    for (int i = 0; i < AB.size(); i++) {
        if (pos == C) {
            break;
        }
        if (AB[i] < c[pos]) {
            AB[i] = c[pos];
            pos++;
        }
    }
    ll ans = 0;
    for (auto v : AB) {
        ans += v;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2552
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', (chunk) => {
    const input = chunk.split(' ').map(el => Number(el));
    const size = (arr) => {
        if (arr.reduce((a, b) => a > b)) {
            return 'a > b';
        } else if (arr.reduce((a, b) => a < b)) {
            return 'a < b';
        } else {
            return 'a == b'
        }
    };
    console.log(size(input));
});


Measured memory_bytes: 15284
import java.util.Scanner
import kotlin.math.*

fun main() {
	val scn = Scanner(System.`in`)
	val x = scn.nextDouble()
	var a = 0L
	while(true){
		val a5 = Math.pow(a.toDouble(), 5.0)
		if (a5==x){
			println("$a 0")
			return
		}else {
			var b = Math.pow(a5-x, 0.2)
			if (b.isNaN()) b = -Math.pow(x-a5, 0.2)
			if (a5 - Math.pow(floor(b), 5.0)==x){
				println("$a ${floor(b).toLong()}")
				return
			}else if (a5 - Math.pow(ceil(b), 5.0)==x){
				println("$a ${ceil(b).toLong()}")
				return
			}
		}
		a++
	}
}

Measured memory_bytes: 37828
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut a = a;
    while a.len() > 1 {
        a.sort();
        for i in 1..a.len() {
            a[i] = a[i] % a[0];
        }

        let mut b = Vec::with_capacity(n);
        for i in 0..a.len() {
            if a[i] > 0 {
                b.push(a[i]);
            }
        }
        a = b;
    }

    println!("{}", a[0]);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string S; cin >> S;
  int n = S.length();
  for (int i = 1; i <= n; ++i) cout << "x";
  return 0;
}

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

ll a, b, c, d;

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

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


int main(){
    cin >> a >> b >> c >> d; a--;
    ll t1, t2;
    t1 = (b/c); t2 = (a/c);
    ll x = t1 - t2;
    t1 = (b/d); t2 = (a/d);
    ll y = t1 - t2;
    ll l = lcm(c, d);
    t1 = (b/l); t2 = (a/l);
    ll z = t1 - t2;

    cout << (b-a) - (x+y-z) << endl;
    return 0;
}

Measured memory_bytes: 3592
var
  i, g, p: integer;
  s: string;
begin
  readln(s);
  for i := 1 to length(s) do
  begin
    if s[i] = 'g' then
      g := g + 1;
    if s[i] = 'p' then
      p := p + 1;
  end;
  
  if p < g then
    writeln((g - p) div 2)
  else
    writeln(0);
end.

Measured memory_bytes: 256
fun main(args: Array<String>) {
    sumitb2019d()
}

fun sumitb2019d() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val topArray = java.util.HashMap<Char, MutableSet<Char>>()
    val candidate = mutableSetOf<String>()
    for (c in s) {
        for (p in topArray) {
            for (e in p.value) {
                candidate.add("${p.key}$e$c")
            }
            p.value.add(c)
        }
        if (c !in topArray) topArray[c] = mutableSetOf<Char>()
    }
    println(candidate.size)
}

Measured memory_bytes: 109068
#include <iostream>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 5e5+17;
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif
	int n;
	string str;
	cin>>n>>str;
	vector<int > vec;
	for (int k = 0; k < 4; ++k)
	{
		vec.clear();
		// debug(k);
		// debug(k&1);
		// debug((k>>1)&1);
		vec.push_back(k&1);
		vec.push_back((k>>1)&1);
		// for (int i = 0; i < 2; ++i)
		// {
		// 	debug(vec[i]);
		// }
		for (int i = 1; i < n-1; ++i)
		{
			if(vec[i]==0)
			{
				if(str[i]=='o')
					vec.push_back(vec[i-1]);
				else
					vec.push_back(!vec[i-1]);
			}
			else
			{
				if(str[i]=='o')
					vec.push_back(!vec[i-1]);
				else
					vec.push_back(vec[i-1]);
			}
			//debug(vec[i+1]);
		}
		bool can = true;
		if(vec[n-1]==0)
		{
			if(str[n-1]=='o'&&vec[n-2]!=vec[0])
				can = false;
			if(str[n-1]=='x'&&vec[n-2]==vec[0])
				can = false;
		}
		if(vec[n-1]==1)
		{
			if(str[n-1]=='o'&&vec[n-2]==vec[0])
				can = false;
			if(str[n-1]=='x'&&vec[n-2]!=vec[0])
				can = false;
		}
		if(vec[0]==0)
		{
			if(str[0]=='o'&&vec[n-1]!=vec[1])
				can = false;
			if(str[0]=='x'&&vec[n-1]==vec[1])
				can = false;
		}
		if(vec[0]==1)
		{
			if(str[0]=='o'&&vec[n-1]==vec[1])
				can = false;
			if(str[0]=='x'&&vec[n-1]!=vec[1])
				can = false;
		}
		if(can)
		{
			for (int i = 0; i < n; ++i)
			{
				if(vec[i]) cout<<'W';
				else cout<<'S';
			}
			return cout<<endl,0;
		}
	}
	cout<<-1<<endl;
	return 0;
}



Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define MAX 1005
using namespace std;

int main(){
    int n, t, a, h[MAX], ans = 1, score = 1000000000;
    scanf("%d%d%d", &n, &t, &a);
    for(int i = 1; i <= n; i++){
        scanf("%d", &h[i]);
        if(score > abs(t*1000-h[i]*6-a*1000)){
            score = abs(t*1000-h[i]*6-a*1000);
            ans = i;
        }
    }
    printf("%d\n", ans);
}


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


int main(int argc, char const *argv[])
{
  int N,buf,ans = 0;
  bool d[100];
  cin >> N ;
  for (int i = 0; i < 100; ++i)
  {
    d[i] = false;
  }
  for (int i = 0; i < N; ++i)
  {
    cin >> buf;
    d[buf-1] = true;
  }
  for (int i = 0; i < 100; ++i)
  {
    if(d[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  if (n & 1) {
    cout << 0 << endl;
  } else {
    n = n / 2;
    ll ans = 0;
    ll d = 5;
    while (n >= d) {
      ans += n / d;
      d *= 5;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int hp1 = sc.nextInt();
		int s1 = sc.nextInt();
		int hp2 = sc.nextInt();
		int s2 = sc.nextInt();
		
		//taka
		while(true)
		{
			hp2 -= s1;
			
			if(hp2 <= 0)
			{
				System.out.println("Yes");
				return;
			}
			
			hp1 -= s2;
			if(hp1 <= 0)
			{
				System.out.println("No");
				return;
			}
		}
		
	}

}


Measured memory_bytes: 27076
#include<iostream>
#include<string.h>
using namespace std;

int main(){
    string s;
    int c = 0;
    cin >> s;
    if(s[0]=='o')c++;
    if(s[1]=='o')c++;
    if(s[2]=='o')c++;
    cout<<c*100+700<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less< i64 >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 100005

i64 a[maxn] ;

int main()
{
    int n ;

    scanf("%d",&n) ;

    for(int i=1 ; i<=n ; i++) scanf("%lld",&a[i]) ;

    i64 ans = a[1]-1 ;

    a[1] = 1 ;

    i64 mx = 1 ;

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

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

    return 0 ;
}


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

int main(){
  int n, num, a, maxx;

  while(cin >> n){
    if(n==0)
      break;

    num = 0;

    for(int i=0;i<n;i++){
      cin >> a;
      num += a;
      if(i == 0) maxx = a;
      maxx = max(maxx,num);
      if(num<0) num = 0;
    }
    cout << maxx << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>
#include <cmath>
#include <cstring>
#include <numeric>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <complex>
#include <list>
#include <cassert>

#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}

using namespace std;
using ll = long long;

/*
struct UnionFind {
    // union tree
    // used for tracking a set of elements partitioned into a number of disjoint subsets
    // rankなしでの実装

    vector<int> par;
    // par[i] means i's parent
    // (ex) par[3] = 2 means 2 is a parent of 3

    UnionFind(int N) : par(N) {
      //used for initialization
      for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
      // データxが属する木の根を再帰で得る
      // root(x) = {xの木の根}
      if (par[x] == x) return x;
      return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
      // xとyのtreeのmerge
      int rx = root(x); //xの根をrx
      int ry = root(y); //yの根をry
      if (rx == ry) return; //同じ時はそのままに
      par[rx] = ry; //xの根rxをyの根ryにつける
    }

    bool same(int x, int y) {
      // 2つのデータx, yが属する木が同じならtrueを返す
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
    }
};

template<typename T>
struct SegTree {
  //segment tree

  //木は配列で表現
  vector<T> seg;
  //木の1/2の大きさ
  int size;
  //単位元
  const T unit;
  //比較関数の型
  using F = function<T(T,T)>;
  //mergeする関数
  const F f;

  //単位元がaで大きさnのsegtreeの初期化を行う
  //大きさnとはすなわち葉の数がnであることをいう
  SegTree(int n, const T a, const F f) : unit(a), f(f) {
    size = 1;
    while(size < n) size <<= 1;
    seg.assign(2*size, unit);
    size--;
  }

  //k番目にtを代入する
  void set(int k, const T& t) {
    seg[k + size] = t;
  }

  //関数fによって木を構築する
  void build(){
    for (int i = size - 1; i >=0; i--){
      seg[i] = f(seg[i*2+1],seg[i*2+2]);
    }
  }

  //i番目の要素を返す
  T operator[](const int i){
    return seg[i + size];
  }

  //k番目の値をaに更新する
  void update(int k, T a){
    k = k + size;
    //必要ならばここを変えても良い
    seg[k] = a;
    //自分の親の情報を再帰的に更新していく
    while(k>0){
      k = ((k-1) >> 1);
      seg[k] = f(seg[k*2+1],seg[k*2+2]);
    }
  }

  //[a,b)についてfをした結果を返す
  //例えば、fがminだったらどうなるかを考えるとわかりやすい
  //unitについては足し算なら0,掛け算なら1,minならinf,どんな値が来てもその値を返すもの
  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return unit;
    } else if (a <= l && r <= b) {
      return seg[k];
    } else {
      T lch = query(a, b, k * 2 + 1, l, (l + r) / 2);
      T rch = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return f(lch, rch);
    }
  }
  T query(int a, int b) { return query(a, b, 0, 0, size+1); }
};
*/

/* --- ここからコード --- */

int main(){
  string S;
  cin >> S;
  if (S[0] == 'A'){
    if(S[1] == 'A' && S[2] == 'A') cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  else{
    if(S[1] == 'B' && S[2] == 'B') cout << "No" << endl;
    else cout << "Yes" << endl;
  }

  return 0;
}

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

int main() {

  int a , b , c , d;

  cin >> a >> b >> c ;

  if (a > b){

     d = a;

     a = b;

     b = d;
  
  } 

  if (b > c) {

    d = b;

    b = c;

    c = d;
  }

  if (a > b){

    d = a;

    a = b;

    b = d;

  }

  cout << a << " " <<  b << " " << c << "\n";

  return 0;

}

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

using namespace std;

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

constexpr long long Inf = numeric_limits<long long>::max() / 4;
typedef long long ll;

namespace flow_algorithm
{
  template<class Flow>
  struct edge
  {
    int to;
    Flow cap, rev;
  };
  
  /*
  template<class Flow>
  using edges = vector<edge<Flow>>;
  
  template<class Flow>
  using graph = vector<edges<Flow>>;
  */
  typedef vector<edge<ll>> edges;
  typedef vector<edges> graph;
  
  template<class Flow>
  class ford_fulkerson
  {
  private:
    
    int V;
    //    graph<Flow> g;
    graph g;
    vector<bool> used;
    
    //   Flow static constexpr Inf = numeric_limits<Flow>::max() / 4;
    
  private:
    
    Flow dfs(int curr, int tar, Flow flow) {
      if(curr == tar) { return flow; }
      used[curr] = true;
      rep(i, g[curr].size()) {
        edge<Flow>& e = g[curr][i];
        if(!used[e.to] && e.cap > 0) {
          Flow d = dfs(e.to, tar, min(flow, e.cap));
          if(d <= 0) { continue; }
          e.cap -= d;
          g[e.to][e.rev].cap += d;
          return d;
        }
      }
      return 0;
    }
    
  public:
    
    ford_fulkerson(int V_)
    {
      V = V_;
      g.resize(V_);
      used.resize(V_);
    }
    
    void add_edge(int from, int to, Flow cap)
    {
      g[from].push_back({to, cap, (Flow)g[to].size()});
      g[to].push_back({from, 0, (Flow)g[from].size()-1});
    }
    
    Flow max_flow(int s, int t)
    {
      Flow ret = 0;
      for(;;) {
        rep(i, V) used[i] = false;
        Flow f = dfs(s, t, Inf);
        if(f == 0) { return ret; }
        ret += f;
      }
    }
    
  };
}

int const SBASE = 10;
int const SRC = 150, SINK = 151;

int main() {
  
  map<string, int> mp = {
    {"Monday",0},
    {"Tuesday", 1},
    {"Wednesday", 2},
    {"Thursday", 3},
    {"Friday", 4},
    {"Saturday", 5},
    {"Sunday", 6}
  };
  
  int N; ll W;
  while(cin >> N >> W && (N|W)) {
    flow_algorithm::ford_fulkerson<ll> ff(200);
    
    rep(i, 7) ff.add_edge(SRC, i, W);
    
    ll need = 0;
    
    rep(i, N) {
      ll t; int c; cin >> t >> c;
      need += t;
      rep(j, c) {
        string s; cin >> s;
        //        dn.add_edge(mp[s], SBASE+i, flow_algorithm::dinic<ll>::Inf);
        ff.add_edge(mp[s], SBASE+i, Inf);
      }
      ff.add_edge(SBASE+i, SINK, t);
    }
    
    cout << ( ff.max_flow(SRC, SINK) == need ? "Yes" : "No" ) << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
using namespace std;
#define ll long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mem(a,t) memset(a,t,sizeof(a))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
const int inf=1e9;
const int N=1e5+5;
const int mod=1e9+7;
vector<pair<int,int> >a,b;
vector<pair<int,pair<int,int> > >g;
int cal(int x,int y,int r,int c){
    if(x==0) return y;
    else if(y==c) return c+x;
    else if(x==r) return c+r+c-y;
    else if(y==0) return c+r+c+r-x;
    else return -1;
}
vector<pair<int,int> >f;
int main(){
    ios_base::sync_with_stdio(false);
    int n,r,c;
    cin>>r>>c>>n;
    int t1,t2;
    rep(i,0,n){
        int x1,x2,y1,y2;
        cin>>x1>>y1>>x2>>y2;
        t1=t2=-1;
        if((x1==0||x1==r)||(y1==0||y1==c)){
            t1=cal(x1,y1,r,c);
        }
        if((x2==0||x2==r)||(y2==0||y2==c)){
            t2=cal(x2,y2,r,c);
        }
        if(t1!=-1&&t2!=-1){
            f.pb(mp(t1,i));
            f.pb(mp(t2,i));
        }
    }

    sort(all(f));
    vector<int>vis(n,0);
    stack<int>s;
    rep(i,0,f.size()){
        int id=f[i].se;
        if(vis[id]==1){
            if(s.top()==id){
                s.pop();
            }
            else{
                s.push(id);
            }
        }
        else{
            vis[id]=1;
            s.push(id);
        }
    }
    if(s.size()==0)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

int main(void)
{
  int n;
  std::cin >> n;

  std::vector<int64_t> a;
  for (int i = 0; i < n; i++) {
    int64_t num;
    std::cin >> num;
    a.push_back(num);
  }

  int64_t sum = 0;
  int64_t max_i = a.front();
  for (int i = 1; i < n; i++) {
    max_i = std::max(a[i-1], max_i);

    int64_t diff = a[i] - max_i;

    if (diff < 0) {
      sum += std::abs(diff);
      // a[i] += std::abs(diff);
    }
  }

  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 5312
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
    
using namespace std;

//pay attention to relative position
class Dice
{
    public: 
    int temp1;
    int temp2;
    int a[100];
     
   // Dice(int top, int south, int east, int west, int north, int bottom)
    //{        
       // a[1] = top;
       // a[2] = south;
      //  a[3] = east;
      //  a[4] = west;
      //  a[5] = north;
     //   a[6] = bottom;
  //  }
     
    void RollS()
    {
            temp1 = a[1];
            temp2 = a[2];
            a[1] = a[5];
            a[2] = temp1;
            a[5] = a[6];
            a[6] = temp2;
    }
     
     void RollN()
    {
            temp1 = a[1];
            temp2 = a[5];
            a[1] = a[2];
            a[2] = a[6];
            a[5] = temp1;
            a[6] = temp2;   
    }
     
     void RollW()
    {
            temp1 = a[1];
            temp2 = a[4];
            a[1] = a[3];
            a[3] = a[6];
            a[4] = temp1;
            a[6] = temp2;
    }
     
     void RollE()
    {
            temp1 = a[1];
            temp2 = a[3];
            a[1] = a[4];
            a[3] = temp1;
            a[4] = a[6];
            a[6] = temp2;
    }
    
    void Spin()  //?¨????????¬?????????????
    {
        temp1 = a[2];
        temp2 = a[4];
        a[2] = a[3]; 
        a[3] = a[5];
        a[4] = temp1;
        a[5] = temp2;
    }
};
 
void Solution()
{    
    Dice p1, p2;
      
    for(int i = 1; i <= 6; i++)
    {
        cin>>p1.a[i];
    }
    
    for(int i = 1; i <= 6; i++)
    {
        cin>>p2.a[i];
    }
     
    //Dice p1(a[1], a[2], a[3], a[4], a[5], a[6]); 

         
    if(p1.a[4] == p2.a[1] || p1.a[3] == p2.a[1]) {p1.RollE();}
    
    for(int i = 0; i < 6; i++)
    {
        if(p1.a[1] == p2.a[1]) break;
        p1.RollN(); // spin based on x axis
    }
    //after ensure the a[1] == b[1], there is a[2] left
    for(int i = 0; i < 6; i++)
    {
        if(p1.a[2] == p2.a[2]) break;
        p1.Spin(); // spin based on y axis
    }
    
    if(p1.a[1] == p2.a[1] &&
      p1.a[2] == p2.a[2] &&
      p1.a[3] == p2.a[3] &&
      p1.a[4] == p2.a[4] &&
      p1.a[5] == p2.a[5] &&
      p1.a[6] == p2.a[6])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
            
              
}
    
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
#約数リスト
import math
#素数列挙
def get_primes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0
    
    while True:
        prime = min(A)
        
        if prime > math.sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P




def resolve():
    n = int(input())
    A = get_primes(int(1.2*n))

    for i in A:
        if i>=n:
            print(i)
            return





if __name__ == "__main__":
    resolve()

Measured memory_bytes: 7832
#include <iostream>

using std::cin;
using std::cout;
using std::endl;


void TorT()
{
  int n, a, b;

  cin >> n >> a >> b;
  if (n * a > b) cout << b << endl;
  else           cout << n * a << endl;
}


void cross9_9()
{
  int a, b;

  cin >> a >> b;
  if (a > 0 && a < 10 && b > 0 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
}


void calculate_circle()
{
  int r;

  cin >> r;
  cout << r * r << endl;
}


void SvsM()
{
  int hp, a;
  int atk_cnt, rest;

  cin >> hp >> a;
  atk_cnt = hp / a;
  if (hp % a) atk_cnt++;
  cout << atk_cnt << endl;
}


void Poor3()
{
  int a, b, c;

  cin >> a >> b >> c;
  if (a == b && b != c) cout << "Yes" << endl;
  else if (b == c && c != a) cout << "Yes" << endl;
  else if (c == a && a != b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


void Algae()
{
  int r, d, x;
  
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++)
  {
    x = r * x - d;
    cout << x << endl;
  }
}


void cross81()
{
  int n;
  int flag = 0;

  cin >> n;
  for (int i = 1; i < 10; i++)
  {
    for (int j = 1; j < 10; j++)
    {
      if (n == i * j)
      {
        flag = 1;
        cout << "Yes" << endl;
        break;
      }
    }
    if (flag) break;
  }
  if(!flag) cout << "No" << endl;
}


void bite_eating()
{
  int n, l;
  int taste[200];
  int sum = 0, ans_sum = 0;
  int diff = 100;

  cin >> n >> l;
  for (int i = 0; i < n; i++)
  {
    taste[i] = l + i;
    sum += taste[i];
  }
  for (int i = 0; i < n; i++)
  {
    if(std::abs(taste[i]) < std::abs(diff)) diff = taste[i];
  }
  ans_sum = sum - diff;
  cout << ans_sum << endl;

}
int main()
{
  //TorT();
  //cross9_9();
  //calculate_circle();
  //SvsM();
  //Poor3();
  //Algae();
  //cross81();
  bite_eating();
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

typedef long long ll;

int n,m,a,b,c;
bool g[52][52];
bool g2[52][52][125];

const int INF = 83025;

int dist[52];

int main(){
  scanf("%d%d%d%d%d",&n,&m,&a,&b,&c);
  REP(i,m){
    int u,v;
    scanf("%d%d",&u,&v);
    u--;v--;
    g[u][v] = true;
  }
  REP(i,n)REP(j,n)g2[i][j][1] = g[i][j];
  FOR(s,2,125){
    REP(i,n)REP(j,n)if(g2[i][j][s-1]){
      REP(k,n)if(g[j][k]){
        g2[i][k][s] = true;
      }
    }
  }
  // REP(i,n){
  //   REP(j,n)printf("%d",g2[i][j][a]);puts("");
  // }
  // REP(i,n){
  //   REP(j,n)printf("%d",g2[i][j][b]);puts("");
  // }
  // REP(i,n){
  //   REP(j,n)printf("%d",g2[i][j][c]);puts("");
  // }
  REP(i,n)dist[i] = INF;
  dist[n-1] = 0;
  REP(t,100){
    set<int> nxt;
    REP(i,n)if(g2[i][n-1][a]&&g2[i][n-1][b]&&g2[i][n-1][c]){
      nxt.insert(i);
    }
    for(int x:nxt){
      CHMIN(dist[x], t+1);
      REP(i,n){
        if(g2[i][x][a])g2[i][n-1][a]=true;
        if(g2[i][x][b])g2[i][n-1][b]=true;
        if(g2[i][x][c])g2[i][n-1][c]=true;
      }
    }
  }
  int ans = dist[0];
  if(ans==INF){
    puts("IMPOSSIBLE");
  }else{
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 222222;
int a[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a[0] = 1e9;
    rep(i, 1, n) {
        int x;
        cin >> x;
        if(a[x - 1]) {
            a[x - 1]--;
            a[x]++;
        }
    }
    rrep(i, 1, n) {
        if(a[i]) {
            cout << n - i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin >> a[i];
        sum^=a[i];
    }
    rep(i,n){
        if(i) cout << " ";
        ll ans=sum^a[i];
        cout << ans;
    }
} 


Measured memory_bytes: 4704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N;
    cin >> N;
    vector<LL> A(N), B(N);
    vector<LL> diff(N);

    LL Asum = 0;
    LL Bsum = 0; 
    REP(i,N)
    {
        cin >> A[i];
        Asum += A[i];
    }
    REP(i,N)
    {
        cin >> B[i];
        Bsum += B[i];
        diff[i] = A[i] - B[i];
    }

    if(Asum < Bsum) 
    {
        cout << -1 << endl;
        return 0;
    }

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

    LL debtcount = 0;
    int ncount = 0;
    int pcount = 0; 
    for(auto u : diff)
    {
        if(u < 0)
        {
            debtcount += u;
            ncount++;
        }
        else break;
    }
    if(debtcount < 0)
    {

        for(int index = N - 1; index >= 0; index--)
        {
            debtcount += diff[index];
            pcount++;
            if(debtcount >= 0)
            {
                break;
            }
        }
    }

    dump(debtcount)

    cout << ncount + pcount << endl;



}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

const int MAX = 510000;
///////combination///////
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
////////////////////////
int main(void) {
    ll h,w;
    cin>>h>>w;
    ll a,b;
    cin>>a>>b;
    COMinit();
    ll res=0;
    for(int i=0;i<=h-1-a;i++){
        ll tmp=COM(i+b-1,b-1);
        if(i+b-1==0&&b==0)tmp=1;
        tmp *= COM(h-1-i+w-b-1,w-b-1);
        tmp%=MOD;
        res+=tmp;
        res %=MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 12160