akhauriyash/Code-Regression huggingface dataset:
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const ll INF = 1e18;

void solve() {
  ll n; cin >> n;
  int ans = 0;
  for(ll i = 2; i * i <= n; i++) {
    if(n % i) continue;
    int pw = 0;
    while(n % i == 0) {
      n /= i;
      pw++;
    }
    int cur = 1;
    int p = 0;
    while(pw >= cur) {
      pw -= cur;
      cur++;
      p++;
    }
    ans += p;
  }
  if(n > 1) {
    ans++;
  }
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

Measured memory_bytes: 3640
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
       in.lines()
           .map(Integer::valueOf)
           .sorted(Comparator.reverseOrder())
           .limit(3)
           .forEach(System.out::println);
    }
}

Measured memory_bytes: 30964
// Author :mdragneell
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define pi  pair< int,int >
#define pl  pair< ll,ll >
#define f first
#define s second


ll const mod=1e9+7;
ll const N=1e3+5;
ll min(ll x,ll y) { if(x < y) return x; else return y; }
ll max(ll x,ll y) { if(x > y) return x; else return y; }
ll gcd(ll x,ll y) { if(x == 0) return y; else return gcd(y%x,x);}
ll powmod(ll x,ll y){ll res=1;while(y>0){if(y%2==1)res=(res*x)%mod;y>>=1;if(y<=0)break;x=(x*x)%mod;}return res;}



struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);}
};
struct compare {
    bool operator()(const pair<ll, ll>& value,  const ll& key){ return (value.first < key); }
    bool operator()(const ll& key, const pair<ll, ll>& value) { return (key < value.first); }
};

bool compare1(const pair<ll,ll> &a,const pair<ll,ll> &b)
{   if(a.first<b.first) return true ;
    else if(a.first==b.first) return (a.second > b.second);
    else return false;
}

int main()
{

        ios_base::sync_with_stdio(false); cin.tie(NULL);
       
        int tt=1;
        //cin>>tt;

        while(tt--)
        {
               ll n,k;
               cin>>n>>k;
               
               ll v[n];
               for(int i=0;i<n;i++)
                cin>>v[i];
                
              sort(v,v+n);
              ll sum=0;
              
              for(int i=0;i<(n-k);i++)
                sum+=v[i];
             cout<<sum<<endl;
              
            
                
        }



}


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

int main()
{
	ll w, h, x, y; cin >> w >> h >> x >> y;
	
	if (2 * x == w && 2 * y == h) {
		cout << fixed << setprecision(11) << (double)w * h / 2 << " " << 1 << endl;
		return 0;
	}

	cout << fixed << setprecision(11) << (double)w * h / 2 << " " << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define mod 1000000007
#define sz(v) v.size()
#define all(x) x.begin(), x.end()
#define prec(x) fixed << setprecision(x)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)
#define speedup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;

void solve(){
    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, 0, n-1) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    int z, y;
    if(n%2){
        y = a[n/2];
        z = b[n/2];
    }else{
        y = a[n/2-1] + a[n/2];
        z = b[n/2-1] + b[n/2];
    }
    cout << z-y+1;
}

int32_t main() {
    speedup;

    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    // test{
        solve();
    // }

    return 0;
}


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

int main() {

	ll n, m; cin >> n >> m;
	vector<pair<ll, ll>> pa;
	for (ll i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		pa.push_back({ a,b });
	}
	sort(pa.begin(), pa.end());
	ll cnt = m;
	ll ans = 0;
	for (ll i = 0; i < pa.size(); i++) {
		if (pa[i].second <= cnt) {
			ans += pa[i].second * pa[i].first;
			cnt -= pa[i].second;
		}
		else {
			ans += cnt * pa[i].first;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5340
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,i,j=1000,k,x,y,z,c1=0,c2=0,c3=0,f=0;
    vector<long long int>v;
    cin>>n;
    for(i=0;i<4;i++)
    {
        k=n/j;
        n=n-k*j;
        j=j/10;
        v.push_back(k);
    }
    c1=v[0];
    if(c1+v[1]+v[2]+v[3]==7)
    {
        cout<<v[0]<<"+"<<v[1]<<"+"<<v[2]<<"+"<<v[3]<<"=7"<<endl;

    }
    else if(c1+v[1]+v[2]-v[3]==7)
    {
        cout<<v[0]<<"+"<<v[1]<<"+"<<v[2]<<"-"<<v[3]<<"=7"<<endl;
    }
    else if(c1+v[1]-v[2]+v[3]==7)
    {
        cout<<v[0]<<"+"<<v[1]<<"-"<<v[2]<<"+"<<v[3]<<"=7"<<endl;
    }
    else if(c1+v[1]-v[2]-v[3]==7)
    {
        cout<<v[0]<<"+"<<v[1]<<"-"<<v[2]<<"-"<<v[3]<<"=7"<<endl;
    }
    else if(c1-v[1]-v[2]-v[3]==7)
    {
        cout<<v[0]<<"-"<<v[1]<<"-"<<v[2]<<"-"<<v[3]<<"=7"<<endl;
    }
    else if(c1-v[1]+v[2]-v[3]==7)
    {
        cout<<v[0]<<"-"<<v[1]<<"+"<<v[2]<<"-"<<v[3]<<"=7"<<endl;
    }
    else if(c1-v[1]-v[2]+v[3]==7)
    {
        cout<<v[0]<<"-"<<v[1]<<"-"<<v[2]<<"+"<<v[3]<<"=7"<<endl;
    }
    else if(c1-v[1]+v[2]+v[3]==7)
    {
        cout<<v[0]<<"-"<<v[1]<<"+"<<v[2]<<"+"<<v[3]<<"=7"<<endl;
    }





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int v[11][3];
int ans = 1e9;
int d, g;
void f(int a, int b, int l, int sum_a) {
	if (a == d + 1) {
		if (sum_a >= g) {
			chmin(ans, b);
		} else {
			rrep(i, d, 0) {
				if (l & (1 << i))
					continue;
				if (i * (v[i][0] - 1) + sum_a >= g) {
					chmin(ans, b + (g - sum_a + i - 1) / i);
					break;
				}
				b += v[i][0] - 1;
			}
		}
		return;
	}
	f(a + 1, b, l, sum_a);
	f(a + 1, b + v[a][0], l + (1 << a), sum_a + v[a][2]);
}
void solve() {
	cin >> d >> g;
	g /= 100;
	rep(i, 1, d + 1) {
		cin >> v[i][0] >> v[i][1];
		v[i][1] /= 100;
		v[i][2] = v[i][0] * i + v[i][1];
	}
	f(1, 0, 0, 0);
	print(ans);
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
using ll = long long;
/*
    g++ -std=c++11 test.cpp -o test.out && ./test.out
*/
void solve(){
    int n; cin >> n;
    vector<int> a(n);

    vector<int> ans;
    int c = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        c ^= a[i];
    }

    for(int i = 0; i < n; i++){
        c ^= a[i];
        ans.push_back(c);
        c ^= a[i];
    }

    for(int i = 0; i < n; i++) cout << ans[i] << " "; 

}   
 
const int MOD = 1e9 + 7;

int modpow(int a, int b) {
	int ans = 1;
	while (b > 0) {
		if (b & 1)
			ans = 1LL * ans * a % MOD;
		a = 1LL * a * a % MOD;
		b >>= 1;
	}
	return ans;
}

ll F[1000005],R[1000005];
void make(){
    F[0] = 1;
    for(int i=1;i<1000005;i++) F[i] = F[i-1]*i%MOD;
    for(int i=0;i<1000005;i++) R[i] = modpow(F[i],MOD-2);
}

ll sum(ll a, ll b){
	a += b;
	if(a >= MOD) a-= MOD;
 	if(a < 0) a += MOD;
	return a;
} 

ll mul(ll a, ll b){
	return a * 1ll * b % MOD;
}

ll sub(ll a, ll b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}



// void solve(){
//     int k; cin >> k; 
//     string str; cin >> str;

//     unordered_map<int,int> count;
//     for(int i = 0; i < str.size(); i++){
//         count[str[i] - 'a']++;;
//     }

//     int n = str.size();

// }

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

Measured memory_bytes: 4964
def main():
    N, K, Q = map(int, input().split())
    
    lst_miss = [Q] * N
    for _ in range(Q):
        A = int(input())
        lst_miss[A - 1] -= 1
    
    for miss in lst_miss:
        ans = "Yes" if miss < K else "No"
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 6612
import math
import collections
def f(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n = n//f
        else:f += 2
    if n != 1:
        a.append(n)
    return a

a,b = map(int,input().split())
a = set(collections.Counter(f(a)).keys())
b = set(collections.Counter(f(b)).keys())
print(len(a&b)+1)

Measured memory_bytes: 3316
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Bad")
    elif q == 0:print("Good")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

#n = ip()                                     #入力整数1つ
a,b,c,d= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
if a == b:
    if a%c and a%d:
        print(1)
    else:print(0)
elif min(a,b)+1 == max(a,b):
    s =0
    if a%c and a%d:s+=1
    if b%c and b%d:s+=1
    print(s)
else:
    sub1 = (b)//d - (a-1)//d
    sub2 = (b)//c - (a-1)//c
    inter = lcm(c,d)
    sub3 = (b)//inter - (a-1)//inter
    print(b-a-sub1-sub2+sub3+1)


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    v.reserve(n*n);

    unsigned long long int total = 0;

    for(int i=0;i<n*n;i++) {
        int t;
        cin >> t;
        v.push_back(t);
    }
    for(int i=0;i<n;i++) {
        for(int j=0;j<i;j++) {
            bool flag = false;
            for(int k=0;k<n;k++) {
                if(i==k || j==k) continue;
                int t = v[i * n + j] - v[i * n + k] - v[k * n + j];
                if (t > 0) {
                    cout << -1 << endl;
                    return 0;
                }
                else if(t == 0) {
                    flag = true;
                }
            }
            if (!flag) total += v[i * n + j];
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<int> a(n);
    vector<vector<int>> x(n),y(n);
    fr(i,n){
        in>>a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        fr(j,a[i]) in>>x[i][j]>>y[i][j],--x[i][j];
    }
    vector<bool> v(n);
    int ans{};
    fr(i,1<<n){
        fr(j,n) v[j]=(i>>j)&1;
        bool f=true;
        fr(j,n) if((i>>j)&1){
            fr(k,a[j]){
                if(v[x[j][k]]!=y[j][k]) f=false;
            }
        }
        if(f) ans=max(ans,__builtin_popcount(i));
    }
    cout<<ans<<endl;
}

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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double ans = 0.0;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) ans += dist(i, j) * 2 / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}

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

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<< '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------



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

string a;
cin >> a;

if(a =="ABC"){
    cout << "ARC" << endl;
}else{
    cout << "ABC" << endl;
}

return 0;
}

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

using namespace std;

using ll = long long;

const int INF = 1145141919;

vector<int> g[100005];
vector<int> color;

bool dfs(int cur) {
    for (int nex : g[cur]) {
        if (color[nex] == color[cur]) {
            return false;
        }
        if (color[nex] != INF) continue;
        color[nex] = !color[cur];
        if (!dfs(nex)) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    ll ans = 0;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    color.resize(n, INF);
    color[0] = 0;
    if (dfs(0)) {
        ll cnt = 0;
        for (int i = 0; i < n; i++) cnt += color[i];
        cout << cnt * (n - cnt) - m << endl;
    } else {
        cout << (ll)n * (n - 1) / 2 - m << endl;
    }
    return 0;
}

Measured memory_bytes: 6400
object Main extends App {
  import scala.math.BigDecimal.RoundingMode
  import java.util.Scanner
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val k = sc.nextInt()
  val result = (1 to k)
    .map { i =>
      val d = sc.nextInt()
      val a = (1 to d).map { _ =>
        sc.nextInt()
      }
      (1 to n).map(a.contains)
    }
    .transpose
    .map(_.contains(true))
    .count(!_)
  println(result)
}


Measured memory_bytes: 57492
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<6)printf("0\n");
    else if(a>=6 && a<=12)printf("%d\n",b/2);
    else printf("%d\n",b);
}


Measured memory_bytes: 128
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=3e2+10;

int Cnt[4],N;
double DP[maxm][maxm][maxm];

int main(){
	register int i,j,k;
	int x;
	scanf("%d",&N);
	for(i=1;i<=N;i++) scanf("%d",&x),Cnt[x]++;
	for(k=0;k<=N;k++){
		for(j=0;j<=N;j++){
			for(i=0;i<=N;i++){
				if(!i && !j && !k) continue;
				if(i) DP[i][j][k]+=DP[i-1][j][k]*i;
				if(j) DP[i][j][k]+=DP[i+1][j-1][k]*j;
				if(k) DP[i][j][k]+=DP[i][j+1][k-1]*k;
				DP[i][j][k]=(DP[i][j][k]+N)/(i+j+k);
			}
		}
	}
	printf("%.12lf",DP[Cnt[1]][Cnt[2]][Cnt[3]]);
	return 0;
}

Measured memory_bytes: 227584
n = int(input())
a = list(map(int,input().split()))

d =[]

for e in range(n+1):
    d.append(e+1)

f = dict(zip(a,d))

g = sorted(f.items())

r = []
for i in g:
    r.append(str(i[1]))

s = " ".join(r)

print(s)

Measured memory_bytes: 32860
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, cnt[100010] = {}, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a > 100000)ans++;
		else cnt[a]++;
	}
	for (int i = 1; i <= 100000; i++) {
		if (cnt[i] >= i)ans += cnt[i] - i;
		else ans += cnt[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()
int main(){
  int h,w,k;cin>>h>>w>>k;vector<vector<int>> c(h,vector<int>(w));
  int i,j,l,n,p;
  rep(i,h)rep(j,w){
    char ch;cin>>ch;
    c[i][j]=(ch-'0');
  }
  int ans=0;
  rep(i,h)rep(j,w){
    bool update=1;vector<vector<int>> m=c;
    m[i][j]=0;int score=0,timev=1;
    while(update) {
      update=0;
      rep(n,w){
        int to=h-1;
        for(l=h-1;l>=0;l--){
          if(m[l][n]!=0){
            swap(m[to][n],m[l][n]);to--;
          }
        }
      }
      int get=0;
      rep(l,h){
        int from=0,now=m[l][w-1];
        rep(n,w){
          if(now!=m[l][n]){
            int dis=(n-1)-from+1;
            if(dis>=k){
              for(p=from;p<n;p++) {
                get+=m[l][p];m[l][p]=0;
              }
            }from=n;now=m[l][n];
          }
        }
        int dis=(w-1)-from+1;
        if(dis>=k){
          for(p=from;p<n;p++){
            get+=m[l][p];m[l][p]=0;
          }
        }
      }
      if(get>0)update=1;
      else break;
      score+=timev*get; timev*=2;
    }ans=max(ans,score);
  }cout<<ans<<endl;
}


Measured memory_bytes: 3616
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p%i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL 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] % p) % p; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N;
	cin >> N;
	VL A(N + 1, 0);
	FOR(i, 0, N)
		A[i] = IN<LL>();

	LL ans = 0;
	FOR(i, 0, N) {
		LL t = A[i];
		while (t % 2 == 0) {
			ans++;
			t /= 2;
		}
	}
	O(ans);

	return 0;
}

Measured memory_bytes: 384
s=list(str(input()))

nax=len(s)
first=0
last=nax
for i in range(nax):
    if s[i]=='A':
        first=i
        break
for i in range(nax):
    if s[nax-1-i]=='Z':
        last=nax-i-1
        break

print(last-first+1)

Measured memory_bytes: 10428
#include <iostream>
#include <cstdlib>
#include <map>
#include <algorithm>
#define fr first
#define sc second
#define INF (2 << 28)
#define SQR(x) (abs(x) * abs(x))
using namespace std;

pair<int, int> p[500001];

int main(){
    
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> p[i].sc >> p[i].fr;
    
    sort(p, p + n);
    int ret = INF;
    for(int i  = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(SQR(p[i].fr - p[j].fr) >= ret) break;
            ret = min(SQR(p[i].fr - p[j].fr) + SQR(p[i].sc - p[j].sc), ret);
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+5;
ll det[MAXN];
struct node
{
	ll x,h;
	node(ll _x=0,ll _h=0):x(_x),h(_h){}
	bool operator < (const node &o)const
	{
		return x<o.x;
	}
}sv[MAXN];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n,d,a;
	scanf("%d%d%d",&n,&d,&a);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&sv[i].x,&sv[i].h);
	sort(sv+1,sv+1+n);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		det[i]+=det[i-1];
		sv[i].h-=det[i];
		if(sv[i].h>0)
		{
			ll sub=(sv[i].h+a-1)/a;
			ans+=sub;
			det[i]+=sub*a;
			int nxt=upper_bound(sv+1,sv+1+n,node(sv[i].x+2LL*d,0))-sv;
			det[nxt]-=sub*a;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque, BinaryHeap};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

fn main() {
    let (n, m): (usize, usize) = input_two();
    let ab: Vec<(usize, usize)> = input_lines_two(n);
    let mut map = HashMap::new();
    for (a, b) in ab {
        let h = map.entry(a).or_insert(Vec::new());
        h.push(b);
    }

    let mut cand = BinaryHeap::new();

    let mut ans = 0;
    for i in 1..m + 1 {
        if map.contains_key(&i) {
            cand.append(&mut map[&i].iter().cloned().collect());
        }
        // dbg!(&cand);
        let p = cand.pop().unwrap_or(0);
        ans += p;
    }

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

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 17840
# WIP
import sys


sys_input = sys.stdin.readline

H, W = map(int, sys_input().split())

areamap = []
areamap.append(['.']*(W+2))
for h in enumerate(range(H)):
    row = list(sys_input().replace('\n', ''))
    row = ['.'] + row + ['.']
    areamap.append(row)
areamap.append(['.']*(W+2))

for h in range(1, H+1):
    for w in range(1, W+1):
        if areamap[h][w] == '#' and \
                areamap[h][w+1] == '.' and \
                areamap[h][w-1] == '.' and \
                areamap[h+1][w] == '.' and \
                areamap[h-1][w] == '.':
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 3064
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    h, n = MAP()
    A = LIST()
    if h <= sum(A):
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 16272
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int abc[3] = {a, b, c};
    sort(abc, abc + 3);
    printf("%d %d %d\n", abc[0], abc[1], abc[2]);

    return 0;
}


Measured memory_bytes: 2824
import java.io.*;
import java.util.*;

public class Main {
    
    private static PrintWriter out;
    
    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }
    
    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }
    
    private static void getAns(MyScanner sc){
       int n = sc.ni(), k = sc.ni();
       char[] ar = sc.nn().toCharArray();
       
       for(int i = 0; i < n; i++){
           if(k - 1 == i) ar[i] = Character.toLowerCase(ar[i]);
           out.print(ar[i]);
       }
    }
    
    static class MyScanner{
        BufferedReader br;
	StringTokenizer st;

	MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
	}

	MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
	}

	String nn(){
            while(st == null || !st.hasMoreElements()){
		try{
                    st = new StringTokenizer(br.readLine());
		}catch(IOException e){
                    e.printStackTrace();
		}
            }
            return st.nextToken();
	}
        
        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

	char nc(){
            return nn().charAt(0);
	}

	int ni(){
            return Integer.parseInt(nn());
	}

	long nl(){
            return Long.parseLong(nn());
	}

	double nd(){
            return Double.parseDouble(nn());
	}

	int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
	}

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
	}

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

Measured memory_bytes: 21332
if __name__ == '__main__':
    n = int(input())
    s = input()
    t = input()
    count = 2 * n
    maxDiff = 0

    for i in range(0,n+1):
        diff = 0
        for j in range(i):
            if s[n - i :][j] == t[j]:
                diff+=1
            else:
                break
        if maxDiff < diff:
            maxDiff=diff
    print(count-maxDiff)

Measured memory_bytes: 8992
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1e5 + 10;
vector<lli> dp(N);
vector<lli> dp2(N);
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	lli n, w;
	cin >> n >> w;
	for(int i = 1; i <= n; i++) {
		lli ww, vv;
		cin >> ww >> vv;
		for(int j = 0; j <= w-ww; j++)
			if(dp[j] != -1)
				dp2[j+ww] = max(dp[j+ww], dp[j] + vv);
		dp = dp2;
	}
	lli ans = 0;
	for(int i = 0; i <= w; i++)
		ans = max(ans, dp[i]);
	cout << ans << "\n";
	return 0;
}

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

int count(int x){
    if(x%2 == 0 || x%5 == 0) return -1;
    int val = 7%x;
    for(int i=1;i<1e7;i++){
        if(!val) return i;
        val = (val *10 + 7)%x;
    }
    return -1;
}

int main(){
  	int k;
  	cin>>k;
  	int ans = count(k);
  	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
//#include <cstdio>
using namespace std;

int A[100000], n;

int partition(int A[], int p, int r)
{
	int x = A[r];
	int i = p - 1;
	int j;
	for(j=p; j < r; j++)
	{
		if(A[j] <= x) swap(A[++i],A[j]);
	}
	swap(A[i+1], A[r]);
	return i+1;
}

int main() {
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> A[i];
	}
	
	int x = A[n-1];
	
	int index_parti = partition(A, 0, n-1);
	
	for(int i=0; i<n; i++)
	{
		if (i) cout << " ";
		
		if(i==index_parti)
		{
			cout << '[' << A[i] <<']';
		}
		else cout << A[i];
		
	}
	cout << endl;
	
//	system("pause");
	return 0;
}


Measured memory_bytes: 3448
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

bool jud(string citya,string cityb,int pointa,int pointb){
  if(citya > cityb){
    return true;
  }
  if(citya == cityb and pointa < pointb){
    return true;
  }
  return false;
}

int main(void){
  int num;
  cin >> num;
  vector<string> city(num);
  vector<int> point(num);
  for(int i = 0;i < num;i ++){
    cin >> city[i] >> point[i];
  }
  vector<int> ans;
  for(int i = 0;i < num;i ++){
    ans.insert(ans.end(),i);
    for(int j = 0;j < i;j ++){
      if(jud(city[ans[i-j]],city[ans[i-j-1]],point[ans[i-j]],point[ans[i-j-1]]) == false){
        int p = ans[i-j];
        ans[i-j] = ans[i-j-1];
        ans[i-j-1] = p;
      }
    }
  }
  
  for(int i = 0;i < num;i ++){
    cout << ans[i]+1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3608
A, B, C, X, Y = [int(n) for n in input().split(" ")]

if X >= Y:
  print(min([X * A + Y * B, 2 * X * C, 2 * Y * C + (X - Y) * A]))
else:
  print(min([X * A + Y * B, 2 * Y * C, 2 * X * C + (Y - X) * B]))

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

typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    int x, y, a, b, c;  cin >> x >> y >> a >> b >> c;
  
    priority_queue<ll> p, q, r, ans;

    for(int i=0; i<a; i++){
        ll tmp;  cin >> tmp;    p.push(tmp);
    }
    for(int i=0; i<b; i++){
        ll tmp;  cin >> tmp;    q.push(tmp);
    }
    for(int i=0; i<c; i++){
        ll tmp;  cin >> tmp;    r.push(tmp);
    }

    int n=x+y;
    ll sum=0;
    while(x--){
        ans.push(p.top());
        p.pop();
    }

    while(y--){
        ans.push(q.top());
        q.pop(); 
    }

    while(!r.empty()){
        ans.push(r.top());
        r.pop();
    }
    for(int i=0; i<n; i++){
        sum += ans.top();
        ans.pop();
    }
    cout << sum << endl;

}

Measured memory_bytes: 8432
s = gets
len = s.length-1
flag = 0
0.upto(len)do|i|
  if(i < len - 1)
    if s[i] == s[i+1]
      puts (i+1).to_s + " " + (i+2).to_s 
      flag = 1
      break
    end
    if( 0 < i )
      if s[i-1] == s[i+1]
        puts (i).to_s + " " + (i+2).to_s 
        flag = 1
         break
      end
   end
 end
end
puts (-1).to_s + " " + (-1).to_s if flag == 0

Measured memory_bytes: 1916
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static int max(int[] array){
		int m = array[0];
		for(int n=1;n<array.length;n++){
			if(array[n]>m) m=array[n];
		}
		return m;
	}
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int N = Integer.parseInt(line[0]),
            T = Integer.parseInt(line[1]);
        
        line = br.readLine().split(" ");
        int[] price = new int[N];
        for(int n=0;n<N;n++) price[n]=Integer.parseInt(line[n]);
        int[] highest = new int[N-1];
        //highest[i]: the highest price of price[i+1],price[i+2],...,price[N-1]
        //if Tak buy apples on city[i], the apple will be sold for highest[i] yen
        highest[N-2] = price[N-1];
        for(int n=N-3;n>=0;n--){
        	highest[n] = Math.max(price[n+1],highest[n+1]);
        }
        int[] profit = new int[N-1];
        for(int n=0;n<N-1;n++)profit[n] = Math.max(0,highest[n]-price[n]);
        int best = max(profit);
        
        int count = 0;
        for(int p:profit){
        	if(p==best)count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
char c; 
int main() {
    // freopen("1.in", "r", stdin);
    // freopen("1.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
 	cin>>c;
 	if(c<='Z') cout<<'A';
 	else cout<<'a';
    return 0;
}

Measured memory_bytes: 3648
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")

#include <cstdio>
#include <stdint.h>
#include <algorithm>
#include <functional>

#ifdef _MSC_VER
//#include <__msvc_all_public_headers.hpp>
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#endif // VS

#define long long long
using namespace std;

void read(uint32_t& x)
{
	x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0')	break;
		x = x * 10 + k - '0';
	}
}

void sread(int32_t& x)
{
	bool flag;
	x = 0;
	int k = getchar_unlocked();
	if (flag = (k == '-')) k = getchar_unlocked();

	while (true)
	{
		if (k < '0')	break;
		x = x * 10 + k - '0';
		k = getchar_unlocked();
	}
	if (flag) x *= -1;
}

void sprint(int64_t x) {
	if (x == 0) {
		putchar_unlocked('0');
		return;
	}
	if (x < 0) {
		putchar_unlocked('-');
		x *= -1;
	}
	int s = 0;
	char f[15];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int32_t a[200000];
int main() {
	uint32_t n;
	read(n);
	for (size_t i = 0; i < n; i++) sread(a[i]);
	int64_t res;
	if (n & 1) {
		//Odd
		int64_t sum = 0;
		for (size_t i = 0; i < n - 1; i += 2) sum += a[i];
		res = sum;
		int64_t tailDiff = 0, tailDiffMax = 0;
		for (int i = n - 3; i >= 0; i -= 2)
		{
			sum -= a[i]; sum += a[i + 1];
			tailDiff += a[i + 2]; tailDiff -= a[i + 1];
			tailDiffMax = max(tailDiffMax, tailDiff);
			res = max(res, sum + tailDiffMax);
		}
	}
	else {
		//Even
		int64_t sum = 0;
		for (size_t i = 0; i < n; i += 2) sum += a[i];
		res = sum;
		for (int i = n - 1; i >= 0; i -= 2)
		{
			sum += a[i]; sum -= a[i - 1];
			res = max(res, sum);
		}
	}
	sprint(res);
}


Measured memory_bytes: 2288
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(container) container.begin(), container.end()
#define debug(var) std::cout << #var << " : " << var;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;


int main(){


	int N, X; std::cin >> N >> X;
	std::vector<int> m(N);
	int sum = 0;
	int ans = N;
	rep(i, N){
		std::cin >> m[i];
		sum += m[i];
	}
	X -= sum;
	std::sort(all(m));

	ans += (X / m[0]);
	std::cout << ans;


	return 0;
}


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


int main(){
  int k,x;
  cin >> k >> x;
  if (x <= 500*k){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,K=map(int,input().split())
cnt=0
for b in range(1,N+1):
    cnt+=max(0,b-K)*(N//b)
    cnt+=max(0,N%b-K+1)
    if K==0:
        cnt-=1
print(cnt)

"""data = input()
data = data.split(" ")
n = int(data[0])
k = int(data[1])
sum = 0
for b in range(1, n+1):
    sum += (n//b*max(0,b-k)+max(0,n%b-k+1))
if k == 0: sum-=n
print(sum)"""


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

#define MAXN (5010)
#define MAXM (210)
#define MAXB (14)
#define ll long long

int n, m;
ll a[MAXN], imos[MAXN][MAXN];
int b[MAXN][MAXM];
std::pair<int, int> seg[1 << MAXB + 1]; //

void build_tree(int j){
	memset(seg, 0, sizeof(seg));
	for(int i = (1 << MAXB); i < (1 << MAXB) + n; ++ i){
		seg[i] = {b[i - (1 << MAXB) + 1][j], i - (1 << MAXB) + 1};
	}
	for(int i = (1 << MAXB) - 1; i; -- i){
		seg[i] = std::max(seg[i << 1], seg[(i << 1) + 1]);
	}
}

std::pair<int, int> query_tree(int l, int r){
	std::pair<int, int> ret = {0, 0};
	l += (1 << MAXB) - 1;
	r += (1 << MAXB);
	for( ; l < r; l >>= 1, r >>= 1){
	    if(l & 1){
		    ret = std::max(ret, seg[l ++]);
		}
		if(r & 1){
			ret = std::max(ret, seg[-- r]);
		}
	}
	return ret;
}

void solve(int l, int r){
	if(l > r) return;
	std::pair<int, int> p = query_tree(l, r);
	int x = p.first, sit = p.second;
	imos[l][sit] += x;
	imos[l][r + 1] -= x;
	imos[sit + 1][sit] -= x;
	imos[sit + 1][r + 1] += x; 
	solve(l, sit - 1);
	solve(sit + 1, r);
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 2; i <= n; ++ i){
		scanf("%lld", a + i);
		a[i] += a[i - 1];
	}
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= m; ++ j){
			scanf("%d", &b[i][j]);
		}
	}
	for(int j = 1; j <= m; ++ j){
		build_tree(j);
		solve(1, n);
	}
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= n; ++ j){
			imos[i][j] += imos[i][j - 1];
		}
	}
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= n; ++ j){
			imos[i][j] += imos[i - 1][j];
		}
	}
	ll ans = 0;
	for(int i = 1; i <= n; ++ i){
		for(int j = i; j <= n; ++ j){
			ans = std::max(ans, imos[i][j] - (a[j] - a[i]));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 200320
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int dx[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
int dy[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
const ll MOD = 1000000007;
const ll INF = 1000000000;
const int MAX = 10000000;


int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++){
        string s = to_string(i);
        string t;
        for (int j = 4; j >= 0; j--){
            t += s[j];
        }
        if (s == t) ans++;
    }

    cout << ans << endl;
   
}

Measured memory_bytes: 256
#include<stdio.h>
#define INF 10000000
typedef struct{
	short to,cost,time;
}edge;
int n,m;
int i,j,k;
int p,q,r;
edge e[100][3000];
int ce[100];
bool used[100];
int d[100];

int min(int a,int b){return a<b?a:b;}

int solve(int p,int q,int r){
	int l;
	for(l=0;l<m;l++){
		used[l]=false;
		d[l]=INF;
	}
	d[p]=0;
	int next;
	while(1){
		next=-1;
		for(l=0;l<m;l++){
			if(!used[l]&&(next==-1||d[next]>d[l]))next=l;
		}
		if(next==-1)break;
		used[next]=true;
		for(l=0;l<ce[next];l++){
			if(r==0)d[e[next][l].to]=min(d[e[next][l].to],d[next]+e[next][l].cost);
			if(r==1)d[e[next][l].to]=min(d[e[next][l].to],d[next]+e[next][l].time);
		}
	}
	return d[q];
}

int main(){
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)return 0;
		for(i=0;i<m;i++)ce[i]=0;
		for(i=0;i<n;i++){
			int a,b,cost,time;
			scanf("%d %d %d %d",&a,&b,&cost,&time);
			e[a-1][ce[a-1]].to=b-1;
			e[a-1][ce[a-1]].cost=cost;
			e[a-1][ce[a-1]].time=time;
			e[b-1][ce[b-1]].to=a-1;
			e[b-1][ce[b-1]].cost=cost;
			e[b-1][ce[b-1]].time=time;
			ce[a-1]++;
			ce[b-1]++;
		}
		scanf("%d",&k);
		for(i=0;i<k;i++){
			scanf("%d %d %d",&p,&q,&r);
			printf("%d\n",solve(p-1,q-1,r));
		}
	}
}

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

using namespace std;

void lcs(std::string str1, std::string str2){

  int l1 = str1.size();
  int l2 = str2.size();

  int mat[l1+1][l2+1];

  for(int i=0; i<=l1; i++){
    for(int j=0; j<=l2; j++){
      if(i==0 || j==0)
      mat[i][j]=0;

      else if (str1[i-1]==str2[j-1]) {
        mat[i][j] = mat[i-1][j-1] +1;
        /* code */
      }
      else
      mat[i][j] = max(mat[i-1][j], mat[i][j-1]);
    }
  }

//return mat[l1][l2];

int index = mat[l1][l2];
//std::cout << "index " <<index << '\n';

char sub_seq[index+1];

sub_seq[index]='\0';

int i=l1, j=l2;

while (i>0 && j>0) {

  if(str1[i-1]==str2[j-1]){
    sub_seq[index-1]=str1[i-1];
    i--;j--;index--;
  }

  else if (mat[i-1][j]>mat[i][j-1]) {
    /* code */i--;
  }

  else
  j--;
}

std::cout<<sub_seq<< '\n';
}

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

///  string str1 = "AGGTAB";
///  std::string str2 = "GXTXAYB";
string str1,str2;

std::cin >> str1>>str2;

  ///int seq = ///
  lcs(str1, str2);

  //std::cout << seq << '\n';
  return 0;
}


Measured memory_bytes: 35456
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[]
D.append(0)
for i in range(1,N+1):
  D.append(D[i-1]+L[i-1])
s=0
for j in range(0,N+1):
  if D[j]<=X:
    s+=1
print(s)

Measured memory_bytes: 3060