akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

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

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int dp[9][101];

void init();
void make_dp(int sum, int prevused, bool* used, int depth);

void init()
{
	bool used[10] = {false};
	make_dp(0, -1, used, 0);
}

void make_dp(int sum, int prevused, bool* used, int depth)
{
	if( depth == 10 )return;
	
	for(int i = prevused + 1; i < 10; i++)
	{
		if( !used[i] )
		{
			sum += i;
			used[i] = true;
			dp[depth][sum]++;
			make_dp(sum, i, used, depth + 1);
			used[i] = false;
			sum -= i;
		}
	}
}

int main()
{
	int n, s;
	init();

	while(true)
	{
		scanf("%d%d", &n, &s);
		if( n == 0 && s == 0 )break;
		printf("%d\n", dp[n - 1][s]);
	}
	return (0);
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}



int main()
{
  int n ;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  int mn=arr[0];
  int ans=1;

  for(int i=1;i<n;i++)
  {
      if(arr[i]<=mn) ans++;
      mn=min(arr[i],mn);
  }
  cout<<ans<<endl;

}

















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

using namespace std;

int main()
{
  string s;
  cin >> s;
  
  string t(s);
  reverse(t.begin(), t.end());
  if (s != t) {
    cout << "No" << endl;
    return (0);
  }
  
  string f(s.substr(0, (s.size()-1)/2));
  string fr(f);
  reverse(fr.begin(), fr.end());
  if (fr != f) {
    cout << "No" << endl;
    return (0);
  }
  
  string l(s.substr(((s.size()+3)/2) - 1, (s.size()-1)/2));
  string lr(l);
  reverse(lr.begin(), lr.end());
  if (lr != l) {
    cout << "No" << endl;
    return (0);
  }
  
  cout << "Yes" << endl;
}
  
  

Measured memory_bytes: 256
typedef struct s{char w[33];int a;}s;main(){int i,j,k,o,e=0;char w[1001];s t[1000];scanf("%[^\n]",w);getchar();j=0,k=0;for(i=0;w[i]!='\0';i++){if(isalpha(w[i])){t[j].w[k]=w[i];k++;}else if(w[i]=' '){k=0;j++;}}o=0;for(i=0;t[i].w[0]!='\0';i++){for(j=i+1;t[j].w[0]!='\0';j++){if(strcmp(t[i].w,t[j].w)==0){t[i].a+=1;if(o<t[i].a) o=t[i].a;}}}for(i=0;t[i].w[0]!='\0';i++){if(o==t[i].a){printf("%s ",t[i].w);break;}}for(i=32;i>0;i--){for(j=0;t[j].w[0]!='\0';j++){if(isalpha(t[j].w[i])){printf("%s\n",t[j].w);return 0;}}}}

Measured memory_bytes: 576
#include<iostream>
using namespace std;
int main () {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = 0; i < 2; i ++) {
    if (A > B) {
      ans += A;
      A --;
    }
    else {
      ans += B;
      B --;
    }
  }
  cout << ans << endl;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string N; cin >> N;
    vector<int> A(4,0);
    REP(i,4){
        A[i] = N[i]-'0';
    }
    REP(i,2){
        REP(j,2){
            REP(k,2){
                int num = A[0];
                num += (i==1?A[1]:-A[1]);
                num += (j==1?A[2]:-A[2]);
                num += (k==1?A[3]:-A[3]);
                if(num==7){
                    cout << A[0];
                    cout << (i==1?"+":"-");
                    cout << A[1];
                    cout << (j==1?"+":"-");
                    cout << A[2];
                    cout << (k==1?"+":"-");
                    cout << A[3];
                    cout << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    

    return 0;
}

Measured memory_bytes: 3608
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,(a+b+r*1j*3**.5)/2,b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


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

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

	int red = 0;
	int blue = 0;
	for (auto& c : s) {
		if (c == '0') {
			++red;
		}
		else {
			++blue;
		}
	}

	cout << min(red, blue) * 2 << endl;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mod 1000000007
using namespace std;
typedef __int128 ll;
ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int Q,K;
ll X,Y;
ll fib[90];
ll ans;
void print(ll ans)
{
    if(!ans)  return;
    print(ans/10);
    putchar((char)(ans%10+'0'));
}
int main()
{
    Q=read();
    fib[0]=fib[1]=1;
    for(int i=2;i<=88;i++)  fib[i]=fib[i-1]+fib[i-2];
    while(Q--)
    {
        ans=0;
        X=read();Y=read();
        if(X>Y)  swap(X,Y);
        if(X==1)
        {
            printf("%d %d\n",1,(int)(Y%mod));
            continue;
        }
        if(X==2&&Y==2)
        {
            puts("1 4");
            continue;
        }
        int p1,p2;
        for(int i=88;i>=1;i--)
        {
            if(fib[i]<=X)
            {
                p1=i;
                break;
            }
        }
        for(int i=88;i>=1;i--)
        {
            if(fib[i]<=Y)
            {
                p2=i;
                break;
            }
        }
        K=min(p1,p2-1);
        printf("%d ",K);
        for(int i=1;i<=K;i++)
        {
            ll tx,ty;
            if(i==K)
            {
                tx=fib[i];
                ty=fib[i+1];
            }
            else{
                int x=K-i;
                tx=fib[i]*fib[x]+fib[i+1]*fib[x-1];
                ty=fib[i]*fib[x+1]+fib[i+1]*fib[x];                
            }
            if(tx<=X&&ty<=Y)
            {
                ans+=(Y-ty)/tx+1;
                if(ty<=X)  ans+=(Y-tx)/ty+1;
            }
        }
        printf("%d\n",(int)(ans%mod));
    }
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=998244353;
const ll inf=1e17;
const ll ms=(2e5)+5;


int ar[ms];
int ans[ms]={0};
vector<int> pp;

int main()
{
    idfc;
    int n;
    cin>>n;
    int i;
    int j;
    int e;

    for(i=1;i<=n;i++)cin>>ar[i];

    for(i=n;i>=1;i--)
    {
        e=0;
        for(j=i;j<=n;j+=i)
        {
            e+=ans[j];
        }
        e%=2;
        if(e!=ar[i])
        {
            ans[i]=1;
            pp.pb(i);
        }
    }
    cout<<pp.size()<<"\n";

    for(int ii:pp)cout<<ii<<" ";

    return 0;
}

Measured memory_bytes: 5192
x,n = map(int,input().split())
lst = list(map(int,input().split()))
i = 0

s =True
while s:
    if (x-i) not in lst:
        print(x-i)
        s = False
    elif (x+i) not in lst:
        print(x+i)
        s = False
    else:
        i += 1

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

int main() {
    int n,m;
    cin>>n>>m;
    vector<ll> a(n),b(n),c(m),d(m);
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];
    rep(i,n) {
        ll dis=abs(a[i]-c[0])+abs(b[i]-d[0]);
        int index=1;
        for (int j=1; j<m; j++) {
           ll res=abs(a[i]-c[j])+abs(b[i]-d[j]);
           if (res<dis) {
               index=j+1;
               dis=res;
           }
        }
        cout<<index<<endl;
    }
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
ans=[]
sum=0
for n in range(N):
    sum=sum+A[n]

for n in range(N-1):
    suma=0
    for a in range(n+1):
        suma=suma+A[a]
    sumb=sum-suma
    sa=abs(sumb-suma)
    ans.append(sa)
print(min(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;

    string s[N];
    for(int i=0; i<N; i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    long long int ans = 0;
    unordered_map<string,int> mp;
    for(int i=0; i<N; i++){
        if(mp.find(s[i]) == mp.end()){
            mp[s[i]] = 1;
        }else{
            ans += mp.at(s[i]);
            mp[s[i]]++;
        }
    }

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

Measured memory_bytes: 17700
"""
B - 105
1 以上 N 以下の奇数のうち, 正の約数を ちょうど 8 個持つようなものの個数を求めよ. 
"""
N = int(input())

cnt = 0
for n in range(1, N+1, 2):
    yaku = 2
    for test in range(3, int(n ** 0.5) + 1, 2):
        #print("test", test)
        # 与えられた数をとりあえず割って、あまりを調べる
        if (n % test) == 0:
            yaku += 2

    #print("yaku", yaku)
    if yaku == 8:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
#define endl '\n'
const int N =6e5+5;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int powmod(int base,int exp,int mod)
{
	int res=1LL;
	while(exp>0)
	{
		if(exp&1LL)
			res=(res*base)%mod;
		exp/=2LL;
		base=(base*base)%mod;
	}
	return res%mod;
}
int dp[101][100001];
signed main()
{
	speed
	int n,W;
	cin>>n>>W;
	int val[n+1];
	int w[n+1];
	Rep(i,n)
	{
		cin>>w[i]>>val[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=W;j++)
		{
			if(w[i]>j)
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+val[i]);
			}
		}
	}
	cout<<dp[n][W]<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,K;
    cin>>N>>K;

    int ans=LLONG_MAX;
    for(int i=0;i<=N;i++){
        chmin(ans,(1ll<<i)+K*(N-i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
a = [0] * 3
a[0] = input()[::-1]
a[1] = input()[::-1]
a[2] = input()[::-1]

d = dict()

d['a'] = 0
d['b'] = 1
d['c'] = 2

nxt = 0
cur = 0

while True:
  cur = nxt
  if len(a[cur])  == 0:
    break
  nxt = d[a[cur][-1]]
  a[cur] = a[cur][:-1]
if cur == 0:
  print('A')
elif cur == 1:
  print('B')
else:
  print('C')

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

if N==M:
	print("Yes")
else:
	print("No")

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

int main(){
    vector<int> time(5);
    for (int i = 0; i < 5; i++){
        cin >> time.at(i);
    }
    vector<int> amari(5);
    int sum = 0;
    for (int i = 0; i < 5; i++){
        amari.at(i) = time.at(i) % 10;
        if (amari.at(i) == 0){
            sum += time.at(i);
        }
        else{
            sum += (time.at(i) / 10 + 1) * 10;
        }
    }
    vector<int> zero = {0,0,0,0,0};
    if (amari == zero){
        cout << sum <<endl;
    }
    else{
        int min_amari = 9;
        for (int i = 0; i < 5; i++){
            if (amari.at(i) > 0 && amari.at(i) < min_amari){
                min_amari = amari.at(i);
            }
        }
        cout << sum - 10 + min_amari << endl; 
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> a(3*N, 0);
    for (int i = 0; i < 3*N; i++) scanf("%lld", &a[i]);
    
    vector<ll> lsum(3*N, 0);
    priority_queue<ll, vector<ll>, greater<ll>> q;
    for (int i = 0; i < N; i++) {
        lsum[N-1] += a[i];
        q.push(a[i]);
    }
    for (int i = N; i < 2*N; i++) {
        lsum[i] = lsum[i-1] + a[i];
        q.push(a[i]);
        lsum[i] -= q.top();
        q.pop();
    }
    
    vector<ll> rsum(3*N, 0);
    priority_queue<ll> r;
    for (int i = 3*N-1; i >= 2*N; i--) {
        rsum[2*N] += a[i];
        r.push(a[i]);
    }
    for (int i = 2*N-1; i >= N; i--) {
        rsum[i] = rsum[i+1] + a[i];
        r.push(a[i]);
        rsum[i] -= r.top();
        r.pop();
    }
    ll ans = lsum[N-1]-rsum[N];
    for (int i = N; i < 2*N; i++) {
        if (lsum[i] - rsum[i+1] > ans) ans = lsum[i] - rsum[i+1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9588
#include <stdio.h>

int main(){
    int n, i, d, s, num[8];
    
    scanf("%d", &n);
    
    while(n--){
        scanf("%d", &d);
        
        for(i = 0; i < 8; i++){
            num[i] = d % 10;
            d /= 10;
        }
        
        for(i = 0; i < 8; i++)
            for(d = 0; d < 7; d++)
                if(num[d] > num[d + 1]){
                    s = num[d + 1];
                    num[d + 1] = num[d];
                    num[d] = s;
                }
        
        for(i = d = 0, s = 1; i < 8; i++){
            d += (num[i] - num[7 - i]) * s;
            s *= 10;
        }
    
        printf("%d\n", d);
    }
        
    return 0;
}     

Measured memory_bytes: 600
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    bool ok = true;
    ok &= (s[2] == s[3]);
    ok &= (s[4] == s[5]);
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
cnt,i = 0,0
while i<n:
    while i+1<n and a[i]==a[i+1]: i+=1
    if i+1<n and a[i]<a[i+1]:
        while i+1<n and a[i]<=a[i+1]: i+=1
    elif i+1<n and a[i]>a[i+1]:
        while i+1<n and a[i]>=a[i+1]: i+=1
    cnt+=1
    i+=1
print(cnt)

Measured memory_bytes: 20472
def popcnt_int(n): # n:int
    return bin(n).count('1')

def popcnt_bin(s): # s:str
    return s.count('1')

def poptimes(n, cnt=1): #:int, popcntのcounter
    if n==0:
        return cnt
    else:
        n %= popcnt_int(n)
        cnt += 1
        return poptimes(n, cnt)

n = int(input())
s = input() #これが直接処理し難い大きさ → 一回目の処理に要工夫。
# 要:いずれかを反転させた場合のbitの数は'反転前のbit数±1'の2通り！

s_int = int(s,2) # 2進数で読み込む
pc = popcnt_bin(s)
pc_plus = s_int % (pc+1) # 予めs_intのmod(pc+1)を取得
if  pc != 1: # mod(pc-1)も同様だが, bitが1個だけの場合に反転すると全て'0'になるためこの場合だけ例外扱い。
    pc_minus = s_int % (pc-1)
#print(n,s,s_int,pc,pc_plus,pc_minus)

# 以下で反転した差分を処理(一回目の処理完了) → 二回目以降は処理対象の値が大きくないためそのまま処理(poptimes関数)すればOK
for i in range(n):
    if s[i] == '1': # 1から0へと減じた差分を処理 
        if pc != 1: # 例外を考慮
            tmp = pc_minus - pow(2, n-i-1, pc-1) # ここで差し引くが, 差分をmod(pc-1)で処理
            print(poptimes(tmp % (pc-1))) # poptimesへパスする前にもmod(pc-1)
        else: # 例外処理: pc=1(反転して全部'0')の場合
            print(0)
            continue
    
    else: # 0から1への差分を処理, 必ず一つはbitが立つので例外は考慮不要
        tmp = pc_plus + pow(2, n-i-1, pc+1)
        print(poptimes(tmp % (pc+1)))


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///
bool sortby(const pair<long long,long long> &a, const pair<long long,long long> &b)
{
    if(a.first==b.first) return a.second>b.second;
    return a.first<b.first;
}

void _case()
{
    long long n,i,m,x,y,ans=0;
    vector<pair<long long,long long> > v;
    cin>>n>>m;
    for(i=0;i<n;i++){
        cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end(),sortby);
    for(i=0;i<n;i++){
        if(v[i].second>=m){
            ans+= v[i].first*m;
            m-=m;
            break;
        }
        else{
            ans+= v[i].first*v[i].second;
            m-=v[i].second;
        }
    }
    cout<<ans<<'\n';
}
main()
{
//    fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

int main() {
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    for (auto &i: s) {
        i += n;
        if (i > 'Z') {
            i = (char)(i - 'Z' + 'A' - 1);
        }
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
cnt = [1, 1]
q = deque([(0, 0), (n-1, 1)])
seen = [False]*n
seen[0] = seen[n-1] = True
while q:
    node, turn = q.popleft()
    for c_node in graph[node]:
        if seen[c_node]:
            continue
        seen[c_node] = True
        cnt[turn] += 1
        q.append((c_node, turn))
print('FSennunkeec'[cnt[1]>=cnt[0]::2])

Measured memory_bytes: 27852
#include<iostream>
#include<string>

using namespace std;

int main () {

    string str;
    cin >> str;

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {

        string order;
        cin >> order;

        // cout << "Scan order" << endl;

        int a, b;
        cin >> a >> b;

        // cout << "Scan a & b" << endl;

        if (order == "print") {

            // cout << "Mode print" << endl;

            string out;
            out = str.substr(a, b + 1 - a);

            cout << out << endl;

        } else if (order == "reverse") {

            // cout << "Mode reverse" << endl;

            int j = 0;
            while (j <= (b - a) / 2) {

                char tmp;
                tmp = str[a + j];
                str[a + j] = str[b - j];
                str[b - j] = tmp; 
                j++;

            }

            // cout << "Result reverse: " << str << endl;

        } else if (order == "replace") {

            // cout << "Mode replace" << endl;
            
            string p;
            cin >> p;

            for (int j = a; j <= b; j++) {

                str[j] = p[j - a];

            }
        
        }

    }

    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> cnts(N, 1);
    vector<bool> reds(N, false);
    reds[0] = true;
    rep(i, M){
        int x, y;
        cin >> x >> y;
        x --;
        y --;
        reds[y] = (reds[y]  || reds[x]);
        cnts[x] --;
        cnts[y] ++;
        if(cnts[x] == 0){
            reds[x] = false;
        }
    }
    int ans = 0;
    rep(i, N){
        if(reds[i]){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 +7;
constexpr int MAXNe6 = 1e6 + 7;
#pragma region 
inline long long read()
{
	char c = getchar();long long flag = 1, ans = 0;
	while(c < '0' || c > '9'){if(c == '-')flag = -1; c = getchar();}
	while(c >= '0' && c <= '9'){ans = ans * 10 + c - '0'; c = getchar();}
	return (ans * flag);
}
#pragma endregion
// C'est la vie
int main() {
    long long h = read(), n = read();
    long long res = 0;
    for(int i = 0; i < n; ++ i) {
        long long input = read();
        res += input;
    }
    if(res >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    #ifndef ONLINE_JUDGE
    system("pause");
    #endif
}

Measured memory_bytes: 504
def isPrime(num):
    if num < 2:
        return False
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False

    for i in range(3, int(num**0.5)+1, 2):
        if num % i == 0:
            return False
    return True

def is_2017(num):
    temp = (num + 1) // 2
    if isPrime(num) and isPrime(temp):
        return True
    else:
        return False

if __name__ == "__main__":
    
    Q = int(input())
    
    is_2017_list = [0] * (10**5 + 1)
    count = 0
    for i in range(1, 10**5):
        if is_2017(i):
            count += 1
            is_2017_list[i] = count
            
        else:
            is_2017_list[i] = count

    ans_list = []
    for _ in range(Q):
        l, r = map(int, input().split())
        ans = is_2017_list[r] - is_2017_list[l-1]
        ans_list.append(ans)
    
    for ans in ans_list:
        print(ans)

    




Measured memory_bytes: 14148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll fac(ll n){
    if (n > 0) {
        return  n * fac(n - 1);
    }else{
        return 1;
    }
}

int main()
{
    ll n,ans = 0;
    cin >> n;
    vector<ll> cnt(5,0);
    string s;
    rep(i, n){
        cin >> s;
        if (s[0] == 'M') {
            ++cnt[0];
        }else if (s[0] == 'A') {
            ++cnt[1];
        }else if (s[0] == 'R') {
            ++cnt[2];
        }else if (s[0] == 'C') {
            ++cnt[3];
        }else if (s[0] == 'H') {
            ++cnt[4];
        }
    }
    rep(i, 3){
        nfor(j, i + 1, 4){
            nfor(k, j + 1, 5){
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


SIZE = 26

table = [None]*SIZE


while True:
    N = int(input())
    if N == 0:
        break

    for i in range(SIZE):
        table[i] = 0

    input_str = list(map(str,input().split()))

    who = None
    ans = N+1
    rest = N

    maximum = 0
    maximum_index = 0
    maximum_count = N

    for i in range(1,(N+1)):
        rest -= 1
        loc = ord(input_str[i-1])-ord('A')
        table[loc] += 1

        if table[loc] > maximum: #新たに単独一意になった
            maximum = table[loc]
            maximum_count = 1
            maximum_index = loc
        elif table[loc] == maximum: #1位が複数
            maximum_count += 1

        if maximum_count > 1:
            continue

        #1位が単独の場合は勝利確定か調べる
        FLG = True
        for k in range(len(table)):
            if k == maximum_index:
                continue
            if table[k]+rest >= table[maximum_index]:
                FLG = False
                break

        if FLG == True:
            who = maximum_index
            ans = i
            break

    if ans == N+1:
        print("TIE")
    else:
        print("%s %d"%(chr(who+ord('A')),ans))



Measured memory_bytes: 13900
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;

int n;

int main()
{
    cin>>n;
    if(n>=195)
        cout<<5<<endl;
    else if(n>=189)
        cout<<4<<endl;
    else if(n>=165)
        cout<<3<<endl;
     else if(n>=135)
        cout<<2<<endl;
    else if(n>=105)
        cout<<1<<endl;
    else
        cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int N, A, x[51], X, XN;
long dp[51][51][2501];

int main(void) {
  cin >> N >> A;
  X = A;
  REP(i, 1, N + 1) {
    cin >> x[i];
    X = max(X, x[i]);
  }
  XN = X * N;

  REP(i, 0, N + 1) {
    REP(j, 0, N + 1) {
      REP(k, 0, XN + 1) {
        if     (i == 0 && j == 0 && k == 0)    dp[i][j][k] = 1;
        else if(i >= 1 && k < x[i])            dp[i][j][k] = dp[i - 1][j][k];
        else if(i >= 1 && j >= 1 && k >= x[i]) dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
        else                                   dp[i][j][k] = 0;
      }
    }
  }

  long ans = 0;
  REP(j, 1, N + 1) {
    ans += dp[N][j][j * A];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 51072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    ll c = abs(a-b);
    cout << (v*t >= w*t + c ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

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

    int choice = 0;
    for(int num : a){
        if(4*m*num >= sum) choice++;
        if(choice >= m) break;
    }
    if(choice >= m) cout << "Yes" << endl;
    else            cout << "No" << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin >> x[i];
    }

    int result = pow(2, 29);
    for(int i=0; i+(k-1)<n; i++){
        int tmp = 0;
        tmp += x[i+k-1] - x[i];
        tmp += min(abs(x[i]), abs(x[i+k-1]));
        result = min(result, tmp);
    }
    cout << result << endl;
    return 0;
}

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

#define ll long long int
#define ff(i,a,b) for(ll i = a; i < b; i++)
#define bf(i,b,a) for(ll i = b-1; i >= 0; i--)
#define itf(i,a) for(auto i = a.begin(); i != a.end(); i++)
#define MII map<int,int> 
#define MCI map<char,int>
#define MSI map<string,int>
#define VI vector<int> 
#define VC vector<char> 
#define VS vector<string> 
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define tc ll t; cin>>t; while(t--)
#define DISPV(v) itf(i,v) cout << *i << ' ';
#define DISPM(m) itf(i,m) cout << i->F << ' ' << i->S << endl;

const int MOD = int(1e9) + 7;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << '\n';
}

Measured memory_bytes: 3648
#include<stdio.h>
#define M 9
#define N 9
int main(){
  int i,j;
  for(i=0;i<M;i++){
    for(j=0;j<N;j++){
      printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
    }
  }
  return 0;
}

Measured memory_bytes: 524
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.ReadLine();
			var inputs = Console.ReadLine().Split(' ').Select(text => long.Parse(text));

			long max = inputs.Max();
			long min = inputs.Min();

			Console.WriteLine(max - min);
		}
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int a[100010];

int main() {
    int N;
    cin >> N;
    rep(i, N)cin >> a[i];

    map<int, int>mp;
    rep(i, N) {
        mp[a[i]]++;
    }
    int cou = 0;
    for (auto p : mp) {
        if (p.first <= p.second) {
            cou += p.second - p.first;
        }
        else {
            cou += p.second;
        }
    }
    cout << cou << endl;
}

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

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

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll ans = INF;
    reps(i, -100, 101){
        ll temp = 0;
        rep(j,N) temp += (a[j] - i) * (a[j] - i);
        ans = min(ans , temp);
    }
    cout<<ans<<endl;
}

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


int main() {
  int N , M ; 
  cin >> N >> M ; 
  int p ;
  string S ; 
  vector<int> ac(N) , pena(N) ; 
  int AC= 0  , WA=0 ;  
  
  for(int i = 0 ; i < M ; i++){
    cin >> p >> S ; 
    
    if(S == "AC"){
      ac.at(p-1) = 1 ; 
    }
    else if(S == "WA" && ac.at(p-1) != 1 ){
      pena.at(p-1)++ ;     
      //cout << pena.at(p-1) << endl ; 
      
    }
  }
    
   
  
  for(int i = 0 ; i < N ; i++){
    AC  += ac.at(i) ;
    if(ac.at(i)) WA += pena.at(i) ; 
  }
  
  cout << AC << " " << WA << endl ; 
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
int main(){
	string s;
	cin>>s;
	bool flag=true;
	rep(i,sz(s)){
		if((i%2==0)&(s[i]=='L')) flag=false;
		if((i%2==1)&(s[i]=='R')) flag=false;
	}
	if(flag==true) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int N;
set<int> s;     

int main(void){
    cin >> N;
    for(int i = 0; i < N; i++){
        int d; cin >> d;
        s.insert(d);
    }

    cout << s.size() << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        if(N%2==0 && S.substring(0, N/2).equals(S.substring(N/2))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 22996
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;

int cnt[55][55];
int n;
char s[55];
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>n;
  REP(i,n){
    scanf("%s",s);
    int m=strlen(s);
    REP(j,m) ++cnt[i][s[j]-'a'];
  }
  string res;
  REP(j,26){
    int mn=INF;
    REP(i,n) chmin(mn,cnt[i][j]);
    res+=string(mn,'a'+j);
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 256
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int, input().split())
cd = lcm(c,d)
bdiv = b//c + b//d - b//cd
adiv = (a-1)//c + (a-1)//d - (a-1)//cd
ans = b - (a-1) - bdiv + adiv
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	/*void a() {
		String s = sc.next();
		char cbefore = s.charAt(0);
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(cbefore == c) {
				System.out.println("Bad");
				return;
			}
			cbefore = c;
		}
		System.out.println("Good");
	}*/
	
	void doIt() {
		int n = sc.nextInt(), l = sc.nextInt();
		int min = 1000,sum = 0;
		for(int i = 1;i <= n;i ++) {
			int taste = l + i - 1;
			min = (Math.abs(min) > Math.abs(taste))?taste:min;
			//System.out.println(min);
			sum += taste;
		}
		System.out.println(sum-(int)(min));
	}

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

}

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

const int MOD = 1000000007;
const int INF = 1e9;

long long modpow(long long a, long long n, long long mod){
  long long res = 1;
  while(n > 0){
    //nを２進数に分解してビットの立っているところだけ掛け算していく。
    if (n &  1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const int max_fac = 2 * 1e6;
long long fac[max_fac], finv[max_fac], inv[max_fac];
void ComInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_fac; 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 Comb(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(){
  long long n;
  cin >> n;

  long long max_ans = modpow(10, n, MOD);
  long long not9 = modpow(9, n, MOD);
  long long not0 = modpow(9, n, MOD);
  long long not09 = modpow(8, n, MOD);

  long long ans = 0;
  ans = max_ans - (not9 + not0) + not09;
  ans %= MOD;
  if(ans < 0) ans += MOD;
  cout << ans << endl;


    



  return 0;
}

Measured memory_bytes: 3632
/* Several vs Monster */

#include <iostream>
using namespace std;

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

  int cnt=0;
  while(1){
    if(h<=0){
      cout << cnt << endl;
      break;
    }
    else{
      h-=a;
    }
    cnt++;
  }
}


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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int64 n,a,b;
    cin >> n >> a >> b;
    int64 diff =  abs(a-b);
    if (diff % 2 == 0) {
        cout << diff/2 << endl;
        return 0;
    }

    int64 ans = 0;

    ans = (a-1) + 1 + abs(a-b+1) /2;
    ans = min(ans, (n-b) + 1 + abs(a-b+1) /2);

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

Measured memory_bytes: 888
/*
                        --------------- PramodDubey 's code-_______
                        /''''''''''(______O] ----------____  \______/]_
     __...---'"""\_ --''        IIT DELHI     ___________@ -> ->  -> - --  - -- - ---- ->>
 |'''                   ._   _______________=---------"""""""
 |                ..--''|   l L |_l   |
 |          ..--''      .  /-___j '   '
 |    ..--''           /  ,       '   '
 |--''                /           `    \
                      L__'         \    -
                                    -    '-.
                                     '.    /
                                       '-./
*/

///   ------------ Bismillah hirrahman nirrahim ----------   ///

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
	ll n, k;
	cin>>n>>k;
	ll count[k];
	for(ll i=0;i<k;i++)count[i]=0;
	for(ll i=1;i<=n;i++)count[i%k]++;
	ll ans=0;
	for(ll i=0;i<k;i++){
		ll a=i;
		ll b=(k-a)%k;
		ll c=(k-b)%k;
		if((a+c)%k != 0)continue;
		ans+=(count[a]*count[b]*count[c]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
l=list(map(int,input().split()))
lcount=[]
for i in range(m):
    a,b=map(int,input().split())
    k1=l[a-1]
    k2=l[b-1]
    if k1>k2:
        lcount.append(b)
    elif k1<k2:
        lcount.append(a)
    else:
        lcount.append(a)
        lcount.append(b)
import collections
c=collections.Counter(lcount)
print(n-len(c))


Measured memory_bytes: 91384
#include <iostream>
using namespace std;
int main() {
	int i, x, n;
	cin >> n;
	for (i = 1; i <= n; i++) {
		x = i;
		if (x % 3 == 0) {
			cout << ' ' << i;
		}
		else {
			do {
				if (x % 10 == 3) {
					cout << ' ' << i;
					break;
				}
				x /= 10;
			} while (x);
		}
	}
	cout << endl;
}

Measured memory_bytes: 1160
{-# LANGUAGE OverloadedStrings #-} 
import qualified Data.Text as T
import qualified Data.Text.IO as I
import qualified Data.Map.Strict as M
import Data.Map.Strict ((!))
import Control.Monad

comb :: Int -> Int
comb n = n*(n-1) `div` 2

main :: IO ()
main = do
  line <- I.getLine
  let n = read $ T.unpack line :: Int

  line2 <- I.getLine
  let as = map (read . T.unpack) $ T.splitOn " " line2 :: [Int]
  let m = foldr (M.alter (\v -> Just $ (maybe 0 id v) + 1)) M.empty as :: M.Map Int Int
  let mm = M.map comb m :: M.Map Int Int
  let total = sum $ M.elems mm

  let ans = map (\i -> total - (mm ! i) + comb ((m ! i) - 1)) as :: [Int]
  forM_ ans print

Measured memory_bytes: 58876
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h1 = scan.nextInt();
        int m1 = scan.nextInt();
        int h2 = scan.nextInt();
        int m2 = scan.nextInt();
        int k = scan.nextInt();
        scan.close();
      
        int diff = h2*60 + m2 - h1*60 - m1;
        
        System.out.println("" + (diff-k));
    }
}

Measured memory_bytes: 38532
#include <iostream>

using namespace std;
using ll = long long;

ll n;
ll div2f(ll num) {
	ll ret = 0;
	for (ll i = 2; num / i > 0; i *= 2) ret += num / i;
	return ret;
}
int main(void) {
	cin >> n;
	for (ll m = 1; ; m *= 2) {
		if (div2f(m) + div2f(n-m) < div2f(n) || n < m) {
			cout << m << endl;
			break;
		}
	}
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    vector<int> in;
    int n = 0;
    while (true)
    {
        int k;
        cin >> k;
        chmax(n, k);
        if (!k)
            break;
        in.emplace_back(k);
    }

    vector<int> dp(n + 5, 1e6);
    vector<int> dp2(n + 5, 1e6);
    dp[0] = 1;
    dp2[0] = 1;

    int h = 1;
    int i = 1;
    while (h <= n)
    {
        rep(j, n + 1)
        {
            chmin(dp[h], 1);

            if (j - h >= 0)
            {
                chmin(dp[j], dp[j - h] + 1);
            }

            if (h % 2 == 0)
            {
                continue;
            }

            chmin(dp2[h], 1);

            if (j - h >= 0)
            {
                chmin(dp2[j], dp2[j - h] + 1);
            }
        }

        i++;
        h = i * (i + 1) * (i + 2) / 6;
    }

    for (int k : in)
    {
        cout << dp[k] << " " << dp2[k] << endl;
    }

    return 0;
}


Measured memory_bytes: 10460