akhauriyash/Code-Regression huggingface dataset:
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}
ll num[1000005];
ll dp[1000005][2];
ll solve(ll idx,ll carry)
{
   if(idx<0) return carry;
   if(dp[idx][carry]!=-1) return dp[idx][carry];
   if(num[idx]==9&&carry==1) return dp[idx][carry]=solve(idx-1,1);
   return dp[idx][carry]=min((num[idx]+carry+solve(idx-1,0)),(10-num[idx]-carry+solve(idx-1,1)));
}
int32_t main()
{   
     IOS;
     string s;
     cin>>s;
     memset(dp,-1,sizeof dp);
     ll n=s.length();
     for(ll i=0;i<n;i++)
      num[i]=s[i]-'0';
    cout<<solve(n-1,0);
     
     
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 71708
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    cout << min_element(v.begin(),v.end()) - v.begin()+1 << "\n";
    return 0;
}


Measured memory_bytes: 3416
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    repf(i,0,n) cin>>a[i];
    multiset<ll> s;
    repf(i,0,n)
    {
        s.insert(a[i]);
    }
    repf(i,0,n)
    {
        s.erase(s.find(a[i]));
        cout<<*(s.rbegin())<<endl;
        s.insert(a[i]);
    }
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  bool f = true;
  rep(i, n) {
    int a;
    cin >> a;
    if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) f = false;
  }
  cout << (f ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define vll vector<long long>
#define mll map<long long,long long>
#define pb push_back
typedef  long long ll;
typedef long double ld;
long double pi=3.14159265358979323846;

vll al[500005];
ll vis[500005],color[500005],I[101][101];

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

bool isPrime(int n)
{
    if (n<=1) return false; 
    if (n<=3) return true; 
    if (n%2==0||n%3==0) return false; 
    for (int i=5;i*i<=n;i=i+6) if (n%i==0||n%(i+2)==0) return false; 
    return true; 
}

ll bpow(ll n, ll po)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res*=n;
			po--;
		}
		else
		{
			n*=n;
			po/=2;
		}
	}
	return res;
}

ll binpow(ll n, ll po, ll mod)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res=(res*n)%mod;
			po--;
		}
		else
		{
			n=(n*n)%mod;
			po/=2;
		}
	}
	return res;
}

ll swap(ll a, ll b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

ll fact(ll n) { 
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}

ll C(ll n, ll r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
        ans=ans%1000000007;
    }

    return ans;
}

//bool bipartite_dfs(ll node, ll flag)
//{
//	vis[node]=1;
//	ll cflag=flag;
//	color[node]=cflag;
//	for(ll child : al[node])
//	{
//		if(!vis[child])
//		{
//			bool n=bipartite_dfs(child,1-cflag);
//			if(n==false) return false;
//		}
//		else if(color[child]==color[node]) return false;
//	}
//	return true;
//}

void mmul(ll A[][101], ll B[][101], ll dim)
{
	ll res[dim][dim];
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		res[i][j]=0;
		for(ll k=0;k<dim;k++) res[i][j]=(res[i][j]+A[i][k]*B[k][j])%1000000007;
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=res[i][j];
}

void mpow(ll A[][101],ll dim, ll po)
{
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		if(i==j) I[i][j]=1;
		else I[i][j]=0;
	}
	while(po>0)
	{
		if(po%2==1)
		{
			mmul(I,A,dim);
			po--;
		}
		else
		{
			mmul(A,A,dim);
			po/=2;
		}
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=I[i][j];
}


int main()
{
	ll n,k;
	cin>>n>>k;
	while(k--)
	{
		ll d,a;
		cin>>d;
		while(d--)
		{
			cin>>a;
			vis[a]=1;
		}
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		if(vis[i]==0) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 15328
f x k d = abs (if (n<=k) then g (x - n*d) (k-n) d else g (x - k*d) 0 d) `min` abs(if (n<=k) then g (x - n'*d) (k-n') d else g (x - k*d) 0 d)
  where
    n = (x `div` d)
    n' = (x`div` d)+1

g x k d = if k`mod`2 == 0 then x else abs (x - d) `min` abs (x + d)

main = do
  [x, k, d] <- map read . words <$> getLine
  print $ abs $ f (abs x) k d

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}
//
// int main()
// {
//     cout << 100000 << " " << 1 << endl;
//     rep(i, 100000) {
//         cout << "AC"[i%2];
//     }
//     cout << endl;
//     cout << "1 100000" << endl;
// }

int odd[100001];
int even[100001];

int main()
{
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    if (S.size()%2) S += "X";
    for (int i=0; i<S.size(); i+=2) {
        if (S[i] == 'A' and S[i+1] == 'C') even[i/2]++;
    }
    if (S.size()%2==0) S += "X";
    for (int i=1; i<S.size(); i+=2) {
        if (S[i] == 'A' and S[i+1] == 'C') odd[i/2]++;
    }
    for (int i=1; i<N; ++i) {
        even[i] += even[i-1];
        odd[i] += odd[i-1];
    }

    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        int ans = 0;
        {
            int tl = l, tr = r;
            if (tr%2==0) tr--;
            if (tl == 0) {
                ans += even[tr/2];
            }
            else {
                tl--;
                ans += even[tr/2] - even[tl/2];
            }
        }
        {
            int tl = l-1, tr = r-1;
            if (tl == -1 and tr == 0) ;
            else
            {
                if (tr%2==0) tr--;
                if (tl <= 0)
                {
                    ans += odd[tr/2];
                }
                else{
                    tl--;
                    ans += odd[tr/2] - odd[tl/2];
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1792
//蜀榊ｸｰ
#include<bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

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

template<typename T,typename U>
void Printarray(T f,U n){for(U i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i]<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> h(n);rep(i,n)cin>>h[i];
  vector<int> dp(n);

  dp.assign(n,0);

  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
}


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

using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n<=5)
    {
        printf("0\n");
    }
    else if(n>=6&&n<=12)
    {
        printf("%d\n",m/2);
    }
    else
    {
        printf("%d\n",m);
    }
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x=int(input())
    ans=x
    while True:
        flag=False
        for i in range(2,int(x**0.5)):
            if ans%i==0:
                flag=True
                break
        if flag:
            ans+=1
            continue
        else:
            break
    print(ans)
resolve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define N 100001
vector<int> G[N],rG[N],g;
bool u[N];
int n,cmp[N];
  
void add_edge(int x,int y){G[x].push_back(y);rG[y].push_back(x);}
void dfs(int x){u[x]=1;rep(i,G[x].size())if(!u[G[x][i]])dfs(G[x][i]);g.push_back(x);} 
void rdfs(int x,int k){u[x]=1;cmp[x]=k;rep(i,rG[x].size())if(!u[rG[x][i]])rdfs(rG[x][i],k);}
int scc() {
  memset(u,0,sizeof(u));g.clear();rep(i,n)if(!u[i])dfs(i);memset(u,0,sizeof(u));
  int k=0;rrep(i,g.size())if(!u[g[i]])rdfs(g[i],k++);return k;
}
vector<int> v[N];
int c[N];
void make() {
  rep(i,n)rep(j,G[i].size()){
    if(cmp[i]==cmp[G[i][j]]) continue;
    v[cmp[i]].push_back(cmp[G[i][j]]);
  }
  rep(i,n){
    sort(v[i].begin(),v[i].end());
    v[i].erase(unique(v[i].begin(),v[i].end()),v[i].end());
    rep(j,v[i].size())c[v[i][j]]++;
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  int m;
  cin >> n >> m;
  while(m--) {
    int x,y;
    cin >> x >> y;
    add_edge(x,y);
  }
  scc();
  make();
  int x=0,y=0,cnt=0,u[n];
  memset(u,0,sizeof(u));
  rep(i,n) {
    int z=cmp[i];
    if(u[z]) continue;
    u[z]=1;
    if(!v[z].size()) x++;
    if(!c[z]) y++;
    cnt++;
  }
  if(cnt==1) cout << 0 << endl;
  else cout << max(x,y) << endl;
  return 0;
}


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {


	int k;
	cin >> k;
	
	if (k < 10) {
		cout << k << endl;
		return 0;
	}

	min_priority_queue<ll> q;
	FOR(i, 1, 10)q.push(i);

	int cnt = 9;

	while (true) {
		ll a = q.top();
		q.pop();
		int b = a % 10;
		if (b != 0) {
			cnt++;
			q.push(a * 10 + b - 1);
			if (cnt == k) {
				cout << a * 10 + b - 1 << endl;
				return 0;
			}
		}
		cnt++;
		if (cnt == k) {
			cout << a * 10 + b << endl;
			return 0;
		}
		q.push(a * 10 + b);

		if (b != 9) {
			cnt++;
			q.push(a * 10 + b + 1);
			if (cnt == k) {
				cout << a * 10 + b + 1 << endl;
				return 0;
			}
		}
	}


	



}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e4;
 
char arr[N][N];
char arr1[N][N];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);
 
    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);
 
 
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int cnt=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        cnt++;
                }
 
            }
            if(cnt==(m*m))
            {
                printf("Yes\n");
                return 0;
            }
 
        }
    }
    printf("No\n");
 
}
 

Measured memory_bytes: 2432
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}


void main() {
    LL x,k,d;
    R(x,k,d);
    x=abs(x);
    LL m=min(k,x/d);
    k-=m;
    x-=m*d;
    k%=2;
    if ( k ) {
        x=min(abs(x-d),abs(x+d));
    }
    W(x);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000001
#define MOD 1e9+7
ll res=0;

ll dfs(ll i,ll p){

}

int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	ll ans=0;
	ll dp[n][2];
	dp[0][0]=a[0];
	dp[0][1]=-a[0];
	for(ll i=1;i<n;i++){
		if(i==n-1){
			dp[i][0]=max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
			break;
		}
		dp[i][0]=max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
		dp[i][1]=max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
	}
	cout<<dp[n-1][0]<<endl;
	//cout<<max(dp[n-1][0],dp[n-1][1])<<endl;
}


Measured memory_bytes: 2560
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{   fast;
    ll n,d,a;
    cin>>n>>d>>a;

    vector<pair<ll,ll> >v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i].ff>>v[i].ss;
    sort(v.begin(),v.end());

    vector<ll> diff(n+1,0);
    ll sum=0;
    ll ans=0;

    for(ll i=0;i<n;i++)
    {
            sum+=diff[i];
            if(sum*a>=v[i].ss)
                continue;
    
                ll put=(v[i].ss-sum*a+a-1)/a;
                auto it=lower_bound(v.begin(),v.end(),pair<ll,ll>(v[i].ff+d+d+1,-1));
            if(it!=v.end())
                diff[it-v.begin()]-=put;
            sum+=put;
            ans+=put;
            //cout<<i<<" "<<ans<<" "<<sum<<" "<<put<<endl;
    }
    cout<<ans<<endl;  
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod2=1000000007;
ll mod=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    vector<int> v[n+1];
    rep(i,0,n-1){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int par[n+1];
    par[1]=0;
    v[1].push_back(0);
    int cnt[n+1];
    fill(cnt,cnt+n+1,0);
    queue<int> q;
    q.push(1);
    while(q.size()>0){
        int now=q.front();q.pop();
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(par[now]==ne)continue;
            par[ne]=now;
            q.push(ne);
        }
    }
    int g[n+1];
    rep(i,1,n+1){
        if(v[i].size()==1)q.push(i);
    }
    while(q.size()>0){
        int now=q.front();
        q.pop();
        g[now]=0;
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(par[now]==ne)continue;
            g[now]^=g[ne]+1;
        }
        int p=par[now];
        cnt[p]++;
        if(cnt[p]==v[p].size()-1)q.push(p);
    }
    if(g[1]==0)cout<<"Bob"<<endl;
    else cout<<"Alice"<<endl;
   // rep(i,1,n+1)cout<<g[i]<<endl;
}



Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <queue>
#include <cassert>
#include <stack>

using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

void print(const vi &a) {
    for (auto item : a) {
        cout << item << " ";
        flush(cout);
    }
}

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

    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int count = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; a[k] < a[j] + a[i] && k < n; ++k) {
                if (a[i] < a[j] + a[k] && a[j] < a[i] + a[k]) {
                    count++;
                }
            }
        }
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

H,W = map(int,input().split(' '))
MAP = [None]*H
for i in range(H):
    MAP[i] = list(input())

ANS = 0

dxy = [(0,1),(1,0),(0,-1),(-1,0)]

import queue
q = queue.Queue()

for i in range(H):
    for j in range(W):
        st = MAP[i][j]
        if st=='#': continue
        dist = [[0]*W for i in range(H)]
        visited = [[0]*W for i in range(H)]
        visited[i][j] = 1
        q.put([i,j])
        while not q.empty():
            y,x = q.get()
            for dy,dx in dxy:
                ny,nx = y+dy,x+dx
                if not (0<=nx<W): continue
                if not (0<=ny<H): continue
                if visited[ny][nx]: continue
                if MAP[ny][nx] == '#': continue
                visited[ny][nx] = 1
                dist[ny][nx] = dist[y][x] + 1
                q.put([ny,nx])
        ANS = max(ANS, max(max(row) for row in dist))
print(ANS)

Measured memory_bytes: 3952
import java.io.*;

public class Main {	
	public static void main(String[] args) throws IOException {
		BufferedReader din = new BufferedReader( new InputStreamReader(System.in));
		String str = din.readLine();
		str = str.replace("apple","APPLE");
		str = str.replace("peach","apple");
		System.out.println(str.replace("APPLE","peach"));
	}
}

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

# define FOR(i,a,b) for (int i=(a);i<(b);i++)
# define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
# define REP(i, n) for (int i = 0; i < (int)(n); i++)
# define RREP(i,n) for (int i=(n)-1;i>=0;i--)

# define int(x) int x; scanf("%d",&x);
# define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
# define string(x) string x; cin >> x;

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    REP (i, mat.size()) {
      REP (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    REP (i, v.size())
      if (i >= v.size()-1)
	cout << v[i];
      else
	cout << v[i] << ' ';
    
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


int main() {
  vint(A,3);
  int min = 100000;
  
  for(int i = 0;i < 3;i++){
    for(int j = i;j < 3;j++){
      if(i != j && ((A[i] + A[j]) < min)){
	min = (A[i] + A[j]);
      }
    }
  }
  cout << min << endl;
  
}


Measured memory_bytes: 256
"use strict";
function Main(input) {
    var nums = input.split(" ").map(function(value) { return value - 0; });
    console.log((Math.min(nums[1], nums[2])), Math.max((nums[1] + nums[2]) - nums[0], 0));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        //HashMap<String, Integer> h = new HashMap<>();
        int[] bT = {0,0,0,0};

        while(sc.hasNext()){
            String blood = sc.next().split(",")[1];
            switch (blood){
                case "A" :
                    bT[0]++;
                    break;
                case "B":
                    bT[1]++;
                    break;
                case "AB":
                    bT[2]++;
                    break;
                case "O":
                    bT[3]++;
                    break;
            }
        }

        for(int bloodType : bT){
            System.out.println(bloodType);
        }
    }
}


Measured memory_bytes: 26180
import sys

def parse(inp):
    K,A,B=map(int,next(inp).split())
    return K,A,B
  
def main(inp):
    K,A,B=parse(inp)
    
    if(B-A <= 2):
        return K+1
    
    else:
#        print(K)
        K=K-A+1
        bis=A+int(K/2)*(B-A)
#        print(bis)
        
        if(K%2==0):
            return bis
        else: return bis+1
        
print(main(sys.stdin))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<int> v;
	int a,b,c;
	cin>>a>>b>>c;
	int k=a%b;
	for(int i=0;i<=1000;i++)
	{
		v.push_back((a*i)%b);
	}
	for(int i=0;i<v.size();i++)
		if(v[i]==c)
		{
			printf("YES");
			return 0;
		}
		printf("NO");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int A = sc.nextInt();
            int B = sc.nextInt();
            int C = sc.nextInt();
            int D = sc.nextInt();
            int Chp = C;
            int Ahp = A;
            while(Chp > 0){
                Chp -= B;

                if(Ahp <= 0){
                    System.out.println("No");
                    return;
                }
                Ahp -= D;
            }
            System.out.println("Yes");
        }
    }


Measured memory_bytes: 35788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;cin>>n>>m;
	vector<int> x(m);
	for(int i=0;i<m;i++){
		cin>>x[i];
	}
	sort(begin(x),end(x));
	vector<int> offset(m-1);
	for(int i=0;i<m-1;i++){
		offset[i]=x[i+1]-x[i];
	}
	sort(begin(offset),end(offset),greater<int>());
	long sum=0;
	for(int i=n-1;i<m-1;i++)
		sum+=offset[i];
	cout<<sum;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1 << " | ";__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

const int MOD = 1e9 + 7;
int power(int a,int n){
	int r=1;
	while( n ){
		if( n&1 ){
			r*=a;
			r%=MOD;
		}
		a*=a;
		a%=MOD;
		n>>=1;
	}
	return r;
}

struct box{
	int w,s,v;
};
bool cmp(box a,box b){
	return a.w + a.s > b.w + b.s;
}
int32_t main()
{
   IOS
   const int MXS=5e4+5;
   vector<int>dp(MXS+1);
   int n;cin>>n;
   vector<box>a(n);
   for(int i=0;i<n;i++)
   cin>>a[i].w>>a[i].s>>a[i].v;
   sort(a.begin(),a.end(),cmp);
   for(int i=0;i<n;i++)
   {
	   int w,s,v;
	   w=a[i].w;
	   s=a[i].s;
	   v=a[i].v;
	   vector<int>dp2=dp;
	   for(int j=0;j<=MXS;j++)
	   {
		   int k = min(j-w,s);
		   if( k >= 0 )
		   {
			   dp2[k]=max(dp2[k],dp[j]+v);
		   }
	   }
	   dp=dp2;
   }
   int mxv=0;
   for(int i=0;i<=MXS;i++)
   mxv=max(mxv,dp[i]);
   cout << mxv << endl;
  
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputs = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var x = inputs[0];
            var y = inputs[1];
            Console.WriteLine(x == 2 || y == 2 ? "No" : ((x == 4 || x == 6 || x == 9 || x == 11) ? ((y == 4 || y == 6 || y == 9 || y == 11) ? "Yes" : "No") : ((y == 4 || y == 6 || y == 9 || y == 11) ? "No" : "Yes")));
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

//  ループ制御を表す列挙子
enum LoopControl {
    Again,
    Break,
    Continue,
};

//  それぞれのvectorから１つずつ選ぶ組み合わせを全探索
#define select( v, data ) SELECTION<typeof(data[0][0])>(data) * [&](vector<typeof(data[0][0])> v) -> LoopControl
template<typename T> struct SELECTION {
    vector<vector <T>> &data;
    SELECTION( vector<vector <T>> &d ) :data(d) {}
    void operator* ( function<LoopControl(vector<T>&)> closure ) {
        int N = data.size();
        vector<int> K(N);
        for( int i=0; i<N; i++ ) {
            K[i] = data[i].size();
        }

        vector<int> now( N, 0 );
        vector<T> arg(N);
        while(true) {
            for( int i=0; i<N; i++ ) {
                arg[i] = data[i][now[i]];
            }

            again:
            switch( closure(arg) ){
                case Again:
                    goto again;
                case Break:
                    return;
                case Continue:;
            }

            for( int i=0; i<N; i++ ) {
                now[i] ++;
                if( now[i] < K[i] ) {
                    break;
                }
                if( i == N-1 ) {
                    return;
                }
                for( int j=0; j<=i; j++ ) {
                    now[j] = 0;
                }
            }
        }
    }
};


int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    int ans = 0;
    for( int d=1; d<=9; d++ ) {
        vector<vector<int>> data( d, {3,5,7} );
        select( v , data ) {
            bool tmp[8] = {false};
            rep( i, d ) tmp[v[i]] = true;
            if( tmp[3]==false || tmp[5]==false || tmp[7]==false ) return Continue;
            int k = 0;
            rep( i, d ){ k *= 10; k += v[i]; }
            ans += k <= N;
            return Continue;
        };
    }

    cout << ans << "\n";
}


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

int main(){long X, Y, Z;
cin >> X >> Y >> Z;
long ans = (X - Z) / (Z + Y);


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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
using namespace std;

int minCost = -1;
int n, m, x; 
vector<vector<int>> books(15);

void solve(vector<int> book_flag) {
  vector<int> bookPoint(15);
  int cost = 0;
  for (int i=0;i<n;i++) {
    if (book_flag[i] == 1) {
      cost += books[i][0];
      for (int j=0;j<m;j++) {
        bookPoint[j] += books[i][j + 1];
      }
    }
  }

  for (int i = 0; i < m ; i++) {
    if (bookPoint[i] < x) {
      cost = -1;
      break;
    }
  }

  if ((cost != -1 && cost < minCost) || minCost == -1) {
    minCost = cost;
  } 
}

void subBin(vector<int> book_flag, int n) {
  if (n == 0) {
    solve(book_flag);
  }
  if (n > 0) {
    vector<int> temp = book_flag;
    book_flag.push_back(0);
    subBin(book_flag, n - 1);
    temp.push_back(1);
    subBin(temp, n - 1);
  }
}

int main() {
  cin >> n >> m >> x;

  for (int i = 0;i < n;i++) {
    int c;
    cin >> c;
    books[i].push_back(c);

    for (int j =0;j < m;j++) {
      int a;
      cin >> a;

      books[i].push_back(a);
    }
  }

  subBin({}, n);

  cout << minCost << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
    char ch;
    int count[26];
    for (int i = 0; i < 26; i++) count[i] = 0;
    
    while (scanf("%c", &ch) != EOF){
        if( (ch >= 'a' && ch <= 'z') || (ch >='A' && ch <='Z')) {
            if(ch >= 65 && ch <= 90)
            ch =ch + 32;
            count[ch - 'a'] ++;
        }
    }
    for (int i = 0; i < 26; i++) printf("%c : %d\n", 'a' + i, count[i]);
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
int main(){
    int N;
    cin >> N;
    bool dir[N];
    for(int i = 0; i < N; i++){
        char a;
        cin >> a;
        if(a == 'W'){
            dir[i] = 0;
        }else{
            dir[i] = 1;
        }
    }
    int sum[N+1];
    sum[0] = 0;
    for(int i = 1; i <= N; i++){
        sum[i] = sum[i-1] + (!dir[i-1]);
    }
    int sum2[N+1];
    sum2[N] = 0;
    for(int i = N-1; i >= 0; i--){
        sum2[i] = sum2[i+1] + dir[i];
    }
    int ans = INF;
    for(int i = 0; i < N; i++){
        ans = min(ans, sum[i] + sum2[i+1]);
    }
    cout << ans << endl;
    
}


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

int main() {
  int a,b,c,X;
  cin >> a >> b >> c >> X;

  int sum = 0;
  int sum_a =0;
  int sum_b =0;
  int sum_c =0;
  int res = 0;
  
  for( int i = 0 ; i <= a; i++){
    sum_a = i*500;
    sum = sum_a;
    if( sum > X) break;

	for( int j = 0 ; j <= b; j++){
      sum_b = j*100;
      sum = sum_a + sum_b;
      if( sum > X) break;
		for( int k = 0 ; k <= c; k++){
          sum_c = k*50;
          sum = sum_a + sum_b + sum_c;
//          cout << "¥500:" << i << " ¥100:" << j << " ¥50:" << k << " sum:" << sum << endl;
			if( sum == X){
            	++res;
//          		cout << "res:" << res << " ¥500:" << i << " ¥100:" << j << " ¥50:" << k << " sum:" << sum << endl;
              	break;
            }
 		}
     }

  }

  cout << res << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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 = 1LL << 60;

//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() {
    ll n;
    cin >> n;
    ll x[n],y[n];
    ll ans=n;
    ll p[n][n],q[n][n];
    for (ll i=0;i<n;i++){
        fill(p[i],p[i]+n,INF);
        fill(q[i],q[i]+n,INF);
        cin >> x[i] >> y[i];
    }
    for (ll i=0;i<n-1;i++){
        for (ll j=i+1;j<n;j++){
            p[i][j]=x[j]-x[i];
            p[j][i]=x[i]-x[j];
            q[i][j]=y[j]-y[i];
            q[j][i]=y[i]-y[j];
        }
    }
    for (ll i=0;i<n-1;i++){
        for (ll j=i+1;j<n;j++){
            ll count=n;
            for (ll k=0;k<n;k++){
                for (ll l=0;l<n;l++){
                    if (x[k]-x[l]==p[i][j] and y[k]-y[l]==q[i][j])count--;
                }
            }
            ans=min(ans,count);
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var B = ReadArrayInt();
            var A = new int[N];
            A[0] = B[0];
            for (int i = 0; i < N - 1; i++)
            {
                if (A[i] > B[i]) A[i] = B[i];
                A[i + 1] = B[i];
            }

            Console.WriteLine(A.Sum());
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main() {
 int l, r, d ;
  scanf("%d", &l);
scanf("%d", &r);
scanf("%d", &d);
if (r % d == 0)
 printf("%d\n", (r-l)/d+1);
else printf("%d\n",(r-l)/d);
return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
#include <stdlib.h>
#define sizemax 100001
int *tree;
int n;
void add(int a,int w){
	for(int x=a;x<=n;x+=x&-x)tree[x]+=w;
}

int sum(int a){
	int ret=0;
	for(int x=a;x>0;x -=x&-x)ret+=tree[x];
	return ret;
}

void init(){
	int i;
	for(i=0;i<=n;i++)
		tree[i]=0;
}

int main(void){
	int w,i,com,x,y;
	scanf("%d %d",&n,&w);
	tree=(int *)calloc(n+1,sizeof(int));
	init();
	for(i=0;i<w;i++){
		scanf("%d %d %d",&com,&x,&y);
		if(com == 0){
			add(x,y);
		}
		if(com == 1)
			printf("%d\n",sum(y)-sum(x-1));
	}
	return 0;
}

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

int f(long a, long b) { return max(to_string(a).size(), to_string(b).size()); }

int main()
{
    long n; cin>>n;
    int res=INT_MAX;
    for(long i=1; i*i<=n; ++i) if (n%i==0) res=min(res, f(i, n/i));
    cout<<res<<endl;
}

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

using namespace std;

static int W, H;
static vector<vector<int>> field;

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

void dfs(int x, int y) {
    if (x < 0 || x >= W || y < 0 || y >= H || field[y][x] == 0)
        return;

    field[y][x] = 0;
    for (int k = 0; k < 8; k++)
        dfs(x + dx[k], y + dy[k]);
}

int main() {
    for (;;) {
        cin >> W >> H;
        if (W == 0) break;

        field.resize(H);
        for (int y = 0; y < H; y++) {
            field[y].resize(W);
            for (int x = 0; x < W; x++) {
                cin >> field[y][x];
            }
        }

        int ans = 0;
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                if (field[y][x] == 1) {
                    dfs(x, y);
                    ans++;
                }
            }
        }

        cout << ans << endl;
    }
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	ll total = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; ++j) {
			for (int k = j; k <= n; ++k) {
				ll t = __gcd(__gcd(i, j), k);
				if (i == j) {
					if (j == k) total += t;
					else total += 3*t;
				} else {
					if (j == k) total += 3*t;
					else total += 6*t;
				}
			}
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		boolean flag = false;
		for(int i = 0; i <= 100/4; i ++){
			for(int j = 0; j <= 100/7; j++){
				if(4 * i + 7 * j == n){
					flag = true;
					break;
				}
			}
			if(flag == true) break;
		}
		
		if(flag == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}

}


Measured memory_bytes: 21844
import sys

input = sys.stdin.readline

n, l = map(int, input().split())

apples = []

for index in range(1, n + 1):
    apples.append(l + index - 1)

sum = sum(apples)
maybe_ans_list = []

for apple in apples:
    maybe_ans_list.append((abs(sum - (sum - apple)), sum - apple))

ans = min(maybe_ans_list,key=lambda x:x[0])

print(ans[1])


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

using namespace std;

int main ()
{
    //freopen ("file.in", "r", stdin);

    int n, a, b, c, d;
    scanf ("%d %d %d %d %d", &n, &a, &b, &c, &d);

    for (int i = 0; i < n; ++i)
        if (1LL * c * (n - 1 - i) - 1LL * d * i <= 1LL * (b - a) && 1LL * (b - a) <= 1LL * d * (n - 1 - i) - 1LL * c * i)
        {
            printf ("YES\n");
            return 0;
        }

    printf ("NO\n");

    return 0;
}


Measured memory_bytes: 128
import numpy as np
N, K = (int(i) for i in input().split())  
A = [int(i) - 1 for i in input().split()] 
N = len(A)

def get_keys_from_value(d, val):
    return [k for k, v in d.items() if v == val][0]

now = 0
lis = []
p = {}
for i in range(N):
  now = A[now]
  if now in p:
    break
  
  p[now] = i
  lis.append(now)

if K < i:
  print(lis[K-1] + 1)
else:
  print(lis[(K-i-1) % (i - p[now]) + p[now]] + 1)
    
  

Measured memory_bytes: 57864
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>
using namespace std;

int main() {
	int A,B;
	bool ans=true;
	string S;
	cin>>A>>B;
	cin>>S;
	for(int i=0;i<S.size();i++)
	{
		if(i==A&&S[i]!='-')ans=false;
		else if(i!=A&&S[i]-'0'<0||S[i]-'0'>9){
			ans=false;
			//cout<<S[i]<<endl;
			}
	}
	cout<<((ans)?"Yes":"No");
	}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const int INFTY = 1e6;

static const int NUMMAX = 300;


int main(){

  int N, K;
  int h;
  int num;

  cin >> N >> K;

  REP(i, N){
    cin >> h;
    if( K <= h )num++;
  }

  cout << num << endl;

  return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

struct st{int a,b,c;};
bool operator<(st&a,st&b){
	if(a.a!=b.a)return a.a<b.a;
	if(a.b!=b.b)return a.b<b.b;
	if(a.c!=b.c)return a.c<b.c;
	return false;
}
bool operator==(st&a,st&b){
	return a.a==b.a&&a.b==b.b&&a.c==b.c;
}
int main(){
	st a,b;cin>>a.a>>a.b>>a.c>>b.a>>b.b>>b.c;
	if(a<b)swap(a,b);//a??????????????\????????????????????????
	if(a==b){puts("0");return 0;}
	if(P(a.b,a.c)<=P(b.b,b.c))cout<<a.a-b.a<<endl;
	else cout<<a.a-b.a+1<<endl;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

vl fact,finv;
ll modpw(ll x,ll k){
	ll res=1;
	while(k!=0){
		if(k&1)res=res*x%MOD;
		x=x*x%MOD;
		k=k>>1;
	}
	return res;
}

ll comb(ll n,ll k) {
	if(n==0&&k==0)return 1;
	if(n<k||n<0)return 0;
	return fact[n]*finv[n-k]%MOD*finv[k]%MOD;
}

struct ferm{
	ferm(ll n){
		fact.resize(n);
		finv.resize(n);
		fact[0]=1;
		finv[0]=1;
		rep(i,n-1){
			fact[i+1]=(fact[i]*(i+1))%MOD;
			finv[i+1]=modpw(fact[i+1],MOD-2);
		}
	}
};
map<ll,ll> primeFactorMp(ll n){
	map<ll,ll> ret;
	for(ll i=2;i*i<=n;i++)if(n%i==0){n/=i;ret[i--]++;}
	if(n-1)ret[n]++;
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ferm(1000001);
	vl v(n);
	rep(i,n)cin>>v[i];
	map<ll,ll> mp;
	rep(i,n){
		auto tmp=primeFactorMp(v[i]);
		for(auto x:tmp){
			chmax(mp[x.fs],x.sc);
		}
	}
	ll gd=1;
	for(auto x:mp){
		rep(i,x.sc){
			gd*=x.fs;
			gd%=MOD;
		}
	}
	ll ans=0;
	rep(i,n){
		ans+=(gd*modpw(v[i],MOD-2))%MOD;
		ans%=MOD;
		//puta(gd*modpw(v[i],MOD-2)%MOD);
	}
	puta(ans);
}


Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define INT long long
#define MOD 1000000007
#define oo 987654321
#define ooLL 99999999987654321ll

using namespace std;

INT a, b, c, A, B, C, ans;

int main()
{
    cin>>a>>b>>c;
    while( ans < 10000000 )
    {
        if( !(a%2==1 or b%2==1 or c%2==1) )
            A = b/2 + c/2, B = a/2 + c/2, C = a/2 + b/2;
        else return cout<<ans<<endl, 0;
        ans++;
        a = A, b = B, c = C;
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
def main():
    #print = out.append
    ''' Cook your dish here! '''
    x, y = get_list()
    res = 100000 * (4-x) if x<=3 else 0
    res += 100000 * (4-y) if y<=3 else 0
    if x==1 and y==1: res += 400000
    print(res)


''' Coded with love at India by Satyam Kumar '''
import sys
#from collections import defaultdict
import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
   ll N,K;
   cin >> N >> K;
   ll ans=0;
   for(ll b=K+1;b<=N;b++){
      ll num = b-K;
      ll lim= N/b;
      ans+=num*lim;
      if(K==0)ans--;
      ans+=max(N-b*lim-(K-1),0ll);
      //cout << b << ":" << lim << endl;
   }
   cout << ans << endl;
   return 0;
}

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

int main (){
    string b;
    cin >> b;
    if (b == "A"){
        cout << "T" << endl;
    } else if (b == "T"){
        cout << "A" << endl;
    } else if (b == "C"){
        cout << "G" << endl;
    } else {
        cout << "C" << endl;
    }
    return 0;
}


Measured memory_bytes: 256