akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 1001001001001001LL;

int main()
{
	int w, h, n;
	scanf("%d %d %d", &w, &h, &n);
	
	vector<int> X, Y, tX, tY;
	for (int i = 0; i < n; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		X.push_back(x); tX.push_back(x);
		Y.push_back(y); tY.push_back(y);
	}
	
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	
	LL resd = INF;
	int resx, resy;
	for (int i = n / 2 - !(n % 2); i <= n / 2; i++){
		for (int j = n / 2 - !(n % 2); j <= n / 2; j++){
			LL sum = 0;
			LL maxi = 0;
			for (int k = 0; k < n; k++){
				LL d = abs(tX[k] - X[i]) + abs(tY[k] - Y[j]);
				sum += d * 2;
				maxi = max(maxi, d);
			}
			sum -= maxi;
			
			if (resd > sum){
				resd = sum;
				resx = X[i];
				resy = Y[j];
			}
		}
	}
	
	printf("%lld\n%d %d\n", resd, resx, resy);
	
	return 0;
}

Measured memory_bytes: 2844
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) { cin >> A.at(i); }
    int ans = 0;
    REP(i, N) {
        while (A[i] % 2 == 0) {
            ans++;
            A[i] /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	int coin[m];
	for (int i=0;i<m;i++){
		cin >> coin[i];
	}
	sort(coin,&coin[m]);
	int map[n];
	for (int i=0;i<n;i++){
		map[i]=i+1;
		for(int j=0;j<m;j++){
			if(i+1<coin[j]){
				break;
			}else if(i+1==coin[j]){
				map[i]=1;
				break;
			}else{
				int temp=map[i-coin[j]]+1;
				if(map[i]>temp){
					map[i]=temp;
				}
			}
		}
	}
	cout << map[n-1] << endl;
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c;
    d = max(a,max(b,c));
    if(d==a){
        cout << 10*d+b+c << endl;
    }else if(d==b){
        cout << 10*d+a+c << endl;
    }else if(d==c){
        cout << 10*d+b+a << endl;
    }
    return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        int ii = i;
        for (int j = 2; j * j <= ii; j++) {
            while (ii % j == 0) {
                ii /= j;
                mp[j]++;
            }
        }
        if(ii > 1)mp[ii]++;
    }
    int ans = 1;
    for (auto x: mp) {
        ans = (ans * (x.second + 1)) % MOD;
    }
    cout << ans << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

int main(){
    int N, M;

    // Load inputs
    cin >> N;
    vector<int> T(N);
    for (int i=0; i < N; i++)
        cin >> T[i];
    cin >> M;
    vector<int> P(M);
    vector<int> X(M);
    for (int j=0; j < M; j++)
        cin >> P[j] >> X[j];

    // Preprocess
    int total_sum = 0;
    for (int i=0; i < N; i++)
        total_sum += T[i];
    
    // Output
    for (int j=0; j < M; j++)
        cout << total_sum - T[P[j]-1] + X[j] << endl ;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ').ToArray();
            Console.WriteLine(new Calu().calu(input));
        }
        
        public class Calu{
            public string calu(string[] s){
                if(s[0]==s[1])return "H";
                return "D";   
            }
        }
    }

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int>v;
	int a,b,n;cin>>n;
	while(n--){
		cin>>a;
		if(a==2)v.pop_back();
		else cin>>b;
		if(a==1)cout<<v[b]<<"\n";
		else if(a==0)v.push_back(b);
	}
	return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll s;
std::set<ll> set;

ll f(ll x){
    if(x % 2 == 0){
        return x / 2;
    }
    return x * 3 + 1;
}

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

    std::cin >> s;

    int m = 1;
    while(true){
        if(set.find(s) != set.end()){
            break;
        }

        m += 1;
        set.emplace(s);
        s = f(s);
    }

    std::cout << m << std::endl;
}


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

int main() {
    int N1, N2, sum = 0;
    cin >> N1;

    N2 = N1;
    while (N1 > 0) {
        sum += N1 % 10;
        N1 /= 10;
    }
    
    cout << (N2 % sum == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    vector<ll> a(N); rep(i,N) cin >> a[i];
    sort(all(a));

    vector<ll> sum(N+1,0);
    sum[0] = 0;
    rep(i,N){
        sum[i+1] = sum[i] + a[i];
    }

    rrep(i,N-1){
        if(a[i+1] > 2*sum[i+1]){
            cout << N-1-i << endl;
            return 0;
        }
    }

    cout << N << endl;
}


Measured memory_bytes: 1792
N = gets.to_i
c = (0..8).map{ 0 }
gets.split.map(&:to_i).each{ |r| c[[r,3200].min / 400] += 1 }
cc = c[0..7].count{ |a| a > 0 }
puts [ cc + (c[-1] > 0 ? 1 : 0) * (cc > 0 ? 0 : 1), cc + c[-1] ].join(" ")


Measured memory_bytes: 1788
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
 
using namespace std;
 
double EPS = 1e-10;
 
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}
 
  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }
 
  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
 
  point operator * (double d){
    return point(x*d,y*d);
  }
};
 
struct segment{
  point a,b;
};
 
double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}
 
double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}
 
int is_intersected_ls(point a1, point a2, point b1, point b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

int is_point_on_line(point a, point b, point c) {
  return cross(b-a, c-a)==0.0 &&
         (dot(b-a, c-a) > -EPS) &&
         (dot(a-b, c-b) > -EPS);
}

int inside(point p, point* ps, int n){
  segment t;
  t.a=t.b=p;
  t.b.x=DBL_MAX;
  ps[n]=ps[0];
  double ymx=-DBL_MAX,ymn=DBL_MAX;
  for(int i=0;i<n;i++){
    ymx=max(ymx,ps[i].y);
    ymn=min(ymn,ps[i].y);
  }
  if(t.a.y<=ymn||t.a.y>=ymx)return 0;

  int cnt1=0;
  for(int i=0;i<n;i++)
    if(is_point_on_line(t.a,t.b,ps[i]))cnt1++;
  
  int cnt=0;
  for(int i=0;i<n;i++)
    if(is_intersected_ls(ps[i],ps[i+1],t.a,t.b))cnt++;

  return (cnt-cnt1)%2;
}

int main(void){
  int n;
  point p[4],k,s;
 
  cin >> n;
  while(n--){

    for(int i=0;i<3;i++)
      cin >> p[i].x >> p[i].y;
     
    cin >> k.x >> k.y >> s.x >> s.y;

    if(inside(k,p,3)!=inside(s,p,3))cout << "OK" << endl;
    else cout << "NG" << endl;
     
  }
 
  return 0;
}

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

typedef unsigned long long ll;
typedef std::pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define All(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define ReAll(i, x) for(typeof(x.end()) i = x.end(); i != x.begin(); i--)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100000;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

vector<pair<ll, ll> > divisors(ll n) {
    vector<pair<ll, ll> > res;
    for(ll i = 1; i*i <= n; i++) {
        if(n % i != 0) continue;
		res.pb(make_pair(i, n/i));
		res.pb(make_pair(n/i, i));
    }
    return res;
}

void solve(){
	ll n, m; cin >> n >> m;
	vector<pair<ll, ll> > v = divisors(m);
	ll d = 0;
	Rep(i, v.size()){
		if(v[i].second >= n){
			d = max(d, v[i].first);
		}
	}
	cout << d << END;
}

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


Measured memory_bytes: 256
def rally(n , xl):

    ans = 0

    aaa = round(sum(xl) / n)

    for i in range(n):
        ans += (xl[i] - aaa)**2

    return ans

def main():
    n = int(input())
    xl = list(map(int , input().split()))
    print(rally(n , xl))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <string.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>

using namespace std;

char s[100005];

int main(void){
	int i,j,k;
	scanf("%s %d" ,s, &k);
	int len =strlen(s);
	for(i=0;i<len;i++){
		if (s[i] != 'a' && 'z' - s[i] + 1<= k){
			k-='z'-s[i] + 1;
			s[i]='a';
		}
	}
	s[len-1] = s[len-1] + k%26;
	printf("%s\n" ,s);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	ll sum=0;
	for(int i=1; ;i++){
		sum+=i;
		if(sum>=n){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

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

#define mod 1000000007
#define MAX_N 3000010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

int main() {
    GetInv(); GetFactorial();
    int x, y; cin >> x >> y;
    if (x < y) swap(x, y);
    int z = x - y;
    y -= z;
    if (y < 0 || y % 3) {
        cout << 0 << endl;
        return 0;
    }
    y /= 3;
    long long ans = combination(y*2+z, y+z);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;

long long ruijou(int n, int k){
    if(k==0) return 1;
    int x=k/2;
    long long t=ruijou(n,x);
    
    if(k%2==1) return n*t*t;
    else return t*t;
}

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
    int N;
    cin>>N;
    int ans=0;

    int p=GetDigit(N);
    if(p%2==0){
        p/=2;
        for(int i=0;i<p;i++) ans+=9*ruijou(100,i);
    }

    else if(p==1) ans=N;

    else{
        p/=2;
        for(int i=0;i<p;i++) ans+=9*ruijou(100,i);
        N-=ruijou(100,p);
        ans+=N;
        ans++;
    }

    cout<<ans<<endl;
}

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

int main(void) {
	
	int n;
	scanf("%d", &n);
	
	int* a, * ret;
	a = (int *)malloc(n * sizeof(int));
	ret = (int *)malloc(n* sizeof(int));
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	
	if(n%2==0){
		// if even
		for(int i=0;i<n;i++){
			if((i+1)%2 == 0){
				ret[n/2-1-i/2] = a[i];
			}
			else{
				ret[n/2+i/2] = a[i];
			}
		}
	}
	else{
		// if odd
		for(int i=0;i<n;i++){
			if((i+1)%2 ==0){
				ret[n/2+(i+1)/2] = a[i];
			}
			else{
				ret[n/2-(i+1)/2] = a[i];
			}
		}
	}
	
	for(int i=0;i<n-1;i++) printf("%d ",ret[i]);
	printf("%d",ret[n-1]);
	
	return 0;
}


Measured memory_bytes: 3712
package main

import "fmt"

func main () {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	max := Max{v: 0, index:n+1}
	max2 := Max{v:0 , index:n+1}
	for i := 0; i <n ; i++ {
		if max.v <= a[i] {
			max2 = max
			max = Max{v:a[i], index:i}
		} else if max2.v <= a[i] {
			max2 = Max{v:a[i], index:i }
		}
	}
	for i := 0; i < n; i++ {
		if i == max.index {
			fmt.Println(max2.v)
			continue
		}
		fmt.Println(max.v)
	}
}

type Max struct {
	v int
	index int
}


Measured memory_bytes: 6688
N=int(input())
h=list(map(int,input().split()))
dp=[0]*N
for i in range(N):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(h[1]-h[0])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])


Measured memory_bytes: 52208
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
        int oneyen=1*sc.nextInt();
        int fiveyen=5*sc.nextInt();
        int tenyen=10*sc.nextInt();
        int fiftyyen=50*sc.nextInt();
        int onehundredyen=100*sc.nextInt();
        int fivehundredyen=500*sc.nextInt();

        if (oneyen+fiveyen+tenyen+fiftyyen+onehundredyen+fivehundredyen>=1000){
            System.out.println(1);
        }else System.out.println(0);
    }
}

Measured memory_bytes: 17300
#include<iostream>
#include<stdio.h>
#include<ext/rope>
#include<vector>
using namespace std;
int p[300010],nex[300010],head[300010],e;
void add(int a,int b){
    p[e]=b;
    nex[e]=head[a];
    head[a]=e++;
}
int vis[300010],A[300010],B[300010],k;
int dfs(int u){
    vis[u]=-1;//cout<<6<<endl;
    int i,v;
    for(i=head[u];i;i=nex[i]){
        v=p[i];
        if(vis[v]==-1) return 0;
        if(vis[v]==0&&dfs(v)==0) return 0;
    }
    vis[u]=1;
    B[u]=k;
    A[k--]=u;
    return 1;
}

int fa[300010];
vector<int>g[300010];
int main(){
    int j,i,n,m,v,a,b;
    cin>>n>>m;
    k=n;
    e=1;
    for(i=1;i<n+m;i++){
        cin>>a>>b;
        add(a,b);
        g[b].push_back(a);
    }
    for(i=1;i<=n;i++) if(vis[i]==0) dfs(i);
    for(i=1;i<=n;i++){
        for(j=0;j<g[i].size();j++){
            v=g[i][j];
            if(fa[i]==0||B[v]>B[fa[i]]) fa[i]=v;
        }
    }
   // for(i=1;i<=n;i++) cout<<A[i]<<endl;

    //cout<<A[1]<<endl;
    for(i=1;i<=n;i++) cout<<fa[i]<<endl;
    //out<<fa[n]<<endl;
    return 0;


}



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

struct UnionFind{
// 同値関係をサポートするデータ構造
// 併合,所属する同値類の代表元: O(a(n)), 集合の分割はNG
// (a(n): アッカーマン関数A(m,n)について,f(n)=A(n,n)としたときの逆関数)
  vector<int> m_root;
  vector<int> m_size;

  UnionFind(int N)
  : m_root(N)
  , m_size(N,1)
  { iota(m_root.begin(), m_root.end(), 0); }

  int find(int a){
    if(m_root.at(a)==a){
      return a;
    }
    else{
      return m_root.at(a)= find(m_root.at(a));
    }
  }

  void unify(int a, int b){
    int r_a= find(a);
    int r_b= find(b);

    if(r_a != r_b){
      if(m_size.at(r_a) < m_size.at(r_b)){
        m_root.at(r_a)= r_b;
        m_size.at(r_b)+= m_size.at(r_a);
        return;
      }
      else{
        m_root.at(r_b)= r_a;
        m_size.at(r_a)+= m_size.at(r_b);
        return;
      }
    }
  }
  
  bool are_comrade(int a, int b){
    return find(a)==find(b);
  }

  int get_size(int a){
    return m_size.at(find(a));
  }
};

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

  vector<int> perm(N);
  for(int i=0; i<N; i++){
    cin >> perm.at(i);
    perm.at(i)--; // 1-indexed -> 0-indexed
  }

  UnionFind uf(N);
  int buf1,buf2;
  for(int j=0; j<M; j++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    uf.unify(buf1, buf2);
  }

  int ans= 0;
  for(int i=0; i<N; i++){
    if(uf.are_comrade(i, perm.at(i))){ ans++; }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n;
string s,s1,s2;
int main(){
  cin>>s;
  n=s.size();
  s1=s.substr(0,(n-1)/2);
  s2=s.substr((n+1)/2,(n-1)/2);
  if(s1!=s2)	 {cout<<"No";return 0;} 
	  
  for(int i=0;i<(n-1)/2;i++)
{
	if(s[i]!=s[(n-3)/2-i])
	 {cout<<"No";return 0;
	  } 
}
cout<<"Yes";
return 0;
}


Measured memory_bytes: 256
/**/
#pragma GCC optimize(3,"Ofast","inline")
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n, k, a[200005], dp1[21][200005], dp2[21][200005], bin[25], Log[200005];
bool vis[200005];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), dp1[0][i] = dp2[0][i] = a[i];
	bin[0] = 1, Log[0] = -1;
	for (int i = 1; i <= 20; i++) bin[i] = bin[i - 1] << 1;
	for (int i = 1; i <= n; i++) Log[i] = Log[i / 2] + 1;
	for (int i = 1; i <= Log[n]; i++){
		for (int j = 1; j + bin[i] - 1 <= n; j++){
			dp1[i][j] = max(dp1[i - 1][j], dp1[i - 1][j + bin[i - 1]]);
			dp2[i][j] = min(dp2[i - 1][j], dp2[i - 1][j + bin[i - 1]]);
		}
	}
	int ans = n - k + 1, f = 0;
	for (int i = 1, j; i <= n; i = j){
		j = i + 1;
		while(a[j] > a[j - 1] && j <= n) j++;
		if(j - i >= k){
			f = 1;
			for (int v = i + k - 1; v < j; v++) vis[v] = true, ans--;
		}
	}
	if(f) ans++;
	for (int i = k + 1; i <= n; i++){
		if(vis[i]) continue;
		int l = i - k, r = i;
		int t = Log[r - l + 1];
		int maxx = max(dp1[t][l], dp1[t][r - bin[t] + 1]);
		int minn = min(dp2[t][l], dp2[t][r - bin[t] + 1]);
		if(maxx == a[r] && minn == a[l]) ans--;
	}
	printf("%d\n", ans);

	return 0;
}
/**/

Measured memory_bytes: 33792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a,b;
ll ans;
ll A=1,B=1,C=1,D=1;
const ll MOD=1000000007;
ll modpow(ll a,ll n,ll MOD){
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%MOD;
        a=a*a%MOD;
        n>>=1;
    }
    return res;
}
ll modinv(ll a,ll MOD) {
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
    }
    u%=MOD; 
    if(u<0) u+=MOD;
    return u;
}
int main(void){
    cin>>n>>a>>b;
    ans=modpow(2,n,MOD)-1;
    for(int i=0;i<a;i++){
        A=(A*(n-i))%MOD;
        C=(C*(i+1))%MOD;
    }
    for(int i=0;i<b;i++){
        B=(B*(n-i))%MOD;
        D=(D*(i+1))%MOD;
    }
    C=modinv(C,MOD); D=modinv(D,MOD);
    ans=(ans-(A*C)%MOD-(B*D)%MOD)%MOD;
    if(ans<0) ans+=MOD;
    cout<<ans<<endl;


}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
int main(void)
{
    ll n;
    cin>>n;
    if (!(n & 1))
        return cout << (n) << ' ' << (n) << ' ' << (n / 2) << '\n',0;
    else
    {
        for (ll i = 1;i <= 4000;++i)
            for (ll j = 1;j <= 4000;++j)
            {
                ll A = (4 * i * j - n * (i + j));
                ll B = n * i * j;
                if (A != 0 && !(B % A))
                {
                    ll C = (B / A);
                    if (1 <= C && C <= 3500)
                        return cout << i << ' ' << j << ' ' << C << '\n',0;
                }
            }

    }
    return 0;
}


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

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

  long long ans = 1e18 + 9;
  if (y - x >= 0){
    ans = min(ans, y - x);
  }
  if (y + x + 1 >= 0){
    ans = min(ans, y + x + 1);
  }
  if (-y - x + 1 >= 0){
    ans = min(ans, -y - x + 1);
  }
  if (x - y + 2 >= 0){
    ans = min(ans, x - y + 2);
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	
	int n,x,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0)printf(" %d",i);
		else while(x>0){
				if(x%10==3){
					printf(" %d",i);
					break;
				}
				x/=10;
			}
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2108
import java.util.*;
public class Main{
	public static void main(String[]args){
    	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();int d=sc.nextInt();
        System.out.println(Math.max(a*b,c*d));
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b, c, d;
int main() {
    cin >> a >> b >> c >> d;
    int ans = max(0, min(b, d) - max(a, c));
    cout << ans << endl;
    return 0;
}


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

int dp[50001];

int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> c(m);
	for(auto &i:c)cin>>i;
	for(int i =0 ;i<50001;i++)
	{
		dp[i] = 1e9;
	}
	dp[0] = 0;
	for(int i = 0;i<m;i++)
	{
		for(int j= 0;j<=n;j++)
		{
			if(j-c[i]>=0)
			dp[j] = min(dp[j],dp[j-c[i]]+1);
		}
	}

	cout<<dp[n]<<endl;
}


Measured memory_bytes: 3296
#include<stdio.h>
 
int main( void ) 
{
 
    int n;
    scanf( "%d", &n );
    
    int i, j;
    int num[10000]; 
    int cnt = n;
    for( i=0; i<n; i++ ) {
        scanf( "%d", &num[i] );
    }
    for( i=0; i<n; i++ ) {    
        if( 2 == *(num+i) ) { continue; }
        
        if( 0 == *(num+i)%2 ) {
            cnt--;
            continue;
        }
        
        for( j=3; j*j<=*(num+i); j+=2 ) {
            if( 0 == *(num+i)%j ) {
                cnt--;
                break;
            }
        }
    }
     
    printf( "%d\n", cnt );
    
    return 0;
}

Measured memory_bytes: 632
# tle
# from copy import deepcopy
# s = list(input())
# a, b = map(int, input().split())
# def searchpath(pos, dir, st):
#     pos = deepcopy(pos)
#     dir = deepcopy(dir)
#     st  = deepcopy(st)
#     while len(st)>0:
#         i = st.pop(0)
#         if i == 'F':
#             if dir == 'r':
#                 pos = [pos[0]+1, pos[1]]
#             if dir == 'l':
#                 pos = [pos[0]-1, pos[1]]
#             if dir == 'u':
#                 pos = [pos[0], pos[1]+1]
#             if dir == 'd':
#                 pos = [pos[0], pos[1]-1]
#             if len(st) == 0 and pos == [a, b]:
#                 return 1
#         if i == 'T':
#             if dir == 'r' or dir == 'l':
#                 if searchpath(pos, 'u', st)==1 or searchpath(pos, 'd', st)==1:
#                     return 1
#             if dir == 'u' or dir == 'd':
#                 if searchpath(pos, 'r', st)==1 or searchpath(pos, 'l', st)==1:
#                     return 1
#             break;
#     return -1
# ans = searchpath([0,0], 'r', s)
# if ans == 1:
#     print('Yes' , flush=True)
# else:
#     print('No' , flush=True)


s = input().split('T')
a, b = map(int, input().split())

current_x = len(s[0])
current_y = 0

# for i in s[2::2]: # cant calculate order
for i in sorted([len(j) for j in s[2::2]])[::-1]:
    if current_x < a:
        current_x += i
    else:
        current_x -= i
for i in sorted([len(j) for j in s[1::2]])[::-1]:
    if current_y < b:
        current_y += i
    else:
        current_y -= i

if current_x==a and current_y==b:
    print('Yes', flush=True)
else:
    print('No', flush=True)
    
    


Measured memory_bytes: 68120
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e18;

signed main(){
    int n; cin >> n;
    REPS(i,3500) REPS(j,3500){
        if(4*i*j-n*i-n*j == 0) continue;
        if(n*i*j%(4*i*j-n*i-n*j) == 0 and n*i*j/(4*i*j-n*i-n*j) > 0){
            cout << i << " " << j << " " << n*i*j/(4*i*j-n*i-n*j) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long int LL;
int main(void)
{
	LL N,T,Q,house[100001],muki[100001];
	LL X[1001];
	LL list[100001];
	LL i,j;
	cin>>N>>T>>Q;
	for(i=1;i<=N;i++) cin>>house[i]>>muki[i];
	for(i=1;i<=Q;i++) cin>>X[i];
	for(i=N;i>=1;i--) {
		if(muki[i]==2) continue;
		if(i==N) list[i]=house[i]+T;
		else if(muki[i+1]==2) list[i]=min(house[i]+T,(house[i]+house[i+1])/2);
		else list[i]=min(house[i]+T,list[i+1]);
	}
	for(i=1;i<=N;i++) {
		if(muki[i]==1) continue;
		if(i==1) list[i]=house[i]-T;
		else if(muki[i-1]==1) list[i]=max(house[i]-T,(house[i]+house[i-1])/2);
		else list[i]=max(house[i]-T,list[i-1]);
	}
	for(i=1;i<=Q;i++) {
		cout<<list[X[i]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int a,b,c,d;
    cin  >> a >> b >> c >> d;
    if((a+b)>(c+d)){
        cout << "Left" << endl;
    }else if(a+b==c+d){
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;
    }
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b;
	int num,cost,times;
	num =a;
	times =b;
	cost = 999999;
	int tmp1,tmp2,flag;
	flag=0;
	c=d=-1;
	for(int i=0;i<num;i++){
		cin >> c >> d;
		if(times>=d && cost >=c){//コストの考え方がおかしい。最初が-1になっているのがよくない
		  cost=c;
		  tmp1=c;
		  tmp2=d;
		  flag=1;
		}
	}
	if(flag!=0){
	cout<< cost <<endl;
	}else{
		cout<<"TLE"<<endl;
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,x=0;
    cin>>n;

    int a[n];

    for(int i=0; i<n; i++){
        cin>>a[i];
        x^=a[i];
    }

    for(int i=0; i<n; i++){

        int y = x^a[i];
        cout<<y<<" ";
    }
    return 0;
}


Measured memory_bytes: 4368
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
#include <string>
#include <queue>
using namespace std;
typedef long long int ll;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n=s.size();
    if(ok(s)&&ok(s.substr(0,(n-1)/2))&&ok(s.substr((n+3)/2-1))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    const int INF=INT_MAX/2;
    int n=in(),m=in();
    vector<pii> a(m+1);
    rep(i,m){
        int x=in(),y=in();
        int res=0;
        rep(j,y){
            int z=in()-1;
            res+=1<<z;
        }
        a[i+1]=mp(x,res);
    }
    vector<vec> ans(m+1,vec(1<<n,INF));
    ans[0][0]=0;
    rep(i,m)rep(j,1<<n){
        ans[i+1][j]=ans[i][j];
        if((a[i+1].second & j))
            ans[i+1][j]=min(ans[i+1][j],ans[i][j-(j&a[i+1].second)]+a[i+1].first);
    }
    cout<<(ans[m][(1<<n)-1]==INF?-1:ans[m][(1<<n)-1])<<endl;
}

Measured memory_bytes: 16256
V,E = map(int,input().split())
dist = [[float("inf")]*V for _ in range(V)]
for i in range(E):
    s,t,d = map(int,input().split())
    dist[s][t] = d
dp = [[-1]*V for i in range(1<<V)] #dp[S][v]Sは訪れた町の集合vは今いる点

#訪れた集合がs、今いる点がvの時０に戻る最短経路
def rec(s,v,dp):
    if dp[s][v] >= 0:
        return dp[s][v]  #一度出てきたもの
        
    if s == (1<<V)-1 and v == 0:
        #全ての頂点を訪れた(s = 11...11 and v = 0)
        dp[s][v] = 0
        return 0
    
    res = float("inf")
    for u in range(V):
        if (s>>u&1) == 0:
            #uに訪れていない時(uの箇所が0の時),次はuとすると
            res = min(res,rec(s|(1<<u),u,dp)+dist[v][u])
            
    dp[s][v] = res
    return res
a = rec(0,0,dp)
if a == float("inf"):
    print(-1)
else:
    print(a)


Measured memory_bytes: 18788
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#define ll long long
using namespace std;

int JUDGE(int n)
{
    int a;
	a=0;
	while(n>0)
	{
		a=a*10+n%10;
		n=n/10;
	}
	return a;
}
int main()
{
    int a,b;
    while(~scanf("%d%d",&a,&b))
    {
        int m, sum=0;
        for(int i=a; i<=b; i++)
        {

           m=JUDGE(i);
            if(m==i)
                sum++;

        }
        cout<<sum<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        int prev = 0;
        int c = 0;
        for (int i = 0; i < n; i++) {
            int curr = sc.nextInt();
            if (curr <= prev) {
                if (max < ++c) {
                    max = c;
                }
            } else {
                c = 0;
            }
            prev = curr;
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 48048
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#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
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#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 << '\n'; }
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 fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int X[] = {-1, -1, -1, 0, 0, 1, 1, 1} ;
    int Y[] = { 0, -1,  1,-1, 1, 0, -1, 1} ;
    int n , m ;
    cin >> n >> m ;
    vector<vector<char> > v(n + 2, vector<char>(m + 2));
    for(int i = 1; i < n + 1; i++){
        for(int j = 1; j < m + 1; j++){
            cin >> v[i][j] ;
        }
    }
    for(int i = 1; i < n + 1; i++){
        for(int j = 1; j < m + 1; j++){
            if ( v[i][j] == '.' ) {
                int cnt = 0 ;
                for(int k = 0; k < 8; k++){
                    if ( v[i + X[k]][j + Y[k]] == '#' ) cnt++ ;
                }
                cout << cnt ;
            }
            else cout << '#' ;
        }
        cout << endl;
    }
    return 0; 
}


Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    unsigned long long n, ans = 0;
    std::cin >> n;
    for (unsigned long long i = 0; i <= n; ++i)
    {
        if (i % 3 != 0 && i % 5 != 0) { ans += i; }
    }

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n, m;
        in >> n >> m;
        ll ans = m * 1900 + (n - m) * 100;
        for (int i = 0; i < m; i++) {
            ans *= 2;
        }
        out << ans << '\n';
    }
};
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 <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

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

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(void){
  double r;
  cin >> r;
  cout << 2*r*M_PI << endl;
  return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;
const ll inf=(ll)1e16;
int n;
int k,q;
struct edge{
  int to,cost;
};
ll d[100001];
vector<edge> v[100001];

int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b,c;cin>>a>>b>>c;
    a--;b--;
    v[a].push_back((edge){b,c});
    v[b].push_back((edge){a,c});
  }
  cin>>q>>k;
  k--;
  priority_queue<pair<ll,int> > pq;
  for(int i=0;i<n;i++){
    d[i]=inf;
  }
  d[k]=0;
  pq.push(make_pair(0,k));
  while(!pq.empty()){
    ll nowd=-pq.top().fi;
    int now=pq.top().se;
    pq.pop();
    if(d[now]<nowd)continue;
    for(int i=0;i<v[now].size();i++){
      if(d[v[now][i].to]>d[now]+v[now][i].cost){
        d[v[now][i].to]=d[now]+v[now][i].cost;
        pq.push(make_pair(-d[v[now][i].to],v[now][i].to));
      }
    }
  }
  for(int i=0;i<q;i++){
    int x,y;cin>>x>>y;
    x--;y--;
    cout<<d[x]+d[y]<<endl;
  }
  return 0;
}

Measured memory_bytes: 11632
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		String s = scanner.next();
		int ans=0;

		if(s.equals("RRR")) {
			ans=3;
		}else if(s.equals("RRS")|| s.equals("SRR")) {
			ans=2;
		}else if(s.equals("RSS") || s.equals("SRS") || s.equals("SSR")||  s.equals("RSR")) {
			ans=1;
		}else if(s.equals("SSS")) {
			ans=0;
		}

		System.out.println(ans);


		scanner.close();

	}

}


Measured memory_bytes: 35596
D=*0..N=gets.to_i;c=2,i=1;$<.map{|l|a,b=l.split.map &:to_i;D[a],D[b]=D[b],D[a];i!=a&&i!=b||i=a+b-i;c<<D[i-1]<<D[i+1]};p (c-[0]|$*).size

Measured memory_bytes: 7444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     string str;
     ll cnt=0;
     map<char,ll>mp;
     cin>>str;
     for(int i=0;i<str.size();i++)
     {
         mp[str[i]]++;
     }
     char i;
     for(i='a';i<='z';i++)
     {
         if(mp[i]==0)
         {
             cnt=10;
             break;
         }
     }
     if(cnt==10)
        cout<<i<<endl;
     else
        cout<<"None"<<endl;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>


int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if (b - a == c - b)
		printf("YES\n");
	else
		printf("NO\n");
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void) {

    int N;
    scanf("%d", &N);

    int d = -1e9, b;
    scanf("%d", &b);
    for (int i = 0, r; i < N - 1; ++i) {
        scanf("%d", &r);
        if (r - b > d)
            d = r - b;
        if (r < b)
            b = r;
    }

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

    return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s[55];
	int co[26], co1[26] = { 0 };
	for (int s1 = 0; s1 < 26; s1++) {
		co[s1] = 1000000007;
	}
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (int j = 0; j < s[i].size(); j++) {
			co1[int(s[i][j] - 'a')]++;
		}
		for (int k = 0; k < 26; k++) {
			if (co[k] > co1[k]) {
				co[k] = co1[k];
			}
			co1[k] = 0;
		}
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < co[i]; j++) {
			cout << char(i + 'a');
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [(list(map(int,input().split()))) for i in range(n)]
ans = 0
for i in range(n):
    z = c
    for j in range(m):
        z += a[i][j] * b[j]
    if z > 0:
        ans += 1
print(ans)

Measured memory_bytes: 8956
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<list>
#include<map>
using namespace std ;
int a; string s ;
int main(){
	cin>>a>>s ;
	if(a<3200)
	puts("red") ;
	else
	cout<<s<<endl ;
	return 0 ;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))

cands = []
for i in range(1, int(m**(1/2))+1):
    if m%i == 0:
        cands.append(i)
        cands.append(m//i)
cands = sorted(cands, reverse = True)
# print(cands)

for c in cands:
    if m//c >= n:
        print(c)
        break


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b && b<c && a<c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 1992
#include <iostream>
using namespace std;
int num[26];
int main(void){
    // Your code here!
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        num[s[i] - 'a'] = 1;
    }
    for (int i = 0; i <= 26; i++) {
        if (i == 26) cout << "None" << endl;
        else if (num[i] == 0) {
            printf("%c", 'a' + i);
            break;
        }
    }
}


Measured memory_bytes: 512
N = int(input())
X = list(map(int, input().split()))
X.append(0)
Y = sorted(X)
#c = Y[len(X) // 2 - 1]
d = Y[len(X) // 2]
e = Y[len(X) // 2 + 1]
#print(X,c)
for i in range(N):
    #print(X[i])
    if X[i] <= d:
        print(e)
    else:
        print(d)


Measured memory_bytes: 25620
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int p[N+3];
    for(int i = 0; i < N; ++i) cin >> p[i];
    int cnt = 0;
    for(int i = 1; i < N-1; ++i) {
        if(p[i-1] < p[i] && p[i] < p[i+1]) ++cnt;
        else if(p[i-1] > p[i] && p[i] > p[i+1]) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){

    string s; cin >> s;
    bool flag = false;

    for(int i = 0; i < (int)s.size(); i++){

        if(flag && s[i] == 'F'){
            cout << "Yes" << endl;
            return 0;
        }else if(s[i] == 'C'){
            flag = true;
        }
    }

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

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

#define REP(i, a) for(int64 i = 0; i < (a);i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define INF (int64)1e9
#define INF_LL (int64)1e18
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int32_t;
using int64 = int64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

template<typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b;}
template<typename A, typename B> inline void chmax(A &a, B b) { if (a > b) a = b;}

vector<int> thr;
vector<vector<int>> dp;

pair<vector<int>, vector<int>> decode(int64 x) {
  vector<int> l, r;
  REP(i, 12) {
    if (x % 3 == 1) {
      l.push_back(i + (i > 5));
    } else if (x%3 == 2){
      r.push_back(i + (i > 5));
    }
    x /= 3;
  }
  return make_pair(l, r);
}

int64 encode(vector<int>& l, vector<int>& r) {
  int64 res = 0;
//  cout << "l :";
  REP(i, l.size()) {
    res += thr[l[i]-(l[i] > 5)];
//    cout << l[i]-(l[i]>5) << " ";
  }
//  cout << endl;
//  cout << "r :";
  REP(i, r.size()) {
    res += thr[r[i]-(r[i] > 5)] * 2;
//    cout << r[i]-(r[i] > 5) << " ";
  }
//  cout << endl;
  return res;
}

int64 dfs(int64 x, int64 turn) {
  if (~dp[turn][x]) return dp[turn][x];
  vector<int> h[2];
  tie(h[0], h[1]) = decode(x);
  if (h[turn].size() == 0) {
    return dp[turn][x] = 1;
  }
  vector<int> used(13, 1);
  REP(i, 2) {
    REP(j, h[i].size()) used[h[i][j]] = 0;
  }
  dp[turn][x] = 0;
  bool ok = 0;
  REP(i, h[turn].size()) {
    int p = h[turn][i];
    if ((p > 0 && used[p-1]) || (p < 12 && used[p+1])) {
      ok = 1;
      x -= thr[p - (p > 5)] * (turn+1);
      int64 ret = 1-dfs(x, 1-turn);
      x += thr[p-(p>5)] * (turn+1);
      dp[turn][x] |= ret;
    }
  }
  if (!ok) dp[turn][x] |= 1-dfs(x, 1-turn);
//  cout << turn << " " << x << ": l(";
//  REP(i, h[0].size()) {
//    cout << h[0][i] << " ";
//  }
//  cout << ") r(";
//  REP(i, h[1].size()) {
//    cout << h[1][i] << " ";
//  }
//  cout << ")" << ": " << dp[turn][x] << endl;
  return dp[turn][x];
}

int main(void) {
  int64 num = 1;
  thr.resize(12, 1);
  FOR(i, 1, 12) thr[i] = thr[i-1] * 3;
  REP(i, 12) num *= 3;
  dp = vector<vector<int>>(2, vector<int>(thr[11]*3, -1));
  int64 N;
  cin >> N;
  REP(_, N) {
    vector<int> used(13, 0);
    used[6] = 1;
    vector<int> l(6), r;
    REP(i, 6) {
      cin >> l[i]; l[i]--;
      used[l[i]] = 1;
    }
    REP(i, 13) {
      if (!used[i]) r.push_back(i);
    }
    int ret = dfs(encode(l, r), 0);
    if (ret) cout << "yes" << endl;
    else cout << "no" << endl;

  }
}



Measured memory_bytes: 9040