akhauriyash/Code-Regression huggingface dataset:
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define endl '\n'
#define pb push_back

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// debug 도구 end

using llong = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VPII = vector<pair<int, int>>;
using VLL = vector<long long>;
using PII = pair<int, int>;

int main() {
	string s;
	cin >> s;
	if (s == "RRR") cout << 3;
	else {
		int cnt = 0;
		for (int i = 0; i < 3; i++) {
			if (s[i] == 'R') cnt++;
		}
		if (cnt == 1) {
			cout << 1;
		}
		else if (cnt == 0) {
			cout << 0;
		}
		else if (s[1] == 'R') cout << 2;
		else cout << 1;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <cmath>
#include <limits>
#include <iostream>

using namespace std;
int main(){
int n;
double ans=0.0;
double path=0.0;
cin >> n;
double order=n;
//order=n;
//order/=2;
//for(int i=1;i<=n;i++){
//  order*=i;
//}
order/=2.0;
int place[n][2];
for(int i=0;i<n;i++){
  cin >> place[i][0] >> place[i][1];
}
for(int i=0;i<n;i++){
  for(int j=i+1;j<n;j++){
    path += (hypot(double(place[i][0] - place[j][0]), double(place[i][1] - place[j][1])));
  }
}
printf("%.9lf\n", path / order);
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N, x;
int a[101];

int main()
{
    cin >> N >> x;

    for (int i = 0; i < N; i++)
        cin >> a[i];

    sort(a, a+N);

    int ans = 0;

    for(int i = 0; i < N; i++){
        x -= a[i];
        if(x < 0)
            break;
        ans++;
    }
    if(x > 0)
        ans--;

    cout << ans <<'\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] hwn = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long h = hwn[0];
            long w = hwn[1];
            long n = hwn[2];

            long[] ans = new long[10];

            HashMap<long, int> map = new HashMap<long, int>();

            for (int i = 0; i < n; i++)
            {
                string[] abstr = Console.ReadLine().Split(' ');
                long x = long.Parse(abstr[0]) - 1;
                long y = long.Parse(abstr[1]) - 1;

                for (int dx = 0; dx < 3; dx++)
                {
                    for (int dy = 0; dy < 3; dy++)
                    {
                        long px = x - dx;
                        long py = y - dy;
                        if (px < 0 || py < 0) continue;
                        if (px + 3 > h || py + 3 > w) continue;
                        map[px * 10000000000 + py]++;
                    }
                }


            }
            foreach (var d in map)
            {
                ans[d.Value]++;
            }

            ans[0] = (h - 2) * (w - 2) - map.Count;

            for (int i = 0; i < ans.Length; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
    }
}
#region HashMap
public class HashMap<K, V> : Dictionary<K, V>
//where V : new()
{
    public HashMap() : base() { }
    public HashMap(int cap) : base(cap) { }
    new public V this[K i]
    {
        get
        {
            V v;
            return TryGetValue(i, out v) ? v :
                base[i] = default(V);
            //base[i] = new V();
        }
        set { base[i] = value; }
    }
}
#endregion

Measured memory_bytes: 48680
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpll vector<pair<ll,ll>>
#define INF 0x3f3f3f3f
#define mp make_pair

int main()
{
    ll a,b;
    in(a);
    ll ans = a-1;
    for(ll i=2;i*i<=a;i++) {
        if(a%i==0) ans = min(ans,i+(a/i)-2);
    }
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a >= 13 {
		fmt.Println(b)
	} else if a >= 6 && a <= 12 {
		fmt.Println(b / 2)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		
		int k = Integer.parseInt(sc.next());
		
		int now = 0;
		boolean jdg = false;
		
		for(int i = 0 ; i <= w ;i++) {
			for(int j = 0 ; j <= h ; j++) {
				now = h * i + w * j - (i * j * 2);
				//System.out.println(now);
				if(now == k) {
					jdg = true;
					break;
				}
			}
		}
		
		
		if(jdg) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
  int main(){
      lint h1,m1,h2,m2,k;
      string s;
    
      cin>>h1>>m1>>h2>>m2>>k;
        lint ans=(h2-h1)*60+m2-m1;
      cout<<max(ans-k,(lint)0);
          }
     
  
      
      
    

  
          
  

Measured memory_bytes: 3720
s = input()
if s == 'SUN' :
  print(7)
elif s == 'MON' :
  print(6)
elif s == 'TUE' :
  print(5)
elif s == 'WED' :
  print(4)
elif s == 'THU' :
  print(3)
elif s == 'FRI' :
  print(2)
elif s == 'SAT' :
  print(1)

Measured memory_bytes: 3060
import sys

def comb(n, r):
    ans = 1
    for i in range(r): ans *= (n - i)
    for i in range(r): ans //= (i + 1)
    return ans

def solve():
    input = sys.stdin.readline
    N, P = map(int, input().split())
    A = [int(a) for a in input().split()]
    even, odd = 0, 0
    for a in A:
        if a % 2 == 0: even += 1
        else: odd += 1
    
    even_Chose = 0
    odd_Chose = 0
    for i in range(even + 1): even_Chose += comb(even, i)
    for i in range(odd + 1):
        if i % 2 == P: odd_Chose += comb(odd, i)
    print(even_Chose * odd_Chose) 

    return 0

if __name__ == "__main__":
    solve()



Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

ll llmax(ll a, ll b){
  return a > b ? a : b;
}

int main(){
  ll N, P;
  cin >> N >> P;
  ll ans;
  if(N==1){
    ans = P;
  }else{
    ans = 1;
    ll p = P;
    ll n = 2;
    while(n <= p && n*n <= P){
      ll pow = 0;
      while(p % n == 0){
        p /= n;
        pow++;
        if(pow%N==0) ans *= n;
      }
      n++;
    }
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<63);

int main() {
  ll N, A, a = 0, b = 0, c = 0, ans = 1;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    int pat = 0;
    if (A == a) pat++;
    if (A == b) pat++;
    if (A == c) pat++;
    ans *= pat;
    ans %= 1000000007;
    if (A == a) a++;
    else if (A == b) b++;
    else if (A == c) c++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import collections

n, k = map(int, input().split())
l = list(map(int, input().split()))

c = collections.Counter(l)
c = c.most_common()

m = len(c)
if m <= k:
    print(0)

else:
    ans = [c[i][1] for i in range(k, m)]
    print(sum(ans))

Measured memory_bytes: 39320
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	string s; cin >> s;
    int n = (int)s.size();
    int ans = 0;
    rep(i, n - 1) {
        if(s[i] != s[i + 1]) {
            ++ans;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 512
n=int(input())

t = list(map(int,input().split()))

count = 0

for i in t:
    if i < 0:
        count += 1

memo = []

for i in t:
    memo.append(abs(i))
memo.sort()

if count%2==0:
    print(sum(memo))
else:
    print(sum(memo)-memo[0]*2)

Measured memory_bytes: 65440
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
using P = pair<int,int>;
typedef long long ll;

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;


bool is_prime(ll N) {
    //素数かどうかをTFで返す
    //Ex. input 13=>false, 2=>true
    if (N == 1) return false;
    for (ll i=2; i*i<=N; i++) {
        if (N % i == 0) return false;
    }
    return true;
}
vector<ll> factor(ll N) {
    //全約数を返す
    //Ex. input 24=>[1,2,3,4,6,8,12,24]
    vector<ll> res;
    for (ll i=1; i*i <= N; i++) {
        if (N%i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
vector<pair<ll, ll>> factors(ll N) {
    //Nの素因数分解を返す
    //Ex. input:24=>{{2, 3}, {3, 1}}
    vector<pair<ll, ll>> res;
    for(ll i=2; i*i<=N; i++){
        if(N%i!=0) continue;
        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;
}

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll lb = b*100+0.05;
    a *= lb;
    a /= 100;
    printf("%lld\n", a);
}

Measured memory_bytes: 3820
n = int(input())
s = sorted([int(input()) for i in range(n)])
total = sum(s)
ans = 0
if total % 10 != 0:
    print(total)
else:
    for i in s:
        if i % 10 != 0:
            ans = total - i
            break
    print(max(0, ans))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    reverse(all(s));
    int n=s.size();

    string a="maerd";
    string b="remaerd";
    string c="esare";
    string d="resare";

    int id=0;
    while(id<n){
        bool ok1=true,ok2=true,ok3=true,ok4=true;
        rep(i,a.size()){
            if(s[id+i]!=a[i]) ok1=false;
        }
        rep(i,b.size()){
            if(s[id+i]!=b[i]) ok2=false;
        }
        rep(i,c.size()){
            if(s[id+i]!=c[i]) ok3=false;
        }
        rep(i,d.size()){
            if(s[id+i]!=d[i]) ok4=false;
        }

        if(ok1) id+=a.size();
        else if(ok2) id+=b.size();
        else if(ok3) id+=c.size();
        else if(ok4) id+=d.size();
        else{
            cout<<"NO"<<endl;
            return 0;
        }
        
        if(id==n){
            cout<<"YES"<<endl;
            return 0;
        }
    }

    cout<<"NO"<<endl;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	vi P(N); // index -> value
	map<int, int> m; // value -> index
	rep(i, N) { // 0-indexed
		cin >> P.at(i); // index -> value
		m[P.at(i)] = i; // value -> index
	}	
	// vdebug(P);
	// for (auto mi : m) cout << mi.first << " " << mi.second << endl;
	set<int> s;
	s.insert(-2); s.insert(-1); s.insert(N); s.insert(N + 1); // 番兵 ※重複不可のため
	ll ans = 0;
	for (int k = N; k > 0; k--) { // k:value
		s.insert(m.at(k)); // indexを入れる		
		auto it = s.lower_bound(m.at(k)); // 値kに対応する添字xに対応するiterator
		// auto it = lower_bound(all(s), m.at(k)); // ダメな例
		ll l2 = max(*prev(prev(it)), -1);
		ll l1 = *prev(it);
		ll x = *it;
		ll r1 = *next(it);
		ll r2 = min(*next(next(it)), N);
		// debug(k);
		// for (auto si : s) cout << si << " "; cout << endl;
		// debug (l2); debug(l1); debug(x); debug(r1); debug(r2);
		ll temp = k * ((l1 - l2) * (r1 - x) + (x - l1) * (r2 - r1));
		// debug(temp);
		ans += temp;
	}

	cout << ans << endl;
}


Measured memory_bytes: 9984
#include <iostream>

using namespace std;

int main(void)
{
  int X;
  int ans;
  cin >> X;
  int iBuf1;
  int iBuf2;
  iBuf1 = X /500;
  iBuf2 = X % 500;
  iBuf2 = iBuf2 /5;
  ans = iBuf1 *1000 + iBuf2*5;
  cout << ans << endl;
  
}


Measured memory_bytes: 3592
object Main extends App {
    val stdin = new java.util.Scanner(new java.io.BufferedInputStream(System.in))
    val stdout = new java.io.PrintWriter(new java.io.BufferedOutputStream(System.out))

    while (stdin.hasNext()) {
        val n = stdin.nextInt()
        val m = stdin.nextInt()
        val c = stdin.nextLong()

        val lhs = Array.fill(n)(stdin.nextLong()).scanLeft(0L)(_ + _)
        val rhs = Array.fill(m)(stdin.nextLong()).scanLeft(0L)(_ + _)

        var p = 0
        var q = 0

        while (p + 1 <= n && lhs(p + 1) <= c) p += 1

        var foo = p
        while (p >= 0) {
            while (q + 1 <= m && lhs(p) + rhs(q + 1) <= c) q += 1
            foo = scala.math.max(foo, p + q)
            p -= 1
        }

        stdout.printf("%d\n", foo.asInstanceOf[java.lang.Integer])
    }

    stdin.close()
    stdout.close()
}

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

int main() {
	int N, X = 0;
	cin >> N;
	for (int i = 1; i <= 500; i++) {
		if (i * (i + 1) / 2 == N) {
			X = i;
			break;
		}
	}
	if (X == 0) cout << "No";
	else {
		cout << "Yes" << endl << X + 1 << endl;
		for (int i = 0; i < X; i++) {
			cout << X;
			for (int j = 1; j <= i; j++) {
				cout << " " << i * (i + 1) / 2 + j;
			}
			for (int j = i; j < X; j++) {
				cout << " " << j * (j + 1) / 2 + i + 1;
			}
			cout << endl;
		}
		cout << X;
		for (int i = 1; i <= X; i++) {
			cout << " " << i * (i + 1) / 2;
		}
	}
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>

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

using namespace std;


int segment_sieve(long a, long b){
    bool is_prime_small[b+1];
    bool is_prime[b+1];
    for(long i=0; i*i <= b; i++) is_prime_small[i] = true;
    for(long i=0; i<b-a; i++) is_prime[i] = true;

    for(long i=2; i*i<=b; i++){
        if(is_prime_small[i]){
            for(long j=2*i; j*j<=b;j+=i) is_prime_small[j] = false;
            for(long j=((a+i) / i ) *i; j<=b; j+=i) is_prime[j-a-1]=false;
        }
    }
    int cnt=0;
    REP(i,b-a){
        if(is_prime[i]) cnt++;
    }
    return cnt;
}

int main(){
    long n;
    while(cin >> n){
        if(n==0) break;
        int res = segment_sieve(n, 2*n);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1636
#include<stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while (A[i] != key)i++;
	return i != n;
}

int main() {
	int i, n, A[10000 + 1], q, key, sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &A[i]);

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &key);
		if (search(A, n, key))sum++;
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 640
#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 = 1e9;

int main() {
  ll n, ans = 0, a, b, c;
  cin >> n;
  for (int i = 1; i < n; ++i) ans += (n - 1) / i;

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef long double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=10001;
const int INF=1LL<<30;
const LL p=7+1e9;
int N,Co;
int DP[2][201][SIZE*2];
int A[201],B[201],C[201];
inline void maximize(int& a,int b){
	a=max(a,b);
}
int main(){
	cin >> N >> Co;
	FOR(i,1,N+1){
		cin >> A[i] >> B[i] >> C[i];
	}
	REP(i,101) REP(j,SIZE) DP[0][i][j]=-INF;
	REP(i,101) REP(j,SIZE) DP[1][i][j]=-INF;
	DP[0][0][0]=0;
	FOR(i,1,N+1){
		bool next=i&1;
		bool now=!next;
		REP(c,Co+1){
			REP(j,SIZE){
				if(DP[now][c][j]<0) continue;
				maximize(DP[next][c+C[i]][j+A[i]],DP[now][c][j]+B[i]);
				maximize(DP[next][c+C[i]][j+B[i]],DP[now][c][j]+A[i]);
				maximize(DP[next][c+C[i]][DP[now][c][j]+A[i]],j+B[i]);
				maximize(DP[next][c+C[i]][DP[now][c][j]+B[i]],j+A[i]);
				maximize(DP[next][c][j],DP[now][c][j]);
				DP[now][c][j]=-INF;
			}	
		}
	}
	int maxim=0;
	REP(i,Co+1) REP(j,SIZE){
		if(DP[N&1][i][j]>=j){
			maxim=max(maxim,j);
		}
	}
	cout << maxim << endl;
	return 0;
}

Measured memory_bytes: 13812
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

ll A, B;

ll f(ll x) {
  ll f_x = 0;

  if ((x + 1) % 2 == 0) {
    ll one_cnt = (x + 1) / 2;
    f_x = one_cnt % 2 == 0;
  } else {
    ll one_cnt = (x + 1) / 2;
    f_x = one_cnt % 2 == 0;
    f_x ^= x;
  }

  return f_x;
}

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

  // if (A == 0 && B == 0) {
  //   cout << 0 << endl;
  //   return 0;
  // }
  // if (A == 0) {
  //   cout << f(B) << endl;
  //   return 0;
  // }

  A--;

  // F(0, A-1)
  ll f_a = f(A);

  // F(0, B)
  ll f_b = f(B);

  cout << (f_a ^ f_b) << endl;
  return 0;
}

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

#define SIZE 2000001

int heap[SIZE];
int n=0;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l = left(i),r = right(i);
  int largest,tmp;

  if(l <= n && heap[l] > heap[i]){
    largest = l;
  }else{
    largest = i;
  }

  if(r <= n && heap[r] > heap[largest]){
    largest = r;
  }

  if(largest != i){
    tmp = heap[i];
    heap[i] = heap[largest];
    heap[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;
  for(i = n/2; i > 0; i--){
    maxHeapify(i);
  }
}

void heapIncreaseKey(int i,int key){
  int tmp;

  heap[i] = key;

  while(i > 1 && heap[parent(i)] < heap[i]){
    tmp = heap[i];
    heap[i] = heap[parent(i)];
    heap[parent(i)] = tmp;
    i = parent(i);
  }
}

void maxHeapInsert(int key){
  n = n + 1;
  heap[n] = INT_MIN;
  heapIncreaseKey(n, key);
}

int heapExtractMax(){
  int max = heap[1];

  heap[1] = heap[n];
  n = n - 1;
  maxHeapify(1);

  return max;
}

int main(){
  int i,key;
  char com[2000000];

  for(i = 1; i <= 2000000; i++){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&key);
      maxHeapInsert(key);
    }else if(com[0] == 'e' && com[1] == 'x'){
      printf("%d\n",heapExtractMax());
    }else if(com[0] == 'e' && com[1] == 'n'){
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 4700
s=input()
n=len(s)
dp=[[0]*(13) for _ in range(n)]
mod=10**9+7

for i in range(n):
    if i==0:
        if s[i]=='?':
            for j in range(10):
                dp[i][j]=1
        else:
            x=int(s[i])
            dp[i][x]=1
    else:
        if s[i]=='?':
            for k in range(10):
                for j in range(13):
                    dp[i][(j*10+k)%13]+=dp[i-1][j]
                    dp[i][(j*10+k)%13]%=mod
        else:
            x=int(s[i])
            for j in range(13):
                dp[i][(j*10+x)%13]+=dp[i-1][j]
                dp[i][(j*10+x)%13]%=mod
print(dp[n-1][5]%mod)

Measured memory_bytes: 61916
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000000
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 1000003;
void solve()
{
    ll n;cin>>n;
    ll a[n+55];
    ll f[maxn]={0};
   
    for(ll i=0;i<n;i++){cin>>a[i];f[a[i]]++;};
    ll cnt =0;
    for(ll i=1;i<=maxn-1;i++)
    {
        if(f[i]>0)
        {
            if(f[i]==1)cnt++;
            for(ll j=i;j<maxn;j+=i)
            {
                f[j]+=4;
            }
        }
        
    }
    cout<<cnt<<endl;
    
}

signed main()
{
   Need_for_speed(activated);

//satisfy
//    {
//  solve();
//   }

    solve();
    
    return 0;
}


Measured memory_bytes: 12992
#include <iostream>
#include <string>
#include <climits>
#include <vector>
using namespace std;

int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
int main(void){
    int n,x,mn = INT_MAX,ans;
    cin >> n >> x;
    vector<int> a(n),b(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        b[i] = abs(x-a[i]);
    }
    int y = b[0];
    for(int i = 0;i < n-1;i++){
        y = gcd(y,b[i+1]);
    }
    cout << y << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();

    set<string> st;

    rep(i, n) {
        string t = "";
        for (int j = i; j < n; j++) {
            if (t.size() > k) break;
            t += s[j];
            st.insert(t);
        }
    }

    int c = 0;
    for (auto&& e : st) {
        c++;
        if (c == k) cout << e << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

sa = list(accumulate(a))
mod = 10 ** 9 + 7
ans = 0
for i in range(n - 1):
    ans += a[i] * (sa[-1] - sa[i])
    ans %= mod
print(ans)


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

int main(){
  int P, Q, R;
  cin >> P >> Q >> R;
  vector<int> a = {P, Q, R};
  sort(a.begin(), a.end());
  cout << a[0] + a[1];
  return 0;
}

Measured memory_bytes: 256
<?php
while (true) {
    $string = getInputStringBothEndsTrimmedSpaces();
    list($a, $operator, $b) = explodeStringWithSpaces($string);
    switch ($operator) {
        case '+':
            $result = addingTwoNum($a, $b);
            break;
        case '-':
            $result = subTractTwoNum($a, $b);
            break;
        case '*':
            $result = multiplyTwoNum($a, $b);
            break;
        case '/':
            $result = divideTwoNumAtFloorPoint($a, $b);
            break;
        case '?':
            exit;
    }
    echo $result, PHP_EOL;
}
 
function getInputStringBothEndsTrimmedSpaces()
{
    return trim(fgets(STDIN));
}
 
function explodeStringWithSpaces($string)
{
    return explode(' ', $string);
}
 
function addingTwoNum($a, $b)
{
    return $a + $b;
}
 
function subTractTwoNum($a, $b)
{
    return $a - $b;
}
 
function multiplyTwoNum($a, $b)
{
    return $a * $b;
}
 
function divideTwoNumAtFloorPoint($a, $b)
{
    return floor($a / $b);
}

Measured memory_bytes: 15392
using System;

namespace tenka1_2018_a
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			if (s.Length == 2) Console.WriteLine(s);
			else
			{
				for (int i = 2; i >= 0; i--) Console.Write(s[i]);
				Console.WriteLine();
			}
		}
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>

int main(){
    std::vector<std::vector<char>> matrix(2, std::vector<char>(3));
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < 3; ++j){
            std::cin >> matrix.at(i).at(j);
        }
    }

    std::vector<std::vector<int>> ans(2, std::vector<int>(3));
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < 3; ++j){
            ans.at(i).at(j) = matrix.at(1 - i).at(2 - j);
        }
    }

    bool flg = false;
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < 3; ++j){
            if(ans.at(i).at(j) == matrix.at(i).at(j)){
                flg = true;
            }else{
                flg = false;
                break;
            }
        }
    }

    if(flg){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int r, g, b;
    cin >> r >> g >> b;
    if ((10 * g + b) % 4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
// C++ program to find the minimum sum of costs such that
// each elements choose one of the costs.
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n,w;
	cin>>n>>w;
	long long int wt[n],val[n];
	long long int i,j;
	for(i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
		// cout<<wt[i]<<" "<<val[i]<<"\n";
	}
	long long int dp[n+1][w+1];
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
			if(i==0 or j==0)
				dp[i][j]=0;
			else
			{
				dp[i][j]=dp[i-1][j];
				if(j>=wt[i-1])
					dp[i][j]=max(dp[i][j],dp[i-1][j-wt[i-1]]+val[i-1]);
				// cout<<dp[i-1][j-wt[i-1]]+val[i-1]<<" ";
			}
			// cout<<dp[i][j]<<" ";
		}
		// cout<<"\n";
	}
	cout<<dp[n][w];
}

Measured memory_bytes: 79232
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cmath>
#include <string>
#include <ctime>
#include <cstring>
#include <queue>
#include <stack>
#define INT long long
#define oo 987654321
#define OO 9999999987654321ll
using namespace std;
INT n, x[200020], a, b, ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    for(int i = 0 ; i < n ; i++ ) cin>>x[i];
    for(int i = 1 ; i < n ; i++ )
        if( (x[i] - x[i-1])*a <= b ) ans += (x[i] - x[i-1])*a;
        else ans += b;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1152
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var n = toInt(input[0]);
	var m = toInt(input[1]);
	var d = toInt(input[2]);
	var ans = (n-d)*(m-1)/(n*n);
	if(d!==0) ans *= 2;
	console.log(ans);
}

Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

ll pLayer(ll num) {
    if (num == 0) return 1;
    return 2 * pLayer(num-1) + 1;
}

ll wholeLayer(ll num) {
    if (num == 0) return 1;
    return 2 * wholeLayer(num-1) + 3;
}

ll f(ll n, ll x, vector<ll> a, vector<ll> p) {
    if (n == 0) {
        if (x <= 0) {
            return 0;
        }
        else {
            return 1;
        }
    }
    else if (x <= 1 + a[n-1]) {
        return f(n-1, x-1, a, p);
    }
    else {
        return p[n-1] + 1 + f(n-1, x-2-a[n-1], a, p);
    }

}

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

    ll n, x;
    cin >> n >> x;

    vector<ll> a, p;
    REP(i, n) {
        a.push_back(wholeLayer(i));
        p.push_back(pLayer(i));
    }


    P(f(n, x, a, p));

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[n];
	ll pref[n+1] = {0};
	int i,j;
	pref[0] = 0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		pref[i+1] = pref[i]+a[i];
	}
	ll dp[n][n]={0};
	for(i=0;i<n;i++)
	{
		for(j=0;j<n-i;j++)
		{
			int k = j+i;
			if(j==k)
			{
				dp[j][k] = 0;
			}
			else
			{	
				int l = j;
				dp[j][k] = dp[j][l]+dp[l+1][k]+pref[k+1]-pref[j];
				for(l = j+1;l<k;l++)
				{
					dp[j][k] = min(dp[j][k],dp[j][l]+dp[l+1][k]+pref[k+1]-pref[j]);
				}
			}
		}
	}

	// for(i=0;i<n;i++)
	// {
	// 	for(j=0;j<n;j++)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<"\n";
	// }

	cout<<dp[0][n-1];
	return 0;
}


Measured memory_bytes: 4880
require 'set'

def opposite(d)
  d == :x ? :y : :x
end

s = gets.chomp
x, y = gets.chomp.split.map(&:to_i)

xy = { :x => [0], :y => [0] }
d, t = :x, 0
s.each_char do |ch|
  if ch == "F"
    d = opposite(d) if t.odd?
    if t != 0
      t = 0
      xy[d] << 0
    end
    xy[d][-1] += 1
  else
    t += 1
  end
end

possibles = Set.new([xy[:x].shift])
until xy[:x].empty?
  dx = xy[:x].shift
  possibles = Set.new.tap do |yld|
    possibles.each do |p|
      yld << p + dx
      yld << p - dx
    end
  end
end
unless possibles.include?(x)
  puts "No"
  exit
end

possibles = Set.new([xy[:y][0], -xy[:y][0]])
xy[:y].shift
until xy[:y].empty?
  dy = xy[:y].shift
  possibles = Set.new.tap do |yld|
    possibles.each do |p|
      yld << p + dy
      yld << p - dy
    end
  end
end
unless possibles.include?(y)
  puts "No"
  exit
end

puts "Yes"

Measured memory_bytes: 83256
#include <iostream>
#include <string>

using namespace std;

int main(){
	string a,b,c;cin >> a >> b >> c;
	int x,y;
	x = a.length();
	y = b.length();
	if(a[x-1] == b[0] && b[y-1] == c[0]){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define write(x) cerr << #x << " = " << (x) << ", "
#define writeI0 cerr << "i = " << 0 << ", "
#define dumpI0 cerr << "i = " << 0 << endl
#define printSet(x) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

int c[3];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin >> s;
    rep(i, 0, LEN(s)) {
        c[ s[i]-'a' ]++;
    }
    int mn = 1e9;
    rep(i, 0, 3) {
        mn = min(mn, c[i]);
    }

    int d = 0;
    rep(i,0,3) {
        c[i] -= mn;
        if(c[i] > 1) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    string s;
    cin >> s;
    map<char,int> mp;
    rep(i, s.size()) mp[s[i]]++;
    int mx = 0; char ch = s[0];
    auto isFin = [&](string str, char ch) {
        bool flag = true;
        for (auto ele : str) {
            if (ele != ch) {flag = false; break;}
        }
        return flag;
    };
    auto count = [&](char ch) {
        string str = s, str1;
        int cnt = 0;
        while(str.size() > 1 && !isFin(str, ch)) {
            str1 = "";
            rep(i,str.size()-1) {
                if (str[i+1] == ch) str1 += ch;
                else str1 += str[i];
            }
            str = str1;
            cnt++;
        }
        return cnt;
    };
    int ans = 100;
    for (auto ele : mp) {
        chmin(ans, count(ele.first));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3612
input();a,b1,b2,b4,r=list(map(int,input().split())),0,0,0,'NYoe s'
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  else: b2+=1
print([r[b1<=b4::2],r[b1<=b4+1::2]][not b2])

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

typedef long long ll;

ll ceil(ll x, ll y) {
  return x / y + (x % y != 0);
}

void solve(long long N, long long X, long long T){
  cout << ceil(N,X) * T << endl;
}

int main() {
  long long N;
  scanf("%lld",&N);
  long long X;
  scanf("%lld",&X);
  long long T;
  scanf("%lld",&T);
  solve(N, X, T);
  return 0;
}


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

vector<int> height;
vector<int> waterVolume;
vector<int> waterPlace;

int getEqualHeightPlace (int start) {
	int i = start;
	int j = i - 2;
	while (j>=0) {
		if (height[i] == height[j]) {
			return j;
		}
		j--;
	}
	return -1;
}

void searchBeforeWaterPlace (int heightPlace) {
	int size = waterPlace.size();
	for (int i = size-1; i>=0; i--) {
		if (waterPlace[i] >= heightPlace) {
			waterVolume.pop_back();
			waterPlace.pop_back();
		} else {
			return;
		}
	}
}

void checker (int size) {
	for (int i=1; i<=size; i++) {
		if (height[i] > height[i-1]) {
			int eHeight = getEqualHeightPlace(i);
			if (eHeight != -1) {
				double volume = 0;
				for (int k=eHeight+1; k<=i; k++) {
					if (height[k] - height[k-1] == -1) {
						volume += 0.5;
						volume += (height[eHeight] - height[k])-1;
					} else if (height[k] - height[k-1] == 0) {
						volume += height[eHeight] - height[k];
					} else {
						volume += 0.5;
						volume += (height[eHeight]- height[k]);
					}
				}
				searchBeforeWaterPlace(eHeight);
				waterVolume.push_back(volume);
				waterPlace.push_back(eHeight);
			}
		}
	}
}

void output(){
	int volumeAll = 0;
	for (int i=0; i<waterVolume.size(); i++) {
		volumeAll += waterVolume[i];
	}
	cout << volumeAll << endl;
	cout << waterVolume.size();
	if (waterVolume.size()>0) {
		cout << " ";
	} else {
		cout << endl;
	}
	for (int i=0; i<waterVolume.size(); i++) {
		cout << waterVolume[i];
		if (i == waterVolume.size()-1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
}

int main(int argc, char const* argv[])
{
	ios::sync_with_stdio(false); 
	string line;
	cin >> line;
	height.push_back(0);
	for (int i=0; i<line.size(); i++) {
		if (line[i] == '/') {
			height.push_back(height[i] + 1);
		} else if (line[i] == '_') {
			height.push_back(height[i]);
		} else {
			height.push_back(height[i] - 1);
		}
	}
	checker (line.size());
	output();
	return 0;
}


Measured memory_bytes: 1424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	vi v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(all(v));
	cout <<v[2]-v[0] << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

#include <bits/stdc++.h>
using namespace std;

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

  if(n%2==1) cout<<0<<endl;
  else{  
    ll k=10;
    ll ans=0;
    while(n/k>=1){
      ans+=n/k;
      k*=5;
    }  
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
#define MOD 1000000007
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
int s[4005][2007];
int main(){
	register int n, m, i, j, k, l, lim, p, a;
	scanf("%d %d %d", &n, &m, &k);
	--k;
	for (i = 1; i <= n + m - 1; ++i) {
		for (j = 1; j <= m; ++j) {
			if (j <= i && i - j < n) a = (s[dmax(i - k, 0)][j] + MOD - s[dmax(i - k, 0)][dmax(j - k - 1, 0)] + 1) % MOD;
			else a = 0;
			s[i][j] = (s[i][j - 1] + a) % MOD;
			//fprintf(stderr, "%d %d %d %d\n", i, j, a, s[i][j]);
		}
	}
	printf("%d", a);
	return 0;
}

Measured memory_bytes: 31488