akhauriyash/Code-Regression huggingface dataset:
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

// Utility for binomial coefficient
ll ncr(ll n,ll k)
{
    if(n<k)
        return 0;
    ll C[n + 1][k + 1];
    ll i,j;
    for(i=0;i<=n;i++){
        for(j=0;j<=min(i,k);j++){
            if (j==0 || j==i)
                C[i][j]=1;
            else
                C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    return C[n][k];
}

void solve(){
	//code
	int n,k;
	cin>>n>>k;
	int x=(n+1)/2;
	if(k<=x)
		cout<<"YES";
	else cout<<"NO";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

inline char flip(char c) {
  if (c >= 'a' && c <= 'z') {
    return c - 0x20;
  } else if (c >= 'A' && c <= 'Z') {
    return c + 0x20;
  }
  return c;
}

int main() {
  string s;
  getline(cin, s);
  for (size_t i = 0; i < s.size(); ++i) {
    printf("%c", flip(s[i]));
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 1164
K=int(input())
ans=-1
num=0
for i in range(K):
    # num += 7*(10**i)
    # if num % K == 0:
    #ってすると計算量がやばいので
    num = (10*num+7) % K
    if num == 0:
        ans = i+1
        break
print(ans)

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

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans=0;
  for(int r=0;R*r<=N;r++){
    for(int g=0;R*r+G*g<=N;g++){
      if((N-R*r-G*g)%B==0)ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

const int mod = 1000000007;
string s;
int dp[2][3][300004];

void sub(const string& s) {
  dp[1][0][0] = 1;
  for (int i = 1; i < s.size(); ++i) {
    for (int c : {0, 1}) {
      if (c == 1 && s[i] == '0'
       || c == 0 && s[i] == '1') continue;
      for (int pc : {0, 1}) {
        for (int k : {0, 1, 2}) {
          int nk =
            k == 2 ? 2
          : k == 1 ? (i % 2 == 0 && c == 1 && pc == 1 ? 2 : 1)
          :          (i % 2 == 1 && c == 1 && pc == 1 ? 1 : 0);
          dp[c][nk][i] += dp[pc][k][i - 1];
          if (dp[c][nk][i] >= mod) dp[c][nk][i] -= mod;
        }
      }
    }
  }
}

int main() {
  cin >> s;
  s = '1' + s + '1';
  sub(s);
  const int n = s.size();
  cout << dp[1][2][n - 1] << endl;
}


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

// #include <atcoder/all>

using namespace std;
// using namespace atcoder;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    
    int n, k;
    cin >> n >> k;
    vector<pii> lr(k);
    rep (i, k) cin >> lr[i].first >> lr[i].second;

    vl dp(2 * n + 10);
    dp[0] = 1;
    dp[1] = -1;
    rep (i, n) {
        rep (j, lr.size()) {
            int l = lr[j].first, r = lr[j].second;
            (dp[i + l] += dp[i]) %= MOD;
            (dp[i + r + 1] -= dp[i]) %= MOD;
            // seg.update(i + l, i + r + 1, now, 0, 0, seg.n);
        }
        (dp[i + 1] += dp[i]) %= MOD;
    }
    // DEBUG_VEC(dp);
    cout << (dp[n - 1] + MOD) % MOD << endl;
}


Measured memory_bytes: 6292
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
typedef long long ll;
using namespace std;
int n,a;
ll dp[52][52][2555];
int num[55];
int main(){
    scanf("%d%d",&n,&a);
    for(int i=1;i<=n;i++) scanf("%d",&num[i]);
    dp[1][1][num[1]]=1;
    dp[1][0][0]=1;
    for(int i=2;i<=n;i++){
        dp[i][1][num[i]]++;
        for(int j=1;j<=i;j++){
            for(int k=1;k<=(i*50);k++){
                dp[i][j][k]+=dp[i-1][j][k];
                dp[i][j][num[i]+k]+=dp[i-1][j-1][k];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dp[n][i][i*a];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 51456
#include <iostream>

using namespace std;

int a[201];

int checkEven(int a[], int n) {
  int res = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 != 0) {
      res = 0;
      break;
    }
  }
  return res;
}

int main()
{
  int n;
  int ans = 0;

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

  int m = 1;
  while (m) {
    // 全ての要素が偶数のとき
    if (checkEven(a, n) == 1) {
      ans++;
      for (int i = 0; i < n; i++) {
        a[i] = a[i] / 2;
      }
    } else {
      m = 0;
    }
  }

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


Measured memory_bytes: 256
#奇数文字目がすべて R, U, D のいずれか。
#偶数文字目がすべて L, U, D のいずれか。

#文字列の入力
S = input()
S_list = []
S_list = list(S)
counter = 0

for i in range(len(S_list)):
  #奇数
  if(i%2 == 0):
    if((S_list[i] == "R")or(S_list[i] == "U")or(S_list[i] == "D")):
      counter = counter + 1
  else:
    if((S_list[i] == "L")or(S_list[i] == "U")or(S_list[i] == "D")):
      counter = counter + 1
      
if(counter == len(S_list)):
  print("Yes")
else:
  print("No")

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

using namespace std;

enum Mark
{
  S = 0,
  H = 1,
  C = 2,
  D = 3,
};

const auto marks = array<string, 4>{"S", "H", "C", "D"};
std::size_t findIndexOfMark(string s)
{
  auto foundItr = find(marks.begin(), marks.end(), s);
  return std::distance(marks.begin(), foundItr);
}

int main()
{
  std::map<Mark, array<bool, 13>> memo;
  for (auto m : {S, H, C, D})
  {
    memo[m] = array<bool, 13>{false, false, false, false, false, false, false, false, false, false, false, false, false};
  }

  int i;
  cin >> i;

  for (auto j = 0; j < i; j++)
  {
    string s;
    int num;
    cin >> s >> num;

    const size_t index = findIndexOfMark(s);
    memo[static_cast<Mark>(index)][num - 1] = true;
  }

  for (auto m : marks)
  {
    const size_t index = findIndexOfMark(m);
    auto nums = memo[static_cast<Mark>(index)];

    for (auto k = 0; k < 13; k++)
    {
      if (nums[k] == false)
      {
        cout << m << " " << k + 1 << endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3128
/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
#define FOR(i, st, en, ch) for(register int i = (st); i <= (en) ; i += (ch))
#define RFOR(i, st, en, ch) for(register int i = (st); i >= (en) ; i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
/*********************************************************************/
void test(int r)
{
    int n;
    cin>>n;
    double d,d1,x,y;
    cin>>d;
    int cn=0;
    while(n--)
    {
        cin>>x>>y;
        d1=sqrt(x*x+y*y);
        if(d1<=d)
            cn++;
    }
    cout<<cn<<endl;

}
/***********************************************************************/
int main()
{
    fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

Measured memory_bytes: 3796
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<queue>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int h, w;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

bool isInside(int y, int x){
    if(y < 0 || y >= h) return false;
    if(x < 0 || x >= w) return false;
    return true;
}

int calc(int sh, int sw, vector<string> s){
    if(s[sh][sw] == '#'){
        return 0;
    }
    vector<vector<int>> d(h, vector<int>(w, INF));
    d[sh][sw] = 0;
    queue<pair<int, int>> q;
    q.push({sh, sw});
    int res = 0;
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(!isInside(ny, nx)){
                continue;
            }
            if(s[ny][nx] == '#'){
                continue;
            }
            if(d[ny][nx] > d[p.first][p.second] + 1){
                d[ny][nx] = d[p.first][p.second] + 1;
                res = max(res, d[ny][nx]);
                q.push({ny, nx});
            }
        }
    }
    return res;
}

int main(){
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = max(ans, calc(i, j, s));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    a = LI()
    d = defaultdict(lambda : 0)
    for i in a:
        d[i] += 1
    d = list(d.values())
    d.sort()
    res = len(d)-k
    print(sum(d[:res]))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 94160
# F - I hate Matrix Construction

n = int(input())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
u = list(map(int, input().split()))
v = list(map(int, input().split()))
assert len(s) == len(t) == n
assert len(u) == len(v) == n

nbits = 64
AND = 0
OR  = 1

# 初期配列
A = [[u[i]] * n for i in range(n)]
for i in range(n):
    for j in range(n):
        if t[j] == AND:
            A[i][j] |= v[j]  # v[j]で1のビットは1
        else:
            A[i][j] &= v[j]  # v[j]で0のビットは0
        # conflict check
        if (s[i] == AND and t[j] == OR  and  u[i] & ~v[j]) or \
           (s[i] == OR  and t[j] == AND and ~u[i] &  v[j]):
            print(-1)
            exit()

def must_set(s, u, ucount, i, k):
    return s[i] == OR  and u[i] & (1 << k) and ucount[i] == 0
def must_clear(s, u, ucount, i, k):
    return s[i] == AND and u[i] & (1 << k) == 0 and ucount[i] == n

def set_pos(t, v, vcount, k):
    "第kビットを1にしてもよい列"
    for j in range(n):
        if t[j] == AND and v[j] & (1 << k) == 0 and vcount[j] < n - 1:
            return j
    raise Exception
def clear_pos(t, v, vcount, k):
    "第kビットを0にしてもよい列"
    for j in range(n):
        if t[j] == OR  and v[j] & (1 << k) and vcount[j] > 1:
            return j
    raise Exception

def check_spec(s, t, u, v, ucount, vcount, i, k, trans):
    if must_set(s, u, ucount, i, k):
        j = set_pos(t, v, vcount, k)
        ucount[i] += 1
        vcount[j] += 1
        if trans: i, j = j, i
        A[i][j] |= 1 << k
    elif must_clear(s, u, ucount, i, k):
        j = clear_pos(t, v, vcount, k)
        ucount[i] -= 1
        vcount[j] -= 1
        if trans: i, j = j, i
        A[i][j] &= ~(1 << k)

# ビットごとの処理
for k in range(nbits):
    # 1の個数
    ucount = [0] * n
    vcount = [0] * n
    for i in range(n):
        for j in range(n):
            if A[i][j] & (1 << k):
                ucount[i] += 1
                vcount[j] += 1

    # 仕様通りでない箇所を修正
    try:
        for i in range(n):
            check_spec(s, t, u, v, ucount, vcount, i, k, False)
        for j in range(n):
            check_spec(t, s, v, u, vcount, ucount, j, k, True)
    except:
        print(-1)
        exit()

for i in range(n):
    print(' '.join(map(str, A[i])))


Measured memory_bytes: 111580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string S;
	cin >> S;

	cout << "2018" << S.substr(4) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N;
    double sum; 
    cin >> N;
    vector<pair<double, double>> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i).first >> A.at(i).second;
    } 
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            double a = A.at(i).first - A.at(j).first, b = A.at(i).second - A.at(j).second;
            sum += sqrt(a * a + b * b);
        }
    }
    cout << setprecision(16) << sum * 2 / N << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,m=0,msum=0,p,t;
	scanf("%d",&n);
	int x[n];
	for(int i=0;i<n;i++){
		scanf("%d",&x[i] );
	}
	for(int i=0;i<100;i++){
		t=0;

		for(int k=0;k<n;k++){
			t+=(i-x[k])*(i-x[k]);
		}
		if(i==0 ||t<msum){
			msum=t;
			p=i;
		}
	}
	printf("%d\n",msum );
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <queue>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
constexpr int inf = 1e9+7;
constexpr int root = 0;
int main() {
    while (true) {
        // input
        int n, m; scanf("%d%d", &n, &m);
        if (n == 0 and m == 0) break;
        vector<vector<tuple<int, int, int> > > g(n);
        repeat (i, m) {
            int u, v, d, c; scanf("%d%d%d%d", &u, &v, &d, &c); -- u; -- v;
            g[u].emplace_back(v, d, c);
            g[v].emplace_back(u, d, c);
        }
        // solve
        // // dijkstra
        vector<int> dist(n, inf); {
            priority_queue<pair<int, int> > que;
            dist[root] = 0;
            que.emplace(- dist[root], root);
            while (not que.empty()) {
                int cost, i; tie(cost, i) = que.top(); que.pop();
                if (dist[i] < - cost) continue;
                for (auto edge : g[i]) {
                    int j, d; tie(j, d, ignore) = edge;
                    if (- cost + d < dist[j]) {
                        dist[j] = - cost + d;
                        que.emplace(cost - d, j);
                    }
                }
            }
        }
        // // make the tree
        vector<vector<int> > h(n);
        repeat (i, n) {
            for (auto edge : g[i]) {
                int j, d, c; tie(j, d, c) = edge;
                if (dist[i] + d == dist[j]) {
                    h[j].push_back(c);
                }
            }
        }
        int result = 0;
        repeat_from (i, 1, n) {
            result += *whole(min_element, h[i]);
        }
        // output
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>
#include<string.h>

int main(void)
{
	char str[4];
	int a=0,b=0,c=0;
	int i=0;
	
	scanf("%s",str);
	
	for(i=0; i<3; i++){
		if(str[i] == 'a'){
			a++;
		}else if(str[i] == 'b'){
			b++;
		}else{
			c++;
		}
	}
	
	if(a==1 && b==1 && c==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<int, int>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;

int main(){
	ll n,k;cin>>n>>k;
	int a[2000];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll cnt=0;
	ll first_cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]>a[j]){
				cnt++;
				if(i<j){
					first_cnt++;
				}
			}
		}
	}
	ll ans=0;
	ll K=k*(k-1)/2%mod;
	cnt%=mod;
	cnt*=K;
	cnt+=first_cnt*k;
	cnt%=mod;
	cout<<cnt<<endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, K;
  cin >> N >> K;
  map<int,int> mp;
  REP(i,N){
	int x;
	cin >> x;
	mp[x]++;
  }
  VI nums;
  for(auto p : mp)
	nums.PB(p.SS);
  SORT(nums);

  int ans = N;
  int M = SZ(nums);
  for(int k=0;k<K&&M-1-k>=0;++k)
	ans -= nums[M-1-k];

  cout << ans << endl;

  return 0;
}


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

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


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

	final long MODULO = 1_000_000_000 + 7;

	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();// 積み木の総数
		int m = sc.nextInt();// 操作回数
		/*
		 * dp[i][j][k]:=i回目の操作まで終えたとき(k=0ならば左端に到達せずに、k=1ならば左端に訪れて）j番目に到達する経路数
		 */

		long[][][] dp = new long[2][n + 1][2];
		for (int i = 0; i <= n; ++i) {
			if (i != 0)
				dp[0][i][0] = 1;
			else
				dp[0][i][1] = 1;
		}

		for (int i = 0; i < m; ++i) {
			for (int k = 0; k < 2; ++k) {
				for (int j = 0; j <= n; ++j) {

					// 左に移動
					if (j - 1 >= 0) {
						if (j - 1 > 0)
							dp[(i + 1) % 2][j - 1][k] += dp[i % 2][j][k];
						else
							dp[(i + 1) % 2][j - 1][1] += dp[i % 2][j][k];
					}
					// 右に移動
					if (j + 1 <= n) {
						dp[(i + 1) % 2][j + 1][k] += dp[i % 2][j][k];
					}

					// 左を経由して元の位置に移動
					if (j - 1 >= 0) {
						if (j - 1 > 0) {
							dp[(i + 1) % 2][j][k] += dp[i % 2][j][k];
						} else if (j - 1 == 0) {
							dp[(i + 1) % 2][j][1] += dp[i % 2][j][k];
						}
					}

					// 右を経由して元の位置に移動
					if (j + 1 <= n) {
						dp[(i + 1) % 2][j][k] += dp[i % 2][j][k];
					}

				}
			}
			for (int k = 0; k < 2; ++k) {
				for (int j = 0; j <= n; ++j) {
					dp[(i + 1) % 2][j][k] %= MODULO;
				}
			}
			dp[i % 2] = new long[n + 1][2];
		}

		long ans = 0;
		for (int i = 0; i <= n; ++i) {
			ans = (ans + dp[m % 2][i][1]) % MODULO;
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 101828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        int ans = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] != t[i])
                ans++;
        }

        System.out.println(ans);
    }
    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

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

Measured memory_bytes: 37948
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
	int n;
int near(char t, int i){
	if(t == 'p') return floor(i/2);
	if(t == 'l') return i*2;
	if(t == 'r') return i*2+1;
	return 0;
}
void max_heapify(int *a,int i){
	int largest;
	int l = near('l', i);
	int r = near('r', i);
	if(l <= n && a[l] > a[i])
		largest = l;
	else
		largest = i;
#ifdef DBG
	cout << l << r << largest <<endl;
#endif
	if(r <= n && a[r] > a[largest]) largest = r;
	if(largest != i){
		swap(a[i], a[largest]);
		max_heapify(a, largest);
	}
}
int main(){
	int a[530000];
	int i;
	int tmp;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> a[i];
	}
	for(i=n/2; i >0 ;i--) max_heapify(a, i);
	for(i=1;i<=n;i++){
		printf(" %d", a[i]);
	}
	cout <<endl;

}



Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll X;

void solve()
{
    ll now = 100;
    cin >> X;
    for (int i = 1;; ++i)
    {
        now += now * 0.01;
        if(now>=X)
            return printf("%d\n", i), void();
    }
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	long long N, Z, W;
	cin >> N >> Z >> W;

	vector<long long> table(N);
	for(long long i=0; i<N; i++)
		cin >> table[i];

	long long ret = abs(W - table.back());
	if(N >= 2)
		ret = max(ret, abs(table[N-2] - table[N-1]));

	cout << ret << endl;

	return 0;
}


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

int main(){
  int N,AC=0,WA=0,TLE=0,RE=0;
  cin >> N;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(S=="AC"){
      AC++;
    }
    else if(S=="WA"){
      WA++;
    }
    else if(S=="TLE"){
      TLE++;
    }
    else{
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}     

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    // calculation
    int ab = abs(b - a), bc = abs(c - b), ad = abs(a-c);
    if ((ab <= d && bc <= d) || ad <= d) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  vector<vector<int>> vec(n);
  vector<pair<int,int>> city(m);
  for(int i=0;i<m;i++){
    int p,y;
    cin>>p>>y;
    vec[p-1].push_back(y);
    city[i]=make_pair(p-1,y);
  }
  for(int i=0;i<n;i++){
    sort(vec[i].begin(),vec[i].end());
  }
  for(auto &e:city){
    int p=e.first,y=e.second;
      auto itr=lower_bound(vec[p].begin(),vec[p].end(),y);
      printf("%06d",p+1);
      printf("%06d",(int)(itr-vec[p].begin())+1);
    cout<<endl;
  }
}

Measured memory_bytes: 7808
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	ll a, b, c, n, m, x, y;
	string s;
	cin >> n;
	REP(i, n,1000) {
		if (i % 111 == 0) {
			m = i;
			break;
		}
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
int main(){
	int m,k;
	cin>>m>>k;
	if(k>(1<<m)-1){
		puts("-1");
		return 0;
	}
	if(m==1){
		if(k==0){
		    printf("0 0 1 1\n");
		}
		else{
		    puts("-1");
		}
		return 0;
	}	
	printf("%d ",k);
	for(int i=0;i<=(1<<m)-1;i++){
		if(i!=k){
		    printf("%d ",i);
		}
	}
	printf("%d ",k);
	for(int i=(1<<m)-1;i>=0;i--){
		if(i!=k){
		    printf("%d ",i);
		}
	}
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:
const int sz=1<<19;
int dp[2][sz];
bool ok[2][sz];

int calc(const vector<int> &a){
	const int n=a.size();
	int limit=0;
	ok[0][0]=true;

	rep(i,n){
		int cur=i&1,nxt=cur^1,nlimit=limit;
		rep(j,limit+1){
			if(ok[cur][j]==false) continue;
			chmax(dp[nxt][j],dp[cur][j]),ok[nxt][j]=true;
			if(j%a[i]==0){
				ok[nxt][j+a[i]]=true;
				chmax(dp[nxt][j+a[i]],dp[cur][j]+1);
				chmax(nlimit,j+a[i]);
			}
		}
		rep(j,limit+1) dp[cur][j]=0,ok[cur][j]=false;
		limit=nlimit;
	}

	int cmax=0;
	rep(j,20) if((1<<j)<=limit) chmax(cmax,dp[n&1][1<<j]);
	
	//cout << cmax << endl;
	//if(cmax==516) rep(j,20) cout << dp[n&1][1<<j] << endl;
	
	rep(i,2)rep(j,limit+1) dp[i][j]=0,ok[i][j]=false;
	return cmax;
}

int main(void){
	int n;
	while(cin >> n,n){
		vector<int> a(n);
		rep(i,n) cin >> a[i];
		int ans=1;
		rep(small,1,501){
			if(small%2==0) continue;
			vector<int> b;
			rep(i,n) if(small<=a[i] and a[i]%small==0 and __builtin_popcount(a[i]/small)==1) b.push_back(a[i]/small);
			chmax(ans,calc(b));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4384
#include <bits/stdc++.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>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string N;
  cin >> N;
  if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import fractions
a, b, c, d = (int(i) for i in input().split())

ABc = b // c - (a - 1) // c
ABd = b // d - (a - 1) // d
cd = c * d // fractions.gcd(c, d)
ABcd = b // cd - (a - 1) // cd

print(b - a + 1 - (ABc + ABd - ABcd))

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

int main() {
  int a, b, c; 
  cin >>a >>b >>c;
  
  int s[c],t[c],u[c];
  for (int i=0; i<c; i++){
    cin >> s[i] >>t[i] >>u[i];
  }
  int d=0,e=a,f=0,g=b;
  
  for(int i=0;i<c;i++){
  if (u[i] ==1)
    d = max(s[i],d);
  
      if (u[i]==2)
        e = min(s[i],e);
      
   if (u[i] ==3)
    f = max(t[i],f);
  
   if (u[i] ==4)
    g = min(t[i],g);
    
    }
    int h = max({0,(e-d)});
    int m = max({0,(g-f)});
  
  cout << h*m <<endl;
  
    }

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    cin >> N;
    ll a[N];
    REP(i, 0, N) {
        cin >> a[i];
    }
    sort(a, a + N);
    reverse(a, a + N);
    ll ans = 0;
    while (1) {
        bool ok = true;
        REP(i, 0, N) {
            if (a[i] >= N) {
                ok = false;
                break;
            }
        }
        if (ok) {
            break;
        }
        REP(i, 0, N) {
            ll num = a[i] / N;
            ans += num;
            REP(j, 0, N) {
                if (j == i) {
                    a[j] -= num * N;
                } else {
                    a[j] += num;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
abcd = gets.chomp

(1..8).each do |x|
  s = abcd.dup
  2.downto(0) do |i|
    o = (x & (1 << i)).zero? ? "-" : "+"
    s[i+1, 0] = o
  end
  if eval(s) == 7
    puts s + "=7"
    exit
  end
end

Measured memory_bytes: 1788
package main

import "fmt"

func main() {
        var topping string
        fmt.Scan(&topping)
        sum := 700
        for i := 0; i < len(topping); i++ {
                if topping[i] == 'o' {
                        sum += 100
                }
        }
        fmt.Printf("%d\n", sum)
}

Measured memory_bytes: 512
use std::io::Read;
use itertools::Itertools;
use rand::Rng;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let d: usize = iterator.next().unwrap().parse().unwrap();
    let c: Vec<isize> = (0..26).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let mut s: Vec<Vec<isize>> = vec![vec![0; 26]; d];
    for i in 0..d {
        for j in 0..26 {
            s[i][j] = iterator.next().unwrap().parse().unwrap();
        }
    }

    let mut rng = rand::thread_rng();

    let mut t: Vec<usize> = vec![0; d];
    for i in 0..d {
        t[i] = rng.gen::<usize>() % 26 + 1;
        // let mut m: isize = 0;
        // for j in 0..26 {
        //     if s[i][j] > m {
        //         m = s[i][j];
        //         t[i] = j + 1;
        //     }
        // }
    }
    return t.iter().join("\n");
}


Measured memory_bytes: 2712
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<int>vx(x),vy(y),vz(z);
    for(auto & e : vx) cin >> e;
    for(auto & e : vy) cin >> e;
    for(auto & e : vz) cin >> e;
    sort(all(vx),greater<>());
    sort(all(vy),greater<>());
    sort(all(vz),greater<>());
    //    vector<int>nx,ny,nz;
    //    nx.push_back(vx.front());
    //    ny.push_back(vy.front());
    //    nz.push_back(vz.front());
    
    //    priority_queue<int,vector<int>>xque,yque,zque;
    //    rep(i,x)if(i)xque.push(vx[i]);
    //    rep(i,y)if(i)yque.push(vy[i]);
    //    rep(i,z)if(i)zque.push(vz[i]);
    //    xque.push(-10000000000);
    //    yque.push(-10000000000);
    //    zque.push(-10000000000);
    //
    //    while((int)nx.size() * (int)ny.size() * (int)nz.size() < k){
    //        int xdif = nx.back() - xque.top();
    //        int ydif = ny.back() - yque.top();
    //        int zdif = nz.back() - zque.top();
    //        if(xdif <= ydif and xdif <= zdif and !xque.empty()){
    //            nx.push_back(xque.top());
    //            xque.pop();
    //        } else if(ydif <= xdif and ydif <= zdif and !yque.empty()){
    //            ny.push_back(yque.top());
    //            yque.pop();
    //        } else {
    //            nz.push_back(zque.top());
    //            zque.pop();
    //        }
    //    }
    vector<int>ans;
    //    rep(i,nx.size())rep(j,ny.size())rep(k,nz.size()){
    //        ans.push_back(nx[i] + ny[j] + nz[k]);
    //    }
    vector<int>sum;
    rep(i,vy.size())rep(j,vz.size())sum.push_back(vy[i] + vz[j]);
    sort(all(sum),greater<>());
    rep(i,vx.size())rep(j,min(3000LL,(int)sum.size()))ans.push_back(vx[i] + sum[j]);
    sort(all(ans),greater<>());
    rep(i,k)cout << ans[i] << endl;
}




Measured memory_bytes: 43368
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define ld long double 
#define int long long 
using namespace std;

const int maxn = 1e5 + 17;

int n;
struct pnt{  int x, y, id;  }  p[maxn];
int cross(pnt a, pnt b, pnt c)
{ 
	return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

ld ans[maxn] ; 


ld sz(pnt a)
{
	return sqrt(a.x*a.x+a.y*a.y) ; 
}

ld angle(pnt a , pnt b)
{
	return atan2(a.y,a.x) - atan2(b.y,b.x) ; 
}

int32_t main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	if(n==2)
	{
		cout << "0.5\n0.5\n" ; 
		return 0 ; 
	}
	for(int i = 0; i < n; i++)
		cin >> p[i].x >> p[i].y, p[i].id = i;
	sort(p, p + n, [](pnt &a, pnt &b){  return a.x == b.x ? a.y < b.y : a.x < b.x;  });
	vector<pnt> st;
	st.pb(p[0]);
	for(int i = 1; i < n; i++){
		while(st.size() > 1 && cross(st[ st.size() - 2 ], st.back(), p[i]) >= 0)  st.pop_back();
		st.pb(p[i]);
	}
	int upper_hull_sz = st.size();
	for(int i = n - 2; i >= 0; i--){
		while(st.size() > upper_hull_sz && cross(st[ st.size() - 2 ], st.back(), p[i]) >= 0)  st.pop_back();
		st.pb(p[i]);
	}
	st.pop_back();
	ld d = 0. ; 
	int m = st.size() ; 
	ld P = acos(-1.) ; 
	ld s = 0 ; 
	ld eps = 1e-7 ;
	for(int i = 0 ; i < m ; i ++ ) 
	{
		pnt P3 = st[(i-1+m)%m] , P1 = st[i] , P2 = st[(i+1)%m] ; 
	 	P2.x -= P1.x ; 
		P2.y -= P1.y ; 
		P3.x -= P1.x ; 
		P3.y -= P1.y ; 
		
		ld d = P2.x * P3.x + P2.x * P3.x ; 

		d /= sz(P2) * sz(P3) ; 
		
	 	ld ang = angle(P2,P3) ; 
		while(ang<eps) ang += P ; 
		while(ang>P-eps) ang -= P ; 
		ans[st[i].id] += (P-ang) / 2. / P ; 
		s += ang ; 
	}
	cout << fixed << setprecision(10) ; 
	for(int i = 0 ; i < n ; i ++ ) cout << ans[i] << '\n' ; 
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define mi map<int,int>
#define mll map<long long,long long>
#define qi queue<int>
#define pb push_back
#define mod %
#define pow ^
#define pnode struct node
#define pair_int pair<int,int>
#define pair_ll pair<long,long>
#define pq priority_queue


double dp[301][301][301];

void solve(int one,int two,int th,int n)
{
   // cout << one << " , " << two << " , " << th << " , " << n << " : " << "entered" << endl;
   double sum = one + two + th;
   double val = 0;
   val = (n*1.0)/(one+two+th);
   if(one + two + th == 0)
   {
      dp[one][two][th]=0;
      return;
   }
   if(one!=0)
   {
      if(dp[one-1][two][th]==-1)
         solve(one-1,two,th,n);
      val+=((one*1.0)/sum)*(dp[one-1][two][th]);
   }
   if(two!=0)
   {
      if(dp[one+1][two-1][th]==-1)
         solve(one+1,two-1,th,n);
      val+=((two*1.0)/sum)*(dp[one+1][two-1][th]);
   }
   if(th!=0)
   {
      if(dp[one][two+1][th-1]==-1)
         solve(one,two+1,th-1,n);
      val+=((th*1.0)/sum)*(dp[one][two+1][th-1]);
   }

   dp[one][two][th] = val;
   // cout << one << " , " << two << " , " << th << " , " << n << " : " << dp[one][two][th] << endl;
   return;
  
}

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   int n;
   cin >> n;

   for(int i=0;i<=300;i++)
   {
      for(int j=0;j<=300;j++)
      {
         for(int k=0;k<=300;k++)
            dp[i][j][k] = -1;
      }
   }
   int one,two,th;
   one = 0;
   two = 0;
   th = 0;
   for(int i=1;i<=n;i++)
   {
      int x;
      cin >> x;
      if(x==1)
         one++;
      else if(x==2)
         two++;
      else
         th++;
   }
   solve(one, two, th, n);
   cout << fixed;
   cout << setprecision(10);
   cout << dp[one][two][th] << "\n";
   return 0;
}


Measured memory_bytes: 213504
use proconio::input;

#[proconio::fastout]
pub fn main() {
    input! {
    mut n:isize,
    }
    let mut ans = 0;
    for i in 2..=1000000 {
        let mut cnt = 0;
        while n % i == 0 {
            n /= i;
            cnt += 1;
        }
        for j in 1..=1000000 {
            cnt -= j;
            if cnt < 0 { break; }
            ans += 1;
        }
        if n == 1 { break; }
    }
    if n != 1 { ans += 1; }
    println!("{}", ans);
}


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

using namespace std;


int main() {
    int H, W;
    cin >> H >> W;
    int dp[101][101];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            dp[i][j] = 1e9;
        }
    }
    char c[101][101];
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            cin >> c[i][j];
    dp[0][0] = c[0][0] == '#';
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i][j] != c[i - 1][j]));
            if (j) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (c[i][j] != c[i][j - 1]));
        }
    }
    cout << (dp[H - 1][W - 1] + 1) / 2 << endl;
}


Measured memory_bytes: 256