akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)

using namespace std;

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

	int K, S;
    cin >> K >> S;
	int ans = 0;
  	for (int i = 0; i < K+1; i++)
	  {
		  for (int j = 0; j < K+1; j++)
		  {
			  if(S-i-j>K || S-i-j<0) continue;
			  else ans++;
		  }
	  }
	cout << ans << endl;
}

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


int main(){
  string s;
  cin >> s;
  int count = 0;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) == 'o'){
      count++;
    }
  }
  
  if(15-s.size() >= 8-count){
    cout << "YES" << endl;
  }else{
    cout << "NO"<< endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

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

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

struct combination {
  //fact 階乗　iface 階乗の逆数
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint f(int n,int m) {//mのn乗
  if (n == 0) return 1;
  mint x = f(n/2,m);
  x *= x;
  if (n%2 == 1) x *= m;
  return x;
}

int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    mint ans = 0;
    combination c(200005);
    //cout << c(4,2).x << endl;
    rep(i,k+1){
        //cout << ans.x << endl;
        mint res = 1;
        res *= m;
        res *= f(n-1-i,m-1).x;
        res *= c(n-1,i).x;
        ans += res;
        //ans += m*f(n-1-i,m-1).x*c(n-1,i).x;
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 6420
fun main(args: Array<String>) {
    var N = readLine()!!.split(" "). map { it.toInt() }.first()
    var h = readLine()!!.split(" "). map { it.toInt() }
    val dp = IntArray(N) {Integer.MAX_VALUE}
    dp[0] = 0
    for (i in 1 until N) {
        dp[i] = Math.min(dp[i], dp[i-1] + Math.abs(h[i] - h[i-1]))
        if (i > 1) {
            dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]))
        }
    }
    println(dp[N-1])
}

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

int main () {
  vector<string> weth={"Sunny","Cloudy","Rainy","Sunny"};
  string s;
  cin >> s;

  for (int i=0;i<3;++i) {
    if (s==weth[i]) {
      cout << weth[i+1] << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int N,M;
int r,q;
int a[1010],b[1010],c[1010],d[1010];

int main(){
	while(1){
		cin>>N>>M;
		if(N==0&&M==0)break;
		cin>>r;
		REP(i,r){
			cin>>a[i]>>b[i]>>c[i]>>d[i];
		}
		
		cin>>q;
		for(int i=0;i<q;i++){
			int ans=0;
			int ts,te,m;
			cin>>ts>>te>>m;
			for(int sec=ts;sec<te;sec++){
				int login=0;
				for(int j=0;j<r;j++){
					if(c[j]==m){
						if(a[j]<=sec){
							if(d[j]==0)login--;
							else login++;
						}
					}
				}
				if(login)ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3012
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <list>          // list
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

struct Point
{
    double x, y;
};

void koch(int n, Point a, Point b)
{
    if (n == 0)
        return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    cout << fixed << setprecision(8) << s.x << " " << fixed << setprecision(8) << s.y << endl;
    koch(n - 1, s, u);
    cout << fixed << setprecision(8) << u.x << " " << fixed << setprecision(8) << u.y << endl;
    koch(n - 1, u, t);
    cout << fixed << setprecision(8) << t.x << " " << fixed << setprecision(8) << t.y << endl;
    koch(n - 1, t, b);
}

int main()
{
    int n;
    cin >> n;
    Point a, b;
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    cout << fixed << setprecision(8) << a.x << " " << fixed << setprecision(8) << a.y << endl;
    koch(n, a, b);
    cout << fixed << setprecision(8) << b.x << " " << fixed << setprecision(8) << b.y << endl;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
  int n;
  cin >> n;
  std::vector<int> d(n);
  REP(i,n) cin >> d[i];

  lint cnt = 0;
  for(int i=0;i<n-1;i++){
    lint tmp = 0;
    for(int j=i+1;j<n;j++){
      tmp += d[j];
    }
    cnt += d[i]*tmp;
  }

  cout << cnt << "\n";
  return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

vector<int> mp(200001, 0);


int main(){

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

    int N, K;
    cin >> N >> K;


    rep(i, N){
        int a;
        cin >> a;
        mp[a]++;
    }

    sort(mp.begin(), mp.end());
    reverse(mp.begin(), mp.end());

    int keep = 0;
    int cnt = 0;
    for(auto m : mp){
        if(cnt == K) break;
        keep += m;
        cnt++;
    }

    ppp(N-keep);





    return 0;
}


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

int swap(int &x,int &y){
  int temp;
  temp = x;
  x = y;
  y = temp;
}

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  swap(A,B);
  swap(A,C);
  cout << A << " " << B << " " << C << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

while line = gets do
  a, b, c, d, e, f = line.split.map(&:to_i)
  ans1 = ((e*c-b*f)*1.0/(a*e-b*d)*1000).round/1000.0
  ans2 = ((a*f-d*c)*1.0/(a*e-b*d)*1000).round/1000.0
  printf("%.3f %.3f\n", ans1, ans2)
end

Measured memory_bytes: 6148
#include <bits/stdc++.h>
 
using namespace std;
 
#define SZ(x) ((int)(x).size())
using namespace std;
typedef pair<int,int> PII;
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = a; i <= b; ++i)
#define M 1000000007
#define MM 998244353
#define SZ(a) int((a).size())
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define mod 1000000007
using ll = long long;

//a and b are assumed to be taken modulo p
inline ll add(ll a, ll b, ll p = mod){ ll c = a + b; if(c >= p) c -= p; return c; }
inline ll sub(ll a, ll b, ll p = mod){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll mul(ll a, ll b, ll p = mod){ return (a * 1ll * b) % p; }
 
using VI = vector<int>;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using VLL = vector<ll>;
using ld = long double;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*1ll*x) % p;
    }
    return res;
}
const int MX = 2e5+10;
const int MX2 = 1e6+5;

ll INF= 4 * (ll)1e18;
int mx = 2 * (ll)1e9 + 10;
set<ll> Sx[MX];
set<ll> Sy[MX];
int main(int argc, const char * argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); // insert code here...
    
    ll k,n;
    cin >> k >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans = 2e9;
    ans = k - (a[0] - a[n - 1] + k) % k;
    for (int i = 0; i < n - 1; i++) {
        ll diff = a[i + 1] - a[i];
        if (k - diff < ans) ans = k - diff;
    }
    cout << ans << endl;
    return 0;
    
}


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

int main()
{
	int A, B, K;

	cin >> A >> B >> K;

	int count = 0;
	vector<int> vc;
	for (int loop = A; loop <= B; ++loop) {
		if (count < K) {
			vc.push_back(loop);
		} else {
			break;
		}
		++count;
	}

	count = 0;
	for(int i = B; i > A; --i) {
		if (count < K) {
			vc.push_back(i);
		} else {
			break;
		}
		++count;
	}

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

	vc.erase( unique(vc.begin(), vc.end()), vc.end() );

	for(int i = 0; i < vc.size(); i++) {
		cout << vc[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define REP(type,i,n) for(type i=0;i<(n);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> Pi;

const int INF=100000000;
const long long int INF_=1000000000000000000;

struct Edge{
	int from,to,cost;
	Edge():from(-1),to(-1),cost(INF){}
	Edge(int a=-1,int b=-1,int c=INF):from(a),to(b),cost(c){}
};

void BellmanFord(int s,vector<Edge> &es,vector<int> &d,int V,int E){
	fill(d.begin(),d.end(),INF);
	d[s]=0;
	while(true){
		bool update=false;
		for(int i=0; i<E; ++i){
			Edge e=es[i];
			if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(!update) break;
	}
}

int main(){
	int N,M;
	cin >> N >> M;
	vector<Edge> es;
	vector<int> d(N);
	REP(int,i,M){
		int a,b,c;
		cin >> a >> b >> c;
		es.push_back(Edge(a,b,-c));
	}
	BellmanFord(0,es,d,N,M);
	cout << -d[N-1] << endl;
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
using namespace std;
#define MAX_N 200
int sugoroku[MAX_N],tmp,nv,nt;
double dp[MAX_N][MAX_N],per;
double tmpdp[MAX_N][MAX_N];
void solve(int n,int t,int l,int b){
  if(n==0){
    return;
  }
  fill(sugoroku,sugoroku+n+1,0);
  fill(dp[0],dp[t+1],0);
  fill(tmpdp[0],tmpdp[t+1],0);
  dp[0][0]=1;
  for(int i=0;i<l;i++){
    cin >> tmp;
    sugoroku[tmp]=1;
  }
  for(int i=0;i<b;i++){
    cin >> tmp;
    sugoroku[tmp]=2;
  }
  for(int i=0;i<t;i++){
    for(int j=0;j<n;j++){
      if(sugoroku[j]==1){
        tmpdp[i+1][j]+=dp[i][j];
        nt = i+2;
      }else{
        nt = i+1;
      }
      per = dp[i][j]/6;
      for(int k=1;k<=6;k++){
        nv = j+k;
        if(nv>n){
          nv = n-(nv-n);
        }
        if(sugoroku[nv]==2){
          dp[nt][0] += per;
        }else{
          dp[nt][nv] += per;
        }
      }
      dp[i][j] += tmpdp[i][j];
    }
    dp[i+1][n]+=dp[i][n];
  }
  /*
  for(int i=0;i<=t;i++){
    double tmp=0;
    for(int j=0;j<=n;j++){
      cout << dp[i][j]<< " ";
      tmp += dp[i][j];
    }
    cout << tmp<<endl;
  }
  */
  printf("%.9f\n",dp[t][n]);
  cin >> n >> t >> l >> b;
  solve(n,t,l,b);
}
int main(void){
  int n,t,l,b;
  cin >> n >> t >> l >> b;
  solve(n,t,l,b);
}



Measured memory_bytes: 3420
# -*- coding:utf-8 -*-

def main():
    import math
    for i in range(int(input())):
        xa,ya,ra,xb,yb,rb=map(float,input().split())
        d=math.sqrt((xa-xb)**2+(ya-yb)**2)
        if d>ra+rb:
            print(0)

        elif ra+rb>=d and d>=abs(ra-rb):
            print(1)

        elif d<abs(ra-rb):
            if ra>rb:
                print(2)
            elif ra<rb:
                print(-2)
        
            
    
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 7660
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N,T,H,L;
  cin >> N >> T >> H >> L;
  vector<pair<int,int> > V(N);
  for(int i=0; i<N; i++){
    int t,h;
    cin >> t >> h;
    V[i] = make_pair(t,h);
  }
  int count = 0;
  for(;;){
    for(int i=0; i<N; i++){
      if(V[i].first == 0 && V[i].second == 0
         || V[i].first > 0 && T == L){
        cout << i+1 << endl;
        return 0;
      }
      if(V[i].first > 0){
        V[i].first--;
        T++;
        count += 10;
      }else{
        V[i].second--;
        H++;
        count += 100;
      }
      if(count >= 90){
        int r = (count - 90)/10;
        if(T < r){
          cout << i+1 << endl;
          return 0;
        }
        T -= r;
        V[i].first += r;
        count = 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

typedef pair<int, int> pii;

int BIT[100010];

void Add(int i, int x)
{
	while (i)
	{
		BIT[i] += x;
		i -= (i&-i);
	}
}

int Get(int i)
{
	int ans = 0;
	while (i < 100010)
	{
		ans += BIT[i];
		i += (i&-i);
	}
	return ans;
}

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

	for (int i = 0; i < q; i++)
	{
		int c, s, t, v;
		scanf("%d", &c);

		switch (c)
		{
		case 0:
			scanf("%d %d %d", &s, &t, &v);
			Add(t, v);
			Add(s - 1, -v);
			break;
		case 1:
			scanf("%d", &s);
			cout << Get(s) << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3508
N=int(input())
L=list(input() for i in range(N))
L=sorted(L)
X=L[0]
c=0
d=0
e=[]
for i in range(N):
  if L[i]==X:
    c+=1
    if i==N-1 and c>d:
      e=[X]
    elif i==N-1 and c==d:
      e.append(X)
  elif L[i]!=X and d<c:
    d=c
    c=0
    e=[]
    e.append(X)
    X=L[i]
    c+=1
  elif L[i]!=X and d==c:
    c=1
    e.append(X)
    X=L[i]
    if i==N-1:
      e.append(X)
  elif L[i]!=X and d>c:
    c=0
    X=L[i]
    c+=1
for i in e:
  print(i)

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


void solve(long long N, std::vector<long long> A){
    vector<long long> res(N);
    long long tmp = 0;
    tmp = A[0];
    for(int i=1;i<N;++i){
        if(i%2==1)tmp -= A[i];
        if(i%2==0)tmp += A[i];
    }
    res[0] = tmp;
    for(int i=2;i<N;i+=2){
        tmp += 2 * A[i-1];
        tmp -= 2 * A[i-2];
        res[i] = tmp;
    }
    tmp = A[0] + A[1];
    for(int i=2;i<N;++i){
        if(i%2==0)tmp -= A[i];
        if(i%2==1)tmp += A[i];
    }
    res[1] = tmp;
    for(int i=3;i<N;i+=2){
        tmp += 2 * A[i-1];
        tmp -= 2 * A[i-2];
        res[i] = tmp;
    }
    for(int i=0;i<N-1;++i)cout<<res[i]<<" ";
    cout<<res[N-1]<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    long long ans=0,p[100010]={},mod=1000000007;
    int N,M,A[100010]={};

    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>A[i];
    }

    int next=0;
    p[0]=1;

    for(int i=1;i<=N;i++){
        if(i==A[next]){
            p[i]=0;
            next++;
            continue;
        }

        if(i==1){
            p[i]=1;
        }else{
            p[i]=p[i-1]+p[i-2];
        }

        p[i]%=mod;
    }

    ans=p[N]%mod;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
int main(void){
  char ch[6];
  int i;
  for(i=0;i<6;i++)
  {
    scanf("%c",&ch[i]);
    if(ch[i]<97 && ch[i]>122)
      return 0;
  }
  if(ch[2]==ch[3] && ch[4]==ch[5])
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 128
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
ANS = [ [0]*W for _ in range(H)]
nc=1
nct=A[0]
ans=[]
for y in range(H):
  if y%2==0:
    for x in range(W):
      nct-=1
      ANS[y][x] = str(nc)
      if nct==0 and nc<N:
        nct=A[nc]
        nc+=1
  else:
    for x in range(W-1,-1,-1):
      nct-=1
      ANS[y][x] = str(nc) 
      if nct==0 and nc<N:
        nct=A[nc]
        nc+=1
        
      
for y in range(H):
    print(" ".join(ANS[y]) )



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

int n, A[50];

int solve(int i, int m) {
    if(m==0) {
        return 1;
    }
    if(i>=n) {
        return 0;
    }
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main() {
    int q, M, i;

    cin >> n;
    for(i=0; i<n; i++) {
        cin >> A[i];
    }
    cin >> q;
    for(i=0; i<q; i++) {
        cin >> M;
        if(solve(0, M)) {
            cout << "yes\n";
        }
        else {
            cout << "no\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3056
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int n,a[3001],vis[3001],maxn=-1,high,tot,xb;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a+(b/2);
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# 約数列挙
def find_divisor(n):
    divisors=[]
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i*i!=n:
                divisors.append(n // i)
    return divisors


def main():
    S=ST()
    ans = len(S)
    for i in range(1,len(S)):
        if S[i-1]!=S[i]:
            ans = min(ans, max(i, len(S)-i))
    print(ans)
        
    
    
    

if __name__ == '__main__':
    main()

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

int main(){
 int h,w,n;
 cin >> h >> w >> n;
 int x = max(h,w);
 if(n%x==0){
     cout << n/x << endl;
 }else{
     cout << n/x+1 << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    int ans = 1;
    int h0;
    cin >> h0;
    for(int i=0; i<N-1; i++) {
        int h1;
        cin >> h1;
        if(h1 >= h0) {
            ans ++;
            h0 = h1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcm(int a, int b)
{
    if (b == 0)
        return a;
    gcm(b, a % b);
}

int main()
{
    int cnt_0 = 0, cnt_1 = 0;
    string s;

    cin >> s;

    REP(i, s.length())
    {
        if (s[i] == '0')
            cnt_0 += 1;
        else
            cnt_1 += 1;
    }
    cout << s.length() - abs(cnt_0 - cnt_1) << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, s, m;

            string[] word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            //a, b, cの最大値を求める。
            m = a;
            if (b > m)  m = b;
            if (c > m)  m = c;

            //最大値を除く金額の和
            s = a + b + c - m;

            Console.WriteLine(s);

            //Console.ReadKey();
        }
    }
}

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

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

typedef long long ll;
typedef long long int64;

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

  if(x<a) cout << "0" << endl;
  else cout << "10" << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[]
mx=-1
s=1
for _ in range(n):
    x=int(input())
    l.append(x)
    if x==mx:
        s+=1
    elif x>mx:
        mx=x
        s=1
if s>1:
    for _ in range(n):
        print(mx)
else:
    j=l.index(mx)
    for i in range(n):
        if i!=j:
            print(mx)
        else:
            l.remove(mx)
            print(max(l))

Measured memory_bytes: 12512
import sys
import heapq

def main():
  input = sys.stdin.readline
  n, m = map(int, input().split())
  s = input()
  
  inf = pow(10, 6)
  ans = [inf]*(n+1)
  key = []
  heapq.heapify(key)
  heapq.heappush(key, (0, n))
  ans[n] = 0
  index = n-1
  count = 0
  while key:
    sub = heapq.heappop(key)
    s1, s2 = sub[0], sub[1]
    if s1 < count:
      continue
    count = s1+1
    subindex = index
    for i in range(min([index, s2-1]), max([-1, s2-m-1]), -1):
      if ans[i] != inf:
        continue
      if s[i] == "1":
        continue
      heapq.heappush(key, (count, i))
      ans[i] = s2
      subindex = i
    index = subindex
      
  if ans[0] == inf:
    print(-1)
  else:
    index = 0
    answer = []
    while True:
      subindex = ans[index]
      answer.append(subindex-index)
      if subindex == n:
        break
      index = subindex
  
    print(*answer)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 58332
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N;
    cin >> N;
    cout << 800 * N - 200 * (N / 15) << endl;
}

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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

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

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    repA(i,1,n)
    cin>>a[i];
    vector<ll> path;
    ll temp=a[1];
    // path.pb(temp);
    path.pb(1);
    set<ll> st;
    st.insert(1);
    while(1)
    {
        if(st.count(temp) >0) break;
        // watch(temp);
        st.insert(temp);
        path.pb(temp);
        temp=a[temp];
    }
    ll sz=path.size();
    ll idx=0;
    rep(i,sz)
    {
        if(path[i]==temp)
        {
            idx=i;
            break;
        }
    }
    if(k<=idx)
    {
        cout<<path[k]<<'\n';
    }
    else
    {
        k-=idx;
        ll tempsz=(sz-idx);
        k%=tempsz;
        cout<<path[k+idx]<<'\n';
    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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

int main()
{
  string a,b;
  cin>>a>>b;
  int n=a.length();
  int cnt=0;
  for(int i=0;i<n;i++)
  {
    if(a[i]!=b[i])
    {
      cnt++;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 3896
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

def solve(a, b, c, d):
    if a < b or d < b:
        return False
    if b < c:
        return True

    g = gcd(b, d)
    return (b + a % g - g) <= c

T, *L = map(int, open(0).read().split())

for t in zip(*[iter(L)] * 4):
    print("Yes" if solve(*t) else "No")


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    private static int[] mins = new int[26];

    public static void solve(String s) {
        int[] cnt = new int[26];
        for (char c : s.toCharArray()) {
            cnt[c - 'a']++;
        }

        for (int i = 0; i < 26; i++) {
            mins[i] = Math.min(mins[i], cnt[i]);
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 26; i++) {
            mins[i] = Integer.MAX_VALUE;
        }

        Scanner sc = new Scanner(System.in);
        int n = Integer.valueOf(sc.nextLine());
        for (int i = 0; i < n; i++) {
            String s = sc.nextLine();
            solve(s);
        }

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 26; i++) {
            for (int k = 0; k < mins[i]; k++) {
                builder.append((char) (i + 'a'));
            }
        }
        System.out.println(builder.toString());
    }
}


Measured memory_bytes: 20948
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

template<typename T = int, class F = std::plus<T>, class F_INV = std::minus<T>, const T E = 0>
struct BinaryIndexedTree {
    const F op = F(); const F_INV op_inv = F_INV();
    int n; vector<T> dat;
    void build(const vector<T>& v) {
        n = v.size(); dat.assign(n, E); for (int i = 0; i < n; ++i) add(i, v[i]);
    }
    void add(int k, T v) { for (int i = k; i < n; i |= i + 1) dat[i] = op(dat[i], v); }
    T query(int a, int b) const {
        T ret = E; if (a == b) return ret;
        for (int i = b - 1; i >= 0; i = (i & (i + 1)) - 1) ret = op(ret, dat[i]);
        return op_inv(ret, query(0, a));
    }
};

struct RangeAddRangeSumQuery {
    int n;
    BinaryIndexedTree<ll> bit0, bit1;
    void build(int n_) {
        n = n_;
        bit0.build(vector<ll>(n + 1));
        bit1.build(vector<ll>(n + 1));
    }
    void range_add(int l, int r, ll x) {
        bit0.add(l, -x * l);
        bit1.add(l, x);
        bit0.add(r, x * r);
        bit1.add(r, -x);
    }
    ll range_sum(int l, int r) {
        return bit0.query(l, r) + r * bit1.query(0, r) - l * bit1.query(0, l);
    }
};

int main() {
    int N, D, A;
    cin >> N >> D >> A;
    vector<pair<ll, ll>> XH(N);
    rep(i, N) cin >> XH[i].first >> XH[i].second;

    sort(all(XH));

    RangeAddRangeSumQuery rars;
    rars.build(N);
    rep(i, N) {
        rars.range_add(i, i + 1, XH[i].second);
    }

    ll ans = 0;
    rep(i, N) {
        ll H = rars.range_sum(i, i + 1);
        if (H > 0) {
            ll n = (H + A - 1) / A;;
            int r = lower_bound(all(XH), pair<ll, ll>(XH[i].first + 2 * D + 1, 0)) - XH.begin();
            rars.range_add(i, r, -A * n);
            ans += n;
        }
    }
    write(ans);
}

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

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

#define int long long
#define float long double 

const int upper = 2e5 + 1;
const int M = (int) 1e9 + 7;
const int inf = (int) 1e17;
const double eps =  1e-8;

signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);	
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif

	string s(4, '.');
	for (int i = 0; i < 4; i += 1) cin >> s[i];

	sort(all(s));

	if (s == "1479") cout << "YES";
	else cout << "NO";
 	end_routine();	
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
int h,w;

int main(){
	fast_io();
	scanf(" %d %d",&h,&w);
	int c[h][w];
	cu(i,0,h){
		cu(j,0,w){
			char t;
			scanf(" %c",&t);
			c[i][j] = t - 'a';
		}
	}
	vector<int> p;
	cu(i,0,w){
		if(i&1)p.pb(p.back());
		else p.pb(i/2);
	}
	ll mul[w];
	mul[0] = 1;
	cu(i,1,w)mul[i] = 27 * mul[i-1];

	int col[6][2];
	ll f[12],b[12]; 
	bool taken[12];
	do {
		memset(col,-1,sizeof(col));
		cu(i,0,w){
			if(col[p[i]][0] == -1){col[p[i]][0] = i;}
			else col[p[i]][1] = i;
		}
		bool val = true;
		map<ll,int> cnt;
		memset(f,0,sizeof(f));
		memset(b,0,sizeof(b));
		memset(taken,0,sizeof(taken));
		cu(i,0,h){
			cu(j,0,(w+1)/2){
				f[i] += mul[j] * c[i][col[j][0]];
				b[i] += mul[w - 1 - j] * c[i][col[j][0]];
				if(col[j][1] != -1){
					f[i] += mul[w - 1 - j] * c[i][col[j][1]];
					b[i] += mul[j] * c[i][col[j][1]];
				}
			}
		}
		bool odd = false;
		cu(i,0,h){
			if(!taken[i]){
				bool flag = 1;
				cu(j,i+1,h){
					if(f[i] == b[j] && !taken[j]){
						taken[j] = 1;
						flag = 0;
						break;
					}
				}
				if(flag){
					if(f[i] == b[i] && !odd && (h&1)){
						odd = true;
						continue;
					}
					val = false;
					break;
				}
			}
		}
		if(val){
			printf("YES\n");
			return 0;
		}
	} while(next_permutation(all(p)));

	printf("NO\n");
}



Measured memory_bytes: 384
char s[9];a,b[9],c;main(n){for(;scanf("%d",&n),n;printf("%d\n",c),a=b[0]=b[1]=c=0)for(;n--;){scanf("%s",s);b[s[0]/109]=s[1]&1;if(b[0]==b[1]&&a-b[0])c++,a=b[0];}}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[105];
int32_t main(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans = 0;
	if(!(a&1) && a==b && b==c){
		cout<<-1;return 0;
	}
	while(((a&1) + (b&1) + (c&1)) == 0){
		int a1=(b+c)/2,b1=(a+c)/2,c1=(a+b)/2;
		ans++;
		a = a1;b=b1;c=c1;
		//cout<<a<<" "<<b<<" "<<c<<"\n";
	}
	cout<<ans;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);i=i+1)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int>A(N); IN(A);
	vector<int>H(N + 1, 0);
	R(i, N) {
		H[A[i]]++;
	}
	vector<int> B;
	for (int i = 1; i <= N; ++i) {
		if (H[i]) {
			B.push_back(H[i]);
		}
	}
	SO(B);
	vector<int> BB(B.size()+1, 0);
	for (int i = 0; i < B.size(); ++i) {
		BB[i+1] = BB[i] + B[i];
	}
	for (LL k = 1; k <= N; ++k) {
		LL L = 0;
		LL R = INF;
		while (L + 1 < R) {
			LL T = (L + R) / 2;
			int index = lower_bound(B.begin(), B.end(),T)-B.begin();
			LL cnt = B.size() - index;
			LL res = BB[index] + cnt * T;
			if (res >= T * k) {
				L = T;
			}
			else {
				R = T;
			}
		}
		cout << L << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 5488
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
  int n, m, x; cin >> n >> m >> x;
  vector<int> c(n, 0);
  vector<vector<int>> a(n, vector<int>(m, 0));

  rep(i, n){
    cin >> c.at(i);
    rep(j, m){
      cin >> a.at(i).at(j);
    }
  }

  vector<int> sum(m, 0);
  rep(i, n){
    rep(j, m){
      sum.at(j) += a.at(i).at(j);
    }
  }
  rep(i, m){
    if(sum.at(i)<x){
      cout << -1 << endl;
      return 0;
    }
  }

  ll ans = 1e+9;
  for(int i=0; i<(1<<n); i++){
    vector<int> S(m, 0);
    ll csum = 0;
    for(int j=0; j<n; j++){
      if(i & (1<<j)){
        csum += c.at(j);
        for(int k=0; k<m; k++){
          S.at(k) += a.at(j).at(k);
        }
      }
    }

    for(int j=0; j<m; j++){
      if(S.at(j)<x){
        break;
      }
      if(j==m-1){
        ans = min(ans, csum);
      }
    }

  }

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


Measured memory_bytes: 3644
import sys
from itertools import accumulate

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n = ini()
a = inl()


def solve():
    al = list(accumulate(a))
    ar = list(reversed(list(accumulate(a[::-1]))))
    ans = 1 << 60
    for i in range(1, n):
        r = abs(al[i - 1] - ar[i])
        ans = min(ans, r)

    return ans


print(solve())


Measured memory_bytes: 39188
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
bool comp(pll a,pll b)
{
    return (a.S<b.S);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x,y;
    cin>>n;
    vector<pll> v;
    for(ll i=0;i<n;i++)
    {
        cin>>x>>y;
        v.pb({x+y,x-y});
    }
    sort(all(v));
    ll ans=abs(v[0].F-v[n-1].F);
    sort(all(v),comp);
    ans=max(ans,abs(v[0].S-v[n-1].S));
    cout<<ans;
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int a,b;
int main() {
    cin>>a>>b;
    if(a+b==15){
        p('+');
    }else if(a*b==15){
        p('*');
    }else{
        p('x');
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;
 
int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n, m;
  cin>>n>>m;
  n = (n * (n - 1)) >> 1;
  m = (m * (m - 1)) >> 1;
  cout<<n+m<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

int main() {
    int n, x;
    cin >> n >> x;
    VI a(n);
    FOR(i, n)cin >> a[i];

    ll ans = 0;
    FOR1(i, n) {
        while (a[i - 1] + a[i] > x) {
            if (a[i] > 0) {
                ans += min(a[i], a[i - 1] + a[i] - x);
                a[i] = max(0, x - a[i - 1]);
            }
            else {
                ans += a[i - 1] - x;
                a[i - 1] = x;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,a;cin>>h>>a;
  ll ans=(h+a-1)/a;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
#define P pair<int,int>
#define mp(a,b) make_pair(a,b)
#define ll long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 2e5+5;
char c[N]; int a[26];

int main() { 
	scanf("%s",c+1); 
	ll n = strlen(c+1), ans = n*(n+1)/2;
    rep(i,1,n) a[c[i]-'a']++, ans -= a[c[i]-'a'];
    cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
char n[N];
int k;
int dp[N][5];
int main() {
	scanf("%s", n);
	scanf("%d", &k);
	int sz = strlen(n);
	reverse(n, n + sz);
	dp[0][0] = 1;
	for(int i = 1; i < sz; ++i) {
		dp[i][0] = 1;
		for(int j = 1; j <= k; ++j) {
			dp[i][j] = dp[i - 1][j] + (9 * dp[i - 1][j - 1]);
		}
	}
	int ans = 0;
	/*cout<<ans<<endl;
	for(int i = 0; i < sz; ++i) {
		for(int j = 0; j <= k; ++j) {
			cout<<dp[i][j]<<" ";
		} cout<<endl;
	}*/
	for(int i = sz - 1, j = k; i >= 0 and j >= 0; --i, --j) {
		if(j == 0) {
			ans++;
			break;
		}
		int num = n[i] - '0';
		if(num == 0) {
			j++;
			continue;
		}
		int l = 1;
		if(i == 0) l = 0;
		ans += (num - l) * dp[i][j - 1] + dp[i][j];
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
ans=INF
def f(a,b)
  a_s=a.to_s.split("").size
  b_s=b.to_s.split("").size
  return max(a_s,b_s)
end
1.upto((N**0.5).to_i) do|x|
    if (N%x).zero?
        ans=min(ans,f(N/x,x))
    end
end
puts ans

Measured memory_bytes: 14668
#include <stdio.h>
#define N 100000

int numcase(int a, int b);

int main(void){
  int n, x, ans[N];
  int i=0, j;

  while(scanf("%d %d", &n, &x), n!=0 || x!=0){
    ans[i] = numcase(n, x);
    i++;
  }
  for(j=0; j<i; j++)
    printf("%d\n", ans[j]);

  return 0;
}

int numcase(int a, int b){
  int num=0; // 個数カウント
  int j,k;

  for(j=1;j<=b/3-1;j++){
    for(k=j+1;;k++){
      if(k>=(b-j-k)){
        break;
      }
      if(a>=(b-j-k)){
        num++;
      }
    }
  }
  return num;
}



Measured memory_bytes: 2032