akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) (a.begin(), a.end())
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

ll a[3000];
ll n;

ll f(ll m) {
	ll res = 0;
	for (int i = 0; i < n; ++i) {
		res += m%a[i];
	} 

	return res;
}

void solve() {
	
	cin >> n;
	ll s = 0;
	for (int i=0; i < n; ++i) {
		cin >> a[i];
		s += a[i]-1;
	}
	cout << s << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

	//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int l[2009][2009]={0},r[2009][2009]={0},u[2009][2009]={0},d[2009][2009]={0};
char mp[2009][2009];;
int main()
{
	
	int n,m,i,j,mmax;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{
		scanf("%s",mp[i]+1);
	}
	for (i=1;i<=n;i++)
	{
		l[i][m+1]=m+1;
	}
	for (i=1;i<=m;i++)
	{
		u[n+1][i]=n+1;
	}
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=m;j++)
		{
			if (mp[i][j]=='#') r[i][j]=j;
			 else r[i][j]=r[i][j-1];
		}
		for (j=m;j>=1;j--)
		{
			if (mp[i][j]=='#') l[i][j]=j;
			 else l[i][j]=l[i][j+1];
		}
	}
	for (j=1;j<=m;j++)
	{
		for (i=1;i<=n;i++)
		{
			if (mp[i][j]=='#') d[i][j]=i;
			 else d[i][j]=d[i-1][j];
		}
		for (i=n;i>=1;i--)
		{
			if (mp[i][j]=='#') u[i][j]=i;
			 else u[i][j]=u[i+1][j];
		}
	}
	mmax=-1;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=m;j++)
		{
//			cout<<u[i][j]<<" ";
			mmax=max(mmax,l[i][j]-r[i][j]-d[i][j]+u[i][j]);
		}
//		cout<<endl;
	}
	printf("%d\n",mmax-3);
	return 0;
}

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

  int n,q;
  cin>>n;
  vector <int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  cin>>q;
  for(int i=0;i<q;i++){
    int k;
    cin>>k;
    auto lu=equal_range(a.begin(),a.end(),k);
    cout<<distance(a.begin(),lu.first)<<" "<<distance(a.begin(),lu.second)<<endl;
  }
  return 0;

}



Measured memory_bytes: 3096
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
bool a[705][705];
vector<int>g[705];
bool dp[705][705];
void dfs(int s, int &a,int &b,vector<int>&dist){
    if(dist[s]%2)a++;
    else b++;
    for(int x:g[s]){
        if(dist[x] == -1){
            dist[x] = dist[s] + 1;
            dfs(x,a,b,dist);
        }else{
            if(dist[x]%2==dist[s]%2){
                cout << -1 << endl;
                exit(0);
            }
        }
    }
}
int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int c,d;
        cin >> c >> d;
        c--,d--;
        a[c][d] = true;
        a[d][c] = true;
    }
    rep(i,n)a[i][i] = true;
    rep(i,n)rep(j,n)if(!a[i][j])g[i].push_back(j);
    vector<pii>vec;
    vector<int>dist(n,-1);
    rep(i,n){
        if(dist[i] == -1){
            dist[i] = 0;
            int a,b;
            a = b = 0;
            dfs(i,a,b,dist);
            vec.emplace_back(a,b);
        }
    }
    dp[0][0] = true;
    rep(i,vec.size()){
        rep(j,n+1){
            if(dp[i][j]){
                dp[i+1][j+vec[i].first] = true;
                dp[i+1][j+vec[i].second] = true;
            }
        }
    }
//    set<int>st;
//    set<int>st2;
//    rep(i,vec.size()){
//        auto x = vec[i];
//        if(i==0){
//            if(x.first)st2.insert(x.first);
//            if(x.second)st2.insert(x.second);
//        }else{
//            for(int y:st){
//                st2.insert(y + x.first);
//                st2.insert(y + x.second);
//            }
//        }
//        swap(st,st2);
//    }
    int ans = INT_MAX;
    rep(x,n+1)if(dp[vec.size()][x]){
        ans = min(ans, x*(x-1)/2 + (n-x)*(n-x-1)/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
N = int(input())

A = list(map(int, input().split()))

count = 0
scount = 0
sscount = 0
for i in range(N):
    if A[i] % 4 == 0:
        count += 1
    elif A[i] == 2:
        scount += 1
    elif A[i] % 2 == 0:
        scount += 1


subcount = 0
subcount = scount // 2

# subcount = min(scount, sscount)

if N % 2 == 0:
    _l = int(N / 2)
    if _l <= subcount + count:
        print('Yes')
        exit()

else:
    _l = N // 2
    if _l <= subcount + count:
        print('Yes')
        exit()


print('No')



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

int main(){
	int x, y;
	
	while(1){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}
		
		if(x < y){
			cout << x << " " << y << endl;
		}else{
			cout << y << " " << x << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int a[10];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)
	{
		int x;
		scanf("%d",&x);
		mp[x]=1;
	}
	int t=n;
	while(true)
	{
		int tt=t;
		bool f=true;
		while(tt)
		{
			if(mp[tt%10])f=false;
			tt/=10;
		}
		if(f)break;
		t++;
	}
	printf("%d",t);
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, T; scanf("%d %d", &N, &T);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  int least = A[0];
  vector<int> P(N);
  for (int i = 0; i < N; ++i) {
    P[i] = A[i] - least;
    least = min(least, A[i]);
  }
  sort(P.begin(), P.end(), greater<int>());
  int i = 0;
  while (i < N and P[i] == P[0]) { ++i; }
  int ans = i;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
 
int main(void)
{
  int i,j,n,a,b,c,x,res,spe[102];
 
  while(scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n){
    for(i=0;i<n;i++){
      scanf("%d", &spe[i]);
    }
 
    res=0;
    for(i=0;i<n;i++,x=(a*x+b)%c,res++){
      while(spe[i]!=x){
        x=(a*x+b)%c;
        res++;
        if(res>10000){
          res=-1;
          break;
        }
      }
      if(res==-1) break;
    }
    if(res!=-1) res--;
    printf("%d\n", res);
  }
 
  return 0;
}


Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    map<int, int> mp;
    mp[1] = 2; mp[2] = 5; mp[3] = 5;
    mp[4] = 4; mp[5] = 5; mp[6] = 6;
    mp[7] = 3; mp[8] = 7; mp[9] = 6;

    vector<string> dp(10010, "");
    vector<bool> ok(10010, false);

    ok[0] = true;
    rep(i,n) {
        if (!ok[i]) continue;
        for (int v : a) {
            if (dp[i+mp[v]].size() < dp[i].size()+1 || dp[i+mp[v]] < dp[i]+to_string(v)) {
                dp[i+mp[v]] = dp[i]+to_string(v);
                ok[i+mp[v]] = true;
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 30160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

#define MAX_N 500
vector<int> to[MAX_N + 1];

int n, m, q;

int main() {
    cin >> n >> m >> q;
    int l, r;
    rep(i, m) {
        scanf("%d%d", &l, &r);
        to[l].push_back(r);
    }
    reps(i, n) { sort(all(to[i])); }
    rep(i, q) {
        scanf("%d%d", &l, &r);
        int ans = 0;
        repc2(j, l, r) { ans += (int)(upper_bound(all(to[j]), r) - to[j].begin()); }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 2176
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

#define MOD 998244353
using namespace std;

// }}}

int main(){
        int N,K;

        cin>>N>>K;
        vector<pair<int, int> > seg;

        FOR(i,0,K) {
                int L,R;
                cin>>L>>R;
                seg.push_back(pair<int,int>(L,R));
        }

        long long cur=0;

        long long a[500000];

        FOR(i,0,N+1) a[i]=0;
        a[0]=1;
        a[1]=-1;

        FOR(i,0,N) {
                cur=(cur+a[i])%MOD;
                FOR(j,0,seg.size()){
                        a[i+seg[j].first] = (a[i+seg[j].first] + cur) % MOD;
                        a[i+seg[j].second + 1] = (a[i+seg[j].second + 1] - cur) % MOD;
                }
        }

        cout<<(cur+MOD)%MOD<<endl;


}


Measured memory_bytes: 6752
#define _USE_MATH_DEFINES

#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

int main() {
	int n,d;
	cin >> n >> d;
	int cnt = 0;
	for (int i=0; i<n; i++) {
		float x,y;
		cin >> x >> y;
		if (sqrt(pow(x, 2.0) + pow(y, 2.0)) <= d) {
			cnt++;
		} 
	}

	cout << cnt << endl;
}

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

const int inf = 1e9;

signed main(void){
  int N,M; cin >> N >> M;
  
  vector<int> ans;
  
  int SIZE = N+1;
  
  vector<vector<int>> to(N);
  
  for(int i = 0; i < M; i++){
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b);
  }
  
  for(int s = 0; s < N; s++){ 
    //どの地点からスタートするか
    vector<int> dist(N,inf);
    vector<int> par(N,-1);
    
    queue<int> Q; Q.push(s); //sからBFS
    
    dist[s] = 0;
    
    while(!Q.empty()){
      int p = Q.front(); Q.pop();
      for(auto v : to[p]){
        if( dist[v] != inf ){ //すでに行ったことがある
          continue;
        }
        dist[v] = dist[p]+1; par[v] = p;
        Q.push(v);
      }
    }
    
    for(int t = 0; t < N; t++){ 
      //終点を決める
      if( t == s || dist[t] == inf ){ continue;}
      
      for(auto ne : to[t] ){ 
        if( ne == s ){ 
          //この時、sからtにかけてのループが形成できると言える。
          int pos = t;
          vector<int> vec;
          while(pos != s){ 
            vec.push_back(pos); 
            pos = par[pos];
          }
          
          vec.push_back(pos);
          
          if( SIZE > vec.size() ){ 
            SIZE = vec.size();
            ans = vec;
          }
          
          
        } // if - ne==s
      }//for-auto
      
    }//終点決定
  }//始点決定
  
  reverse(ans.begin(),ans.end());
  if(ans.empty()){ cout << -1 << endl; return 0;}
  cout << (int)ans.size() << endl;
  
  for(auto ne : ans){
    cout << ne+1 << endl;
  }
  
  return 0;
}

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

using namespace std;

typedef long long LL;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}


int main(){
    int R,C;
    cin>>R>>C;
    REP(r,R)REP(c,C){
        string s;cin>>s;
        if(s=="snuke"){
            cout<<(char)('A'+c)<<r+1<<endl;
            return 0;
        }
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define 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>>;
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 int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


VVI v;
int n, m, q;
void f(int i,int k,VI w) {
	if (i == n) {
		v.push_back(w);
		return;
	}
	FOR(j, k, m + 1) {
		VI z = w;
		z.push_back(j);
		f(i + 1, j, z);
	}
}


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

	VI a(q), b(q), c(q), d(q);
	REP(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;
		b[i]--;

	}

	f(0, 1, {});

	int ans = 0;

	for (VI e : v) {
		int cur = 0;
		REP(i, q) {
			if (e[b[i]] - e[a[i]] == c[i]) {
				cur += d[i];
			}
		}
		ans = max(ans, cur);
	}
	cout << ans << endl;

	
}


Measured memory_bytes: 9864
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    int r;
    cin >> r;

    cout << r*r << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<math.h>
#include<map>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;
#define INF int(1e9)
#define MP make_pair
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,a) for(LL  i=0;i<(a);++i)
typedef pair<int, int> P;
typedef pair<pair<P, P>, P>PP;
string a;
LL tori[2000001], ans;
LL bunkai[40];
int main()
{
	cin >> a;
	FOR(i, 1, a.size() + 1)
	{
		tori[i] = i * (i - 1) / 2;
	}
	REP(i,a.size())
	{
		bunkai[a[i] - 'a']++;
	}
	ans += tori[a.size()];
	ans++;
	REP(i, 'z' - 'a' + 1)
	{
		ans -= tori[bunkai[i]];

	}

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

Measured memory_bytes: 2180
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a), __##i = (b); i < __##i; i += (s))
#define down(i, a, b, s) for (int i = (a), __##i = (b); _##i < i; i -= (s))

const int maxn = 102;

int n, a[maxn];

int main(int argc, char const *argv[]) {
  // freopen("B.txt", "r", stdin);

  while (cin >> n) {
    range(i, 0, n, 1) cin >> a[i];
    int sum = 0;
    range(i, 0, n, 1) sum += a[i];
    int ans = sum, cnt = 0;
    range(i, 0, n, 1) {
      cnt += a[i];
      ans = min(ans, abs(cnt - (sum - cnt)));
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef long long int llu;

llu max(llu a, llu b) {
    return (a < b) ? b : a;
}

int main() {
    // INPUT
    int N, W;
    scanf("%d%d", &N, &W);

    int w[N], v[N];
    for (int i = 0; i < N; ++i) {
        scanf("%d%d", &w[i], &v[i]);
    }

    // INITIALIZE
    llu *dp = (llu*) calloc(W+1, sizeof(llu));

    // DP
    for (int i = 1; i <= N; ++i) {
        for (int j = W; j >= w[i-1]; --j) {
            dp[j] = max( dp[j-w[i-1]] + v[i-1] , dp[j] );
        }
    }

    // OUTPUT
    printf("%llu\n", dp[W]);
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 107 D / Link: http://abc107.contest.atcoder.jp/tasks/abc107_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


template<typename type>
struct BIT0 { // 0-index
	int N;
	int nn;
	vector<type> data;
	BIT0(int n) {
		N = n + 1;
		data = vector<type>(n + 1, 0);
		nn = 1;
		while (nn * 2 <= N)nn *= 2;
	}
	void add(int i, type w) { // a[i] += w
		i++;
		for (int x = i; x < N; x += x & -x) {
			data[x] += w;
		}
	}
	type sum(int i) { // iまでの和 [0,i)
		type ret = 0;
		for (int x = i; x > 0; x -= x & -x) {
			ret += data[x];
		}
		return ret;
	}
	// [l, r)
	type sum(int l, int r) {
		return sum(r) - sum(l);
	}
};

LL ans = 0LL;

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

	LL N; cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	auto b = a;
	SORT(b);

	auto f = [](const VL& a, LL x) { // x以上の値が過半数を占める連続部分列の総数
		int N = SZ(a);
		LL cnt = 0;
		BIT0<LL> bit(2 * N + 10);
		int cur = N + 5;
		FOR(i, 0, N) {
			bit.add(cur, 1);
			if (a[i] < x)cur--;
			else cur++;
			cnt += bit.sum(cur + 1); // 上側からなので良い

		}
		return cnt;
	};
	int L = 0;
	int R = N;
	while (R - L > 1) {
		int mid = (L + R) / 2;
		if (f(a, b[mid]) * 4 >= N * (N + 1)) {
			L = mid;
		}
		else {
			R = mid;
		}
	}
	ans = b[L];
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3456
n, k = map(int, input().split())
x = list(map(int, input().split()))
# for i in range(n):
#     if x[i] >= 0:
#         ln = i
#         break
import bisect
ln=bisect.bisect_right(x,0)

l = [0] + x[:ln][::-1]
r = [0] + x[ln:]
ans = 1000000000000
for i in range(k + 1):
    if i >= len(l): continue
    if k - i >= len(r): continue
    t= -l[i] + r[k - i] + min(-l[i], r[k - i])
    ans = min(ans,t)
print(ans)

Measured memory_bytes: 14252
/*
 * 	Roses are red
 * 		Violets are blue
 * 			I cried
 * 				And so did you
 */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int bolck[10];
void solve() {
	int n,k;
	cin>>n>>k;
	fr(i,1,n) {
		int te;
		cin>>te;
		bolck[te]=1;
	}
	for(int i=n; ; i++) {
		int te=i;
		int valid=1;
		while(te>0) {
			if(bolck[te%10])
				valid=0;
			te/=10;
		}
		if(valid) {
			cout<<i<<endl;
			return;
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, a[100]={0};
    cin >> n;
    for(int i =0; i<n; i++){
        cin >> a[i];
    }
    for(int i =n-1; i>=0; i--){
        if (i==n-1){
        cout << a[i];
        }
        else{
            cout << " " << a[i];
        }
    }
    cout << endl;
}



Measured memory_bytes: 3108
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
R = I()
if R < 1200:
    print('ABC')
elif R < 2800:
    print('ARC')
else:
    print('AGC')

Measured memory_bytes: 68428
#include <stdio.h>
#include <string.h>

int main(void){
	int i, j, point[1001], n, s, sum, cnt;
	scanf("%d",&n);
	while(n != 0){
		memset(point,0,sizeof(point));
		for(i = 0;i < n;i++){
			scanf("%d",&s);
			point[s]++;
		}
		for(i = 0;i <= 1000;i++){
			if(point[i]){
				point[i]--;
				break;
			}
		}
		for(i = 1000;i >= 0;i--){
			if(point[i]){
				point[i]--;
				break;
			}
		}
		sum = 0;
		cnt = 0;
		for(i = 0;i <= 1000;i++){
			for(j = 0;j < point[i];j++){
				sum += i;
				cnt++;
			}
		}
		printf("%d\n",sum / cnt);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1032
from collections import defaultdict
from math import sqrt
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N = int(input())
S = []

x = 0
for a in map(int, input().split()):
    x ^= a
    S.append(x)

A = defaultdict(int)
B = defaultdict(int)
L = defaultdict(int)
Z = 0

if S[-1] != 0:
    sr = S[-1]
    a, b = 0, 0
    for s in S:
        if s == sr:
            b =  (b + a + 1)%MOD
        elif s == 0:
            a = (a + b)%MOD
    print(a+1)
else:
    for s in S:
        if s == 0:
            Z += 1
        else:
            A[s] = (A[s] + (Z - L[s])*B[s])%MOD
            B[s] = (A[s] + B[s] + 1)%MOD
            L[s] = Z
    print((sum(B.values()) + pow(2, Z-1, MOD))%MOD)

Measured memory_bytes: 138336
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int n1 , n2;
	vector<int> val1 , val2 , ans;
	int input;

	cin >> n1 >> n2;

	for (int i = 0; i < n1; i++)
	{
		cin >> input;
		val1.push_back(input);
		ans.push_back(0);
	}
	for (int i = 0; i < n2; i++)
	{
		cin >> input;
		val2.push_back(input);
	}

	for (int i = 0; i < n2; i++)
	{
		for (int j = 0; j < n1; j++)
		{
			if (val2[i] >= val1[j])
			{
				ans[j]++;
				break;
			}
		}
	}

	int Max = -100;
	int index = -1;

	for (int i = 0; i < ans.size(); i++)
	{
		if (ans[i] > Max)
		{
			Max = ans[i];
			index = i;
		}
	}

	cout << index + 1 << endl;

	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
   int n,k,count,ans;
   ans=0;
   cin>>n>>k;
   rep(i,n){
     cin>>count;
     if(abs(count-k)>count){
       ans+=count*2;
     }else{
       ans+=abs(count-k)*2;
     }
   }
     cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
//dp[i]: i円引き出すのに必要な操作回数の最小値
ll dp[100100];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;
    rep(i,N+1)dp[i] = INFLL;
    dp[0] = 0;
    ll e[] = {6, 9};
    rep(j,2){
        ll cost = 1;
        while(cost <= N){
            rep(i,N){
                if(dp[i] == INFLL)continue;
                if(i + cost > N)continue;
                chmin(dp[i+cost], dp[i] + 1);
            }
            cost *= e[j];
        }
    }
    cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
import { COPYFILE_FICLONE_FORCE } from 'constants';

namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  const checkFlag = (f: any) => {
    return f['A'] && f['B'] && f['C'];
  };

  async function slove() {
    const sc = new Scanner();
    const input = [];
    for (let i = 0; i < 5; i += 1) {
      input.push(+(await sc.getLine()));
    }
    let ans = 0;
    let max = 10000;
    const ary = [];
    for (let i = 0; i < 5; i += 1) {
      const val = input[i];
      if (val % 10 === 0) {
        ans += val;
      } else {
        const d = val % 10;
        max = Math.min(d, max);
        ary.push(val);
      }
    }
    let f = false;
    for (const v of ary) {
      if (!f && v % 10 === max) {
        ans += v;
        f = true;
      } else {
        ans += Math.ceil(v / 10) * 10;
      }
    }
    console.log(ans);
    sc.close();
  }

  slove();
}


Measured memory_bytes: 7500
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N; cin >> N ;
  vector<ll> A,B;

  
  rep(i,N){
    ll inp;cin >> inp;
    A.pb(inp);
  }
  rep(i,N){
    ll inp; cin >> inp;
    B.pb(inp);
  }

  ll suma = 0;
  ll sumb = 0;

  rep(i,N){
    suma += A[i];
    sumb += B[i];
  }
  
  ll times = sumb - suma;
  ll at = 0 ,bt = 0;
  
  rep(i,N){
    if(A[i] < B[i]){
      at += ((B[i]-A[i])/2 + ((B[i]-A[i])%2));
      if((B[i]-A[i]) %2) bt ++;
    }
    else
      bt += A[i]-B[i];
  }
  
  
  
  if( at >= bt ) cout << "Yes" << endl;
  else cout <<"No" << endl;
  

  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
      	String s = sc.next();
      	int count = 0;
      	for(int cnt = 0;cnt < n.length();cnt++){
        	if(n.charAt(cnt) != s.charAt(cnt)){
            	count++;
            }
        }
      	System.out.println(count);
	}
}

Measured memory_bytes: 41004
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int r,c,K;cin >> r >> c >> K;
  vector<string> v(r);
  for(int i=0;i<r;i++) cin >> v[i];
  int L = 1<<r-1;
  int ans = r-1 + c-1;
  int cnt[r];
  for(int i=0;i<L;i++){
    int nn = __builtin_popcount(i);
    int h = nn;
    memset(cnt,0,sizeof(cnt));
    int lst = 0;
    for(int j=0;j<c;j++){
      for(int k=0;k<=nn;k++){
        if(cnt[k]>K){
          memset(cnt,0,sizeof(cnt));
          lst = j;
          h++;
        }
      }
      int id = 0;
      for(int k=0;k<r;k++){
        cnt[id] += v[k][j]-'0';
        if((1<<k)&i) id++;
      }
      for(int k=0;k<=nn;k++){
        if(cnt[k]>K){
          if(lst==j){
            lst = -1;
          }
          memset(cnt,0,sizeof(cnt));
          id = 0;  
          lst = j;
          for(int k=0;k<r;k++){
            cnt[id] += v[k][j]-'0';
            if((1<<k)&i) id++;
          }
          h++;
          break;
        }
      }
      for(int k=0;k<=nn;k++){
        if(cnt[k]>K && lst==j){
          lst = -1;
        }
      }
      if(lst==-1) break;
    }
    if(lst!=-1)
      ans = min(ans,h);
    // cout << i << " " << h << " " << lst << endl;
  } 
  cout << ans << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 256
import numpy as np

X, Y = map(int, input().split())

cranes = np.arange(X+1) * 2
turtles = (np.arange(X+1)*4).reshape(-1,1)

total = np.diag(np.fliplr(cranes + turtles))


if np.any(total == Y):
  print('Yes')
else:
  print('No')
                    

Measured memory_bytes: 27328
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static int solve() {
		int[] v = new int[10];
		for (int i = 0; i < 10; ++i) {
			v[i] = sc.nextInt();
		}
		Arrays.sort(v);
		return v[9] + v[8] + v[7];
	}

	public static void main(String[] args) {
		int a = solve();
		int b = solve();
		System.out.println(a + " " + b);
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

vector<bool > prime;

//primeListには素数は入ってません
void isPrime(ll N){
    prime[0] = false;
    prime[1] = false;

    //ルートN以下まで繰り返す
    for(ll i = 2; i < ceil(sqrt(N)) ; i++){
        //素数になりえないとき
        //cout << i << endl;
        if(!prime[i]) continue;
        
        //Nまでのi(素数)の倍数を斑入り落とす
        for(ll j = i * i; j <= N; j += i){
            prime[j] = false;
        }    
    }
}

int main() {

    //準備
    prime.assign(101, true);
    isPrime(100);

    ll N;
    cin >> N;

    //N!の素因数
    map<ll, ll > PF;
    for(ll i = 1; i <= 100; i++){
        ll cn = 0;
        if(prime[i] == true){
            ll j = i;
            while(N / j > 0){
                PF[i] += N / j;
                cn += N / j;
                j *= i;

            }
        }
        //cout << cn << endl;
    }

    ll num75 = 0;
    ll num25 = 0;
    ll num15 = 0;
    ll num5 = 0;
    ll num3 = 0;


    auto begin = PF.begin(), end = PF.end();
    for (auto iter = begin; iter != end; iter++) {
        ll cn = iter->second;
        if(cn >= 2) num3++;
        if(cn >= 4) num5++;
        if(cn >= 14) num15++;
        if(cn >= 24) num25++;
        if(cn >= 74) num75++;
    }

    ll ans = num75;
    //重複して数えているのでマイナス１する
    ans += (num5 - 1) * num15;
    ans += (num3 - 1) * num25;
    ans += (num3 - 2) * num5 * (num5 - 1) / 2;

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int r;
	cin >> r;
	cout << (double)r * 3.141592 * 2 << endl;
}




Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll a = 1000000000;
    ll s;
    ll x1,x2,y1,y2;
    cin >> s;
    if (s == a * a)
    {
        cout << "0 0 1000000000 0 0 1000000000";
        return 0;
    }
    x1 = a;
    y2 = s / a + 1;
    y1 = 1;
    x2 = a - s % a;
    cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll Q;
ll A[200], B[200];

bool can_pair(ll a, ll b, ll k) {
  if ((a + k) % 2 == 0) {
    return ((a + k) / 2) * ((a + k) / 2) < a * b;
  } else {
    return ((a + k - 1) / 2) * ((a + k + 1) / 2) < a * b;
  }
}

int main() {
  cin >> Q;
  rep(i, 0, Q) { cin >> A[i] >> B[i]; }

  rep(i, 0, Q) {
    ll a = A[i];
    ll b = B[i];
    if (a > b) {
      swap(a, b);
    }

    ll ub = b;
    ll lb = a;
    ll k = (ub + lb) / 2;
    while (ub - lb > 1) {
      ll k = (ub + lb) / 2;
      if (can_pair(a, b, k)) {
        lb = k;
      } else {
        ub = k;
      }
    }
    cout << a + lb - 2 << endl;
  }
}


Measured memory_bytes: 256
P = 998244353
N =int(input())
S = input()
X = [0] * 3
D = {"R":0, "G":1, "B":2}
ans = 1
for i in range(1, N+1):
    ans = ans * i % P
for s in S:
    i = D[s]
    if min(X[i-1], X[i-2]):
        ans = ans * min(X[i-1], X[i-2]) % P
        X[i-1] -= 1
        X[i-2] -= 1
    else:
        ans = ans * max(X[i-1]+X[i-2]-X[i], 1) % P
        X[i] += 1
print(ans)


Measured memory_bytes: 3828
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  if ((A == B && A != C) || (B == C && A != B) || (A == C && B != C))
    cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
a-=1
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        a = abs(a)
        b = abs(b)
        while b:
            a, b = b, a % b
        return a
    return a * b // gcd(a, b) # int

print(b-b//c-b//d+b//lcm(c,d)-(a-a//c-a//d+a//lcm(c,d)))


Measured memory_bytes: 38256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanln(&a, &b)
	var s string
	switch {
	case a > b:
		s = ">"
	case a < b:
		s = "<"
	default:
		s = "=="
	}
	fmt.Print("a " + s + " b\n")
}


Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    if(s[1]==s[2] && s[0]==s[1]) cout<<"Yes";
    else if(s[1]==s[2] && s[2]==s[3]) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

int32_t main() { 
    boost;

    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    int l[n+1],r[n+2];
    l[0]=r[0]=0;
    int last = -c-1;
    for(int i=1;i<=n;i++){
    	if(s[i-1]=='x')
    		l[i]=l[i-1];
    	else{
    		if(i>last+c){
    			l[i]=l[i-1]+1;
    			last=i;
    		}
    		else
    			l[i]=l[i-1];
    	}
    }
   	
   	last=n+c+1;
   	r[n+1]={0};
   	for(int i=n;i>0;i--){
   		if(s[i-1]=='x')
   			r[i]=r[i+1];
   		else {
   			if(last-i>c){
   				r[i]=r[i+1]+1;
   				last=i;
   			}
   			else
   				r[i]=r[i+1];
   		}
   	}
   	//print(l,n+1);
   	//print(r,n+1);
   	for(int i=1;i<=n;i++){
   		if(s[i-1]=='o' && l[i-1]+r[i+1]<k && l[i]+r[i]==k+1)
   			cout<<i<<endl;
   	}
}           





Measured memory_bytes: 5012
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,i=0,j,c=0,p,h[1000010],m=0,max=0;
    string s;
    cin >> s;
    p=s.size();
    for(i=1;i<p;i++)
    {
        if(i%2==1 && s[i]==s[0])
        {
            max++;
        }
        else if(i%2==0 && s[i]!=s[0])
        {
            max++;
        }
            
    }
    cout << max << endl;
    return 0;

}


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

#define         ull             unsigned long long
#define         ll              long long
#define         inf             INT_MAX
#define         pi              acos(-1.0)
#define         vi              vector<int>
#define         vl              vector<long long>
#define         pii             pair<int,int>
#define         pll             pair<long long,long long>
#define         mp              make_pair
#define         mii             map<int,int>
#define         mll             map<int,int>
#define         mli             multimap<int,int>
#define         mlll            multimap<long long,long long>
#define         msi             multiset<int>
#define         msl             multiset<long long>
#define         si              set<int>
#define         sl              set<long long>
#define         FOR(I,A,B)      for(int I = (A); I < (B); I++)
#define         rev(I,A,B)      for(int I = A ; I >= B ; I--)
#define         mem(a, v)       memset(a, v, sizeof (a))
#define         mod             1000000007
#define         all(a)          a.begin(),a.end()
#define         rall(a)         a.rbegin(),a.rend()
#define         ff              first
#define         ss              second
#define         arsort(ar,n)    sort(ar,ar+n);
#define         vsort(v)        sort(v.begin(),v.end())
#define         vrev(v)         reverse(v.begin(),v.end())
#define         arrev(ar,n)     reverse(ar,ar+n)
#define         pb              push_back
#define         popb            pop_back
#define         booster()       ios_base::sync_with_stdio(0); cin.tie(0);
#define         read(f)         freopen(f, "r", stdin)


#define         min3(a,b,c)     min(a,min(b,c))
#define         max3(a,b,c)     max(a,max(b,c))
#define         min4(a,b,c,d)   min(min(a,b),min(c,d))
#define         max4(a,b,c,d)   max(max(a,b),max(c,d))
#define         max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define         min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))


#define         bitCheck(a,k)     ((bool)(a&(1<<(k))))
#define         bitOff(a,k)       (a&(~(1<<(k))))
#define         bitOn(a,k)        (a|(1<<(k)))
#define         bitFlip(a,k)      (a^(1<<(k)))


int fx[] = {-1,+0,+1,+0,+1,+1,-1,-1,+0};
int fy[] = {+0,-1,+0,+1,+1,-1,+1,-1,+0};
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

using namespace std;

bool comp(int x, int y) { return x > y; }

/*********************** let the play begin() ***********************************/

int main()
{
    booster()
    int n,k,sum=0;
    cin>>n>>k;
    int arr[n+5];
    FOR(i,0,n)
        cin>>arr[i];
    arsort(arr,n);
    reverse(arr,arr+n);
    FOR(i,0,k)
        sum+=arr[i];
    cout<<sum;
    return 0;
}


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

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

using namespace std;

typedef long long ll;

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

  int n; cin >> n;
  int ans = 800 * n - n/15 * 200;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+5
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define int long long
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;

int32_t main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << ((c-1+b)/b <= (a+d-1)/d ? "Yes" : "No") << endl;
}






Measured memory_bytes: 3644
/*By vscode, especially checked x+2^y*/i,A=-1,a[14]={0,1,1,1,7,4,1,336,384,334,220,108,36,6},b[10]={108,220,334,384,334,220,108,36,6};main(){long long n;scanf("%lld",&n);if(n<14)A=a[n];else if(n==27||n==134217723)A=976;else if(n==29||n==536870907)A=4;else if(n==61||n==2305843009213693946)A=1;else if(n==1152921504606846970)A=220;else if(n==268435451)A=108;else for(i=0;i<9;i++)if(pow(2,i+5)-n==4)A=b[i];printf("%d",A);}

Measured memory_bytes: 2532
#include <stdio.h>

int main(void)
{
	int l, m, n, mnth;
	int i;

	while (1) {
		mnth = 0;
		scanf("%d", &l);
		if (l == 0) 
			break;
		for (i = 0; i < 12; i++) {
			scanf("%d%d", &m, &n);
			l -= m - n;
			if (l > 0) 
				mnth++;
		}
		if (l > 0)
			puts("NA");
		else
			printf("%d\n", mnth + 1);
	}
	
	return 0;
}

Measured memory_bytes: 608