akhauriyash/Code-Regression huggingface dataset:
//第 2 問: ABC 081 A - Placing Marbles (100 点) https://atcoder.jp/contests/abc081/tasks/abc081_a
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    string s;
    cin >> s;
    int ans;
    REP(i, s.size()){
        ans += (int)(s[i] - '0');
    }
    cout << ans << endl;
}

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

typedef struct{

  int x,y;
  
}xy;

int main(){
  
  int N;
  int num_block,direction;
  int x_max,y_max,x_min,y_min;
  xy data[200];

  data[0].x=1,data[0].y=1;

  while(1){
    
    cin >>N;
    if(N==0)break;
    
    x_max=1,y_max=1;
    x_min=0,y_min=0;

    rep(i,N-1){
      cin >>num_block>>direction;
      if(direction == 0){
	data[i+1].x=data[num_block].x-1;
	data[i+1].y=data[num_block].y;
      }else if(direction == 1){
	data[i+1].x=data[num_block].x;
	data[i+1].y=data[num_block].y-1;
      }else if(direction == 2){
	data[i+1].x=data[num_block].x+1;
	data[i+1].y=data[num_block].y;
      }else{
	data[i+1].x=data[num_block].x;
	data[i+1].y=data[num_block].y+1;
      }
      if(data[i+1].x > x_max){
	x_max=data[i+1].x;
      }else if(data[i+1].x-1 < x_min){
	x_min=data[i+1].x-1;
      }else if(data[i+1].y > y_max){
	y_max=data[i+1].y;
      }else if(data[i+1].y-1 < y_min){
	y_min=data[i+1].y-1;
      }
    }

    //cout <<x_max<<" "<<x_min<<endl;
    //cout <<y_max<<" "<<y_min<<endl;
    
    cout <<x_max-x_min<<" "<<y_max-y_min<<endl;
    
  }

  return 0;
}

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

#define ll long long int

using namespace std;

#define M 1000000007

ll
mpow(ll x, ll n)
{
    ll ans = 1;
    while (n > 0){
        if (n & 1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}


int main() {
    string L;
    cin >> L;

    ll n = L.size();

    vector<vector<ll>> dp(n, vector<ll>(2));

    ll res = 0;

    ll countBit = 0;
    for (ll i = 0; i < n; ++i) {
        if (L[i] == '1') {
            res += mpow(2, countBit) * mpow(3, n-1-i);
            res %= M;
            ++countBit;
        }
    }
    res += mpow(2,countBit);
    res %= M;
    cout << res << endl;
}


Measured memory_bytes: 8752
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<15;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int A, B, C;
  cin >> A >> B >> C;
  int a = max({A, B, C});
  int b = min({A, B, C});
  if (a != C && b != C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    for h in range(1, 3500 + 1):
        for n in range(1, 3500 + 1):
            numerator = N * h * n
            denominator = 4 * h * n - N * n - N * h
            if denominator == 0:
                continue
            if numerator % denominator != 0:
                continue
            w = numerator // denominator
            if w <= 0:
                continue
            print(h, n, w)
            return

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39536
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    S = input()[:-1]
    if N%2==0 and S[:N//2] == S[N//2:]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 64364
import java.util.*;

public class Main {

    private int N;
    private int D;
    private int X;
    private int[] A;

    public void inputData() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        D = sc.nextInt();
        X = sc.nextInt();
        A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
    }

    public void printAnswer() {
        int count = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 1; j <= D; j += A[i]) {
                count++;
            }
        }
        count += X;
        System.out.println(count);
    }

    public void run() {
        inputData();
        printAnswer();
    }

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

}


Measured memory_bytes: 23892
#include <algorithm>
#include <iostream>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    P p[502];
    int b[250002]{0};
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        x--;
        b[x] = i + 1;
        p[i] = P(x, i + 1);
    }
    sort(p, p + n);
    int k = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < p[i].second - 1; j++){
            while(b[k]) k++;
            if(k > p[i].first){
                cout << "No" << endl;
                return 0;
            }
            b[k] = p[i].second;
            k++;
        }
    }
    k = n * n - 1;
    for(int i = n - 1; i >= 0; i--){
        for(int j = 0; j < n - p[i].second; j++){
            while(b[k]) k--;
            if(k < p[i].first){
                cout << "No" << endl;
                return 0;
            }
            b[k] = p[i].second;
            k--;
        }
    }
    cout << "Yes" << endl;
    for(int i = 0; i < n * n; i++) cout << b[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2176
A = list(input())
B = list(input())
for i in reversed(range(len(A)-len(B)+1)):
    for j in reversed(range(len(B))):
        if A[j+i] == B[j] or A[j+i] == "?":
            pass
        else:
            j +=1
            break
    if j == 0:
        A[i:i+len(B)] = B
        A = "".join(A)
        A = A.replace("?","a")
        print(A)
        exit()
print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
long int ans=0; 
void factorize(long long n) 
{ 
    int count = 0;
    while (!(n % 2)) { 
        n >>= 1; 
        count++; 
    }  
    if(count) 
    {
      int i=1;
      while((count-i)>=0)
      {
        count-=i;
        ans++;
        i++;
      }
    }
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
        {
          int j=1;
      while((count-j)>=0)
      {
        count-=j;
        ans++;
        j++;
      }
        }
    }  
    if (n > 2) 
        ans++; 
} 
int main() 
{ 
    long long n;
  ans=0;
  cin>>n;
    factorize(n); 
  cout<<ans;
} 

Measured memory_bytes: 3680
// 解説後
#include <algorithm>
#include <iostream>
#include <vector>

// N <= 2*10^5なので、O(N^2)ではおそらくTLEする
// => せめてO(NlogN)でやりたい
//
// 成績は(消化コスト*食べにくさ)
// => 一方を小さく、もう一方を大きくなるよう選ぶと全体として成績は小さくなる
// => メンバーを昇順に、食べ物を降順に並べて割り当てれば良い
//
// 成績の最小値を求めたい
// => 逆に考えて、「成績の最小値がxとなり得るか」に対して、その境界値を二分探索で計算すれば良い
int solve_E() {
  size_t N = 0;  // チームの人数
  uint64_t K = 0;  // 修行できる最大回数
  std::cin >> N >> K;

  std::vector<uint64_t> costs(N);  // メンバーの消化コストの配列
  for (auto& cost : costs) {
    std::cin >> cost;
  }

  std::vector<uint64_t> foods(N);  // 食べ物の食べにくさの配列
  for (auto& food : foods) {
    std::cin >> food;
  }

  // 配列をソートする
  std::sort(costs.begin(), costs.end(), std::less<>{});
  std::sort(foods.begin(), foods.end(), std::greater<>{});

  // 取りうる成績の最大値を計算する
  uint64_t max = 0;
  for (size_t i = 0; i < N; ++i) {
    max = std::max(max, costs[i] * foods[i]);
  }

  // 成績の最小値が取り得る境界を二分探索で探す
  uint64_t min = 0;
  while (min < max) {
    const uint64_t mid = min + (max - min) / 2;

    // 成績がx以下となるように修行できるかを確かめる
    const auto check = [&](uint64_t x) -> bool {
      uint64_t k = 0;
      for (size_t i = 0; i < N; ++i) {
        // 成績がx以下になるような修行回数を累積的に計算する
        const auto new_cost = x / foods[i];
        if (costs[i] > new_cost) {
          k += costs[i] - new_cost;
        }

        // 最大修行回数に収まらなければ、成績をx以下にできないことが分かる
        if (k > K) return false;
      }
      return true;
    };
    if (check(mid)) {
      max = mid;
    } else {
      min = mid + 1;
    }
  }

  // 結果発表
  std::cout << min;

  return 0;
}

int main() { return solve_E(); }


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

int main(){
  long long int n;
  cin >> n;
  long long int s=0;
  for(int i=0;i<=n;i++){
    s+=i;
    if(i%3==0||i%5==0){
      s-=i;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3676
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    bool flag = 0;
    for(int i = 0; i <= N / 4; i++)
    {
        for(int j = 0; j <= N / 4; j++)
        {
            if(4 * i + 7 * j == N)
            {
                flag = 1;
                break;
            }
        }
    }
    if(flag)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long A = 0;
            for(int i = 1; i <= N; i++)
            {
                if(i % 3 != 0 && i % 5 != 0)
                {
                    A += i;  
                }
            }
            Console.WriteLine(A);
        }
    }
}

Measured memory_bytes: 27524
# Splitting Pile
N = int(input())
a = list(map(int, input().split()))
 
s = [sum(a[1:]) - a[0]]
for i in range(N-2):
    s.append( s[i]- 2*a[i+1] )
a = list(map(abs, s))
print(min(a))

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   int r;
   cin >> r;
   cout << r*r << endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> d(k);
    int b;
    for(int i = 0; i < k; i++){
        cin >> d[i];
        do{
            cin >> b;
            a[b - 1] += 1;
            d[i] -= 1;
        }while(d[i] > 0);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == 0){
            ans += 1;
        }
    }

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

Measured memory_bytes: 3552
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int ctr[N];

int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int a;
		cin >> a;
		if (a <= n) {
			++ctr[a];
		} else {
			++ans;
		}
	}

	for (int i = 1; i <= n; ++i) {
		if (ctr[i] < i) {
			ans += ctr[i];
		} else if (ctr[i] > i) {
			ans += ctr[i] - i;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
 
int main(){
    ll n,k;
    ll ans=0;
    cin>>n>>k;
    ll d=n/k;
    if(k%2==0){
        ans+=pow(d,3);
        if(n-d*k>=k/2) ans+=pow(d+1,3);
        else ans+=pow(d,3);
    }
    else ans=pow(d,3);
    cout<<ans<<endl;
    
}

Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"

int main(int argc, char const *argv[]) {

  int NN;
  std::cin >> NN;

  int cc=0;

  for (size_t i = 1; i < NN+1; i++) {
    int cc2 = 0;
    if(i %2 == 1){for (size_t d = 1; d < NN+1; d++) {
        if (i % d == 0) {
          cc2++;
          // std::cout << d << '\n';
        }
      }}

    if (cc2 == 8) {
      cc++;
    }
  }

  std::cout << cc << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 500000
void maxHeapify(int [],int);
 
int H;
int main(){
    int i;
    int A[N+1];
 
    scanf("%d",&H);
    for(i=1;i<=H;i++){
        scanf("%d",&A[i]);
    }
    for(i=H/2;i>=1;i--){
        maxHeapify(A,i);
    }
    for(i=1;i<=H;i++){
        printf(" %d",A[i]);
    }
    printf("\n");
 
    return 0;
}
void maxHeapify(int A[],int i){
    int l,r,largest,tmp;
 
    l = i*2;
    r = i*2+1;
    if(l<=H && A[l]>A[i]){
        largest = l;
    }
    else largest = i;
    if(r<=H && A[r]>A[largest]){
        largest = r;
    }
 
    if(largest != i){
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(A,largest);
    }
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define mx 100005
#define inf 1000000007
using namespace std;

int n, k, h[mx], mincost[mx];
long long l;

int main(){
	scanf("%d%d", &n, &k);
	fill(mincost, mincost+n, inf);
	mincost[0] = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", &h[i]);
		for(int j = 1; j <= k; j++){
			if(i - j < 0) break;
			mincost[i] = min(mincost[i], mincost[i-j] + abs(h[i] - h[i-j]));
		}
	}
	printf("%d\n", mincost[n-1]);
}


Measured memory_bytes: 1024
/*
author : nit1n
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;
	
	int n ; 
	cin>> n ;
	cout <<(n+1)/2  ; 

}


Measured memory_bytes: 3648
H, W = gets.split.map(&:to_i)
S = readlines.map(&:chomp)

m = ['#' * (W + 2)] + S.map{|l| ("#" + l + "#")} + ['#' * (W + 2)]
q = [[1, 1]]
d = {}
d[[1, 1]] = 1
while !q.empty?
  i0, j0 = q.shift
  [[1, 0], [-1, 0], [0, 1], [0, -1]].each do |di, dj|
    i, j = i0 + di, j0 + dj
    next if m[i][j] != '.' || d[[i, j]]
    d[[i, j]] = d[[i0, j0]] + 1
    (puts S.inject(0){|s, l| s + l.count('.')} - d[[H, W]]; exit) if [i, j] == [H, W]
    q << [i, j]
  end
end
puts -1

Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#define REP(i,m,n) for(int i = (int)(m) ; i < (int) (n);i++)
#define rep(i,n) REP(i , 0 ,n)
using namespace std;

int n, p[22];
int c;


int main() {
	cin >> n;
	rep(i, n)  cin >> p[i];
	REP(i, 1, n - 1) {
		if (p[i] < p[i - 1] && p[i] > p[i + 1] || p[i] > p[i - 1] && p[i] < p[i + 1]) {
			c++;
		}
	}
	cout << c << endl;


	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_EXP = 60;

int main()
{
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	bool printed1 = false;
	for (int i = MAX_EXP; i >= 0; i--)
	{
		ll minVal = 0, maxVal = 0;
		for (int j = 1; j < i; j += 2)
			minVal -= (1LL << j);
		for (int j = 0; j < i; j += 2)
			maxVal += (1LL << j);
		if (n >= minVal && n <= maxVal)
		{
			if (i == 0 || printed1)
				cout << '0';
		}
		else
		{
			cout << '1';
			printed1 = true;
			n -= (1LL << i) * ((i % 2 == 0) ? 1LL : -1LL);
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	int h, n; cin >> h >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int num; cin >> num;
		sum += num;
	}
	if (sum >= h) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }


	return 0;
}

Measured memory_bytes: 384
//(bool) ? (if true) : (if false)
//63LL - __builtin_clzll(n)
//(x&-x)
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pf push_front
#define sz size()
#define FORN(i,j,n) for(long long i=j; i<(long long)n;i++) 
#define FOR(i,n) FORN(i,0,n)
#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )
#define LIM 262150
#define ones(x) __builtin_popcount(x)
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
using namespace std;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;
const ll MAX = 1e5+5;

int main() {
	fastio;
	ll d,t,s; cin >> d >> t >> s;
	if(d <= t*s) cout<< "Yes\n";
	else cout<< "No\n";
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>

int main() {
	int n;
	std::cin >> n;
	std::vector<int>v(n);
	for (int i = 0;i < n;i++) {
		std::cin >> v[i];
	}
	std::sort(v.begin(), v.end());
	int nSum = 0;
	for (int i = 0;i < n;i++) {
		if (v[i] == v[i + 1]) {
			i++;
		}
		else {
			nSum++;
		}
	}
	std::cout << nSum << std::endl;
	return 0;
}
	


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;


/*Please dont change namespace, Dcoder 
and class must not be public*/

//Compiler version 4.0, .NET Framework 4.5


namespace Dcoder
{
public class Program
{
public static void Main(string[] args)
{
Method(args);
}

public static void Method(string[] args)
{
string[] s=Console.ReadLine().Split(' ');
long a=long.Parse(s[0]);
long b=long.Parse(s[1]);
Console.WriteLine((a-1)*(b-1));
}
}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535

int main() {
    ll n;
    cin >> n;
    vector<ll> h(n);
    vector<bool> down(n);
    for(ll i = 0; i < n; i++){
        cin >> h[i];
        down[i] =false;
    }
    bool ans;
    ll now = 0;
    while(1){
        if(now == n - 1){
            ans = true;
            break;
        }else if(h[now] <= h[now + 1]) now++;
        else{
            if(now == 0){
                if(!down[now]){
                    h[now]--;
                    down[now] = true;
                }else{
                    ans = false;
                    break;
                }
            }else{
                now--;
                if(!down[now + 1]){
                    h[now + 1]--;
                    down[now + 1] = true;
                }else{
                    ans = false;
                    break;
                }
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    

}


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

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
    map<char,int> count;
    for (char a : S){
        count[a]++;
    };
    if ((abs(count['b']-count['a'])<=1)&&(abs(count['c']-count['b'])<=1)&&(abs(count['a']-count['c'])<=1)) cout << YES << endl;
    else cout << NO << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}
func main() {
	inputs := scanIntNums()
	N := inputs[0]
	M := inputs[1]
	X := inputs[2]

	books := make([][]int, N)

	for i := 0; i < N; i++ {
		inputs := scanIntNums()
		books[i] = inputs
	}

	var tmp int
	min := -1
	var patterns [][]int
	var skipFlag bool
	for i := 1; i <= N; i++ {
		patterns = append(patterns, choose(i, N)...)
	}
	for _, pattern := range patterns {
		tmpArray := make([]int, M)
		tmp = 0
		skipFlag = false

		for _, num := range pattern {
			tmp += books[num-1][0]
			for i := 1; i <= M; i++ {
				tmpArray[i-1] += books[num-1][i]
			}
		}
		for _, sum := range tmpArray {
			if sum < X {
				skipFlag = true
			}
		}
		if !skipFlag && (tmp < min || min == -1) {
			min = tmp
		}
	}
	fmt.Println(min)

}

func choose(N, M int) [][]int {
	var count int

	var result [][]int
	var tmp []int

	for bits := 0; bits < (1 << uint64(M)); bits++ {
		for i := 0; i < M; i++ {
			if (bits>>uint64(i))&1 == 1 {
				if count == 0 {
					tmp[0] = i + 1
				} else {
					tmp = append(tmp, i+1)
				}
				count++
			}
		}
		if count == N {
			result = append(result, tmp)
		}
		count = 0
		tmp = make([]int, 1)
	}

	return result
}


Measured memory_bytes: 6620
import java.util.*;
 
class Main {
static Scanner scan = new Scanner(System.in);
  
  public static void main(String[] args){
	String S = scan.next();
	long K = scan.nextLong();
    int oneCount = 0;
    String ans = null;
    for(int i = 0; i < S.length();i++){
    	if("1".equals(S.substring(i,(i+1)))){
          oneCount += 1;
          continue;
        }
      break;
  	}
    
    if(oneCount >= K){ans = "1";}
    else{ ans = S.substring(oneCount,(oneCount+1));}
    
    System.out.println(ans);
  }
}


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

int main(void)
{
	int A, B, C;
	cin >> A >> B >> C;

	vector <int> n;
	n.push_back(A); n.push_back(B); n.push_back(C);

	int ans = 0;
	while ((n[0]!=n[1]) || (n[0]!=n[2]))
	{
		std::sort(n.begin(), n.end());
		if (n[1]==n[2]) {
			n[0] += 2;
			ans++;
		} else {
			n[0] += 1;
			n[1] += 1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

vector< pair<int, vector<int>> > calcPossibleSums(int l, int M, vector<int> k, vector<bool> canZero){
  vector< pair<int, vector<int>> > res;
  for(int S=0;S<(1<<10);S++){
    if(__builtin_popcount(S) != M) continue;
    vector<int> perm;
    for(int i=0;i<10;i++){
      if( S & (1<<i) ) perm.push_back(i);
    }

    vector<int> sums;
    do{
      int sum = 0;
      bool leading_zero = false;
      for(int i=0;i<M;i++){
        sum += k[l+i] * perm[i];
        if(not canZero[l+i] and perm[i]==0) leading_zero = true;
      }
      if(not leading_zero) sums.push_back(sum);
    }while( next_permutation(perm.begin(), perm.end()) );

    sort(sums.begin(), sums.end());
    res.push_back( make_pair(S, sums) );
  }
  return res;
}

int main(){
  int n;
  while(cin >> n){
    if(n == 0) break;

    string s;
    map<char, int> id;
    vector<int> k(10, 0);
    vector<bool> canZero(10, true);
    for(int i=0;i<n;i++){
      cin >> s;
      int x = 1;
      for(int j=s.size()-1;j>=0;j--){
        if(id.count(s[j]) == 0) id[s[j]] = id.size()-1;
        k[id[s[j]]] += (i==n-1) ? -x : x;
        x *= 10;
      }
      if(s.size()>1) canZero[id[s[0]]] = false;
    }

    int M = id.size();
    if(M==1){
      cout << 0 << endl; continue;
    }

    int l_len = M/2, r_len = M - l_len;
    auto l_sums = calcPossibleSums(0, l_len, k, canZero);
    auto r_sums = calcPossibleSums(l_len, r_len, k, canZero);

    int ans = 0;
    for(auto& l : l_sums){
      for(auto& r : r_sums){
        if( l.first & r.first ) continue;
        for(int x : l.second){
          int num = upper_bound(r.second.begin(), r.second.end(), -x)
                     - lower_bound(r.second.begin(), r.second.end(), -x);
          ans += num;
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
// URDL
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
long long mod = 1e9+7;
//

int main(){
  int n, m; cin >> n >> m;
  vector<int> a(m);
  vector<long long> dp(n+1, 0);
  dp[0] = 1;
  dp[1] = 1;
  for(int i=0; i<m; i++) {
    cin >> a[i];
    dp[a[i]] = -1;
  }

  for(int i=2; i<=n; i++) {
    if(dp[i] == -1) continue;
    if(dp[i-1] != -1) dp[i] += dp[i-1];
    if(dp[i-2] != -1) dp[i] += dp[i-2];
    dp[i] %= mod;
  }

  cout << dp[n] << endl;

  return 0;
}




// EOF


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main()
{
	string s, t; 
	cin >> s >> t;
 
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
 
	if( s < t )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    for(int i =a;i<=b; i++){
      if(i%k==0){
        System.out.println("OK");
        return ;
      }
    }



    System.out.println("NG");
  }
}


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

using namespace std;
 int res[4];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        string c;
        cin>>c;
        if(c=="AC"){
            res[0]++;
        }
        else if(c=="WA"){
            res[1]++;
        }
        else if(c=="TLE"){
            res[2]++;
        }
        else{
            res[3]++;
        }
     
    }
       cout<<"AC x "<<res[0]<<endl;
         cout<<"WA x "<<res[1]<<endl;
          cout<<"TLE x "<<res[2]<<endl;
           cout<<"RE x "<<res[3]<<endl;

}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){
    s[i] = (s[i]-'A'+n)%26+'A';
  }
  cout << s << endl;
}


Measured memory_bytes: 256
a = []
a.append(list(input().split()))
a.append(list(input().split()))
a.append(list(input().split()))
flag = [[False]*3]*3

n = int(input())

for i in range(n):
  b = input()
  for j in range(3):
    for k in range(3):
      if (a[j][k] == b):
        a[j][k] = 0
        
# ビンゴのチェック
ans = 'No'
# 横
for i in range(3):
  if (a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
    ans = 'Yes'
# 縦
for i in range(3):
  if (a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0):
    ans = 'Yes'
# 斜め
if (a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0):
  ans = 'Yes'
elif (a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
  ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    unsigned long N, M, K;
    cin >> N >> M >> K;

    unsigned long i, total_tm = 0;
    unsigned long A[N], B[M], A_sum[N + 1];
    A_sum[0] = 0;
    for (i = 0; i < N; i++) {
        cin >> A[i];
        total_tm += A[i];
        A_sum[i + 1] = total_tm;
    }
    for (i = 0; i < M; i++) {
        cin >> B[i];
        total_tm += B[i];
    }

    if (total_tm <= K) {
        cout << N + M;
        return 0;
    }
    if (K < A[0] && K < B[0]) {
        cout << 0;
        return 0;
    }

    unsigned long best_j = M - 1;
    unsigned long max_i_j = 0;
    unsigned long b_j = total_tm - A_sum[N];

    for (i = 0; i < N + 1; i++) {
        if (K >= A_sum[i]) {
            unsigned long j;
            for (j = best_j; j >= 0; j--) {



                if (K - A_sum[i] >= b_j) {
                    best_j = j;
                    if (max_i_j < best_j + 1 + i) {
                        max_i_j = best_j + 1 + i;
                    }
                    break;
                }
                b_j -= B[j];
            }
        }
    }

    cout << max_i_j;

    return 0;
}

Measured memory_bytes: 8280
n,m = gets.split.map(&:to_i)
a = []
n.times{
  a << gets.chomp.split("")
}
b = []
m.times{
  b << gets.chomp.split("")
}
result = "false"
for i in 0..n-m
  for j in 0..n-m
ans = "true"
for l in 0..m-1
  for k in 0..m-1
    if a[i+l][j+k] != b[l][k]
      ans = "false"
    end
  end
end
  if ans == "true"
    result = "true"
  end
  end
end
if result == "true"
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 2172
import java.util.Scanner;

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

		int x, y;

		while(true) {
			x = sc.nextInt();
			y = sc.nextInt();
			if(x == 0 && y == 0) {
				break;
			}
			if(x > y) {
				System.out.println(y + " " + x);
			} else {
				System.out.println(x + " " + y);
			}
		}
	}
}



Measured memory_bytes: 35072
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a[100]={};
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        a[(int)s[i]]++;
    }for(int i=60;i<95;i++){
        if(a[i]!=0&&a[i]!=2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

int main()
{
    __

    int n,sum=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    if((sum-a[n-1])>a[n-1]) cout<<"Yes";
    else cout<<"No";

return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    for(int i = 0; i < n; i++) cin >> a[i];
    a[n] = 0;
    ll sum = 1000;
    ll k = 0;
    int flag;
    if(a[0] > a[1]) flag = -1;
    else{
        flag = 1;
        k = sum/a[0];
        sum -= k*a[0];
    }
    for(int i = 1; i < n; i++){
        if(a[i] > a[i+1] && flag == 1){
            flag = -1;
            sum += k*a[i];
            k = 0;
        }
        if(a[i] < a[i+1] && flag == -1){
            flag = 1;
            k = sum/a[i];
            sum -= k*a[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3628
from itertools import permutations
N = int(input())
map_xy = []
for i in range(N):
  map_xy.append(list(map(int,input().split())))
  
def length_calc(start,goal):
  #print("S&G",start,goal)
  #print(start[0],start[1],goal[0],goal[1])
  return ((goal[1]-start[1])**2 + (goal[0]-start[0])**2)**0.5
  
#########################
list=[_ for _ in range(N)]
per=permutations(list,N)


route_distance = 0
per_count = 0
for i in per:
  go_to_tuple = i
  for j in range(len(go_to_tuple)-1):
    start = map_xy[go_to_tuple[j]]
    goal = map_xy[go_to_tuple[j+1]]
    #print("LEMNGTH",length_calc(start,goal))
    route_distance += length_calc(start,goal)
  per_count += 1

#print(per_count)
ans = route_distance /  per_count
print(ans)
    
    

Measured memory_bytes: 9384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int arr[300005],n;
ll sumXOR() 
{ 
    ll sum = 0; 
    for (int i = 0; i < 62; i++)  
    { 
        int zc = 0, oc = 0;  
        ll idsum = 0;  
        for (int j = 0; j < n; j++) 
            if (!((1LL<<i)&arr[j])) 
                zc++;  
        idsum = ((((n-zc)* zc)%MOD)* ((1LL << i)%MOD))%MOD;   	
        sum = ((sum%MOD)+(idsum%MOD))%MOD;  
    } 
    return sum%MOD; 
} 
int32_t main(){
	boost;
	ll ans=0;
	cin>>n;
	for (int i = 0; i < n; ++i)
		cin>>arr[i];
	cout<<sumXOR();
	return 0;
}
//long long
//array bounds
//special cases
//binary search

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;

vector<pair<ll, ll>> pf(ll n){
    vector<pair<ll, ll>> res;
    for (ll i = 2; i*i <= n; i++){
        if (n%i != 0){
            continue;
        }
        else{
            ll ex = 0;
            while (n%i == 0){
                ex++;
                n /= i;
            }
            res.push_back({i, ex});
        }
    }
    if (n != 1){
        res.push_back({n, 1});
    }
    return res;

    //素因数分解
    //入力:ll
    //出力:vector<pair<ll, ll>>
    //res[i].first == i番目に小さい素因数
    //res[i].second == res[i].firstの指数
}

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

    ll n,p;
    cin >> n >> p;

    vector<pair<ll,ll>> x = pf(p);
    ll ans = 1;

    for (auto i : x){
        if (i.second < n){
            continue;
        }

        rep(j,(i.second/n)){
            ans *= i.first;            
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 3664
#include <stdio.h>

char s[15];

int main() {
    scanf("%s", s);
    if (s[0] == 'A') printf("T\n");
    else if (s[0] == 'C') printf("G\n");
    else if (s[0] == 'G') printf("C\n");
    else printf("A\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;
int main( void ){
	int s; cin >> s;
	map <int, bool> mp;
	int cnt = 1;
	while(true){
		if (mp[s]){
			cout << cnt << endl;
			return 0;
		}
		mp[ s ] = true;
		cnt++;
		if (s % 2 == 0)
			s /= 2;
		else
			s = s * 3 + 1;
	}

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, c;

  scanf("%d%d%d", &a, &b, &c);

  if(a < b){
    if(b < c){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 580
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int n;
long long sum, a;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a);
		sum+=a;
	}
	if(sum%2)puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
 
int32_t main()
{
    int a,b,n;
    cin>>a>>b>>n;
    if(n>=b)
    {
      n=b-1;
    	cout<<floor((a*n)/b);
    }
    else
    {
        int x=n;
        cout<<floor((a*x)/b)-a*floor(x/b);
        
    }
 
    
 
}


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

ln = list()
for i in range(n):
    ln.append(list(map(int, input().split())))

lm = list()
for i in range(m):
    lm.append(list(map(int, input().split())))

for i in range(n):
    d = abs(ln[i][0] - lm[0][0]) + abs(ln[i][1] - lm[0][1])
    ans = 1
    for j in range(1, m):
        if d > abs(ln[i][0] - lm[j][0]) + abs(ln[i][1] - lm[j][1]):
            d = abs(ln[i][0] - lm[j][0]) + abs(ln[i][1] - lm[j][1])
            ans = j+1
    print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int out =0;
		if(str.equals("SUN")) {
			out = 7;
		}else if(str.equals("MON")) {
			out = 6;
		}else if(str.equals("TUE")) {
			out = 5;
		}else if(str.equals("WED")) {
			out = 4;
		}else if(str.equals("THU")) {
			out = 3;
		}else if(str.equals("FRI")) {
			out = 2;
		}else if(str.equals("SAT")) {
			out = 1;
			
		}
		System.out.println(out);
	}

}


Measured memory_bytes: 19412
n,m = map(int, input().split())
p = [0]*n
q = [False]*n
for _ in range(m):
  v,s = input().split()
  v = int(v)-1
  if q[v]: continue
  if s == 'AC': q[v] = True
  else: p[v] += 1
print(sum(q),sum(p[i] for i in range(n) if q[i]))

Measured memory_bytes: 4596
A,B = map(int, input().strip().split(' '))

if B-A < 4:
  answer = 0
  for i in range(A,B+1):
    answer ^= i
  print(answer)
  exit()
	
if A%2 == 0:
  head = 0
  left = A
else:
  head = A
  left = A+1

if B%2 == 0:
  tail = B
  right = B-1
else:
  tail = 0
  right = B

body = int(((right-left+1)/2)%2)
  
print(head^body^tail)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
 int n,k,q,a,i,p[100000]={};
 scanf("%d%d%d",&n,&k,&q);
 for(i=0;i<q;i++){scanf("%d",&a);p[a-1]++;}
 for(i=0;i<n;i++)printf("%s\n",p[i]-q+k>0?"Yes":"No");
 return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int a[100010],c[100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),mx=0,mn=1e9;
	for(int i=1;i<=n;++i)++c[a[i]=gi()],mx=std::max(a[i],mx),mn=std::min(a[i],mn);
	if(mx-mn>1)return puts("No"),0;
	if(mx==mn){
		if(mx==n-1||mx*2<=n)puts("Yes");
		else puts("No");
		return 0;
	}
	if(mn<c[mn]||n-c[mn]<2*(mx-c[mn]))puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
s = []
for i in range(n):
  s.append(input())

import collections
c = collections.Counter(s)
values, counts = zip(*c.most_common())

maxn = counts[0]
cnt = counts.count(maxn)
l = []
for i in range(cnt):
  l.append(values[i])

l.sort()

for i in range(len(l)):
  print(l[i])

Measured memory_bytes: 59532
#include<stdio.h>
int main(){
  int n;
  int i,j;
  int cnt=0;
  int a;
  int mochi[111];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    for(j=0;j<cnt;j++){
      if(mochi[j]==a) break;
    }
    if(j==cnt){
      mochi[cnt]=a;
      cnt++;
    }
  }

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

  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int p,ans;
string s,t;
map<char,int>m;
map<int,int>cnt;

int bnf();

int get(){
  int res;
  if(s[p]=='[')p++,res=bnf(),p++;
  else if(isalpha(s[p]))res=m[s[p++]];
  return res;
}

int bnf(){
  int res=get(),a,b;
  while(s[p]=='+'||s[p]=='*'||s[p]=='^'){
    int tmp=p++;
    a=get();
    b=get();
    if(s[tmp]=='+')res=a|b;
    if(s[tmp]=='*')res=a&b;
    if(s[tmp]=='^')res=a^b;
  }
  return res;
}

void dfs(int d,string tt){
  if(d==4){
    p=0;
    m['a']=tt[0]-'0';
    m['b']=tt[1]-'0';
    m['c']=tt[2]-'0';
    m['d']=tt[3]-'0';
    int x=bnf();
    if(tt==t)ans=x;
    cnt[x]++;
    return;
  }
  r(i,10){
    string pp=tt;
    pp+=(i+'0');
    dfs(d+1,pp);
  }
}

int main(){
  while(cin>>s,s!="."){
    cin>>t;
    s+="@";
    cnt.clear();
    dfs(0,"");
    cout<<ans<<' '<<cnt[ans]<<endl;
  }
}



Measured memory_bytes: 3216
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    if (S.size() <= K)
        cout << S << endl;
    else {
        string s = S.substr(0, K);
        cout << s << "..." << endl;
    }
}

Measured memory_bytes: 3640
//package com.company;

import java.io.*;
import java.util.*;


public class Main {
    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int k = sc.nextInt();
            if ((n + 1) / 2 >= k) {
                pw.println("YES");
            } else {
                pw.println("NO");
            }

        }

    }

    private static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("23.in"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("froggy.out"));


//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));
        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

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

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

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

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

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

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

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

int main(){
  int a,b,c;
  cin >>a>>b>>c;
  if(a==b&&a==c&&b==c) cout <<"No"<<endl;
  else if(a==b||a==c||b==c) cout <<"Yes"<< endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3520
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    tmd = collections.defaultdict(list)
    n = int(input().rstrip('\n'))
    d = collections.defaultdict(int)
    for i in range(n-1):
        tma, tmb, cost = list(map(int, input().rstrip('\n').split()))
        tmd[tma-1] += [tmb-1]
        tmd[tmb-1] += [tma-1]
        d[tma-1, tmb-1] = cost
        d[tmb-1, tma-1] = cost

    ql = [[0, 0]]
    ql = collections.deque(ql)
    fq = collections.defaultdict(int)
    while True:
        if len(ql) != 0:
            cost, tmp = ql.popleft()
            for tmv in tmd[tmp]:
                if tmv not in fq:
                    ql.append([cost + d[tmv, tmp], tmv])
                    fq[tmv] = (cost + d[tmv, tmp]) % 2
        else:
            break
    for i in range(n):
        print(fq[i])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 115036
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int x, y, a, b, c;
  readf("%s %s %s %s %s\n", &x, &y, &a, &b, &c);
  auto p = readln.chomp.split.to!(long[]);
  auto q = readln.chomp.split.to!(long[]);
  auto r = readln.chomp.split.to!(long[]);
  sort(p);
  sort(q);
  auto t = p[$-x..$] ~ q[$-y..$] ~ r;
  sort!("a > b")(t);
  t[0..x+y].sum.writeln;
}


Measured memory_bytes: 14932