akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;++i)
typedef long long int ll;

int main(){

    int n;
    cin >> n;

    vector<ll> c;

    ll t;
    cin >> t;

    c.push_back(t);

    rep(i,n-1){
        cin >> t;
        if(c.back()==t){
            continue;
        }
        c.push_back(t);
    }

    vector<ll> dp(c.size(),1);
    vector<ll> pos[200001];
    dp[0]=1;
    pos[c[0]].push_back(0);
    ll mo=1e+9+7;

    for(ll i=1;i<c.size();i++){
        if(c[i-1]==c[i]) continue;
        dp[i]=dp[i-1];
        if(pos[c[i]].size()!=0){
            dp[i]*=2;
            dp[i]-=(dp[i-1]-dp[pos[c[i]].back()]);
            dp[i]%=mo;

        }
        pos[c[i]].push_back(i);
    }

    cout << dp.back() << endl;

    return 0;
}

Measured memory_bytes: 14320
import bisect
h,w,k=map(int,input().split())
s=["."*(w+2)]+["."+input()+"." for i in range(h)]+["."*(w+2)]
l=[[0]*(w+2) for i in range(h+2)]
ans=1
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=='#':
            l[i][j]=ans
            ans+=1
        
A=1
ss=[]
for i in range(1,h+1):
    if list(set(s[i]))!=['.']:
        ss.append(i)
        for j in range(1,w+1):
            if l[i][j]!=0:
                A=l[i][j]
            elif l[i][j]==0:
                l[i][j]=A
        A+=1
for i in range(1,h+1):
    if i not in ss:
        z=bisect.bisect_left(ss,i)
        if z==len(ss):
            l[i]=l[ss[z-1]]
        else:
            l[i]=l[ss[z]]


for i in range(1,h+1):
    print(" ".join(map(str,l[i][1:-1])))
            



Measured memory_bytes: 43372
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        String ymd = S.replace("/","");
        int ymdi = Integer.parseInt(ymd);
        if (ymdi <= 20190430) {
            System.out.println("Heisei");
        }
        else {
            System.out.println("TBD");
        }

    }
}

Measured memory_bytes: 21332
#include<stdio.h>

int main (void)
{
	int i,input1,input2,input3;
	int count = 0;
	
	scanf("%d %d %d",&input1,&input2,&input3);
	for(i = input1 ; i <= input2 ; i++)
	{
		if(input3 % i == 0)
		{
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2120
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	int n, m;
	cin >> n >> m;
	char c[101][101];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cout << c[i][j];
		}
		cout << endl;
		for (int j = 0; j < m; j++) {
			cout << c[i][j];
		}
		cout << endl;
	}
	
		return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int main()
{
    int a,b;
    cin>>a>>b;
    printf("%d\n",a*b);
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	int a, b;
	while (cin >> a >> b, a || b) {
		if (a < b) swap(a, b);
		
		int ans = 0;
		while (b != 0) {
			a = a % b;
			swap(a, b);
			ans++;
		}
		printf("%d %d\n", a, ans);
	}
	return 0;
}

Measured memory_bytes: 3120
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 200005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"NO\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}

vector<ll> facts, invfacts;

ll power(ll x, ll n, ll d) {
    ll val = (x%d), res = 1;
    while(n>0) {
        if(n&1)
            res = (res*val)%d;
        val = (val*val)%d;
        n = n>>1;
    }
    return (res+d)%d;
}

ll nck(ll n, ll k, ll d) {
    if(k>n)
        return 0;
    return (facts[n]*invfacts[k]%d*invfacts[n-k]%d+d)%d;
}

ll npk(ll n, ll k, ll d) {
    if(k>n)
        return 0;
    return (facts[n]*invfacts[n-k]%d+d)%d;
}

void initialize_facts(ll n, ll mod) {
    facts.resize(n+1);
    invfacts.resize(n+1);
    facts[0] = 1;
    invfacts[0] = 1;

    for(ll i=1;i<=n;i++) {
        facts[i] = (facts[i-1]*i)%mod;
        invfacts[i] = power(facts[i], mod-2, mod);
    }
}

int main() {
    
    initialize_facts(Nmax, N);
    
    get2(n,k);
    fill_nums(A,n);
    sort(ALL(A));

    ll ans = 0;
    rep(i,n) {
        ans = (ans - A[i]*nck(n-i-1,k-1,N)%N)%N;
    }

    repr(i,n-1) {
        ans = (ans + A[i]*nck(i,k-1,N)%N)%N;
    }


    printf("%lld\n", (ans+N)%N);
    return 0;  
}

Measured memory_bytes: 4096
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
	int d, g;
	cin >> d >> g;
	vector<int> p(d), c(d);
	for (int i = 0; i < d; i++) {
		cin >> p[i] >> c[i];
	}

	int Qnum = INF;
	for (unsigned b = 0; b < (1u << d); b++) {
		bitset<10> bit(b);
		int point = 0, Qnum_tmp = 0;
		for (int i = 0; i < d; i++) {
			if (bit[i]) {
				point += 100 * (i+1) * p[i] + c[i];
				Qnum_tmp += p[i];
			}
		}

		if (point >= g) {
			int Qnum_tmp3 = Qnum_tmp;
			for (int i = 0; i < d; i++) {
				int point_tmp = point, Qnum_tmp2 = Qnum_tmp;
				if (bit[i]) {
					point_tmp -= c[i];
					int pi = p[i];
					while (point_tmp - 100 * (i + 1) >= g && pi > 0) {
						point_tmp -= 100 * (i + 1);
						Qnum_tmp2--;
						pi--;
					}
				}
				if (point_tmp >= g) Qnum_tmp3 = min(Qnum_tmp2, Qnum_tmp3);
			}

			Qnum = min(Qnum, Qnum_tmp3);
		}
	}

	cout << Qnum << endl;
	return 0;
}


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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

vector <pi> v;
ll n, a, b, ans;

int main() {
	fio();
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		v.pb({a + b, a});	
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i = 0; i < n; i++) {
		b = v[i].first - v[i].second;
		a = v[i].first - b;
		if (i & 1) 
			ans -= b;
		else
			ans += a;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2420
/********************************
Auther: jianwei
blog  : http://blog.csdn.net/jianwei2016
********************************/

#include<bits/stdc++.h>
#define ll long long
#define PI acos(-1)
#define FILEIN freopen("in.txt","r",stdin)
#define FILEOUT freopen("out.txt","w",stdout)
#define CLR(x) memset(x,0,sizeof(x))
#define MEM(a,x) memset(a,x,sizeof(a))
#define PB(x) push_back(x)
#define PF(x) push_front(x)
#define For(x,a,b) for(int x=a;x<b;x++)
#define rFor(x,a,b) for(int x=a;x>b;x--)
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define rFOR(x,a,b) for(int x=a;x>=b;x--)
#define lowbit(x) (x&(-x))

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
using namespace std;

const double eps = 1e-6;
const ll mod = 1e9+7;
const int maxn = 100100;
const int maxe = 100100;

void Solve()
{
    char a,b;
    cin>>a>>b;
    if(a>b)printf(">");
    else if(b>a)printf("<");
    else printf("=");
}

int main()
{
    //FILEIN
    //FILEOUT
    std::ios::sync_with_stdio(false);
    ll Case=1,cases;
    //cin>>Case;cases=Case;
    while(Case--){
        //printf("Case #%d:",cases-Case);
        Solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	int a1,a2,a3;
	a1=a[0];
	a2=b[0];
	a3=c[0];
	cout<<a[0]<<b[0]<<c[0];
	return 0;
}


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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

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

typedef long long ll;

int main() {
    int n, m, x;
    ll ans = -1;
    cin >> n >> m >> x;

    vector<vector<int>> A(n, vector<int>(m + 1));
    rep(i, n) {
        rep(j, m + 1) {
            cin >> A[i][j];
        }
    }

    for (int bit = 0; bit < (1 << n); bit++) {
        vector<int> tot(m + 1);
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                for (int j = 0; j < m + 1; j++) {
                    tot[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        for (int j = 1; j < m + 1; j++) {
            if (tot[j] < x) {
                ok = false;
            }
        }
        if (ok) {
            if (ans == -1) {
                ans = tot[0];
            } else {
                ans = min(ans, (ll)tot[0]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 31
#define M 100010
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
 int b[N][M];
int main(){
     int n,m;
     int s,t,c;
     int ans,maxn;
    ios::sync_with_stdio( false );
    cin>>n>>m;
   for (int i=1;i<=n;i++) {
       cin>>s>>t>>c;
        for (int j=s-1;j<t;j++)
            b[c][j]=1;
    }
      maxn=0;
    for (int i=1;i<=100000;i++){
        ans=0;
        for (int j=1;j<=m;j++)
           if (b[j][i])
            ans++;
        maxn=max(maxn,ans);
    }
    cout << maxn << endl;
    return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;

const int INF = 1LL << 40;
const int N = 100001;
vector<int> adj[N];
int visited[N];
int dist[N];
vector<int> topo;

void dfs(int cur) {
    visited[cur] = 1;
    for(int next : adj[cur])
        if(!visited[next])
            dfs(next);
    topo.push_back(cur);
}

signed main() {
    
    int n, m;
    cin >> n >> m;
    
    int u, v;
    while(m--) {
        cin >> u >> v;
        adj[u].push_back(v);
    }
    
    for(int i = 1; i <= n; i++) visited[i] = 0, dist[i] = -INF;
    for(int i = 1; i <= n; i++)
        if(!visited[i])
            dist[i] = 0, dfs(i);
    reverse(topo.begin(), topo.end());
    
    for(int cur : topo) {
        for(int next : adj[cur])
            dist[next] = max(dist[next], dist[cur] + 1);
    }
            
    //for(int i = 1; i <= n; i++) cerr << dist[i] << " ";
            
    cout << *max_element(dist + 1, dist + n + 1) << endl;
 
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  for ( int i = 1 ; i<=50000 ; i++){
    int c = i*1.08 ;
    if ( c==n){
      cout << i << endl;
      return 0 ;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 1e7

using namespace std;
typedef long long int ll;
typedef tuple<int,int,int> tii;
typedef tuple<long long int,long long int,long long int> tll;

int main()
{
    ll x,y; cin >> x >> y;
    ll a = x;
    int ans = 1;
    while(1)
    {
        ll b = 2*a;
        if(b > y) break;
        a = b;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<numeric>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(lli i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	lli n, a, b; cin >> n >> a >> b;
	lli ans = (b*(n-1)+a) - (a*(n-1)+b) + 1;
	cout << (ans>0?ans:0) << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
s = 0
for i in range(k, n+1):
    s += (((n - i + 1) + n) * i // 2 - (i * (i-1) // 2) + 1) % (10 ** 9 + 7)
print(s % (10 ** 9 + 7) + 1)


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

int main() {
  int H, W;
  cin >> H >> W;
  int anscol = 0, ansrow = 0;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      string s;
      cin >> s;
      if (s == "snuke") {
        anscol = j;
        ansrow = i + 1;
      }
    }
  }

  char c = (anscol%26) + 'A';
  cout << c << ansrow << endl;

  return 0;
}


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

class Baseball{
	private:
	int out;
	int runner;
	int point;

	public:
	void init();
	int get_out();
	int get_point();
	void event_hit();
	void event_homerun();
	void event_out();
};

void Baseball::init(){
	out = 0;
	runner = 0;
	point = 0;
}

int Baseball::get_out(){
	return out;	
}

int Baseball::get_point(){
	return point;
}

void Baseball::event_hit(){
	if(runner == 3){
		++point;
	}else{
		++runner;
	}
}

void Baseball::event_homerun(){
	point += ++runner;
	runner = 0;
}

void Baseball::event_out(){
	++out;
}

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

	std::string event;
	Baseball base;
	base.init();
	for(int i = 0; i < num; ++i){
		while(base.get_out() < 3){
			std:: cin >> event;

			if(event == "OUT"){
				base.event_out();		
			}else if(event == "HIT"){
				base.event_hit();
			}else if(event == "HOMERUN"){
				base.event_homerun();
			}
		}
		std::cout << base.get_point() << std::endl;
		base.init();
	}
	return 0;
}

Measured memory_bytes: 1208
//kruskal tree
#include <cstdio>
#include <algorithm>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<int,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int differ(int a,int b){
    int x=root(a),y=root(b);
    if(x==y)return 0;
    return 1;
}
int unite(int a,int b){
    int x=root(a),y=root(b);
    if(x==y)return 0;
    parent[x]=y;
    return 1;
}
int main(){
    int i,j,n,m,r,R;
    for(;scanf("%d%d",&n,&m),n;printf("%d\n",R)){
        for(i=0;i<m;i++)scanf("%d%d%d",a+i,b+i,&node[i].first),node[i].second=i,a[i]--,b[i]--;
        sort(node,node+m);
        for(R=-1,i=0;i<m;i++){
            for(r=j=0;j<n;j++)parent[j]=j;
            unite(a[node[i].second],b[node[i].second]);
            for(j=i+1;j<m;j++)if(unite(a[node[j].second],b[node[j].second]))r=node[j].first-node[i].first;
            for(j=1;j<n&&!differ(0,j);j++);
            if(j==n&&(R==-1||R>r))R=r;
        }
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ms(a) memset (a , 0 , sizeof a)
#define rr(i, a, b) for(register int i=a;i<=b;++i)
#define re(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
typedef long long ll ;

#define v(int) vector <int> 
#define pb push_back
#define pp push
#define fi first
#define se second
using namespace std ;

const int N = 100 ;
int qwq () {
	char ch = getchar () ;
	int x = 0 , f = 1 ;
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1 ; ch = getchar() ;}
	while (ch >= '0' && ch <= '9') {x = x *10 + ch - '0' ; ch = getchar() ;}
	return x * f ;
}
#define q qwq () 

int main () {
	string s , t ;
	cin >> s >> t ;
	int ans = 0 ;
	
	for (int i = 0 ; i <= s.size () - 1; i ++) {
		if (s[i]!=t[i]) ans ++;  
	}
	cout << ans << endl ;
	
	return 0 ; 
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0 ; i < N ; i++){
		cin >> a[i];
	}
	int ans = 1e9;
	for(int i = -100 ; i <= 100 ; i++){
		int sm = 0;
		for( auto x : a ){
			sm += (x - i) * (x - i);
		}
		ans = min(ans, sm);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    while(cin >> s, s != "#"){
        int y,m,d;
        cin >> y >> m >> d;
        if(y > 31 || (y == 31 && m > 4)){
            cout << "? " << y-30 << " " << m << " " << d << endl;
        }else{
            cout << s << " " << y << " " << m << " " << d << endl;
        }
    }
}



Measured memory_bytes: 3192
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

ll AN(ll A, ll N, ll mod){
  if (N == 0){
    return 1;
  }else{
    if (N % 2 == 0){
      return AN(A * A % mod, N / 2, mod);
    }else{
      return (A * AN(A * A % mod, N / 2, mod)) % mod;
    }
  }
}

int main(){

  ll N; cin >> N;
  vector <int> cnt(N);
  for (int i = 0; i < N; i++){
    int A; cin >> A; cnt[A]++;
  }
  
  bool flag = true;
  if (N % 2 == 0){
    for (int i = 1; i < N; i+=2){
      if (cnt[i] != 2) flag = false;
    }
  }else{
    if (cnt[0] != 1) flag = false;
    for (int i = 2; i < N; i+=2){
      if (cnt[i] != 2) flag = false;
    }
  }
  ll ans = flag * AN(2, N / 2, nmax);  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n, m;
	while (1) {
		cin >> n >> m;

		if (n == 0 && m == 0) { 
			return 0;
		}

		int a[100000];
		int b[100000];

		int a_total = 0;
		int b_total = 0;

		int ans1 = 100000;
		int ans2 = 100000;

		for (int i = 0; i < n; i++) {
			cin >> a[i];
			a_total += a[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> b[i];
			b_total += b[i];
		}


		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (a_total - a[i] + b[j] == b_total - b[j] + a[i]) {
					if (a[i] + b[j] < ans1 + ans2) {
						ans1 = a[i];
						ans2 = b[j];
					}
				}
			}
		}
		if (ans1 != 100000) {
			cout << ans1<<" "<<ans2 << endl;
		}
		else {
			cout << -1 << endl;
		}
		
		
	}


}

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



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

    int n, sum;
    sum=0;
    cin >> n;

    int usb[n];

    for (int i=0; i<n; i++) {
        cin >> usb[i];
        sum += usb[i];
    }

    sort(usb, usb+n);

    sum -= usb[n-1]/2;

    cout << sum;

}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
  int n, a, b;
  int64_t ans = 0;

  cin >> n;
  b = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    if (b > a)
    {
      ans += b - a;
    }
    else
      b = a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n){return REPS(n).map(i->getInt());}
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		while(true){
			int n=getInt(),m=getInt();
			if(n+m==0)return;
			boolean f=true;
			int p=0,a[]=INS(n).toArray();

			for(int i=1;i<=m;++i) {
				p+=getInt();
				if(p<n)
					p+=a[p];
				if(f&&p>=n-1){
					f=false;
					System.out.println(i);
				}
			}
		}
	}
}

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

int main() {
  string s;
  cin >> s;
  int count=0;
  rep(i,3){
    if(s[i]=='1'){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n, q;
vector<vector<ll>> g;
vector<ll> dp;

void dfs(ll v, ll p = -1) {
    for(auto u : g[v]) {
        if (u == p) continue;
        dp[u] += dp[v];
        dfs(u, v);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n >> q;
    g.resize(n);
    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dp.resize(n, 0);
    rep(i, q) {
        ll p, x;
        cin >> p >> x;
        p--;
        dp[p] += x;
    }
    dfs(0);
    rep(i, n) printf("%lld%s", dp[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int MAX_N = 1<<17;
const ll INF = INT_MAX;

/*
  RMQ and RUQ
  ?????????????°?????????????(RMQ)
  ????????????????????´??????(RUQ)
 */

class RMQ2{
public : 
  struct data{
    bool type; //0 - empty   , 1 - update
    ll value;
  };
  ll n,dat[2*MAX_N-1];
  data td[2*MAX_N-1];
  
  RMQ2(){
    n=MAX_N;
    memset(td,0,sizeof(td));
    for(int i=0;i<2*n-1;i++)dat[i]=INF;
  }
  RMQ2(int n_){
    n=1;
    while(n<n_)n*=2;
    memset(td,0,sizeof(td));
    for(int i=0;i<2*n-1;i++)dat[i]=INF;
  }
  
  //[a,b)?????????x????????´???update(a,b,x)
  ll update(int a,int b,int x,bool flg=true,int k=0,int l=0,int r=-1){
    if(r==-1) r=n;
    if(r<=a||b<=l)return flg? dat[k]:INF;
    if(a<=l&&r<=b){
      if(flg==true){
	td[k]=(data){1,x};
	dat[k]=x;
      }
      return dat[k];
    }
    
    if(td[k].type){
      dat[k*2+1]=dat[k*2+2]=td[k].value;
      td[k*2+1]=td[k*2+2]=(data){1,td[k].value};
      td[k].type=0;
    }
    
    ll vl=update(a,b,x,flg,k*2+1,l,(l+r)/2);
    ll vr=update(a,b,x,flg,k*2+2,(l+r)/2,r);
    if(flg==true)dat[k]=min(vl,vr);
    return min(vl,vr);
  }
  
  //[a,b)???????°????????????????find(a,b);
  ll find(int a,int b){return update(a,b,0,false);};
};


int main(){
  int q,n;
  cin>>n>>q;
  RMQ2 T(n);
  while(q--){
    int cmd,s,t,x;
    scanf("%d%d%d",&cmd,&s,&t);
    if(cmd==0)cin>>x,T.update(s,t+1,x);
    else cout <<T.find(s,t+1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 9364
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(n, m, k int, ab, cd [][2]int) []int {
        friends := make([]int, n)
        uf := NewUnionFind(n)
        for i := 0; i < m; i++ {
                a := ab[i][0] - 1
                b := ab[i][1] - 1
                friends[a]++
                friends[b]++
                uf.unite(a, b)
        }
        blocks := make([]int, n)
        for i := 0; i < k; i++ {
                c := cd[i][0] - 1
                d := cd[i][1] - 1
                if uf.same(c, d) {
                        blocks[c]++
                        blocks[d]++
                }
        }
        out := make([]int, n)
        for i := 0; i < n; i++ {
                out[i] = uf.size(i) - friends[i] - blocks[i] - 1
        }
        return out
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var n, m, k int
        fmt.Fscan(r, &n, &m, &k)
        ab := make([][2]int, m)
        for i := range ab {
                fmt.Fscan(r, &ab[i][0], &ab[i][1])
        }
        cd := make([][2]int, k)
        for i := range cd {
                fmt.Fscan(r, &cd[i][0], &cd[i][1])
        }
        for _, t := range solution(n, m, k, ab, cd) {
                fmt.Printf("%v ", t)
        }
}

type UnionFind struct {
        d []int
}

func NewUnionFind(n int) *UnionFind {
        d := make([]int, n)
        for i := 0; i < n; i++ {
                d[i] = -1
        }
        return &UnionFind{d: d}
}

func (uf *UnionFind) find(x int) int {
        if uf.d[x] < 0 {
                return x
        }
        uf.d[x] = uf.find(uf.d[x])
        return uf.d[x]
}

func (uf *UnionFind) unite(x, y int) bool {
        x, y = uf.find(x), uf.find(y)
        if x == y {
                return false
        }
        if uf.d[x] > uf.d[y] {
                x, y = y, x
        }
        uf.d[x] += uf.d[y]
        uf.d[y] = x
        return true
}

func (uf *UnionFind) same(x, y int) bool {
        return uf.find(x) == uf.find(y)
}

func (uf *UnionFind) size(x int) int {
        return -uf.d[uf.find(x)]
}

Measured memory_bytes: 9256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            WriteLine(s[1]*s[2] >= s[0] ? "Yes":"No");
        }
        
    }
}


Measured memory_bytes: 28288
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+1;
int n,a,b,tot,ans,u,v;
int dis1[N],dis2[N],pre[N<<1],las[N],des[N<<1];
void dfs1(int x)
{
	for (int i=las[x];i;i=pre[i])
		if (!dis2[des[i]])
		{
			dis2[des[i]]=dis2[x]+1;
			dfs1(des[i]);
		}
}
void dfs2(int x)
{
	for (int i=las[x];i;i=pre[i])
		if (!dis1[des[i]]&&dis1[x]+1<dis2[des[i]])
		{
			dis1[des[i]]=dis1[x]+1;
			dfs2(des[i]);
		}
}
void link(int x,int y)
{
	pre[++tot]=las[x];
	des[tot]=y;
	las[x]=tot;
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<n;++i)
	{
		scanf("%d%d",&u,&v);
		link(u,v);
		link(v,u);
	}
	dis2[b]=1;
	dfs1(b);
	dis1[a]=1;
	dfs2(a);
	for (int i=1;i<=n;++i)
		if (dis1[i])
			ans=max(ans,dis2[i]-2);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5504
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    let tmp = a.iter().fold(0, |a, x| a ^ x);
    let ans = if tmp == 0 { "Yes" } else { "No" };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    int n;
    long long a[10001]={0};
    cin >> n;
    for(int i =0; i< n; i++) {
        cin >> a[i];
    }
    long long min = 1000000, max = -1000000, sum = 0;
    for(int i =0; i < n; i++){
        if(a[i]<min){
            min = a[i];
        }
        
        if(a[i]>max) {
            max = a[i];
        }
        sum = sum + a[i];
    }
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3188
// https://atcoder.jp/contests/abc067/tasks/abc067_b
// B - Snake Toy
#include <stdio.h>
#include <stdlib.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

// バブルソート
void sort(int a[], int num) {
    int i, j, b;
    for (i = 0; i < num-1; i++) {
        for (j = 0; j < num-i-1; j++) {
            if (a[j] > a[j+1]) {
                b = a[j];
                a[j] = a[j+1];
                a[j+1] = b;
            }
        }
    }
}
int main(void) {
    int n, k, i, sum;
    int l[50];
    n = get_num();
    k = get_num();
    for (i = 0; i < n; i++) {
        l[i] = get_num();
    }

    sort(l, n);
    
    sum = 0;
    for (i = 0; i < k; i++) {
        sum += l[n-1-i];
    }

    printf("%d\n", sum);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
typedef long long ll;

// binary行列の掃き出し法と行列累乗
// bitset高速化により、定数倍速い

const int MAX_ROW = 1000;
const int MAX_COL = 1000;
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m, int n) : H(m), W(n) {}
    inline bitset<MAX_COL> & operator [] (int i) { return val[i]; }
};
inline BitMatrix operator * (BitMatrix A, BitMatrix B) {
    BitMatrix R(A.H, B.W);
    BitMatrix tB(B.W, B.H);
    for (int i = 0; i < tB.H; i++) for (int j = 0; j < tB.W; j++) tB[i][j] = B[j][i];
    for (int i = 0; i < R.H; i++) for (int j = 0; j < R.W; j++) R[i][j] = ((A[i] & tB[j]).count() & 1);
    return R;
}
inline BitMatrix pow(BitMatrix A, ll  n) {
    BitMatrix R(A.H, A.H);
    for (int i = 0; i < A.H; ++i) R[i][i] = 1;
    while (n > 0) { if (n & 1) R = R * A; A = A * A; n >>= 1; }
    return R;
}
int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; col++) {
        if (is_extended && col == A.W - 1) break; // 拡大係数行列。この場合、最後の列は掃き出さない
        int pivot = -1;
        for (int row = rank; row < A.H; row++) if (A[row][col]) { pivot = row; break; }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; row++) if (row != rank && A[row][col]) A[row] ^= A[rank];
        rank++;
    }
    return rank;
}
int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);
    for (int row = rank; row < m; row++) if (M[row][n]) return -1; // check if it has no solution
    res.assign(n, 0);
    for (int i = 0; i < rank; i++) res[i] = M[i][n];
    return rank;
}


// verified
//  https://atcoder.jp/contests/code-thanks-festival-2017/tasks/code_thanks_festival_2017_f

// verified
//  https://atcoder.jp/contests/abc141/tasks/abc141_f

// verified
//  https://yukicoder.me/problems/no/184

// verified
//  https://yukicoder.me/problems/no/803

// verified
//  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1308&lang=en
void AOJ_Awkward_Lights() {
    int m, n, d;
    while (true) {
        cin >> m >> n >> d;
        if (m == 0) break;
        vector <vector<int>> s(n, vector<int>(m));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cin >> s[i][j];
            }
        }
        BitMatrix A(n * m, n * m);
        vector<int> b(n * m), res;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                A[i * m + j][i * m + j] = 1;
                b[i * m + j] = 1 - s[i][j];
                for (int k = 0; k < n; k++) {
                    for (int l = 0; l < m; l++) {
                        if (abs(i - k) + abs(j - l) == d) A[i * m + j][k * m + l] = 1;
                    }
                }
            }
        }
        cout << (linear_equation(A, b, res) == -1 ? 0 : 1) << '\n';
    }
}

int main() {
    AOJ_Awkward_Lights();
    return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define nl "\n"
#define pb push_back
#define sp " "
typedef long long ll;

using namespace std;
vector<ll> v;


void pre(ll n){
    v.push_back(n);
    int d=n%10;
    if(n<1e9){
            pre(n*10+d);
            if(d!=9)pre(n*10+d+1);
            if(d!=0)pre(n*10+d-1);

    }


    }







int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    pre(1);
    pre(2);
    pre(3);
    pre(4);
    pre(5);
    pre(6);
    pre(7);
    pre(8);
    pre(9);
    sort(v.begin(),v.end());
    int n;
    cin >> n;
    cout<<v[n-1]<<nl;


}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, d[1003][1003] = {}, z = 0;
    string s[1003] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> s[i], s[i] = '#' + s[i] + '#';
    queue<pair<pii, int>> q;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (s[i][j] == '#') d[i][j] = 1, q.push({{i, j}, 1});
    while (!q.empty()) {
        pair<pii, int> v = q.front();
        q.pop();
        int x = v.first.first, y = v.first.second, w = v.second;
        if (s[x - 1][y] == '.') {
            s[x - 1][y] = '#';
            d[x - 1][y] = w + 1;
            q.push({{x - 1, y}, w + 1});
        }
        if (s[x + 1][y] == '.') {
            s[x + 1][y] = '#';
            d[x + 1][y] = w + 1;
            q.push({{x + 1, y}, w + 1});
        }
        if (s[x][y - 1] == '.') {
            s[x][y - 1] = '#';
            d[x][y - 1] = w + 1;
            q.push({{x, y - 1}, w + 1});
        }
        if (s[x][y + 1] == '.') {
            s[x][y + 1] = '#';
            d[x][y + 1] = w + 1;
            q.push({{x, y + 1}, w + 1});
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            //cout << d[i][j] << ' ';
            z = max(z, d[i][j]);
        }
        //cout << '\n';
    }
    cout << z - 1;
}


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

int main(){
   long long int s,S,c,b,d;
   cin>>s;
   S=s;
   vector<int> a(10);
int i=0;
 d=0;
   while(d==0){
      a.at(i)=S%10; S=S/10;
      i++;
    if(S==0){d=1;}}
   c=1000;
  
  for(int j =2;j<i;j++){
    b=753 -a.at(j)*100 -a.at(j-1)*10 -a.at(j-2);
     if(0>b){b =0-b;}
    if(c>b){c=b;}}
   
cout<<c<<endl;
   }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a[100000]={0};
    ll dp[100000]={0};
    ll n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
}

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

/////////////////////////
// Range Minimum Query //
/////////////////////////

class RangeMaximumQuery {
private:
	std::vector<long long> container_;
	void constructorHelper(const unsigned int array_size)
	{
		unsigned int length{1};
		while (length < array_size)
			length <<= 1;
		container_.resize(2 * length);
	}
	long long getHelper(const int index, const int node_l, const int node_r, const int query_l, const int query_r) const
	{
		if (query_r <= node_l || node_r <= query_l) return 0;
		if (query_l <= node_l && node_r <= query_r) return container_[index];
		const int node_m{(node_l + node_r) >> 1};
		return std::max(getHelper(2 * index, node_l, node_m, query_l, query_r), getHelper(2 * index + 1, node_m, node_r, query_l, query_r));
	}

public:
	RangeMaximumQuery(const unsigned int array_size) { constructorHelper(array_size); }
	// indexは0-indexed
	void update(const int index, const long long assigned)
	{
		auto update_place{(container_.size() >> 1) + index};
		container_[update_place] = assigned;
		while (update_place > 1)
		{
			update_place >>= 1;
			container_[update_place] = std::max(container_[2 * update_place], container_[2 * update_place + 1]);
		}
	}
	// left,rightは0-indexed、[left, right)の半開区間
	long long get(const int left, const int right) const
	{
		return getHelper(1, 0, container_.size() >> 1, left, right);
	}
};

int main()
{
	long long N, M, C;
	scanf("%lld%lld%lld", &N, &M, &C);
	std::vector<long long> smell(N);
	for (auto& e: smell) scanf("%lld", &e);
	RangeMaximumQuery inc(N), dec(N);
	// セグ木内部の値はすべて正
	for (long long i{}; i < N; i++)
		inc.update(i, smell[i] + i * C);
	for (long long i{}; i < N; i++)
		dec.update(i, smell[i] + (N - 1 - i) * C);

	auto condition{[&](int R)
		{
			long long sum{};
			for (long long i{}; i < N; i++)
			{
				sum += std::max(inc.get(std::max(i - R, 0ll), i) - C * i, dec.get(i, std::min(i + R + 1, N)) - C * (N - 1 - i));
				if (sum >= M) return true;
			}
			return sum >= M;
		}
	};
	long long ok{N}, ng{-1};
	while (ok - ng > 1)
	{
		long long mid{(ok + ng) / 2};
		if (condition(mid)) ok = mid;
		else ng = mid;
	}
	if (ok == N) puts("-1");
	else printf("%d\n", ok);

	return 0;
}


Measured memory_bytes: 7896
# include<iostream>
using namespace std;
int main ()
{
	 int n;
	 cin>>n;
	 int a[n];
	 for(int i=0;i<n;i++)
	 {
	 	cin>>a[i];
	 }
	 int sum =1;
	 int k=a[0];
	 for(int i=1;i<n;i++)
	 {
	 	 if(a[i]<=k)
	 	 {
	 	 	 k=a[i];
	 	 	 sum++;
		  }
	 	
	 }
	
	 cout<<sum<<endl;
	
	
}

Measured memory_bytes: 1024
#include<iostream>
#include<set>
using namespace std;
int main(){
	set<int>a;
	//set<int>b;
	int n,m;
	cin>>n;
	while(n--){
		int x;
		cin>>x;
		a.insert(x);
	}
	cin>>m;
	while(m--){
		int x;
		cin>>x;
		a.insert(x);
	}
	for(set<int>::iterator i=a.begin(); i!=a.end(); i++){
		cout<<*i<<endl;
	}
	return 0;
}


Measured memory_bytes: 21772
/// Source : https://atcoder.jp/contests/abc042/tasks/arc058_a
/// Author : liuyubobobo
/// Time   : 2020-09-22

#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;


/// Brute Force
/// Time Complexity: O(10*N*logN)
/// Space Complexity: O(1)
class Solution{

public:
    int handMoney(int N, const vector<bool>& dislikes){

        int smallestlike = 0;
        for(;dislikes[smallestlike];smallestlike ++);

        vector<int> num;
        while(N) num.push_back(N % 10), N /= 10;

        int carry = 0;
        for(int i = 0; i < num.size(); i ++){
            int d = num[i] + carry;
            for(; d < 10; d ++)
                if(!dislikes[d]) break;

            if(d != 10){
                if(d > num[i]) for(int j = 0; j < i; j ++) num[j] = smallestlike;
                num[i] = d, carry = 0;
            }
            else{
//                for(int j = 0; j < i; j ++) num[j] = smallestlike;
                num[i] = smallestlike, carry = 1;
            }
        }
        if(carry){
            for(int i = 1; i < 10; i ++)
                if(!dislikes[i]){
                    num.push_back(i);
                    break;
                }
        }

        int res = 0;
        for(int i = num.size() - 1; i >= 0; i --)
            res = res * 10 + num[i];
        return res;
    }
};

int main() {

    int N, K;
    scanf("%d%d", &N, &K);

    vector<bool> dislikes(10, false);
    for(int i = 0; i < K; i ++){
        int x; scanf("%d", &x);
        dislikes[x] = true;
    }

    printf("%d\n", Solution().handMoney(N, dislikes));

    return 0;
}


Measured memory_bytes: 3152
#include<iostream>

using namespace std;

int main(){
    int A,B,C;
    cin>>A>>B>>C;

    if(A==7&&B==5&&C==5){
        cout<<"YES"<<endl;
    }
    else if(A==5&&B==7&&C==5){
        cout<<"YES"<<endl;
    }
    else if(A==5&&B==5&&C==7){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> l(n, 0);
	for(int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end(), greater<int>());
	int ans = 0;
	for(int i = 0; i < k; i++) {
		ans += l[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  long x;
  scanf("%ld", &x);
  long sum = 0;
  for (long i = 1; i <= x; i++) {
    sum += i;
    if (sum >= x) {
      printf("%ld\n", i);
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 128
n;main()
{
	int x,i,j;
	scanf("%d",&n);
	for(i=1;n--;)
		for(printf("Case %d:\n",i++),scanf("%d",&x),j=10;j--;)
			printf("%d\n",x=((x*x)%1000000-(x*x)%100)/100);
}

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


void solve(long long N){
    switch (N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    }
}

// Generated by 1.1.7.1 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);
    solve(N);
    return 0;
}


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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
    int n; in >> n;

    vector<int> v(2*n);
    REP(i, 2*n) in >> v[i];

    sort(all(v));

    int res = 0;
    REP(i, n) res += v[2*i];

    out << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        boolean cards[][];
        cards=new boolean[4][13];
        for(int i=0;i<4;i++) {
            for (int j = 0; j < 13; j++) {
                cards[i][j]=false;
            }
        }

        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        while(n-->0){
            int tmp;
            String str=sc.next();
            int rank=sc.nextInt();
            if(str.equals("S"))tmp=0;
            else if(str.equals("H"))tmp=1;
            else if(str.equals("C"))tmp=2;
            else if(str.equals("D"))tmp=3;
            else break;
            if(rank<1&&13<rank)break;
            rank--;
            cards[tmp][rank]=true;
        }
        for(int i=0;i<4;i++) {
            for (int j = 0; j < 13; j++) {
                if(!cards[i][j]){
                    if(i==0)System.out.print("S ");
                    if(i==1)System.out.print("H ");
                    if(i==2)System.out.print("C ");
                    if(i==3)System.out.print("D ");
                    System.out.println(j+1);
                }
            }
        }
    }
}



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

int main() {
    int N;
    int K;
    int p[1100];  
    cin >> N;
    cin >> K;
    for (int i = 0; i < N; ++i) cin >> p[i];

//    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
    sort(p, p + N);
    int res = 0;
    for (int i = 0; i < K; ++i) {
        res += p[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define MOD 1e9+7
ll INF = 1e15;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()

ll a,b,c;

int main(){
	cin>>a>>b>>c;
    cout<<b + min(a+b+1, c);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def main():
	n = int(input())
	xy = []
	for _ in range(n):
		xy +=[list(map(int,input().split()))]
	xy.sort(key=lambda x:(x[0],x[1]))
	dic = {}
	for i in range(n):
		for j in range(i+1,n):
			x,y = xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]
			if x*y == 0:
				temp = "{}.{}".format(x,y)
			else:
				k = "" if x*y > 0 else "-"
				x = abs(x)
				y = abs(y)
				temp = "{}.{}{}".format(x,k,y)
			if temp in dic:
				dic[temp] = dic[temp]+1
			else:
				dic[temp] = 1
	mans = 0
	for i in dic:
		mans = max(mans, dic[i])
	ans = n - mans
	print(ans)
	return

main()



Measured memory_bytes: 3188