akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int durationof_contests = 365;
const int typeof_contests = 26;

vector<int> penalty(typeof_contests);
vector<vector<int>> prize(durationof_contests, vector<int>(typeof_contests));

vector<int> solvefor(int i, int j, const vector<int> &last_occured) {
  int days = j-i+1;
  // debug(days);
  int possibilities = pow(typeof_contests, days);
  int maxm = INT_MIN;vector<int> ans;
  for(int mask = 0; mask < possibilities;mask++) {
    vector<int> tans;
    int maskc = mask;
    rep(abra, days) {
      tans.pb(maskc % typeof_contests);
      maskc /= typeof_contests;
    }
    // calculate score
    vector<int> last_occured_cpy = last_occured;
    int score = 0;
    rep(day, days) {
      int ctype = tans[day];
      int wday = i + day;
      score += prize[wday][ctype];
      last_occured_cpy[ctype] = wday;
      rep(k, typeof_contests) {
        score -= penalty[k] * (wday - last_occured_cpy[k]);
      }
    }

    // update maximum
    if(score > maxm) {
      maxm = score;
      ans = tans;
    }
  }

  return ans;
}

vector<int> consecutive_days_tolook(int days) {
  // 26^days * 365 * 26
  // debug(days);
  vector<int> ans;
  vector<int> last_occured(typeof_contests, -1);
  for(int i = 0;i - 1 + days < durationof_contests;i++) {
    vector<int> tans = solvefor(i, i+days-1, last_occured); // tans.size() == days
    if(i+days == durationof_contests) {
      for(auto x: tans) ans.pb(x);
      break;
    }

    last_occured[tans[0]] = i;
    ans.pb(tans[0]);
  }
  return ans;
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

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

 cin>>durationof_contests;
 rep(i, typeof_contests) cin>>penalty[i];
 rep(i, durationof_contests) {
   rep(j, typeof_contests) {
     cin >> prize[i][j];
   }
 }

 auto ans = consecutive_days_tolook(3);
 for(auto x: ans) cout << x + 1 << endl;

 return 0;
}


Measured memory_bytes: 4036
nums = list(map(int, input().split()))
N, M = nums[0], nums[1]
A = list(map(int, input().split()))
A = [(-x, x) for x in A]
import heapq
heapq.heapify(A)

for _ in range(M):
    b = heapq.heappop(A)[1]
    b = b // 2
    heapq.heappush(A, (-b, b))

ans = 0
for i in range(N):
    ans += A[i][1]
print(ans)


Measured memory_bytes: 17424
/*
* Author:sam51305
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define mp make_pair
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pb push_back
#define ary array

#define Yes cout << "Yes" <<endl;
#define No cout << "No" << endl;
int main() {
    fastio
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


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

using namespace std;

#define ll long long




void solve() {

	ll n;
	cin >> n;
	for(ll i = (int)sqrt(n); i >= 1; i--) {
		if(n % i == 0) {
			cout << i + n / i - 2 << "\n";
			break;
		}
	}


	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
const int mod = 1000000007;
int n,ans=0;
string s;
int main(){
  cin >> n >> s;
  for (size_t i = 0; i < n; i++) {
    if(s.substr(i,3) == "ABC")ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 14.07.2020 08:56:00
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  int n;
  cin>>n;

  int a[n];
  REP(i,n)cin>>a[i];

  int _gcd=a[0];
  REP(i,n-1)
  {
    _gcd=min(_gcd,gcd(a[i],a[i+1]));
  }

  cout<<_gcd<<endl;

  return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if ((a < c && c < b) || (a>c && c>b))cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
//		package Dynamic;
import java.io.*;
import java.util.*;
class Main{
	static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
    static public void main(String[] args)throws IOException
    {
    	st=new StringTokenizer(br.readLine());
    	int n=i();
    	int ar[]=ari(n);
    	int arr[]=new int[n];
    	System.arraycopy(ar,0,arr,0,n);
    	Arrays.sort(ar);
    	int c=0;
    	for(int x=0;x<n;x++)
    	{
    		if(ar[x]!=arr[x])
    			c++;
    	}
    	if(c==0||c==2)
    		pl("YES");
    	else pl("NO");
    }
    static int i()throws IOException
    {
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	return Integer.parseInt(st.nextToken());
    }
    static long l()throws IOException
    {
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	return Long.parseLong(st.nextToken());
    }
    static String s()throws IOException
    {
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	return st.nextToken();
    }
    static double d()throws IOException
    {
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	return Double.parseDouble(st.nextToken());
    }
    static void p(String p)
    {
    	System.out.print(p);
    }
    static void pl(String pl)
    {
    	System.out.println(pl);
    }
    static void pl()
    {
    	System.out.println();
    }
    static int[] ari(int n)throws IOException
    {
    	int ar[]=new int[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=i();
    	return ar;
    }
    static long[] arl(int n)throws IOException
    {
    	long ar[]=new long[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=l();
    	return ar;
    }
    static String[] ars(int n)throws IOException
    {
    	String ar[]=new String[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=s();
    	return ar;
    }
    static double[] ard(int n)throws IOException
    {
    	double ar[]=new double[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=d();
    	return ar;
    }
    static char[] arc(int n)throws IOException
    {
    	char ar[]=new char[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=st.nextToken().charAt(0);
    	return ar;
    }
    static void pari(int ar[])
    {
    	for(int a:ar)
    		System.out.print(a+" ");
    }
    static void parl(long ar[])
    {
    	for(long a:ar)
    		System.out.print(a+" ");
    }
    static void pars(String ar[])
    {
    	for(String a:ar)
    		System.out.print(a+" ");
    }
    static void pard(double ar[])
    {
    	for(double a:ar)
    		System.out.print(a+" ");
    }
    static void parc(char ar[])
    {
    	for(char a:ar)
    		System.out.print(a+" ");
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;
typedef long long ll;
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9 + 7;

/////////////////////////////////////////////////////////////////////////////////////////////

typedef long long ll;
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main()
{
    ll n, m; cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1)/2 << endl;

    return 0;
}

//Solution* sol = new Solution();
//vector<int> v1 = { 1,2,3,4 };
//vector<vector<int>> v;
//vector<int> p = { 1,0 };
// Solution* sol = new Solution();


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
      	
      	//2z +4(x-z) = y;
		int zz = (4*x) - y;
      	if(zz == 0) {
         System.out.println("Yes");
        }else{
          int z = zz /2;
          int r = zz % 2;
          if (r==0 && z>0) {        
            if(x >= z){
          System.out.println("Yes");
            }else{
              System.out.println("No");
            }
          } else {
          System.out.println("No");
    		}
        }
    }
}

Measured memory_bytes: 35768
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	int n, m;
	cin >> n >> m;
	v64 arr(n, 0);
	ll sum = 0;
	for (int i = 0; i < n; i++)
		cin >> arr[i], sum += arr[i];
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (arr[i] * 4 * m < sum)
			continue;
		cnt++;
	}
	if (cnt >= m)
		cout << "Yes" << ln;
	else
		cout << "No" << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> freq(M + 1, 0);
  for (int i = 0; i < N; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int p;
      cin >> p;
      freq[p]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < M + 1; i++) {
    if (freq[i] == N) {
      ans++;
    }
  }

  cout << ans << endl;

  cout << setprecision(10);
  // Failed to predict input format
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2005;
const int MOD = 1e9 + 7;

int n, k, ans = 0;
int a[N];

int32_t main()
{
	IOS;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(a[i] > a[j])
			{
				int cur = k * (k - 1) / 2;
				cur %= MOD;
				ans += cur;
				if(i < j)
					ans += k;
				ans %= MOD;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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);}
/*
 <url:https://atcoder.jp/contests/abc149/tasks/abc149_b>
 問題文============================================================
 B - Greedy Takahashi
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll A,B,K; cin >> A >> B >> K;
    res = {max(0LL,A-K),max(0LL,B+min(0LL,A-K))};
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<vector<ll>>() << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s,ans,num =1,1,2
for i in range(2, n+1):
  s*=i
l=[]
while s!=1:
  if not s%num:
    l.append(num)
    s//=num
  else:
    num+=1
for i in set(l):
  ans*=l.count(i)+1
print(ans%(10**9+7))
#print(l)

Measured memory_bytes: 3064
import sys, math
sys.setrecursionlimit(10**5 + 10)

def input():
    return sys.stdin.readline()[:-1]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, M, K = map(int,input().split())
    uf = UnionFind(N)
    F = [[] for k in range(N)]
    for k in range(M):
        a, b = map(int,input().split())
        uf.union(a-1,b-1)
        F[a-1].append(b-1)
        F[b-1].append(a-1)
    A = [uf.size(k)-len(F[k])-1 for k in range(N)]
    for k in range(K):
        c, d = map(int,input().split())
        if uf.same(c-1,d-1) == True:
            A[c-1] -= 1
            A[d-1] -= 1
    print(*A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32392
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

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


int main()
{
	ll h,w,n;
	cin >> h >> w >> n;
	
	vector<set<pair<int,int> > > v(10);
	vector<pair<int,int> > node;
	map<pair<int,int>,int> mp;
	
	
	REP(i,n)
	{
		int x,y;
		cin >> x >> y;
		mp[MP(x,y)] = 1;
		node.PB(MP(x,y));
	}
    
	ll ze = 0;
	
	REP(i,n)
	{
		REP(j,9)
		{
			int cou = 0;
			int cx = node[i].FI + dx[j];
			int cy = node[i].SE + dy[j];
			if(cx < 2 || cx > h-1 || cy < 2 || cy > w-1)continue;
			REP(k,9)
			{
				if(mp.find(MP(cx+dx[k],cy+dy[k])) != mp.end())
				{
					cou++;
				}
			}
			v[cou].insert(MP(cx,cy));
		}		
	}
	
	REP(i,9)
	{
		ze += v[i+1].size();
	}
	
	cout << (h-2)*(w-2) - ze << endl;
	REP(i,9)
	{
		cout << v[i+1].size() << endl;
	}
	
	
	return 0;
}

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

map<ll,ll> prime_factor(ll n){
  map<ll,ll> rtn;
  for(ll i=2;i*i<=n;i++){
    while(!(n%i)){
      ++rtn[i];
      n/=i;
    }
  }
  if(n!=1) rtn[n]=1;
  return rtn;
}

int main(){
  ll n,ans=0,ttl=0;cin>>n;
  map<ll,ll> mp=prime_factor(n);
  vector<int> num;

  for(int i=1;i<10;i++){
    ttl+=i;
    num.push_back(ttl);
  }
  for(auto p:mp) for(int i=0;p.second>=num.at(i);i++) ans++;

  cout<<ans<<endl;
}



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

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int>A){
        int sum = 0;
        if(A.size()==n+1){
                int sum = 0;
                rep(i,q){
                        if(A[b[i]]-A[a[i]]==c[i]){
                                sum += d[i];
                        }
                }
                ans = max(sum, ans);
                return;
        }

        A.push_back(A.back());
        while(A.back()<=m){
                dfs(A);
                A.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 << ans << endl;

        return 0;
}



Measured memory_bytes: 3620
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto K = readln.chomp;
    auto D = readln.chomp.to!int;
    auto N = K.length.to!int;

    auto dp = new long[][][](N+1, D, 2);
    dp[0][0][0] = 1;

    foreach (i; 0..N) {
        foreach (j; 0..D) {
            foreach (k; 0..2) {
                int d = 10;
                if (!k) d = K[i] - '0' + 1;
                foreach (x; 0..d) {
                    (dp[i+1][(j+x)%D][k||x<K[i]-'0'] += dp[i][j][k]) %= MOD;
                }
            }
        }
    }

    long ans = (dp[N][0][0] + dp[N][0][1] - 1) % MOD;
    ans = (ans + MOD) % MOD;
    ans.writeln;
}


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

int main(){
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
     
    return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n;
map<int, int> mp[2];

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

	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		mp[i&1][a]++;
	}
	int ma[2][2] = {}, tmp[2][2];
	tmp[0][1] = tmp[1][1] = INF;
	REP(i, 2) {
		for(auto s: mp[i]) {
		    if (s.se > ma[i][0]) {
				ma[i][1] = ma[i][0];
				tmp[i][1] = tmp[i][1];
				ma[i][0] = s.se;
				tmp[i][0] = s.fi;
			}
			else if (s.se > ma[i][1]) {
				ma[i][1] = s.se;
				tmp[i][1] = s.fi;
			}
		}
	}
	int ans = 0;
	if (tmp[0][0] == tmp[1][0]) {
		ans = n - max(ma[0][0] + ma[1][1], ma[0][1] + ma[1][0]);
	}
	else ans = n - ma[0][0] - ma[1][0];

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N+2, 0);
    vector<long long int> dfA(N+1);
    vector<long long int> sdfA(N+2, 0);
    for(int n=1; n<=N; n++) {
        cin >> A[n];
        dfA[n-1] = abs(A[n]-A[n-1]);
        sdfA[n] = dfA[n-1]+sdfA[n-1];
    }
    dfA[N] = abs(A[N+1]-A[N]);
    sdfA[N+1] = sdfA[N]+dfA[N];
    // cout << endl;
    // for(int n=0; n<N+1; n++) {
    //     cout << dfA[n] << " ";
    // }
    // cout << endl;
    // for(int n=0; n<=N+1; n++) {
    //     cout << sdfA[n] << " ";
    // }
    // cout << endl;

    for(int n=0; n<N; n++) {
        long long int ans=0;
        ans += sdfA[N+1]-sdfA[n+2];
        ans += sdfA[n]-sdfA[0];
        
        if((A[n+1]-A[n])*(A[n+2]-A[n+1])<0) {
            ans += abs(dfA[n]-dfA[n+1]);
        } else {
            ans += sdfA[n+2]-sdfA[n];
        }
        cout << ans << endl;
    }


    return 0;
    
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int x, n; cin >> x >> n;
	vector<bool> a(102,0); int p;
	REP(i,n){
		cin >> p;
		a[p]=1;
	}
	for(int i=0;1;i++){
		if(!a[x-i]){
			cout << x-i << endl;
			break;
		}
		if(!a[x+i]){
			cout << x+i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    cout<<48-n;
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#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 <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

#include <string>
#include <vector>

//Morris-Pratt法
//res[i] := [0,i)の接頭辞と接尾辞が最大何文字一致しているか（自明な長さiを除く）
//res[0] = -1
void morris_pratt(const std::string& str, std::vector<int>&res)
{
	int len = str.length();
	res.resize(len + 1);
	res[0] = -1;
	int j = -1;
	for (int i = 0; i < len; ++i)
	{
		while (j >= 0 && str[i] != str[j])j = res[j];
		++j;
		res[i + 1] = j;
	}
}

//Manacher法
//res[i] := iを中心とする最大の回文の半径
void manacher(const std::string& str, std::vector<int>&res)
{
	int len = str.length();
	res.resize(len);
	int i = 0, j = 0;
	while (i < len)
	{
		while (i - j >= 0 && i + j < len && str[i - j] == str[i + j])
			++j;
		res[i] = j;
		int k = 1;
		while (i - k >= 0 && i + k < len && k + res[i - k] < j)
			res[i + k] = res[i - k], ++k;
		i += k, j -= k;
	}
}

//Z-algorithm
//res[i] := 自分自身と[i,|S|)の最長共通接頭辞の長さ
void z_algorithm(const std::string& str, std::vector<int>&res)
{
	int len = str.length();
	res.resize(len);
	res[0] = len;
	int i = 1, j = 0;
	while (i < len)
	{
		while (i + j < len && str[j] == str[i + j])
			++j;
		res[i] = j;
		if (j == 0)
		{
			++i;
			continue;
		}
		int k = 1;
		while (i + k < len && k + res[k] < j)
			res[i + k] = res[k], ++k;
		i += k, j -= k;
	}
}

int main(void)
{
	string s;
	cin >> s;
	int n = s.size();
	int cyc = 0;
	vector<int>Z;
	z_algorithm(s, Z);
	for (int i = 1; i <= n / 2; ++i)
	{
		if (n % i != 0)continue;
		if (Z[i] >= n - i)
		{
			cyc = i;
			break;
		}
	}
	if (cyc == 0)
	{
		cout << "1\n1\n";
		return 0;
	}
	if (cyc == 1)
	{
		cout << n << endl << "1\n";
		return 0;
	}
	string rev = s;
	vector<int>ZZ;
	reverse_copy(s.begin(), s.end(), begin(rev));
	z_algorithm(rev, ZZ);
	vector<bool>ans(n, true);
	ans[0] = false;
	for (int i = 1; i < n; ++i)
	{
		for (int j = 2; (j) * (i) <= Z[i] + i; ++j)
		{
			if (j * i >= n)break;
			ans[j *(i)] = false;
		}
	}
	for (int i = 1; i < n; ++i)
	{
		for (int j = 2; j * (i) <= ZZ[i] + i; ++j)
		{
			if (j * i >= n)break;
			ans[n - j * (i)] = false;
		}
	}
	int answer = 0;
	for (bool b : ans)if (b)answer++;
	cout << "2\n" << answer << endl;
	return 0;
}


Measured memory_bytes: 5252
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    mark = 1
    remain = 0
    for i in range(n):
        if a[i] == mark:
            remain += 1
            mark += 1
    if remain == 0:
        print(-1)
    else:
        print(n-remain)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26268
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003;

int n, m;
int a[N];
LL ans, sum;
map <int, int> p;
bool st[N];

int main()
{
	//File("");
	n = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi(), ++p[a[i]];
	for (int i = 1; i <= n; i+=1)
	{
	    if (!st[a[i]])
	    {
	        st[a[i]] = true;
	        ans += 1ll * p[a[i]] * (p[a[i]] - 1) / 2;
	    }
	}
	for (int i = 1; i <= n; i+=1)
	{
	    sum = ans;
	    printf("%lld\n", ans - (p[a[i]] - 1));
	}
	return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, k;
int c, a, b;
ll w;

ll INF = 1LL<<61;
ll graph[210][210];
ll dist[210][210];


int main() {
    while (cin >> n >> k) {
        if (n == 0 && k == 0) break;
        for (int i = 0; i < 210; ++i) for (int j = 0; j < 210; ++j) graph[i][j] = dist[i][j] = INF;
        
        for (int i = 0; i < k; ++i) {
            cin >> c;
            if (c == 0) {
                cin >> a >> b;
                --a; --b;
                for (int i = 0; i < 210; ++i) for (int j = 0; j < 210; ++j) dist[i][j] = INF;
                dist[a][a] = 0;
                priority_queue<pair<ll,int>, vector<pair<ll,int> >, greater<pair<ll,int> > > que;
                que.push(MP(0,a));
                while (!que.empty()) {
                    ll di = que.top().first, pl = que.top().second; que.pop();
                    if (dist[a][pl] < di) continue;
                    for (int j = 0; j < n; ++j) {
                        if (j == pl || graph[pl][j] == INF) continue;
                        ll ndi = dist[a][pl] + graph[pl][j];
                        if (chmin(dist[a][j], ndi)) {
                            que.push(MP(ndi, j));
                        }
                    }
                }
                if (dist[a][b] < INF) cout << dist[a][b] << endl;
                else cout << -1 << endl;
            }
            else {
                cin >> a >> b >> w;
                --a; --b;
                chmin(graph[a][b], w);
                chmin(graph[b][a], w);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1904
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;

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

int stoi(char *s,int len){
	int res=0;
	int i;
	rep(i,len){
		res*=10;
		res+=s[i]-'0';
	}
	return res;
}

int cases;
char s[11111];

int dfs(int l,int r){
	int num=1;
	int i;
	repl(i,l+1,r-1){
		if(s[i]<'0'||s[i]>'9'){
			num=0;
			break;
		}
	}
	if(num){
		return stoi(s+l+1,r-l-2)/2+1;
	}else{
		int level=-1;
		int ll;
		int ns[11111];
		int idx=0;
		repl(i,l,r){
			if(s[i]=='['){
				if(level==0){
					ll=i;
				}
				level++;
			}else if(s[i]==']'){
				level--;
				if(level==0){
					//ns.pb(dfs(ll,i+1));
					ns[idx++]=dfs(ll,i+1);
				}
			}
		}
		//sort(all(ns));
		qsort((void *)ns,idx,sizeof(int),int_sort);
		int res=0;
		rep(i,idx/2+1){
			res+=ns[i];
		}
		return res;
	}
}

int main(){
	scanf("%d",&cases);
	while(cases--){
		scanf("%s",s);
		printf("%d\n",dfs(0,strlen(s)));
	}
	return 0;
}

Measured memory_bytes: 716
#include<stdio.h>
#define MAX 2000001

int H, A[MAX];

void maxHeapify(int i){
  int l,r,biggest,tmp;
  l=2*i;
  r=2*i+1;
  if(l<=H&&A[l]>A[i])
    biggest=l;
  else
    biggest=i;
  if(r<=H&&A[r]>A[biggest])
    biggest=r;
  if(biggest!=i){
    tmp=A[i];
    A[i]=A[biggest];
    A[biggest]=tmp;
    maxHeapify(biggest);
    }
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100005;
const int INF = (LL)1e9 + 5;
 
int deg[MAXN], ans, N, col[MAXN], dp1[MAXN][2], dp2[MAXN];
vector<int> ch[MAXN], G[MAXN];
 
bool dfs(int v, int p) {
	bool ok = col[v];
	for (int to : G[v]) {
		if (to == p) continue;
		ok = dfs(to, v) || ok;
	}
	
	if (ok && v != p) {
		ch[p].push_back(v);
		deg[v]++;
		deg[p]++;
		ans += 2;
	}
	
	return ok;
}
 
void dfs2(int v) {
	ans += deg[v] % 2 != col[v];
	if (ch[v].empty()) {
		dp1[v][0] = 0;
		dp1[v][1] = deg[v] % 2 == col[v] ? -1 : 1;
		dp2[v] = 0;
		return;
	}
	
	int add = deg[v] % 2 == col[v] ? -1 : 1;
	int h1[2] = {-INF, -INF}, h2[2] = {-INF, -INF}, who[2] = {-1, -1};
	for (int to : ch[v]) {
		dfs2(to);
		dp2[v] = max(dp2[v], dp2[to]);
		for (int i = 0; i < 2; i++) {
			int h = dp1[to][i];
			if (h > h1[i]) h2[i] = h1[i], h1[i] = h, who[i] = to;
			else if (h > h2[i]) h2[i] = h;
		}
	}
	
	dp1[v][0] = max(0, h1[0] + add + 1);
	dp1[v][1] = max(add, h1[1] + add + 1);
	
	int cross = (who[0] == who[1] ? max(h1[0] + h2[1], h2[0] + h1[1]) + add + 2 : h1[0] + h1[1] + add + 2);
	dp2[v] = max({dp2[v], h1[1] + 1, h1[0] + add + 1, cross});
//	cout << "Finish " << v << " -> " << dp1[v][0] << " " << dp1[v][1] << "\n";
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	int all = 0;
	for (int i = 1; i <= N; i++) {
		char ch;
		cin >> ch;
		col[i] = ch == 'W';
		all += col[i];
	}
	
	if (all == 0) {
		cout << "0\n";
		return 0;
	}
	
	int root;
	for (int i = 1; i <= N; i++) {
		if (col[i]) {
			root = i;
			dfs(i, i);
			break;
		}
	}
	
	dfs2(root);
	
	cout << ans - dp2[root] << "\n";
	
	return 0;
	
	/**** Note MAXN ****/
}

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

#define nl '\n'
#define F fisrt
#define S second
#define pb push_back
#define mp make_pair
#define REP(i,a,b) for(int i = a; i < b; i++)

#define Fizz -1
#define Buzz -2
#define FizzBuzz -3

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef stack<int> si;
typedef deque<int> di;
typedef pair<int,int> pi;

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

  //your code here
  int n; cin >> n;
  ll sum = 0;

  REP(i,1,n+1)
    if(i%3!=0&&i%5!=0)
      sum+=i;
  cout << sum;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s ;

    string ans = "" ;

    for (int i = 0; i < s.size(); i++)
    {
        if (s.at(i) != 'B')
        {
            ans.push_back(s.at(i)) ;
        }else
        {
            if (ans.size() > 0)
            {
                ans.pop_back() ;
            }
            
        }
        
    }
    

    cout << ans << endl ;
}    

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(all(A));
  int ans = 0;
  int ac = A[2] - A[0];
  int bc = A[2] - A[1];
  if(ac>=2){
    ans += ac/2;
    ac %= 2;
  }
  if(bc>=2){
    ans += bc/2;
    bc %= 2;
  }
  if(ac+bc==2){
    ans++;
  }
  else if(ac+bc==1){
    ans += 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/* ex 4_2
   cy_an  */

#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793
double deff2(double r);

int main(void){

    // 変数宣言
    double len_A, len_B, hour, minutes, degree_tmp, degree_rad, length;
    
    // 入力
    scanf("%lf %lf %lf %lf", &len_A, &len_B, &hour, &minutes);

    // 角度(deg)の累積を計算
    degree_tmp = (hour * 60 + minutes) * 11 / 360;
    // 角度(rad)を0に近い値で計算
    degree_rad = deff2(degree_tmp) * PI;
    // 余弦定理を使ってlengthを求める
    length = sqrt(len_A*len_A + len_B*len_B - 2*len_A*len_B*cos(degree_rad));

    // lengthの出力
    printf("%.20lf\n", length);

    return 0;
}
// 0に最も近いmod2を計算する関数
double deff2(double r){
    while(r > 1){
        r -= 2;
    }
    return r;
}

Measured memory_bytes: 2596
n = int(input())
p = list(map(int, input().split()))
import numpy as np
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i+2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 21148
#include <iostream>
using namespace std;
int n,m;
int mp[101][101];

int check() {
  int flg[101] ={};
  int dis[101];
  int sum = 0;
  for(int i=0;i<n;i++) dis[i] = 1000000000;
  dis[0]  = 0;

  for(int k=0;k<n;k++) {
    int mincost = 1000000000;
    int ima;
    for(int i=0;i<n;i++) {
      if(mincost > dis[i] && flg[i] == 0) {
	mincost = dis[i];
	ima = i;
      }
    }
    sum += mincost;
    flg[ima] = 1;
    // cout << mincost<<endl;;
    
    for(int i=0;i<n;i++) 
      if(mp[ima][i] < dis[i] && flg[i] == 0 )
	dis[i] = mp[ima][i];
  }


  return sum;

}

int main() {
  
  while(1) {
    cin >> n >> m;

    if(n == 0 && m ==0) break;

    for(int i=0;i<n;i++) 
      for(int j=0;j<n;j++)
	mp[i][j] = 1000000000;

    int a,b,cost;
    for(int i=0;i<m;i++){
      cin >> a >> b >> cost;
      mp[a][b] = cost;
      mp[b][a] = cost;
    }
    
    
    int ans = check();
    
    cout << ans << endl;
    
  }

  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N];

int main()
{
	int n,k;
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0){
			break;
		}
		rep(i,n){
			scanf("%d",&a[i]);
		}
		ll ans=0;
		ll s=0;
		int id=0;
		while(id<n){
			s += a[id];
			if(id>=k){
				s-=a[id-k];
				ans = max(ans,s);
			}else if(id==k-1){
				ans = s;
			}
			id++;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    for(int i=0;i<n;i++){
        cin>>hoge.at(i);
    }
    
    sort(hoge.begin(),hoge.end());
    
    long long ans=99999999999;
    
    for(int i=1;i<=hoge.at(hoge.size()-1);i++){
        long long preans=0;
        for(int k=0;k<n;k++){
            preans+=(hoge.at(k)-i)*(hoge.at(k)-i);
        }
        ans=min(preans,ans);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

const ll INF = 1e10;
const ll D = 80 * 160 + 10;
const ll D2 = D * 2;
typedef bitset<D2> bs;

ll H, W;
ll A[85][85];
bs dp[85][85];

int main() {
    // 入力
    cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
        }
    }

    rep(i, H) {
        rep(j, W) {
            ll x; cin >> x;
            A[i][j] = abs(A[i][j] - x);
        }
    }

    // D始まり 
    dp[0][0][D - A[0][0]] = 1;
    dp[0][0][D + A[0][0]] = 1;
    rep(i, H)rep(j, W) {
        if (i) {
            dp[i][j] |= dp[i - 1][j] << A[i][j];
            dp[i][j] |= dp[i - 1][j] >> A[i][j];
        }
        if (j) {
            dp[i][j] |= dp[i][j - 1] << A[i][j];
            dp[i][j] |= dp[i][j - 1] >> A[i][j];
        }
    }
    ll ans = D2;
    rep(i, D2) if (dp[H - 1][W - 1][i]) {
        ans = min(ans, abs((ll)i - D));
    }
    cout << ans << endl;
}

Measured memory_bytes: 22784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

const int N=1000010;
bool v[N],ok[N];
int n,a[N];

void get_prime(int x){
	memset(v,0,sizeof v);
	v[1]=1;
	for(int i=2;i<=x;i++){
		if(v[i]) continue;
		for(int j=2*i;j<=x;j+=i) v[j]=1;
	}
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
	bool All_ok=true;
    get_prime(1000000);
//    cout<<v[1]<<" "<<v[2]<<" "<<v[3]<<" "<<v[5]<<endl;
    for(int i=1;i<=n;i++) {
    	int tmp=a[i];
    	for(int j=1;j*j<=tmp;j++)
    	    if(tmp%j==0) {
    	    	if(!v[j]){
    	    	    if(ok[j]!=1) ok[j]=1;
    	    	    else All_ok=false;
			    }
			    if(j*j==tmp) continue;
			    if(!v[tmp/j]){
    	    	    if(ok[tmp/j]!=1) ok[tmp/j]=1;
    	    	    else All_ok=false;
				}
			}
		if(All_ok==false) break;
	}
	if(All_ok) {
		cout<<"pairwise coprime";
		return 0;
	}
    int ans=a[1];
    for(int i=2;i<=n;i++) ans=__gcd(ans,a[i]);
    if(ans==1) cout<<"setwise coprime";
    else cout<<"not coprime";
	return 0;
}

Measured memory_bytes: 8472