akhauriyash/Code-Regression huggingface dataset:
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  string s;
  cin >> s;
  cout << s.substr(0, s.size()-8) << endl;

  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    vector<int> A(N);
    REP (i, N) {
        cin >> A[i];
    }
    SORTR(A);

    priority_queue<PII> q;
    if (N < 3) {
        REP(i,N-1) {
            ans += A[i];
            cout << ans << endl;
            return 0;
        }
    }

    ans = A[0] + A[1];

    q.push({A[1],A[0]});
    q.push({A[2],A[0]});
    q.push({A[2],A[1]});

    int i = 3;

    while (1) {
        PII a = q.top();
        q.pop();
        ans += min(a.first,a.second);
        i++;
        if (i == N) break;
        q.push({A[i-1],a.first});
        q.push({A[i-1],a.second});
    }
    cout << ans << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc173/abc173_d && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc173/abc173_d && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc173/abc173_d && sh shellscripts/submit_cpp.sh
*/


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


int main(){
	int A,B,K;cin>>A>>B>>K;
	set<int> ans;
	for(int i=A,j=0;i<=B && j<K;i++,j++) ans.insert(i);
	for(int i=B,j=0;i>=A && j<K;i--,j++) ans.insert(i);
	for(auto x: ans) cout<<x<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pii(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main()
{    iso;
	 ll n;cin>>n;
	 ll sum=0;
	 for(int i=1;i<=n;i++){
	 	 if(i%3!=0&&i%5!=0){
	 	 	sum+=i;
		  }
	 }
     cout<<sum;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> x(n);
  for (ll i = 0; i < n; ++i) {
    cin >> x[i];
  }

  vector<ll> r;
  vector<ll> l;
  for (ll i = 0; i < n; ++i) {
    if (x[i] < 0) {
      l.push_back(x[i]*-1);
    } else {
      r.push_back(x[i]);
    }
  }
  reverse(l.begin(), l.end());

  ll ans = 1e18;
  k--;
  for (ll ri = k; ri >= 0; --ri) {
    ll li = k-ri;
    if (r.size() <= ri) continue;

    ll d = r[ri];
    if (li > 0) {
      if (l.size() <= li-1) continue;
      d *= 2;
      d += l[li-1];
    }
    ans = min(ans, d);
  }

  for (ll li = k; li >= 0; --li) {
    ll ri = k-li;
    if (l.size() <= li) continue;

    ll d = l[li];
    if (ri > 0) {
      if (r.size() <= ri-1) continue;
      d *= 2;
      d += r[ri-1];
    }
    ans = min(ans, d);
  }

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


Measured memory_bytes: 2424
MOD = 10**9+7
N,  M = map(int, input().split())
a = set()
for i in range(M):
    a.add(int(input()))
stair = [0 for _ in range(N+1)]
stair[0] = 1
if 1 not in a:
    stair[1] = 1

for i in range(2, N+1):
    if i in a:
        stair[i] = 0
    else:
        stair[i] = (stair[i-1] + stair[i-2]) % MOD
print(stair[N])

Measured memory_bytes: 17396
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(void)
{
	double prb=0.0;
	int n, k, i, j;

	cin >> n >> k;
	
	for (i = 1; i <= n; i++)
	{
		if (i >= k)
		{
			prb += (double)1 / n;
			continue;
		}
		
		int tmp = i;
		for (j = 1; ; j++)
		{
			tmp *= 2;
			if (tmp >= k)
			{
				prb += (double)1 / n * pow(0.5, j);
				break;
			}
		}
	}

	printf("%.9lf", prb);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << a*b/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int fpow(int x,int y){
	if(y<0)return 0;
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%mod)
		if(y&1)res=1ll*res*x%mod;
	return res;
}
int main()
{
	int n; cin>>n;
	cout<<(((1ll*fpow(10,n)-2ll*fpow(9,n))%mod+1ll*fpow(8,n))%mod+mod)%mod<<endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	int n,l,r,i;
	char s[200];
	char ch;
	l=r=0;
	cin>>n>>s;

	stack<char> st;

	for(i=0;i<n;i++)
	{
		if(s[i]=='(')
			st.push(s[i]);
		else if(s[i]==')')
		{
			if(!st.empty() && st.top()=='(')
				st.pop();
			else
				st.push(s[i]);
		}
	}

	while(!st.empty())
	{
		ch=st.top();
		st.pop();
		if(ch==')')
			l++;
		if(ch=='(')
			r++;
	}

	while(l--)
		cout<<'(';
	cout<<s;
	while(r--)
		cout<<')';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define mod 1000000007
using namespace std;
LL quickpow(LL a,LL b,LL m)
{
	LL result = 1;
	LL base = a;
	while(b>0)
	{
		if(b&1==1)
		result=(result*base)%m;
		base=(base*base)%m;
		b>>=1;
	}
	return result;
}
LL comp(LL a,LL b,LL p)
{
	if(a<b)return 0;
	if(a==b)return 1;
	if(b>a-b)b=a-b;
	int ans=1,ca=1,cb=1;
	for(LL i=0;i<b;i++)
	{
		ca=(ca*(a-i))%p;
		cb=(cb*(b-i))%p;
	}
	ans=(ca*quickpow(cb,p-2,p))%p;
	return ans;
}
LL lucas(LL n,LL m,LL p)
{
	LL ans=1;
	while(n&&m&&ans)
	{
		ans=(ans*comp(n%p,m%p,p))%p;
		n/=p;
		m/=p;
	}
	return ans;
}
int main()
{
    LL n,a,b;
    cin>>n>>a>>b;
    LL ans=quickpow(2,n,mod)-1;
    ans=(ans+mod-lucas(n,a,mod))%mod;
    ans=(ans+mod-lucas(n,b,mod))%mod;
    cout<<ans;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

char S[20],T[20],U[20];

int A,B;

int main()
{
  cin >>S>>T>>A>>B>>U;
  
  if(strcmp(S,U)==0)
  {
    cout <<A-1 <<" "<< B;
  }
  else
  {
    cout <<A<<" "<<B-1;
  }
  
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#define MAX_N 200000
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> edge;
  map<int, int> map;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      edge.push_back(b);
    }
    if (b == N) {
      map.insert(make_pair(a, N));
    }
  }

  for (auto iter0 = edge.begin(); iter0 != edge.end(); ++iter0) {
    int v = *iter0;
    if(map[v] == N) {
        cout << "POSSIBLE" << endl;
        return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 9976
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main () {
	int a;
	double x, y,c;
	while(cin >> a) {
		if(a == -1) {
			break;
		}
		c = 0.0;
		for(size_t i = 1; i < a; i++) {
			c += acos ( sqrt ( i ) / sqrt ( i + 1 ) );
		}
		cout << sqrt ( a )*cos ( c ) << endl;
		cout << sqrt ( a )*sin ( c ) << endl;
	}
	//cout << acos ( 1 / sqrt ( 2 ) ) *180/M_PI<< endl;
	//getchar ();
	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    
    int N,K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    
    vector<ll> C;
    for (int i = 1; i <= N; i++) {
        ll s = 0;
        rep(j,i) s += a[j];
        int sb = 0,sf = i-1;
        
        C.push_back(s);
        for (int j = sf+1; j < N; j++) {
            s -= a[sb];
            sb++;
            s += a[j];
            
            C.push_back(s);
        }
        
    }
    
    sort(all(C));
    
    
    //rep(i,int(C.size())) cout << C[i] << " ";cout << endl;
    //cout << endl;
    
    
   
    
    
    ll t = 1;
    vector<ll> A;
    vector<vector<ll>> B;
    A.push_back(t);
    B.push_back({});
    for (int i = 1; i < 40; i++) {
        t = t*2;
        A.push_back(t);
        B.push_back({});
        if(t > C.back()) break;
    }
    
    for (int i = 0; i < int(C.size()); i++) {
        for (int k = 0; k < int(A.size()); k++) {
            if((A[k]&C[i]) == A[k]) B[k].push_back(C[i]);
        }
    }
    
    
    for (int k = int(A.size())-1; k >= 0; k--) {
        if(int(B[k].size()) >= K){
            
            ll ans = A[k];
            
            int nn = k;
            vector<ll> E;
            E = B[k];
            while (nn != -1) {
                //cout << " sss " << A[nn] << endl;
                //rep(i,int(E.size())) cout << E[i] << " ";cout << endl;
                
                int nnn = -1;
                vector<vector<ll>> D;
                D.resize(40);
                for (int i = 0; i < int(E.size()); i++) {
                    for (int j = 0; j < int(A.size()); j++) if((E[i]&A[j]) == A[j]) D[j].push_back(E[i]);
                }
                
                for (int i = nn-1; i >= 0; i--) {
                    if(int(D[i].size()) >= K){
                        nn = i;
                        nnn = 1;
                        break;
                    }
                }
                
                if(nnn == -1){ cout << ans << endl; break;}
                else ans += A[nn];
                E = D[nn];
                
            }
            
            
            
            
            break;
        }
    }
    
    
    
    return 0;
}



Measured memory_bytes: 102768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=1e5+5;
ll n, m, l[mxn], r[mxn], cl, cr, ans;
priority_queue<ll>pq_left;
priority_queue<ll, vector<ll>, greater<ll> >pq_right;
int main(){
	scanf("%lld", &n);
	for(ll i=0; i<n; i++){
		scanf("%lld%ld", &l[i], &r[i]);
		if(i==0){
			pq_left.push(l[i]);
			pq_right.push(l[i]);
			cl=cr=0;
			continue;
		}
		ll last=r[i-1]-l[i-1], cur=r[i]-l[i];
		cl-=cur; cr+=last;
		ll lf=pq_left.top()+cl, rg=pq_right.top()+cr;
		if(l[i]<lf){
			ans+=lf-l[i];
			pq_right.push(lf-cr);
			pq_left.push(l[i]-cl);
			pq_left.push(l[i]-cl);
			pq_left.pop();
		}else if(l[i]>rg){
			ans+=l[i]-rg;
			pq_left.push(rg-cl);
			pq_right.push(l[i]-cr);
			pq_right.push(l[i]-cr);
			pq_right.pop();
		}else{
			pq_left.push(l[i]-cl);
			pq_right.push(l[i]-cr);
		}
	}
	printf("%lld\n", ans); return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> T(N);
    ll sum = 0;
    rep(i, N) {
        cin >> T[i];
        sum += T[i];
    }
    int M;
    cin >> M;
    rep(i, M) {
        int p, x;
        cin >> p >> x;
        p--;
        cout << sum - (T[p] - x) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int i,j,k,l,sum,ar[100009],a,n,t,m,br[1000009],b,sum2,cnt,cnt1,cnt2,d,e,f,r,cr[100008];
string s;

int main()
{

        cin>>s;
        for(i=0;i<s.size()/2;i++)
        {
            if(s[i]!=s[s.size()-i-1])
                sum++;
        }
        cout<<sum<<endl;


    return 0;


}




Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int n,y;
double money[1001];
struct DATA{
int name,r,t;
double money;
};
DATA data[1001];

int main(){
	while(1){
		cin>>n;
		if(n==0){break;}
		cin>>y;
		for(int i=0;i<n;i++){
			cin>>data[i].name>>data[i].r>>data[i].t;
			if(data[i].t==1){data[i].money=(1.0+y*data[i].r/100.0);}
			if(data[i].t==2){data[i].money=pow(1.0+data[i].r/100.0,y);}
		}
		for(int i=0;i<n;i++){
			money[i]=data[i].money;
		}
		sort(money,money+n);
		for(int i=0;i<n;i++){
			if(money[n-1]==data[i].money){
				cout<<data[i].name<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1276
W,H,N=map(int,input().split())

a1,a2,a3,a4=0,W,0,H
for i in range(N):
  x,y,a=map(int,input().split())
  if a==1:a1=max(a1,x)
  elif a==2:a2=min(a2,x)
  elif a==3:a3=max(a3,y)
  else:a4=min(a4,y)
    
if a1>=a2 or a3>=a4:
  print(0)
  exit()
if a1>=W or a2<=0 or a3>=H or a4<=0:
  print(0)
  exit()
  
print((a2-a1)*(a4-a3))

Measured memory_bytes: 9212
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())

    def func(x, n):
        if int(x / n):
            return func(int(x / n), n) + str(x % n)
        return str(x % n)

    print(len(func(N, K)))


main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>

int main(void) {
	int a, b;

	std::cin >> a >> b;

	if (b % a == 0) {
		std::cout << a + b << std::endl;
	}
	else {
		std::cout << b - a << std::endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=40;
ll n,x,m;
vvl a,b;

int main(){
	cin>>n>>x>>m;
	a=b=vvl(M,vl(m));
	for(ll i=0;i<m;i++){
		a[0][i]=i;
		b[0][i]=i*i%m;
	}
	for(int i=1;i<M;i++) for(int j=0;j<m;j++){
		b[i][j]=b[i-1][b[i-1][j]];
		a[i][j]=a[i-1][j]+a[i-1][b[i-1][j]];
	}
	ll res=0;
	for(int i=0;i<M;i++) if(n&1LL<<i){
		res+=a[i][x];
		x=b[i][x];
	}
	cout<<res<<endl;
}

Measured memory_bytes: 66816
#include <stdio.h>

int main(void){
	int num;
  	int f = 0;
  	
    if(scanf("%d",&num) == 0);
  
  	if(num / 100 == 7){
     	 f = 1;
    }
  
    num = num % 100;
  
    if(num / 10 == 7){
   	    f = 1; 
    }
  
    num = num % 10;
  
    if(num == 7){
   	    f = 1; 
    }
  
    if(f == 1){
   	    printf("Yes\n"); 
    }else{
   	    printf("No\n"); 
    }
    
	return 0;
}

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

int main() {

  int N;
  cin >> N;

  vector<double> x(N);
  vector<double> y(N);

  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }

  double d = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      double dx = (x[i]- x[j]) * (x[i]- x[j]);
      double dy = (y[i]- y[j]) * (y[i]- y[j]);
      d += sqrt(dx + dy);
    }
  }

  cout << setprecision(14) << d * 2 / N << endl;

}

Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define deb(x) cout << #x << ' ' << x << '\n'
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define per(i,ini) for(int i=ini;i>=0;i--)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;

vector<int> v[N];
set<int> s;
int val[N], ans[N], removed[N];

void dfs(int node, int par)
{
	auto i = s.lower_bound(val[node]);

	if(i != s.end())
	{
		removed[node] = *i;
		s.erase(*i);
	}
	else
	removed[node] = -1;

	s.insert(val[node]);

	ans[node] = (int)s.size();

	for(int i : v[node])
	if(i != par)
	dfs(i, node);

	s.erase(val[node]);

	if(removed[node] != -1)
	s.insert(removed[node]);
}

int main()
{
	int n;
	scn(n);

	rep(i, 1, n+1)
	scn(val[i]);

	rep(i, 1, n)
	{
		int a, b;
		scn(a); scn(b);

		v[a].pb(b); v[b].pb(a);
	}

	dfs(1, -1);

	rep(i, 1, n+1)
	prin(ans[i]);

	return 0;
}

Measured memory_bytes: 31416
let count_ABC str sz =
  let rec iter_count pos rest =
    if pos >= sz - 2
    then rest
    else 
      if String.sub str pos 3 = "ABC"
      then iter_count (pos+1) (rest+1)
      else iter_count (pos+1) rest
  in iter_count 0 0

let () = Scanf.scanf "%d\n %s" @@ fun n s -> Printf.printf "%d\n" @@ count_ABC s n

Measured memory_bytes: 3824
N = gets.chomp.to_i
s = {}
N.times do
	w = gets.chomp
	h = {w.to_sym => 1}
	s.merge!(h){|key, v0, v1|
		v0 + v1
	}
end
M = gets.chomp.to_i
M.times do
	w = gets.chomp
	h = {w.to_sym => -1}
	s.merge!(h){|key, v0, v1|
		v0 + v1
	}
end
p [s.max{ |x, y| x[1] <=> y[1] }[1],0].max

Measured memory_bytes: 3836
n, x = map(int, input().split())

P = [0] * (n + 1)
P[0] = 1
for i in range(1, n + 1):
    P[i] = P[i - 1] * 2 + 1

A = [0] * (n + 1)
A[0] = 1
for i in range(1, n + 1):
    A[i] = A[i - 1] * 2 + 3

#print(P)
#print(A)

def dfs(n, x):
    cnt = 0
    if n == 0:
        return 1
    if x == 1:
        cnt += 0
    elif x <= 1 + A[n - 1]:
        cnt += dfs(n - 1, x - 1)
    elif x == 1 + A[n - 1] + 1:
        cnt += P[n - 1] + 1
    elif 1 + A[n - 1] + 1 < x < 1 + A[n - 1] + 1 + A[n - 1] + 1:
        cnt += P[n - 1] + 1 + dfs(n - 1, x - 1 - A[n - 1] - 1)
    elif x >= 1 + A[n - 1] + 1 + A[n - 1] + 1:
        cnt += P[n - 1] + 1 + P[n - 1]
    return cnt

print(dfs(n, x))    

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
MOD = 2  # type: int

def solve(S, k, p, M, N):
    count = 0
    for sw in range(2**N):
        sw_str = bin(sw)[2:].zfill(N)
        sw_list = list(map(int, list(sw_str)))
        isGood = True
        for i in range(M):
            bsum = 0
            for j in range(k[i]):
                bsum += sw_list[S[i][j]]
            if bsum % 2 != p[i]:
                isGood = False
                break
        if isGood:
            count += 1

    print(count)
    return 

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    k = [0] * M
    p = [0] * M
    S = []
    for i in range(M):
        k[i] = int(next(tokens))
        S += [ [int(next(tokens))-1 for j in range(k[i]) ] ]
    for i in range(M):
        p[i] = int(next(tokens))

    solve(S, k, p, M, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	final int L = stdin.nextInt();
	final int A = stdin.nextInt();
	final int B = stdin.nextInt();
	final int C = stdin.nextInt();
	final int D = stdin.nextInt();

	System.out.println( L - Math.max( ( A - 1 ) / C, ( B - 1 ) / D ) - 1);	
    }    
}

Measured memory_bytes: 17160
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

const double PI = 3.1415926535;

bool eq(double a, double b){
   return fabs(a-b) < 1e-8;
}

double angle(double cur, double next){
   double r = cur - next + 2*PI;
   while( r >= 2*PI ) r -= 2*PI;
   return r;
}

double dist(double x1, double y1, double x2, double y2){
   return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

int main(){
   int n;
   double x[400], y[400];
   while( cin >> n && n ){
       for(int i = 0; i < n; i++){
           cin >> x[i] >> y[i];
       }
       double cx = 0, cy = 0, cang = atan2(0,-1);
       double lv, ld, sum = 0.0;
       int ln;
       for(int i = 0; i < n; i++){
           lv = 100, ld = 1000;
           for(int j = 0; j < n; j++){
               if( x[j] < 0 ) continue;
               double ang = angle( cang,
                                   atan2(y[j]-cy, x[j]-cx) );
               if( ang < lv ||
                   ( eq(ang, lv) && dist(cx, cy, x[j],y[j]) < ld ) ){
                   lv = ang; ln = j;
                   ld = dist(cx, cy, x[j], y[j]);
               }
           }
           sum += ld;
           cang = atan2(y[ln]-cy, x[ln]-cx);
           cx = x[ln]; cy = y[ln];
           x[ln] = -1;
       }
       cout << fixed<< setprecision(1) << (int)(sum*10+0.5)/10.0 << endl;
   }
   return 0;
}

Measured memory_bytes: 1376
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


ll n,m;
vll G[100010];
ll color[100010]={};
bool b[100010];



bool dfs(ll s,ll c){
    color[s]=c;
    for(ll t:G[s]){
        if(color[t]==c) return false;
        if(color[t]==0 && !dfs(t,-c)) return  false;
        }
    return true;
}


bool solve(){
    rep(i,n){
        if(color[i]==0){
            if(!dfs(i,1)){
                return false;
            }
        }
    }
    return true;
}

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


    cin>>n>>m;
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    if(dfs(0,1)){
        ll a=0,b=0;
        rep(i,n){
            if(color[i]==1) a++;
            else b++;
        }
        cout<<a*b-m<<endl;
    }
    else{
        cout<<n*(n-1)/2-m<<endl;
    }
    return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<cctype>
#include<cstring>
#include<iostream>
using namespace std;

int main(){
    char T[1001];
    char W[10];
    char temp;
    int len_W=0,len_T=0,count=0;
    scanf("%s",W);
    len_W=strlen(W);
    while(1){
        scanf("%s",T);
        if(strcmp(T,"END_OF_TEXT")==0)break;
        len_T=strlen(T);
        for(int i=0;T[i]!='\0';i++){
            if(isalpha(T[i])){
                if(isupper(T[i])){
                    T[i]=tolower(T[i]);
                }
            }
            if(W[i]==T[i]){
                if((len_W==i+1)&&T[i+1]=='\0'){
                    count++;
                }
            }else{
                break;
            }

        }
    }
    cout<<count<<endl;
}


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

#define int long long
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define fs first
#define sc second
#define mpr make_pair
#define iter iterator
#define all(X) X.begin(),X.end()
#define sau(X) sort(all(X)),X.resize(unique(all(X))-X.begin())
#define exist(X,ele) binary_search(all(X),ele)
#define y0 I_love_Ryougi_Shiki_0
#define y1 I_love_Ryougi_Shiki_1

template<typename T1,typename T2>
ostream& operator << (ostream& out,const pair<T1,T2>& X)
{
	out<<"{"<<X.fs<<","<<X.sc<<"}";
	return out;
}

template<typename T>
ostream& operator << (ostream& out,const vector<T>& X)
{
	for(auto i:X) out<<i<<" ";
	return out;
}

inline void cmin(int& x,int y)
{
	x=min(x,y);
}

inline void cmax(int& x,int y)
{
	x=max(x,y);
}

const int inf=5000000000000000ll;

const char w3[3][3]=
	{	{'i','i','g'},
		{'b','.','g'},
		{'b','n','n'}	};
const char w4[4][4]=
	{	{'l','l','u','r'},
		{'i','i','u','r'},
		{'y','n','a','a'},
		{'y','n','i','i'}	};
const char w5[5][5]=
	{	{'r','r','y','y','o'},
		{'i','k','k','.','o'},
		{'i','.','.','i','u'},
		{'s','.','.','i','u'},
		{'s','i','i','g','g'}	};
const char w7[7][7]=
	{	{'.','f','f','k','k','u','u'},
		{'s','.','a','a','i','i','.'},
		{'s','h','.','.','.','.','f'},
		{'o','h','.','.','.','.','f'},
		{'o','g','.','.','.','.','e'},
		{'n','g','.','.','.','.','e'},
		{'n','.','g','g','n','n','.'}	};

int N;
char ans[1010][1010];

inline void output()
{
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			cout<<ans[i][j];
		}
		cout<<endl;
	}
}

main()
{
	ios::sync_with_stdio(false);
	
	cin>>N;
	if(N<=2)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	
	for(int i=0;i<N;i++) for(int j=0;j<N;j++)
	{
		ans[i][j]='.';
	}
	if(N%3==0)
	{
		for(int i=0;i<N;i++) for(int j=0;j<N;j++)
		{
			ans[i][j]=w3[i%3][j%3];
		}
		output();
		return 0;
	}
	else
	{
		for(int t4=0;t4*4<=N;t4++) for(int t5=0;t5*5<=N;t5++) for(int t7=0;t7*7<=N;t7++)
		{
			if(t4*4+t5*5+t7*7==N)
			{
				for(int k=0;k<t4;k++)
				{
					for(int i=0;i<4;i++) for(int j=0;j<4;j++)
					{
						ans[k*4+i][k*4+j]=w4[i][j];
					}
				}
				for(int k=0;k<t5;k++)
				{
					for(int i=0;i<5;i++) for(int j=0;j<5;j++)
					{
						ans[t4*4+k*5+i][t4*4+k*5+j]=w5[i][j];
					}
				}
				for(int k=0;k<t7;k++)
				{
					for(int i=0;i<7;i++) for(int j=0;j<7;j++)
					{
						ans[t4*4+t5*5+k*7+i][t4*4+t5*5+k*7+j]=w7[i][j];
					}
				}
				output();
				return 0;
			}
		}
	}
}






















Measured memory_bytes: 2176
fn main() {
    let n = read::<usize>();
    let mut v: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut order: Vec<(usize, usize)> = Vec::new();
    for _ in 0..n-1 {
        let ab = read_vec::<usize>();
        let a = ab[0];
        let b = ab[1];
        v[a-1].push(b-1);
        v[b-1].push(a-1);
        order.push((a-1, b-1));
    }

    let mut done: Vec<bool> = vec![false; n];
    let mut stack : Vec<usize> = Vec::new();
    stack.push(0);
    let mut color: Vec<usize> = vec![0; n];
    let mut parent: Vec<usize> = vec![0; n];
    let mut ma = 0;
    while !stack.is_empty() {
        let i = stack.pop().unwrap();
        if done[i] {
            continue;
        }
        done[i] = true;

        let p = parent[i];
        let mut paint = 1;
        for j in v[i].iter() {
            if p == *j { continue; }

            if paint == color[i] {
                paint += 1;
            }
            color[*j] = paint;
            if ma < paint {
                ma = paint;
            }
            paint += 1;
            parent[*j] = i;
            stack.push(*j);
        }
    }

    println!("{}", ma);
    for &(a, b) in order.iter() {
        if parent[a] == b {
            println!("{}", color[a]);
        } else {
            println!("{}", color[b]);
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n;
           cin>>n;
           vin p(n),q(n);
           rep(i,0,n){
            cin>>p[i]; 
           }
           rep(i,0,n)cin>>q[i];
           vin order(n);
           rep(i,0,n)order[i]=i;
           int a=0,b=0;
           int cnt=0;
           do{
             cnt++;
             bool P=true,Q=true;
             rep(i,0,n){
               if(order[i]+1!=p[i])P=0;
               if(order[i]+1!=q[i])Q=0;
             }
             if(P)a=cnt;
             if(Q)b=cnt;
             
             
           }while(next_permutation(all(order)));
                  cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll a, b, k; cin >> a >> b >> k;
    cout << max(0LL, a - k) << " " << max(a + b - k - max(0LL, a - k), 0LL) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;


int main(){

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

    cout << (a <= 8 && b <= 8 ? "Yay!" : ":(");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B == C + D) {
        cout << "Balanced" << endl;
    }
    else if (A + B < C + D) {
        cout << "Right" << endl;
    }
    else {
        cout << "Left" << endl;
    }
}

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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int count = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        if(i * 500 + j * 100 + k * 50 == x){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){

  // f[0]=1, f[1]=1, f[2]=2, f[3]=3,

  ll N;
  cin >> N;
  ll ans = 0;

  if ((N % 2) == 0) { // N is even
    // for (int i=1; i<=18; i++) {
    //   ans = ans + (ll)((ll)N / (ll)(pow(10, i)));
    // }
    // for (int j=1; j<=100; j++) {
    //   for (int i=1; i<=18; i++) {
    //     if ( (ll)pow(5, j) * (ll)pow(10, i) > N ) {
    //       (ll)pow(5, j) * (ll)pow(10, i-1)
    //       ans = ans + (i-1)*j;
    //       cout << "i: " << i << ", j: " << j << endl;
    //       break;
    //     }
    //   }
    // }
    for (int j=1; j<=100; j++) {
      for (int i=1; i<=18; i++) {
        if ( (log((ll)N / (ll)(pow(10, i))) / log(5)) < j ) {
          break;
        }
        // if ( ((ll)(pow(5, j))*(ll)(pow(10, i))) > N ){
        //   break;
        // }
        ans = ans + (ll)((ll)N / ((ll)(pow(5, j))*(ll)(pow(10, i))));
        break;
      }
    }
    ans = ans + (N / 10);
  }
  else{ // N is odd
    ans = 0;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	
	int n, d;
	cin >> n >> d;
	int x[10][10] = {0};

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}

	int ans = 0;
	double tmp = 0;
	double iptr;
	double fraction;

	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			tmp = 0;
			for (int k = 0; k < d; k++) {
				tmp += pow(x[i][k] - x[j][k], 2);
			}
			tmp = sqrt(tmp);
			fraction = modf(tmp, &iptr);
			if (fraction == 0)ans++;
		}

	}
	cout << ans << endl;
}

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

int main(){
    char s[4];
    scanf("%s",s);
    if(strlen(s)==2){
        printf("%s\n",s);
    }else{
        printf("%c%c%c\n",s[2],s[1],s[0]);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<long> pq;
    for (int i=0; i<n; i++) {
        long a;
        cin >> a;
        pq.push(a);
    }
    for (int i=0; i<m; i++) {
        long t = pq.top(); pq.pop();
        pq.push(t / 2);
    }
    long ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1400
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(m);
    int sum=0;
    rep(i,m){
        cin>>a[i];
        sum+=a[i];
    }
    n-=sum;
    if(n<0)n=-1;
    cout<<n<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void)
{
	int K, a, b, c;
	long int sum = 0;

	scanf("%d", &K);
	for (a = 1; a <= K; a++) {
		for (b = 1; b <= K; b++) {
			for (c = 1; c <= K; c++) {
				sum += gcd3(a, b, c);
			}
		}
	}
	printf("%ld", sum);

	return 0;
}

int gcd2(int a, int b) {
	if (b == 0)
		return a;
	return gcd2(b, a % b);
}

int gcd3(int a, int b, int c) {
	return gcd2(gcd2(a, b), c);
}

Measured memory_bytes: 2152
#include <iostream>

using namespace std;

int main()
{
    long long int W,a,b;
    cin>>W>>a>>b;
    if(b>=(a+W)) cout<<b-(a+W);
    else{
        if(a>(b+W)) cout<<a-(b+W);
        else cout<<0;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
/*
6
abcdef
aabbdd

abcdef
abbddd
aabbdd

6
abcdef
aabcde

abcdef
abcdee
abcdde
abccde
abbcde
aabcde
*/

int N;
char S[1000111];
char T[1000111];
int C[1000111];
int off = 0, add = 0;

void MAIN() {
    scanf("%d%s%s", &N, S, T);
    while (N > 0 && S[N-1] == T[N-1]) N--;

    memset(C, 0xc0, sizeof C);
    int pos = N-1;
    int ans = 0;
    for (int i=N-1; i>=0; ) {
	int j=i;
	while (j > 0 && T[j-1] == T[i]) j--;

	// T[j .. i];
	int nxt = min(pos, j);
	while (nxt >= 0 && S[nxt] != T[i]) nxt--;
	if (nxt == -1) {
	    puts("-1");
	    return;
	}

	off++;
	add++;
	for (int k=nxt; k<=pos; k++) C[k+off] = 1 - add;
	for (int k=j; k<=i; k++) amax(ans, C[k+off] + add);

//	REP (z, N) eprintf("%d ", C[z+off] + add);
//	eprintf("\n");

	pos = nxt - 1;
	i = j-1;
    }
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

using namespace std;

long double dp[4000][4000];

int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	dp[0][0] = 1;
	int n = 0;
	cin >> n;
	vector<long double> p(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i];
	}
	for(int i =0 ; i< n; ++i){
		for(int j = 0; j < i+1; ++j){
			dp[i+1][j] += dp[i][j] * (1 - p[i]);
			dp[i+1][j + 1] += dp[i][j] * p[i];
		}
	}
	long double res = 0;
	for(int i = 0;i <= n; ++i){
		if(i > n/2){
			res+=dp[n][i];
		}
	}
	cout << setprecision(10) << res;
	return 0;
}

Measured memory_bytes: 186880
i = list(map(int, input().split()))
count5 = 0
count7 = 0

if i[0] == 5:
    count5 += 1
elif i[0] == 7:
    count7 += 1

if i[1] == 5:
    count5 += 1
elif i[1] == 7:
    count7 += 1

if i[2] == 5:
    count5 += 1
elif i[2] == 7:
    count7 += 1

if count5 == 2 or count7 == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main () {
	int x, ans;

	cin >> x ;

	if ((x >= 1) && (x <= 100)) {
		ans = x * x * x;
	    cout << ans << "\n";
	} else {
		cout << "Input number is too large.\n";
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 1; i <= n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
#define MP make_pair
#define FI first
#define SE second
#define VI vector<int>
#define CLR(x) memset(x, 0, sizeof(x))
#define SZ(x) (x.size())
#ifdef QWERTIER
#define err(x) cerr<<x<<endl;
#else
#define err(x)
#endif

typedef long long LL;

#define MOD 1000000007
LL fPow(LL t, int p) {
  LL ret = 1;
  while (p) {
    if (p&1)ret = ret * t % MOD;
    t = t * t % MOD;
    p >>= 1;
  }
  return ret;
}

#define N 1010
int fact[N], f[N][N], dp[N][N], C[N][N];
void calc() {
  fact[0] = 1;
  for (int i = 1; i <= 1000; i++)
    fact[i] = fact[i-1] * (LL) i % MOD;
  C[0][0] = 1;
  for (int i = 1; i <= 1000; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
      if (i%j!=0)
        continue;
      f[i][j] = fact[i] * fPow(fPow(fact[i/j], j), MOD-2) %MOD* fPow(fact[j], MOD-2) % MOD;
    }
  }
}
int main() {
#ifdef QWERTIER
  freopen("in.txt", "r", stdin);
#endif
  calc();
  int n, a, b, c, d;
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
  dp[a-1][0] = 1;
  for (int i = a; i <= b; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j] = dp[i-1][j];
      for (int k = c; k <= min(d, j / i); k++) {
        dp[i][j] = (dp[i][j] + dp[i-1][j-k*i]*(LL)C[j][k*i]%MOD * (LL)f[k*i][k]) % MOD;
      }
    }
  }
  printf("%d\n", dp[b][n]);
  return 0;
}


Measured memory_bytes: 12160
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
}
#else
#define debug(...)
#endif
// 3
void _main(int tc) {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 3576
# -*- coding: utf-8 -*-
"""
A - Can't Wait for Holiday
https://atcoder.jp/contests/abc146/tasks/abc146_a

"""
import sys


def solve(S):
    return {'SUN': 7, 'MON': 6, 'TUE': 5, 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1}[S]


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
 if(a==5||a==7&&b==5||b==7&&c==5||c==7)
    { 
   if(a==7&&b!=7&&c!=7)
            { printf("YES"); }
  else  if(b==7&&a!=7&&c!=7)
       { printf("YES"); }
 else  if(c==7&&b!=7&&a!=7)
    { printf("YES"); }
      else{ printf("NO");}
        }
    
 else {printf("NO");}
    return 0;
    
}

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

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

  int n,cnt=0;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    if( (i+1)&1  && arr[i]&1 )
     cnt++;
  }
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<math.h>

int main(){
  int i,l,k,j,n,a[101],b[101][101];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&a[i-1],&a[i]);
  }
  
  for(i=1;i<=n;i++)b[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      b[i][j]=INFINITY;
      for(k=i;k<=j-1;k++){
	if(b[i][j]>b[i][k]+b[k+1][j]+a[i-1]*a[k]*a[j])b[i][j]=b[i][k]+b[k+1][j]+a[i-1]*a[k]*a[j];
      }
    }
  }
  printf("%d\n",b[1][n]);
  
  return 0;
}



Measured memory_bytes: 2052