akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
int gcd(int a,int b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
int prime(int a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(int i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int pow(int x,int y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
  int N,a;
  cin>>N;
  unordered_map<int,int> mp;
  vector<int> vec(N);
  for(int h=0;h<N;h++){
    cin>>a;
    vec.at(h)=a;
    int A=a;
    if(a==2){
      mp[2]=max(mp[2],1);
    }
    if(a==3){
      mp[3]=max(mp[3],1);
    }
    for(int i=2;i*i<=A;i++){
      if(prime(i)==1){
        int j=0;
        while(a%i==0){
          a/=i;
          j++;
        }
        mp[i]=max(mp[i],j);
      }
      if(a==1){break;}
    }
    if(a!=1){mp[a]=max(mp[a],1);}
  }
  int ans=0;
  unordered_map<int,int> mpcopy=mp;
  for(int i=0;i<N;i++){
    ll rock=1;
    int a=vec.at(i);
    int A=a;
    if(a==2){
      mp[2]=max(mp[2],1);
    }
    if(a==3){
      mp[3]=max(mp[3],1);
    }
    for(int i=2;i*i<=A;i++){
      if(prime(i)==1){
        while(a%i==0){
          a/=i;
          mp[i]--;
        }
      }
      if(a==1){break;}
    }
    if(a!=1){mp[a]--;}
    for(auto itr=mp.begin();itr!=mp.end();itr++){
      rock*=pow(itr->first,itr->second);
      rock%=MOD;
    }
    ans+=rock;
    ans%=MOD;
    mp=mpcopy;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4480
import qualified Data.ByteString.Char8 as B
import Data.Maybe

main :: IO ()
main = do
  [a, b, c, x] <- map (fst . fromJust . B.readInt) . B.words <$> B.getContents
  print $ length $ filter (== x) $ total <$> [0..a] <*> [0..b] <*> [0..c]
    where total u v w = 500*u + 100*v + 50*w

Measured memory_bytes: 380
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())-1
    st=[]
    n=26
    for i in range(1,1000000):
        st.append(chr(N%n+ord("a")))
        N=int(N//n)
        if N==0:
            break
        N-=1
    st=st[::-1]
    print("".join(st))
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 9184
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
int main()
{
    int n,q;
    cin>>n>>q;
    queue<int> que[n];
    int tp1,tp2,a;
    while(q--){
        cin>>tp1;
        switch(tp1){
        case 0:
            cin>>tp2>>a;
            que[tp2].push(a);
            break;
        case 1:
            cin>>tp2;
            if(!que[tp2].empty())cout<<que[tp2].front()<<"\n";
            break;
        case 2:
            cin>>tp2;
            if(!que[tp2].empty())que[tp2].pop();
            break;
        }
    }
}

//list<int> lit;
//list<int>::iterator it;
//int main()
//{
//    lit.clear();
//    int t,tp,a;
//    it=lit.begin();
//    cin>>t;
//    while(t--){
//        cin>>tp;
//        switch(tp){
//        case 0:
//            cin>>a;
//            lit.insert(it,a);
//            break;
//    case 1:
//            cin>>a;
//            if(a<0){
//                while(a++){
//                    if(it!=lit.end())it++;
//                }
//            }
//            else if(a>0){
//                while(a--){
//                    if(it!=lit.begin())it--;
//                }
//            }
//        break;
//    case 2:
//        lit.erase(--it);
//        break;
//        }
//    }
//    lit.reverse();
//    for(it=lit.begin();it!=lit.end();it++){
//
//        cout<<*it<<"\n";
//    }
//}



Measured memory_bytes: 4372
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;

    auto dp = make_v<LL>(s.size()+1, 13);
    dp[0][0] = 1;
    REP(i, s.size())
    {
        REP(j, 13)
        {
            if(s[i] == '?') REP(k, 10) (dp[i+1][(j * 10 + k) % 13] += dp[i][j]) %= MOD;
            else (dp[i+1][(j * 10 + (int)(s[i] - '0')) % 13] += dp[i][j]) %= MOD;
        }
    }

    cout << dp[s.size()][5] << endl;
}

Measured memory_bytes: 13648
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    vvi A(3, vi(3));
    REP(i, 3)
    {
        REP(j, 3)
        {
            cin >> A[i][j];
        }
    }
    IN(ll, N);
    AIN(ll, b, N);
    FOR(x, b)
    {
        REP(i, 3)
        {
            REP(j, 3)
            {
                if (A[i][j] == x)
                {
                    A[i][j] = 0;
                }
            }
        }
    }
    bool ok = A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0 or A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0;
    REP(i, 3)
    {
        ok |= A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0 or A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0;
    }
    YES(ok);
}

Measured memory_bytes: 256
// I think of what the world could be, A vision of the one I see, A million dreams is all it's gonna take

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

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

    string s;
    cin >> s;
    bool ok = sz(s) %2 == 0;
    for(int i = 0; i < sz(s); i++)
	ok&= (s[i] == ("hi"[i&1]));
    return cout << (ok ? "Yes\n" : "No\n"), 0;
}


Measured memory_bytes: 256
h,w,d=map(int,input().split())
e={}
ans=[0]*(h*w+1)
for i in range(1,h+1):
    a=list(map(int,input().split()))
    for j in range(w):
        e[a[j]]=(i,j+1)
for i in range(d+1,h*w+1):
    x,y=e[i]
    c,v=e[i-d]
    ans[i]=abs(x-c)+abs(y-v)+ans[i-d]

q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l])

Measured memory_bytes: 24652
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
H=[0]*N
for i in range(N):
    H[i]=int(input())
H.sort()
ans=float('inf')
for i in range(N-K+1):
    ans=min(ans,H[i+K-1]-H[i])
print(ans)

Measured memory_bytes: 45144
inpu = input()
back = list(r"\\")[0]

stack = []
area = 0
area_sub = []
for i,symbol in enumerate(inpu):
    if symbol == back:
        stack.append(i)
        #print(back)
    elif symbol == "/":
        #print(symbol)
        if len(stack)>0:
            a = stack.pop()
            area += i-a
            
            area2 = 0
            while len(area_sub) and a<area_sub[-1][0]:
                pre = area_sub.pop()
                area2 += pre[1]
            area2 += i-a 
            area_sub.append([a,area2])
print(area)

#print(" ".join(a for a in area_sub))
if len(area_sub) > 0: 
    print(len(area_sub), end=" ")
    ar = [a[1] for a in area_sub]
    print(*ar)
else:
    print(len(area_sub))


Measured memory_bytes: 6512
//author: zekigurbuz (Zeki Gurbuz) 2019

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef queue<int> qi;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, vi> mvi;
typedef map<int, vpii> mvpii;
typedef priority_queue<int> pqi;
typedef set<int> si;

#define int ll
#define double ld
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rsz resize
#define forn(a,b) for(int a=0;a<b;++a)
#define rep(a,b,c) for(int a=b;a<c;++a)
#define all(x) begin(x), end(x)

const ld PI = 4*atan((ld)1);
const int MOD = 1000000007; //998244353
const ll INF = 1e18;
const int N = 200005;

ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a,ll b){return a / gcd(a, b) * b;}

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
void eval(bool b){cout<<(b?"Yes":"No");}


signed main() {ios_base::sync_with_stdio(0);cin.tie(0);
	
	string s; cin >> s;
	bool w = 1;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			w &= s[i] == 'R' || s[i] == 'U' || s[i] == 'D';
		}
		else {
			w &= s[i] == 'L' || s[i] == 'U' || s[i] == 'D';
		}
	}
	eval(w);
	
return 0;}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


const int MAX = 1000000;
int cal(int n) { return n*(n+1)*(n+2)/6; }
void dpru(int* dp, const vector<int>& tet)
{
	for (int i = 0; i <= MAX; ++i)
		dp[i] = 1 << 28;
	dp[0] = 0;
	for (int i = 1; i <= MAX; ++i)
		for (int j = 0; j < tet.size() && i - tet[j] >= 0; ++j)
			min_swap(dp[i], dp[i - tet[j]] + 1);
}
int main()
{
	vector<int> tetra, odd_tetra;
	for (int i = 1; cal(i) <= MAX; ++i)
	{
		tetra.push_back(cal(i));
		if (cal(i) & 1)
			odd_tetra.push_back(cal(i));
	}

	static int min_tet[MAX + 1], min_odd_tet[MAX + 1];
	dpru(min_tet, tetra);
	dpru(min_odd_tet, odd_tetra);

	int n;
	while (scanf("%d", &n), n)
		printf("%d %d\n", min_tet[n], min_odd_tet[n]);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, l;

    cin >> n >> l;

    vector<string> words;
    string temp_word;

    for(int i=0; i<n; i++){
        cin >> temp_word;
        words.push_back(temp_word);
    }

    sort(words.begin(), words.end());

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




    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    int t = n-1;
    rep(i,n) {
        int lim = 2;
        if (i==0) lim = 1;
        rep(j,lim) {
            if (t>0) {
                ans += a[i];
                t--;
            }
        }
    }
    cout << ans << "\n";
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    while (cin >> t && t) {
        int n;
        cin >> n;
        int time = 0;
        for (int i = 0; i < n; ++i) {
            int s, f;
            cin >> s >> f;
            time += f - s;
        }
        if (time >= t) {
            cout << "OK" << '\n';
        } else {
            cout << t - time << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    lint a, b, k;
    cin >> a >> b >> k;
    lint mi = min(a, k);
    a -= mi;
    k -= mi;
    b -= min(b, k);
    cout << a << " " << b << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n;
    cin>>n;
    long long a[n];
    rep(i,n){
        cin>>a[i];
    }
    int r=0,l=0;
    int b=1;
    long long now=a[0];
    long long s=a[0];
    long long ans=1;
    
    while(r<n-1 or b==0){
        if (b==1){//now==sの時
            r+=1;
            now=s^a[r];
            s+=a[r]; 
            if (now==s){
                ans+=r-l+1;             
            }
            else{             
                b=0;
            } 
        }
        else{
            now^=a[l];
            s-=a[l];
            if (now==s){
                b=1;
                ans+=r-l;
            }
            l+=1;
        }


    }
    cout<<ans<<endl;

    return 0;
}  

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include<unordered_map>
#include<unordered_set>

using namespace std;
#define IO                 \
	ios::sync_with_stdio(0); \
cin.tie(0);              \
cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define getcurrtime() \
	cerr << "Time = " << ((double)clock() / CLOCKS_PER_SEC) << endl

#define watch(x) cerr << (#x) << " is " << (x) << endl;

#ifndef LOCAL
#define cerr if(false)cerr
#endif
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll P=1e9+7;
double PI=3.141592653589793;
const int arrn = 2e5 + 1;


void solve(){
	int n,k;
	cin >> n >> k;
	vector<int> cnt(n);
	forn(i,k){
		int d;
		cin >> d;
		while(d--){
			int ind;cin >> ind;
			cnt[ind-1]++;
		}
	}
	int ans=0;
	forn(i,n) ans+=(cnt[i]==0);
	cout << ans;
}

int main() {
	IO;
	int T=1;
//	cin >> T;
	forn(c,T){
		solve();
	}
}



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

vector<int>a, b, c, d;
int n, m, q;
int an = 0;
void dfs(vector<int>r) {
	if (r.size() == n + 1) {
		int ans = 0;
		rep(j, q) {
			if (r[b[j]] - r[a[j]] == c[j])ans += d[j];
		}
		an = max(an, ans);
		return;
	}
	r.push_back(r.back());
	while (r.back() <= m) {
		dfs(r);
		r.back()++;
	}
}
int main() {
	cin >> n >> m >> q;
	a = b = c = d = vector<int>(q);
	rep(i, q)cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(vector<int>(1, 1));
	cout << an;
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

struct Node
{
    int parent;
    int size;
    int depth;
};

int a[100'000];
int b[100'000];

int64_t result[100'000];

Node nodes[100'000];

int findRoot(const int idx)
{
    int curr = idx;
    while (curr != nodes[curr].parent)
    {
        curr = nodes[curr].parent;
    }
    return curr;
}

void mergeSet(const int r0, const int r1)
{
    if (r0 == r1)
    {
        throw runtime_error("r0 and r1 must be different");
    }
    if (nodes[r0].depth < nodes[r1].depth)
    {
        nodes[r0].parent = r1;
        nodes[r1].size += nodes[r0].size;
    }
    else if (nodes[r0].depth > nodes[r1].depth)
    {
        nodes[r1].parent = r0;
        nodes[r0].size += nodes[r1].size;
    }
    else
    {
        nodes[r0].parent = r1;
        nodes[r1].size += nodes[r0].size;
        nodes[r1].depth++;
    }
}

int main()
{
    int64_t n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    for (int i = 0; i < n; i++)
    {
        nodes[i].parent = i;
        nodes[i].size = 1;
        nodes[i].depth = 0;
    }

    int64_t unconnected = n * (n - 1LL) / 2LL;
    for (int i = m - 1; i >= 0; i--)
    {
        result[i] = unconnected;

        int va = a[i];
        int vb = b[i];
        int ra = findRoot(va);
        int rb = findRoot(vb);

        if (ra == rb)
        {
            continue;
        }

        int64_t sizeA = nodes[ra].size;
        int64_t sizeB = nodes[rb].size;

        mergeSet(ra, rb);
        int newRoot = findRoot(ra);
        int64_t newSize = nodes[newRoot].size;

        unconnected += sizeA * (sizeA - 1LL) / 2LL;
        unconnected += sizeB * (sizeB - 1LL) / 2LL;
        unconnected -= newSize * (newSize - 1LL) / 2LL;

        if (unconnected < 0)
        {
            throw runtime_error("unconnected must be non-negative");
        }
    }

    if (unconnected != 0)
    {
        throw runtime_error("unconnected must be 0 after processing");
    }

    for (int i = 0; i < m; i++)
    {
        cout << result[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int N,M,A[MAXN];
int main()
{
	cin>>N>>M;
	for (int i=1;i<=N;++i) scanf("%d",&A[i]);
	sort(A+1,A+1+N);
	M=max(0,N-M);
	long long sum=0;
	for (int i=1;i<=M;++i) sum+=A[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
n1, n2 = [int(i) for i in input().split()]

s1  = float(0)
for i1 in range(n1):
    r1 = (i1 + 1)
    c1 = 1
    if n2 <= r1:
        s1 += (1/n1)
        continue

    while True:
        r1 *= 2
        c1 = c1 * (1/2)
        if n2 <= r1:
            s1 += ((1/n1)*c1)
            break

print('{:.12g}'.format(s1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;
const int INF = 1e18;

//Graph
struct edge
{
    int to;
    int cost;
};
using Graph = vector<vector<edge>>;

Graph G;
struct UnionFind
{
    vector<int> data;
    void init(int n) { data.assign(n, -1); }
    bool unionSet(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
};

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    rep(i, m)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        UnionFind uf;
        uf.init(n);
        for (int j = 0; j < m; j++)
        {
            if (i == j)
                continue;
            uf.unionSet(a[j], b[j]);
        }

        bool isOK = true;
        rep(x, n)
        {
            rep(y, n)
            {
                if (x == y)
                    continue;
                if (x < y)
                    continue;
                if (!uf.findSet(x, y))
                    isOK = false;
            }
        }
        if (isOK == false)
            ans++;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] a = new int[N + 1];
    for (int i = 0; i < N; i++) a[i + 1] = scanner.nextInt();

    for (int i = 1; i <= N; i++) {
      a[i] += a[i - 1];
      a[i] %= K;
    }
    for (int i = 1; i <= N; i++) {
      a[i] -= i % K;
      if (a[i] < 0) a[i] += K;
    }

    long count = 0;
    HashMap<Integer, Integer> freq = new HashMap<>();
    for (int i = 0; i <= N; i++) {
      count += freq.getOrDefault(a[i], 0);
      freq.put(a[i], freq.getOrDefault(a[i], 0) + 1);
      if (i >= K - 1) freq.put(a[i - K + 1], freq.get(a[i - K + 1]) - 1);
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 93164
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

//-----------------------------------------------
#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 1000 * 1000 + 5;
const ll mod = 1000000007;
const ll INF = 1000000000 * 1ll * 1000000000 + 500000;
const ld pi = acosl(-1.0);

ll ans, n;

ll bpw(ll a, ll n) {
    return (n == 0 ? 1 : (n % 2 == 1 ? a * bpw(a, n - 1) % mod : bpw(a * a % mod, n >> 1)));
}

ll C(ll n, ll k) {
    ll ans = 1;
    for (int i = n - k + 1; i <= n; i++) {
        ans = (ans * i) % mod;
    }
    for (int i = 1; i <= k; i++) {
        ans = (ans * bpw(i, mod - 2)) % mod;
    }
    return ans;
}

int S;

void input() {
    cin >> S;
}

// x_1 + x_2 + x_3 + ... + x_n = S
// C(S + n - 1, n - 1)
void solve(int testId) {
    ll ans = 0;
    for (int cnt = 1; cnt < S; cnt++) {
        if (cnt * 3 <= S) {
            int S_ = S - cnt * 3;
            ans = (ans + C(S_ + cnt - 1, cnt - 1)) % mod;
        }
    }
    cout << ans << endl;
}

int main() {
    // freopen("test", "r", stdin);
    int testcases = 1;
    // scanf("%d", &testcases);
    for(int testId = 1; testId <= testcases; testId++) {
        input();
        solve(testId);
    }
    return 0;
}


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

using namespace std;

int main(){

    string s;
    int cnt = 0;

    cin >> s;

    for(int i = 0; i<s.size(); i++){
        if(s[i] == '1'){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int arr[123];
int main(){
    //~ freopen("file.in", "r", stdin);
	for(int i=0;i<3;i++)
		cin>>arr[i];
		int ans=INF;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(i!=j and j!=k and i!=k)
					umin(ans,abs(arr[i]-arr[j])+abs(arr[j]-arr[k]));
				cout<<ans<<endl;	
	return 0;
}
 

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

struct Point {
  long long x;
  long long y;
  long long z;
};

int sign(int x) { return x == 0 ? -1 : 1; }

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

  int N, M;
  cin >> N >> M;
  vector<Point> v(N);
  for (int i = 0; i < N; ++i) cin >> v[i].x >> v[i].y >> v[i].z;

  long long ans = LLONG_MIN;
  for (int i = 0; i < 8; ++i) {
    const int a = sign(i & 0x1);
    const int b = sign((i >> 1) & 0x1);
    const int c = sign((i >> 2) & 0x1);
    sort(v.begin(), v.end(), [a, b, c](const Point& lhs, const Point& rhs) {
      return a * lhs.x + b * lhs.y + c * lhs.z >
             a * rhs.x + b * rhs.y + c * rhs.z;
    });
    long long x = 0, y = 0, z = 0;
    for (int i = 0; i < M; ++i) {
      x += v[i].x;
      y += v[i].y;
      z += v[i].z;
    }
    ans = max(ans, abs(x) + abs(y) + abs(z));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int K = Integer.parseInt(stdin.next());
		int X = Integer.parseInt(stdin.next());
		
		int i;
		int j;
		
		for(i=0;i<K-1;i++) {
			if(X-i <= -1000000) break;
		}
		for(j=0;j<K-1;j++) {
			if(X+j > 1000000) break;
		}

		for(int z=X-i;z<=X+j;z++) {
			out.print(z+" ");
		}
		out.flush();
	}

	
}

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <algorithm>

// Definitions
#define MAXN 
#define elif else if
typedef long long int64;
typedef long double num128;
typedef unsigned long long uint64;

#define PUTLINE printf("[%d] current line.\n", __LINE__)
#define STARTFUNC printf("[%s] function start.\n", __FUNCTION__)
#define File(s) freopen(#s".in", "r", stdin), freopen(#s".out","w", stdout)

// Improve the speed of read-in.
inline bool IsNum(char x) { return ('0' <= x) && (x <= '9'); }
inline int64 ReadNum() {
  int64 sign = 1, val = 0; char tmp = getchar();
  while (!IsNum(tmp)) { if (tmp == '-') {sign = -sign;} tmp = getchar(); }
  while (IsNum(tmp)) { val = val * 10 + tmp - 48; tmp = getchar(); }
  return val * sign;
}

// Variables
int d, t, s;

// Functions
inline void Initialize(bool prgmsta) {
  if (!prgmsta) {
    
  } else {
    
  }
}
inline void Process() {
  
}
inline void ReadIn() {
  d = ReadNum(),
  t = ReadNum(),
  s = ReadNum();
}
inline void PrintAns() {
  if (d <= t * s)
    puts("Yes");
  else
    puts("No");
}

int main() {
  #ifndef ONLINE_JUDGE
    File(data);
  #endif
  Initialize(0);
  ReadIn();
  Initialize(1);
  Process();
  PrintAns();
  return 0;
}
/*

*/


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;

int main() {
  int n;
  vector<int> a(1000);
  cin >> n;
  rep (i, n) {
    cin >> a.at(i);
  }
  rep (i, n) {
    if (a.at(i) % 2 == 0 && a.at(i) % 3 != 0 && a.at(i) % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  
  cout << "APPROVED" << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

// change minimumのこと
// a>bならばaにbを代入し、trueを返す
// 他の場合はfalseを返す
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

int main() {
int n,k;
cin >> n >> k;
long long dp[n];
int h[n];
for(int i = 0; i < n; i++) {
  cin >> h[i];
  dp[i] = INF;
}
dp[0] = 0;
for(int i = 0; i < n; i++) {
  for(int j = 1; j <= k; j++) {
    if(i+j <= n-1) {
      chmin(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
    }
  }
}
cout << dp[n-1] << endl;
return 0;
}

Measured memory_bytes: 1408
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int A,B;
	cin >> A >> B;
	if( A+B >= 10 ){
		cout << "error" << endl;
	}else{
		cout << A+B << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
  string S; cin >> S;
  int N=S.size(), c[N], d[2]={0,0};
  //dr 偶数/奇数番目のr dlも然り
  for(int i=0; i<N; i++) c[i] = 0;
  d[0]++; int r=0;
  for(int i=1; i<N; i++) {
    if (S[i]=='L'){
      if (r==i-1){
        c[r] += d[r%2];
        c[r+1] += d[(r+1)%2] + 1;
        d[0]=0; d[1]=0;
      } else {
        int t=i-r;
        c[r+t%2]++;
      }
    } else {
      d[i%2]++; r=i;
    }
    //for(int i=0; i<N; i++) cout << c[i] << " "; cout <<"@"<<r<< endl;
  }
  for(int i=0; i<N; i++) cout << c[i] << " ";
}

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

long int score[11][2];
int main(){
  int N;
  int D4 = 0,D7 = 0;
  string ans = "No";

  cin >>N;

  while (N - D4 >= 0) {
    if((N-D4) % 7 == 0)ans = "Yes";
    D4 += 4;
  }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='a'){
            a++;
        }else if(s[i]=='b'){
            b++;
        }else{
            c++;
        }
    }
    if(a==1&b==1&c==1){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var AP = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine((AP[0]*3+AP[1])/2);
        }
    }
}


Measured memory_bytes: 28076
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		long[] A = new long[N];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
		}
		long ans = 0;
		for(var i=1;i<N;i++){
			if(A[i] == A[i-1]){
				ans += 1;
				A[i] = 10000;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include <iostream>


using namespace std;
int main(){

    int n,b;
    cin>>n>>b;


    if(n>=13)
    {
        cout<<b;

    }
   else if (n>=6 && n<=12)
    {
    cout<<b/2;
   }
   else
    cout<<0;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  #define ll  long long int
  #define N 51
  #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
  #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
  #define po pop_back
  #define pb push_back
  #define lb lower_bound
  #define fi first
  #define se second
  #define debug(x) cout << #x << " = " << x << endl
  #define ub upper_bound
  #define ibs ios_base::sync_with_stdio(false)
  #define cti cin.tie(0)
  #define all(x) x.begin(),x.end()
  #define PI 3.14159265
  #define cot cout.tie(0)
  using namespace std;
    /**
      * @author :: Sawlani
      *
      */
      int main()
      {
          ll n,m;
          cin >> n >>  m;

           ll a[n+1]={0};

           ll pen[n+1]={0};
           ll ac=0;
               bool check[n+1]={false};

           f(i,1,m)
           {
               ll x;string j;
               cin >> x >>  j;


               if(a[x]==0&&j=="AC")
               {
                  ac++;
                  a[x]=1;
                  check[x]=true;
               }
               else if(a[x]==0&&j=="WA")
               {
                   pen[x]++;
               }
            }
            ll res=0;
            f(i,1,n)
            {
                if(check[i])
                    res+=pen[i];

            }

            cout << ac <<  " " << res;
}



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

using namespace std;
typedef long long ll;

#define MAX 100001
int A[MAX];
vector<int> v[MAX];

void dfs(int root, int parent) {
    if(v[root].size() == 1) return;

    ll mx = -1, sum = -A[root];
    for(int vv : v[root]) {
        if(vv != parent) {
            dfs(vv, root);
            sum += A[vv];
            if(mx < A[vv]) mx = A[vv];
        }
    }
    if(sum < 0 || A[root] < mx || (A[root]-=sum) < 0) puts("NO"), exit(0);
}

int main(void) {
    int i, n, a, b, root;
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d", A+i);
    if(n == 2) return puts(A[0] == 1 && A[1] == 1 ? "YES" : "NO"), 0;
    for(i=0; i<n-1; i++) {
        scanf("%d%d", &a, &b);
        v[a-1].emplace_back(b-1);
        v[b-1].emplace_back(a-1);
    }
    for(root=0; root<n; root++) {
        if(v[root].size() > 1) {dfs(root, -1); break;}
    }
    puts(A[root] ? "NO" : "YES");
    return 0;

}

Measured memory_bytes: 12800
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
using namespace std;
int ma[1010][1010]; 
int main()
{
	int h,w,i,j,a,b;
	scanf("%d%d%d%d",&h,&w,&a,&b);
	for(i=1;i<=b;i++)
	{
		for(j=1;j<=a;j++)
			ma[i][j]=0;
		for(j=a+1;j<=w;j++)
			ma[i][j]=1;
	}
	for(i=b+1;i<=h;i++)
	{
		for(j=1;j<=a;j++)
			ma[i][j]=1;
		for(j=a+1;j<=w;j++)
			ma[i][j]=0; 
	}
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
			printf("%d",ma[i][j]);
		printf("\n"); 
	}
	return 0;
}

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

int main()
{
	int x[3];
	for(int i=0;i<3;++i)
		cin >> x[i];

	sort(&x[0],&x[3]);

	cout << x[0] << " " << x[1] << " " << x[2] << endl;
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}


int main(){
    ll N; cin >> N;
    vector<ll> A(N+1);
    rep1(i,N) cin >> A[i];
    
    map<ll,ll> ls;
    vector<ll> ans(N+1);
    
    for(ll i = N; i >= 1; i--) {
        vector<ll> ret;
        for(ll j = 1; j * j <= i; j++) {
            if(i % j == 0) {
            ret.push_back(j);
            if(j * j != i) ret.push_back(i / j);
            }
        }
        
        if(!ls.count(i)) ans[i] = A[i];
        else ans[i] = abs((ls[i]%2)-A[i]); 
        rep(j,sz(ret)) ls[ret[j]]+=ans[i];
    }
    
    ll M = 0;
    rep1(i,N) M += ans[i];
    
    pr(M);
    rep1(i,N) if(ans[i]) cout << i << " ";
    
}

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

int main() {
    ll N;
    double D;
    ll count=0;
    //vector<DP> list;
    cin>>N>>D;
    rep(i,N)
    {
      double X,Y;
      cin>>X>>Y;
      //pair<double,double>tp = make_pair(X, Y);
      /*for(int i=0;i<list.size();i++)
      {
        //cout<<list[i].first<<" "<<list[i].second;
      }*/
      /*if (find(list.begin(), list.end(), tp) != list.end() )
      {
         //cout<<"重複あり"<<endl;
         continue;
      }
      list.push_back(tp);*/
      double t = sqrt(X*X+Y*Y);

      if(t<=D)
        count++;
    }
    cout<<count<<endl;
    return 0;
}

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

// main.cpp

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::vector<std::int_fast64_t> p;
  p.reserve(n);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), n, std::back_inserter(p));

  std::int_fast64_t answer = 0;
  for (std::int_fast64_t i = 1; i < n - 1; ++i) {
    if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1])) ++answer;
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>


int descending_compare(const void *a, const void *b) {
	if (*(int*)a > *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

int ascending_compare(const void *a, const void *b) {
	if (*(int*)a < *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y) {
	if (y == 0) {
		return x;
	}
	else if (x > y) {
		return gcd(y, x % y);
	}
	else {
		return gcd(x, y % x);
	}
}



long long factorial(int x) {
	long long rtn = 1;
	int i;
	for (i = x; i > 1; i--) {
		rtn = (rtn*i);
	}
	return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

int main(void) {
	char c;
	char vowel[10] = "aiueo";
	scanf("%c", &c);
	for (int i = 0; i < 5; i++) {
		if (c == vowel[i]) {
			printf("vowel\n");
			return 0;
		}
	}

	printf("consonant\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int check(string s)
{
    int f=0;
    for(int i=0; i<s.size(); i++)
    {

        if(s[i]!='3'||s[i]!='5'||s[i]!='7')
            {
                return 0;
                f=1;
                break;
            }
    }
    if(f==0)
    return 1;
}
int main()
{
    long n,gcd,i,c=0,k=0;
    string s;
    cin >> s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='0') c++;
        else k++;
    }
    cout<<(min(c,k))*2<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int a[100000];

int main(){
	int n,in;
	cin >> n;
	REP(i,n){
		cin >> in;
		
		if(n%2 == in%2){
			cout << 0 << endl;
			return 0;
		}
		if(in==0 && a[in] >= 1){
			cout << 0 << endl;
			return 0;
		}
		if(a[in] >= 2){
			cout << 0 << endl;
			return 0;
		}else{
			a[in]++;
		}
		
	}
	
	const ll mod = 1000000007;
	ll ans = 1;
	REP(i,n/2){
		ans = (ans*2)%mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3856
'use strict'
function main(inp) {
  inp = inp.trim().split('\n');
  // 必要な変数をそれぞれ格納
  let NandM = inp[0].split(' ').map(x=>x*1);
  let N =NandM[0];
  let M =NandM[1];
  let A = inp[1].split(' ').map(x=>x*1).sort((a,b) => {return b-a });
  let ans = "Yes";
  // 合計値を調べる
  let Sum = A.reduce((a,c) => a+c);
  // Mが条件と一致しているかを精査、ダメならNoを記載する
  for(let i = 0; i < M; i++){
  	if(A[i] < Sum/(4*M)){
    	ans = "No";
    }
  }

  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <cstdio>
#include <algorithm>
using namespace std;
int N,v[50]; double ans;
int main() {
    scanf("%d",&N); for (int i = 0;i < N;i++) scanf("%d",&v[i]); sort(v,v+N);
    ans = v[0]; for (int i = 1;i < N;i++) ans+=v[i],ans/=2;
    printf("%f\n",ans);
}


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

int w, h;
int c[51][51];
int island[51][51];
int ans;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

void dfs(int y, int x, int id) {
    island[y][x] = id;
    rep(i, 8) {
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(nx>=0 && nx<w && ny>=0 && ny<h &&
                c[ny][nx] == 1 && island[ny][nx] != id) {
            dfs(ny, nx, id);
        }
    }
}
    
int main(void){
    while(cin >> w >> h && w) {
        rep(y, h) rep(x, w) cin >> c[y][x];
        ans = 0;
        memset(island, -1, sizeof(island));
        rep(y, h) {
            rep(x, w) {
                if(c[y][x]==1 && island[y][x]==-1) {
                    dfs(y, x, ans);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int a, b, c;

signed main()
{
  cin >> a >> b >> c;
  int tmp = c-a-b;
  if (tmp <= 0) {
    cout << "No" << endl;
    return 0;
  }

  if (4*a*b < tmp * tmp) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		long[] a = new long[N];
		long[] sum = new long[N];
		
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			if(i == 0) {
				sum[i] = a[i];
			} else {
				sum[i] = sum[i - 1] + a[i];
			}
		}
		
		long min = Math.abs(sum[N - 1] - sum[0] - sum[0]);
		
		for(int i = 1; i < N - 1; i++) {
			long x = sum[i];
			long y = sum[N - 1] - sum[i];
			min = Math.min(min, Math.abs(x - y));
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 85980