akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 100005
#define MOD 1000000007

int n, answer, d[NMAX], AIB[NMAX];
long long v[NMAX],a,b;

void update(int poz,int val)
{
    for(; poz <= n; poz += (poz^(poz-1)&poz)){
        AIB[poz] += val;
        if(AIB[poz] >= MOD)
            AIB[poz] -= MOD;
    }
}
 
inline int query(int poz)
{
    int s = 0;
    for(; poz; poz -= (poz^(poz-1)&poz)){
        s += AIB[poz];
        if(s >= MOD)
            s -= MOD;
    }
    return s;
}
 

int main (){
    
    scanf("%d%lld%lld",&n,&a,&b);
    
    if(a < b){
        long long aux = a;
        a = b;
        b = aux;
    }
    
    for(int i = 1; i <= n; i++){
        scanf("%lld", &v[i]);
        if(i > 2 && v[i] - v[i - 2] < b){
            printf("0\n");
            return 0;
        }
    }
        
    int last = n + 1;
    d[n] = 1;
    update(n, d[n]);
    for(int i = n - 1; i >= 1; i--){
        if(last == n + 1)
            d[i] = 1;
            
        int st = i + 1, dr = n, sol = 0;
        while(st <= dr){
            int mij = (st + dr) / 2;
            if(v[mij] - v[i] < a)
                st = mij + 1;
            else{
                sol = mij;
                dr = mij - 1;
            }
        }
        if(sol && sol <= last){
            d[i] += (query(min(last, n)) - query(sol - 1)) % MOD;
            if(d[i] < 0)
                d[i] += MOD;
        }
        update(i, d[i]);
        if(v[i + 1] - v[i] < b)
            last = i + 1;

      // printf("%d %d\n",i,d[i]);
    }
    
    int answer = 0;
    d[n + 1] = 1;
    for(int i = 1; i <= n + 1; i++){
        answer += d[i];
        if(answer >= MOD)
            answer -= MOD;
        if(i > 1 && v[i] - v[i - 1] < b)
            break;
    }
    printf("%d\n", answer);
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  // 読み込み
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> data.at(i).at(j);
  	}
  }
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (data.at(i).at(j) == '#') {
        cout << '#';
      } else {
        int count = 0;
        for (int ki=i-1; ki<=i+1; ki++) {
          for (int kj=j-1; kj<=j+1; kj++) {
            if (ki>=0 && ki<H && kj>=0 && kj<W) {
              if (data.at(ki).at(kj) == '#')
                count++;
            }
          }
        }
        cout << count;
      }
  	}
    cout << endl;
  }
}

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

int main(){
    char s[4];
    for(int i=0;i<4;i++){
        cin>>s[i];
    }

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

    cout<<"Good"<<endl;
    return 0;
}

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

vector<long long int> a,dp;
 int main(){
    long long int N ; cin>>N;
    a.resize(N);
    dp.resize(N,1e9);
    // memset(dp,0,sizeof(dp));
    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(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    // for (int j=0;j<N;++j){
    //     cout<<dp[j]<<" ";
    // }
    cout<<dp[N-1]<<endl;
    return 0;
 }

Measured memory_bytes: 4784
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
const ll mod = (ll)1e9 + 7;
const ll INF = (ll)2e18;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}

class BROTN {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    string S, ans;
	    in >> N >> S;
	    for (char a : S) {
	        ans += ((int)a - (int)'A' + N) % 26 + 'A';
	    }
	    out << ans << endl;
	}
};


int main() {
	BROTN solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import math

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

ans = 0
fil = 1
for i in range(60):
    num1 = len([1 for j in range(N) if A[j] & fil])
    num0 = N - num1
    ans += (num1 * num0) * fil
    fil <<= 1

print(ans % (10 ** 9 + 7))

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

int main()
{
	int w,n,i;
	cin >> w; cin >> n;
	int vertical_bar[w];
	// 配列を初期化
	for(i=0;i<w;i++){
		vertical_bar[i] = i+1;
	}
		
	for(i=0;i<n;i++){
		int a,b;
		scanf("%d, %d", &a,&b);
		swap(vertical_bar[a-1], vertical_bar[b-1]);
	}
	
	for(i=0;i<w;i++){
		cout << vertical_bar[i] <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
 
template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}
 
//~ ifstream f(".in");
//~ ofstream g(".out");
 
const int NMAX = 2e5 + 5;

int h[NMAX];
int a[NMAX];
ll tree[4 * NMAX];
ll lazy[4 * NMAX];

void update(int node, int left, int right, int x, int y, ll val) {
  if (x <= left && right <= y) {
    uax(tree[node], val);
    uax(lazy[node], val);
    return;
  }
  int mid = left + (right - left) / 2;
  if (x <= mid) {
    update(2 * node + 1, left, mid, x, y, val);
  }
  if (mid < y) {
    update(2 * node + 2, mid + 1, right, x, y, val);
  }
}

ll query(int node, int left, int right, int pos) {
  int mid = left + (right - left) / 2;
  if (left != right) {
    update(2 * node + 1, left, mid, left, mid, lazy[node]);
    update(2 * node + 2, mid + 1, right, mid + 1, right, lazy[node]);
  } else {
    return tree[node];
  }
  if (pos <= mid) {
    return query(2 * node + 1, left, mid, pos);
  } else {
    return query(2 * node + 2, mid + 1, right, pos);
  }
}
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif
 
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> h[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ll curr_dp = query(0, 1, n, h[i]) + a[i];
    update(0, 1, n, h[i], n, curr_dp);
    uax(ans, curr_dp);
  }
  
  cout << ans << '\n';
 
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 14080
using System;

class _0045 {
    public static void Main() {
        string str;
        long sum = 0, ams = 0, ave = 0, c = 0;
        int[] nums;
        while ((str = Console.ReadLine()) != null) {
            c++;
            nums = Array.ConvertAll(str.Split(','), s => int.Parse(s));
            sum += nums[0] * nums[1];
            ams += nums[1];
        }
        ave = (long)Math.Round(ams / (double)c, MidpointRounding.AwayFromZero);
        Console.Write("{0}\n{1}\n", sum, ave);
    }
}

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

void dfs(map<int, vi> G, vi &Q, int cur) {
    Q[cur] = true;

    for (int i = 0; i < G[cur].size(); i++) {
        if (Q[G[cur][i]]) continue;
        dfs(G, Q, G[cur][i]);
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vi A(M), B(M);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    int bridge_cnt = 0;
    // 落とす橋で全探索する
    rep(i, M) {

        map<int, vi> G;
        rep(j, M) {
            if (i == j) continue;
            G[A[j]].push_back(B[j]);
            G[B[j]].push_back(A[j]);
        }

        vi Q(N, false);

        int cnt = 0;
        for (int k = 0; k < N; k++) {
            if (!Q[k]) {
                dfs(G, Q, k);
                cnt++;
            }
        }
        if (cnt != 1) bridge_cnt++;
    }

    cout << bridge_cnt << endl;
}

Measured memory_bytes: 3848
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))
(deftype int7 () '(signed-byte 7))

;;macros
(defmacro println (n)
  `(format t "~a~%" ,n))
(defmacro vint-out (vec)
  `(progn
     (rep i (length ,vec)
          (princ (vref ,vec i))
          (princ " "))
     (fresh-line)))


;;vector
(defmacro vec (type &optional (num 100) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num))
       (make-array ,g :element-type ',type :initial-element ,val
                   :adjustable nil :fill-pointer ,g))))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))

(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

(defmacro defchangef (name op default-val)
  `(defmacro ,name (var &optional (val ,default-val))
     `(setq ,var (,',op ,val ,var))))

;;本体
(defvar n (read))
(defvar a (make-array `(2 ,n) :element-type 'int7))
(dotimes (i 2)
  (dotimes (j n)
    (setf (aref a i j) (read))))
(defun dfs (i j arr)
  (cond ((and (= i 1) (= j (1- n))) (aref arr 1 (1- n)))
        ((= i 1) (+ (dfs i (1+ j) arr) (aref arr i j)))
        ((= j (1- n)) (+ (dfs 1 j arr ) (aref arr i j)))
        (t (max (+ (dfs i (1+ j) arr) (aref arr i j))
                (+ (dfs (1+ i) j arr) (aref arr i j))))))

(defun main ()
  (println (dfs 0 0 a)))

  
#-swank(main)


Measured memory_bytes: 22884
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().rstrip()

    L = 0
    R = 0
    for s in S:
        if s == "(":
            R += 1
        else:
            if R > 0:
                R -= 1
            else:
                L += 1

    ans = "".join(["(" * L, S, ")" * R])
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#define INF 0x3f3f3f3f
typedef long long LL;
const int N = 1e5 + 10;

void solve()
{
    int n;cin>>n;
  	if(n>=30) cout<<"Yes\n";
  	else cout<<"No\n";
}
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //freopen("data1.txt", "r", stdin);
    //freopen("data2.txt", "w", stdout);
    int _ = 1;
    //cin >> _;
    for (int i = 1; i <= _; ++i)
        solve();
    //system("pause");
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, M, C;
    cin >> N >> M >> C;
    vector<ll> B(M);
    rep(i, 0, M) cin >> B[i];
    ll ans = 0;
    rep(i, 0, N){
        ll tmp = C;
        rep(j, 0, M){
            ll a; cin >> a;
            tmp += a * B[j];
        }
        if(tmp > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int v[n],c[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>v[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>c[i];
	}
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		if (v[i]-c[i]>0)
		{
			ans+=v[i]-c[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define abs(a) (((a)>0)?(a):(-a))

int main()
{
	int n;
	char s[110];
	int ans = 0, ch[30], count;

	scanf("%d%s", &n, s);
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < 30; j++)
		{
			ch[j] = 0;
		}
		count = 0;
		for (int j = 0; j <= i; j++)
		{
			ch[s[j] - 'a'] = 1;
		}
		for (int j = i + 1; j < n; j++)
		{
			if (ch[s[j] - 'a'] == 1)
			{
				count++;
				ch[s[j] - 'a'] = 0;
			}
		}
		ans = max(ans, count);
	}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(ll i=a;i<(b);i++)
#define fj(a,b) for(ll j=a;j<(b);j++)
#define fk(a,b) for(ll k=a;k<(b);k++)
//hash base 177013
const int mod=1e9+7;
ll binpow(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1){
			res=((res%mod)*(a%mod))%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b=b>>1;
	}
	return res%mod;
}
const int mxn=1e6+3;
vector<ll> fact(mxn),inv(mxn);
void facto()
{
	fact[0]=fact[1]=1;
	fi(2,mxn)
	{
		fact[i]=(fact[i-1]*i)%mod;
		//assert(fact[i]>=0&&fact[i]<=mod);
	}
	inv[0]=inv[1]=1;
	fi(2,mxn)
	{
		inv[i]=binpow(fact[i],mod-2)%mod;
		//assert(inv[i]>=0&&inv[i]<=mod);
	}	
}

ll ncr(ll a,ll b)
{
	//assert(a-b>=0);
	return (((fact[a]*inv[b])%mod)*inv[a-b]%mod)%mod;
}

int main()
{
	FAST;
	facto();
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		ll n;
		cin>>n;
		ll ans=1,ans2=1,ans3=1;
		fi(0,n)
		{
			ans=(ans*9)%mod;
			ans2=(ans2*8)%mod;
			ans3=(ans3*10)%mod;
		}	
		//cout<<ans2<<'\n';
		ll out=(ans3+ans2)%mod-(2*ans)%mod;
		if(out<0)
		{
			out+=mod;
		}
		cout<<out%mod<<'\n';
		//map<int,int> m;
		//fi(1,n+1)
		//{	
			//ll pos_zero=ncr(n,i);
			//fj(1,n+1)
			//{
				//if(i+j>n) break;
				//ll pos_one=ncr(n-i,j);
				//ll rem=n-i-j;
				//ans=(ans+(((binpow(8,rem)*pos_zero)%mod)*pos_one%mod)%mod)%mod;
			//}
		//}
		//cout<<ans<<'\n';
	}
}



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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int n, d;
    cin >> n >> d;
    d = 2 * d + 1;
    cout << (n + d - 1) / d << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using ll = long long;
using namespace std;
int N;
int ans = 0;
int D[100010];
void dfs(ll x, bool flag3, bool flag5, bool flag7){
    if(x > N)return;
    if(flag3 && flag5 && flag7)ans++;
    
    dfs(10 * x + 3, true, flag5, flag7);
    dfs(10 * x + 5, flag3, true, flag7);
    dfs(10 * x + 7, flag3, flag5, true);
}
int main(){
        cin >> N;
        dfs(0,0,0,0);
    cout << ans;
}


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

signed main(){
  int N,W;cin>>N>>W;
  std::vector<int> w(N),v(N);
  for(int i=0;i<N;i++)cin>>w[i]>>v[i];
  std::vector<int> dp(W+1);
  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]);
    }
  }
  sort(dp.begin(),dp.end());
  cout<<dp[W]<<endl;
}


Measured memory_bytes: 1024
A,B,K = map(int,input().split())

if A+K-1 < B-K+1:
    for i in range(A,A+K):
        print(i)

    for  i in range(B-K+1,B+1):
        print(i)
else:
    for i in range(A,B+1):
        print(i)



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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int x,y;
    cin >> x >> y;
    if(x > y)cout << "safe";
    else cout << "unsafe";
    return 0;
}


Measured memory_bytes: 3596
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		long N = sc.nextLong();
		long P = sc.nextLong();
		long ans = 1;
		
		if(N == 1){
			System.out.println(P);
			return;
		}
		
		for(long i = 2; i * i <= P; i++){
			if(P % i == 0){
				int count = 0;
				while(P % i == 0){
					P /= i;
					count++;
				}
				//System.out.println(i + " ^ " + count);
				if(count >= N){
					int num = (int)(count / N);
					ans *= Math.pow(i, num);
				}
			}
		}
		
		
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<size_t> a(n, 0);
    for (size_t i = 0; i < n; ++i)
        cin >> a[i];
    auto x = max(a[0], a[1]);
    auto y = min(a[0], a[1]);
    for (size_t i = 2; i < n; ++i) {
        auto z = a[i];
        if (x < z)
            x = z;
        else if (y < z)
            y = z;
    }
    for (size_t i = 0; i < n; ++i) {
        if (a[i] == x)
            cout << y << endl;
        else
            cout << x << endl;
    }
    return 0;
}

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

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

ll gyaku(ll a);
ll d = pow(10, 9) + 7;

int main(){
  ll x, y;
  cin >> x >> y;

  if((2*y-x)%3!=0 || (2*x-y)%3!=0 ||(2*x-y)<0||(2*y-x)<0) cout << 0;
  else{
    ll a=(2*y-x)/3, b=(2*x-y)/3;
    ll ans = 1;
    for(ll i=0; i<a; i++){
      ans = ans * (a+b-i);
      //cout << ans << endl;
      if(ans>d) ans = ans%d;
      ans = ans * (gyaku(a-i)%d);
      if(ans>d) ans = ans%d;
    }
    if(ans>d) ans = ans%d;
    cout << ans;
  }
}

ll gyaku(ll a){
  ll x=1;
  ll di = d-2;

  while(di>0){
    if(di&1) x *= a;
    a  = a * a % d;
    if(x>d) x=x%d;
    di >>= 1;
  }
  return x;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long a[100000],b[100000];
    vector<pair<long,long>>v;
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
        v.push_back(make_pair(a[i]+b[i],a[i]));
    }
    sort(v.rbegin(),v.rend());
    long long x=0,y=0;
    for(int i=0; i<n; i++){
        if(i%2==0)x+=v[i].second;
        else y+=v[i].first-v[i].second;
    }
    cout<<x-y<<endl;
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// 整数スキャン（複数）
/*
int x;
scanf("%d",&x);
int y;
scanf("%d",&y);
int z;
scanf("%d",&y);

// n個の整数のスキャン
/*
ll a[n] = {};
rep(i,n){
    scanf("%lld",&a[i]);
}
*/

// 文字列スキャン
/*
string s;
cin >> s;
*/


int main() {
    int n;
    scanf("%d",&n);
    int x;
    scanf("%d",&x);
    int ans = 0;

    if(n%x==0){
        ;
    }else{
        ans=1;
    }




    

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


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

int main() {
    std::string S;
    std::cin >> S;
    
    if (S == "keyence") {
        std::cout << "YES" << std::endl;
        return 0;
    }
    
    auto offset = S.size()-7;
    
    bool ans = false;
    for (size_t i=0; i<S.size()-offset; i++) {
        std::string Ser = S;
        Ser.erase(i, offset);
        if (Ser == "keyence") { 
            ans = true;
            break;
        }
    }
    std::cout << (ans ? "YES" : "NO") << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int P,A,B,C,D,X,Y;
  scanf("%d\n%d\n%d\n%d\n%d",&A,&B,&C,&D,&P);
  X=P*A;
  if (P<=C){
    Y=B;
  } else{
    Y=B+(P-C)*D;
  }
  if (X<=Y){
    printf("%d\n",X);
  }else{
    printf("%d\n",Y);
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int b[m],a[n][m];
    rep(i,0,m-1){
        cin>>b[i];
    }
    int ans=0;
    int sum=0;
    rep(i,0,n-1){
        sum = 0;
        rep(j,0,m-1){
            cin>>a[i][j];
            sum += a[i][j]*b[j];
        }
        if(sum+c>0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
#define int long long
using namespace std;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,d;
	cin>>n>>d;
	d=d*d;
	
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(x*x+y*y<=d)
		{
			++cnt;
		}
	}
	cout<<cnt<<endl;
	
	return 0;
}

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

//prefixSum[i] -> how many bombs affect i-th monster

int N, D, A;
LL prefixSum[MAXN + 3], answer;
pair<int, int> monsters[MAXN + 3];

int main() {
    scanf("%d%d%d", &N, &D, &A);
    for (int i = 1; i <= N; i++) {
        int X, H;
        scanf("%d%d", &X, &H);

        monsters[i] = {X, H};
    }

    sort(monsters + 1, monsters + N + 1);

    memset(prefixSum, 0, sizeof(prefixSum));
    answer = 0;

    for (int i = 1; i <= N; i++) {
        prefixSum[i] += prefixSum[i - 1];
        LL H = (LL) monsters[i].second - prefixSum[i] * A;

        if (H <= 0)
            continue;
        else {
            int cntBomb = H/A + (H%A == 0 ? 0 : 1);

            //find first monster that is not affected by this bomb
            int lo = i, hi = N, mid;
            while (hi >= lo) {
                mid = (lo + hi)/2;
                if (monsters[mid].first - monsters[i].first <= 2 * D)
                    lo = mid + 1;
                else
                    hi = mid - 1;
            }

            prefixSum[i] += cntBomb;
            prefixSum[lo] -= cntBomb;

            answer += cntBomb;
        }
    }

    printf("%lld\n", answer);
}


Measured memory_bytes: 3328
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

int main(){
  int N;
  int K;

  scanf("%d %d", &N, &K);
  int res = (N % K);  
  if(N%K == 0){
    res = 0;
  }else{
    res = 1;
  }


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


Measured memory_bytes: 128
n = int(input())
ans = 0
back = 0
front = 0
either = 0
for i in range(n):
  s = str(input())
  ans += s.count("AB")
  if s[-1] == "A" and s[0] == "B":
    either += 1
  else:
    if s[-1] == "A":
      back += 1
    if s[0] == "B":
      front += 1

if front == back == 0:
  either = max(0, either - 1)
back += either
front += either
print(ans + min(back, front))

Measured memory_bytes: 44008
#include <bits/stdc++.h>
using namespace std;
#define INF 120
int main()
{
	char a[INF],b[INF];
	while(cin>>a){
	int len=strlen(a);
	for(int i=0;i<len-8;i++){
	cout<<a[i];
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <bitset>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    int n;
    cin >> n;
    int a[100010];
    int tmp, b, in;
    cin >> tmp;
    int sum = abs(tmp);
    b = 0;
    REP(i, n - 1){
        cin >> in;
        sum += abs(tmp - in);
        a[i] = abs(b - in) - abs(in - tmp) - abs(b - tmp);
        b = tmp;
        if(i != n - 2) tmp = in;
    }
    sum += abs(in);
    a[n - 1] = abs(tmp) - abs(tmp - in) - abs(in);
    REP(i, n){
        cout << sum + a[i] << endl;
    }
}

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


//vector<vector<int>> z(n,vector<int>(2));
//n番目から数えてm個の文字列をXに置換したい場合はreplace(n,m,X) teWttest
//s1.substr(3,3);
//n番目以降の文字列をm個取り出す、上だとtte

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  rep(i,n)p[i]--;
  vector<int>idx(n);
  rep(i,n)idx[p[i]]=i;
  set <int>s;
  ll ans=0;
  int l1,l2,r1,r2;
  for (int i=n-1;i>=0;i--){
    int x=idx[i];
    {
    s.insert(x);
  

    l1=-1;l2=-1;r1=n;r2=n;
    {
    auto it=s.find(x);
    if (it!=s.begin()){it--;l1=*it;}
    if (it!=s.begin()){it--;l2=*it;}
  }{
    auto it=s.find(x);
    it++;
    if (it!=s.end()){r1=*it;it++;}
    if (it!=s.end()){r2=*it;}
  }
}


    ll c=0;
    int ls1,ls2,rs1,rs2;
    ls1=x-l1;ls2=l1-l2;rs1=r1-x;rs2=r2-r1;

    c=(ll)ls1*rs2+(ll)ls2*rs1;

    ans+=c*(i+1);
  }
  cout<<ans;
}


Measured memory_bytes: 5760
let () =
  Scanf.scanf "%d %d\n"
    (fun n time ->
       let f lst (c, t) = if t <= time then c :: lst else lst in
       Array.init n (fun _ ->
           Scanf.scanf "%d %d\n" (fun cc tt -> (cc, tt)))
       |> Array.fold_left f []
       |> List.fold_left min 2000)
  |> (fun m -> if m = 2000 then "TLE" else string_of_int m)
  |> print_string

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
using namespace std;

int main() {

    string s, t;
    cin >> s >> t;

    int sz = s.size(), answer = 0;

    for(int i = 0; i < sz; ++i) {
        answer += (s[i] != t[i]) ? 1 : 0;
    }

    cout << answer;

    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#define LL long long
const int M=4000005;
const int N=105;
using namespace std;

int n,m,A[N],B[N];
char a[N][N];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("\n");
		A[i]=0;
		for(int j=1;j<=m;j++){
			scanf("%c",&a[i][j]);
			if(a[i][j]=='#')A[i]=B[j]=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(!A[i])continue;
		for(int j=1;j<=m;j++){
			if(B[j])printf("%c",a[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
program zero_or_one_wap
  implicit none
  integer :: n, p(50) = 0, i, m = 0
  read(*,*) n
  read(*,*) p(1:n)
  do i = 1, n
    if (p(i) /= i) m = m+1
  end do
  if (m*(m-2) == 0) then
    write(*,'(a)') "YES"
  else
    write(*,'(a)') "NO"
  end if
  stop
end program zero_or_one_wap

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int n,l,i=0;
  scanf("%d %d",&n,&l);
  char s[n][l+1];
  for(i=0;i<n;i++) scanf("%s",s[i]);
  
  qsort(s,n,l+1,strcmp); 
  for(i=0;i<n;i++) printf("%s",s[i]);
}


Measured memory_bytes: 252
#include <stdlib.h>  
#include <stdio.h>
                                  
typedef struct node {     
  int k;                
  struct node *p;
  struct node *l;
  struct node *r;           
} node;  
                                            
static node *build_node(int k) {
  node *n;              
  n = (node *) malloc(sizeof(node));
  n->p = n->l = n->r = NULL;                     
  n->k = k;               
  return n;                                                   
}                                      
                                
static void insert_node(node *r, node *n) {
  if (n->k <= r->k) { 
    if (r->l == NULL) {
      r->l = n;                        
      n->p = r;                         
    } else {  
      insert_node(r->l, n);
    }         
  } else {                  
    if (r->r == NULL) {
      r->r = n;
      n->p = r;
    } else {
      insert_node(r->r, n);                
    }
  }
}

static node *find_node(node *n, int k) {
  node *ret;
  if (n == NULL) {
    ret = NULL;
  } else if (k == n->k) {
    ret = n;
  } else if (n->l != NULL && k < n->k) {
    ret = find_node(n->l, k);
  } else if (n->r != NULL && k > n->k) {
    ret = find_node(n->r, k);
  } else {
    ret = NULL;
  }
  return ret;
}

static node *find_successor(node *n) {
  node *p;

  if (n->r != NULL) {
    n = n->r;
    while (n->l != NULL) n = n->l;
    return n;
  }

  p = n->p;
  while (p != NULL && n == p->r) {
    n = p;
    p = p->p;
  }
  return p;
}

static node *delete_node(node *r, node *n) {
  node *dn;
  node *cn;
  node *rn;

  if (n == NULL) return r;
  dn = (n->l == NULL || n->r == NULL) ? n : find_successor(n);
  cn = (dn->l != NULL) ? dn->l : dn->r;
  if (cn != NULL) cn->p = dn->p;
  rn = r;
  if (dn->p == NULL) {
    rn = cn;
  } else if (dn == dn->p->l) {
    dn->p->l = cn;
  } else {
    dn->p->r = cn;
  }
  if (dn != n) n->k = dn->k;
  free(dn); dn = NULL;

  return rn;
}

static void print_inorder(node *n) {
  if (n->l != NULL) print_inorder(n->l);
  printf(" %d", n->k);
  if (n->r != NULL) print_inorder(n->r);
}

static void print_preorder(node *n) {
  printf(" %d", n->k);
  if (n->l != NULL) print_preorder(n->l);
  if (n->r != NULL) print_preorder(n->r);
}

static void free_node(node *n) {
  if (n == NULL) return;
  free_node(n->l);
  free_node(n->r);
  free(n);
}

int main(int argc, char **argv) {
  int m, i, k;
  char cmd[8];
  node *r = NULL;
  node *n;

  scanf("%d", &m);
  for (i = 0; i < m; ++i) {
    scanf("%s", cmd);
    switch (cmd[0]) {
      case 'i':
        scanf("%d", &k);
        n = build_node(k);
        if (r == NULL) {
          r = n;
        } else {
          insert_node(r, n);
        }
        break;
      case 'f':
        scanf("%d", &k);
        n = find_node(r, k);
        printf("%s\n", n == NULL ? "no" : "yes");
        break;
      case 'd':
        scanf("%d", &k);
        n = find_node(r, k);
        r = delete_node(r, n);
        break;
      case 'p':
        print_inorder(r); printf("\n");
        print_preorder(r); printf("\n");
        break;
      default:
        break;
    }
  }
  free_node(r);
  exit(0);
}


Measured memory_bytes: 20476
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int X = sc.nextInt();

		int intArray[] = new int[N];
		for (int i = 0; i < N;i ++ ){
			intArray[i] = sc.nextInt();
		}

		int sum = 0;
		int cnt = 0;
		if(sum < X){
			cnt ++;
		}else{
			System.out.println(cnt);
	   		sc.close();
	        return ;
		}

		for (int i = 0; i < N;i ++ ){
			sum = sum + intArray[i];
			if(sum <= X){
				cnt ++;
			}else{
				break ;
			}
		}

		System.out.println(cnt);

   		sc.close();
        return ;

    }
    
}



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

using namespace std;
int cnt = 0;

void insertionSort(vector<int>& A, int g)
{
	for (int i = g; i < A.size(); ++i)
	{
		if (A[i - g] > A[i])
		{
			int v = A[i];
			int j = i - g;
			while (j >= 0 && A[j] > v)
			{
				A[j + g] = A[j];
				j -= g;
				++cnt;
			}
			A[j + g] = v;
		}
	}
}

void solve()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	cnt = 0;
	vector<int> G;
	int h = 1;
	while (N >= h)
	{
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1; i >= 0; --i)
	{
		insertionSort(A, G[i]);
	}
	cout << G.size() << endl;
	for (int i = G.size() - 1; i > 0; --i)
	{
		cout << G[i] << " ";
	}
	cout << G[0] << endl;
	cout << cnt << endl;
	for (int i = 0; i < A.size(); ++i)
	{
		cout << A[i] << endl;
	}
}

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

Measured memory_bytes: 4896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n), f(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> f[i];
    }
    sort(all(a));
    sort(all(f)); reverse(all(f));


    ll ng = -1;
    ll ok = 1e13+5;

    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        ll required = 0;
        for(int i = 0; i < n; i++){
            if(a[i]*f[i] > mid){
                required += a[i] - (mid/f[i]);
            }
        }
        if (required<=k) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;

}


Measured memory_bytes: 3328
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
e = [0 for _ in range(n)]
for i in range(n):
    if d[i][0] == d[i][1]:
        e[i] = 1
f = [0 for _ in range(n)]
for i in range(2, n):
    f[i] = e[i]*e[i-1]*e[i-2]
if sum(f) > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62512
n = int(input())
H = list(map(int, input().split()))

ans = 0
cnt = 0
bh = H[0]
for i in range(1, n):
    if H[i] <= bh:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
    bh = H[i]
else:
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {
	static int p[][];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		while(!IsPrime(x)) {
			x++;
		}

		System.out.println(x);

        return;
    }

	static boolean IsPrime(int n) {
		if (n == 2) return true;
		else if (n%2 == 0) return false;
		double sqrtNum = Math.sqrt(n);
		for (int i=3; i<=sqrtNum; i+=2) {
			if (n%i == 0) {return false;}
		}
		return true;
	}

}



Measured memory_bytes: 25044
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar(); }
	do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
	return x * f;
}

typedef long long ll;
const int MAXN = 500001;
const int mod = 998244353;

int n,m;
ll fac[MAXN],ifac[MAXN];
ll pown[MAXN],powm[MAXN];

ll C(int n,int m) {
	return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main() {
	n = read(), m = read();
	fac[0] = 1;
	for(int i = 1;i <= n || i <= m;i++) fac[i] = (fac[i - 1] * i) % mod;
	ifac[0] = ifac[1] = 1;
	for(int i = 2;i <= n || i <= m;i++) ifac[i] = ((mod - mod / i) * ifac[mod % i]) % mod;
	for(int i = 2;i <= n || i <= m;i++) ifac[i] = (ifac[i - 1] * ifac[i]) % mod;
	pown[0] = powm[0] = 1;
	for(int i = 1;i <= m;i++) pown[i] = (pown[i - 1] * (n + 1)) % mod;
	for(int i = 1;i <= n;i++) powm[i] = (powm[i - 1] * (m + 1)) % mod;
	ll ans = 0;
	for (int i = 0;i <= n && i <= m;i++) {
		ll res = (C(n,i) * C(m,i)) % mod;
		res = res * fac[i] % mod;
		res = res * pown[m - i] % mod;
		res = res * powm[n - i] % mod;
		if(i & 1) ans = (ans + mod - res) % mod;
		else ans = (ans + res) % mod;
	}
	std::printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 19392
N = int(input())
S = input()

bc = [0]*(N+1)

c = 0
for i,s in enumerate(S):
	if s == '#':
		c += 1
	bc[i+1] = c
abc = bc[-1]

t = [abc-x for x in bc]

ans = N
k = N
for b in bc:
	nb = k - abc + b
	ans = min(ans,nb+b)
	k = k-1
print(ans)


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

int lcs(string x, string y)
{
    int m = x.length();
    int n = y.length();
    int array[m + 1][n + 1];
    for (int i = 0; i <= m; i++)
    {
        array[i][0] = 0;
    }
    for (int i = 0; i <= n; i++)
    {
        array[0][i] = 0;
    }
    int lcsValue = 0;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (x[i - 1] == y[j - 1])
            {
                array[i][j] = array[i - 1][j - 1] + 1;
                lcsValue = max(lcsValue, array[i][j]);
            }
            else if (array[i - 1][j] >= array[i][j - 1])
            {
                array[i][j] = array[i - 1][j];
            }
            else
            {
                array[i][j] = array[i][j - 1];
            }
        }
    }
    return lcsValue;
}

int main()
{
    int num;
    cin >> num;
    for (int i = 0; i < num; i++)
    {
        string x;
        string y;
        cin >> x >> y;
        int ans = lcs(x, y);
        cout << ans << endl;
    }
}


Measured memory_bytes: 7104
#include <stdio.h>

int getblock(char[8][9],int,int);

int main(void) {
	char heimen[8][9];
	int x,y;
	while(1) {
		if(scanf("%s",heimen[0])==-1)break;
		for(y=1;y<8;y++)scanf("%s",heimen[y]);
		for(y=0;y<8;y++) {
			for(x=0;x<8;x++) {
				if(getblock(heimen,x,y)) {
					if(getblock(heimen,x+1,y) &&
						getblock(heimen,x,y+1) &&
						getblock(heimen,x+1,y+1))printf("A\n");
					else if(getblock(heimen,x,y+1) &&
						getblock(heimen,x,y+2) &&
						getblock(heimen,x,y+3))printf("B\n");
					else if(getblock(heimen,x+1,y) &&
						getblock(heimen,x+2,y) &&
						getblock(heimen,x+3,y))printf("C\n");
					else if(getblock(heimen,x,y+1) &&
						getblock(heimen,x-1,y+1) &&
						getblock(heimen,x-1,y+2))printf("D\n");
					else if(getblock(heimen,x+1,y) &&
						getblock(heimen,x+1,y+1) &&
						getblock(heimen,x+2,y+1))printf("E\n");
					else if(getblock(heimen,x,y+1) &&
						getblock(heimen,x+1,y+1) &&
						getblock(heimen,x+1,y+2))printf("F\n");
					else if(getblock(heimen,x+1,y) &&
						getblock(heimen,x,y+1) &&
						getblock(heimen,x-1,y+1))printf("G\n");
					y=8;break;
				}
			}
		}
	}
	return 0;
}

int getblock(char heimen[8][9],int x,int y) {
	if(x<0 || x>=8 || y<0 || y>=8)return 0;
	if(heimen[y][x]=='1')return 1; else return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define printclock cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n";
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define deb1(x) cout << #x << ": " << x << endl
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define prec(n) fixed << setprecision(n)
#define all(a) a.begin(), a.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define pii pair<int, int>
#define vii vector<int>
#define ld long double
#define int long long
#define MOD LLONG_MAX
#define mp make_pair
#define pb push_back
#define endl "\n";
inline void get(vector<int> &arr, int n)
{
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        arr.push_back(a);
    }
}
inline void print(vector<int> &arr, int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}
/*----------------------------------TEMPLATE------------------------------------*/
int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    fast;
    /*----------------------------PEEPEEPOOPOO-------------------------------------*/
    int t;
    //cin >> t;
    t=1;
    while (t--)
    {
        int n;
        cin >> n;
        int count = 0;
        vector<int> dp(2001,0);
        dp[0] = 1;
        dp[1] = 0;
        dp[2] = 0;
        int mod = 1e9 + 7;
        rep(i,3,n+1)
        {
            rep(j,3,i+1)
            {
                dp[i]=(dp[i]%mod+ dp[i-j]%mod)%mod;
            }
        }
        cout << dp[n]%mod << endl;
    }
    return 0;
}
/*--------------------------------PEEPEEPOOPOO-------------------------------------*/

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAXLEN 104
#define LL long long

void solve(char *str, int len, LL K) {
    int i;
    for(i = 0; i < len; ++i) {
        if(str[i] != '1') { break; }
        if(i >= K-1) { break; }
    }
    printf("%c\n", str[i]);
} 

int main()
{
    char *str = (char*)malloc(MAXLEN * sizeof(char));
    LL k;
    scanf("%s", str);
    scanf("%lld", &k);
    int len = strlen(str);
    //printf("k = %lld\n", k);
    solve(str, len, k);
    return 0;
}

Measured memory_bytes: 128
import java.util.*

private class UnionFind(n: Int) {
    private val rank = IntArray(n) { 0 }
    private val parent = IntArray(n) { -1 }

    fun find(x: Int): Int {
        if (parent[x] < 0) {
            return x
        }
        parent[x] = find(parent[x])
        return parent[x]
    }

    fun unite(x: Int, y: Int) {
        val x1 = find(x)
        val y1 = find(y)
        if (x1 == y1) {
            return
        }
        if (rank[x1] < rank[y1]) {
            parent[y1] += parent[x1]
            parent[x1] = y1
        } else {
            parent[x1] += parent[y1]
            parent[y1] = x1
            if (rank[x1] == rank[y1]) {
                rank[x1]++
            }
        }
    }

    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    fun size(x: Int): Int {
        return -parent[find(x)]
    }
}

fun main(args: Array<String>) {
    val (n, m, k) = readLine()!!.split(' ').map { it.toInt() }
    val uf = UnionFind(n)
    val friends = Array(n) { 0 }
    for (i in 0 until m) {
        var (a, b) = readLine()!!.split(' ').map { it.toInt() }
        a--
        b--
        uf.unite(a, b)
        friends[a]++
        friends[b]++
    }
    val ans = Array(n) { 0 }
    for (i in 0 until n) {
        ans[i] = uf.size(i) - friends[i] - 1
    }
    for (i in 0 until k) {
        var (c, d) = readLine()!!.split(' ').map { it.toInt() }
        c--
        d--
        if (uf.same(c, d)) {
            ans[c]--
            ans[d]--
        }
    }
    println(ans.joinToString(" "))
}

Measured memory_bytes: 77464