akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A > B){
      if(A > C && C > B)cout << "Yes" << endl;
      else cout << "No" << endl;
    }
    if(A < B){
      if(A < C && C < B)cout << "Yes" << endl;
      else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt();

    int sum = 0;
    int[] l = new int[n];
    int maxI = 0;

    for (int i = 0; i < n; i++) {
      l[i] = in.nextInt();
      sum += l[i];
      maxI = (l[i] > l[maxI]) ? i : maxI;
    }

    out.println((l[maxI] < sum - l[maxI]) ? "Yes" : "No");

    out.close();
  }

  static class InputReader {

    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

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

  public static int[] mergeSort(int[] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    int[] left = new int[mid];
    int[] right = new int[a.length - mid];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];

    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return merge(mergeSort(left), mergeSort(right));
  }

  public static int[] merge(int[] l, int[] r) {
    int[] merged = new int[l.length + r.length];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      if (l[i] <= r[j])
        merged[k++] = l[i++];
      else
        merged[k++] = r[j++];
    }

    while (i < l.length)
      merged[k++] = l[i++];
    while (j < r.length)
      merged[k++] = r[j++];

    return merged;
  }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
vector<int>ed[N],tr[N];
int vis[N],mk[N];
pii edge[N];
int out[N];
int n,m;
vector<pii>res;
void dfs(int i){
	vis[i]=1;
	for(int j:ed[i]){
		int v=edge[j].fi+edge[j].se-i;
		if(vis[v])continue;
		tr[i].pb(v);
		tr[v].pb(i);
		mk[j]=1;
		dfs(v);
	}
}
void dfs1(int i,int p){
	for(int j:tr[i]){
		if(j==p)continue;
		dfs1(j,i);
	}
	if(!p)return;
	if(out[i]&1){
		res.pb(pii(i,p));
		out[i]++;
	}
	else{
		res.pb(pii(p,i));
		out[p]++;
	}
}
void solve(){
	cin>>n>>m;
	rep(i,m){
		int u,v;
		cin>>u>>v;
		edge[i]=pii(u,v);
		ed[u].pb(i);
		ed[v].pb(i);
	}
	if(m&1){cout<<-1;return;}
	dfs(1);
	for(int i=0;i<m;i++){
		if(mk[i])continue;
		res.pb(edge[i]);
		out[edge[i].fi]++;
	}
	dfs1(1,0);
	for(pii p:res)cout<<p.fi<<" "<<p.se<<"\n";
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 71416
#左より大きければリセット、小さければ+1
n=int(input())
H=input().split()
h=[int(i) for i in H]
li=[0]
for i in range(0,n-1):
    if h[i] >= h[i+1]:
        li[-1] += 1
    else:
        li.append(0)
print(max(li))


Measured memory_bytes: 14648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define int long long

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

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

// 階乗, 逆元テーブル(mod)
const int nMax = 200005;
ll fact[nMax], fact_inv[nMax], inv[nMax];
ll calc_fact() {
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < nMax; i++) {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}

// 組合せ, 二項係数
ll mod_comb(ll n, ll r) {
    if (r < 0 || n < r) return 0;
    return ((fact[n] * fact_inv[r]) % MOD) * fact_inv[n - r] % MOD;
}

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

    calc_fact();

    ll sumx = 0, sumy = 0;
    ll comb = mod_comb(N * M - 2, K - 2);

    REP(i, N) sumx = (sumx + i * (N - i) % MOD) % MOD;
    sumx = sumx * M * M % MOD;
    REP(j, M) sumy = (sumy + j * (M - j) % MOD) % MOD;
    sumy = sumy * N * N % MOD;

    ll ans = comb * (sumx + sumy) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i).sort
b = gets.chomp.split.map(&:to_i).sort
c = gets.chomp.split.map(&:to_i).sort

INF = 10**10

a.unshift(nil)
a.push(INF)
b.unshift(nil)
b.push(INF)
c.unshift(nil)
c.push(INF)

ai = 1
bi = 1

barr = Array.new(N+2, 0)

while ai <= N || bi <= N
  if a[ai] < b[bi]
    barr[bi] += 1
    ai += 1
  else
    bi += 1
    barr[bi] = barr[bi-1]
  end
end

carr = Array.new(N+2, 0)

bi = 1
ci = 1

while bi <= N || ci <= N
  if b[bi] < c[ci]
    carr[ci] += barr[bi]
    bi += 1
  else
    ci += 1
    carr[ci] = carr[ci-1]
  end
end

carr.pop
carr.shift
p carr.sum


Measured memory_bytes: 30744
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) (X=min(X,Y))
#define chmax(X,Y) (X=max(X,Y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
 
int n;
string s;
 
#define N 500100
int dp[N][4];
int a[N];
 
int solve(int m){
	if(m==1) return 0;
	memset(dp, -1, sizeof(int)*(m+10)*4);
	dp[0][3] = 0;
	for(int i = 1; i < m; i++){
		for(int j = 0; j < 4; j++){
			if(dp[i-1][j]<0) continue;
			dp[i][3] = max(dp[i][3], dp[i-1][j]);
			if(j==0){
				if(a[i-1]>1) dp[i][0] = max(dp[i][0], dp[i-1][j]+a[i-1]-1);
				if(a[i-1]>1) dp[i][1] = max(dp[i][1], dp[i-1][j]+a[i]-1);
				if(a[i-1]>1) dp[i][2] = max(dp[i][2], dp[i-1][j]+a[i]);
			} else if(j==1){
				dp[i][0] = max(dp[i][0], dp[i-1][j]+1);
				dp[i][1] = max(dp[i][1], dp[i-1][j]+a[i]-1);
				dp[i][2] = max(dp[i][2], dp[i-1][j]+a[i]);
			} else if(j==2){
				//dp[i][0] = max(dp[i][0], dp[i-1][j]);
				//dp[i][1] = max(dp[i][1], dp[i-1][j]);
				//dp[i][2] = max(dp[i][2], dp[i-1][j]);
			} else if(j==3){
				dp[i][0] = max(dp[i][0], dp[i-1][j]+a[i-1]);
				dp[i][1] = max(dp[i][1], dp[i-1][j]+a[i]-1);
				dp[i][2] = max(dp[i][2], dp[i-1][j]+a[i]);
			}
		}
	}
	int res = 0;
	rep(i, 4) chmax(res, dp[m-1][i]);
	return res;
}
 
int main(){
	cin>>n>>s;
	s += "222";
	ll res = 0;
	int i = 0;
	while(true){
		int p = 0;
		while(s[i]=='0') i++;
		if(s[i]=='2') break;
		while(true){
			while(s[i]=='1'){
				i++;
				a[p]++;
			}
			p++;
			if(s[i]=='0' && s[i+1]=='1'){
				i++;
				continue;
			}
			res += solve(p);
			memset(a, 0, sizeof(int)*(p+10));
			break;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
#define endl "\n"

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) (x) % 2 == 0
#define odd(x) (x) % 2 != 0
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

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

bool isDigit(char c) {
    return '0' <= c and c <= '9';
}

int main() {

    int N; cin >> N;
    vector<vector<int>> ts(N+1);
    REP(i, N+1) {
        string s; cin >> s;
        REP(j, s.size()) {
            char c = s[j];
            if (isDigit(c)) {
                int p = j;
                while (p < s.size() and isDigit(s[p])) p++;
                int num = stoi(s.substr(j, p - j));
                j = p-1;
                ts[i].push_back(INT32_MIN + num);
            } else {
                ts[i].push_back(c);
            }
        }
    }

    FOR(i, 1, N+1) {
        bool done = false, less = false;
        REP(j, min(ts[0].size(), ts[i].size())) {
            if (ts[0][j] > ts[i][j]) {
                done = true;
                less = true;
                break;
            }
            if (ts[0][j] < ts[i][j]) {
                done = true;
                less = false;
                break;
            }
        }
        if (not done) {
            if (ts[0].size() > ts[i].size()) less = true;
            else less = false;
        }
        if (less) cout << "-" << endl;
        else cout << "+" << endl;
    }

    return 0;
}


Measured memory_bytes: 3248
#n=int(input())
#s,t=input().split()
n,m = map(int, input().split())
#l=list(map(int, input().split()))
l=[0]*100005
r=[1000005]*100005
z=1000010
for i in range(m):
   l[i],r[i]=map(int,input().split()) 
mi=max(l)
ma=min(r)



if mi>ma:
    print(0)
else:
    print(ma-mi+1)

Measured memory_bytes: 16652
//author:emre yazicioglu

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c); a++)
#define ford(a,b,c) for(ll a = b;a >= ll(c); a--)

const int N = 2e6 + 7;
ll n,m,k,ans,cur,ar[N];
ll sum,a,b,c,d,q;
map <ll, ll> mp;
vector <ll> v;
string str;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	
	ar[1] = ar[n] = -1;
	cin >> n;
	fori(i,1,n + 1){
		cin >> ar[i];
		if(ar[i] <= ar[i - 1]) cur++;
		else cur = 0;
		ans = max(ans, cur);
	}
	cout << ans;
}

Measured memory_bytes: 1024
n=int(input())
h=[int(i) for i in input().split()]
dp=[0]*n

dp[0]=0
dp[1]=abs(h[1]-h[0])
if n>1:
    for i in range(2,n):
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[-1])

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

int main(){
    ll N,D;
    cin>>N>>D;
    int ans=0;
    rep(i,N){
        ll X,Y;
        cin>>X>>Y;
        if(pow(X,2)+pow(Y,2)<=pow(D,2))ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
S = input()

S = S.replace("BC", "D")

cnt_A = 0
ans = 0

"""
ABC -> BCA の処理は、BCとAwo入れ替えてAを右に送ると考えると理解しやすかった
ans = Aを何回右に送ることができるか
BCがあると、今あるAをそのBCの右に送ることができる
"""
for c in S:
    if c == "A":
        cnt_A += 1
    elif c == "D":
        ans += cnt_A
    else:
        # BBとかCBとかでAのカウントをリセット
        cnt_A = 0
        
print(ans)

Measured memory_bytes: 3500
N,K,Q = map(int,input().split())
minas = [-Q]*N
A = [int(input()) for _ in range(Q)]
for i in A:
  minas[i-1] += 1
  
for i in minas:
  if  K + i<= 0:
    print("No")
  else:
    print("Yes")



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

int main() {
  
  int s1s2s3,A,B,C;
  cin >> s1s2s3;
  A = s1s2s3/100;
  B = (s1s2s3-100*A)/10;
  C = s1s2s3-100*A-10*B;
  cout << A+B+C << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int func(int [],int,int);

int main(){
  int i,j,n,q,cnt=0;
  int a[N + 1];
  int k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&k);
    if(func(a,n,k)) cnt++;
  }

  printf("%d\n",cnt);
  return 0;
}

int func(int a[], int n, int k){
  int i = 0;
  a[n] = k;
  while(a[i] != k){
    i++;
  }
  return i != n;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

typedef long long int lli;
typedef long long ll;

const int MAX = 1000000;

long long fac[MAX],finv[MAX],inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int 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(int n, int k)
{
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}


int main()
{
    int x,y; cin >> x >> y;
    if(2*x-y < 0 || (2*x-y)%3 != 0 || 2*y - x < 0 || (2*y - x)%3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    int a = (2*x-y)/3;
    int b = (2*y-x)/3;
    COMinit();
    cout << COM(a+b,a) << endl;
    return 0;
}

Measured memory_bytes: 27040
fun main(args: Array<String>) {
    var (h, w) = readLine()!!.split(" ").map { it.toInt() }
    while(h != 0 || w != 0) {
        if (h != 0 && w != 0) {
            val wide = "#".times(w)
            for (i in 0 until h) {
                println(wide)
            }
        }
        println("")
        val (h2, w2) = readLine()!!.split(" ").map { it.toInt() }
        h = h2
        w = w2
    }
}

private operator fun String.times(num: Int): String {
    var s = ""
    for (i in 0 until num) s += this
    return s
}






Measured memory_bytes: 32208
fun main(args: Array<String>)
{
    val (a, b) = readNInts()

    val sum = a + b
    val sub = a - b
    val prd = a * b

    val ans: Int

    if (sum >= sub && sum >= prd)
    {
        ans = sum
    }
    else if (sub >= sum && sub >= prd)
    {
        ans = sub
    }
    else
    {
        ans = prd
    }

    println(ans)


}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!


Measured memory_bytes: 37868
N, x = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
for i in range(1,N):
	tmp = max(0, A[i]+A[i-1]-x)
	cnt += tmp
	if A[i] >= tmp:
		A[i] -= tmp
	else:
		tmp -= A[i]
		A[i] = 0
		A[i-1] -= tmp

print(cnt)

Measured memory_bytes: 14052
#include <cstdio>
#include <cmath>
#include <algorithm>
#define MAX_NUM 100000

using namespace std;

int main(void){
	int n, i, j;
	bool f[MAX_NUM + 1];
	fill(f,f + MAX_NUM + 1,true);
	for(i = 2;i <= sqrt((double)MAX_NUM);i++){
		for(j = i * 2;j <= MAX_NUM;j+=i){
			f[j] = false;
		}
	}
	while(scanf("%d",&n) != EOF){
		for(i = n - 1;!f[i];i--);
		printf("%d ",i);
		for(i = n + 1;!f[i];i++);
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1120
t = raw_input()
count = int(input())
g,e,r = 0,0,1
for i in range(count):
  r,e =1,0
  y = raw_input()
  y *=2
  for j in range(len(y)):
    if t == y[e:e+len(t)]:
      g+=1
      break
    e+=1
print g

Measured memory_bytes: 4228
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N;
vector<ll> vec;

void solve() {
	cin >> N;
	vec.resize(N);
	rep(i, N) cin >> vec[i];

	vector<ll> output(N,0);
	ll ans = 0;

	for (ll i = N; i > 0; i--) {

		if (i * 2 > N) {

			if (vec[i - 1] == 1) {
				output[i - 1] = 1;
				ans++;
			}

		}
		else {
			ll sum = 0;
			for (ll j = 2*i; j <= N; j+=i) {
				if (output[j-1] == 1) sum++;
			}

			if (vec[i - 1] != sum % 2) {
				output[i - 1] = 1;
				ans++;
			}

		}

	}

	cout << ans << endl;
	rep(i, N) {
		if (output[i]==1) cout << i+1 << endl;
	}

}

int main() {
	solve();
	cout << endl;
	return 0;
}


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

int main() {
    int Q;
    cin >> Q;
    
    vector<int> veq;
    
    for (int q = 0; q < Q; q++) {
        int c;
        cin >> c;
        if (c == 0) {
            int a;
            cin >> a;
            veq.push_back(a);
        } else if (c == 1) {
            int a;
            cin >> a;
            cout << veq[a] << endl;
        } else {
            veq.pop_back();
        }
    }
}


Measured memory_bytes: 3896
#include<stdio.h>

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

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

    if((a+b)%2 == 0) {
        x = (a+b)/2;
    } else {
        x = (a+b)/2 + 1;
    }

    printf("%d", x);

    return 0;
}


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

int main()
{
	int N, mi = 0, ma = 0;
	vector<int> used(8, 0);
	vector<int> rate = { 1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200 };
	cin >> N;
	for (int i = 0, a; i < N; i++) {
		cin >> a;
		int id = upper_bound(rate.begin(), rate.end(), a) - rate.begin() - 1;
		if (id < 8 && used[id] == 0) {
			used[id] = 1;
			ma++;
			mi++;
		}
		else if (id == 8) {
			ma++;
		}
	}
	cout << max(mi, 1) << ' ' << ma << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < A.length; i++) {
                A[i] = in.nextInt();
            }

            int max = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    max = Math.max(max, Math.abs(A[i] - A[j]));
                }
            }
            System.out.println(max);
        }
    }
}


Measured memory_bytes: 21204
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int n, m;
long long int rikuro[201][201], kairo[201][201];

int solve(vector<int> z, int r)
{
	vector<vector<long long int> > result(1001, vector<long long int>(201, mod));
	result[0][z[0]] = 0;
	for(int i = 0; i < n; i++){
		result[0][i] = min(result[0][i], kairo[z[0]][i] + rikuro[i][z[0]]);
	}
	for(int i = 0; i < r - 1; i++){
		for(int j = 0; j < n; j++){
			result[i + 1][j] = min(result[i + 1][j], result[i][j] + rikuro[z[i]][z[i + 1]]);
			for(int k = 0; k < n; k++){
				result[i + 1][k] = min(result[i + 1][k], result[i][j] + rikuro[z[i]][j] + kairo[j][k] + rikuro[k][z[i + 1]]);
			}
		}
	}
	long long int ans = mod;
	for(int i = 0; i < n; i++){
		ans = min(ans, result[r - 1][i]);
	}
	return ans;
}

int main()
{
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				rikuro[i][j] = mod;
				kairo[i][j] = mod;
			}
			rikuro[i][i] = 0;
			kairo[i][i] = 0;
		}
		for(int i = 0; i < m; i++){
			int x, y;
			long long int t;
			char sl;
			cin >> x >> y >> t >> sl;
			x--;
			y--;
			if(sl == 'S'){
				kairo[x][y] = min(kairo[x][y], t);
				kairo[y][x] = min(kairo[y][x], t);
			} else {
				rikuro[x][y] = min(rikuro[x][y], t);
				rikuro[y][x] = min(rikuro[y][x], t);
			}
		}
		for(int k = 0; k < n; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					kairo[i][j] = min(kairo[i][j], kairo[i][k] + kairo[k][j]);
					rikuro[i][j] = min(rikuro[i][j], rikuro[i][k] + rikuro[k][j]);
				}
			}
		}
		int r;
		cin >> r;
		vector<int> z;
		for(int i = 0; i < r; i++){
			int tmpz;
			cin >> tmpz;
			tmpz--;
			z.push_back(tmpz);
		}
		cout << solve(z, r) << endl;
	}
	return 0;
}

Measured memory_bytes: 4996
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

ll ceilDiv(ll a, ll b) {
    return (a + b - 1LL) / b;
}

int main() {
    int k; cin >> k;
    vector<ll> a(k);
    for (int i = 0; i < k; ++i) {
        cin >> a[i];
    }
    ll l = 2, r = 2;
    for (int i = k - 1; i >= 0; --i) {
        ll x = ceilDiv(l, a[i]) * a[i];
        ll y = (r / a[i]) * a[i];

        if (x > y) {
            cout << -1 << endl;
            return 0;
        }

        l = x;
        r = y + a[i] - 1LL;
    }

    cout << l << " " << r << endl;
    return 0;
}

Measured memory_bytes: 1024
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

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

	ll t = max(0LL, a-c);
	c = max(0LL,c - a);
	//cout<<c<<endl;
	ll aa = max(0LL, b-c);

	cout<<t<<" "<<aa<<endl;

	

	return 0;
}

Measured memory_bytes: 3620
#include<vector>
#include<cmath>
#include<algorithm>

const double INF = 1e9;
const double EPS = 1e-9;

struct Point {
    Point() :x(INF), y(INF) {}
    Point(double x, double y) :x(x), y(y) {}
    bool operator==(const Point& p) const {return x == p.x && y == p.y;}
    double x, y;
};
struct Compare {
    bool f;
    Compare(bool f = false) :f(f) {}
    bool operator()(const Point& lhs, const Point& rhs) const {return f ? lhs.y < rhs.y : lhs.x < rhs.x;}
};
double distance(const Point& lhs, const Point& rhs) {return std::hypot(lhs.x - rhs.x, lhs.y - rhs.y);}

struct Result {
    double d;
    Point p1, p2;
    Result() :d(INF) {}
    Result(double d, const Point p1, const Point p2) :d(d), p1(p1), p2(p2) {}
};
bool operator<(const Result& lhs, const Result& rhs) {return lhs.d < rhs.d;}

Result closest_pair_recursion(const std::vector<Point>::const_iterator& begin, const std::vector<Point>::const_iterator& end) {
    int size = end - begin;
    if(size <= 1) return Result();

    auto mid = begin + size / 2;
    Result r = std::min(closest_pair_recursion(begin, mid), closest_pair_recursion(mid, end));

    auto left = std::lower_bound(begin, end, Point(mid->x - r.d - EPS, mid->y), Compare());
    auto right = std::upper_bound(left, end, Point(mid->x + r.d + EPS, mid->y), Compare());
    std::vector<Point> y_sorted(left, right);
    std::sort(y_sorted.begin(), y_sorted.end(), Compare(true));

    for(auto i = y_sorted.begin(); i != y_sorted.end(); ++i) {
        auto top = std::upper_bound(i + 1, y_sorted.end(), Point(i->x, i->y + r.d + EPS), Compare(true));
        for(auto j = i + 1; j != top; ++j) {
            if(distance(*i, *j) >= r.d) continue;
            r = Result(distance(*i, *j), *i, *j);
        }
    }
    return r;
}
Result closest_pair(std::vector<Point> point) {
    std::sort(point.begin(), point.end(), Compare());
    return closest_pair_recursion(point.begin(), point.end());
}

////////////////////////////////////////////////////////////////////////////////
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
    int n;
    vector<Point> v;
    for(cin >> n; n > 0; --n) {
        double x, y;
        cin >> x >> y;
        v.push_back(Point(x, y));
    }
    auto res = closest_pair(v);
    cout <<setprecision(12) << fixed << res.d << endl;
}

Measured memory_bytes: 5768
#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 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N, M;
    cin >> N >> M;
    vector<bool> ac(N, false), acc(N, false);
    vector<pair<int, string>> v;
    int pn = 0, cor = 0;
    rep(i, M) {
        int a;
        cin >> a;
        string s;
        cin >> s;
        v.push_back({a, s});
        if (s == "AC")
            ac[a] = true;
    }

    rep(i, M) {
        int a = v[i].first;
        string s = v[i].second;
        if (!ac[a])
            continue;
        if (!acc[a] && s == "WA")
            pn++;
        else if (!acc[a] && s == "AC")
            acc[a] = true, cor++;
    }

    cout << cor << " " << pn << endl;
}

Measured memory_bytes: 8484
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a=1;
	cin>>n;
	while(1)
	{
		a*=2;
		if(a>n)
		{
			cout<<a/2<<endl;
			break;
		}
		else if(a==n)
		{
			cout<<a<<endl;
			break;
		}
	}
	return 0;
}

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

int main() {
 int N,M;
  cin >> N >> M;
  vector<int> data(M*2);
  for(int i=0;i<M*2;i++){
  cin >> data.at(i);
  }
  int count;
  for(int i=0;i<N;i++){
  count = 0;
  for(int j=0;j<M*2;j++){
  if(data.at(j) == i+1){
  count++;
  }
  if(j == M*2-1){
  cout << count << endl;
  }
  }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<pair<int,P>> v(n);
  rep(i,n){
    int x,y,h;
    cin >> x >> y >> h;
    v[i] = make_pair(h,P(x,y));
  }
  sort(v.begin(),v.end());
  auto f = [&](int i,int cx,int cy){
    int x = v[i].second.first, y = v[i].second.second, h = v[i].first;
    return h+abs(x-cx)+abs(y-cy);
  };
  rep(cx,101)rep(cy,101){
    bool ok = true;
    int ch = f(n-1,cx,cy);
    rep(i,n-1){
      int h = f(i,cx,cy);
      if(ch==h) continue;
      else if(h>ch && v[i].first==0) continue;
      ok = false;
      break;
    }
    if(ok){
      printf("%d %d %d\n",cx,cy,ch);
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
	int H, W;
	std::vector<int> h, w;
	
	int cnt = 0;
	while(1)
	{
		std::cin >> H >> W;
		
		if( H == 0 && W == 0 ) break;
		
		else 
		{
			h.push_back(H);
			w.push_back(W);
		}
		
		cnt++;
	}
		
	for(int i = 0; i < cnt; i++)
	{
		for(int j = 0; j < h[i]; j++)
		{
			for(int k = 0; k < w[i]; k++)
			{
				if( j == 0 || j == h[i] - 1 || k == 0 || k == w[i] - 1 )
					std::cout << "#";
				
				else 
					std::cout << ".";
			}
			
			std::cout << std::endl;
		}
		
		std::cout << std::endl;
	}

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
    }
    int cnt=0;
    cnt+=*min_element(B.begin(), B.end());
    cnt+=*max_element(A.begin(), A.end());
    cout << cnt;
}

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

int main(){

	int a, b;
	cin >> a >> b;

	if(a < b){
		cout << "a < b" << endl;
	}else if(a > b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}

return 0;
}

Measured memory_bytes: 1156
S, T = input(), input()

def f():
  dicS, dicT = {}, {}
  for i in range(len(S)):
    if dicS.get(S[i], '') == '':
      dicS[S[i]] = T[i]
    else:
      if dicS[S[i]] != T[i]:
        return 'No'
    if dicT.get(T[i], '') == '':
      dicT[T[i]] = S[i]
    else:
      if dicT[T[i]] != S[i]:
        return 'No'
  return 'Yes'
print(f())

Measured memory_bytes: 3632
#pragma GCC optimize(2)
#include <iostream>
#include <cstdio>
using namespace std;
#define LL long long

LL a,b,c;

int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a%2==0||b%2==0||c%2==0) printf("0\n");
	else printf("%lld\n",min(min(a*b,a*c),b*c));
	return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;

  REP(i, S.length()) { cout << "x"; }
  cout << endl;

  return 0;
}


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

//nまでの総和を返す自作関数
long long sum(long long n){
    return (n*(n+1))/2;
}

int main(){
    long long n;
    cin>>n;
    long long ans;
    ans=sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define PI acos(-1)
int main(){
int a,b;
while(cin>>a>>b,a||b){
rep(i,a){
rep(j,b)cout<<"#";
cout<<endl;
}
cout<<endl;
}
}

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

int main(){
    char output1, output2;
    int count[26]={0};
    string line;
    while(1){
        getline(cin, line);
        if(line==""){
            break;
        }
        rep(i, line.size()){
            rep(j, 26){
                output1='a'+j;
                output2='A'+j;
                if(line.at(i)==output1||line.at(i)==output2){
                    count[j]++;
                }
            }
        }
    }
    
    rep(i, 26){
        output1='a'+i;
        cout<<output1<<" : "<<count[i]<<endl;
    }
}


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

const int maxn=100005;
int used[maxn];

int main(){
    int n,m;
    cin>>n>>m;
    vector<pii> d;
    rep(i,n){
        int a,b;cin>>a>>b;
        d.emplace_back(make_pair(a,b));
    }
    sort(d.begin(),d.end());
    int ans=0;
    priority_queue<int> que;
    
    int pos=0;
    for(int i=0;i<=m;i++){
        while(pos<n&&d[pos].first<=i){
            que.push(d[pos].second);
            pos++;
        }

        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}

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



long long C(long long A,long long B){
  long long ans=1;
  for(int i=0;i<B;i++){
    ans=ans*(A-i)/(i+1);
  }
  return ans;
}


int main() {
 long long N,a,b,c,ans=0;
  long double sum=0;
  cin>>N>>a>>b;
  vector<long long> V(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  for(int i=0;i<a;i++){
    sum+=V.at(i);
  }
  cout<<fixed<<setprecision(10)<<sum/a<<endl;
  if(V.at(0)==V.at(a-1)){
    c=count(V.begin(),V.end(),V.at(0));
    b=min(b,c);
    for(long long i=a;i<=b;i++){
      ans+=C(c,i);
    }
  
  }
  else{
    c=count(V.begin(),V.end(),V.at(a-1));
    b=count(V.begin(),V.begin()+a,V.at(a-1));
    ans=C(c,b);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N = input()

dp = [[[0] * 8 for _ in range(2)] for _ in range(len(N) + 1)]

dp[0][0][0] = 1

for i in range(len(N)):
    for j in range(2):
        D = 9 if j else int(N[i])
        for d in [x for x in [3, 5, 7] if x <= D]:
            if d == 3:
                dp[i + 1][j | (d < D)][1] += dp[i][j][0] + dp[i][j][1]
                dp[i + 1][j | (d < D)][3] += dp[i][j][2] + dp[i][j][3]
                dp[i + 1][j | (d < D)][5] += dp[i][j][4] + dp[i][j][5]
                dp[i + 1][j | (d < D)][7] += dp[i][j][6] + dp[i][j][7]
            elif d == 5:
                dp[i + 1][j | (d < D)][2] += dp[i][j][0] + dp[i][j][2]
                dp[i + 1][j | (d < D)][3] += dp[i][j][1] + dp[i][j][3]
                dp[i + 1][j | (d < D)][6] += dp[i][j][4] + dp[i][j][6]
                dp[i + 1][j | (d < D)][7] += dp[i][j][5] + dp[i][j][7]
            elif d == 7:
                dp[i + 1][j | (d < D)][4] += dp[i][j][0] + dp[i][j][4]
                dp[i + 1][j | (d < D)][5] += dp[i][j][1] + dp[i][j][5]
                dp[i + 1][j | (d < D)][6] += dp[i][j][2] + dp[i][j][6]
                dp[i + 1][j | (d < D)][7] += dp[i][j][3] + dp[i][j][7]
            else:
                raise Exception("Not 3 or 5 or 7")


ans = dp[len(N)][1][7] + dp[len(N)][0][7]

sub = 0
for i in range(3, len(N)):
    sub753 = 3 ** i
    sub75 = 2 ** i
    sub += sub753 - (3 * sub75 - 3)

print(ans + sub)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define N 100005
ll a[21];
using namespace std;
int main(){
    ll n,i,x,s=0;
    cin>>n;
    for(i=1; i<=n; ++i)
        cin>>a[i];
    for(i=1; i<=n; ++i){
        cin>>x;
        if(x<a[i])
            s+=a[i]-x;
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    int a,b,c,d,e,x,y,z,h,j,k;
    cin >>a>>b>>c>>d>>e;
    
    x = abs(a);
    y = x * c;
    h = b - a;
    j = h * e;
    z = b * e;
    
    if(a < 0){
        k = y + d + z;
        cout <<k<<endl;
    }else if(a > 0){
        cout <<j<<endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }



ll mod_pow(ll x,ll n, ll mod){
    if(n==0) return 1;
    ll res=mod_pow(x * x % mod, n/2, mod);
    if(n & 1) res=res * x % mod;
    return res;
}

ll extgcd(ll a, ll b, ll& x, ll& y){
    ll d=a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }
    else{
        x=1;y=0;
    }
    return d;
}

ll mod_inverse(ll a,ll mod){
    ll x,y;
    extgcd(a,mod,x,y);
    return (mod+x%mod)%mod;
}


void solve(){
    ll n;
    ll a[10];
    cin>>n>>a[0]>>a[1];
    ll ans=mod_pow(2,n,MOD);
    ans--;
    rep(i,2){
        ll sum=1,sum1=1;
        rep(j,a[i]){
            sum*=(n-j);
            sum%=MOD;
        }
        rep2(j,1,a[i]+1){
            sum1*=j;
            sum1%=MOD;
        }
        ll s=sum*mod_inverse(sum1,MOD)%MOD;
        ans+=MOD;
        ans-=s;
        ans%=MOD;

    }
      
    
    cout<<ans<<endl;
    
}


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

    solve(); 


    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

vector<pair<ll,ll>> prime_factorize(ll n) {
    vector<pair<ll,ll> > res;
    for (ll p = 2;p*p <= n;++p) {
        if (n%p!=0) continue;
        int num = 0;
        while(n%p ==0) {
            ++num;
            n/=p;
        }
        res.push_back(make_pair(p,num));
    }
    if (n!=1) res.push_back(make_pair(n,1));
    return res;
}

int main(void){
    // Your code here!
    ll n; cin >> n;
    auto pf = prime_factorize(n);
    ll res = 0;
    for (auto p:pf) {
        ll t = p.second;
        ll tmp = 0,cur = 1;
        while(t>=cur) t -= cur++,++tmp;

        res += tmp;
    }
    cout << res << endl;
}


Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(250000)

def main():
    n = int(input())

    if n == 0:
        print(1)
    elif n == 1:
        print(0)
    # n, w = map(int, input().split())
    #
    # pairs=[]
    # for i in range(n):
    #     pairs.append(list(map(int, input().split())))
    #
    # dp =  [[0] * 10001 for i in range(101)]
    # for j in range(0, 10001):
    #     for i in range(0,n):
    #         if j >= pairs[i][1]:
    #             dp[i+1][j] = max(dp[i][j-pairs[i][1]] + pairs[i][0], dp[i][j])
    #         else:
    #             dp[i+1][j] = dp[i][j]
    #
    # print(dp[n][w])
main()


Measured memory_bytes: 61692
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	string s;
	cin >> s;
	bool ok = true;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s.size(); j++) {
			if (i != j && s.at(i) == s.at(j)) {
				ok = false;
			}
		}
	}
	if (ok) cout << "yes\n";
	else cout << "no\n";
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

struct XYZ{
	int x, y, z;
};

struct UnionFind{
	vector<int> par;
	vector<int> rank;
	UnionFind(int n) : par(n), rank(n){
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
		} else {
			par[y] = x;
			if(rank[x] == rank[y]) rank[x] ++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}	
};

int main(){
	int n, m; cin >> n >> m;
	vector<bool> num(n, false);
	vector<XYZ> h(m);
	UnionFind uf(2*n);
	rep(i, m){
		int x, y, z; cin >> x >> y >> z;
		-- x; -- y;
		uf.unite(x,y);
		// if(z%2){
		// 	uf.unite(x+n, y+n);
		// 	uf.unite(x, y);	
		// }else{
		// 	uf.unite(x+n, y);
		// 	uf.unite(x, y+n);
		// }
		
	}
	map<int,int> mp;
	rep(i, n){
		mp[uf.find(i)] += 1;
	}
	int cnt = 0;
	for (auto x : mp){
		cnt ++;
	} 
	cout << cnt << endl;
}

Measured memory_bytes: 7680
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = ns()
f = [0] * 26
for c in s:
    f[ord(c)-ord('A')] += 1
f.sort()
if f[-1] == 2 and f[-2] == 2:
    print("Yes")
else:
    print("No")


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int M[n][n];
    // 隣接行列の初期化
    rep(i,n) rep(j,n) M[i][j] = 0;
    // 隣接リストを読み込む
    rep(i,n){
        int u; cin >> u; u--;   // 二次元配列のインデックスに合うように頂点番号をデクリメント
        int k; cin >> k;
        rep(_,k){
            int vi; cin >> vi; vi--;
            M[u][vi] = 1;
        }
    }
    rep(i,n){
        rep(j,n){
            cout << M[i][j];
            if(j != n-1) cout << " ";
        }
        cout << endl;
    }
}


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

using namespace std;

typedef long long ll;

int main() {
    vector<ll> V = {1, 2, 3, 4, 5, 6, 7, 8, 9};

    int idx = 0;
    while (V.size() < 100000) {
        int n = (int)V.size(), cnt = 0;
        for (int i = idx; i < n; i++) {
            ll w = V[i]; ll d = w % 10;
            if (d > 0) {
                V.push_back(w * 10 + d - 1);
                cnt++;
            }
            if (d < 9) {
                V.push_back(w * 10 + d + 1);
                cnt++;
            }
            V.push_back(w * 10 + d);
            cnt++;
        }
        idx = n;
    }
    sort(V.begin(), V.end());

    int K;
    scanf("%d", &K);
    printf("%lld\n", V[K - 1]);

    return 0;
}

Measured memory_bytes: 3700
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 2100
#define ll long long
using namespace std;

int read_p,read_ca;
inline int read(){
	read_p=0;read_ca=getchar();
	while(read_ca<'0'||read_ca>'9') read_ca=getchar();
	while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
	return read_p;
}
long long l,r,mmh;
inline ll max(ll a,ll b){return a>b?a:b;}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll work(ll l,ll r,ll up){
	if (l>r) swap(l,r);
	int i;
	if (l==r) return 0;
	for (i=60;;i--) if (((r>>i)&1)&&(!((l>>i)&1))) break;
	r&=(1ll<<(i+1))-1;l&=(1ll<<(i+1))-1;r^=1ll<<i;up^=1ll<<i;
	if (r+1>=l) return min(1ll<<i,up)-r-1;
	ll mmh=work(1,r,l);
	mmh+=min((1ll<<i),up)-l;
	return mmh;
}
int main(){
	int i,j;
	scanf("%lld%lld",&l,&r);
	if (l==r) return puts("1"),0;
	printf("%lld\n",work(l,r,1ll<<62)+r-l+1);
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a, val) memset(a, val, sizeof (a))
#define PB push_back
#define endl '\n'
typedef long long ll;

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}

template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
	return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;

template<typename T> using min_pq =
	std::priority_queue<T, vector<T>, greater<T> >;

//int dx[] = {-1, +0, +1, +0};
//int dy[] = {+0, +1, +0, -1};

const int maxn = 200005;

int n, m;
int a[maxn];
int cnt[maxn], cnt2[maxn];
int w = 0;

void add2(int x) {
	if(x <= 0) return;
	cnt2[x]++;
	if(cnt2[x] == 1) w--;
}
void rem2(int x) {
	if(x <= 0) return;
	cnt2[x]--;
	if(cnt2[x] == 0) w++;
}

void add(int x) {
	if(cnt[x] != 0) {
		// rem2(x - cnt[x] + 1);
	}
	cnt[x]++;
	add2(x - cnt[x] + 1);
}
void rem(int x) {
	rem2(x - cnt[x] + 1);
	cnt[x]--;
	if(cnt[x] != 0) {
		// add2(x - cnt[x] + 1);
	}
}

int32_t main () {
	// freopen("in", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
    	cin >> a[i];
    	cnt[a[i]]++;
    }
    for(int i = 1; i <= n; i++) {
    	if(cnt[i]) {
    		for(int j = max(1, i - cnt[i] + 1); j <= i; j++) {
    			cnt2[j]++;
    		}
    	}
    }
    // for(int i = 1; i <= n; i++) cout << i << ' '; cout << endl;
   	// for(int i = 1; i <= n; i++) cout << cnt[i] << ' '; cout << endl;
   	// for(int i = 1; i <= n; i++) cout << cnt2[i] << ' '; cout << endl;
    for(int i = 1; i <= n; i++) {
    	if(cnt2[i] == 0) w++;
    }
    // cout << w << endl;
    while(m--) {
    	int x, y;
    	cin >> x >> y;
    	rem(a[x]);
    	a[x] = y;
    	add(a[x]);
    	// cout << endl << "HERE GOES HOES: " << endl;
    	// for(int i = 1; i <= n; i++) cout << i << ' '; cout << endl;
	   	// for(int i = 1; i <= n; i++) cout << cnt[i] << ' '; cout << endl;
	   	// for(int i = 1; i <= n; i++) cout << cnt2[i] << ' '; cout << endl;
    	cout << w << endl;
    	// cout << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int K;
  cin >> K;
  vector <int>  x(N);
  for(int i = 0; i < N; i++){
    cin >> x.at(i);
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    int tmp = min(x.at(i) , K - x.at(i));
    ans += tmp;
  }
  cout << ans * 2 << endl;
  return 0;
}


Measured memory_bytes: 256