akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

typedef long long ll;

const ll MAX_N = 1e5 + 5, MAX_LOG_N = 20;
ll n, S, E, prv, M, K;
ll Arr[MAX_N];
ll Brr[MAX_N];
ll nxt[MAX_LOG_N][MAX_N];
ll Crr[MAX_N];
bool mark[MAX_N];
vector <ll> p;

void dfs (ll v) {
	p.push_back(v);
	mark[v] = true;
	if (!mark[nxt[0][v]])
		dfs(nxt[0][v]);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> S; prv = S;
	n--;
	for (ll i = 0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		Arr[i] = tmp - prv;
		prv = tmp;
	}

	cin >> M >> K;
	for (ll i = 0; i < n; i++)
		Brr[i] = i;

	for (ll i = 0; i < M; i++) {
		ll tmp;
		cin >> tmp;
		tmp -= 2;

		swap(Brr[tmp], Brr[tmp + 1]);
	}

	for (ll i = 0; i < n; i++) {
		nxt[0][Brr[i]] = i;
	}

	for (ll i = 1; i < MAX_LOG_N; i++)
		for (ll j = 0; j < n; j++)
			nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];

	for (ll i = 0; i < n; i++) {
		if (!mark[i]) {
			dfs(i);
			ll tmp = K % p.size();
			for (ll v: p) {
				ll u = v;
				for (ll i = MAX_LOG_N; ~i; i--)
					if ((tmp >> i) & 1)
						u = nxt[i][u];

				Crr[u] = Arr[v];
			}
			p.clear();
		}
	}

	cout << S << " ";
	for (ll i = 0; i < n; i++) {
		S += Crr[i];
		cout << S << " ";
	}
	return 0;
}

Measured memory_bytes: 20212
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        if (m == n) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>
int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    if(a>=b){
        for (int i = 0; i <a ; ++i) {
            printf("%d", b);
        }
    }else{
        for (int i = 0; i <b ; ++i) {
            printf("%d", a);
        }
    }
}

Measured memory_bytes: 128
(()->begin
  n,m,q = readline() |> split |> x->parse.(Int,x)
  arr = fill([], q)
  for i in 1:q
    arr[i] = readline() |> split |> x->parse.(Int,x)
  end

  function dfs(n, m)
    result = []
    function dfs_walk(arr)
      if (length(arr) == n + 1)
        push!(result, arr[2:end])
        return;
      end
      push!(arr, arr[end])
      while (arr[end] <= m)
        dfs_walk(copy(arr))
        arr[end] += 1
      end
    end
    dfs_walk([1])
    return result
  end
  ans = 0
  for comb in dfs(n, m)
    tmp = 0
    for (a,b,c,d) in arr
      if comb[b] - comb[a] == c
        tmp += d
      end
    end
    ans = max(ans, tmp)
  end
  println(ans)
end)()


Measured memory_bytes: 231108
def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    max_time = 0
    for i in range(N):
        data.append(list(map(int,input().split())))
        max_num = max(data[i])
        if max_num>max_time:
            max_time=max_num

    #data_np = np.array(data).reshape(N,3)
    #data_np = np.array(data)

    #max_time = int(max(data))
    #print("max",max_time)
    schedule = [[0]*C for i in range(max_time)]
    #schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            if start+j-1<0:continue
            schedule[start+j-1][channel] = 1

#    for c in range(C):
#        for t in range(max_time):
#            if t==0:continue
#            if schedule[t][c]==1 and schedule[t-1][c]==0:
#                schedule[t-1][c]=1

    #max_N =0
    #for t in range(max_time):
    #    sum_of_ch = sum(schedule[t])

    temp = list(map(sum,list(schedule)))
    max_N = int(max(temp))


    #    if sum_of_ch>max_N:
    #        max_N = int(sum_of_ch)
    print(max_N)







main()


Measured memory_bytes: 61508
def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = [None]*(n+1)
    s[n] = 0
    for i in reversed(range(n)):
        s[i] = a[i] + s[i+1]
    dic = {}
    ans = 0
    for i in range(n+1):
        if s[i] in dic.keys():
            ans += dic[s[i]]
            dic[s[i]] += 1
        else:
            dic[s[i]] = 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 41468
#include <cstdio>
#define ll long long int
using namespace std;
ll a, b, c;
int main()
{
	scanf("%lld%lld%lld", &a, &b, &c);
	if(c-a-b<0||a<0||b<0||c<0)
	{
		printf("No\n");
		return 0;
	}
	if(a*b*4<(c-a-b)*(c-a-b))
	    printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main()
{
  ll L,R,d,tmp;
  cin >> L >> R;
  d = R-L;
  if(d>=2018){
    cout << 0 << endl;
    return 0;
  }
  if(d==1){
    tmp = L%2019;
    tmp = tmp*(tmp+1)%2019;
    cout << tmp << endl;
    return 0;
  }
  ll** A;
  A = (ll**)malloc(sizeof(ll*)*d);
  for(ll i=0;i<d;i++){
    A[i] = (ll*)malloc(sizeof(ll)*d);
  }
  for(ll i=0;i<d;i++){
    A[i][i] = (L+i)*(L+i+1)%2019;
    for(ll j=i+1;j<d;j++){
      A[i][j] = (A[i][j-1]+L+i)%2019;
    }
  }
  tmp = A[0][0];
  for(ll i=0;i<d;i++){
    for(ll j=i;j<d;j++){
      if(A[i][j]<tmp){
        tmp = A[i][j];
      }
    }
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 23168
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{ 

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in); 
		int N = input.nextInt();
		long W = input.nextLong();
		long[][] dp = new long[101][100001]; //Minimum weights to get value v by item N
		//100000 = 100*1000 = (max items)*(max value)
		//Arrays.fill(dp, (long)(1e5));
		//Don't need all rows (only 2 rows needed for comparison)
		long[] w = new long[N+1];
		int[] v = new int[N+1];
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100000; j++) {
				dp[i][j]=(long)(1e9+1);
			} 
		}
		for (int i = 1; i <= N; i++) {
			w[i]=input.nextLong();
			v[i] = input.nextInt();
		}
		dp[1][v[1]]=w[1];
		if (w[1]<=W) ans=Math.max(ans, v[1]);
		for (int i = 2; i <= N; i++) {
			dp[i][v[i]]=w[i];
			for (int val = 1; val <= 100000; val++){
				dp[i][val]=Math.min(dp[i][val],dp[i-1][val]);
				if (val-v[i]>0) dp[i][val] = Math.min(dp[i][val], dp[i-1][val-v[i]]+w[i]);
				if (dp[i][val]<=W&&dp[i][val]>0) ans=Math.max(ans, val);
			}
		} 
		System.out.println(ans);
	}	
}

Measured memory_bytes: 129108
#include <stdio.h>
int main(){
	int n,k,h,ans=0;
	scanf("%d%d", &n,&k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h);
		if(h>=k){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define RSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))
#define PREC(n) setprecision(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    int a,b,i;

    cin>>a>>b;

    if(a<b){
        rep(i,b){
            cout<<a;
        }
    }
    else{
        rep(i,a){
            cout<<b;
        }
    }
	
	return 0;
}


Measured memory_bytes: 256
def resolve():
    n=int(input())
    d=[]
    for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
    d.sort()
    ans=[0]*n
    for i in range(n):
        ans[i]=d[i][2]
    for m in ans:
        print(m+1)
resolve()

Measured memory_bytes: 9084
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    reps(i, 1, n){
        ans += n / i + ((n % i != 0) ? 1 : 0) - 1;
    }
    cout << ans << endl;
}

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

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

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

int H, W;
bool field[91][91];
int ans;

void dfs(int x, int y, int n){
  rep(i, 4){
    int nx = x+dx[i], ny = y+dy[i];
    if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
    if(!field[ny][nx]) continue;
    field[ny][nx] = false;
    ans = max(ans, n+1);
    dfs(nx, ny, n+1);
    field[ny][nx] = true;
  }
}

int main(){
  while(cin >> H >> W, H|W){
    rep(i, H)
      rep(j, W) cin >> field[i][j];
   
    ans = 0;
   
    rep(i, H){
      rep(j, W){
	if(field[i][j]){
	  field[i][j] = false;
	  dfs(j, i, 1);
	  field[i][j] = true;
	}
      }
    }
    cout << ans << endl;        
  }
  return 0;
}

Measured memory_bytes: 1168
#include<stdio.h>
int gcd(int,int);

int main(){
  int x,y;
  int n;
  scanf("%d %d",&x,&y);
  printf("%d\n",n=gcd(x,y));
  return 0;
}

int gcd(int a,int b){
  int n;
  if(a<b){
    n=a;
    a=b;
    b=n;
  }
  while(b>0){
    n = a % b;
    a = b;
    b = n;
  }
  return a;
}


Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bits/stdc++.h>


using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, K; cin >> N >> K;
    vector<int> p(N); repp(i,0,N) cin >> p[i];
    vector<double> P(N);
    repp(i,0,N) {
        repp(j,1,p[i] + 1) {
            P[i] += j;
        }
    }
    repp(i,0,N) P[i] /= p[i];

    double res = 0;
    repp(i,0,K) res += P[i];
    double res2 = res;
    repp(i,K,N) {
        res += P[i];
        res -= P[i-K];
        res2 = max(res2, res);
    }
    cout << setprecision(11) << res2 << endl;
}


Measured memory_bytes: 2560
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    string s,t;cin>>s>>t;
    ll ans=0;
    for(ll i=0;i<s.length();++i)if(s[i]!=t[i])++ans;
    cout<<ans<<endl;
}


Measured memory_bytes: 3852
#include<stdio.h>
#define INF 0x09090909
int main(){
	int n, m;
	int i, j;
	while(scanf("%d%d", &n, &m), n) {
		int cost[100][100] = {0};
		int determined[100] = {0}, undeterminednodes = n;
		int costsum = 0;
		int minnode, minnodecost, nextminnode;

		for(i = 0; i < n; i ++) {
			for(j = 0; j < n; j ++) {
				cost[i][j] = INF;
			}
		}
		for(i = 0; i < m; i ++) {
			int a, b, d;
			scanf("%d,%d,%d", &a, &b, &d);
			cost[a][b] = cost[b][a] = d/100-1;
		}
		minnode = 0;
		minnodecost = 0;

		while(undeterminednodes > 0) {
			determined[minnode] = 1;
			costsum += minnodecost;
			undeterminednodes --;
			cost[0][minnode] = INF;
			minnodecost = INF;
			for(i = 0; i < n; i ++) {
				if(!determined[i]) {
					if(cost[minnode][i] < cost[0][i])
						cost[0][i] = cost[minnode][i];
				}
				if(cost[0][i] < minnodecost) {
					nextminnode = i;
					minnodecost = cost[0][i];
				}
			}
			minnode = nextminnode;
		}
		printf("%d\n", costsum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n;
    map<string, int> mp;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }

    int mx = 0;
    vector<string> ans;
    for (auto &i : mp) {
        if (mx < i.second) {
            ans = {i.first};
            mx = i.second;
        }
        else if (mx == i.second) ans.push_back(i.first);
    }
    sort(all(ans));
    for (auto &i: ans) cout << i << endl;
}


Measured memory_bytes: 26868
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<string, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m,k, p, q, w, h, ans, cnt, dp[2000][2000], sum, a[200000], b[200000];
string str, ss;
bool f;
char c[1100][1100];
int main() {
	cin >> n >> k;
	cout << max(n - k + 1, (LL)0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <cmath>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

/*******                      *******/

int n, k;

ll solve(int val, int cnt){
    if(val<k){
        cnt++;
        val *= 2;
        return solve(val, cnt);
    }
    return pow(2, cnt);
}

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    cin >> n >> k;
    
    double res = 0;
    double foo = 0;
    rep(i, n){
        int u = i+1;
        foo += 1.0 / (solve(u, 0));
    }
    res += 1.0 / (double)n * foo ;
    
    printf("%.9lf\n", res);
    
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h],
    }
    let mut result = 0;
    for y in 0..2usize.pow(h as u32) {
        for x in 0..2usize.pow(w as u32) {
            let mut count = 0;
            for i in 0..h {
                for j in 0..w {
                    if 1 << i & y == 0 && 1 << j & x == 0 && c[i][j] == '#' {
                        count += 1;
                    }
                }
            }
            if count == k {
                result += 1;
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
 
const int Inf = 1000000;
const int mod = 1000000007;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, h, d;
long long r = 0, f = 1;
long long dp[1000005], psum[1000005];

signed main()
{
	Fastio();
	cin >> n >> h >> d;
	for(int i = 1; i <= n; i++)
	{
		f = f * i % mod;
		r += f;
		r %= mod;
	}
	for(int i = 1; i <= h; i++)
	{
		int temp;
		if(0 > i - d - 1)
		{
			temp = psum[i - 1];
		}
		else
		{
			temp = psum[i - 1] - psum[i - d - 1];
		}
		temp = (temp % mod + mod) % mod;
		temp = temp * r % mod;
		if(i <= d)
		{
			temp += f;
		}
		dp[i] = temp % mod;
		psum[i] = (psum[i - 1] + dp[i]) % mod;
	}
	cout << dp[h] % mod;
}

Measured memory_bytes: 15872
def hamming2(s1, s2):
       """Calculate the Hamming distance between two bit strings"""
       assert len(s1) == len(s2)
       return sum(c1 != c2 for c1, c2 in zip(s1, s2))

   
S = input()
T = input()

len_t = len(T)

min_d = 10000
for i in range(len(S)-len_t+1):
    s = S[i:i+len_t]
    d = hamming2(s, T)
    if d < min_d:
        min_d = d

print(min_d)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  vector<char> N(4);
  for(auto& n : N) cin >> n;
  auto ans = N[0] == N[1] && N[1] == N[2];
  ans |= N[1] == N[2] && N[2] == N[3];

  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

#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, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()


using namespace std;

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

	for (int i = 0; i < K; i++)
	{
		if (s[i] != '1')
		{
			cout << s[i] << endl;
			return 0;
		}
	}

	cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
t_list = list(map(int, input().split()))

# t_list = [a, b, c,]
# 	              stop_time = 0, total_time = 0
#    a      a+T 
#    <----->          [??, stop_time) [a, a+T) (no overlap) a+T, total_time+T
#        b      b+T
#        <----->      [??, stop_time) [b, b+T) (overlap) b+T, total_time+(b+T-stop_time)
#                  c      c+T
#                  <----->
#                     [??, stop_time) [c, c+T) (no overlap) c+T, total_time+T

stop_time, total_time = 0, 0
for x in t_list:
  # [x, x+T)
  if stop_time <= x:
    # no overlap
    total_time += T
  else:
    # overlap
    total_time += ((x + T) - stop_time)
  stop_time = x + T

print(total_time)


Measured memory_bytes: 85328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
int main() {
  double n,m;
  cin >> n >> m;
  vector<double> goods(n);
  rep(i,n) cin >> goods[i];
  double total = 0;
  rep(i,n) total += goods[i];
  
  sort(all(goods));
  reverse(all(goods));
  
  if(goods[m-1] >= total/4/m ) dunk("Yes");
  else dunk("No");
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

    int n; 
    cin >> n;

    int x, xmin = 2000, xmax = 0;
    for ( int i=0; i<n; ++i ) {
	cin >> x;
	if ( x < xmin ) xmin = x;
	if ( x > xmax ) xmax = x;
    }

    cout << xmax - (xmin + xmax)/2 << endl;
    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

class Circle{
    public : double x, r;
};

double dist(Circle a, Circle b){
    double z = a.r + b.r;
    double x = abs(a.r - b.r);
    return sqrt(z * z - x * x);
}

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

    Circle v[505] = {Circle{0,0}};
    rep(i,n){
        cin >> v[i].r;
    }

    rep(i,n){
        double max_dist = v[i].r;
        int p = 0;
        rep(j,i){
            //if(max_dist < dist(v[i],v[j]) + (limit - v[j].x)){
            //    min_dist = dist(v[i],v[j]) + (limit - v[j].x);
            //    p = j;
            //}
            max_dist = max(max_dist, dist(v[i],v[j]) + v[j].x);
        }
        if(i == p) v[i].x = v[i].r;
        else v[i].x = max_dist;
    }

    double ans = 0;
    rep(i,n){
        ans = max(ans, v[i].x + v[i].r);
    }
    cout <<fixed << setprecision(5) <<  ans << endl;
}

Measured memory_bytes: 3292
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC134E();

#if 1
int main()
{
	ABC134E();
	fflush(stdout);
	return 0;
}
#endif

static void ABC134E()
{
	int N;
	getint(N);

	std::vector<int> ai(N);
	for (int i = 0; i < N; i++) {
		getint(ai[i]);
	}
	
	std::multiset<int> colors;
	colors.insert(ai[0]);
	for (int i = 1; i < N; i++) {
		auto it = colors.lower_bound(ai[i]);
		if (it != colors.begin()) {
			colors.erase(--it);
		}
		colors.insert(ai[i]);
	}
	printf("%u\n", colors.size());
}


Measured memory_bytes: 5376
#include<iostream>
using namespace std;
typedef long long llong;

static const int MAX = 4001;

int main(){
    llong n;
    char s[MAX];
    cin >> n;
    cin >> s;

    llong cnt = 0, r = 0, g = 0, b = 0;
    int i, j, k;
    for(i=0; i<n; i++){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else if(s[i] == 'B') b++;
    }

    for(i=0; i<n-2; i++){
        for(j=i+1; j<n-1; j++){
            k = 2 * j - i;
            if(s[i] != s[j] && s[k] != s[j] && s[k] != s[i] && k < n) cnt++;
        }
    }

    llong ans = r*g*b - cnt;
    
    // for(i=0; i<n; i++){
    //     for(j=i+1; j<n; j++){
    //         for(k=j+1; k<n; k++){
    //             if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i] && j-i!=k-j) cnt++;
    //         }
    //     }
    // }

    cout << ans << endl;
}


Measured memory_bytes: 3620
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> S(2010, vector<char>(2010, '#'));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> S[i][j];
        }
    }

    Graph H(2010), W(2010);
    for(int i = 0; i <= h + 1; i++){
        for(int j = 0; j <= w + 1; j++){
            if(S[i][j] == '#'){
                H[i].push_back(j);
                W[j].push_back(i);
            }
        }
    }

    int ans = 0;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(S[i][j] == '#') continue;
            auto itr1 = lower_bound(all(H[i]), j), itr2 = lower_bound(all(W[j]), i);
            int tmp = *itr1 + *itr2 - 3;
            itr1--;
            itr2--;
            tmp -= *itr1 + *itr2;
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 38528
/*
float like a butterfly
sting like a Bee

?#%^*&~`!  YOUR ONLY LIMIT IS YOUR MIND

*/

#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define q '\n'

using namespace std;

lli x, n , a[200];
bool b[200] = {};

int main() {
	cin >> x >> n;
	for (int i = 0;i < n; i++){
		cin >> a[i];
		b[a[i]] = 1;
	}
	for (int i = 0; i <= x; i++){
		if (b[x - i] == 0){
			cout << x - i;
			break;
		}
		if (b[x + i] == 0){
			cout << x + i;
			break;
		}
	}
}


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


def main():
    S = list(map(int, list(input())))

    result = 0
    for i in range(1, len(S)):

        if S[i - 1] == S[i]:
            if S[i] == 1:
                S[i] = 0
            else:
                S[i] = 1
            result += 1

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4652
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void D_task();

#if 1
int main()
{
	D_task();
	fflush(stdout);
	return 0;
}
#endif

static void D_task()
{
	//	------------------------------------
	//	公式の解説見ても何が何だか！！
	//	------------------------------------


	auto numStr = new char[100001];
	memset(numStr, 0, sizeof(char) * 100001);
	getstring(numStr);

	int slen = strlen(numStr);
	auto dp = new LLONG[slen + 1][13];
	memset(dp, 0, sizeof(LLONG) * (slen + 1) * (13));

	dp[0][0] = 1;	//	0文字目：あまり0の一通り
	for (int i = 0; i < slen; i++) {
		//	遷移元を13通り見る
		for (int j = 0; j < 13; j++) {
			//	? のときは 10 通り確かめる
			if (numStr[i] == '?') {
				for (int k = 0; k < 10; k++) {
					int j2 = (10 * j + k) % 13;
					dp[i + 1][j2] += dp[i][j];
					dp[i + 1][j2] %= MOD_NUM;
				}
			}
			else {
				int num = numStr[i] - '0';
				int j2 = (j * 10 + num) % 13;
				dp[i + 1][j2] += dp[i][j];
				dp[i + 1][j2] %= MOD_NUM;
			}
		}
		
	}
	printf("%lld\n", dp[slen][5]);

	delete[] dp;
	delete[] numStr;
}


Measured memory_bytes: 10496
#include <iostream>
using namespace std;
struct Rect
{
	Rect(){
		minX = minY = 10000;
		maxX = maxY = -10000;
	}
	void add(int i, int j){
		if (minX > i) minX = i;
		if (minY > j) minY = j;
		if (maxX < i) maxX = i;
		if (maxY < j) maxY = j;
	}
	int getWidth() {
		return (maxY - minY + 1);
	}
	int getHeight() {
		return (maxX - minX + 1);
	}
	int minX;
	int minY;
	int maxX;
	int maxY;
};
int main()
{
	char c;
	int A[8][8] = {};
	while (true){
		Rect r;
		for (int i = 0; i < 8; ++i){
			for (int j = 0; j < 8; ++j){
				cin.get(c);
				if (c == '1') A[i][j] = 1;
				else A[i][j] = 0;
				if (1 == A[i][j])
					r.add(i, j);
			}
			cin.get(c);
		}
		int w = r.getWidth();
		int h = r.getHeight();
		if (1 == w) cout << "B\n";
		else if (1 == h) cout << "C\n";
		else if (2 == w && 2 == h) cout << "A\n";
		else if (2 == w && 3 == h){
			if (A[r.minX][r.minY] == 1) cout << "F\n";
			else cout << "D\n";
		}
		else if (3 == w && 2 == h){
			if (A[r.minX][r.minY] == 1) cout << "E\n";
			else cout << "G\n";
		}
		if (!cin.get(c))
			break;
	}
	return 0;
}

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

#define int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;0<=i;i--)
int n;
string s;
int _jj[114514];
int _ii[114514];
int _jo[114514];
int _oi[114514];

signed main(){
  cin>>n>>s;
  int *jj=&_jj[1];
  int *ii=&_ii[1];
  int *jo=&_jo[1];
  int *oi=&_oi[1];
  REP(i,n){
    jj[i]=jj[i-1];
    if(s[i]=='J')jj[i]++;
  }
  RREP(i,n){
    ii[i]=ii[i+1];
    if(s[i]=='I')ii[i]++;
  }
  int org=0;
  REP(i,n){
    if(s[i]=='O')org+=jj[i-1]*ii[i+1];
  }
  REP(i,n){
    jo[i]=jo[i-1];
    if(s[i]=='O')jo[i]+=jj[i-1];
  }
  RREP(i,n){
    oi[i]=oi[i+1];
    if(s[i]=='O')oi[i]+=ii[i+1];
  }
  int mx=0;
  REP(_i,n+1){
    int i=_i-1;
    mx=max(mx,oi[i+1]);
    mx=max(mx,jj[i]*ii[i+1]);
    mx=max(mx,jo[i]);
  }
  cout<<(org+mx)<<endl;
  return 0;
}

Measured memory_bytes: 6440
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> cnt(h, vector<int>(w));

    rep(i, h) {
        vector<int> done(w);
        rep(j, w) {
            if(s[i][j] == '#') continue;
            if(done[j]) continue;
            int l = 0;
            while(j + l < w) {
                if(s[i][j + l] == '#') break;
                l++;
            }
            rep(k, l) {
                cnt[i][j + k] += l;
                done[j + k] = 1;
            }
        }
    }
    rep(j, w) {
        vector<int> done(h);
        rep(i, h) {
            if(s[i][j] == '#') continue;
            if(done[i]) continue;
            int l = 0;
            while(i + l < h) {
                if(s[i + l][j] == '#') break;
                l++;
            }
            rep(k, l) {
                cnt[i + k][j] += l;
                done[i + k] = 1;
            }
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20224
<?php
fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%s', $s);
$ret = 0;
for($i = 1; $i < $n; $i++) {
    $wb = substr($s, 0, $i);
    $s_len = strlen($s);
    $wa = substr($s, $i, $s_len);
    $count = 0;
    $n_arr = [];
    for($j = 0; $j < $s_len; $j++) {
        $needle = $s[$j];
        if(strpos($wa, $needle) === false || strpos($wb, $needle) === false
            || in_array($needle, $n_arr)) {
            continue;
        }
        $count += 1;
        $n_arr[] = $needle;
    }
    $ret = ($count > $ret) ? $count: $ret;
//    var_dump($wb, $wa, $count);
//    echo "\n";
}
echo $ret;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int a[111111];
int main(){
    DRI(n);
REP(i,n*2)RI(a[i]);
sort(a,a+2*n);
int an=0;
REP(i,n)an+=a[i*2];
cout<<an<<endl;
    return 0;
}

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


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class DDiceInLine {
public:
    static void solve(std::istream &cin, std::ostream &cout) {
        int n, k;
        cin >> n >> k;
        vector<int> p_vec(n);
        for (int i = 0; i < n; ++i) {
            cin >> p_vec[i];
        }
        vector<double> precalc(n);
        for (int i = 0; i < n; ++i) {
            double p = p_vec[i];
            precalc[i] = (p * (p + 1) / 2) / p;
        }
        double ans = 0.0;
        for (int i = 0; i < k; ++i) {
            ans += precalc[i];
        }
        double tmp = ans;
        for (int i = k; i < n; ++i) {
            tmp -= precalc[i - k];
            tmp += precalc[i];
            ans = max(ans, tmp);
        }
        printf("%lf\n", ans);
    }
};


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


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

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

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << s1[0] << s2[1] << s3[2] << endl;   

    return 0;
}

Measured memory_bytes: 256
import math
import numpy as np
import decimal
import collections
import itertools
import sys
#Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x, y):
    p = find(x)
    q = find(y)
    if p == q:
        return None
    if p > q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p
def same(x, y):
    return find(x) == find(y)
def size(x):
    return -par[find(x)]
n = 0
par = [-1 for i in range(n)]

#素数関連
def prime_numbers(x):
    if x < 2:
        return []
    prime_numbers = [i for i in range(x)]
    prime_numbers[1] = 0
    for prime_number in prime_numbers:
        if prime_number > math.sqrt(x):
            break
        if prime_number == 0:
            continue
        for composite_number in range(2 * prime_number, x, prime_number):
            prime_numbers[composite_number] = 0
    return [prime_number for prime_number in prime_numbers if prime_number != 0]
def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime_number = 7
    difference = 4
    while prime_number <= math.sqrt(x):
        if x % prime_number == 0:
            return False
        prime_number += difference
        difference = 6 - difference
    return True
#nCr
mod = 10 ** 9 + 7
def comb(n, r):
    if n < r:return 0
    if n < 0 or r < 0:return 0
    return fa[n] * fi[r] % mod * fi[n - r] % mod
fa = [1] * (n + 1)
fi = [1] * (n + 1)
for i in range(1, n + 1):
    fa[i] = fa[i - 1] * i % mod
    fi[i] = pow(fa[i], mod - 2, mod)
#BIT
BIT = [0] * (n + 1)
def add(i, x):
    while i <= n:
        BIT[i] += x
        i += i & -i
def query(i):
    s = 0
    while i > 0:
        s += BIT[i]
        i -= i & -i
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
cnt = 0
li = [1 for i in range(n - k + 1)]
for i in range(1, k):
    if p[i - 1] > p[i]:
        cnt += 1
if cnt == 0:
    li[0] = 0
for i in range(k, n):
    if p[i - 1] > p[i]:
        cnt += 1
    if p[i - k] > p[i - k + 1]:
        cnt -= 1
    if cnt == 0:
        li[i - k + 1] = 0
Q1 = deque([])
Q2 = deque([])
L1 = [0 for i in range(n - k + 2)]
L2 = [0 for i in range(n - k + 2)]
for i in range(n):
    while Q1 and p[Q1[-1]] > p[i]:
        Q1.pop()
    while Q2 and p[Q2[-1]] < p[i]:
        Q2.pop()
    Q1.append(i)
    Q2.append(i)
    if Q1[0] == i - k + 1:
        Q1.popleft()
    if Q2[0] == i - k + 1:
        Q2.popleft()
    if i >= k - 2:
        L1[i - k + 2] = p[Q1[0]]
        L2[i - k + 2] = p[Q2[0]]
ans = 0
for i in range(1, n - k + 1):
    if p[i - 1] > L1[i] or p[i + k - 1] < L2[i]:
        if li[i] > 0:
            ans += 1
print(ans - min(li) + li[0] + 1)

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

int main (void)
{
    char s[20], t[20];

    scanf("%s", s);
    scanf("%s", t);

    t[strlen(t) - 1] = '\0';

    if (!strcmp(s, t)) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}



Measured memory_bytes: 1608
import bisect

n,m=map(int,input().split())

x=[list(map(int,input().split())) for i in range(m)]

lst=[[] for i in range(n)]

for i,v in x:
    lst[i-1].append(v)

for i in range(n):
    lst[i].sort()

for i,v in x:
    z=bisect.bisect_left(lst[i-1],v)+1

    print('0'*(6-len(str(i)))+str(i)+'0'*(6-len(str(z)))+str(z))

Measured memory_bytes: 106200
#include <iostream>
#include <map>
#include <set>

using namespace std;

typedef map< string, set<int> > Dic;
Dic dic;

int main(){
  //map<string, int> dic;
  int num;
  string s;
  while(cin >> s >> num)
  {
    dic[s].insert(num);
  }
  
  for(Dic::iterator it = dic.begin() ; it != dic.end() ; it++)
  {
  	cout << it->first << endl;
  	int counter = 0;
  	for(set<int>::iterator set_it = it->second.begin() ; set_it != it->second.end() ; set_it++)
  	{
  		if(counter!=0) cout<<" ";
  		cout << *set_it;
  		counter++;
  	}
  	cout << endl;
  }

  return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> R(M*2); //道の情報
  for (int i = 0; i < R.size(); i++)
    cin >> R.at(i);
  vector<int> F(N+1, 0);//数え上げ用
  int count = 0;

  for (int j = 1; j <= N; j++){
      for (int i = 0; i < M*2; ){

        if(R.at(i) == j){

          F.at(R.at(i+1)) += 1;

        }else if(R.at(i+1) == j){

          F.at(R.at(i)) += 1;

        }

        i = i + 2;

      }

    for (int l = 0; l < F.size(); l++){
      count += F.at(l);
    }
      cout << count << endl;
      count = 0;
      F = vector<int>(N+1, 0);
  }

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; scanf("%d",&x); return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  int n = in();
  int a[100001];

  for (int i = 0; i < n; i++) a[i] = in();

  int cnt = 0;
  for (int i = 0; i < n; ++i){
    if (i + 1== a[a[i] - 1]){
      cnt++;
    }
  }
  cout << cnt / 2 << endl;


  return (0);
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A);
    vector<int> q(B);
    vector<int> r(C);
    rep(i,A) cin >> p.at(i);
    rep(i,B) cin >> q.at(i);
    rep(i,C) cin >> r.at(i);
    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());
    sort(r.begin(),r.end(),greater<int>());
    vector<pair<int,int>> pq; //pairの後ろは0ならp,1ならq,2ならr
    rep(i,X) {
        pq.push_back(make_pair(p.at(i),0));
    }
    rep(i,Y) {
        pq.push_back(make_pair(q.at(i),1));
    }
    SORT(pq);
    bool Acomp = false;
    bool Bcomp = false;
    int pqcnt = 0;
    int rcnt = 0;
    int Acnt = 0;
    int Bcnt = 0;
    // cout << "ここまで" << endl;
    while((Acnt<=X||Bcnt<=Y)&&pqcnt<X+Y&&rcnt<C) {
        if(pq.at(pqcnt).first<r.at(rcnt)) {
            if(pq.at(pqcnt).second==0) {
                Acnt++;
                if(Acnt<=X) {
                    pq.at(pqcnt).first=r.at(rcnt);
                    rcnt++;
                }
            } else {
                Bcnt++;
                if(Bcnt<=Y) {
                    pq.at(pqcnt).first=r.at(rcnt);
                    rcnt++;
                }
            }
            pqcnt++;
        }
        else {
            break;
        }
            // cout << "1交換" << endl;
    }
    ll sum = 0;
    for(int i = 0; i < pq.size(); i++) {
        sum += pq.at(i).first;
    }
    cout << sum << endl;
}

Measured memory_bytes: 4596
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        int cnt = 0;
        int max = 0;

        for(int i = 0;i < n;i++){
            h[i] = sc.nextInt();
        }
        for(int i = 0;i < n-1;i++){
            if(h[i] >= h[i+1]){
                cnt++;
            }else{
                if(max < cnt)
                max = cnt;
                cnt = 0;
            }
            if(max < cnt)
                max = cnt;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 50904
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(ALL(v));
    int x = v.back();
    v.pop_back();
    auto it = lower_bound(ALL(v),x/2);
    cerr << *it << endl;
    int y;
    if (it == v.end()) y = v.back();
    else if (it == v.begin()) y = v.front();
    else {
        int y1 = *it;
        int y2 = *(it-1);
        if (x - y1 > y2) y = y1;
        else y = y2;
    }

    cout << x << " " << y << endl;


    return 0;
}

Measured memory_bytes: 768