akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e10;

long long x[1000], y[1000];
int main() {
	long long n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
	}
	map<pair<long long, long long>, long long> p;
	for (long long i = 0; i < n; i++)
	{
		for (long long j = 0; j < n; j++) {
			if (i == j) continue;

			long long dx = x[j] - x[i];
			long long dy = y[j] - y[i];
			p[make_pair(dx, dy)]++;
		}
	}
	long long ans = 0;
	for (auto i : p) {
		//debug(i.second);
		ans = max(ans, i.second);
	}
	cout << n - ans << endl;
	return 0;

}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(15);
  string S, FS, BS;
  cin >> S;
  u32 Q;
  cin >> Q;
  u32 flag = 0, cont_flag = 0;
  for (u32 i = 0; i < Q; ++i) {
    u32 T;
    cin >> T;
    if (T == 1) {
      flag++;
      cont_flag++;
    } else {
      cont_flag = 0;
      u32 F;
      cin >> F;
      string C;
      cin >> C;
      if (F == 1) {
        if (flag & 0x01) {
          BS += C;
        } else {
          FS = C + FS;
        }
      } else {
        if (flag & 0x01) {
          FS = C + FS;
        } else {
          BS += C;
        }
      }
    }
  }
  flag -= cont_flag;
  if (flag & 0x01) {
    if ((cont_flag & 0x01) == 0) {
      reverse(S.begin(), S.end());
      reverse(FS.begin(), FS.end());
      reverse(BS.begin(), BS.end());
      cout << BS + S + FS << endl;
      return 0;
    }
  } else {
    if (cont_flag & 0x01) {
      reverse(S.begin(), S.end());
      reverse(FS.begin(), FS.end());
      reverse(BS.begin(), BS.end());
      cout << BS + S + FS << endl;
      return 0;
    }
  }
  cout << FS + S + BS << endl;
  return 0;
}


Measured memory_bytes: 1360
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n, sum=0;
		n=sc.nextInt();
		while (n >= 1)
		{
			sum += n % 10;
			n /= 10;
		}
		if (sum != 1)
			System.out.print(sum);
		else
			System.out.print(10*sum);
	}
}


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

int main() {
    string S;cin >> S;
    int N = S.size();
    int ans[N] = {};
    int flag = 0;int countR = 0;int countL = 0;int tarR = 0,tarL = 0;
    for (int i = 0; i < N; ++i) {
        if (flag == 0){
            //"RL"発生までのループ
            if (S[i] == 'R'){
                countR++;
                ans[i] = 0;
            }
            else if (S[i] == 'L'){
                    ans[i - 1] += (countR + 1) / 2;
                    ans[i] += countR / 2;
                    flag = 1;
                    countR = 0;countL = 1;
                    tarR = i - 1;tarL = i;
                    if (i == N - 1) ans[i] += 1;
            }
        }
        else if (flag == 1){
            //"LR"発生までのループ
            if (i == N - 1){
                countL++;
                ans[tarR] += countL / 2;
                ans[tarL] += (countL + 1) / 2;
            }
            else if (S[i] == 'L'){
                countL++;
                ans[i] = 0;
            }
            else if (S[i] == 'R'){
                ans[tarR] += countL / 2;
                ans[tarL] += (countL + 1) / 2;
                flag = 0;
                ans[i] = 0;
                countL = 0;countR = 1;
            }
        }
    }
    for (int i = 0;i < N; i++){
        cout << ans[i] << " ";
        if (i == N - 1) cout << endl;
    }
}


Measured memory_bytes: 1024
M = 10**9 + 7
a = [1] + [0] * 12
p = 1
for c in reversed(input()):
    r = range(0, p * 10, p) if c == '?' else (p * int(c),)
    a = [sum(a[(i - j) % 13] for j in r) % M for i in range(13)]
    p = p * 10 % 13
print(a[5])


Measured memory_bytes: 47524
import itertools
n=int(input())
ball=[]
for i in range(n):
    ball.append([int(i) for i in input().split()])

ball.sort()

# p,qの候補取得
pq_cand=set()
for v in itertools.combinations(ball,2):
    xdiff=v[0][0]-v[1][0]
    ydiff=v[0][1]-v[1][1]
    pq_cand.add((xdiff,ydiff))
    
connect=0
for pq in pq_cand:
    con=0
    for point in ball:
        if [point[0]+pq[0],point[1]+pq[1]] in ball:
            con+=1
    connect=max(connect,con)
print(n-connect)


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,dat[105];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&dat[i]);
	
	int cur=0,res=0;
	for(int i=1;i<=n+1;i++)
		if(dat[i]!=dat[i-1])
		{
			res+=cur/2;cur=1;
		}
		else cur++;
	printf("%d",res);
	return 0;
}

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

long long mod=1e9+7;

void comb(vector<vector<long long> > &vec){
  for(size_t i=0;i<vec.size();i++){
    vec[i][0]=1;
    vec[i][i]=1;
  }
  for(size_t i=1;i<vec.size();i++){
    for(size_t j=1;j<i;j++){
      vec[i][j]=vec[i-1][j-1]+vec[i-1][j];
      vec[i][j]%=mod;
    }
  }
}

int main(){
  long long n,k;
  cin >> n >> k;  
  vector<vector<long long> > vec(2005,vector<long long>(2005,0));
  comb(vec);
  for(int i=1;i<=k;i++){
    cout << (vec[n-k+1][i]*vec[k-1][i-1])%mod << endl;
  }
  return 0;
}


Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

ll BIT1[200010];
ll BIT2[200010];

void add1(int A, ll B) {
	while (A > 0) {
		BIT1[A] = min(BIT1[A], B);
		A -= A & -A;
	}
}
ll query1(int A) {
	ll kotae = 1e18;
	while (A <= 200000) {
		kotae = min(kotae, BIT1[A]);
		A += A & -A;
	}
	return kotae;
}
void add2(int A, ll B) {
	while (A <= 200000) {
		BIT2[A] = min(BIT2[A], B);
		A += A & -A;
	}
}
ll query2(int A) {
	ll kotae = 1e18;
	while (A > 0) {
		kotae = min(kotae, BIT2[A]);
		A -= A & -A;
	}
	return kotae;
}

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


	ll N, D;
	cin >> N >> D;
	int A[200001];
	rep1(i, N) cin >> A[i];

	rep1(i, 200000) BIT1[i] = 1e18;
	rep1(i, 200000) BIT2[i] = 1e18;

	rep1(i, N) {
		add1(i, A[i] + i * D);
	}
	rep1(i, N) {
		add2(i, A[i] - i * D);
	}

	ll setuyaku = 0;
	for (int i = 2; i < N; i++) {
		ll kari1 = query1(i + 1) - i * D;
		ll kari2 = query2(i - 1) + i * D;
		if (A[i] > min(kari1, kari2)) {
			setuyaku += A[i] - min(kari1, kari2);
		}
	}

	ll motomoto = 0;
	rep1(i, N - 1) motomoto += A[i];
	rep1(i, N - 1) motomoto += A[i + 1];
	motomoto += (N - 1) * D;

	co(motomoto - setuyaku);

	Would you please return 0;
}

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<ll>> abcs;
    for(int i=0; i<n; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        abcs.push_back(vector<ll>{a, b, c});
    }
    vector<vector<ll>> dp(n, vector<ll>(3, 0));
    dp.at(0) = abcs.at(0);
    for(int i=1; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            chmax(dp.at(i).at(j), dp.at(i-1).at((j+1)%3) + abcs.at(i).at((j)));
            chmax(dp.at(i).at(j), dp.at(i-1).at((j+2)%3) + abcs.at(i).at((j)));
        }
    }
    // for(auto &v : dp)
    // {
    //     for(auto num : v)
    //     {
    //         cout << num << " ";
    //     }
    //     cout << '\n';
    // }
    cout << max(dp.back().at(0), max(dp.back().at(1), dp.back().at(2))) << '\n';

    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0}; 

int n;
int data[300];
int dp[300][301]; // hankai
int score[300][301];

int solve(int st, int en)
{
    //cout << "call : " << st << " " << en << endl;;
    if ( dp[st][en] ) {
        //cout << " ret1 : 0" << endl;
        return score[st][en] = dp[st][en] = 0;
    }
    if ( score[st][en] ) {
        //cout << " ret2 : " << score[st][en] << endl;
        return score[st][en];
    }
    if (en - st < 2) {
        //cout << " ret3 : " << en - st << endl;
        return score[st][en] = en - st;
    }
    int ret = en - st;
    for (int i = st+2; i < en; i++) {
        if (dp[st][i]) {
            ret = min(solve(i, en), ret);
        }
    }
    return score[st][en] = min(ret, 1+solve(st+1, en));
    //score[st][en] = min(ret, 1+solve(st+1, en));
    //cout << score[st][en] << endl;
    //return score[st][en];
}

void make(int st, int en)
{
    //cout << "call : " << st << " " << en << endl;
    if (en - st < 2) return;

    if (0 <= st - 1 && en + 1 <= n && abs(data[st-1]-data[en]) < 2)
        dp[st-1][en+1] = 1;

    for (int i = max(0LL, st - (en - st)); i < st; i++)
        if (dp[i][st]) dp[i][en] = 1;

    for (int i = en+1; i < min(n+1, en + (en - st)); i++)
        if (dp[en][i]) dp[st][i] = 1;

}

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

    cin >> n;
    while ( n ) {
        memset(data, 0, sizeof(data));
        memset(dp, 0, sizeof(dp));
        memset(score, 0, sizeof(score));
        rep(i, n) cin >> data[i];

        rep(i, n-1) if (abs(data[i] - data[i+1]) < 2) dp[i][i+2] = 1;
        /*
        rep(i, n) {
            Rep(j, n+1) {
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }
        cout << "============" << endl;
        */

        for (int i = 2; i < n; i++) {
            for (int st = 0; st < n - i + 1; st++) {
                int en = st + i;
                if (dp[st][en]) make(st, en);
            }
        }

        /*
        rep(i, n) {
            Rep(j, n+1) {
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }
        */

        cout << n - solve(0, n) <<endl;
        cin >> n;
    }

    return 0; 
}



Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1)a = 14;
	if (b == 1)b = 14;
	if (a > b)puts("Alice");
	else if (a < b)puts("Bob");
	else puts("Draw");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF -1
using namespace std;

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

int main() {

	int a, b;
	cin >> a >> b;
	int ans = 0;

	for (int i = 1; i <= 9; i++) {
		for (int k = 0; k <= 9; k++) {
			for (int j = 0; j <= 9; j++) {
				ll c = 10000 * i + 1000 * k + 100 * j + 10 * k + i;
					if (c >= a && c <= b) {
						ans += 1;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b;
  cin>>a>>b;
  if(a%3==0 || b%3==0 || (a+b)%3==0){
    cout<<"Possible"<<endl;
  }
  else cout<<"Impossible"<<endl;
}

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

int main(){
  stack<int> S1; 
  stack<pair<int,int>> S2;
  char ch;
  int sum=0;
  for(int i=0; cin >> ch ; i++){
    if(ch=='\\') S1.push(i);
    else if(ch == '/' && S1.size()>0){
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i -j;
      while( S2.size() > 0 && S2.top().first > j){
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }
  
  vector<int> ans;
  int t = 0;
  while( S2.size() > 0 ){ ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i = 0; i < ans.size(); i++){
    cout <<" ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;
  
  return 0;
}
                                        
  
  
  
     





Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<((ll)n);i++)
#define rep1(i,n) for(ll i=1;i<=((ll)n);i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define meow(a) cout<<a<<" meow\n";
typedef pair<long long,long long> pii;
const ll maxn=200005;
const ll MOD=998244353;
double mypow(ll a,ll b){
	double res=1;
	while(b){
		if(b&1) res=res*a;
		a=a*a;

		b>>=1;
	}
	return res;
}
ll n,m;


int main()
{
    //IOS;
    while(cin>>n>>m)
    {
        ll nowl=1,nowr=n;
        rep(i,m)
        {
            ll l,r;
            cin>>l>>r;
            nowl=max(l,nowl);
            nowr=min(r,nowr);
        }
        cout<<max(nowr-nowl+1,ll(0))<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Beautiful Currency
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int N = 200000;
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++)a[i] = sc.nextInt();
		double[][] dp = new double[n][N];
		for(int i=0;i<n;i++)Arrays.fill(dp[i], 1<<29);
		for(int i=1;i<N;i++)dp[0][i] = Math.abs(a[0]-i)*1.0/a[0];
		for(int i=0;i<n-1;i++){
			for(int j=1;j<N;j++){
				for(int k=j;k<N;k+=j){
					dp[i+1][k] = Math.min(dp[i+1][k], Math.max(dp[i][j], Math.abs(a[i+1]-k)*1.0/a[i+1]));
				}
			}
		}
		double min = 1<<29;
		for(int j=1;j<N;j++){
			min = Math.min(min, dp[n-1][j]);
		}
		System.out.printf("%.9f\n", min);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 42000
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
using namespace std;

int main()
{
__

int a,b,ans=1;

cin >> a >> b;

for(int i=(b-a);i>0;)
{
ans++;
i-=(a-1);
}

if(b==1)
cout << 0 << '\n';

else cout << ans << '\n';

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string S; cin >> S;
    int res = 0,N=S.size();
    for (int i=0;i<N/2;i++)if (S[i]!=S[N-1-i]) res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cstdlib>

#define N 501
#define conv(x) (int)(x-'A')
#define ft first
#define sd second

using namespace std;

typedef pair<int,int> Pa;

struct P{
  int x1, x2, y1, y2;
  P() {}
  P(int _x1, int _y1, int _x2, int _y2): x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}
};

int h, w;
char a[N][N];
map<char, P> mpp;
vector<char> v1, v2;

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {-1, 0, 1, 0};
bool dfs(int sx, int sy, int gx, int gy)
{
  int dr;
  char ch = a[sy][sx];
  if(sx == gx){
    dr = (sy > gy)? 0 : 2;
  } else {
    dr = (sx > gx)? 3 : 1;
  }

  while(!(sx == gx && sy == gy)){
    sx += xdir[dr];
    sy += ydir[dr];
    if(sx < 0 || sx >= w || sy < 0 || sy >= h) return false;
    if(isalpha(a[sy][sx]) && ch != a[sy][sx]) return false;
  }

  return true;
}

int solve()
{
  int t = -1, res = 0;

  while(v1.size() != t){
    t = v1.size();
    v2.clear();

    for(int i = 0; i < t; i++){
      int x1 = mpp[v1[i]].x1, y1 = mpp[v1[i]].y1, x2 = mpp[v1[i]].x2, y2 = mpp[v1[i]].y2;
      if((dfs(x1, y1, x1, y2) && dfs(x2, y2, x1, y2))
	 || (dfs(x1, y1, x2, y1) && dfs(x2, y2, x2, y1))){
	res += 2;
	a[y1][x1] = a[y2][x2] = '.';
      } else {
	v2.push_back(v1[i]);
      }
    }
    v1 = v2;
  }
  v1.clear();
  v2.clear();

  return res;
}

bool check(int p1, int q1, int p2, int q2)
{
  return (abs(p1-p2)+abs(q1-q2) != 1);
}

int main()
{
  bool used[26];
  while(cin>>h>>w && (h+w)){
    map<char, vector<Pa> > mp;
    fill(used, used+26, false);

    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++){
	cin >> a[i][j];
	if(isalpha(a[i][j])){
	  vector<Pa> vec;
	  if(used[conv(a[i][j])]) vec = mp[a[i][j]];
	  vec.push_back(Pa(i, j));
	  mp[a[i][j]] = vec;
	  used[conv(a[i][j])] = true;
	}
      }

    for(int i = 0; i < 26; i++){
      char ch = (char)('A'+i);
      if(used[i] && check(mp[ch][0].ft, mp[ch][0].sd, mp[ch][1].ft, mp[ch][1].sd)){
	mpp[ch] = P(mp[ch][0].sd, mp[ch][0].ft, mp[ch][1].sd, mp[ch][1].ft);
	v1.push_back(ch);
      }
    }

    cout << solve() << endl;
    mpp.clear();
  }

  return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    string s;
    cin>>s;
    int sz = s.size();
    if(sz%2){
        cout<<"No\n";
        return;
    }
    for(int i = 0; i < sz; i++){
        if(s[i%2]!="hi"[i%2]){
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
S=input()
# S="1234567876"
# S="35753"
# S="1111111111"

TARGET = 753
current_min_diff = 1000
for i in range(len(S) - 2):
    tmpS = S[i:i+3]
    diff = abs(int(tmpS) - TARGET)
    if (diff < current_min_diff):
        current_min_diff = diff
print(current_min_diff) 

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

const int Maxn = 105;

int n;
int a[Maxn];
int sum;
int best = 1000000000, bi;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    for (int i = 0; i < n; i++) {
        int cand = abs(n * a[i] - sum);
        if (cand < best) { best = cand; bi = i; }
    }
    printf("%d\n", bi);
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = INT()

ans = 2*(x//11)
x %= 11

if 1 <= x <= 6:
    ans += 1
elif 6 < x: 
    ans += 2
print(ans)


Measured memory_bytes: 5456
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;
int main()
{
    int64_t N, W;
    cin >> N >> W;
    vector<pair<int64_t, int64_t>>vec(N);
    for (int64_t i=0; i<N; i++) {
        int64_t v, w;
        cin >> w >> v;
        vec[i] = make_pair(v, w);
    }

    vector<vector<int64_t>>dp(N+1,vector<int64_t>(100001, 0));
    for (int64_t i=0; i<N; i++) {
        for (int sum_w = W; sum_w >= 0; --sum_w) {
            // i 番目の品物を選ぶ場合
            if (sum_w - vec[i].second >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - vec[i].second] + vec[i].first);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 83100
// Author - Saikat_7
#include <bits/stdc++.h> 
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define trav(i,cont) for(const auto& i:cont)
#define cs(x) cout<<x<<" "
#define cn(x) cout<<x<<" "<<endl
#define ll long long int
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007 //998244353 
#define inf 1e17
const int mx = 2000005; // 2* (10 to power 5);
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    int tc=1;
    // cin>>tc;
    while(tc-- > 0)
    {
        ll h,w;
        cin>>h>>w;
        char arr[h][w];
       	for(int i=0;i<h;i++)
       	{
       		for(int j=0;j<w;j++)
       		{
       			cin>>arr[i][j];
       		}
       	}
       	ll dp[h][w];
       	 for(int i=0;i<h;i++)
       	{
       		for(int j=0;j<w;j++)
       		{
       			if(arr[i][j]=='#')
       				dp[i][j]=0;
       			else
       			{
       				if(i==0 && j==0)
       					dp[i][j]=1;
       				else if(i==0)
       					dp[i][j]=dp[i][j-1];
       				else if(j==0)
       					dp[i][j]=dp[i-1][j];
       				else
       					dp[i][j]=(dp[i-1][j]+dp[i][j-1])% mod;
       			}
       		}
       	}
       	// for(int i=0;i<h;i++)
       	// {
       	// 	for(int j=0;j<w;j++)
       	// 	{
       	// 		cout<<dp[i][j]<<" ";
       	// 	}
       	// 	cout<<endl;
       	// }
       	cout<<dp[h-1][w-1];
       
    }
    return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
        double r = stdin.nextDouble();
	double x = Math.PI;
	double s = (double)x*r*r;
	double l = (double)2*x*r;
	System.out.printf("%.6f %.6f %n", s, l);
    }
}

	

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

void solve(int n, int l) {
    map<int, int> pos;
    vector<char> dir(n);
    char d;
    int p;
    for (int i = 0; i < n; i++) {
        cin >> d >> p;
        dir[i] = d;
        pos[i] = p;
    }
    int last_ant;
    int elapsed = 0;
    vector<vector<int> > tunnel(l + 1);
    while (true) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (dir[i] == 'L') pos[i]--;
            else if (dir[i] == 'R') pos[i]++;
            else cnt++;
        }
        if (cnt == n) break;
        for (int i = 0; i <= l; i++) tunnel[i].clear();
        for (int i = 0; i < n; i++) {
            if (dir[i] == 'N') continue;
            tunnel[pos[i]].push_back(i);
        }
        for (int i = 1; i < l; i++) {
            if (tunnel[i].size() == 2) {
                for (int j = 0; j < 2; j++) {
                    if (dir[tunnel[i][j]] == 'L') {
                        dir[tunnel[i][j]] = 'R';
                    }
                    else if (dir[tunnel[i][j]] == 'R') {
                        dir[tunnel[i][j]] = 'L';
                    }
                }
            }
        }
        if (tunnel[l].size() == 1) {
            dir[tunnel[l][0]] = 'N';
            last_ant = tunnel[l][0];
        }
        if (tunnel[0].size() == 1) {
            dir[tunnel[0][0]] = 'N';
            last_ant = tunnel[0][0];
        }
        elapsed++;
    }
    cout << elapsed << ' ' << last_ant + 1 << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    while (true) {
        cin >> N >> L;
        if (N == 0 && L == 0) break;
        solve(N, L);
    }
    return 0;
}


Measured memory_bytes: 3152
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);

		int a=s.nextInt();
		for(int i=0;i<a;i++){
			int d=0;
			for(int k=0; k<2; k++) {
				String b=s.next();
				int temp1=0,temp2=1;
				for(int j=0;j<b.length();j++){
					if(b.charAt(j)=='m'){
						d+=1000*temp2;
						temp2=1;
					}
					else if(b.charAt(j)=='c') {
						d+=100*temp2;
						temp2=1;
					}
					else if(b.charAt(j)=='x') {
						d+=10*temp2;
						temp2=1;
					}
					else if(b.charAt(j)=='i') {
						d+=temp2;
						temp2=1;
					}
					else {
						temp2=(int)b.charAt(j)-'0';
					}
				}
			}
			int g=d;
			if(g/1000>1) {
				System.out.print((int)g/1000+"m");
			}
			else if(g/1000==1) {
				System.out.print("m");
			}
			if(g%1000/100>1) {
				System.out.print((int)g%1000/100+"c");
			}
			else if(g%1000/100==1) {
				System.out.print("c");
			}
			if(g%100/10>1) {
				System.out.print((int)g%100/10+"x");
			}
			else if(g%100/10==1) {
				System.out.print("x");
			}
			if(g%10>1) {
				System.out.print(g%10+"i");
			}
			else if(g%10==1) {
				System.out.print("i");
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 39052
#include<bits/stdc++.h>
#define N ((int)(1e5 + 5))
using namespace std;

int deg[N];

int main()
{
    int n, m;
    scanf("%d %d",&n,&m);
    while(m--){
        int a, b;
        scanf("%d %d",&a,&b);
        deg[a]++;
        deg[b]++;
    }
    for(int i = 1; i<=n; i++){
        if(deg[i]&1){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll inf = (1LL<<59);

int main(){
    int N, M; cin >> N >> M;
    ll x[N][3];
    for(int i=0; i<N; i++) cin >> x[i][0] >> x[i][1] >> x[i][2];

    ll ans = -inf;

    vector<ll> cake(N);
    for(int bit=0; bit<(1<<3); bit++){
        for(int i=0; i<N; i++){
            ll tmp = 0;
            for(int j=0; j<3; j++){
                if(bit&(1<<j)) tmp += x[i][j];
                else tmp -= x[i][j];
            }
            cake[i] = tmp;
        }
        sort(cake.begin(), cake.end(), greater<ll>());
        ll sum = 0;
        for(int i=0; i<M; i++) sum += cake[i];
        ans = max(ans, sum);
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int INF = numeric_limits<int>::max() / 2;

struct Edge
{
	int src, dst;
	int weight;
	Edge(int src, int dst, int weight) : src(src), dst(dst), weight(weight) {}
};

auto operator<(const Edge &e, const Edge &f)
{
	if (e.weight != f.weight)
		return e.weight > f.weight;
	else if (e.src != f.src)
		return e.src < f.src;
	else
		return e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;

pair<int, int> sweep(int p, int v, const Graph &g)
{
	pair<int, int> r(0, v);
	for (auto e : g[v])
	{
		if (e.dst != p)
		{
			pair<int, int> t = sweep(v, e.dst, g);
			t.first += e.weight;
			if (r.first < t.first)
				r = t;
		}
	}
	return r;
}
int double_sweep(const Graph &g, int s)
{
	pair<int, int> r = sweep(-1, s, g);
	pair<int, int> t = sweep(-1, r.second, g);
	return t.first;
}

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

	while (true)
	{
		int n;
		cin >> n;
		if (n == 0)
			break;
		int len = 0, cut = 0;
		vector<int> p(n), d(n);
		for (int i = 1; i < n; i++)
		{
			cin >> p[i];
			p[i]--;
		}
		for (int i = 1; i < n; i++)
		{
			cin >> d[i];
			len += d[i];
		}
		vector<int> v[1000];
		vector<bool> leaf(n, false);
		Graph g(n);
		for (int i = 1; i < n; i++)
		{
			int s = i, g = p[i];
			v[s].push_back(g);
			v[g].push_back(s);
		}
		for (int i = 0; i < n; i++)
			if (v[i].size() == 1)
				leaf[i] = true;
		for (int i = 1; i < n; i++)
		{
			if (leaf[i] || leaf[p[i]])
				continue;
			else
			{
				Edge e(i, p[i], d[i]), e2(p[i], i, d[i]);
				g[i].push_back(e);
				g[p[i]].push_back(e2);
				cut += d[i];
			}
		}

		int st;
		for (int i = 0; i < n; i++)
			if (!leaf[i])
				st = i;
		int r = double_sweep(g, st);
		//���a=r
		cout << len + cut * 2 - r << endl;
	}
}


Measured memory_bytes: 3292
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define val(i,j) ((i)*n+(j))
#define INF (1<<20)
int dist[108000];
int n, m, x;
vector<int> edge[108000];
bool solve(){
	cin >> n >> m;
	if(n == 0 && m == 0)return false;
	for(int i = 0;i < m;i++)
		for(int j = 0;j < n;j++){
			dist[val(i,j)] = INF;
			edge[val(i,j)].clear();
		}

	for(int i = 0;i < m-1;i++){
		for(int j = 0;j < n-1;j++){
			cin >> x;
			if(x==1)continue;
			edge[val(i,j)].push_back(val(i,j+1));
			edge[val(i,j+1)].push_back(val(i,j));
		}
		for(int j = 0;j < n;j++){
			cin >> x;
			
			if(x==1)continue;
			edge[val(i,j)].push_back(val(i+1,j));
			edge[val(i+1,j)].push_back(val(i,j));
		}
	}
	for(int j = 0;j < n-1;j++){
		cin >> x;
		if(x==1)continue;
		edge[val(m-1,j)].push_back(val(m-1,j+1));
		edge[val(m-1,j+1)].push_back(val(m-1,j));
	}

	queue<int> q;
	
	q.push(val(0,0));
	dist[val(0,0)] = 0;
	
	while(!q.empty()){
		int now = q.front();q.pop();
		for(int i = 0;i < edge[now].size();i++){
			int to = edge[now][i];
			if(dist[to] != INF)continue;
			dist[to] = dist[now] + 1;
			q.push(to);
		}
	}
	if(dist[val(m-1,n-1)] == INF)dist[val(m-1,n-1)] = -1;
	cout << dist[val(m-1,n-1)]+1 << endl;
	return true;
}

int main(){
	while(solve());
	return 0;
}


Measured memory_bytes: 5620
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))

d = [(A[i] - B[i])*T[i] for i in range(2)]
if d[0] < 0:
    d = [-d[0],-d[1]]
s = sum(d)
if s == 0:
    print('infinity')
elif s > 0:
    print(0)
else:
    print(d[0]//(-s)*2 + 1 - (d[0]%s == 0))


Measured memory_bytes: 3064
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        String S = stdIn.next();
	if(S.equals("AAA")||S.equals("BBB")){
	    System.out.println("No");
	}else{
	    System.out.println("Yes");
	}
    }
}
	

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int a,b;
int main() {
    cin>>a>>b;
    int ans = (a*b)-(a+b-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;

int n, k;
vector<int> az(300);
int solve(){
	for(int i=0;;i++){
		sort(az.begin(), az.end(), [](int l, int r){ return l > r; });
		for(int j=0;j<k;j++){
			if(az[j] == 0){ return i; }
			az[j]--;
		}
	}
}
int main(){
	cin >> n >> k;
	for(int i=0;i<n;i++){
		string p;
		cin >> p;
		az[p[0]]++;
	}
	cout << solve() << endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  string S;
  cin >> S;
  int ans = 1;
  int c = 0;
  bool last_2 = 0;
  FORIN(i, 1, (int)S.size()) {
    if (S[i] != S[i - 1] || c > 0 || last_2) {
      if (c > 0)
        last_2 = 1;
      else
        last_2 = 0;
      ans++;
      c = 0;
    } else {
      c++;
    }
  }
  cout << ans + (c > 0 && last_2) << endl;
  return 0;
}
#include <algorithm>


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string x,y,z;
	cin>>x>>y>>z;
	char a,b,c;
	a=x[0]-32;
	b=y[0]-32;
	c=z[0]-32;
	cout<<a<<b<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {


    llong ans = 0;
    llong tmp = 0;
    llong k, a, b;

    signed call_of_Cthulhu( signed datum ) {

        read k >> a >> b;
        llong K = k;
        llong p = k;
        if ( a+1 <= b ) {
            k++;
            ans += b * ( k / (a+2) );
            k %= (a+2);
        }
        if ( k > 0 ) ans += k;

        if ( 1 ){
            K -= a-1;
            tmp = b * ((K)/2) - (a * ((K/2)-1)) + ( K&1);
        }
        echo std::max(ans, std::max(p+1, tmp)) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;


int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(k>0&&b<=a){
		k--;b*=2;
	}
	while(k>0&&c<=b) k--,c*=2;
	
	if(c>b&&b>a) cout<<"Yes\n";
	
	else cout<<"No\n";
	
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  vl num(3,0);
  REP(i,s.length()){
    char c = s[i];
    num[c-'a']++;
  }
  sort(num.begin(),num.end());
  if(num[2]-num[0]<2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;

typedef int64 simple_t;

int compare_simple(const void *a, const void *b)
{
  simple_t *x;
  simple_t *y;

  x = (simple_t *)a;
  y = (simple_t *)b;

  if (x > y) return 1;
  if (y < x) return -1;

  return 0;
}
void qsort_simple (simple_t *array, int size)
{
  qsort(array, size, sizeof(simple_t), compare_simple);
}

int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 N;
  int64 i;
  int64 total = 0;

  get_N(&N);

  for(i=1; i<=N; i++) {
    if ((i%3) == 0) continue;
    if ((i%5) == 0) continue;
    total += i;
  }
  
  printf("%lld", total);
  return 0;
}



Measured memory_bytes: 1732
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if len(set([l[i], l[j], l[k]])) == 3 and max(l[i], l[j], l[k]) < sum([l[i], l[j], l[k]]) - max(l[i], l[j], l[k]):
                ans += 1
print(ans)

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


Measured memory_bytes: 2012
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int N, M, X, Y;
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  int x[N];
  int y[M];
  int _x;
  int _y;
  for (int i = 0; i < N; i++) {
    scanf("%d", &x[i]);
  }
  for (int i = 0; i < M; i++) {
    scanf("%d", &y[i]);
  }
  sort(x, x + N);
  sort(y, y + M);
  _x = x[N - 1];
  _y = y[0];
  // printf("%d %d\n", _x, _y);
  for (int i = _x + 1; i <= _y; i++) {
    if (X < i && i <= Y) {
      printf("No War\n");
      return 0;
    }
  }
  printf("War\n");
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    string ans="No";
    if(s.size()%2==1){
        cout << ans << endl;
        return 0;
    }
    for(int i=0;i<s.size()-1;i+=2){
        if(s[i]=='h'&&s[i+1]=='i') ans="Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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 n, k, h[300000], ans = 0;
    cin >> n >> k;
    rep(i, n) cin >> h[i];
    sort(h, h + n, greater());
    for (int i = k; i < n; i++)
        ans += h[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
typedef long long ll;
typedef long double ld;
const ld eps = 1e-6;

int n;
ld x[N], y[N];

bool eq(ld x) { return abs(x) < eps; }
bool eq(ld x, ld y) { return eq(x - y); }
void mxm(ld &x, ld y) { x = max(x, y); }
void mnm(ld &x, ld y) { x = min(x, y); }
ll det(ll x1, ll y1, ll x2, ll y2) {
	return x1 * y2 - x2 * y1;
}
ld det(ld x1, ld y1, ld x2, ld y2) {
	ld d = x1 * y2 - x2 * y1;
	return d;
}
bool colinear(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3) {
	ld xu = x3 - x1, yu = y3 - y1, xv = x2 - x1, yv = y2 - y1;
	return eq(det(xu, yu, xv, yv));
}
bool solveEQ(ld a1, ld b1, ld c1, ld a2, ld b2, ld c2, ld &k1, ld &k2) {
	if (eq(det(a1, b1, a2, b2))) return false;
	ld detAB = det(a1, b1, a2, b2),
		detAC = det(a1, c1, a2, c2),
		detBC = det(b1, c1, b2, c2);
	k1 = -detBC / detAB; k2 = detAC / detAB;
	return true;
}
bool centerInscibe(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3, ld &xc, ld &yc) {
	if (colinear(x1, y1, x2, y2, x3, y3)) return false;
	ld xa = (x1 + x2) / 2, ya = (y1 + y2) / 2, xb = (x1 + x3) / 2, yb = (y1 + y3) / 2;
	ld x_12 = x2 - x1, y_12 = y2 - y1, x_13 = x3 - x1, y_13 = y3 - y1;
	ld xu = -y_12, yu = x_12, xv = -y_13, yv = x_13;
	ld k1, k2;
	if (!solveEQ(xu, -xv, xb - xa, yu, -yv, yb - ya, k1, k2)) return false;
	xc = xa + k1 * xu;
	yc = ya + k1 * yu;
	return true;
}
ld dist(ld x1, ld y1, ld x2, ld y2) { return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)); }
ld R(ld X, ld Y) {
	ld ans = 0.0;
	for (int i = 0; i < n; ++i)
		mxm(ans, dist(X, Y, x[i], y[i]));
	return ans;
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n; for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
	ld ans = R(x[0], y[0]);
	for (int i=0; i<n; ++i)
		for (int j = i + 1; j < n; ++j) {
			ld xm = (x[i] + x[j]) / 2, ym = (y[i] + y[j]) / 2;
			mnm(ans, R(xm, ym));
		}
	for (int i=0; i<n; ++i)
		for (int j=i+1; j<n; ++j)
			for (int k = j + 1; k < n; ++k) {
				ld xc, yc;
				if (centerInscibe(x[i], y[i], x[j], y[j], x[k], y[k], xc, yc)) {
					int debug = 1;
					mnm(ans, R(xc, yc));
				}
			}
	cout.precision(20);
	cout << ans << endl;
}

Measured memory_bytes: 256
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, K = LI()
H = LI()

INF = 10 ** 10


def main():
    dp = [INF] * N
    dp[0] = 0
    for i in range(1, N):
        n = min(K + 1, i + 1)
        for j in range(1, n):
            dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]))
    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 84804