akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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;
    cin >> N;
    vector<int> A(N,0);
    vector<int> B(N-1,0);
    rep(i,N-1) cin >> B[i];
    A[0] = B[0];
    for(int i = 1;i<N-1;i++){
        A[i] = min(B[i-1],B[i]);
    }
    A[N-1] = B[N-2];

    int sum =0;
    rep(i,N){
        sum += A[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int e;
	while(cin>>e){
		if(e==0) break;
		int m=e,x,ct=0;
		for(int z=pow(e,0.333333333333333334)+1;z>=0;z--){
			for(int y=0;y<pow(e-z*z*z,0.5)+1;y++){
				if(e-z*z*z-y*y>=0){
					x=e-z*z*z-y*y;
					m=min(m,x+y+z);
					ct++;
					if(ct>10000){
						goto end;
					}
				}
				else{
					break;
				}
			}
		}
		end:;
		cout<<m<<endl;
	}
    return 0;
}

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

int main() {
    int64_t A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(V <= W) {
        cout << "NO" << '\n';
        return 0;
    }
    if((V - W) * T >= abs(A - B)) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

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

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

	int N, X;
	cin >> N >> X;
	vector<ll> x;
	ll min_v = INF;
	rep(i, 0, N) {
		ll tmp_x;
		cin >> tmp_x;
		x.push_back(tmp_x);
	}
	x.push_back(X);
	vsort(x);
	ll diff[N];
	rep(i, 0, N) {
		diff[i] = x[i + 1] - x[i];
	}
	ll rsl = diff[0];
	rep(i, 0, N) {
		rsl = gcd(rsl, diff[i]);
	}

	cout << rsl << endl;

}


Measured memory_bytes: 1908
N,M = map(int,raw_input().split())
B = map(int,raw_input().split())
P = map(int,raw_input().split())
C1,C2 = [],[]
for i in xrange(M):
    C1 += [1]*P[i] if i%2 else [0]*P[i]
    C2 += [0]*P[i] if i%2 else [1]*P[i]

ans = 1e10
for C in [C1,C2]:
    if sum(B) == sum(C):
        tmp = 0
        i = j = 0
        while not i == j == N-1:
            if not B[i]: i = min(N-1, i+1)
            if not C[j]: j = min(N-1, j+1)
            if B[i] and C[j]:
                tmp += abs(i-j)
                i = min(N-1, i+1)
                j = min(N-1, j+1)
        ans = min(ans, tmp)
print ans

Measured memory_bytes: 4288
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int A, B, K; cin >> A >> B >> K;
  set<int> st;
  
  repi(i,A,min(A+K-1,B)) {
    st.insert(i);
  }
  
  repi(i,max(B-K+1,A),B) {
    st.insert(i);
  }
  
  for (auto x : st) {
    printf("%d\n", x);
  }
}

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

int main() {
	int k, s, sum = 0;

	cin >> k >> s;

	if (s > 3 * k)cout << sum << endl;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int a = s - x - y;
			if (a > k&&a < 0)break;
			else if(a<=k&&a>=0)sum++;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
onelist,nlist = [],[]
for i in range(M):
    aa,bb = map(int,input().split())
    if aa == 1:
        onelist.append(bb)
    if bb == N:
        nlist.append(aa)


if len(set(onelist) & set(nlist)) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 10000;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, k;
bool fix[105];
int pasta[105];
int dp[105][3][3];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    rep(i, k) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        fix[a] = true;
        pasta[a] = b;
    }
    rep(i, n)rep(j, 3) {
        if (fix[i]) {
            if (i == 0) {dp[i + 1][pasta[i]][1] = 1; break;}
            if (pasta[i] == j) (dp[i + 1][pasta[i]][2] += dp[i][j][1]) %= mod;
            else (dp[i + 1][pasta[i]][1] += dp[i][j][1] + dp[i][j][2]) %= mod;
        }
        else {
            if (i == 0)  {
                dp[i + 1][j][1] = 1;
            }
            else {
                (dp[i + 1][j][2] += dp[i][j][1]) %= mod;
                (dp[i + 1][(j + 1) % 3][1] += dp[i][j][1] + dp[i][j][2]) %= mod;
                (dp[i + 1][(j + 2) % 3][1] += dp[i][j][1] + dp[i][j][2]) %= mod;
            }
        }
    }
    int ans = 0;
    rep(j, 3) (ans += dp[n][j][1] + dp[n][j][2]) %= mod;
    cout << ans % mod << endl;
}

Measured memory_bytes: 3176
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int MaxN = 1e5;

int n;
int a[MaxN + 5];
bool pos[MaxN + 5];
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		for(int i = 1; i <= n; i++)
			scanf("%d", &a[i]);
		int p = 1;
		int cnt = 0;
		bool f = 0;
		while(true)
		{
			cnt++;
			if(pos[p] == 1){
				f = 0;
				break;
			}
			if(p == 2)
			{
				f = 1;
				break;
			}
			pos[p] = 1;
			p = a[p];
		}
		if(f == 1) printf("%d\n", cnt - 1);
		else printf("-1\n");
		memset(a, 0, sizeof(a));
		memset(pos, 0, sizeof(pos));
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if (a>b){
		cout<<"a > b";
	}
	else if (a<b){
		cout<<"a < b";
	}
	else{
		cout<<"a == b";
	}
	cout<<endl;
}



Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
using namespace std;
int main(void){
    int a[3],i,j,mp,count=0;
    for(i=0;i<3;i++){
        cin >> a[i];
    }
    for(i=0;i<3;i++){
        for(j=0;j<2;j++){
        if(a[j]<=a[j+1]){
            mp = a[j];
            a[j] = a[j+1];
            a[j+1] = mp;
        }
        }
    }

    while(a[0]!=a[1]){
        a[1]++;
        a[2]++;
        count++;
    }
        if((a[0]-a[2])%2==0){
            count += (a[0]-a[2])/2;
        }
        else{
            count += ((a[0]+1)-a[2])/2 + 1;
        }
        cout << count;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define pb push_back
#define ll long long
#define ae addEdge
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define vvi vector< vector<int> >
#define pii pair <int,int>
#define sortv sort(v.begin(),v.end())
#define sorta sort(a.begin(),a.end())
#define sortb sort(b.begin(),b.end())
#define sorts sort(s.begin(),s.end())

ll knapsack(vi w, vi v, int n, int wt){
	vector<vector<ll> > dp(n+1,vll (wt+1,0));
	for(int i=0;i<n+1;i++){
		for(int j=0;j<wt+1;j++){
			if(i==0 || j==0) dp[i][j]=0;
			else if(w[i-1]>j) dp[i][j]=dp[i-1][j];
			else dp[i][j]= max(dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]]);
			//cout<<"i"<<i<<"j"<<j<<"dp[i][j]"<<dp[i][j]<<" ";
		}
	}
	return dp[n][wt];
}

int main(){
	ll n,wt;
	cin>>n>>wt;
	vi w,v;
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		w.pb(a); v.pb(b);
	}
	cout<<knapsack(w,v,n,wt)<<endl;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int h,w;
    cin >>h>>w;
    vector<vector<char>> c(h,vector<char> (w,'.'));
    vector<vector<bool>> black(h,vector<bool> (w,false));
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    vector<vector<int>> L(h,vector<int>(w,0));
    vector<vector<int>> R(h,vector<int>(w,0));
    vector<vector<int>> U(h,vector<int>(w,0));
    vector<vector<int>> D(h,vector<int>(w,0));
    rep(i,h){
        for(int j=0;j<w;j++){
            if(j==0){
                L[i][j]=0;

            }
            else if(c[i][j]=='#'){
                L[i][j]=0;
            }
            else if(c[i][j-1]=='#'){
                L[i][j]=0;
            }
            else{
                L[i][j]=L[i][j-1]+1;
            }
            //cout<<L[i][j]<<" ";
        }
        //cout<<endl;
    }
    rep(i,h){
        for(int j=w-1;j>=0;j--){
            if(j==w-1){
                R[i][j]=0;

            }
            else if(c[i][j]=='#'){
                R[i][j]=0;
            }
            else if(c[i][j+1]=='#'){
                R[i][j]=0;
            }
            else{
                R[i][j]=R[i][j+1]+1;
            }
            //cout<<R[i][j]<<" ";
        }
        //cout<<endl;
    }
    rep(j,w){
        rep(i,h){
            if(i==0){
                U[i][j]=0;
            }
            else if(c[i][j]=='#'){
                U[i][j]=0;
            }
            else if(c[i-1][j]=='#'){
                U[i][j]=0;
            }
            else{
                U[i][j]=U[i-1][j]+1;
            }
        }
    }
    /*
    rep(i,h){
        rep(j,w){
            cout<<U[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    rep(j,w){
        for(int i=h-1;i>=0;i--){
            if(i==h-1){
                D[i][j]=0;
            }
            else if(c[i][j]=='#'){
                D[i][j]=0;
            }
            else if(c[i+1][j]=='#'){
                D[i][j]=0;
            }
            else{
                D[i][j]=D[i+1][j]+1;
            }
        }
    }
/*
    rep(i,h){
        rep(j,w){
            cout<<D[i][j]<<" ";
        }
        cout<<endl;
    }
*/int cnt;
    int Max=0;
    rep(i,h){
        rep(j,w){
            cnt = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1;
            if(cnt>Max){
                Max = cnt;
            }
        }
    }

    cout<<Max<<endl;
}

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

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D+1), c(D+1);
    for(int i=1; i<=D; i++) cin >> p[i] >> c[i];

    int ans = 1000;
    for(int i=0; i<pow(2,D); i++){
        int tmp = i;
        int score = 0;
        int nSolved = 0;
        vector<bool> solved(D+1);
        for(int j=1; j<=D; j++) solved[j] = false;

        for(int j=1; j<=D; j++){
            if(tmp%2==1){
                score += 100*j*p[j] + c[j];
                nSolved += p[j];
                solved[j] = true;
            }
            tmp/=2;
        }
        if(score >= G){
            ans = min(ans, nSolved);
            continue;
        }

        for(int j=D; j>=1; j--){
            if(!solved[j] && score + 100*j*(p[j]-1) >= G){
                nSolved += (int)ceil(1.0*(G-score)/(100*j));
                ans = min(ans, nSolved);
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int dx, dy;
  dx = x2 - x1;
  dy = y2 - y1;
  
  int x3, y3, x4, y4;
  x3 = x2 - dy;
  y3 = y2 + dx;
  x4 = x3 - dx;
  y4 = y3 - dy;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int h;
  int w;

  while(1) {
    std::cin >> h >> w;
    if(h == 0 && w == 0) {
      break;
    }
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        std::cout << '#';
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }

  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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; }

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    string s;
    ll q;

    cin >> s;
    cin >> q;

    int t, f;
    char c;

    deque<char> que;

    rep(i, s.size()) {
        que.push_back(s[i]);
    }

    int rev = 0;

    rep(i, q) {
        cin >> t;
        if (t == 1) {
            rev = 1 - rev;

        }else{
            cin >> f >> c;

            if (rev) {
                if (f == 1) {
                    que.push_back(c);
                } else {
                    que.push_front(c);
                }
            } else {
                if (f == 1) {
                    que.push_front(c);
                } else {
                    que.push_back(c);
                }
            }
        }
    }

    if (rev) {
        reverse(que.begin(), que.end());
    }

    rep(i, que.size()) {
        cout << que[i];
    }


    cout << endl;

}



Measured memory_bytes: 896
#include <iostream>

using namespace std;

struct elem {
    int key;
    elem *prev;
    elem *next;
};

struct list {
    elem *first;
    elem *last;

    list() {
        first = nullptr;
        last = nullptr;
    }

    void insert(int x) {
        elem *e;
        e = (elem *) malloc(sizeof(elem));
        e->key = x;
        e->next = nullptr;
        e->prev = nullptr;
        if (this->last == nullptr) {
            this->first = e;
            this->last = e;
        } else {
            e->next = this->first;
            e->next->prev = e;
            this->first = e;
        }
    }

    void deleteFirst() {
        if (this->first == nullptr) return;
        elem *e = this->first;
        if (e->next == nullptr) {
            this->first = nullptr;
            this->last = nullptr;
        } else {
            this->first = e->next;
            this->first->prev = nullptr;
        }
        free(e);
    }

    void deleteLast() {
        if (this->last == nullptr) return;
        elem *e = this->last;
        if (e->prev == nullptr) {
            this->first = nullptr;
            this->last = nullptr;
        } else {
            this->last = e->prev;
            this->last->next = nullptr;
        }
        free(e);
    }

    void erase(int x) {
        elem *e = this->first;
        while (e->key != x) {
            if (e->next == nullptr) return;
            e = e->next;
        }
        if (e == this->first) {
            this->deleteFirst();
        } else if (e == this->last) {
            this->deleteLast();
        } else {
            e->next->prev = e->prev;
            e->prev->next = e->next;
            free(e);
        }
    }
};

int main() {
    int n, val;
    string op;
    list li;
    cin >> n;
    while (n-- > 0) {
        cin >> op;
        if (op == "deleteFirst") li.deleteFirst();
        else if (op == "deleteLast") li.deleteLast();
        else {
            cin >> val;
            if (op == "insert") li.insert(val);
            else if (op == "delete") li.erase(val);
        }
    }
    if (li.first != nullptr) {
        elem e = *li.first;
        while (e.next != nullptr) {
            cout << e.key << ' ';
            e = *e.next;
        }
        cout << e.key << endl;
    } else cout << endl;
    return 0;
}



Measured memory_bytes: 34304
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo;}
  else return mpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n,d;
  cin>>n>>d;
  vector<ll> D,Q;
  vector<ll> dp1,dp2;
  dp1.push_back(d);
  dp2.push_back(0);
  rep(i,n){
    ll inp;
    cin>>inp;
    D.push_back(inp);
    if(inp < dp1[i]){
      dp1.push_back(dp1[i] - inp);
    }else if(inp < dp1[i]*2){
      dp1.push_back(inp - dp1[i]);
    }else{
      dp1.push_back(dp1[i]);
    }
  }
  REP(i,n){
    if(D[i]/2 <= dp2.back()){
      dp2.push_back(dp2.back() + D[i]);
    }else{
      dp2.push_back(dp2.back());
    }
  }
  reverse(all(dp2));
  /*rep(i,n){
    cout<<i<<" "<<dp1[i]<<" "<<dp2[i]<<endl;
  }*/
  ll q;
  cin>>q;
  rep(i,q){
    ll inp;cin>>inp;inp--;
    Q.push_back(inp);
    if(dp1[inp] <= dp2[inp+1]){
      cout<<"NO"<<endl;
    }else{
      cout<<"YES"<<endl;
    }
  }

  return 0;
}


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

int main() {
	int n;
	cin>>n;
	int M[105][105];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			M[i][j]=0;
		}
		
	}
	int h,p,e;
	for(int i=0;i<n;i++){
		cin>> h>>p;
		h--;
		for(int j=0;j<p;j++){
			cin>>e;
			e--;
			M[h][e]=1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j){
				printf(" ");
			}
			printf("%d",M[i][j]);
		}
		cout <<endl;
	}
	return 0;
}


Measured memory_bytes: 3256
x1, y1, x2, y2 = map(int, input().split())

r1 = y1-y2
r2 = x1-x2
x3 = x2+r1
y3 = y2-r2
x4 = x3+r2
y4 = y3+r1

print("{} {} {} {}".format(x3, y3, x4, y4))


Measured memory_bytes: 2940
from collections import deque
H,W = map(int,input().split())
s = list(input() for i in range(H))
board = [[1]*(W+2) for i in range(H+2)]
white = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            white += 1
            board[i+1][j+1] = 0
queue = deque([[1,1]])
v = [[1,0],[-1,0],[0,-1],[0,1]]
while queue != deque([]):
    x,y = queue.popleft()

    for a,b in v:
        if board[x+a][y+b] == 0:
            board[x+a][y+b] = board[x][y]+1
            queue.append([x+a,y+b])

if board[H][W] != 0:
    print(white-board[H][W]-1)
else:
    print(-1)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

//////////////////////////////////////////////////////
//BellmanFord/////////////////////////////////////////
//////////////////////////////////////////////////////
struct edge { int from, to, cost; };
edge es[MAX_M];
ll d[MAX_N];
int V, E;

void bellmanFord(int s) {
	fill(d, d + V, INF);
	d[s] = 0;
	ll cnt = 0;
	while (1) {
		cnt++;
		bool update = false;
		rep(i, 0, E) {
			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;
				if (cnt == V - 1) {
					cout << "NEGATIVE CYCLE" << endl;
					exit(0);
				}
				update = true;
			}
		}
		if (!update) break;
	}
}
bool find_negative_loop() {
	rep(i, 0, V)d[i] = 0;
	rep(i, 0, V) {
		rep(j, 0, E) {
			edge e = es[j];
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if (i == V - 1) return true;
			}
		}
	}
	return false;
}
///////////////////////////////////////////////////////
int main() {
	ll r; cin >> V >> E >> r;
	rep(i, 0, E) {
		ll s, t, d; cin >> s >> t >> d;
		es[i].from = s;
		es[i].to = t;
		es[i].cost = d;
	}

	//if (find_negative_loop()) {
	//	cout << "NEGATIVE CYCLE" << endl;
	//	return 0;
	//}
	bellmanFord(r);

	rep(i, 0, V) {
		if (d[i] == INF)cout << "INF" << endl;
		else cout << d[i] << endl;
	}
	return 0;
}


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

using namespace std;

int main(void){
    string s, t;

    cin >> s >> t;

    int len = s.size();

    int cnt = 0;
    for(int i = 0; i < len; i++){
        if(s[i] != t[i]) cnt++;
    }

    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3824
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-7
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(n) ((n) * (n))
#define INF 300000005
#define MAXN 1000000

int main()
{
	ll n;
	scanf("%lld", &n);
	printf("50\n");
	REP(i, 50)
	{
		printf("%lld ", 49 - i + (n + 49 - i) / 50);
	}
	return 0;
}


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

using namespace std;

int main()
{
	int N;
	string com;
	list<int> v;

	cin >> N;

	for (int i = 0;i < N;i++)
	{
		int key;
		cin >> com;

		if (com == "insert")
		{
			cin >> key;
			v.push_front(key);
		}
		else if (com == "delete")
		{
			cin >> key;
			for (auto it = v.begin(); it != v.end();it++)
			{
				if (*it == key)
				{
					v.erase(it);
					break;
				}
			}
		}
		else if (com == "deleteFirst")
			v.pop_front();
		else if (com == "deleteLast")
			v.pop_back();
	}

	int i = 0;
	for(auto it : v)
	{
		if (i > 0)
			cout << " ";
		cout << it;

		i++;
	}
	cout << endl;

	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a,b;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='A'){
            a=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s.at(i)=='Z'){
            b=i;
            break;
        }
    }
    cout << b-a+1 << endl;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))

a=sorted(a,reverse=True)
if n==2:
    print(max(a))
    exit(0)

ans=a[0]
a=a[1:]
from math import floor

for i in range(n-2):
    index=floor(i/2)
    ans+=a[index]

print(ans)

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int x; cin >> x;
    if (x > 29) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3616
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[A,B,C] = inpl()
print(max(B+C-A,0))

Measured memory_bytes: 14536
#include<stdio.h>

int main() {
  int N,T;
  scanf("%d%d",&N,&T);
  int A[N];
  int a;
  for (int i=0;i<N;i++) {
      scanf("%d",&a);
      A[i]=a;
  }
  int ans = 0;
  for (int i=0;i<N-1;i++) {
    int p = A[i+1] - A[i];
    if (p <= T) ans += p;
    else ans += T;
  }
  printf("%d\n",ans+T);
  return 0;
}

Measured memory_bytes: 896
#include"iostream"
using namespace std;
 
int main()
{
	int h, w;
	cin >> h >> w;
	int a[510][510];
	int check[250250][4];
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> a[i][j];
		}
	}
 
	int ans = 0;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w-1; j++)
		{
			if (a[i][j] % 2 == 1)
			{
				check[ans][0] = i;
				check[ans][1] = j;
				check[ans][2] = i;
				check[ans][3] = j + 1;
				ans++;
				a[i][j + 1] ++;
			}
		}
	}
 
	for (int i = 0; i < h-1; i++)
	{
		if (a[i][w - 1] % 2 == 1)
		{
			check[ans][0] = i;
			check[ans][1] = w - 1;
			check[ans][2] = i + 1;
			check[ans][3] = w - 1;
			ans++;
			a[i + 1][w - 1]++;
		}
	}
	cout << ans << "\n";
	for (int i = 0; i < ans; i++)
	{
		cout << check[i][0] + 1 << " " << check[i][1] + 1 << " " << check[i][2] + 1 << " " << check[i][3] + 1 << "\n";
	}
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int N, W;
    cin >> N >> W;
    ll w[N], v[N];
    rep(i, 0, N) cin >> w[i] >> v[i];

    ll dp[N + 1][W + 1];
    rep(i, 0, N + 1) rep(j, 0, W + 1) dp[i][j] = 0ll;

    rep(i, 0, N) {
        rep(j, 0, W + 1) {
            if(0 <= j - w[i]) {
                dp[i + 1][j] = max(dp[i + 1][j], max(dp[i][j], dp[i][j - w[i]] + v[i]));
            } else {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            }
        }
    }

    cout << dp[N][W] << endl;

}


Measured memory_bytes: 79104
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int naive(const vector<pair<int, int>> &AB, const int T) {

	int res = 0;
	for (int bit = 0; bit < (1 << AB.size()); bit++) {

		int last = 0, sum = 0, time = 0;
		for (int i = 0; i < AB.size(); i++) {

			if (bit & (1 << i)) {
				int tmp = last;
				if (chmax(last, AB[i].first)) time += tmp;
				else time += AB[i].first;
				sum += AB[i].second;
			}
			if (time >= T) break;
		}

		if (time < T) if(chmax(res, sum)) DMP(bit);

	}

	return res;

}

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

int main() {

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

	int N, T;
	cin >> N >> T;

	vector<pair<int, int>> AB(N);
	for (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;
	sort(AB.begin(), AB.end());
	
	auto dp = make_vec(N + 1, T + 1, 0);
	for (int i = 1; i <= N; i++) {
		dp[i] = dp[i - 1];
		for (int j = 0; j < T; j++) {
			chmax(dp[i][min(j + AB[i - 1].first, T)], dp[i - 1][j] + AB[i - 1].second);
		}
	}
	DMP(dp);

	int ans = 0;
	for (int j = 0; j <= T; j++) chmax(ans, dp[N][j]);
	
	cout << ans << "\n";
	DMP(naive(AB, T));

	return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int f = 0;
	for(int i = 0; i < s.length()-1;i++){
		if(s[i] == s[i+1]){
			cout<<"Bad"<<endl;
			f = 1;
			break;
		}
	}
	if(f == 0)
		cout<<"Good"<<endl;
	return 0;
} 

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    string S; cin >> S;
    int cnt = 1;
    rep(i, N-1) {
        if (S[i] != S[i+1]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int n, W;
int v[1200], w[1200], dp[1200];

int main() {
  int cnt = 1;
  while(cin >> W, W) {
    cin >> n;
    for(int i = 0; i < n; i++) scanf("%d,%d", &v[i], &w[i]);
    
    printf("Case %d:\n", cnt++);
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < n; i++) {
      for(int j = W; j >= 0; j--) {
	if(j-w[i] >= 0) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
      }
    }
    cout << dp[W] << endl;

    for(int i = W; i >= 0; i--) {
      if(dp[W] != dp[i]) {
	cout << i+1 << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 1284
use text_io::*;
use std::process::exit;

fn main(){
    let mut k:usize = read!();
    let mut a:usize = read!();
    let mut b:usize = read!();
    for i in a..b+1 {
        if i%k == 0 {
            println!("OK");
            exit(0);
        }
    }
    println!("NG");
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    veci x(5);
    REP(i,5) cin >> x[i];
    REP(i,5) {
        if(x[i] != i+1) {
            cout << i+1 << endl;
            return 0;
        }
    }   
}

Measured memory_bytes: 3588
var F:array[0..100000] of int64;
     W,V:array[0..100000] of longint;
     i,n,m,t:longint;  f1:text; max:int64;

 function min(x,y:int64):int64;
 begin
  if x<y then exit(x) else exit(y);
 end;

 begin
  assign(f1,''); reset(F1);
  readln(f1,n,m);
  max:=low(int64);
  for i:=1 to n do readln(f1,W[i],V[i]);
  for i:=1 to 100000 do F[i]:=100000000000;
  for i:=1 to n do
   for t:=100000 downto v[i] do F[t]:=min(F[t],F[t-v[i]]+w[i]);
  for i:=1 to 100000 do
   if F[i]<=m then if max<i then max:=i;
  write(max);
  readln;
  close(f1);
 end.




Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, h;
    cin >> n >> h;
    vector<P> k(n);
    rep(i,n) cin >> k[i].second >> k[i].first;
    sort(rall(k));
    int maxD = 0;
    rep(i,n) maxD = max(maxD, k[i].second);
    int ans = 0;
    int i = 0; 
    while(i < n){
        if (k[i].first > maxD){
            ans++;
            h -= k[i].first;
        }
        if (h <= 0) break;
        if (k[i].first <= maxD || i == n-1){
            ans += h / maxD;
            if (h % maxD != 0) ans++;
            break;
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4060
#include<iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
        return 0;
    }
    int a, b;
    cin >> a;
    cin >> b;

    cout << a + b << endl;
    return 0;
}

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

int main(){
  long long X;
  cin >>  X ;
  long long A =100;
  int i=0;
  while(X>A){
    A*=1.01;
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 3604
class Segment_Tree():
    def __init__(self,N,calc,unit,L=[]):
        """calcを演算とするN項のSegment Treeを作成

        N:要素数
        calc:演算(2変数関数,モノイド)
        unit:モノイドcalcの単位元 (xe=ex=xを満たすe)
        """
        self.calc=calc
        self.unit=unit

        N=max(N,len(L))

        d=max(1,(N-1).bit_length())
        k=2**d

        X=[unit]*(k-1)+L+[unit]*(k-len(L))

        self.num=k
        self.depth=d

        for i in range(k-2,-1,-1):
            X[i]=calc(X[2*i+1],X[2*i+2])

        self.data=X

    def index(self,k,index=0):
        return self.data[(self.num-1)+(k-index)]

    def update(self,k,x,index=0):
        """第k要素をxに変え,更新を行う.

        k:数列の要素
        x:更新後の値
        """

        m=(self.num-1)+(k-index)
        self.data[m]=x

        for _ in range(self.depth):
            m=(m-1)//2
            self.data[m]=self.calc(self.data[2*m+1],self.data[2*m+2])


    def sub_array(self,From,To,index=0,left_closed=True,right_closed=True):
        A=From-index+(not left_closed)
        B=To-index-(not right_closed)

        return self.__sub_array_second(A,B+1,0,0,self.num)

    def __sub_array_second(self,a,b,k,l,r):
        if r<=a or b<=l:
            return self.unit
        elif a<=l and r<=b:
            return self.data[k]
        else:
            alpha=self.__sub_array_second(a,b,2*k+1,l,(l+r)//2)
            beta=self.__sub_array_second(a,b,2*k+2,(l+r)//2,r)
            return self.calc(alpha,beta)

    def all_prod(self):
        return self.data[0]

    def max_right(self,l,r,cond,index=0):
        """以下の2つをともに満たすxの1つを返す.\n
        (1) r=l or cond(data[l]*data[l+1]*...*d[r-1]):True
        (2) r=x or cond(data[l]*data[l+1]*...*data[r]):False
        ※fが単調減少の時,cond(data[l]*...*data[r-1])を満たす最大のrとなる.

        cond:関数(引数が同じならば結果も同じ)
        cond(unit):True
        0<=l<=r<=n
        """
        l-=index
        assert 0<=l<=r<=self.num,"添字が範囲外"
        assert cond(self.unit),"単位元が条件を満たさない."

        if l==r:
            return r+index

        l+=(self.num-1)
        sm=self.unit

        calc=self.calc
        while True:
            while l%2:
                l=(l-1)>>1

            if not cond(calc(sm,self.data[l])):
                while l<self.num-1:
                    l=2*l+1

                    if cond(calc(sm,self.data[l])):
                        sm=calc(sm,self.data[l])
                        l+=1

                return min(l-(self.num-1)+index,r)

            sm=calc(sm,self.data[l])
            l+=1

            m=l+1
            if not (m&(-m) !=m):
                break

        return r+index
#================================================
N,Q=map(int,input().split())
A=list(map(int,input().split()))

S=Segment_Tree(N,lambda x,y:max(x,y),-1,A)

X=[]
for _ in range(Q):
    T,alpha,beta=map(int,input().split())

    if T==1:
        S.update(alpha,beta,1)
    elif T==2:
        X.append(S.sub_array(alpha,beta,1))
    else:
        X.append(S.max_right(alpha,N,lambda x:x<beta,1))

print("\n".join(map(str,X)))


Measured memory_bytes: 130344
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
int c[110];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		c[p]++;c[q]++;
	}
	for(int i=0;i<a;i++)printf("%d\n",c[i]);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int K, A, B;
    string ans = "NG";
    cin >> K >> A >> B;
    
    for (int i = A; i < B + 1; i++) {
        if (i % K == 0) {
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
}


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

const int M=1e5+5;
int h[M];
vector<int> g[M];

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	int u,v;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int f=1;
		for(int v:g[i])
			if(h[v]>=h[i])
			{
				f=0;
				break;
			}
		ans+=f;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9348
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;
const int MAX_LEN = 500100;
bool G[MAX_LEN];
bool rG[MAX_LEN];

int z[2][MAX_LEN];
void Z(int b) {
    int L = (int)s.size();
    z[b][0] = L;
    int i = 1, j = 0;
    while (i < L) {
        while (i+j < L && s[j] == s[i+j]) j++;
        z[b][i] = j;
        if (j == 0) {
            i++;
            continue;
        }
        int k = 1;
        while (i+k < L && k+z[b][k] < j) {
            z[b][i+k] = z[b][k];
            k++;
        }
        i += k;
        j -= k;
    }
}


bool uniq() {
    for (int i = 1; i < (int)s.size(); i++) {
        if (s[0] != s[i])
            return false;
    }
    return true;
}

void solve() {
    int L = (int)s.size();
    if (uniq()) {
        cout << L << endl;
        cout << 1 << endl;
        return;
    }

    Z(0);
    reverse(ALL(s));
    Z(1);
    
    memset(G, true, sizeof(G));
    memset(rG, true, sizeof(rG));
    for (int i = 1; i <= L; i++) {
        for (int j = i; j < L; j+=i) {
            if (z[0][j] >= i) G[j+i-1] = false;
            else break;
        }
    }
    for (int i = 1; i <= L; i++) {
        for (int j = i; j < L; j+=i) {
            if (z[1][j] >= i) rG[L-j-i] = false;
            else break;
        }
    }

    
    if (G[L-1]) {
        cout << 1 << endl;
        cout << 1 << endl;
        return;
    }

    int res = 0;
    for (int i = 0; i < L-1; i++) {
        if (G[i] && rG[i+1])
            res++;
    }
    cout << 2 << endl;
    cout << res << endl;
}

void input() {
    cin >> s;
}

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

    input();
    solve();
}


Measured memory_bytes: 5788
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <time.h>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int a, b, c, d, ans = -INF;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;
    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> k(m), p(m);
    vector<vector<int>> s(m, vector<int>(n));
    rep(i, m) {
        cin >> k[i];
        rep(j, k[i]) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i, m) cin >> p[i];

    int ans = 0;

    rep(t, 1 << n) {
        bool check = true;
        rep(i, m) {
            int tot = 0;
            rep(j, k[i]) {
                if(t >> s[i][j] & 1) {
                    tot++;
                }
            }
            if(tot % 2 != p[i]) check = false;
        }
        if(check) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using i64 = int64_t;

int main(){
    int n, m;
    while(cin >> n >> m, n != 0){
        vector<i64> v;
        for(int i=0;i<n;++i){
            i64 a;
            cin >> a;
            v.push_back(a);
        }
        i64 ans = -1;
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                if(v[i] + v[j] <= m && ans < v[i] + v[j]){
                    ans = v[i] + v[j];
                }
            }
        }
        if(ans == -1)cout << "NONE" << endl;
        else cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3044
#include <iostream>

using namespace std;

int A[20];
int n, q;
bool solved[20];

bool solve(int index, int m) {
    if (m == 0) return (solved[index] = true);
    if (index >= n) return false;
    return solve(index + 1, m) || solve(index + 1, m - A[index]);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    cin >> q;
    int target[q];
    for (int i = 0; i < q; i++) cin >> target[i];
    for (int m: target) {
        cout << (solve(0, m) ? "yes" : "no") << endl;
    }
}



Measured memory_bytes: 3084