akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

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

  string s, t;
  cin >> s >> t;
  vector<vector<ll>> alphabets(26);
  for(int i = 0; i < s.size(); i++) alphabets[s[i]-'a'].emplace_back(i);
  ll index = -1, ans = 0;
  for (int i = 0; i < t.size(); i++) {
    int c = t[i] - 'a';
    if (alphabets[c].empty()) {
      cout << -1 << endl;
      return 0;
    }
    auto it = upper_bound(alphabets[c].begin(), alphabets[c].end(), index);
    if (it == alphabets[c].end()) {
      ans += (ll)(s.size()) - index;
      index = alphabets[c][0];
      ans += index;
    }
    else {
      ans += *it - index;
      index = *it;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4560
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int k = sc.nextInt();
        int x = sc.nextInt();
        if (k * 500 >= x) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int INF = (int)1e8;
const int N = 100100;
const int K = 31;
int n;
int a[N], b[N];
int dp[2][K];

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

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		int k = 0;
		while((1 << k) < x) k++;
		a[i] = k;
		if (x != (1 << k))
			b[i] = 1;
	}

	for (int k = 0; k < K; k++)
		dp[0][k] = INF;
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int k = 0; k < K; k++)
			dp[1][k] = INF;
		for (int k = 0; k < K; k++) {
			if (dp[0][k] == INF) continue;
			if (k > a[i]) continue;
			if (k == a[i] && b[i] == 0)
				dp[1][k] = min(dp[1][k], dp[0][k]);
			dp[1][a[i]] = min(dp[1][a[i]], dp[0][k] + max(1, a[i] - k));
			if (a[i] > 0)
				dp[1][a[i] - 1] = min(dp[1][a[i] - 1], dp[0][k] + a[i] - k);
		}
		for (int k = K - 2; k >= 0; k--)
			dp[1][k] = min(dp[1][k], dp[1][k + 1]);
		for (int k = 0; k < K; k++)
			dp[0][k] = dp[1][k];
	}
	printf("%d\n", dp[0][0]);

	return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

int N, K;
vector<vector<int>>orders;
int memo[1 << 16][16][6];

int getperm(const int now, const vector<int>&perm) {
	vector<int>a(N - K);
	int n = 0;
	for (auto e : perm) {
		if (find(orders[now].begin(), orders[now].end(), e) == orders[now].end()) {
			a[n++] = e;
		}
	}
	if (N - K == 3) {
		if (a[0] < a[1]) {
			if (a[1] < a[2])return 0;
			else
				if (a[0] < a[2])return 1;
				else return 4;
		}
		else {
			if (a[1] > a[2])return 5;
			else
				if (a[0] < a[2])return 2;
				else return 3;
		}
	}
	else if (N - K == 2) {
		return a[0] < a[1];
	}
	else{
		return 0;
	}
}
vector<int>getans(bitset<16>&rest, const vector<int>&perm) {
	for (int i = 0; i < N;++i){
		if (rest[i]) {

			const int hash = getperm(i, perm);
			if (memo[rest.to_ulong()][i][hash])continue;
			const int n(i);
			vector<int>aperm(perm);

			auto it = aperm.begin();
			for (int o = 0; o < orders[0].size(); ++o) {
				it = find(it, aperm.end(), orders[n][o]);
			}
			if (it == aperm.end())continue;
			else {
				if (rest.count() == 1) {
					return vector<int>(1, n);
				}
				else {
					for (int p = 0; p < orders[0].size(); ++p) {
						auto it = find(aperm.begin() + p, aperm.end(), orders[n][p]);
						aperm.erase(it);
						aperm.insert(aperm.begin(), orders[n][p]);
					}
					rest[i] = false;
					vector<int>v=getans(rest, aperm);
					rest[i] = true;
					if (!v.empty()) {
						v.push_back(n);
						return v;
					}
				}
			}
			memo[rest.to_ulong()][i][hash] = true;
		}
		
	}
	return vector<int>(0);
}
int main() { 
	memset(memo, 0, sizeof(memo));
	cin >> N >> K;
	orders.resize(N);
	for (int i = 0; i < N; ++i) {
		string st; cin >> st;
		for (int j = 0; j < st.size(); ++j) {
			orders[i].push_back(st[j] - 'A');
		}
	}
	string ans = "ZZZZZZZZZZZZZZZZZZZZ";
	for (int i = 0; i < N; ++i) {
		vector<int>perm(orders[i]);
		vector<int>aa;
		for (int j = 0; j < N; ++j) {
			if (find(perm.begin(), perm.end(), j) == perm.end()) {
				aa.push_back(j);
			}
		}
		sort(aa.begin(), aa.end());
		do {

			bitset<16>bs(0);
			for (int i = 0; i < N; ++i) {
				bs[i] = true;
			}
			vector<int>aperm(perm); 
			aperm.insert(aperm.end(), aa.begin(),aa.end());
			vector<int>v = getans(bs, aperm);
			if (!v.empty()) {
				if (v.size() != N)assert(false);
				reverse(v.begin(), v.end());
				string nans;
				for (auto a : v) {
					nans.push_back(a + 'A');
				}
				ans = min(ans, nans);
			}
		} while (next_permutation(aa.begin(), aa.end()));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27808
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
n,a,i=1,0,0
while i<N-1:
    if A[i]==n:
        a+=1
        i+=1
        continue
    print(a)
    a=0
    n+=1
print(a)
m=N-n
for i in range(m):
    print(0)

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    char a, b;
    cin >> a >> b;
    if (a == 'H') {
        cout << b << '\n';
    } else {
        cout << (b == 'H' ? 'D' : 'H') << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
map<string, ll>a;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}


int main() {
	ll a, b;
	cin >> a >> b;
	cout << max({a + b, a - b, a * b});
}

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

int main() {
  long long n,m;
  cin >> n >> m;
  if(n==1 && m==1){
    cout << 1 << endl;
  }else if(n==1 || m==1){
    cout << max(n,m)-2 << endl;
  }else{
    cout << (n-2)*(m-2) << endl;
  }
}

Measured memory_bytes: 256
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define deb(x) cout<<#x<<" "<<x<<el;
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n==1) return x;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                              //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

template<typename T>
T maxx(T a,T b)
{
  if(a<b) re b;
  re b;
}
template<typename T, typename... Args>
T maxx(T a,T b, Args... args)
{
    re(maxx(maxx(a,b),args...));
}

template<typename T>
T minn(T a,T b)
{
  if(a<b) re a;
  re b;
}
template<typename T, typename... Args>
T minn(T a,T b, Args... args)
{
    re(minn(minn(a,b),args...));
}

template<typename T>
void read(T& a)
{
  cin>>a;
}
template<typename T, typename... Args>
void read(T& a,Args&... args)
{
  cin>>a; read(args...);
}

template<typename T>
void write(T a)
{
  cout<<a<<' ';
}
template<typename T, typename... Args>
void write(T a,Args... args)
{
  cout<<a<<' '; write(args...);
}

inline ll min(ll a,ll b)
{
  if(a<b) re a;
  else re b;
}
inline ll max(ll a,ll b)
{
  if(a<b) re b;
  else re a;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ld n,m,k;
    cin>>n>>k;
    if(n<=1) m=1;
    else
    m=floor(log2(n)/log2(k))+1;

    cout<<m;

  }


  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 200000
int n,Num[MAXN+5],l[MAXN+5],r[MAXN+5],T[MAXN+5],top;
long long Ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>Num[i];
    for(int i=1;i<=n;i++){
        l[i]=1;
        while(top&&Num[T[top]]>Num[i]) top--;
        if(top) l[i]=T[top]+1;
        T[++top]=i;
    }
    top=0;
    for(int i=n;i>=1;i--){
        r[i]=n;
        while(top&&Num[T[top]]>Num[i]) top--;
        if(top) r[i]=T[top]-1;
        T[++top]=i;
    }
    for(int i=1;i<=n;i++)
        Ans+=(long long)Num[i]*(i-l[i]+1)*(r[i]-i+1);
    cout<<Ans;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int a,b;
ll solve(){
   ll ans=0;
   

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

    cin>>a>>b;
    cout<<a*b<<endl;
    //cout<<solve()<<endl;
    return 0;
}

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

int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<s.size()-5+1;i++){
		string str=s.substr(i,5);
		if(str=="peach")s.replace(i,5,"apple");
		else if(str=="apple")s.replace(i,5,"peach");
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
int main()
{
 double l,a,b,c;
 cin>>l;
a=l/3.0;
b=(l-a)/2;
c=l-(a+b);
c=a*b*c;
cout<<fixed<<setprecision(10)<<c<<endl;

}


Measured memory_bytes: 3676
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextString(scanner)
	for i := 0; i < len(n); i++ {
		if n[i] == '1' {
			fmt.Fprint(writer, "9")
			continue
		}
		if n[i] == '9' {
			fmt.Fprint(writer, "1")
			continue
		}
		fmt.Fprintf(writer, "%c", n[i])
	}
	writer.Flush()
}


Measured memory_bytes: 640
import java.io.*;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		String[] bubble = new String[n];
		String[] select = new String[n];
		String[] confirm=new String[n];
		for (int i = 0; i < n; i++) {
			String str = st.nextToken();
			bubble[i] = str;
			select[i] = str;
                        confirm[i]=str;
			
			
		}
		bubblesort(bubble);
		selectsort(select);
		StringBuilder stb1 = new StringBuilder(bubble[0]);
		StringBuilder stb2 = new StringBuilder(select[0]);
		boolean con1=sortconfirm(confirm, bubble);
		boolean con2=sortconfirm(confirm,select);
		
		for (int i = 1; i < n; i++){
            stb1.append(" " + bubble[i]);
            stb2.append(" " + select[i]);
        }
		System.out.println(stb1+"\r\n"+(con1?"Stable":"Not stable"));			
		System.out.println(stb2+"\r\n"+(con2?"Stable":"Not stable"));

	}

	static void bubblesort(String[] in) {
		for (int i = in.length; i > 0; i--) {
			for (int j = 1; j < i; j++) {

				if (in[j - 1].charAt(1) > in[j].charAt(1)) {
					
					String tmp = in[j - 1];
					in[j - 1] = in[j];
					in[j] = tmp;
				}
			}
		}
		
	}

	static void selectsort(String[] in) {
		
		for(int i=0;i<in.length-1;i++){
			int mini=i;
			for(int j=i+1;j<in.length;j++){
				if(in[mini].charAt(1)>in[j].charAt(1)){
					mini=j;
				}
			}
			if(mini!=i){
			String tmp=in[i];
			in[i]=in[mini];
			in[mini]=tmp;}
		}}
	static boolean sortconfirm(String[] input,String[] sorted){
		StringBuilder[] comp1=new StringBuilder[9];
		StringBuilder[] comp2=new StringBuilder[9];
		for(int i=0;i<9;i++){
			comp1[i]=new StringBuilder();
			comp2[i]=new StringBuilder();
		}
		for(int i=0;i<input.length;i++){
			char s=input[i].charAt(1);
			comp1[Integer.parseInt(Character.toString(s))-1].append(input[i].charAt(0));
			char t=sorted[i].charAt(1);
			comp2[Integer.parseInt(Character.toString(t))-1].append(sorted[i].charAt(0));
		}
		boolean con=true;
		for(int i=0;i<9;i++){
			if(comp1[i].toString().equals(comp2[i].toString()))continue;
			else con=false;break;
		}
		return con;
	}
}

Measured memory_bytes: 17072
#include<stdio.h>


int main(){
int m, f, r;

while(1){
  scanf("%d %d %d", &m, &f, &r);
  if(m == -1 && f == -1 && r == -1) break;
  if(r != -1){
      if(r >= 50 )
        printf("C\n");
      else if(30 <= m + f && m + f <50 )
        printf("D\n");
      else
        printf("F\n");
  }else{
      if(m == -1 || f == -1)
        printf("F\n");
      else if(m + f >= 80)
        printf("A\n");
      else if(65 <= m + f && m + f <80)
        printf("B\n"); 
      else if(50 <= m + f && m + f <65)
        printf("C\n"); 
      else if(30 <= m + f && m + f <50)
        printf("D\n"); 
      else
        printf("F\n");
  }
}

    
    
}


Measured memory_bytes: 2692
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int a,b,c,d,q,cnt,pos,pos1,pos2,la,lb,len;
int main()
{
	q=in();while (q--){
		a=in();b=in();c=in();d=in();
		len=(a+b)/(min(a,b)+1);
		int l=1,r=a;pos=0;
		while (l<=r){
			int mid=(l+r)>>1;cnt=(mid+len-1)/len;
			la=a-mid;lb=b-cnt+1-len;
			if (1ll*la*len<lb) r=mid-1;
			else pos=mid,l=mid+1;
		}cnt=(pos+len-1)/len;pos1=(cnt)?cnt-1+pos:0;
		la=a-pos;lb=b-max(0,cnt-1);pos2=pos1+lb-(len*la);
		for (int i=c;i<=d;++i){
			if (i<=(cnt-1)*(len+1)) putchar((i%(len+1))?'A':'B');
			else if (i<=pos1) putchar('A');
			else if (i<=pos2) putchar('B');
			else putchar(((i-pos2)%(len+1)==1)?'A':'B');
		}puts("");
	}return 0;
}

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

int main(){
	int H, W;
	int i = 1;
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		if (i)i = 0;
		else cout << endl;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cout << '#';
			}
			cout << endl;
		}
	}
	cout << endl;
	return 0;
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    long a, b;
    cin >> a >> b;
    int res = 0;
    for (long i = 2; i * i <= a; i++) {
        if (a % i == 0) {
            while (a % i == 0) {
                a /= i;
            }
            if (b % i == 0) {
                res++;
            }
        }
    }
    if (a > 1 && b % a == 0) {
        res++;
    }
    cout << res + 1;

    return 0;
}

Measured memory_bytes: 384
N = input()
if len(set(list(N))) == 1:
  print(N)
else:
  #入力が入力の百の位*3より小さい ex)750<777 112>11
  if int(N) < int(str(int(N[0]))*3):
    print(N[0]*3)
  else:
  	print(str(int(N[0])+1)*3)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define PI 3.14159265358979323846  // 円周率

/**
 * @brief 度をラジアンに変換する。
 * @param degree 度
 * @return ラジアン
 */
double deg2rad(double degree)
{
    return degree * PI / 180.0;
}

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    H %= 12;
    double ans2;
    double cab;
    double degA;
    double degB;
    degA = (double)H*30 + (double)M*0.5;
    degB = (double)M*6;
    double degAB = min(abs(degA-degB), abs(360-degA+degB));
    cab = cos(deg2rad(degAB));

    ans2 = A*A + B*B -(2*A*B*cab);
    printf("%.10lf\n", sqrt(ans2));

}   

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

int main(){
  ll n; cin >> n;
  vector<string> s(n);
  for(ll i=0; i<n; ++i) cin >> s[i];
  sort(s.begin(), s.end());
  ll res = 1;
  for(ll i=0; i<n-1; ++i){
    if(s[i] != s[i+1]) ++res;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 9516
N = int(input())
H = list(map(int,input().split()))
max1 = 0
count = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        count = 0
    
    if count > max1:
        max1 += 1
print(max1)

Measured memory_bytes: 14224
#ABC082

s = sorted(input())
t = sorted(input())
a = s
b = sorted(t,reverse = True)

c = False

if len(s) < len(t):
    if s == t[:len(s)]:
        c = True
        
if c == False:
    for i in range(min(len(a),len(b))):
        if a[i] < b[i]:
            c = True
            break
        elif a[i] > b[i]:
            break

if c:
    print("Yes")
else:
    print("No")

            
       
               
    



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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> H(N);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    long long ans = 0;
    if(N <= K) printf("%lld\n", ans);
    else{
        for(int i = 0; i < N - K; i++){
            ans += H[i];
        }
        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var y, p, p1, p2, p3, p4 float64
	fmt.Scan(&n)

	x := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&y)
		p = math.Abs(x[i] - y)
		p1 = p1 + p
		p2 = p2 + math.Pow(p, 2)
		p3 = p3 + math.Pow(p, 3)
		p4 = math.Max(p, p4)
	}
	fmt.Println(p1)
	fmt.Println(math.Sqrt(p2))
	fmt.Println(math.Cbrt(p3))
	fmt.Println(p4)
}



Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int a[3]={0,0,0};
  for(int i=0;i<s.size();i++){
    int q=s[i]-'a';
    a[q]++;
  }
  int m=abs(a[0]-a[1]);
  m=max(abs(a[1]-a[2]),m);
  m=max(abs(a[0]-a[2]),m);
  if(m<=1)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = B[A[0]-1]
for i in range(1, N):
    ans += B[A[i]-1]
    if A[i]-A[i-1] == 1:
        ans += C[A[i-1]-1]

print(ans)

Measured memory_bytes: 9064
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	sort(a, a+5, greater<int>());
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.text.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = (int)998244353;

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

    void run() {

        String s = sc.next();

        char c = s.charAt(s.length()-1);

        if (c == '3') {
            System.out.println("bon");
        } else if (c == '0' || c == '1' || c == '6' || c == '8') {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }



    }
}



Measured memory_bytes: 35648
n = int(input())
t = list(map(int,input().split()))
m = int(input())
d = [tuple(map(int,input().split())) for i in range(m)]
ans=0
for px,i in zip(d,range(m)):
    q=t[:]
    q[px[0]-1]=px[1]
    print(sum(q))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    string s;
    cin>>s;
    int ansi=-1;
    vector<int> ans(3);
    if(s[0]=='R') ans[0]=1;
    ansi=ans[0];
    for(int i=1;i<3;i++){
        if(s[i]=='R') ans[i]=ans[i-1]+1;
        else ans[i]=0;
        ansi=max(ansi,ans[i]);
    }
    cout<<ansi;
    return 0;
}

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

int main() {
  int N, A, B, C, X;

  while(1) {
    cin >> N >> A >> B >> C >> X;
    if(N == 0) break;

    vector<int> Y;
    for(int i = 0; i < N; i++) {
      int y;
      cin >> y;
      Y.push_back(y);
    }

    int x = X;
    int cnt = 0;

    for(int i = 0; i < N; i++) {
      for(; cnt <= 10000; cnt++) {
        if(x == Y[i]) {
          if(i < (N-1) && Y[i] == Y[i+1]) {
            cnt++;
            x = ((A * x + B) % C);
          }
          break;
        }
        x = (A * x + B) % C;
      }   
    }
    if(cnt <= 10000)
      cout << cnt << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3136
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            out.println(a <= c && c <= b ? "Yes" : "No");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int flag=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout<<i+1<<" "<<i+2<<endl;
			flag=1;
			break;
		}
		else if(i<s.size()-2&&s[i]==s[i+2])
		{
			cout<<i+1<<" "<<i+3<<endl;
			flag=1;
			break;
		}
	}
	if(!flag)
	cout<<-1<<" "<<-1<<endl;
	return 0;	
} 

Measured memory_bytes: 512
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    s, w = map(int, input().split())
    print("unsafe" if s <= w else "safe")
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 9844
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
acum1 = [0]
for i in range(N):
    acum1.append(acum1[-1] + A[i])
acum2 = [0]
for i in range(M):
    acum2.append(acum2[-1] + B[i])
ans = 0
j = M
for i in range(N + 1):
    if acum1[i] > K:
        break
    while acum2[j] > K - acum1[i] and j > 0:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47464
def ispalindrome(str): return 1 if str == str[::-1] else 0


def resolve():
    S = list(input())

    if not ispalindrome(''.join(S)):
        print('No')
        return

    num = len(S)
    half = num // 2

    half_1 = S[0:half]
    half_2 = S[half + 1:]

    if not ispalindrome(''.join(half_1)):
        print('No')
        return

    if not ispalindrome(''.join(half_2)):
        print('No')
        return

    print('Yes')


resolve()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	double a, b, c, d, e, f, x, y;
	while (cin >> a >> b >> c >> d >> e >> f) {
		// (1) a x + b y = c  && (2) dx +  ey =  f
		// (3) adx + bdy = cd && (4) adx + aey = af
		// (3) - (4) (bd - ae) * y = cd - af
		// (5) y = (cd - af) / (bd - ae)
		// (1) x = (c - by) / a
		y = (c * d - a * f) / (b * d - a * e);
		x = (c - b * y) / a;
		// 1.234ab * 1000
		// 1234.ab + 0.5
		// (int)(1234.cd / 1000)
		// 1.234c
		x *= pow(10, 3);
		y *= pow(10, 3);
		if (x < 0) {
			x -= 0.5;
		}
		else if (x > 0) {
			x += 0.5;
		}
		else {
			x;
		}
		if (y < 0) {
			y -= 0.5;
		}
		else if (y > 0) {
			y += 0.5;
		}
		else {
			y;
		}
		x = (int)x;
		y = (int)y;
		x /= pow(10, 3);
		y /= pow(10, 3);
		cout << fixed << setprecision(3) << x << flush;
		cout << " " << flush;
		cout << fixed << setprecision(3) << y << flush;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main{
    public static void main(String[] args) throws IOException {
        scanner sc = new scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] choice = new int[n];
        boolean[] memo = new boolean[k+1];

        for (int i = 0; i < n; i++) {
            choice[i] = sc.nextInt();
        }

        for (int i = 0; i <= k; i++) {
            for (int j = 0; j < n; j++) {
                if (i >= choice[j] && !memo[i-choice[j]])
                    memo[i] = true;
            }
        }

        out.println(memo[k]?"First":"Second");

        out.flush();

    }
}
class scanner{
    StringTokenizer st;
    BufferedReader br;
    public scanner(InputStream s){
        br = new BufferedReader(new InputStreamReader(s));
    }
    public scanner (String s) throws FileNotFoundException { br = new BufferedReader(new FileReader(s));}

    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return  Long.parseLong(next());
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public boolean ready() throws IOException {
        return br.ready();
    }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

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


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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll temp=(c-a-b)*(c-a-b);
    ll fk=4*a*b;
    if((c-a-b)<=0){
        cout<<"No"<<endl;
        return;
    }
    if(temp>fk) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────

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

	vi a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	int c = 0, d = 0;
	vi o(n);
	iota(ASC(o), 1);
	do {
		c++;
		if (a == o) {
			break;
		}
	} while (next_permutation(ASC(o)));

	iota(ASC(o), 1);
	do {
		d++;
		if (b == o) {
			break;
		}
	} while (next_permutation(ASC(o)));

	//cout << c << " " << d << endl;
	cout << abs(c - d) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,ans=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a==7){
    if(b==5&&c==5){
      ans=1;
    }
  }
  if(b==7){
    if(a==5&&c==5){
      ans=1;
    }
  }
  if(c==7){
    if(b==5&&a==5){
      ans=1;
    }
  }
  if(ans==0){
    printf("NO");
  }else{
    printf("YES");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

ll st[1000];
int sp = 0;

void push(ll n)
{
    st[sp] = n;
    sp++;
}

ll pop(void)
{
    sp--;
    return st[sp]; 
}
int main()
{
    char s[100];
    while(scanf("%s", s) != EOF){
        ll a, b;
        if (s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-'){
            a = pop();
            b = pop();
            push(b - a);
        }
        else if (s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }
        else {
            push(atoi(s));
        }
    }
    cout << pop() << endl;
    return 0;
}


Measured memory_bytes: 3168
f = [list(map(int, input().split())) for _ in range(3)]
a, b = [0], f[0]
a.append(f[1][0] - b[0])
a.append(f[2][0] - b[0])
flag = True
for i in range(3):
  for j in range(3):
    if a[i] + b[j] != f[i][j]:
      flag = False
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
/*
Author: Srinjoy
Language: C++ 17
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define fileinput(s) freopen(s,"r",stdin)
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
const ll mod = 1000000007;

template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }
 
template<class T>
istream& operator >> (istream& in, pair<T, T> & v){ in >> v.X >> v.Y;return in; }

void printArr(vector<int> arr){
	cout<<"\n------------------------------------\n";

	for(int i=0;i<arr.size();i++) cout<<arr[i]<<" ";
	
	cout<<"\n------------------------------------\n";
}


int main(){
	optimiza_io

	const int inf = 1e9;

	int n,p;
	cin>>n>>p;

	vector<int> arr(n);
	cin>>arr;

	vector<ll> dp(n,inf);

	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);

	for(int i=2;i<n;i++){
		for(int k= max(i-p,0); k<i ; k++){
		
			dp [i] = min( dp[i], (dp[ k ] + abs(arr[i] - arr[k])) );

		}
	}

	

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

Measured memory_bytes: 1408
def makeDivisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return divisors

def isPrime(n):
    for i in range(2, n+1):
        if i**2 > n:
            break
        if n % i == 0:
            return False
    return True

A, B = map(int, input().split())

div_A = makeDivisors(A)
div_B = makeDivisors(B)

common_divisors = list(set(div_A) & set(div_B))

count = 0
for i in common_divisors:
    if isPrime(i):
        count += 1

print(count)


Measured memory_bytes: 41056
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;


template <typename T>
struct segtree{
    int n;
    T UNIT;
    vector<T> dat;
    segtree(int n_, T unit){
        UNIT = unit;
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n);
        for(int i = 0; i < 2*n; i++) dat[i] = UNIT;
    }

    T calc(T a, T b){
        T ans;
        ans = max(a, b);
        return ans;
    }
    void insert(int k, T a){
        dat[k+n-1] = a;
    }
    void update_all(){
        for(int i = n-2; i >= 0; i--){
            dat[i] = calc(dat[i*2+1], dat[i*2+2]);
        }
    }
    //k番目の値(0-indexed)をaに変更
    void update(int k, T a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = calc(dat[k*2+1], dat[k*2+2]);
        }
    }

    //[a, b)
    //区間[a, b]へのクエリに対してはquery(a, b+1)と呼ぶ
    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        if(r <= a || b <= l) return UNIT;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = query(a, b, k*2+1, l, (l+r)/2);
            T vr = query(a, b, k*2+2, (l+r)/2, r);
            return calc(vl, vr);
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, K; cin >> N >> K;
    int M = 300000;
    segtree<int> sgt(300001, 0);
    int ans = 0;
    for(int i = 0; i < N;i++){
        int a; cin >> a;
        int l = max(0, a-K);
        int r = min(M, a+K);
        int q = sgt.query(l, r+1);
        sgt.update(a, q+1);
        ans = max(ans, q+1);
    }
    cout << ans << endl;

}

Measured memory_bytes: 7432
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
//	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();


		int ans = 1;

		if(X < 600) {
			ans = 8;
		}else if(X < 800) {
			ans = 7;
		}else if(X < 1000) {
			ans = 6;
		}else if(X < 1200) {
			ans = 5;
		}else if(X < 1400) {
			ans = 4;
		}else if(X < 1600) {
			ans = 3;
		}else if(X < 1800) {
			ans = 2;
		}else {
			ans = 1;
		}


		System.out.println(ans );
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 35608
n, m = map(int, input().split())
a_array = [int(input()) for x in range(m)]
res = [1 for x in range(n + 1)]
res[1] = 1
for i in a_array:
    res[i] = -1
if n <= 2:
    print(n if m == 0 else 1)
    exit()
for i in range(2, n + 1):
    if res[i] == -1:
        continue
    if res[i - 1] != -1 and res[i - 2] != -1:
        res[i] = (res[i - 1] + res[i - 2])%1000000007
    elif res[i - 1] != -1 or res[i - 2] != -1:
        res[i] = max(res[i - 1], res[i - 2])%1000000007
    else:
        res[i] = 0
print(res[-1])


Measured memory_bytes: 7860
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
 
int main(void) {
    Int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
LL gcd(LL a,LL b)
{
	return (b==0)?a:gcd(b,a%b);
}
int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	off;
	LL a,b,c,d;
	cin>>a>>b>>c>>d;
	LL al = (a-1)/c;
	LL ah = b/c;
	LL adiv = ah - al;
	LL bl = (a-1)/d;
	LL bh = b/d;
	LL bdiv = bh - bl;
	LL lcm = (c*d)/gcd(c,d);
	LL abl = (a-1)/lcm;
	LL abh = b/lcm;
	LL abdiv = abh - abl;
	// cout<<"ah "<<ah <<" al "<<al<<"\n";
	// cout<<"bh "<<bh <<" bl "<<bl<<"\n";
	LL ans = adiv + bdiv - abdiv;
	cout<<(b-a+1)-ans;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,j;
    cin>>a>>b;
    vector<string>v(a);
    for(i=0; i<a; i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(i=0; i<a; i++)
    {
        cout<<v[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256