akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0218
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                for (int k = 0; k < n; k++)
                {
                    int[] vs = RAInt();

                    int max = vs.Max();
                    int sum = vs.Sum();
                    int sumME = vs.Take(2).Sum();

                    string res;
                    if (max == 100 || sum >= 240 || sumME >= 180)
                    {
                        res = "A";
                    }
                    else if (sum >= 210 || (sum >= 150 && (vs[0] >= 80 || vs[1] >= 80)))
                    {
                        res = "B";
                    }
                    else
                    {
                        res = "C";
                    }
                    Console.WriteLine(res);
                }
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RASt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RAInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RALong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RADouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 14200
N=int(input())
L=[[0]*10 for i in range(10)]
for i in range(1,N+1):
    n=str(i)
    first=int(n[0])
    last=int(n[-1])
    L[first-1][last-1]+=1
ans=0
for i in range(1,N+1):
    n=str(i)
    first=int(n[0])
    last=int(n[-1])
    ans+=L[last-1][first-1]

print(ans)

Measured memory_bytes: 9168
#include <iostream>
#include <map>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;

int T, N, X, Y, SX, SY;
map<pii, int> P;
int dd[7] = { 0, 1, 1, 0, -1, -1, 0 };

int dfs(pii p, int t, int ans) {
  if((P.count(p) && t >= P[p]) || t > T) return ans;
  if(P.count(p) == 0) ans++;
  P[p] = t;
  REP(i, 0, 6) ans = dfs(pii(p.fi + dd[i], p.se + dd[i + 1]), t + 1, ans);
  return ans;
}

int main(void) {
  while(cin >> T >> N, T || N) {
    P.clear();
    REP(i, 0, N) {
      cin >> X >> Y;
      P[pii(X, Y)] = 0;
    }
    cin >> SX >> SY;

    cout << dfs(pii(SX, SY), 0, 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 3232
n = int(input())
a = [0]*n
x = []
y = []
aa = 0
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        b,c = map(int,input().split())
        x.append(b)
        y.append(c)

for i in range(2**n):
    sw = [0]*n
    for j in range(n):
        if (i >> j) & 1:
            sw[j] = 1
    s = 0
    q = 1
    for j in range(n):
        if sw[j] == 1:
            for k in range(a[j]):
                if sw[x[s]-1] != y[s]:
                    q = 0
                    break
                s += 1
        else:
            s += a[j]

    if q == 1:
        su = sum(sw)
        aa = max(aa,su)
print(aa)

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int count = 0;
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
    for (int j = 0; j < 50; j++){
      if (a.at(i) % 2 == 0){
        count++;
        a.at(i) /= 2;
      }
      else break;
    }
  }
  cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;
const int INF = 1000001;

int main()
{
  int n;
  cin >> n;
  if (n % 2 == 0)
    cout << n << endl;
  else
    cout << n * 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    reverse(v.begin(),v.end());
    bool ok = 1;
    rep(i,n-1){
        if(v[i]>=v[i+1]);
        else{
            if(v[i+1]-v[i]>=2) ok = 0;
            else{
                v[i+1]--;
            }
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<utility>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<stack>
#include<complex>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<sstream>
#include<fstream>
#include<climits>
#include<chrono>
#include<random>
#include<functional>
#include<regex>
 
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
 
// ????§??????????°INF
const int INF = (1 << 30);
// ???¨??±?????????????????
const double EPS = (1e-10);
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)
 
 
int main()
{
    cin.tie(0);
    ios::ios_base::sync_with_stdio(false);
    int N, W, H;
    cin >> N >> W >> H;
    vector<bool> w((W << 1) + 1, false), h((H << 1) + 1, false);
    int x, y, r;
    for (int i = 0; i < N; ++i) {
        cin >> x >> y >> r;
        fill(w.begin() + max(0, (x - r) << 1), w.begin() + min(W << 1, (x + r) << 1) + 1, true);
        fill(h.begin() + max(0, (y - r) << 1), h.begin() + min(H << 1, (y + r) << 1) + 1, true);
    }
    for (int j = 1; j <= (W << 1) - 1; j += 2) {
        if (w[j])continue;
        for (int k = 1; k <= (H << 1) - 1; k += 2) {
            if (!h[k]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int fare[101][101], dist[21][101][101];
int cost[101];
int P[21];
int N, M, C, S, G;
typedef pair<int, int> pint;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N >> M >> C >> S >> G && N){
        S--; G--;
        rep(i, 21) rep(j, 101) rep(k, 101) dist[i][j][k] = INF;
        rep(i, 21) rep(j, 101) dist[i][j][j] = 0;
        rep(i, 101) rep(j, 101) fare[i][j] = INF;
        rep(i, 101) fare[i][i] = 0;
        int x_, y_, d_, c_;
        rep(i, M){
            cin >> x_ >> y_ >> d_ >> c_;
            x_--; y_--; c_--;
            dist[c_][x_][y_] = dist[c_][y_][x_] = min(dist[c_][x_][y_], d_);
        }
        rep(c, C) rep(k, N) rep(i, N) rep(j, N)
          dist[c][i][j] = min(dist[c][i][j], dist[c][i][k] + dist[c][k][j]);
        rep(c, C) cin >> P[c];
        rep(c, C){
            vector<int> Q(P[c] + 1, INF), R(P[c]), f(P[c]);
            REP(i, 1, P[c]) cin >> Q[i];
            Q[0] = 0;
            rep(j, P[c]) cin >> R[j];
            f[0] = 0;
            REP(i, 1, P[c]) f[i] = R[i - 1] * (Q[i] - Q[i - 1]) + f[i - 1];
            rep(i, N - 1) REP(j, i + 1, N){
                if(dist[c][i][j] == INF) continue;
                int it = lower_bound(Q.begin(), Q.end(), dist[c][i][j]) - Q.begin();
                it--;
                int temp = f[it] + R[it] * (dist[c][i][j] - Q[it]);
                fare[i][j] = fare[j][i] = min(fare[i][j], temp);
            }
        }
        priority_queue<pint, vector<pint>, greater<pint> > que;
        fill(cost, cost + N, INF);
        cost[S] = 0;
        que.push(pint(0, S));
        while(!que.empty()){
            pint now = que.top(); que.pop();
            int v = now.second;
            if(cost[v] < now.first) continue;
            rep(i, N){
                if(fare[v][i] == INF || v == i) continue;
                if(cost[i] > cost[v] + fare[v][i]){
                    cost[i] = cost[v] + fare[v][i];
                    que.push(pint(cost[i], i));
                }
            }
        }
        int ans = cost[G];
        if(ans == INF) ans = -1;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (i%2 && s[i] == 'g') ++ans;
        if (i%2 == 0 && s[i] == 'p') --ans;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 512
#include<iostream>//AT3875
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include <algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
using namespace std;
int main()
{
	int n,j,k,l,i;
	cin>>n;
	for(i=1;i<=n;i++)
	 {
	 	cin>>j>>k>>l;
	 	if(k+l>j){cout<<"No";return 0;}
	 	k=(k+l)%2;l=j%2;
	 	if(k!=l){cout<<"No";return 0;}
	 }
	 cout<<"Yes";
	 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll a,b,h;
  cin>>a>>b>>h;
  cout << (((a+b)*h)/2) << endl;
  return 0;
}


Measured memory_bytes: 256
L = []
N,M = map(int, input().split())
A = input().split()
for i in range(N):
    L += [int(A[i])]
All = sum(L)
a = 0
for i in range(N):
    if L[i] >= All/4/M:
        a += 1
if a >= M :
    print('Yes')
else:
    print('No')

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

vector<int> commonDiv(int a, int b) {
    vector<int> div;
    for (int i = (a > b) ? b : a; i > 0; --i) {
        if (a % i == 0 && b % i == 0) {
            div.emplace_back(i);
        }
    }

    return div;
}

int main(void) {
    int a, b, k;
    cin >> a >> b >> k;

    cout << commonDiv(a, b)[k - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	int mx=0,l=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			l++;
		}
		if(s[i]=='S')
		{
			mx=max(mx,l);
			l=0;
		}
	}
	cout<<max(mx,l)<<endl;
	return 0;
}

Measured memory_bytes: 3632
#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>;

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int dif = 0;
    while (true)
    {
        bool fmin = true;
        bool fmax = true;
        rep(i, n)
        {
            if (p[i] == (x - dif))
            {
                fmin = false;
            }
            if (p[i] == (x + dif))
            {
                fmax = false;
            }
        }
        if (fmin)
        {
            cout << (x - dif) << endl;
            return 0;
        }
        if (fmax)
        {
            cout << (x + dif) << endl;
            return 0;
        }
        dif++;
    }
    cout << (x - dif) << endl;
    return 0;
}


Measured memory_bytes: 3632
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int A, B; cin >> A >> B;

    string ans = "Impossible";
    if (A%3==0 || B%3==0 || (A+B)%3==0) {
        ans = "Possible";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;


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

  ll t,i,min,d;
  min=n-1;

  for(i=1;i*i<=n;i++){
    if(n%i!=0)continue;
    t=n/i;
    d=t+i-2;
    if(d<min){
      min=d;
    }
  }
  cout<<min<<endl;

  return 0;
}


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

int main(){
    string S;
    cin >> S;
    string W[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i=0; i<7; i++) if(S == W[i]){
        cout << 7-i << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dp[BITLE(19)][20];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n),B(n);
  for(auto &a:A)cin>>a;
  for(auto &a:B)cin>>a;
  A.pb(0);
  B.pb(0);
  for(int i=0;i<BITLE(n);i++)
    for(int j=0;j<=n;j++)
      dp[i][j]=llINF;
  dp[0][n]=0;
  for(int i=0;i<BITLE(n);i++){
    for(int i2=0;i2<=n;i2++){
      if(dp[i][i2]!=llINF){
	ll cnt=0;
	for(int j=0;j<n;j++)
	  if(i&(BITLE(j)))cnt++;
	//	cout<<cnt<<endl;
	for(int j=0;j<n;j++){
	  if(i&BITLE(j))continue;
	  ll pre=0;
	  ll ma=0;
	  for(int k=0;k<n;k++){
	    if((i&BITLE(k)) && (k<j))pre++;
	  }

	  if(i==0)ma=0;
	  else{
	    if((cnt-1)%2 == i2%2)ma=A[i2];
	    else ma=B[i2];
	  }
	  
	  ll now=0;
	  if(cnt%2 == j%2)now=A[j];
	  else now=B[j];
	  //	  cout<<i<<" "<<ma<<" "<<now<<" "<<i2<<" "<<j<<" "<<cnt<<endl;
	  if(now>=ma){
	    dp[i|BITLE(j)][j] = min(dp[i|BITLE(j)][j],
				    dp[i][i2]+(j-pre));
	  }
	}
      }
    }
  }
  ll ans=llINF;

  for(int i=0;i<n;i++)
    ans=min(ans,dp[BITLE(n)-1][i]);
  if(ans==llINF)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 43264
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
f = [[0] * (w+2) for _ in range(h+2)]
d = [(-1, 1), (-1, 0), (-1, -1), (0, 1), (0, -1), (1, 1), (1, 0), (1, -1)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            for x, y in d:
                f[i+1+x][j+1+y] += 1

for i in range(h):
    ans = ''
    for j in range(w):
        if s[i][j] == '#':
            ans += '#'
        else:
            ans += str(f[i+1][j+1])
    print(ans)

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

int main(int argc, char const *argv[])
{
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int ans=0;
	for (int i = 0; i <= a; ++i)
	{
		for (int j = 0; j <= b; ++j)
		{
			for (int k = 0; k <= c; ++k)
			{
				if (500*i+100*j+50*k==x)
				{
					++ans;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const int mod = 998244353;
long long modpow(long long a, long long n){
  long long r = 1;
  while (n) {
    r = r * ( (n%2)?a:1 ) %mod;
    a = a * a % mod;
    n >>= 1;
  }
  return r;
}
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main(void){
    ll n,m,k;cin>>n>>m>>k;
    combination c(200010);
    mint res=0;
    rep(x,k+1){
        mint buf1=m*modpow(m-1,n-1-x);
        mint buf2= c(n-1,x);
        res+=(buf1*buf2);
    }
    cout<<res.x<<endl;
}

Measured memory_bytes: 6412
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;
using ll=long long;

int main()
{
    string A, B, C;
    
    cin >> A >> B >> C;
    
    bool isWordChain = false;
    if (A.back() == B.front() && B.back() == C.front())
    {
        isWordChain = true;
    }
    
    printf("%s\n", isWordChain ? "YES" : "NO");
    
    return 0;
}


Measured memory_bytes: 256
s = [int(input()) for _ in range(int(input()))]

if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for i, x in enumerate(s):
        if x % 10 != 0:
            print(sum(s) - x)
            break
    else:
        print(0)

Measured memory_bytes: 9020
#include <iostream>
#include <queue>

int main()
{
	int N, M, a;
	scanf("%d %d", &N, &M);

	std::priority_queue<int> q;
	for (int i = 0; i < N; ++i)
	{
		scanf("%d", &a);
		q.push(a);
	}

	for (int i = 0; i < M; ++i)
	{
		int c = q.top() / 2;
		q.pop();
		q.push(c);
	}

	long long ans = 0;
	while (!q.empty())
	{
		ans += q.top();
		q.pop();
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s.compare(t)<0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    idx = {aa: i for i, aa in enumerate(a)}
    left = [i for i in range(N+2)]
    right = [i for i in range(N+2)]
    res = 0
    for n in range(N, 0, -1):
        i = idx[n]
        l = left[i]
        r = right[i]
        res += n * (i - l + 1) * (r - i + 1)
        left[r+1] = l
        right[l-1] = r
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 97996
import math

a, b, c = map(int, input().split())
rad = c * math.pi / 180
s = 0.5 * a * b * math.sin(rad)
l = a + b + (a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)) ** 0.5
h = b * math.sin(rad)
print(s, l, h, sep='\n')



Measured memory_bytes: 5724
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
  int N,M;
  int R[51][51]={0};
  int a,b;
  scanf("%d %d",&N,&M);
  for(int i=1;i<=M;i++){
    scanf("%d %d",&a,&b);
    R[a][b]+=1;R[b][a]+=1;
  }
  for(int i=1;i<=N;i++){
    int ans=0;
    for(int j=1;j<=N;j++){
      ans+=R[i][j];
    }
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 2000010


int main(){
	IOS;
	
	
	ll x;
	cin>>x;
	ll ans = (x/500)*1000;
	x-=(x/500)*500;
	ans += (x/5)*5;
	cout<<ans;
	
	
	
	
	
	return 0;
}



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



int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (a == b + c) cout << "Yes" << endl;
	else if (b == a + c) cout << "Yes" << endl;
	else if (c == a + b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }
    vector<vector<int>> dp(N, vector<int>(3));
    dp[0][0] = A[0];
    dp[0][1] = B[0];
    dp[0][2] = C[0];
    for (int i = 1; i < N; i++) {
        dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i]);
        dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i]);
        dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i]);
    }
    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << endl;
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  vector<int> vec(5);
  int cnt=0;
  rep(i,5){
    cin>>vec[i];
    int a =(vec[i]+9)/10*10;
    cnt+=a;
  }
  int ans=cnt;
  rep(i,5){
    int b=vec[i];
    b%=10;
    if(b!=0){
      ans=min(ans,cnt+b-10);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#include<cstring>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;



int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MAX = 100010;

int par[MAX];//親
int Rank[MAX];//木の深さ

			  //n要素で初期化
void init(int n) {
	REP(i, n) {
		par[i] = i;
		Rank[i] = 0;
	}
}

//木の根を求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);//経路圧縮(根に直接つなぎなおす)もしつつ
	}
}

//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	//低いほうを高いほうにつなげる(効率化)
	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

//xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}


struct edge { int u, v, cost; };
struct vertex { int p, x, y; };

//比較関数
bool comp(const edge& e1, const edge&e2) {
	return e1.cost < e2.cost;
}
bool compX(const vertex& v1, const vertex& v2) {
	return v1.x < v2.x;
}
bool compY(const vertex& v1, const vertex& v2) {
	return v1.y < v2.y;
}

edge es[2 * MAX];
vertex ver[MAX];
int N; int E;

ll kruskal() {
	sort(es, es + E, comp);//costでソート
	init(N);
	ll res = 0;
	//コストが小さい辺から順に追加する
	REP(i, E) {
		edge e = es[i];
		//もし閉路ができなければその辺を追加する
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main() {
	cin >> N;
	REP(i, N) {
		int x, y;
		cin >> x >> y;
		ver[i] = {i, x,y };
	}
	E = 2*(N-1);
	//x座標でソート
	sort(ver, ver + N, compX);
	REP(i, N - 1) {
		//隣接した点の間にコスト|x1-x2|の辺を貼る
		es[i] = { ver[i].p,ver[i + 1].p,abs(ver[i].x - ver[i + 1].x) };
	}
	//y座標でソート
	sort(ver, ver + N, compY);
	REP(i, N - 1) {
		es[N - 1 + i] = { ver[i].p,ver[i + 1].p,abs(ver[i].y - ver[i + 1].y) };
	}
	ll ans=kruskal();
	cout << ans << endl;
}


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

int main()
{
	int n;
	while(cin >> n){
		if(n==0)
			break;
		int ice[10] = {0};
		int icenum;
		for(int i=0;i<n;i++){
			cin >> icenum;
			ice[icenum]++;
		}
	
		for(int i=0;i<10;i++){
			if(ice[i]==0)
				cout << "-";
			for(int j=0;j<ice[i];j++){
				cout << "*" ;
			}
			cout << endl;
		}
	}
	return 0;
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


llint a,b,c,k;

void solve(){
  cin >> a >> b >> c >> k;
  if(a>=k)cout << k << endl;
  else if(a+b>=k)cout << a << endl;
  else{
    cout << 2*a-k+b << endl;
  }
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll K;
    cin >> K;
    queue<ll> q;
    repe(i, 1, 10) q.emplace(i);

    ll ans;
    while(!q.empty()){
        ll v = q.front();
        q.pop();
        K--;
        if(K==0){
            ans = v;
            break;
        }

        ll r = v % 10;
        if (r > 0) q.emplace(10 * v + r - 1);
        q.emplace(10 * v + r);
        if (r < 9) q.emplace(10 * v + r + 1);
    }

    cout << ans << endl;
}

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

ll INF = 1e9 + 5;

int main(){
    int n, w;
    cin >> n >> w;
    vector<ll> dp(100001, INF);
    dp[0] = 0;
    // dp[i] = min weight of items whose value equals i
    for(int item = 0; item < n; item++){
        int weight, value;
        cin >> weight >> value;
        for(int i = 100000; i >= value; i--){
            dp[i] = min(dp[i], dp[i-value] + (ll)weight);
        }
    }
    ll mx = 0;
    for(int i = 0; i < 100001; i++){
        if(dp[i] <= w) mx = i;
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

int XX[8] = { +1, +1, +1, 0, 0, -1, -1, -1};
int YY[8] = { +1, 0, -1, +1, -1, +1, 0, -1};
int dx[4] = { -1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};


int a[401];
int sum[401][401], dp[401][401];
int n;

int solve(int i, int j) {
	if (i == j) return 0;
	if (dp[i][j] != -1) return dp[i][j];
	int mini = inf;
	for (int k = i; k < j; k++) {
		mini = min(mini, sum[i][j] + solve(i, k) + solve(k + 1, j));
	}

	return dp[i][j] = mini;
}

void preprocess() {
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j++) {
			sum[i][j] = a[j] + ((i == j) ? 0 : sum[i][j - 1]);
		}
	}
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n;

	loop(i, 1, n) cin >> a[i];
	preprocess();
	memset(dp, -1, sizeof(dp));
	cout << solve(1, n) << endl;

	return 0;
}

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

int main() {
  int K;
  cin>>K;
  int ans=0;
  for (int i=1; i<=K; i++) {
    if (i%2==0) {
      for (int j=1; j<=K; j++) {
        if (j%2!=0) {
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
void solve(int T){
	int n,ans=0;
	ll d,x,y,dis;
	scanf("%d%lld",&n,&d);
	d*=d;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&x,&y);
		dis=x*x+y*y;
		if(dis<=d)ans++;
	}
	printf("%d",ans);
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}



Measured memory_bytes: 3824
#include <stdio.h>
int main(void){
	int i;
	double x[3],y[3],p,q,f[3],s;
	while(1){
		for(i=0;i<3;i++){
			if(scanf("%lf %lf",&x[i],&y[i])==EOF)
				return 0;
		}
		scanf("%lf %lf",&p,&q);
		for(i=0;i<3;i++){
			s=(x[(i+1)%3]-x[i])*(q-y[(i+1)%3])-(y[(i+1)%3]-y[i])*(p-x[(i+1)%3]);
			if(s>0)f[i]=1;
			else f[i]=0;
		}
		if(f[0]==f[1]&&f[1]==f[2])puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

bool check(string s){
  bool all = true;
  for(int j = 1;j<s.size();j++){
    if(s[j] != s[0])
      all = false;
  }
  return all;

}

int main(){
  string s;
  cin>>s;
  string tmp = s;
  int ans = 11111111;
  int num = 0;
  for(int i = 0;i<26;i++){
    tmp = s;
    num = 0;
    bool update = true;
    while(update){
      update = false;
      if(tmp.size() == 1)
	break;
      for(int j = 0;j<tmp.size()-1;j++){
	//最終文字まで置換
	if(tmp[j] == 'a'+i){
	  //そのまま
	  update = true;
	}else if(tmp[j+1] == 'a'+i){
	  tmp[j] = tmp[j+1];
	  update = true;
	}
	  
      }
      tmp = tmp.substr(0,tmp.size()-1);
      if(update)
	num++;

      if(check(tmp))
	break;

      //cout<<"["<<num<<"]:"<<tmp<<endl;
    }

    if(check(tmp)){
      ans = min(ans,num);
    }
  }
  cout<<ans<<endl;

  return 0;
}


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

int main(void)
{
	int n, r;
	scanf("%d", &n);

	if (n % 1000 == 0)
	{
		r = 0;
	}
	else
	{
		r = 1000 - (n % 1000);
	}

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

		return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double real;
typedef pair<int, string> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
static inline ll mod_inv(ll a, ll p){ return pow_mod(a,p-2,p); }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
static const int Mod = 1000000000;

static inline int popcnt(int x){ return __builtin_popcount(x); }

struct Food {
  string f;
  int w, s;
  Food(){}
  void read(){
    cin >> f >> w >> s;
  }
  bool operator<(const Food& f) const {
    if (f.s == s) return f.w < w;
    return f.s < s;
  }
};

struct Solver {
  vector<Food> fs;
  vector<Food> best;
  vector<Food> cur;
  bool used[16];
  int best_cg;
  int total_w;
  const int N;

  Solver(int n) : N(n), fs(n) {}
  void init(){
    for (int i = 0; i < N; i++) fs[i].read();
    sort(fs);
    memset(used, 0, sizeof(used));
    best_cg = 1 << 25;
    total_w = 0;
    for (int i = 0; i < N; i++){
      total_w += fs[i].w;
    }
  }
  void solve(int cg=0, int tw=0, int t=1){
    if (t == N + 1){
      if (best_cg > cg){
        best = cur;
        best_cg = cg;
      }
      return;
    }
    if (cg > best_cg) return;
    for (int i = 0; i < N; i++){
      if (used[i]) continue;
      if (fs[i].s < total_w - (tw + fs[i].w)) continue;
      used[i] = true;
      cur.push_back(fs[i]);
      solve(cg + t * fs[i].w, tw + fs[i].w, t + 1);
      cur.pop_back();
      used[i] = false;
    }
  }
  void show(){
    for (int i = 0; i < N; i++) cout << best[i].f << "\n";
  }
};

int main()
{
  int n;
  while (n = in()){
    Solver solver(n);
    solver.init();
    solver.solve();
    solver.show();
  }
  return (0);
}

// priority_queue queue deque first second front top push pop map set stringstream max_element min_element insert count find

Measured memory_bytes: 1248
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    string s,t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

S = input()
d = Counter(S).values()
if len(S) == 1:
  ans = "YES"
elif len(S) == 2:
  if S[0] != S[1]:
    ans = "YES"
  else:
    ans = "NO"
elif len(d) == 3 and max(d) - min(d) <=1:
  ans = "YES"
else:
  ans = "NO"
print(ans)


Measured memory_bytes: 9288
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool IsAllEven(const vector<int>& A)
{
    for (const int i : A)
    {
        if (i % 2 != 0) return false;
    }
    return true;
}

void _main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    int ans = 0;
    while (true)
    {
        if (!IsAllEven(A)) break;
        for (int& i : A)
        {
            i /= 2;
        }
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String cc = sc.next();
		if(cc.charAt(0) == 'A'){
			System.out.print('T');
		}else if(cc.charAt(0) == 'T'){
			System.out.print('A');

		}else if(cc.charAt(0) == 'G'){
			System.out.print('C');

		}else{
			System.out.print('G');
		}

	}


}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 19924
#include <iostream>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
#define MAX 10000

int dp[50];


int fibonacci(int i)
{
    if(i == 0 || i == 1) return dp[i] = 1;
    if (dp[i] != -1) return dp[i];
    return dp[i] = fibonacci(i-1) + fibonacci(i-2);
}

int main()
{
    int n;
    rep(i, 50) dp[i] = -1;

    cin >> n;
    cout << fibonacci(n) << endl;

    return 0;
}



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


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

/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> data(3, vector<int>(4));
*/
 
int main() {
  
  int count=0, ans=0;
  string D;
  cin >> D;
  
  if( D.at(0) != D.at(1) ) count++;
  if( D.at(2) != D.at(1) ) count++;
  
  if (count >=1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N, M, T;
    cin >> N >> M >> T;
    vector<int> a(N), cum(T + 1, 0);
    REP (i, N) {
        cin >> a[i];
        cum[a[i] - M]++;
        cum[min(T, a[i] + M)]--;
    }
    REP (i, T) cum[i + 1] += cum[i];
    int ans = 0;
    FOR (i, 1, T + 1) ans += (cum[i] == 0);
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll INF=1e17;
P ad(P a,P b){
  return mp(a.first+b.first,a.second+b.second);
}

int main(){
  ll n,ma,mb,a,b,c,dp[100010][44]={};
  fr(i,100010) fr(j,44) dp[i][j]=INF;
  cin>>n>>ma>>mb;
  P p[50];
  fr(i,n){
    cin>>a>>b>>c;
    p[i]=mp(a*mb-b*ma,c);
  }
  fr(j,n){
    for(int i=-4000;i<=4000;i++){
      if(i==p[j].first){
        dp[5000+i][j+1]=min(dp[5000+i][j],p[j].second);
      }
      else dp[5000+i][j+1]=min(dp[5000+i][j],dp[5000+i-p[j].first][j]+p[j].second);
    }
  }
  cout<<(dp[5000][n]==INF?-1:dp[5000][n])<<endl;
}

Measured memory_bytes: 34688
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

int N, M, A[100009], B[100009], cnt; vector<int>X[100009];
priority_queue<int, vector<int>, greater<int>>Q;

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i]; X[A[i]].push_back(B[i] - 1);
	}
	for (int i = 1; i <= N - 1; i++) {
		for (int j = 0; j < X[i].size(); j++) Q.push(X[i][j]);
		if (!Q.empty() && Q.top() == i) {
			while (!Q.empty()) Q.pop();
			cnt++;
		}
	}
	if (!Q.empty()) cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int X = scan.nextInt();
		
		int counter = 1;
		double sum = 0;
		
		for (int count = 0; count < N; count++) {
			int input = scan.nextInt();
			sum += input;
			if(sum <= X) {
				counter++;
			}
		}
		System.out.println(counter);
	}
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  ll H, A, S = 0;
  int N;
  cin >> H >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    S += A;
  }
  if (S >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll x,n;
ll p[105];
ll a[105];
ll ans;
int main(void){
    cin>>x>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
        a[p[i]]++;
    }
    sort(p,p+n);
    for(int i=0;i<=101;i++){
        if(a[i]==0){
            if(abs(i-x)<abs(ans-x)){
                ans=i;
            }
        }
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3596
ks=[]
n,m=map(int,input().split())
for i in range(m):
	ks.append(list(map(int,input().split())))
p=list(map(int,input().split()))
ans_ans=0
for i in range(2**n):
	num="0"*10+bin(i)
	ans=0
	for j in range(m):
		cnt=0
		for k in range(n):
			if num[-k-1]=="1" and k+1 in ks[j][1:]:
				cnt+=1
		if cnt%2==p[j]:
			ans+=1
	if ans==m:
		ans_ans+=1
print(ans_ans)


		


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

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

  ll N; cin >> N;
  ll MAX = 100 * 100 + 10;
  vector<ll> A(MAX, 0);
  for (ll i = 1; i < 100; i++) {
    for (ll j = 1; j < 100; j++) {
      for (ll k = 1; k < 100; k++) {
        ll n = i * i + j * j + k * k + i * j + j * k + k * i;
        if (n > N) break;
        A[n]++;
      }
    }
  }
  for (ll i = 1; i <= N; i++) {
    cout << A[i] <<'\n';
  }
  return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const ll mod = 1e9 + 7;

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n){
        if(n % 2){
            ans = ans * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    ll N,K; cin >>N>>K;
    vector<ll> kosuu(K+1);
    ll ans = 0;
    for(ll i = K; i>= 1; i--){
        ll floor = K / i;
        kosuu[i] = mpow(floor, N);
        for(ll j = 2;j * i <= K ; j++){
            kosuu[i] += (mod - kosuu[j * i]) % mod;
            kosuu[i] %= mod;
        }
        ans += i * kosuu[i];
        ans %= mod;

    }
    //cout << kosuu[100] << endl;
    cout << ans << endl;

}



Measured memory_bytes: 3996