akhauriyash/Code-Regression huggingface dataset:
n=input()
s=len(n)
ans=0
if s%2==0:
  for i in range(1,s):
    if i%2!=0:
      ans+=9*10**(i-1)
else:
  ans+=int(n)-10**(s-1)+1
  for i in  range(1,s):
    if i%2!=0:
      ans+=9*10**(i-1)
      
print(ans)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
	using namespace std;
	#define ll long long int
    const ll mod = 1e9+7;
	const ll INF = 1e18L+7;

	int main(){
	int r,c;
	cin>>r>>c;
	char arr[r][c];
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
	       cin>>arr[i][j];
		}
	}
	int val=1;
	int dp[r][c];
	memset(dp , 0 , sizeof dp);
	dp[0][0]=1;
	 for(int i=1;i<c;i++){
	    if(arr[0][i]=='#'){val=0;}
	       dp[0][i]=val;
	 }
	val=1;
	for(int i=1;i<r;i++){
	    if(arr[i][0]=='#'){val=0;}
	       dp[i][0]=val;
	 }


	for(int i=1;i<r;i++){
		for(int j=1;j<c;j++){
	          if(arr[i][j]=='#')dp[i][j]=0;
	          else{
	          	dp[i][j] = (dp[i-1][j] +dp[i][j-1])%mod;
	          }
	       
		}
    }

	cout<<dp[r-1][c-1];
	}

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

int main() {
    string s; cin >> s;
    vector<char> t(26, 0);

    for (int i = 0; i < s.size(); i++) {
        int ch = s[i] - 'a';
        t[ch]++;
    }

    int ele = 0;
    for (int i = 0; i < 26; i++) {
        if (t[i] % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    int n=0;
    REP(i,st.size()){
        if(st[i]=='o'){
            n++;
        }
    }
    cout<<700+100*n<<endl;
    return 0;
}

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

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

    
    if(K<A){
        cout << K << endl;
    }else if(K<A+B){
        cout << A << endl;
    }else{
        cout << A-(K-A-B) << endl;
    }
    
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<string> c(h);
  for (int i = 0; i < h; i++) {
    cin >> c[i];
  }

  int ans = 0;

  for (int hbit = 0; hbit < (1 << h); ++hbit) {
    for (int wbit = 0; wbit < (1 << w); wbit++) {
      vector<string> cp(h);
      copy(c.begin(), c.end(), cp.begin());

      for (int i = 0; i < h; ++i) {
        if (hbit & (1 << i)) {
          for (int k = 0; k < w; k++) {
            cp[i][k] = '.';
          }
        }
      }
      for (int j = 0; j < w; j++) {
        if (wbit & (1 << j)) {
          for (int k = 0; k < h; k++) {
            cp[k][j] = '.';
          }
        }
      }

      int cnt = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (cp[i][j] == '#') ++cnt;
        }
      }

      if (cnt == k) ++ans;
    }
  }
  cout << ans << endl;
}

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

  solve();
  return 0;
}


Measured memory_bytes: 3656
fn main() {
    let mut v: Vec<char> = Vec::new();
    let s: String = read();
    v = s.chars().collect();
    let n = v.len();
    let mut ans = "Yes";
    for i in 0..n/2 {
        if v[i] != v[n-i-1] {
            ans = "No";
        }
    }
    println!("{}", ans); 
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

Measured memory_bytes: 4352
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1007*1007;

int n;
char wcz[nax];
int tab[nax];

int niby[nax];
int suf[nax];

int wyn=nax;

int licz(int v)
{
	int ter=0;
	int mini=0;
	for (int i=1; i<=n; i++)
	{
		if (tab[i])
		{
			ter+=tab[i];
		}
		else
		{
			if (ter+1+suf[i+1]<=v)
				ter++;
			else
				ter--;
		}
		
		mini=min(mini, ter);
	}
	return mini;
}

int main()
{
	scanf("%s", wcz+1);
	n=strlen(wcz+1);
	for (int i=1; i<=n; i++)
	{
		if (wcz[i]=='0')
		{
			tab[i]=-1;
			niby[i]=-1;
		}
		if (wcz[i]=='1')
		{
			tab[i]=1;
			niby[i]=1;
		}
		if (wcz[i]=='?')
		{
			tab[i]=0;
			niby[i]=-1;
		}
	}
	for (int i=n; i; i--)
		suf[i]=max(suf[i+1]+niby[i], 0);
	for (int i : {suf[1], suf[1]+1})
		wyn=min(wyn, i-licz(i));
	printf("%d\n", wyn);
	return 0;
}


Measured memory_bytes: 16540
n=int(input())
lis=[input()]
ok=True
for i in range(n-1):
    a=input()
    if a in lis:
        ok=False
        break
    if lis[-1][-1]!=a[0]:
        ok=False
        break
    lis.append(a)
if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
	int a,b;
	for (int A=0;A<4;A++){
		cin>>a>>b;
		if (a==1)cout<<6000*b<<endl;
		if (a==2)cout<<4000*b<<endl;
		if (a==3)cout<<3000*b<<endl;
		if (a==4)cout<<2000*b<<endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;

int main()
{
	int a, b;
	stringstream ss;
	while (cin >> a >> b)
	{
		a += b;
		string s;
		ss << a; ss >> s; ss.clear();
		cout << static_cast<int>(s.size()) << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import functools

a = [int(input()) for _ in range(5)]
def e(x):
    if x % 10:
        return x % 10
    else:
        return 10
a.sort(key=functools.cmp_to_key(lambda x,y: e(x) - e(y)), reverse=True)
ans = 0
for x in a[:-1]:
    d,m = divmod(x, 10)
    ans += (d + (m != 0)) * 10
ans += a[-1]
print(ans)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

#define llset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define en '\n'
#define S second
#define F first
#define pll pair<ll,ll>
#define PB push_back

const ll N = 1e6+7;
ll mod = 1e9+7;
#define calncr for(int i=1  ;i<=1e6;i++) fac[i] = (fac[i-1]*i)%mod;
ll fac[N] = {0};

ll gen_base(const ll before, const ll after) {
    auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
    std::mt19937 mt_rand(seed);
    int base = std::uniform_int_distribution<ll>(before+1, after)(mt_rand);
    return base % 2 == 0 ? base-1 : base;
}

ll pow(ll a,ll b)
{
    if(!b)
        return 1;
    ll p = pow(a,b/2);
    if(b%2)
        return (a*((p*p)%mod))%mod;
    else
        return (p*p)%mod;
}

ll modInv(ll a)
{
    //cout<<a<<" "<<mod<<en;
    return pow(a%mod,mod-2);
}

ll nCr(ll n,ll r)
{
    return (fac[n]*modInv((fac[r]*fac[n-r])%mod))%mod;
}

ll hashf(ll r,ll x,ll mod)
{
    return (x+r)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    fac[0] = 1;
    calncr;
    ll k;
    cin>>k;
    ll num = 7,cnt=1;
    for(ll i=1;i<=k;i++){
        if(num%k==0){
            cout<<cnt<<en;
            break;
        }
        cnt++;
        num = (num%k)*10+7;
    }
    if(cnt>k)
        cout<<-1<<en;
}


Measured memory_bytes: 11448
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y)
{
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&1)
    res=(res*x)%M;
    return res;
}
ll nCr(ll n,ll x)
{
    ll num=1,den=1;
    for(ll i=1;i<=x;i++)
    {
        num=(num*(n-i+1))%M;
        den=(den*i)%M;
    }
    return (num*power(den,M-2))%M;
}
ll solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=(power(2,n)-1+M)%M;
    ans=(ans-nCr(n,a)+M)%M;
    ans=(ans-nCr(n,b)+M)%M;
    cout<<ans<<endl;
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

int main(){
	int sum[5], n, m, ans;
	bool flag = false;

	while(1){
		for(int i=0 ; i<5 ; i++){
			sum[i] = 0;

			cin >> n >> m;
			if( n==0 && m==0 ){
				flag = true;
				break;
			}
			sum[i] += n+m;
		}
		if( flag ) break;
		ans = 0;
		for(int i=1 ; i<5 ; i++){
			if( sum[ans] < sum[i]) ans = i;
		}
		char s = ans + 'A';
		cout << s << " " << sum[ans] << endl;
	}

	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int X, Y, Z;
  cin >> X >> Y >> Z;
  int N = X + Y + Z;
  using T = tuple<LL,LL,LL>;
  vector<T> xs(N);
  REP(i,N){
	LL a, b, c;
	cin >> a >> b >> c;
	xs[i] = make_tuple(a,b,c);
  }
  sort(ALL(xs), [](const T& l, const T& r){
	  return get<0>(l)-get<1>(l) < get<0>(r)-get<1>(r);
	});

  auto comp1 = [&](const T& l, const T& r){
	return get<0>(l)-get<2>(l) > get<0>(r)-get<2>(r);
  };
  priority_queue<T,vector<T>,decltype(comp1)> gs(comp1);
  LL tot_x = 0, tot_y = 0;
  VL rs(N);
  for(int i=N-1;i>=0;--i){
	gs.push(xs[i]);
	tot_x += get<0>(xs[i]);
	if(SZ(gs) > X){
	  tot_x -= get<0>(gs.top());
	  tot_y += get<2>(gs.top());
	  gs.pop();
	}
	rs[i] = tot_y + tot_x;
  }
  
  auto comp2 = [&](const T& l, const T& r){
	return get<1>(l)-get<2>(l) > get<1>(r)-get<2>(r);
  };
  priority_queue<T,vector<T>,decltype(comp2)> ss(comp2);
  tot_x = 0, tot_y = 0;
  VL ls(N);
  REP(i,N){
	ss.push(xs[i]);
	tot_x += get<1>(xs[i]);
	if(SZ(ss) > Y){
	  tot_x -= get<1>(ss.top());
	  tot_y += get<2>(ss.top());
	  ss.pop();
	}
	ls[i] = tot_y + tot_x;
  }
  
  LL ans = 0;
  FOR(i,Y,N-X+1)
	maxi(ans, ls[i-1] + rs[i]);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll A, B, m;
	cin >> A >> B >> m;
	ll a[A], b[B], x[m], y[m], c[m];
	
	ll ma = INF;
	ll mb = INF;
	zep(i, 0, A){cin >> a[i]; ma = min(a[i], ma);}
	zep(i, 0, B){cin >> b[i]; mb = min(b[i], mb);}
	
	ll ans = ma+mb;
	zep(i, 0, m){
		cin >> x[i] >> y[i] >> c[i];
		x[i]--; y[i]--;
		ans = min(a[x[i]]+b[y[i]]-c[i], ans);
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}




int main() {

	ll N,an=0;
	cin >> N;
	for (ll i = 1; i * i <= N; i++) {
		ll k = i;
		if (N % k == 0) {
			if (N / k - 1 > k)an += N / k - 1;
			k = N / k;
			if (N / k - 1 > k&&k*k!=N)an += N / k - 1;
		}
	}
	cout << an << endl;

}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;

static class Abc118a {
    static void Main(string[] args){
        var ab = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);
        var a = ab[0]; var b=ab[1];
        var ans = a+b;
        if(b%a!=0) ans = b-a;
        System.Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
	using namespace std;

	int a, b;
	cin >> a >> b;
	
	auto taps{ 1 }, ans{0};

	while (taps < b)
	{
		taps += -1 + a;
		++ans;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut x: usize = read();
    let mut y = x;
    let n: usize = read();
    let p: Vec<usize> = (0..n).map(|_| read()).collect();
    if !p.contains(&x) {
        println!("{}", x)
    } else {
        for _ in 0..=101 {
            if x == 0 {
            } else {
                x = x - 1;
            }
            y = y + 1;
            if !p.contains(&x) {
                println!("{}", x);
                break;
            } else if !p.contains(&y) {
                println!("{}", y);
                break;
            }
        }
    }
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll N,ans;
    string A,B,C;
    cin >> N;
    cin >> A >> B >> C;
    ans = 0;
    for(int i = 0;i < N;i++){
        if(A[i] != B[i]) ans++;
        if(A[i] != C[i] && B[i] != C[i]) ans++;
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int count_digit(long long n){
  int digit = 0;

  while(n>0){
    n/=10;
    digit++;
  };

  return digit;
}

int main(){
  long long n;
  int min;
  cin>>n;
  long long tmp = n;
  min = count_digit(n);

  for(long long i=1;i*i<=n;i++){
    if(n%i!=0)continue;
    long long b = n / i;
    int digit = max(count_digit(i), count_digit(b));
    if(min>digit){
      min = digit;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<malloc.h>
int i;
long long k,a[200005],sum[200005];
long long n,num;
void merge(long long *x,int left,int mid,int right)
{
	long long *temp=(long long*)malloc(sizeof(long long)*(right-left+5));
	int i=left,j=mid+1,tempnum=0;
	while(i<=mid&&j<=right)
	{
		if(sum[i]<=sum[j])
			temp[tempnum++]=sum[i++];
		else
		{
			temp[tempnum++]=sum[j++];
			num+=mid+1-i;
			//printf("%d %d %d %d\n",i,mid,right,num);			
		}
	}
	while(i<=mid)
		temp[tempnum++]=sum[i++];
	while(j<=right)
		temp[tempnum++]=sum[j++];
	for(i=left;i<=right;++i)
		sum[i]=temp[i-left];
	free(temp);
}
void mergesort(long long *x,int left,int right)
{
	int mid=(left+right)>>1;
	if(left>=right)
		return ;
	mergesort(x,left,mid);
	mergesort(x,mid+1,right);
	merge(x,left,mid,right);
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(i=1;i<=n;++i)
	{
		scanf("%lld",a+i);
		*(a+i)-=k;
		*(sum+i)=*(sum+i-1)+*(a+i);
	}
	//printf("%d\n",num);
	mergesort(sum,0,n);
	printf("%lld\n",n*(n+1)/2-num);
	return 0;
}

Measured memory_bytes: 5668
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

ll dp[3007][3007];
string s,t;

ll fun(ll x, ll y)
{
	if(dp[x][y]!=-1)
	{
		return dp[x][y];
	}

	if(x==s.size() || y==t.size())
		return 0;

	if(s[x]==t[y])
	{
		dp[x][y] = fun(x+1,y+1) +1;
	}
	else
		dp[x][y] = max (fun(x,y+1) , fun(x+1,y));

	return dp[x][y];
}

int main()
{
	fastio
	
	cin >> s >> t;
	ll n =s.size();
	ll m = t.size();
	for(ll i=0;i<n+1;i++)
		for(ll j=0;j<m+1;j++)
			dp[i][j]=-1;
	//cout << fun(0,0)<< endl;
	ll i=0;
	ll j=0;
	string ans;
	ll val = fun(0,0);
	while(i<n && j<m)
	{
		if(s[i]==t[j])
		{
			ans += s[i];
			i++;
			j++;
		}
		else
		{
			if(dp[i][j]==dp[i+1][j])
				i++;
			else
				j++;
		}
	}
	cout << ans << endl;
	return 0;	
}


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

int main() {
  int N; cin>>N;
  for(int i=0; i<N; i++){
    char c; cin>>c;
    if(c!='Y') continue;
    else{
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N = 4005;
const int M = 1e9+7;
#define pi acos(-1)
#define INF 1e10
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int a[N],b[N],c[N];//r,g,b
int main()
{
	int n;sd(n);
	string s;cin >> s;
	for(int i=0;i<n;++i)
	{
		a[i+1] = a[i],b[i+1] = b[i],c[i+1] = c[i];
		if(s[i] == 'R') a[i+1]++;
		else if(s[i] == 'G') b[i+1]++;
		else if(s[i] == 'B') c[i+1]++;
	}
	LL ans = 0;
	for(int i=0;i<n;++i)
	{
		if(s[i] == 'R')
		{
			for(int j=i+1;j<n;++j)
			{
				if(s[j] == 'G')
				{
					int len = j-i;
					ans += c[n]-c[j+1];
					if(j+len < n && s[j+len] == 'B') ans--;
				}
				else if(s[j] == 'B')
				{
					int len = j-i;
					ans += b[n]-b[j+1];
					if(j+len < n && s[j+len] == 'G') ans--;
				}
			}
		}
		else if(s[i] == 'G')
		{
			for(int j=i+1;j<n;++j)
			{
				if(s[j] == 'R')//GRB
				{
					int len = j-i;
					ans += c[n]-c[j+1];
					if(j+len < n && s[j+len] == 'B') ans--;
				}
				else if(s[j] == 'B')//GBR
				{
					int len = j-i;
					ans += a[n]-a[j+1];
					if(j+len < n && s[j+len] == 'R') ans--;
				}
			}
		}
		else if(s[i] == 'B')
		{
			for(int j=i+1;j<n;++j)
			{
				if(s[j] == 'R')//BRG
				{
					int len = j-i;
					ans += b[n]-b[j+1];
					if(j+len < n && s[j+len] == 'G') ans--;
				}
				else if(s[j] == 'G')//BGR
				{
					int len = j-i;
					ans += a[n]-a[j+1];
					if(j+len < n && s[j+len] == 'R') ans--;
				}
			}
		}
		//dbg(ans);
	}
	plr(ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int send(int i) {
  cout << i << endl;
  fflush(stdout);
  string s;
  cin >> s;
  if (s == "Vacant") exit(0);
  if (s == "Male") return 0;
  return 1;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  int ans0 = send(0);
  int l = 0, r = n;
  int vl = ans0, vr = ans0;
  while (true) {
    int x = (l + r) / 2;
    int vx = send(x);
    if ((x - l) % 2 != (vl + vx) % 2) {
      r = x;
      vr = vx;
    } else {
      l = x;
      vl = vx;
    }
  }
  return 0;
}

Measured memory_bytes: 852
s = input().strip()
ans = [-1,-1]
for i in range(len(s)):
    if i<len(s)-1 and s[i]==s[i+1]:
        ans = [i+1,i+2]
        break
    if i<len(s)-2 and s[i]==s[i+2]:
        ans = [i+1,i+3]
        break
print(ans[0], ans[1])

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

int main(){
  int lastTwentyFourHours = 24;
  int currentTimeAsHour;
  cin >> currentTimeAsHour;

  int remainingTimeAsHour = 24 - currentTimeAsHour;
  cout << remainingTimeAsHour + lastTwentyFourHours << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define H_MAX 51
#define W_MAX 51
 
bool s[H_MAX][W_MAX];
int V[H_MAX][W_MAX];

typedef struct location{
    int x;
    int y;
}loc;

int main(){
    int H,W;
    cin >> H >> W;
    char inp;
    int wnum = 0;
    REP(i,H) REP(k,W)
    {
        cin >> inp;
        if(inp == '.'){
            s[i][k] = true;
            wnum++;
        }
        else
            s[i][k] = false;
    }

    queue<pair<loc, int> > q;
    loc init = {0, 0};
    s[0][0] = false;
    q.push(make_pair(init, 0));
    while(!q.empty()){
        pair<loc, int> tmp = q.front();
        q.pop();
        loc p = tmp.first;
        int x = p.x, y = p.y;
        int path = tmp.second;
        V[y][x] = path;
        if(x-1 >= 0 && s[y][x-1]) {
            loc next = {x-1, y};
            s[y][x-1] = false;
            q.push(make_pair(next, path+1));
        }
        if(y-1 >= 0 && s[y-1][x]) {
            loc next = {x, y-1};
            s[y-1][x] = false;
            q.push(make_pair(next, path+1));
        }
        if(x+1 < W && s[y][x+1]) {
            loc next = {x+1, y};
            s[y][x+1] = false;
            q.push(make_pair(next, path+1));
        }
        if(y+1 < H && s[y+1][x]) {
            loc next = {x, y+1};
            s[y+1][x] = false;
            q.push(make_pair(next, path+1));
        }
    }

    if(V[H-1][W-1] == 0)
        cout << -1 << endl;
    else
        cout << wnum - V[H-1][W-1] - 1<< endl;
    return 0;
}


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

int main(void){
  int N;
  char W[110][20] = {};
  int i, j, k;
  int flag = 0;//ルールが守られていれば1，そうれでなければ0

  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%s", &W[i][0]);//ここ重要
  }

  for(i = 1; i < N; i++){
    //i番目の単語が既出かどうか確認
    for(j = 0; j < i; j++){
      flag = 0;
      for(k = 0; k < 10; k++){
        if(W[i][k] != W[j][k]){
          flag = 1;
          break;
        }
      }
      if(flag == 0){
        break;
      }
    }

    //i番目の単語が既出でなかったとき，その単語の先頭の文字が直前の単語の末尾と一致するか確認
    if(flag == 1){
      if(W[i][0] != W[i-1][strlen(&W[i-1][0])-1]){
        flag = 0;
        printf("No\n");
        break;
      }
    }
    //i番目の端が既出であったとき，Noを出力
    else if(flag == 0){
      printf("No\n");
      break;
    }
  }

  if(flag == 1){
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <cmath>

using namespace std;

int main()
{
    long n;
    cin >> n;

    int ans = INT_MAX;
    long ulimit = sqrt(n);

    for (int a = 1; a <= ulimit ; a++) {
        if (n % a == 0) {
            auto b = n / a;
            ans = min(ans,
                      (int) max(log10(a), log10(n/a)));
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  bool m = false;
  c = getchar();
  while(!isdigit(c)){
    if(c == '-') m = true;
    c = getchar();
  }
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  if(m) ret = -ret;
  return ret;
}

int main(){
  int n,k;
  while((n = getInt()) + (k = getInt())){
    vector<int> tmp(k);
    int kk = 0;
    int nn = 0;
    int sum = 0;
    int ans = INT_MIN;
    REP(i,n){
      int tt = getInt();
      //cout << "tt=" << tt << endl;
      if(i >= k){
        sum -= tmp[nn++];
        nn %= k;
      }
      tmp[kk++] = tt;
      kk %= k;
      sum += tt;
      if(i >= k - 1){
        ans = max(ans, sum);
      }
    }
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
        int a, b;
        printf("");
        scanf("%d %d", &a, &b);
        if(a,b>=1 && a,b<=100)
                printf("%d %d\n", a*b, (a+b)*2);
        else
                printf("\n");
        return 0;
}

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

int main() {
    int N;
    double x, sum = 0;
    string u;
    const double BTC_RATE = 380000.0;

    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> x >> u;
        if (u == "BTC") {
            sum += x * BTC_RATE;
        } else {
            sum += x;
        }
    }

    cout << sum << endl;

    return 0;
}

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

int main()
{
  int n ;
cin >> n ;
int a[n];
int mx = 0 ,mn = 100000007 ;
for(int i = 0 ; i < n ; i++)
{
  cin >> a[i] ;
if(a[i] > mx)
  mx = a[i] ;
if(a[i] < mn)
 mn = a[i] ;
}
cout << (mx-mn) ;
return 0 ; 
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, M := sc.nextInt(), sc.nextInt()
	bl, br := sc.nextInt(), sc.nextInt()
	for i := 1; i < M; i++ {
		l, r := sc.nextInt(), sc.nextInt()
		bl, br = max(bl, l), min(br, r)
	}
	if bl > br {
		fmt.Println(0)
	} else {
		ans := 0
		for i := bl; i <= br; i++ {
			if i <= N {
				ans++
			} else {
				break
			}
		}
		fmt.Println(ans)
	}
}


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

main() {
  string w; cin >> w;
  int cnt[26]{};
  for (int i = 0; i < w.length(); i++) {
    cnt[w[i] - 'a']++;
  }
  int ans = true;
  for (int i = 0; i < 26; i++) if (cnt[i] % 2) ans = false;
  cout << ( (ans) ? "Yes" : "No" ) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  tuple<int, int, int> cp;
  cp = make_tuple(2019, 4, 30);

  string a = s.substr(0, 4);
  string b = s.substr(5, 2);
  string c = s.substr(8, 2);
  int y = stoi(a);
  int m = stoi(b);
  int d = stoi(c);
  tuple<int, int ,int> tp(y, m, d);
  tp <= cp ? cout << "Heisei" << endl : cout << "TBD" << endl;
  return 0;
}

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

fn main() {
    let d: u32 = read();
    let n: i32 = read();

    println!("{}", if n == 100 { 101 } else { n } * 100i32.pow(d));
}

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

#[test]
mod test {
    fn test() {
        assert!(true);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<set>
#include<string>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;
    set<string>st;
    while(n--)
    {
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();
    return 0;

}


Measured memory_bytes: 19140
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
signed main() {
  int N;
  int ans;
  cin >> N;
  for (int i = 1; i * i <= N; i++) {
    ans = i;
  }
  cout << ans * ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
    int n,m;
    cin >> n >> m;
    vector<vi> q(n+1);
    rep(i,0,m-1)
    {
        int l,r;
        cin >> l >> r;
        q[l].pb(r);
        q[r].pb(l);
    }

    int ans[n+1] = {0};
    queue<pii> q1;
    q1.push({1,-1});
    while(q1.size())
    {
        int s = q1.size();
        while(s--)
        {
            pii c = q1.front();
            q1.pop();
            if(ans[c.fr]!=0)
                continue;
            ans[c.fr] = c.sc;
            loop(q[c.fr])
                q1.push({it, c.fr});
        }
    }


    rep(i,2,n)
    {
        if(ans[i]==0)
        {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;
    rep(i,2,n)
        cout << ans[i] << endl;

}   


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 17112
#include <iostream>
using namespace std;
char ma[8][8];
bool p(int i,int j){return (0<=i&&i<8&&0<=j&&j<8)&&(ma[i][j] == '1');}
void c(int x,int y){

  if(p(y-3,x))cout << 'B'<<endl;
  else if(p(y,x-3))cout << 'C' << endl;
  else if(p(y-2,x+1))cout << 'D' << endl;
  else if(p(y-1,x-2))cout << 'E' << endl;
  else if(p(y-2,x-1))cout << 'F' << endl;
  else if(p(y,x-1) &&p(y-1,x+1))cout << 'G' << endl;
  else cout << 'A' <<endl;

}

int main(){
  int x,y;
  while(cin >> ma[0][0]){

    for(int i = 0 ; i < 8 ; i++ ){
      for(int j = 0 ; j < 8 ; j++ ){
	if(i + j == 0)continue;
	cin >> ma[i][j]; 
	if(ma[i][j] == '1'){x = j,y = i;}
      }
    }

    int f = 0;
    c(x,y);
  }
  return 0;
}

Measured memory_bytes: 1132
#from functools import reduce
def gcd(m,n):
  x=max(m,n)
  y=min(m,n)
  while y!=0:
    x,y=y,x%y
  return x
 
a=int(input())
li=list(map(int,input().split()))
left_gcd=[0]
#left_gcd.append(li[0])
right_gcd=[0]
#right_gcd.append(li[a-1])

for i in range(a):
    left_gcd.append(gcd(li[i],left_gcd[i]))
    right_gcd.append(gcd(li[a-1-i],right_gcd[i]))
    #k=k+1
# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)
#print(right_gcd)
#print(left_gcd)
num_li=[]
#num_li.append(right_gcd[a-2])
#num_li.append(left_gcd[a-2])
#s=2
for i in range(a):
    ans=gcd(left_gcd[(a-1)-i],right_gcd[i])
    #print(left_gcd[(a-3-i)],right_gcd[i])
  
    #print(ans)
    num_li.append(ans)
    

print(max(num_li))


Measured memory_bytes: 14076
import bisect
from itertools import accumulate
X = input()
S = [0]*(len(X))
T = [0]*(len(X))
for i in range(len(X)):
    if X[i] == "S":
        S[i] = 1
    else:
        T[i]=1
Ssum = list(accumulate(S))
Tsum = list(accumulate(T))
kosu=len(X)//2
count=1
for i in range(1,kosu+1):
    Tindex = bisect.bisect_left(Tsum, i)
    if Ssum[Tindex]>=count:
        count+=1
print(len(X)-(count-1)*2)

Measured memory_bytes: 27892
import math
mod = 10 ** 9 + 7
n, m = map(int, input().split())

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret //= j

    return (int)(ret)


ans = 1
for i in f:
    ans *= comb(i+n-1, i)
print(ans % mod)


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

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

ll N, K;
string s;
ll cnt[100010];
vector<ll> vt, vt2;
int main() {
	cin >> N >> K;
	cin >> s;
	ll ans = 1;
	if(s[0]=='0') vt.push_back(0);
	vt2.push_back(0);
	REP(i,0,N){
		if(s[i] == '1' && s[i+1] == '0'){
			vt.push_back(i+1);
		}else if(s[i] == '0' && s[i+1] == '1'){
			vt2.push_back(i+1);
		}

	}
	vt.push_back(N);
	vt2.push_back(N);
	if(K>=vt.size()) ans = N;
	else{
		REP(i,0,vt.size()-K){
//			cout<< vt[i+K] <<" "<< vt2[i] << endl;
			ans = max ({ans, vt[i+K] - vt2[i]});
		}
	}

	p(ans);
	return 0;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////


int N;
int A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	int res = 0;
	int cnt = 0;
	rep(i, 0, N - 1) {
		if(A[i] >= A[i + 1]) cnt++;
		else {
			MAX(res, cnt);
			cnt = 0;
		}
	}
	MAX(res, cnt);
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 640
def main():
    D = int(input())
    fuman = list(map(int, input().split()))
    manzoku = [[0]*26 for _ in range(D)]
    for i in range(D): manzoku[i] = list(map(int, input().split()))
    # できるだけ点数が下がらないように、満足度の高いものを選んでいく
    # d日目にテストiを受けた時、score += manzoku[d][i]-sigma[i以外25個](fuman[k]*それを受けてない日数)
    # >テストiをd日目に受ける
    # 1.fuman[i]*受けてない日数が一番でかいやつを受ける
    # 2.manzoku[d][i]が一番でかいやつを受ける
    timepass = [0]*26
    # 初日のみ指定
    x,t = 0,0
    for j in range(26):
        tmp = manzoku[i][j]
        if tmp>x:
            x = tmp
            t = j
    print(t+1)
    for i in range(1,D):
        #1
        x1 = 0
        t1 = 0
        for j in range(26):
            tmp = fuman[j]*timepass[j]
            if tmp>x1:
                x1 = tmp
                t1 = j
        #2
        x2 = 0
        t2 = 0
        for j in range(26):
            tmp = manzoku[i][j]
            if tmp>x2:
                x2 = tmp
                t2 = j
        #sel
        if x1>x2:
            for j in range(26):
                if not j==t1: timepass[j] += 1
                else: timepass[j] = 0
            print(t1+1)
        else:
            for j in range(26):
                if not j==t2: timepass[j] += 1
                else: timepass[j] = 0
            print(t2+1)




main()


Measured memory_bytes: 9512
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n,p[333][333];
int tate[333][333];
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++) cin >> p[i][j];
    }
    
    memset(tate,0,sizeof(int));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            tate[i][j] = p[i][j]+tate[i-1][j];
        }
    }
    
    int ans = p[1][1];
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            int retu = tate[j][1]-tate[i-1][1];
            for(int k=2;k<=n;k++){
                ans = max(ans,retu+tate[j][k]-tate[i-1][k]);
                if(i == j) retu = max(retu+p[i][k],tate[j][k]-tate[i-1][k]);
                else retu = max(retu+p[i][k]+p[j][k],tate[j][k]-tate[i-1][k]);
            }
        }
    }
    
    cout << ans << endl;
    
    return(0);
}



Measured memory_bytes: 3872
from sys import stdin
S=(stdin.readline().rstrip())
flag=0
if S[0] != "A":
    flag=1
if S[2:-1].count("C") != 1:
    flag=1
for j in S.replace("A","").replace("C",""):
    if j.islower() != True:
        flag=1
if flag == 1:
    print("WA")
else:
    print("AC")

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

const int N = 301010;
const int MOD = 998244353;
const int INV = (MOD + 1) >> 1;
typedef long long ll;

char S[N];
int fac[N << 2], inv[N << 2];
int v[N][2], h[N][2];
int pre[N], suf[N], p2[N];
int n, m, lim, ans;

inline void Mod(int &x) {
	while (x >= MOD) x -= MOD;
}
inline int Pow(int a, int b) {
	int c = 1;
	while (b) {
		if (b & 1) c = (ll)c * a % MOD;
		b >>= 1; a = (ll)a * a % MOD;
	}
	return c;
}
inline int Inv(int x) {
	return Pow(x, MOD - 2);
}
inline int C(int n, int m) {
	return (ll)fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
inline int Calc(int X, int Y, int Z) {
	if (X == 0) return (Y + Z) ? 0: 1;
	return C(X + Y + Z - 1, X - 1);
}
inline void Solve(void) {
	static int x, y, z;
	memset(p2, 0, sizeof p2);
	memset(suf, 0, sizeof suf);
	x = y = z = 0;
	for (int i = 1; i <= n; i++) x += h[i][1];
	p2[0] = 1;
	for (int i = 1; i <= m; i++)
		Mod(p2[i] = p2[i - 1] << (v[i][0] & v[i][1]));
	for (int i = m; i; i--) {
		if (!v[i][0] && !v[i][1]) {
			suf[i] = suf[i + 1];
			continue;
		}
		Mod(suf[i] = suf[i + 1] + (ll)Calc(x, y, z) * p2[i] % MOD);
		y += v[i][0]; z += v[i][1];
	}
	x = y = z = 0;
	for (int i = 1; i <= n; i++) x += h[i][0];
	for (int i = 1; i <= m; i++) {
		if (!v[i][0] && !v[i][1]) continue;
		pre[i] = (ll)Calc(x, y, z) * Inv(p2[i - 1]) % MOD;
		Mod(ans += (ll)pre[i] * suf[i] % MOD);
		y += v[i][0]; z += v[i][1];
	}
}


int main(void) {
	scanf("%d%d\n", &n, &m);
	lim = max(n, m) << 2;
	inv[1] = 1;
	for (int i = 2; i <= lim; i++)
		inv[i] = (ll)(MOD - MOD / i) * inv[MOD % i] % MOD;
	fac[0] = inv[0] = 1;
	for (int i = 1; i <= lim; i++) {
		fac[i] = (ll)fac[i - 1] * i % MOD;
		inv[i] = (ll)inv[i - 1] * inv[i] % MOD;
	}
	scanf("%s\n", S);
	for (int i = 1; i <= n; i++) h[i][0] = S[i - 1] - '0';
	scanf("%s\n", S);
	for (int i = 1; i <= n; i++) h[i][1] = S[i - 1] - '0';
	scanf("%s\n", S);
	for (int i = 1; i <= m; i++) v[i][0] = S[i - 1] - '0';
	scanf("%s\n", S);
	for (int i = 1; i <= m; i++) v[i][1] = S[i - 1] - '0';
	Solve(); lim >>= 2;
	for (int i = 1; i <= lim; i++) {
		swap(h[i][0], v[i][0]);
		swap(h[i][1], v[i][1]);
	}
	swap(n, m); Solve();
	cout << max(ans, 1) << endl;
}

Measured memory_bytes: 14720
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//ID
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int m = sc.nextInt();
		Set<Integer> set = new HashSet<Integer>();
		for(int i=0;i<m;i++)set.add(sc.nextInt());
		long[][] dp = new long[2][10];
		int X = 1;
		dp[0][0] = 1;
		for(int i=1;i<=n;i++,X=1-X){
			Arrays.fill(dp[X], 0);
			for(int j=0;j<10;j++){
				if(s[n-i]=='*'){
					for(int x:set){
						if(i%2==0)x*=2;
						dp[X][(j+(x/10)+(x%10))%10]+=dp[1-X][j];
					}
				}
				else{
					int x = s[n-i]-'0';
					if(i%2==0)x*=2;
					dp[X][(j+(x/10)+(x%10))%10]+=dp[1-X][j];
				}
			}
		}
		System.out.println(dp[1-X][0]);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main()
{
  long long x,a,b;
  cin >>x>>a>>b;
  if(a>=b){
    cout<<"delicious"<<endl;
    return 0;
  }
  if(x>=b-a){
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256