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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1<<30)

int main() {
	ll N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	ll res =0;
	for (ll d = 60; d >= -1; d--) {
		// d桁目について、Kが１でなければcontinue
		if(d != -1 && !(K & (1LL<<d))) continue;

		ll tmp=0;
		for (ll e = 60; e >= 0; e--) {
			// mask : e番目のビットだけ立たせたもの
			ll mask = 1LL<<e;
			// num : 1が立っている数
			ll num=0;
			for(ll i=0; i<N; i++)
				if(A[i] & mask) num++;

			// dより上位の桁はKと合わせる
			if (e > d) {
				// Kの e 桁目が１なら１、０なら０
				if(K & mask) tmp += mask * (N-num);
				else tmp += mask * num;
			}
			// d桁目は０とする
			else if (e == d) {
				tmp += mask * num;
			}
			// dより下位の桁については、Greedy
			else {
				// 多い方に合わせる
				tmp += mask * max(num, N-num);
			}
		}
		res = max(res, tmp);
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


    public static void main(String args[] ) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String Origin = br.readLine();
        String Serch = br.readLine();

        String[] origin = Origin.split("");
        String[] serch = Serch.split("");
        int plusi = PlusI(serch);

        int Origin_length = origin.length;
       // System.out.println( SameString(serch) );
        for(int i = 0 ; i < origin.length; ){


           int equal_point = Origin.indexOf(Serch , i);

           if(equal_point>-1){
        	   System.out.println(equal_point);
        	   i = equal_point+1;
           }
           else{
        	    i += plusi;
           }

        }


    }


    public static int PlusI(  String[] Serch ){


    	for(int j = 0; j < Serch.length; j++ ){

    	    if( Serch[j].equals(Serch[0]) && 0 < j){
    	    	return j;
    	    }

    	}


        return Serch.length;


    }


    public static boolean SearchWord(String[] Origin , String[] Serch , int i){


    	boolean SerchCheck = false;
    	for(int j = i , k = 0; k < Serch.length; j++ , k++){

    	    if( Serch[k].equals(Origin[j]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }


    public static boolean SameString(String[] Serch ){


    	boolean SerchCheck = false;
    	for(int i = 0 ; i < Serch.length; i++){

    	    if( Serch[0].equals(Serch[i]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }



}

Measured memory_bytes: 24972
import java.util.Scanner;

public class Main {

	static int n, a[] = new int[3], l[];

	public static int solve(int cur, int c, int d, int e) {
		if (cur == n) {
			int tmp = 0;
			int b[] = new int[3];
			b[0] = c;
			b[1] = d;
			b[2] = e;
			int min = c;
			for (int i = 0; i < 3; ++i) {
				min = Math.min(min, b[i]);
			}
			if (min <= 0)
				return 1000000000;
			for (int i = 0; i < 3; ++i)
				tmp += Math.abs(b[i] - a[i]);
			tmp -= 30;
			return tmp;
		}
		int ans[] = new int[4];
		ans[0] = solve(cur + 1, c, d, e);
		ans[1] = solve(cur + 1, c + l[cur], d, e) + 10;
		ans[2] = solve(cur + 1, c, d + l[cur], e) + 10;
		ans[3] = solve(cur + 1, c, d, e + l[cur]) + 10;
		int min = ans[0];
		for(int i = 0; i < 4; ++i) {
			min = Math.min(min,  ans[i]);
		}
		return min;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for (int i = 0; i < 3; ++i)
			a[i] = sc.nextInt();
		l = new int[n];
		for (int i = 0; i < n; ++i) {
			l[i] = sc.nextInt();
		}
		sc.close();
		int ans = solve(0, 0, 0, 0);
		System.out.println(ans);
	}

}


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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    int mini = 1000;
    for (int i=0; i<N; i++) {
        cin >> m.at(i);
        X -= m.at(i);
        mini = min(mini, m.at(i));
    }
    int num = X / mini;
    cout << N + num << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        a: i64,
        b: i64,
        k: i64,
    );

    let mut a = a;
    let mut b = b;

    if k <= a {
        a -= k;
    }
    else if k - a <= b {
        b -= k - a;
        a = 0;
    }
    else {
        a = 0;
        b = 0;
    }

    println!("{} {}", a, b);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s,s1;
vi v;
 
void solve(){
	cin >> s >> s1;
	int sLen= s.length(),s1Len=s1.length();
	int mn = 1e9;
	for(int i =0;i<=sLen-s1Len;i++){
		int cnt = 0;
		for(int j=0;j<s1Len;j++){
			if(s1[j]!=s[j+i])cnt++;
		}
		mn = min(cnt,mn);
	} 	
	cout << mn;
}
 
int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int a,b,c,sum=3;
int main(){
	cin>>a>>b>>c;
	if(a==b){
		sum--;
	}
	if(b==c){
		sum--;
	}
	if(c==a){
		sum--;
	}
	if(a==b&&b==c){
		cout<<1;
		return 0;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF=1001001001001001001;
// Combination Table

ll C[51][51]; // C[n][k] -> nCk



void comb_table(int N){
    for(int i=0;i<=N;++i){
        for(int j=0;j<=i;++j){
            if(j==0 or j==i){
            C[i][j]=1LL;
          }
          else{
            C[i][j]=(C[i-1][j-1]+C[i-1][j]);
          }
        }
      }
    }





int main() {
  ll n,a,b;
  cin>>n>>a>>b;
  vector<double> v(n);
  rep(i,n)cin>>v[i];
  sort(v.rbegin(),v.rend());
  ll first=v[0];
  ll last=v[a-1];
  ll idr=a-1;
  ll idl=a-1;


  while(v[idr]==last)idr++;
  while(v[idl]==last)idl--;

  ll lenr=idr-a;
  ll lenl=a-idl-1;
  //cout<<lenr<<" "<<lenl<<endl;

  double sumall=0;
  rep(i,a)sumall+=v[i];
  comb_table(51);

  //sumall/=a;
  ll cnow=C[lenr+lenl][lenl];



  if (last!=first){
//  cout<<lenl<<" "<<lenr<<endl;
      cout<<fixed<<setprecision(8)<<double(sumall/a)<<endl;
    //  cout<<precision(20);
  //  cout<<lenr<<" "<<lenl<<endl;
    //  cout<<C[1][1]<<' '<<C[2][1]<<endl;
    cout<<C[lenl+lenr][lenl];
    return 0;
  }
  else{
    ll ans=0;
    ll now=min(b,a+lenr+2);
    //cout<<lenr<<"lenr"<<lenl<<"lenl"<<endl;
    ll N=lenr+lenl;
  //  cout<<N<<endl;
    for(ll i=a;i<=min(b,lenr+lenl);i++){
    //  ll temp=comb(lenr+lenl,i+1);
      ans+=C[N][i];
  //    cout<<C[N][i]<<'i'<<i<<endl;
    }
    cout<<fixed<<setprecision(8)<<double(sumall/a)<<endl;

    cout<<ans;

  }
//  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;
using uset = unordered_set<int>;

int main(){
    int A,N,M;
    cin >> A >> N >> M;
    int y = 1;
    int ans = 0;
    while(y <= M) {
        int a = y + A;
        int m = 1;
        for(int i = 0 ;i < N; i++) m *= a;
        if(m > M) break;

        int b = m;
        int sum = 0;
        while(b){
            sum += b % 10;
            b /= 10;
        }
        if(m <= M && sum == y) ans++;
        y++;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3116
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n>=m:
  n=m
if m==1:
  print(0)
else:
  x.sort()
  ans=x[m-1]-x[0]
  l=[]
  for i in range(m-1):
    l.append(x[i+1]-x[i])
  l.sort(reverse=1)
  for i in range(n-1):
    ans-=l[i]
  print(ans)

Measured memory_bytes: 13968
def f(N, L):
    if L > 0:
        return (N - 1) * (N + L * 2) // 2
    elif 1 - L > N:
        return (N - 1) * (N + L * 2 - 2) // 2
    else:
        return N * (N - 1 + 2 * L) // 2


N, L = map(int, input().split())
print(f(N, L))

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static int dfs(int total, int addv, int target, int n){ return n == 0 ? total == target ? 1 : 0 : addv > 9 ? 0 : dfs(total + addv, addv + 1, target, n - 1) + dfs(total, addv + 1, target, n); }
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(true){ int n = sc.nextInt(), s = sc.nextInt(); if(n == 0 && s == 0) break; System.out.println(dfs(0, 0, s, n)); }
		}
	}
}

Measured memory_bytes: 26012
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[109],num=0;;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i+=2)
        if(a[i]%2)
        num++;
    cout<<num;
    return 0;
}


Measured memory_bytes: 3492
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int N, M, C;
  int b[22];

  cin >> N >> M >> C;

  rep(i, 0, M) cin >> b[i];

  int ans = 0;

  rep(i, 0, N) {
    int sum = 0;
    rep(j, 0, M) {
      int a; cin >> a;
      sum += a * b[j];
    }
    if (sum + C > 0) ++ans;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int h, w, n;
Int r, c;

vector<int> bit1(108000, 0), bit0(108000, 0);
vector<P> wall;
void add(vector<int> &bit, int ind, int val){
  ind++;
  while(ind < bit.size()){
    bit[ind] += val;
    bit[ind] %= MOD;
    ind += ind & -ind;
  }
}

Int sum(vector<int> &bit, int ind){
  ind++;
  Int res = 0;
  while(ind){
    res += bit[ind];
    ind -= ind & -ind;
    res %= MOD;
  }
  return res;
}

Int fact[216000], invfact[216000];
Int dp[3000][2];

Int mod_pow(Int x, Int a, Int m = MOD){
  if(a == 0)return 1;
  Int res = mod_pow(x, a / 2, m);
  res = res * res % m;
  if(a % 2)res *= x;
  return res % m;
}

Int inv(Int x){
  return mod_pow(x, MOD-2);

}
Int nCk(Int n, Int k){
  if(n < k)return 0;
  return fact[n] * invfact[k] % MOD * invfact[n-k] % MOD;
}
	
int main(){
  fact[0] = 1;
  invfact[0] = 1;
  for(int i = 1;i < 216000;i++){
    fact[i] = fact[i-1] * i % MOD;
    invfact[i] = inv(fact[i]);
  }
  cin >> h >> w >> n;
  for(int i = 0;i < n;i++){
    cin >>r >> c;
    wall.push_back(P(r, c));
  }
  Int res = nCk(h+w-2, h-1);
  sort(wall.begin(), wall.end());
  for(int i = 0;i < n;i++){
    dp[i][1] = nCk(wall[i].first + wall[i].second - 2, wall[i].first - 1);
    for(int j = 0;j < i;j++){
      if(wall[j].second > wall[i].second)continue;
      dp[i][0] += dp[j][1] * nCk(wall[i].first + wall[i].second - wall[j].first - wall[j].second, wall[i].first - wall[j].first) % MOD;
      dp[i][0] %= MOD;
      
      dp[i][1] += dp[j][0] * nCk(wall[i].first + wall[i].second - wall[j].first - wall[j].second, wall[i].first - wall[j].first) % MOD;
      dp[i][1] %= MOD;
    }
    res += dp[i][0] * nCk(h + w - wall[i].first - wall[i].second, h - wall[i].first) % MOD;res %= MOD;
    res -= dp[i][1] * nCk(h + w - wall[i].first - wall[i].second, h - wall[i].first) % MOD;res %= MOD;
  }
  if(res < 0)res += MOD;
  cout << res << endl;
  return 0;
}


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

int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
}


Measured memory_bytes: 256
n = int(raw_input())
matrix = []
for i in range(n):
    a = map(int, raw_input().split())
    matrix.append([a[0], a[1]])

m = [[0 for i in range(n+1)] for j in range(n+1)]
p = [0 for i in range(n+1)]
p[0] = matrix[0][0]
for i in range(n):
    p[i+1] = matrix[i][1]

for l in range(2, n+1):
    for i in range(1, n-l+2):
        j = i + l - 1
        m[i][j] = 10**19
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j])

print m[1][n]

Measured memory_bytes: 6500
from itertools import combinations

n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

l = set(sum(t) for i in range(n) for t in combinations(A, i+1))

for j in m:
    print('yes' if j in l else 'no')
        

Measured memory_bytes: 7764
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

ll mod=1e9+7;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int> (n));
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
    int maxn=1<<n;
    vector<ll> dp(maxn,0);
    dp[maxn-1]=1;
    for(int i=maxn-2;i>=0;i--){
        int cur=i;
        //get the current person by counting the number of already assigned bits
        int mn=0;
        while(cur!=0){
            mn+=(cur&1);
            cur=cur>>1;
        }
        //debug(mn);
        for(int k=0;k<n;k++){
            if(a[mn][k] && !(i&(1<<k))){
                dp[i]+=dp[i|(1<<k)];
                dp[i]%=mod;
            }
        }
    }
    cout<<dp[0]<<"\n";
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) { 
    ll N;cin>>N;
    ll r = 1;
    string ans  = "";
    int pos = 0;
    for (int i = 0; i <= 40; i++) {
        if (N % (r*2) != 0){
            ans += '1';
            N -= ((i % 2) ? -r : r);
            pos = i;
        } else{
            ans += '0';
        }
        r *= 2;
    }
    for(int i = pos; i >= 0; i--) {
        cout << ans[i];
    }
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long l, r;
    scan(l, r);
    if(r - l >= 2019)
    {
        writeln(0);
        return;
    }

    long minmod = 2019;
    foreach(i; l .. r)
    {
        foreach(j; i + 1 .. r + 1)
        {
            auto mod = (i * j) % 2019;
            minmod = min(mod, minmod);
        }
    }
    minmod.writeln();
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

map<ll, ll> primefact(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

ll A, B, C;

int main() {
    cin >> A >> B >> C;
    if(A == B && B == C) {
        if(A % 2) {
            cout << 0 << "\n";
        } else {
            cout << -1 << "\n";
        }
        return 0;
    }
    auto Af = primefact(A);
    auto Bf = primefact(B);
    auto Cf = primefact(C);
    if(Af[2] == Bf[2] && Bf[2] == Cf[2]) {
        cout << Af[2] + 1 << "\n";
    } else {
        cout << min(Af[2], min(Bf[2], Cf[2])) << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
/*input
2
157 193
*/

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>




#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pdd pair<double, double>
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define forstl(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.f<<" , "<<it.s<<endl;} cerr<<endl
#define PI           3.14159265358979323846

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define pdd pair<double, double>
#define in(v,n) vll v(n);rep(i,n) cin>>v[i]


using namespace std;


int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;
	// cout<<std::fixed<<std::setprecision(35);
	// cin>>T;while(T--)
	{
		ll t,n,i,j,x,y,m,l,d,k;
		cin>>n;
		ll arr[n];
		rep(i,n) cin>>arr[i];
		vll v;
		ll in=0,money=1000,st;
		for(int i=0;i<n;){
			while(i<n&&arr[i+1]<=arr[i]) i++;
			if(i==n) break;
			v.pb(arr[i]);
			i++;
			while(i<n&&arr[i+1]>=arr[i]) i++;
			if(i==n) break;
			v.pb(arr[i]);
			i++;
		}
		v.pb(arr[n-1]);
		rep(i,v.size()){
			if(i%2==0){
				st=money/v[i];
				money=money-st*v[i];
			}
			else{
				money+=st*v[i];
				st=0;
			}
			// dbg(money);
			// dbg(st);
			// dbg(v[i]);
		}
		cout<<money+v.back()*st<<endl;

	}
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=998244353;
int f[500010],n,d[500010],fa[500010],tmp[500010],ts;
LL ANS,ans[500010],p2[500010];
char s[500010];

int getf(int x){
	if (fa[x]==x) return x;
	int t=fa[x];
	fa[t]=getf(t);
	d[x]^=d[t];
	fa[x]=fa[t];
	return fa[x];
}
int main(){
	p2[0]=1;
	FOR(i,1,500000) p2[i]=p2[i-1]*2%MO;
	cin>>n;
	scanf("%s",s+1);
	FOR(i,1,n*2) if ((n*2)%i==0 && n%i!=0) tmp[++ts]=i;
	FOR(o,1,ts){
		int h=tmp[o];
		int fre=h;
		FOR(i,0,h-1) fa[i]=i,d[i]=0,f[i]=-1;
		int ok=1;
		FOR(O,1,n){
			int i=O%h,j=(O+n)%h;
			int X=getf(i),Y=getf(j);
			if (X==Y){
					if (d[i]==d[j]){ok=0;break;}
				}
				else{
					fa[X]=Y;
					d[X]=d[i]^d[j]^1;
					--fre;
				}
		}
		if (!ok) continue;
		FOR(i,1,n){//di i wei qiahao bi ta xiao
			if (s[i]=='1'){
				int X=getf(i%h);
				if (f[X]==-1){(ans[o]+=p2[fre-1])%=MO;}
				else if (f[X]==d[i%h]){(ans[o]+=p2[fre])%=MO;}
			}
			int X=getf(i%h);
			if (f[X]==-1) f[X]=(s[i]-'0')^d[i%h],--fre;
			else if (f[X]!=(s[i]-'0')^d[i%h]) break;
			if (i==n) (ans[o]+=p2[fre])%=MO;
		}
	}
	FOR(i,1,ts)
		FOR(j,1,i-1)
			if (tmp[i]%tmp[j]==0) (ans[i]-=ans[j])%=MO;
	FOR(i,1,ts) (ANS+=ans[i]*tmp[i])%=MO;
	ANS=(ANS%MO+MO)%MO;
	cout<<ANS<<endl;
	return 0;
}

Measured memory_bytes: 13568
#include <cstdio>
#include <queue>
using namespace std;

int main()
{
	int i;
	double temp,res;
	priority_queue<double> pq;
	for (i = 1; scanf("%lf",&temp) != EOF;i++) {
		pq.push(temp);
	}
	res = pq.top();
	for (int j = 0; j < i - 1; j++)pq.pop();
	res -= pq.top();
	printf("%lf",res);
	return 0;
}

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

int main(){
    long long a,b;
    cin >> a >> b;
    int ans = 0;
    string rev;
    for (int i = a; i < b+1; i++){
        if (i%10 == i/10000 && (i/10)%10 == (i/1000)%10){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
int ans[100005];
int b[13]={0,1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int main(){
   int n,k;
   cin>>n;
   for(int i=1;i<=n;i++)ans[i]=INF;
 
	for(int j=12;j>=1;j--)
	  {
	  	  for(int i=b[j];i<=n;i++)
	  	   ans[i]=min(ans[i],ans[i-b[j]]+1);
	  }
    cout<<ans[n];
   
  return 0;
}

Measured memory_bytes: 640
#D問題
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))

B = []
for a in A:
    heapq.heappush(B,-a)

for j in range(M):
    b = -heapq.heappop(B)
    b = b//2
    heapq.heappush(B,-b)
    
print(-sum(B))

Measured memory_bytes: 14184
n,w=map(int,input().split()) 
wt=[] 
val=[] 
for i in range(n):
	x,y=map(int,input().split()) 
	val.append(y) 
	wt.append(x) 
dp=[[0 for j in range(w+1)] for i in range(n+1)] 
for i in range(n+1):
	for j in range(w+1):
		if i==0 or j==0:
			dp[i][j]=0 
		elif j>=wt[i-1]:
			dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]) 
		else:
			dp[i][j]=dp[i-1][j] 
print(dp[-1][-1])


Measured memory_bytes: 217808
#include<bits/stdc++.h>
using namespace std;
#define INS(x) (x).begin(),(x).end()
#define gcd(x,y) __gcd((x),(y))

int a[100005];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;

    for (int i=1;i<=m;i++)
    {
        cin>>a[i];
        n-=a[i];
    }

    if (n>=0) cout<<n<<'\n';
    else cout<<"-1\n";
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
class Main{
    static final int INF = 2000000000;
    int N, diff;
    int[] A;
    Scanner sc;

    void update(int i, int v){
        int d1 = 0, d2 = 0;
        if ( A[i-1] > A[i] ) d1++;
        if ( A[i] > A[i+1] ) d1++;
        A[i] = v;
        if ( A[i-1] > A[i] ) d2++;
        if ( A[i] > A[i+1] ) d2++;
        diff += (d2 - d1);
    }

    void activate(){
        sc = new Scanner(System.in);
        N = sc.nextInt();
        A = new int[N+2];
        for ( int i = 1; i <= N; i++ ) A[i] = sc.nextInt();
        A[0] = -INF;
        A[N+1] = INF;
        System.out.println(solve());
    }
    
    
    int solve(){
        int a, b, q, v1, v2;
        diff = 0;
        for ( int i = 1; i <= N; i++ ) {
            if ( A[i-1] > A[i] ) diff++;
        }
        if ( diff == 0 ) return 0;
        q = sc.nextInt();
        for ( int i = 1; i <= q; i++ ){
            a = sc.nextInt();
            b = sc.nextInt();
            v1 = A[a];
            v2 = A[b];
            update(a, v2);
            update(b, v1);
            if ( diff == 0 ) return i;
        }

        return -1;
    }

    public static void main(String[] args){ new Main().activate(); }
}



Measured memory_bytes: 202304
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int a, b;
    cin >> a >> b;
    if((a * b) % 2 != 0) cout << "Odd" << endl;
    else cout << "Even" << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n+1);
    rep(i,n) cin >> h[i];
    h[n] = 1001001001;
    int ans = 0;
    int cur = 0;
    int ct = 0;
    while (cur < n) {
        rep(i,n-cur) {
            if (h[cur+i] >= h[cur+i+1]) {
                ct++;
                continue;
            }
            else {
                cur += i + 1;
                ans = max(ans,ct);
                ct = 0;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
memo = [dict() for _ in range(n+1)]

memo[0][""] = 1

def ok(last4):
  for ng in ["AGC","ACG","GAC"]:
    if last4.find(ng)>=0:
      return False
  if len(last4) < 4:
    return True
  if last4[0] =="A" and last4[2:]=="GC":
    return False
  if last4[:2]=="AG" and last4[3]== "C":
    return False
  return True

for i in range(1,n+1):
  for last3, v in memo[i-1].items():
    for c in "ATGC":
      if ok(last3+c):
        try:
          memo[i][last3[-2:]+c] += v
        except KeyError:
          memo[i][last3[-2:]+c] = v

MOD = int(10**9+7)
ans = 0
for v in memo[n].values():
  ans += v

print(ans%MOD)


Measured memory_bytes: 3820
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s= sc.next();
		int count = 0;
		for (int i=1;i<s.length()-1;i++) {
			String s1=s.substring(0,i);
			String s2= s.substring(i,s.length());
			int array1[]= new int[26];
			int array2[]= new int[26];
			for (int j=0;j<s1.length();j++) {
				array1[s1.charAt(j)-'a']++;
			}
			for (int j=0;j<s2.length();j++) {
				array2[s2.charAt(j)-'a']++;
			}
			int temp =0;
			for (int j=0;j<26;j++) {
				if (array1[j]>0&&array2[j]>0) {
					temp++;
				}
			}
			if (temp>count) {
				count =temp;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
double dist(double x1, double y1, double x2, double y2)
{
	double one = x2 - x1;
	double two = y2 - y1;
	return sqrt(one * one + two * two);
}
int main()
{
	int a;
	cin >> a;
	pair<double, double> arr[a + 50];
	for(int i=0; i<a; i++)
		cin >> arr[i].first >> arr[i].second;
	vector<int> V;
	for(int i=0; i<a; i++)
		V.push_back(i);
	double sum = 0;
	do
	{
		double temp = 0.0;
		for(int i=1; i<V.size(); i++)
		{
			temp += dist(arr[V[i - 1]].first, arr[V[i - 1]].second, arr[V[i]].first, arr[V[i]].second);
		}
		sum += temp;
	} while(next_permutation(V.begin(), V.end()));
	double temp = 1;
	for(int i=1; i<=a; i++)
		temp *= (double)i * 1.0;
	double ans = sum / temp;
	printf("%.10lf", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9 + 7;

int main() {
  int n; cin >> n;
  vector<pair<int, int>> a;
  pair<int, int> p;
  rep(i, n) {
    int t; cin >> t;
    p.first = t;
    p.second = 0;
    a.push_back(p);
  }
  rep(i, n) {
    int t; cin >> t;
    p.first = t;
    p.second = 1;
    a.push_back(p);
  }

  sort(all(a));

  LL ans = 1;
  stack<int> x, y;
  rep(i, 2 * n) {
    if (a[i].second == 0) {
      if (y.empty()) {
        x.push(a[i].first);
      } else {
        ans *= y.size();
        ans %= mod;
        y.pop();
      }
    } else {
      if (x.empty()) {
        y.push(a[i].first);
      } else {
        ans *= x.size();
        ans %= mod;
        x.pop();
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <math.h>

void swap(long long *a, long long *b)
{
    *a = *a ^ *b;
    *b = *a ^ *b;
    *a = *a ^ *b;
    return;
}

int main()
{
    long long a = 0, b = 0;
    long i = 0, max = 0;
    int count = 1;
    int flag1 = 0, flag2 = 0, flag = 0;
    scanf("%lld %lld", &a, &b);
    if (a > b) swap(&a, &b);
    max = (long)sqrt(b);
    while (a % 2 == 0)
    {
        a /= 2;
        flag1 = 1;
    }
    while (b % 2 == 0)
    {
        b /= 2;
        flag2 = 1;
    }
    if (flag1==1 && flag2==1) count++;
    for (i = 3; i <= max; i += 2)
    {
        if (i>a || i>b) break;
        flag1 = 0;
        flag2 = 0;
        while (a % i == 0)
        {
            a /= i;
            flag1 = 1;
        }
        while (b % i == 0)
        {
            b /= i;
            flag2 = 1;
        }
        if (flag1==1 && flag2==1) count++;
    }
    if (a > max && a == b) count++;
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
using namespace std;
#define MAX_N 100

int graph[MAX_N+1][MAX_N+1];
int d[MAX_N+1];
int f[MAX_N+1];

int n;
int t;
void dfs(int id) {
  if(id != 0)
    t++;
  d[id] = t;
  for(int i=1;i<=n;i++) {
    if(graph[id][i] != 0 && d[i] == 0) {
      dfs(i);
    }
  }
  if(id != 0)
    t++;
  f[id] = t;
}

int main() {
  scanf("%d\n",&n);
  // dummy
  for(int i=0;i<=n;i++) {
    graph[0][i] = 1;
  }
  int u,k,v;
  for(int i=0;i<n;i++) {
    scanf("%d %d ",&u,&k);
    for(int j=0;j<k;j++) {
      scanf("%d ",&v);
      graph[u][v] = 1;
    }
  }

  dfs(0);

  for(int i=1;i<=n;i++) {
    printf("%d %d %d\n",i,d[i],f[i]);
  }
}

Measured memory_bytes: 1068
#include <iostream>
using namespace std;
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if (a == b){
    printf("%d",a+b);
  }else if (a > b){
    printf("%d",a+a-1);
  }else{
    printf("%d",b+b-1);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MX 1003
#define pb push_back
int dp[MX][MX];
int m = 1e9 + 7;
int main() {
	int n, w;
	cin >> n >> w;
	dp[1][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= w; ++j) {
			char c;
			cin >> c;
			if (c == '.')
				dp[i][j] = (dp[i - 1][j] % m + dp[i][j - 1] % m) % m;
		}
	cout << dp[n][w] << endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

  int N;
  std::cin >> N;

  std::vector<int> v(N, 0);

  std::string P;
  std::string Q;

  for (int i = 0; i < N; i++) {
    v[i] = i + 1;
    int a;
    std::cin >> a;
    P += a + '0';
  }

  for (int i = 0; i < N; i++) {
    int a;
    std::cin >> a;
    Q += a + '0';
  }

  std::vector<std::string> n;
  int c = 0;
  do {
    std::string o;
    for (int i = 0; i < N; i++) {
      o += static_cast<char>(v[i] + '0');
    }
    n.push_back(o);
    c++;
  } while (next_permutation(v.begin(), v.end()));

  std::sort(n.begin(), n.end());
  int p, q;

  for (int i = 0; i < c; i++) {
    if (n[i] == P) {
      p = i;
    }
    if (n[i] == Q) {
      q = i;
    }
  }

  std::cout << std::abs(p - q) << std::endl;

  return 0;
}


Measured memory_bytes: 2424
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>M>>K;
	if(N<=K){
		K-=N;
		N=0;
	}
	else{
		N-=K;
		K=0;
	}
	if(M<=K){
		K-=M;
		M=0;
	}
	else{
		M-=K;
		K=0;
	}
	cout<<N<<" "<<M<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	if(S.back()=='s') S+="es";
	else S+="s";
	cout<<S<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3656
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(0, n, 2):
        if a[i]%2 == 1:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9108
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<int, int> P;

template<typename T1, typename T2>
istream& operator >> (istream& is, pair<T1, T2>& p){
  is >> p.first >> p.second;
  return is;
}

int main() {
  int N;  cin >> N;
  vector<P> ps(N);
  vector<int> ids(N);
  for (int i = 0; i < N; ++i) {
    cin >> ps[i];
    ids[i] = i;
  }

  double sum = 0;
  LL cnt = 0;
  do {
    for (int i = 1; i < N; ++i) {
      int id1 = ids[i-1], id2 = ids[i];
      double x1 = ps[id1].first, y1 = ps[id1].second;
      double x2 = ps[id2].first, y2 = ps[id2].second;
      sum += hypot(x1-x2, y1-y2);
    }
    ++cnt;
  } while(next_permutation(ids.begin(), ids.end()));
  printf("%.9f\n", sum/cnt);
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main()
{
   int x, h, m, s;
   cin >> x;
   h = x / 3600 ;
   m = ((x-(h*3600))/60) ;
   s = x % 60 ;
   cout << h << ":" << m << ":" << s << endl;
 
   return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=200005;
int n,k;
int p[N];
int a[N];
pair<int,int> Min[N][20],Max[N][20];
void init()
{
	for(int i=1;i<=n;i++)
		Min[i][0]=Max[i][0]=make_pair(p[i],i);
	for(int j=1;(1<<j)<=n;j++)
		for(int i=1;i+(1<<j)-1<=n;i++)
			Min[i][j]=min(Min[i][j-1],Min[i+(1<<(j-1))][j-1]);
	for(int j=1;(1<<j)<=n;j++)
		for(int i=1;i+(1<<j)-1<=n;i++)
			Max[i][j]=max(Max[i][j-1],Max[i+(1<<(j-1))][j-1]);
	return;
}
int querymin(int l,int r)
{
	int k=log2(r-l+1);
	return min(Min[l][k],Min[r-(1<<k)+1][k]).second;
}
int querymax(int l,int r)
{
	int k=log2(r-l+1);
	return max(Max[l][k],Max[r-(1<<k)+1][k]).second;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)
		a[i]=p[i-1]>p[i];
	for(int i=1;i<=n;i++)
		a[i]+=a[i-1];
	init();
	int ans=0;
	bool flag=false;
	for(int r=k;r<=n;r++)
	{
		int l=r-k+1;
		if(a[l]==a[r])
		{
			flag=true;
			continue;
		}
		if(l==1)
		{
			ans++;
			continue;
		}
		if(querymin(l-1,r-1)==l-1&&querymax(l,r)==r) continue;
		ans++;
	}
	if(flag) ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 68024
main :: IO ()
main = do
  _n <- (read :: String -> Int) <$> getLine
  hs <- fmap (read :: String -> Int) . words <$> getLine
  print $ fst $ solve hs

solve hs = foldr acc (0,0) $ False:(zipWith (>=) hs (tail hs))
  where
    acc a (m, c) = if a then (m, c+1) else (max m c, 0)


Measured memory_bytes: 61820
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize,
        edges: [(usize1, usize1, u64); n-1]
    }

    let mut g = vec![vec![];n];
    for i in 0..n-1 {
        let (u,v,w) = edges[i];
        g[u].push((v, w));
        g[v].push((u, w));
    }
    let mut ans = vec![false;n];
    dfs(&g, &mut ans, 0, None, true);
    for i in 0..n {
        println!("{}", if ans[i] {"0"} else {"1"});
    }
}

fn dfs(g: &[Vec<(usize, u64)>], ans: &mut [bool], cur: usize, pre: Option<usize>, is_w: bool) {
    ans[cur] = is_w;
    for &(v, w) in &g[cur] {
        if pre.map(|src| src == v).unwrap_or(false) {
            continue;
        }
        if w % 2 == 0 {
            dfs(g,ans,v,Some(cur),is_w);
        } else {
            dfs(g,ans,v,Some(cur),!is_w);
        }
    }
}

Measured memory_bytes: 25084
#include<bits/stdc++.h>
#define PI 2*acos(0)
#define ll long long
#define pii pair<int,int>
#define mx 100005
using namespace std;
ll int a[mx],f[mx];
ll int sum;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll int i,j,n,q,b,c;
    cin>>n;
    sum=0;
    for(i=1;i<=n;i++){
        cin>>a[i];
        //cout<<a[i]<<endl;
        f[a[i]]++;
        sum+=a[i];
    }
    //cout<<"Sum =" <<sum<<endl;
    cin>>q;
    for(i=1;i<=q;i++){
        cin>>b>>c;
        sum+=f[b]*(c-b);
        f[c]+=f[b];
        f[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int a[N], n, h;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> h >> n;
	Foz(i, n) cin >> a[i];
	int sm = 0;
	Foz(i, n) sm += a[i];
	if (sm < h) cout << "No\n";
	else cout << "Yes\n";
}



Measured memory_bytes: 640
from sys import stdin

def main():
    n = stdin.readline()
    if(n[0] == n[1] and n[1] == n[2]):
        print("Yes")
    elif(n[1] == n[2] and n[2] == n[3]):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    string s,t;
    cin >> s >> t;
    vsort(s);
    rsort(t.begin(),t.end(),char);
    
    if(s < t)Yes;
    else No;
    
	return  0;
}

Measured memory_bytes: 256
def solve(a,b):
    if a>b:
        print("a > b")
    if a<b:
        print("a < b")
    if a==b:
        print("a == b")
    
def answer():
    line = list(map(int, input().split()))
    a = line[0]
    b = line[1]
    solve(a,b)

if __name__ =='__main__':
    answer()





Measured memory_bytes: 5596