akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1010

ll a[SIZE], b[SIZE], c[SIZE];

int main(){
  int X, Y, Z, K;

  cin >> X >> Y >> Z >> K;

  if(true){
    for(int i=0;i<X;i++) cin >> a[i];
    for(int i=0;i<Y;i++) cin >> b[i];
    for(int i=0;i<Z;i++) cin >> c[i];
  } else {
    for(int i=0;i<X;i++) a[i] = 1;
    for(int i=0;i<Y;i++) b[i] = 1;
    for(int i=0;i<Z;i++) c[i] = 1;
  }

  vector<ll> vec;

  for(int j=0;j<Y;j++){
    for(int k=0;k<Z;k++){
      vec.push_back(b[j] + c[k]);
    }
  }

  sort(vec.begin(), vec.end());

  ll l = 0, r = 3e10;

  while(l < r){
    ll mid = (l+r+1)/2;
    ll sum = 0;

    for(int j=0;j<X;j++){
      int v = vec.end() - lower_bound(vec.begin(), vec.end(), mid-a[j]);
      sum += v;
      if(sum >= K) break;
    }

    if(sum >= K){
      l = mid;
    }else{
      r = mid - 1;
    }
  }


  debug(l);

  vector<ll> ans;

  for(int i=0;i<X;i++){
    ll b;
    if(ans.size() >= K) b = l-a[i]+1;
    else b = l-a[i];

    auto it = lower_bound(vec.begin(), vec.end(), b);

    while(it != vec.end()){
      ans.push_back(*it + a[i]);
      it++;
    }

    debug(i);
  }

  sort(ans.begin(), ans.end(), greater<ll>());

  for(int i=0;i<K;i++)
    printf("%lld\n", ans[i]);

  return 0;
}


Measured memory_bytes: 10604
n = int(input())
s = input()
ans = len(s)
wc = 0
ec = s.count('E')
for i in range(len(s)):
  if (s[i] == 'E'):
    ec -= 1
  if (ans > ec + wc):
    ans = ec + wc
  if (s[i] == 'W'):
    wc += 1
print(ans)

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    string s,key="keyence";
    cin>>s;
    auto solve=[&](int l){
        int r=0;
        while(l+r<s.size()){
            string t=s;
            t.erase(l,r);
            if(t==key){
                cout<<"YES"<<endl;
                return true;
            }
            r++;
        }
        return false;
    };
    rep(i,s.size()){
        if(solve(i)){
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

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

int main()
{
    string s;
    cin >> s;

    string ans;

    for(size_t i = 0; i < s.size(); i++)
    {
        char key = s[i];
        if (key == '0')
        {
            ans.push_back('0');
        }
        else if(key == '1')
        {
            ans.push_back('1');
        }
        else
        {
            if (ans.size() != 0)
                ans.pop_back();
        }
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

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 char newl = '\n';

ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans*=a;a*=a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mod){ll ans=1;do{if(b&1)ans=ans*a%mod;a=a*a%mod;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> hs;
    vector<ll> blacklist;
    rep(i, n) {
        ll h;
        cin >> h;
        hs.push_back(h);
    }
    map<ll, ll> mp;
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        ll ha = hs[a-1];
        ll hb = hs[b-1];
        if (ha <= hb) {
            mp[a-1] += 1;
        }
        if (hb <= ha) {
            mp[b-1] += 1;
        }
    }

    int cnt = 0;
    rep(i, n) {
        if (mp[i]) {
            cnt++;
        }
    }

    cout << n - cnt << newl;


    return 0;
}


Measured memory_bytes: 9976
# -*- coding: utf-8 -*-
import math
n, k = map(int, input().split())

prop = 0.0
_prop = 0.0

if n >= k:
    _prop = (n - k) / n

end = min(n, k) + 1
for i in range(1, end):
    dest = k / i
    coin = math.ceil(math.log2(dest))
    __prop = (1 / n) * (1 / pow(2, coin))
    prop += __prop

print(prop + _prop)


Measured memory_bytes: 3060
while True:
    ans = 0
    t = list(int(x) for x in input().split())
    if t[0] == 0:
        break
    for i in t:
        if i >= 11:
            ans += 10
        else:
            ans += i
    if 1 in t:
        if ans + 10 <= 21:
            ans += 10
    if ans > 21:
        ans = 0
    print(ans)


Measured memory_bytes: 5604
// copied and pasted by #2956807(FlatHarvest)
#include <stdio.h>
#include <math.h>

int main()
{
    int D, G;
    int p[10], c[10], s[10], N;
    int max, sum, n, min;
    int i, j;
    scanf("%d %d",&D, &G);

    for(i=0; i<D; i++) {
        scanf("%d %d",&p[i], &c[i]);
        s[i] = 100*(i+1)*p[i] + c[i];
        N += p[i];
    }

    for(i=0; i<(1<<D); i++) {
        sum = n = 0;
        for(j=0; j<D; j++) {
            if(i & (1<<j)) {
                sum += s[j];
                n += p[j];
            } else {
                max = j;
            }
        }
        min = N;
        if(G-sum<=0 && n<N)
            N = n;
        if(G-sum>0) {
            for(j=0; j<D; j++) {
                if(!(i&(1<<j))) {
                    int k = ceil((G-sum)/100./(j+1));
                    if(k<min && k<p[j]) {
                        min = k;
                    }
                }
            }
        }
        if(min<N && n+min<N) {
            N = n + min;
        }
    }
    printf("%d",N);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++) b[i]=k-q;
	for(int i=1;i<=q;i++)
	{
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int H, W, N;
char original_field[30][31];
char field[30][31];
int del_field[30][30];

int dh[] = {1, 0};
int dw[] = {0, 1};

inline bool in_field(int h, int w){
    return 0<=h&&h<H && 0<=w&&w<W;
}

bool vanish(){
    //?¶?????????????true?????????
    memset(del_field, 0, sizeof(del_field));
    
    bool updated = false;
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            if(field[h][w] == '.') continue;
            
            char color = field[h][w];
            for(int d=0; d<2; d++){
                if(del_field[h][w]>>d&1) continue;
                
                int l = 1;
                while(in_field(h+dh[d]*l, w+dw[d]*l) && field[h+dh[d]*l][w+dw[d]*l] == color) l++;
                if(l < N) continue;
                
                for(int i=0; i<l; i++){
                    del_field[h+dh[d]*i][w+dw[d]*i] |= 1<<d;
                    updated = true;
                }
            }
        }
    }
    
    if(updated)
        for(int h=0; h<H; h++)
            for(int w=0; w<W; w++)
                if(del_field[h][w])
                    field[h][w] = '.';
    
    return updated;
}

void down(){
    for(int w=0; w<W; w++){
        int top = -1;
        for(int h=H-1; h>=0; h--){
            if(field[h][w] == '.') continue;
            if(top >= 0)
                top--;
            else{
                int hi = h+1;
                while(hi < H && field[hi][w] == '.') hi++;
                top = hi-1;
            }
            swap(field[top][w], field[h][w]);
        }
    }
}

bool check(){
    down();
    while(vanish())
        down();
    
    for(int h=0; h<H; h++)
        for(int w=0; w<W; w++)
            if(field[h][w] != '.')
                return false;
    
    return true;
}

string solve(){
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int nh = i, nw = j+1;
            if(!in_field(nh, nw)) continue;
            
            memcpy(field, original_field, sizeof(original_field));
            swap(field[i][j], field[nh][nw]);
            if(check())
                return "YES";
            
        }
    }
    return "NO";
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.precision(16);
    
    scanf("%d%d%d", &H, &W, &N);
    for(int i=0; i<H; i++)
        scanf("%s", original_field[i]);
    
    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  
  for(i=sx;i<tx;i++)cout<<"R";
  for(i=sy;i<ty;i++)cout<<"U";
  for(i=sx;i<tx;i++)cout<<"L";
  for(i=sy;i<ty;i++)cout<<"D";
  cout<<"D";
  for(i=sx;i<=tx;i++)cout<<"R";
  for(i=sy;i<=ty;i++)cout<<"U";
  cout<<"LU";
  for(i=sx;i<=tx;i++)cout<<"L";
  for(i=sy;i<=ty;i++)cout<<"D";
  cout<<"R"<<endl;
}


Measured memory_bytes: 256
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $route=[];
  $uf = new UnionFind($n);

  for ($i=0; $i<$m; $i++) {
    list($a, $b) = explode(" ", trim(fgets(STDIN)));
    $uf->unite($a,$b);
  }

  $x=[];
  for ($i=1; $i<=$n; $i++){
    $x[$uf->root($i)]=true;
  }

  echo count($x)-1;

class UnionFind {
    public $d = [];
    function __construct($n){
      for($i=1;$i<=$n;$i++){
        $this->d[$i] = -1;
      }
    }
    function unite($x, $y){
      $rx = $this->root($x);
      $ry = $this->root($y);
      if($rx == $ry) return;
      //echo $rx." ".$ry." ";
      if($this->size($rx) > $this->size($ry)){
        $this->d[$rx]+= $this->d[$ry];
        $this->d[$ry] = $rx;
        //echo $this->d[$rx].PHP_EOL;
      }else{
        $this->d[$ry]+= $this->d[$rx];
        $this->d[$rx] = $ry;        
        //echo $this->d[$ry].PHP_EOL;
      }
    }
    function root($x){
      //echo $x.PHP_EOL;
      if($this->d[$x] < 0){
        return $x;
      }
      return $this->d[$x] = $this->root($this->d[$x]);
    }
    function size($x){
      return $this->d[$this->root($x)]*-1;
    }
    function isSame($x, $y){
      return $this->root($x) == $this->root($y);        
    }
  }

Measured memory_bytes: 25596
import sys, collections

def dfs(i, c, col, edge):
    col[i] = c
    for next_node in edge[i]:
        if col[next_node] == c: return False
        if col[next_node] == 0 and dfs(next_node, -c, col, edge) == False: return False

    return True

def longest(i, edge, N):
    q = collections.deque()
    q.append((i, 1))
    dist = dict()
    ans = 1
    for j in range(N): dist[j] = -1
    flag = True
    while q:
        nn, nd = q.popleft()
        if dist[nn] == -1:
            ans = max(nd, ans)
            dist[nn] = nd
            for next_node in edge[nn]:
                if dist[next_node] == -1: q.append((next_node, nd + 1))
                elif abs(dist[next_node] - nd) != 1: flag = False
        elif dist[nn] != nd:
            ans = -1
            break
    #print(i, dist)
    return (ans if flag else -1)

def solve():
    N = int(input())
    edge = dict()
    col = dict()
    for i in range(N): 
        edge[i] = set()
        col[i] = 0
        s = input()
        for j in range(N):
            if s[j] == "1": edge[i] |= {j}

    is_bipartite = dfs(0, 1, col, edge)
    if not is_bipartite: print(-1)
    else:
        ans = -1
        for i in range(N):
            ans = max(ans, longest(i, edge, N))
        print(ans)

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 5052
while True:
    try:
        xA,yA,xB,yB,xC,yC,xD,yD = map(float, raw_input().split())
        if abs((yB-yA)*(yD-yC) + (xB-xA)*(xD-xC)) < 1.e-10:
                print "YES"
        else:
            print "NO"
    except:
        break

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  cout << A.at(N-1)-A.at(0) << endl;
}

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

signed main() {
  int n;
  cin>>n;
  int b[n-1];
  for(int i=0;i<n-1;i++)cin>>b[i];
  int ans=b[0];
  for(int i=1;i<n-1;i++){
    ans+=min(b[i-1],b[i]);

  }
  ans+=b[n-2];

   cout<<ans;
 


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    using namespace std;
     
    typedef long value_type; /* ソートするキーの型 */
     
    /* x, y, z の中間値を返す */
    value_type med3(value_type x, value_type y, value_type z) {
        if (x < y) {
            if (y < z) return y; else if (z < x) return x; else return z;
        } else {
            if (z < y) return y; else if (x < z) return x; else return z;
        }
    }
     
    /* クイックソート
     * a     : ソートする配列
     * left  : ソートするデータの開始位置
     * right : ソートするデータの終了位置
     */
    void quicksort(value_type a[], long left, long right) {
        if (left < right) {
            long i = left, j = right;
            value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2 ではオーバーフローしてしまう */
            while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
                while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
                while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
                if (i >= j) break;
                tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i], a[j] を交換 */
                i++; j--;
            }
            quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
            quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
        }
    }
     
    int main(){
      
      long N; cin >> N;
      long *d;
      d = (long *)malloc(N * sizeof(long));
      for(long i=0; i<N; i++) cin >> d[i];
      quicksort(d, 0, N-1);
      cout << d[N/2] - d[N/2 - 1] << endl;
      return 0; 
      
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1e9 + 7;
typedef long long ll;

long long kaijyo(long long n, long long m) {
    long long r = 1LL;
    while (n)
    {
        r = (r * n) % m;
        n--;
    }
    return r;
}

class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll n, m;
        in >> n >> m;
        ll ans = 0;
        if (abs(n - m) < 2) {
            ans = 1;
            ans = (ans * kaijyo(n, MOD)) % MOD;
            ans = (ans * kaijyo(m, MOD)) % MOD;
            ans = (ans * (abs(n - m) == 1 ? 1 : 2)) % MOD;
        }
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}

#include <fstream>
#include <iostream>

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MOD 1000000007

int fastPowSca(long long x, long long n) {
	long long prod = 1;

	while (n) {
		if (n & 1) {
			prod *= x;
			prod %= MOD;
		}
		x *= x;
		x %= MOD;

		n >>= 1;
	}

	return prod;
}

int main(void) {
	int m, n;

	scanf("%d %d", &m, &n);

	printf("%d\n", fastPowSca(m, n));

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n,m;
    cin >> n >> m;
    vector<ll> h(n,0);
    rep(i,n)cin >> h[i];
    vector<vector<ll>> graph(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        if(find(graph[a-1].begin(),graph[a-1].end(),b-1) == graph[a-1].end())graph[a-1].push_back(b-1);
        if(find(graph[b-1].begin(),graph[b-1].end(),a-1) == graph[b-1].end())graph[b-1].push_back(a-1);
    }
    ll ans = 0;
    rep(i,n){
        bool t = true;
        if(graph[i].size() == 0){
            ans++;
            continue;
        }
        for(auto g : graph[i]){
            if(h[i] <= h[g]){
                t = 0;
                break;
            }
        }
        if(t)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9860
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;
    int n = sz(s);
    if (n == 2) {
        if (s[0] == s[1]) cout<<1<<" "<<2<<endl;
        else cout<<-1<<" "<<-1<<endl;
        return 0;
    }
    rep(i, n - 2) {
        if (s[i] == s[i + 1] || s[i] == s[i + 2]) {
            cout<<i + 1<<" "<<i + 3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

input_line = sys.stdin.readline()

n = int(input_line)
S = []

if n==0:
	print("")
	quit()

for i in range(n):
	input_line = sys.stdin.readline()
	S.append(input_line)

used_list = []
used_count = {}
maxLength = 0
for mojiretsu in S:
	_used_dict = {}
	if len(mojiretsu) > maxLength :
		maxLength = len(mojiretsu)
	for moji in mojiretsu:
		if not moji in _used_dict:
			_used_dict[moji] = 0
		if _used_dict[moji] == 0:
			if not moji in used_count:
				used_count[moji] = 0
			used_count[moji] += 1
			_used_dict[moji] = 0
		_used_dict[moji] += 1

	sorted(_used_dict.items(), key=lambda x:x[1], reverse=True)
	used_list.append(_used_dict)

used_flags = []
mojiKeys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm','n','o','p','q','r','s','t','u','v','w','x','y','z']

i = 0
candidates = {}
for alpha in mojiKeys:
	if alpha in used_count and used_count[alpha] == n:
		candidates[alpha] = 0
		minimum = maxLength
		for used in used_list:
			if used[alpha] < minimum :
				minimum = used[alpha]
		candidates[alpha] = minimum

output = ""

for i in range(len(mojiKeys)):
	if not mojiKeys[i] in candidates:
		continue
	for j in range(candidates[mojiKeys[i]]):
		output += mojiKeys[i]

print(output)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	vector<int> p(n);
	for (int i=0; i<n; i++)
		cin>>p[i];
	sort (p.begin(),p.end());
	int ret=0;
	for (int i=0; i<k; i++)
		ret+=p[i];
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
vector<int>v[100009];
int dp[100009];
int dfs(int nod)
{
    int &ret=dp[nod];
    if(ret!=-1)return ret;
    ret=0;
    for(int i=0;i<v[nod].size();i++)
    {
        int x=v[nod][i];
        ret=max(ret,dfs(x)+1);
    }
    return ret;
}
int n,m,x,y,ans;
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;
        y--;
        v[x].push_back(y);
    }
    for(int i=0;i<n;i++)
    {
        ans=max(ans,dfs(i));
    }
    cout<<ans;
}


Measured memory_bytes: 8192
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
        
        scanf("%d", & S);

        h=S/3600;
        S=S%3600;
        m=S/60;
        s=S%60;

        printf("%d:%d:%d\n", h, m, s );

        return 0;
}

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

using namespace std;

typedef	unsigned long long	ull;

int main(){
	int f[128];
	for(int i='0';i<='9';i++)	f[i]=i-'0';
	for(int i='A';i<='Z';i++)	f[i]=i-'A'+10;

	int base;
	string s;
	for(;cin>>base>>s,base;){
		ull num=0;
		for(int i=0;i<s.length();i++)	num=num*base+f[s[i]];

		const int p[]={31,29,23,19,17,13,11,7,5,3,2};
		int pcnt[11]={};
		for(int b=base,i=0;b>1;){
			if(b%p[i]==0)	b/=p[i],pcnt[i]++;
			else	i++;
		}

		ull zcnt=1ULL<<63;
		for(int i=0;i<11;i++){
			if(pcnt[i]>0){
				ull num2=num,zcnt2=0;
				while(num2)	zcnt2+=num2/p[i],num2/=p[i];
				zcnt=min(zcnt,zcnt2/pcnt[i]);
			}
		}
		cout<<zcnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 928
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

string s;

int main() {
	cin >> s;
	if (s[0] == s[s.size() - 1]) {
		if (s.size() % 2 == 1) {
			cout << "Second\n";
		}
		else {
			cout << "First\n";
		}
	}
	else {
		if (s.size() % 2 == 0) {
			cout << "Second\n";
		}
		else {
			cout << "First\n";
		}
	}
	return 0;
}




Measured memory_bytes: 512
n,k=map(int,input().split())
sunuke=[0 for i in range(n)]
for i in range(k):
    d=int(input())
    alist=list(map(int,input().split()))
    for i in alist:
        sunuke[i-1]+=1
ans=0
for i in sunuke:
    if i==0:
        ans+=1
print(ans)

Measured memory_bytes: 67588
#include<cstdio>
#include<algorithm>

const int MAX_N = 200000;
int C[MAX_N];
typedef std::pair<int, int> P;
P sorted[MAX_N];
int dp[MAX_N];
int prev_index[MAX_N];

int main() {
	int n;
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &C[i]);
		sorted[i] = P(C[i], i);
	}
	std::sort(sorted, sorted + n);
	for(int i=0,x=-1,pre;i<n;i++) {
		P p = sorted[i];
		if(x < p.first) {
			x = p.first;
			prev_index[p.second] = -1;
		} else {
			prev_index[p.second] = pre;
		}
		pre = p.second;
	}
	dp[0] = 1;
	for(int i=1;i<n;i++) {
		if(prev_index[i] == -1 || prev_index[i] == i-1) {
			dp[i] = dp[i-1];
		} else {
			dp[i] = (dp[i-1] + dp[prev_index[i]]) % 1000000007;
		}
	}
	printf("%d\n", dp[n-1]);
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define inf (long long)(1e17)
#define fi first
#define se second
using namespace std;
using P = pair<long long, long long>;

long long n, x, d;
map<long long, vector<P>> mp;

long long solve();

int main() {
  cin >> n >> x >> d;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  if(d == 0) {
    if(x != 0) return n + 1;
    return 1;
  }
  if(d < 0) {
    d *= -1;
    x *= -1;
  }
  long long ans = 0;
  for(long long i = 0; i <= n; ++i) {
    long long nowmod = (i * x) % d, now = (i * x) / d,
              firstnum = (long long)i * (i - 1) / 2,
              lastnum = (n - 1) * i;
    lastnum -= firstnum;
    mp[nowmod].push_back({firstnum + now, lastnum + now});
  }
  for(auto now : mp)
    if(now.se.size() != 0) {
      vector<P> v = now.se;
      sort(v.begin(), v.end());
      long long vsize = v.size(), nowl = v[0].fi,
                nowr = v[0].se;
      for(long long i = 1; i < vsize; ++i) {
        if(nowr < v[i].fi) {
          ans += nowr - nowl + 1;
          nowl = v[i].fi;
          nowr = v[i].se;
        }
        else
          nowr = max(v[i].se, nowr);
      }
      ans += nowr - nowl + 1;
    }
  return ans;
}

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

int A[12][12];
int n,m,x;
int C[12];

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

    int res = 1e9;

    cin >> n >> m >> x;

    for(int i=0;i<n;i++)
    {
    	cin >> C[i];
    	for(int j=0;j<m;j++)
    	{
    		cin >> A[i][j];
    	}
    }

    for(int i=1;i<(1<<n);i++)
    {
    	int sum = 0;
    	int a[12];
    	memset(a,0,sizeof(a));
    	for(int j=0;j<n;j++)
    	{
    		if((i&(1<<j)))
    		{
    			sum += C[j];
    			for(int k=0;k<m;k++)
    			{
    				a[k] += A[j][k];
    			}
    		}
    	}
    	bool ok = true;
    	for(int j=0;j<m;j++)
    	{
    		if(a[j] < x)
    		{
    			ok = false;
    		}
    	}
    	if(ok)
    	{
    		res = min(res,sum);
    	}
    }

    if(res==1e9)
    {
    	res = -1;
    }

    cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	double l;
	cin>>l;
	cout<<fixed<<setprecision(15);
	cout<<(l/3)*(l/3)*(l/3)<<endl;
	
	return 0;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

    int N,W;
    cin>>N>>W;

    int w[N], v[N];
    for(int i=0;i<N;i++) {
        cin>>w[i]>>v[i];
    }
    int dp[W+1][N+1];
    memset(dp, 0, sizeof(dp));
    for(int i=0;i<=W;i++) {
        for(int j=1;j<=N;j++) {
            if(i-w[j-1]>=0) {
                dp[i][j]=max(dp[i][j-1], dp[i-w[j-1]][j-1]+v[j-1]);
            }
            else {
                dp[i][j]=dp[i][j-1];
            }
        }
    }

    cout<<dp[W][N];

    return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool solve(ll A, ll B, ll C, ll D){
    if(A < B) return false;
    if(D < B) return false; 
    if(B <= C) return true;
    ll g = __gcd(B, D);
    C -= A - 1, B -= A;
    return C / g == B / g;
}

int main(){
    int T;
    cin >> T;
    for(int i = 0; i < T; i++){
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        cout << (solve(A, B, C, D) ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, k;
int arr[(int)1e5 + 4];
long long dp[int(1e5) + 4];

long long solve(int index)
{
    if(index == n - 1)
        return 0;
    long long &ret = dp[index];
    if(~ret)
        return ret;
    ret =  1e9 + 7;
    for(int i = 1; i <= k && index + i < n; i++)
        ret = min(ret, solve(index + i) + abs(arr[index] - arr[index + i]));
    return ret;
}

int main()
{
    IO;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0);
    return 0;
}


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

using namespace std;

void solve()
{
	int n;
	string s;
	cin >> n >> s;
	vector<int> xs(n+1);
	for (int i = 0; i < n; i++)
	{
		xs[i+1] += xs[i] + (s[i] == '#');
	}
	int ans = min(n-xs[n], xs[n]);
	for (int i = 1; i <= n; i++)
	{
		ans = min(ans, xs[i]+n-i-(xs[n]-xs[i]));
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1412
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  int64_t ac = 0;
  int64_t wa = 0;
  int64_t tle = 0;
  int64_t re = 0;
  for (int64_t i = 0; i < N; ++i) {
    string a;
    cin >> a;
    if (a == "AC") {
      ++ac;
    } else if (a == "WA") {
      ++wa;
    } else if (a == "TLE") {
      ++tle;
    } else {
      ++re;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, a[210], res, ans;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            ans++;
        } if (ans > 0 && a[i] != a[i + 1]) {
            res += (ans + 1) / 2;
            ans = 0;
        } if (ans > 0 && i == n - 2) {
            res += (ans + 1) / 2;
        }
    }
    cout << res << endl;
}


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

int main(){
    map <string,long> data;
    long count=0;
    long n;
    cin>>n;
    for (int i=0; i<n; i++){
        string s;
        cin>>s;
    
        if (data[s]==0) {
            data[s]+=1;
            count+=1;
        }
    }
    cout<<count<<endl;
}

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

int main(){
  int K;
  cin >> K;
  vector<int> cnt(K+1, 0);
  FOR(a, 1, K+1){
    FOR(b, 1, K+1){
      cnt[gcd(a,b)]++;
    }
  }
  ll sum = 0;
  FOR(c, 1, K+1){
    FOR(ab, 1, K+1){
      sum += cnt[ab] * gcd(ab, c);
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
ll n,k,w[100005];

bool func(ll P) {
    ll cnt=0;
    ll sum=0;
    rep(i,n) {
        if(w[i]>P) return false;
        if(sum+w[i]>P) {
            sum=0;
            cnt++;
        }
        sum+=w[i];
    }
    return cnt<k;
}

int main() {
    cin>>n>>k;
    rep(i,n) cin>>w[i];

    ll l=0,r=10e18;
    while(r-l>1) {
        ll mid=(l+r)/2;
        if(func(mid)) r=mid;
        else l=mid;
        // cout<<l<<","<<r<<endl;
    }
    cout<<r<<endl;

    return 0;
}

Measured memory_bytes: 1936
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N;
    cin>>N;
    vi a(N);
    REP(i,N)cin>>a[i];
    ll con=1;
    ll prev=0;
    REP(i,N){
        if(prev==a[i])con++;
        else{
            ans+=con/2;
            con=1;
        }
        prev=a[i];
    }
    ans+=con/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

const INFINITY = math.MaxInt64/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	k := stdin.ReadInt()
	n := stdin.ReadInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = stdin.ReadInt()
	}

	ans := a[n-1] - a[0] // 時計回り
	for i := 0; i < n-1; i++ {
		t := a[i] + (k - a[i+1]) // 反時計回り
		ans = Min(ans, t)
	}
	stdout.Println(ans)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}


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

int main(){

  string s[10];

  while(cin >> s[0]){
    for(int i=1;i<8;i++) cin >> s[i];

    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){

	if(s[i][j] == '1'){
	  if(s[i][j+1] == '1' && s[i+1][j] == '1' && s[i+1][j+1] == '1') cout << 'A' << endl;
	  else if(s[i+1][j] == '1' && s[i+2][j] == '1' && s[i+3][j] == '1') cout << 'B' << endl;
	  else if(s[i][j+1] == '1' && s[i][j+3] == '1' && s[i][j+3] == '1') cout << 'C' << endl;
	  else if(s[i+1][j-1] == '1' && s[i+1][j] == '1' && s[i+2][j-1] == '1') cout << 'D' << endl;
	  else if(s[i][j+1] == '1' && s[i+1][j+1] == '1' && s[i+1][j+2] == '1') cout << 'E' << endl;
	  else if(s[i+1][j] == '1' && s[i+1][j+1] == '1' && s[i+2][j+1] == '1') cout << 'F' << endl;
	  else if(s[i][j+1] == '1' && s[i+1][j-1] == '1' && s[i+1][j] == '1') cout << 'G' << endl;
	}

      }
    }
  }
}

Measured memory_bytes: 1180
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
    int N, A;
    cin >> N >> A;

    N %= 500;

    if (N <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	bool ans = true;
	for (int ii = 0; ii < s.size(); ++ii){
		if (s[ii] != t[ii]){
			ans = false;
		}
	}

	if (ans){
	cout << "Yes" << "\n";
	} else {
	cout << "No" << "\n";

	}


	return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 200100;
int n,k;
int t[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> k;
  R(i,n){
    cin >> t[i];
  }
  int ilns = 0;
  set<int> secik;
  int nic = 0;
  R(i,k-1){
    if(t[i+1] < t[i])
      ilns ++;
  }
  R(i,k){
    secik.insert(t[i]);
  }
  int res = n - k + 1;
  R(i,n-k + 1){
    if(ilns == 0) nic ++;
    if(i != n - k){
      if(t[i] == *secik.begin() && *secik.rbegin() <= t[i+k]){
        if(ilns != 0)
          res--; 
      }
      secik.erase(t[i]);
      secik.insert(t[i+k]);
      if(t[i+1] < t[i]){
        ilns--;
      }
      if(t[i+k] < t[i+k-1])
        ilns++;
    }
  }
  debug(res,nic);
  if(nic > 1)res -= nic - 1;
  cout << res << "\n";
}


Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
    long sum = 0;
    long fra[10000];
    int n;
     
    //??????'n'?????\???
    cin >> n;
     
    //??????fra[]???????????£??\???????¨????sum?????????
    for(int i = 0; i < n; i++){
        cin >> fra[i];
        sum = sum + fra[i];
    }
     
    while(1){
        int flag = 0;
    //???????????¬???
        for(int i = 0; i < n; i++){
            if(fra[i-1] > fra[i] && i > 0 && i < n){
                swap(fra[i-1],fra[i]);
            }
        }
    //???????????????
        int count = 0;
        for(int i = 0; i < n; i++){
            if(fra[i-1] <= fra[i] && i > 0 ){
                count++;
            } 
            if(count == n-1){
                flag = 1;
            }
        }
         
        if(flag == 1)break;
    }
     
    cout << fra[0] << " " << fra[n-1] << " " << sum << endl;
     
    return 0;
}

Measured memory_bytes: 3188
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,y,a,b,c;
    cin>>n>>y;
    for(a=0;a<=y/10000;a++){
        for(b=0;b<=y/5000;b++){
            c=n-a-b;
            if(c>=0 && a*10000+b*5000+c*1000==y){
                cout<<a<<' '<<b<<' '<<c;
                return 0;
            } 
        }
    }
    cout<<"-1 -1 -1";
    return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 2e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int a, b;   cin >> a >> b;
    if(a == b)  cout << "Draw";
    else if(b != 1 && (a == 1 || (a > b))) cout << "Alice";
    else if(b == 1 || b > a)    cout << "Bob";
}


Measured memory_bytes: 256
k = int(input())

def calc_dp(n):
    if(n==0):
        return 0

    s = str(n)
    slen = len(s)
    dp = [[0] * 12 for _ in range(slen)]
    dp_o = [[0] * 12 for _ in range(slen)]

    #initial
    for i in range(1,int(s[0])):
        dp[0][i+1] = 1
    dp_o[0][int(s[0])+1] = 1

    #update
    for i in range(slen-1):
        for j in range(1,11):
            dp[i+1][j] = dp[i][j-1] + dp[i][j] + dp[i][j+1] +1
        dp[i+1][1] -= 1

        s_b = int(s[i])
        s_n = int(s[i+1])

        for j in range( max(0,s_b-1), min(10, s_b+2)  ):
            if(j < s_n ):
                dp[i+1][j+1] += dp_o[i][s_b+1]
            elif(j == s_n):
                dp_o[i+1][j+1] += dp_o[i][s_b+1]

    ans = 0
    for i in range(1,11):
        ans += dp[-1][i] + dp_o[-1][i]

    return ans

min_ = 0
max_ = 3234566676


for i in range(100):
    tmp = (min_+max_)//2
    tmp_c = calc_dp(tmp)
    if(k > tmp_c):
        min_ = tmp
    else:
        max_ = tmp

    if(max_ - min_ == 1 ):
        break

print(max_)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll n,a[5], i,ans=0,mi=1e+17;
	cin >> n;
	for (i = 0; i < 5; i++)
		cin >> a[i];
	for (i = 0; i < 5; i++)
		mi = min(mi, a[i]);
	ans = (n - 1) / mi + 5;
	cout <<ans << endl;
}

Measured memory_bytes: 5500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc_061
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = new int[n[0]];
            for (int i = 0; i < n[1]; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                a[x[0] - 1]++;
                a[x[1] - 1]++;
            }
            for (int i = 0; i < n[0]; i++)
            {
                Console.WriteLine(a[i]);
            }
            Console.ReadLine();
        }
    }
}


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

typedef long long ll;

using namespace std;

int main() {
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    q *= 8, h *= 4, s *= 2;
    cout << min({q, h, s, d}) * (n / 2) + min({q, h, s}) / 2 * (n % 2) << endl;
    return 0;
}


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

int const N = 1e5+1, M = 1e4, mod = 1e9+7;
char c[1001][1001];
int n,m;
ll dp[1001][1001];
vector<pair<int,int> > g ;

int main(){
   cin >> m >> n ;
   for(int i=1;i<=m;++i){
      for(int j=1;j<=n;++j){
         cin >> c[i][j];
         if(c[i][j] == '#')dp[i][j]=-1;
      }
   }
    if(dp[1][1]!=-1)
    dp[1][1]=1;
    for(int i=1;i<=m;i++) {
        for(int j=1;j<=n;j++) {
            if(dp[i][j]==-1) {
                dp[i][j]=0;
                continue;
            }
            if(i==1 && j==1)
                continue;
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[m][n];
} 

Measured memory_bytes: 9088
s = list(input())
def kaibun(a):
    l = len(a)
    
    
    for _ in range(l//2):
    
        if a[_] != a[l - _ - 1]:
            return False
    return True
    

if kaibun(s):
    ss = list()
    for __ in range(len(s)//2):
        ss += s[__]

    if kaibun(ss):
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3060