akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

using std::binary_search;

typedef long long int ll;
const int MOD = 1e9 + 7;

class point {
   public:
    int x, y;
    point() {}
    point(int x, int y) : x(x), y(y) {}

    bool operator<(const point& p) const {
        return x == p.x ? y < p.y : x < p.x;
    }
    bool operator==(const point& p) const {
        return x == p.x && y == p.y;
    }
};

void subr(vector<point>& pp, int w, int h, int x, int y) {
    if (1 < x && x < w && 1 < y && y < h) {
        pp.push_back(point(x, y));
    }
}

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    vector<point> bp(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        bp[i] = point(b, a);
    }
    sort(bp.begin(), bp.end());

    vector<point> pp;
    for (const point& p : bp) {
        subr(pp, w, h, p.x + 0, p.y + 0);
        subr(pp, w, h, p.x + 0, p.y + 1);
        subr(pp, w, h, p.x + 0, p.y - 1);
        subr(pp, w, h, p.x + 1, p.y + 0);
        subr(pp, w, h, p.x + 1, p.y + 1);
        subr(pp, w, h, p.x + 1, p.y - 1);
        subr(pp, w, h, p.x - 1, p.y + 0);
        subr(pp, w, h, p.x - 1, p.y + 1);
        subr(pp, w, h, p.x - 1, p.y - 1);
    }

    sort(pp.begin(), pp.end());
    pp.erase(unique(pp.begin(), pp.end()), pp.end());

    vector<ll> ans(10);
    for (const point& p : pp) {
        int cnt = 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x + 0, p.y + 0)) ? 1 : 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x + 0, p.y + 1)) ? 1 : 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x + 0, p.y - 1)) ? 1 : 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x + 1, p.y + 0)) ? 1 : 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x + 1, p.y + 1)) ? 1 : 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x + 1, p.y - 1)) ? 1 : 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x - 1, p.y + 0)) ? 1 : 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x - 1, p.y + 1)) ? 1 : 0;
        cnt += binary_search(bp.begin(), bp.end(), point(p.x - 1, p.y - 1)) ? 1 : 0;
        ans[cnt]++;
    }

    ll sum = 0;
    for(int i = 1; i <= 9; i++){
        sum += ans[i];
    }
    ans[0] = (ll)(w - 2) * (ll)(h - 2) - sum;

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

    return 0;
}


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

using namespace std;

int main()
{
  int nodes, edges;
  cin >> nodes >> edges;

  vector<vector<bool>> connected(nodes, vector<bool>(nodes));

  for (int i = 0, a, b; i < edges; ++i) {
    cin >> a >> b;
    a--;
    b--;
    connected[a][b] = true;
    connected[b][a] = true;
  }

  int bridges = 0;

  for (int i = 0; i < nodes; ++i) {
    for (int j = 0; j < nodes; ++j) {
      if (!connected[i][j])
        continue;

      connected[i][j] = false;
      int count = 0;

      vector<bool> visited(nodes, false);

      auto dfs = [&](int node, auto dfs)->void {
        visited[node] = true;
        count++;
        for (int k = 0; k < nodes; ++k)
          if (!visited[k] && connected[node][k])
            dfs(k, dfs);
      };

      dfs(0, dfs);

      if (count < nodes)
        bridges++;

      connected[i][j] = true;
    }
  }

  cout << bridges;
}


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

int main() {
  int n, c = 0; cin >> n; set <int> st;
  for(int i = 1; i <= n; i++) {
    int x; cin >>x;
    st.insert(x);
    if(*st.begin() == x) ++c;
  } cout << c << endl;
}



Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}
map<pii,int> Mp;
signed main()
{
    io;
    int n;cin>>n;  int ans=0;
    rep(i,1,n){
        int r=i%10;
        int l=i;
        while(l/10 != 0)l/=10;
        Mp[mp(l,r)]++;
    }
    rep(i,1,9){
        rep(j,1,9){
            ans += Mp[mp(i,j)]*Mp[mp(j,i)];
        }
    }
    
    cout<<ans<<endl;


    getchar(); //

    getchar();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
int  main(){
ll x,y;
cin >> x >> y;
ll ans = 1;
ll che = x;
while(che<y){
    che = che*2;
    if(che>y)break;
    ans++;
}
cout<<ans<<endl;
}







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

using namespace std;
#define PROBLEM "B"

int main(){

	#ifdef DBG
	freopen("problem" PROBLEM ".in", "r", stdin);
	freopen("problem" PROBLEM ".out", "w", stdout);
	#endif

	int n;
	while(cin >> n){

		int a[25];
		int b[25];
		int c[25];

		for(int i = 1 ; i <= n ; i++){

			cin >> a[i];
		}
		for(int i = 1 ; i <= n ; i++){

			cin >> b[i];
		}
		for(int i = 2 ; i <= n ; i++){

			cin >> c[i];
		}


		int ans = b[a[1]];
		// cout << ans << endl;
		for(int i = 2 ; i <= n ; i++){

			// cout << ans << endl;
			if(a[i] == a[i-1]+1){

				ans += b[a[i]];
				// cout << "b: " << ans << endl;
				ans += c[a[i]];
				// cout << "a: " << ans << endl;
			}
			else{

				ans += b[a[i]];
				// cout << "ww: " << ans << endl;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K;

void solve() {
	cin >> N >> K;
	if(K == 1) cout << 0 << "\n"; 
	else cout << N - K << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

typedef long long ll;

using namespace std;

void solve(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = n-1; i >= 0; i--){
        cout << a[i];
        if(i != 0){
            cout << " ";
        }
    }
    cout << endl;
}

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

Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
	static long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = (int)h[0];
		var es = new int[h[1]].Select(_ => Read()).ToArray();

		var r = MinCostFlow(n - 1, 0, n - 1, es, h[2]);
		Console.WriteLine(r == long.MaxValue ? -1 : r);
	}

	static long MinCostFlow(int n, int sv, int ev, long[][] dg, long f)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<long[]>());
		foreach (var e in dg)
		{
			map[e[0]].Add(new[] { e[0], e[1], e[2], e[3], map[e[1]].Count });
			map[e[1]].Add(new[] { e[1], e[0], 0, -e[3], map[e[0]].Count - 1 });
		}

		long r = 0, t;
		while (f > 0)
		{
			if ((t = BellmanFord(n, sv, ev, map, ref f)) == long.MaxValue) return t;
			r += t;
		}
		return r;
	}

	static long BellmanFord(int n, int sv, int ev, List<long[]>[] map, ref long f)
	{
		var from = new long[n + 1][];
		var cost = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
		var minFlow = new long[n + 1];
		cost[sv] = 0;
		minFlow[sv] = f;

		var next = true;
		while (next)
		{
			next = false;
			for (int v = 0; v <= n; v++)
			{
				if (cost[v] == long.MaxValue) continue;
				foreach (var e in map[v])
				{
					if (e[2] == 0 || cost[e[1]] <= cost[v] + e[3]) continue;
					from[e[1]] = e;
					cost[e[1]] = cost[v] + e[3];
					minFlow[e[1]] = Math.Min(minFlow[v], e[2]);
					next = true;
				}
			}
		}

		if (from[ev] == null) return long.MaxValue;
		for (long v = ev; v != sv; v = from[v][0])
		{
			var e = from[v];
			e[2] -= minFlow[ev];
			map[e[1]][(int)e[4]][2] += minFlow[ev];
		}
		f -= minFlow[ev];
		return minFlow[ev] * cost[ev];
	}
}



Measured memory_bytes: 20544
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  ll m;
  cin>>n>>m;
  ll a[n+1]={};
  ll s[n+1]={};
  ll ans=0;
  cin>>a[0];
  s[0]=a[0]%m;
  if(s[0]==0) ans++;
  for(int i=1;i<n;i++){
    cin>>a[i];
    a[i]%=m;
    s[i]=(s[i-1]+a[i])%m;
    if(s[i]==0) ans++;
  }
  sort(s,s+n);
  ll c=0;
  for(int i=1;i<n;i++){
    if(s[i]==s[i-1]) c++;
    else{
      if(c%2==0) ans=ans+c/2*(c+1);
      else ans=ans+(c+1)/2*c;
      c=0;
    }
  }
  if(c%2==0) ans=ans+c/2*(c+1);
  else ans=ans+(c+1)/2*c;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, N = LI()
if N < B:
    ans = math.floor(A * N / B)
elif N >= B:
    ans = math.floor(A * (B - 1) / B)
print(ans)





Measured memory_bytes: 10900
import math
def main():
    a,b,c,d = map(int,input().split())
    bc = b // c
    bd = b // d
    bx = b // (c * d // math.gcd(c,d))
    B = b - bc - bd + bx
    
    a -= 1
    ac = a // c
    ad = a // d
    ax = a // (c * d // math.gcd(c,d))
    A = a - ac - ad + ax
    
    print(B-A)
    
if __name__ == "__main__":
    main()

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

void solve()
{
ll n,i;
    cin>>n;
    vector<ll>a(n);
    for(ll &x:a)
        cin>>x;
    vector<ll>pre(n),suf(n);
    pre[0]=a[0];
    suf[n-1]=a[n-1];
    for(i=1;i<n;i++)
        pre[i]=pre[i-1]^a[i];
    for(i=n-2;i>=0;i--)
        suf[i]=suf[i+1]^a[i];
    
    for(i=0;i<n;i++)
    {
     if(i==0)
         cout<<suf[i+1]<<" ";
     else if(i==n-1)
         cout<<pre[i-1]<<" ";
     else 
     {
      ll ans=pre[i-1]^suf[i+1];
         cout<<ans<<" ";
     }
    }
    
    
}


int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}

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

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

  int N;
  std::string X;
  int D;

  std::cin >> N;
  std::cin >> X;
  std::cin >> D;

  bool flag[1024] = {};
  for(int i = 0; i < N; ++i) {
    if( D == 0 ) break;
    if( X[i] == '0' ) {
      flag[i] = true;
      X[i] = '1';
      D -= 1;
    }
  }

  for(int i = N - 1; i >= 0; --i) {
    if( D == 0 ) break;
    if( X[i] == '1' and not flag[i] ) {
      flag[i] = true;
      X[i] = '0';
      D -= 1;
    }
  }

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

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,a;
  cin>>n>>a;
  n=n%500;
  if(n<=a) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}



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

int gcd(long long x,long long y){
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}

int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    a-=1;
    cout<<b-b/c-b/d+b/(c*d/gcd(c,d))-(a-a/c-a/d+a/(c*d/gcd(c,d)));
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using VI = vector<int>;
const int INF = 1 << 30;

int dfs(int& N, VI& ABC, VI& l, int d, VI& abc) {
    if (d == N) {
        int res = 0;
        for (int i = 0; i < 3; i++) {
            if (abc[i] == 0) return INF;
            res += abs(ABC[i] - abc[i]) - 10;
        }
        return res;
    }
    int res = min(INF, dfs(N, ABC, l, d+1, abc));
    for (int i = 0; i < 3; i++) {
        VI abc0 = abc;
        abc0[i] += l[d];
        res = min(res, dfs(N, ABC, l, d+1, abc0) + 10);
    }
    return res;
}

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

    int N; cin >> N;
    vector<int> ABC(3);
    for (int i = 0; i < 3; i++) cin >> ABC[i];
    vector<int> l(N);
    for (int i = 0; i < N; i++) cin >> l[i];

    vector<int> abc(3);
    cout << dfs(N, ABC, l, 0, abc) << "\n";
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n;
	cin >> n;
	map<int,int> mp;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		mp[a]++;
	}
	int num = 0;
	for(auto x: mp){
		num += x.second-1;
	}
	if(num % 2 == 1) num++;
	cout << n - num << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
/* DSU 
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rank[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/ 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
 
ll mod(ll a, ll b) {return (a % b + b) % b;}
 
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 
using namespace std;

int main()
{
	fast;
	ll a,b,c,d; cin>>a>>b>>c>>d;
	if(abs(b-a) <= d && abs(c-b) <= d)
		cout << "Yes" << endl;
	else if(abs(a-c) <= d)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
#include<bitset>
using ll=long long;


int main(){
  int x;
  cin >> x;
  bool f=true;
  do{
    int cnt=0;
    for(int i=1;i<=x;i++){
      if(x%i==0)cnt++;
    }
    if(cnt==2)f=false;
    else x++;
  }while(f);

  cout << x;
}
    





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

using ll = long long;
const ll mod = 1e9 + 7;

int N;
ll a[300002];

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

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  ll res = 0;
  for (int i = 0; i < 62; ++i) {
    ll zeros = 0;
    ll ones = 0;
    for (int j = 0; j < N; ++j) {
      if (a[j] % 2ll == 0) {
        ++zeros;
      } else {
        ++ones;
      }
      a[j] >>= 1;
    }
    ll cur = (((((1ll << i) % mod) * zeros) % mod) * ones) % mod;
    res += cur;
    res %= mod;
  }
  cout << res << '\n';
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s,t,a;
  cin>>s>>t;
  for(int i=0;i<n;i++)
  {
    a +=s[i];
    a+=t[i];
  }
  cout<<a<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint pls;
    vint pl5;
    for(int i=2;i<=55555;i++){
        bool f = true;
        for(int j=0;j<pls.size();j++){
            if(i%pls[j]==0){
                f=false;
                break;
            }
        }
        if(f) {
            pls.pb(i);
            if(i%5==1){
                pl5.pb(i);
            }
        }
    }
    cout << 11;
    for(int i=1;i<n;i++){
        cout << " " << pl5[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=1000005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

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

    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans=0;
    ll mn=min(a,k);
    k-=mn;
    ans+=mn;
    mn=min(b,k);
    k-=mn;
    mn=min(c,k);
    ans-=mn;
    k-=mn;
    ret(ans);
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s1,s2;cin>>s1>>s2;
  int t = stoi(s1+s2);
  int k = (int) (sqrt(t));
  if(k*k==t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;

  }

  return 0;
}


Measured memory_bytes: 256
/**
 *   author: r1933
**/
#include "bits/stdc++.h"

using namespace std;

#define all(x) x.begin(), x.end()
using i64 = long long;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s.length() == 3) reverse(all(s));
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 256
n,x = map(int,input().split())
m = [int(input()) for i in range(n)]
m.sort()
sum = 0
c = 0

for i in range(n):
    sum += m[i]
    if sum > x:
        break
    c += 1
if i == n-1:
    c += (x-sum) // m[0]

print(c)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_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); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	int R, S, P; cin >> R >> S >> P;
	string T; cin >> T;

	int ans = 0;
	string s;
	rep(i, 0, N) {
		int pi = i - K;
		if (pi >= 0) {
			if (T[i] == 'r') {
				if (s[pi] == 'p') {
					int ni = i + K;
					if (ni < N && T[ni] == 'p') {
						s += 'r';
					}
					else {
						s += 's';
					}
				}
				else {
					s += 'p';
					ans += P;
				}
			}
			else if (T[i] == 's') {
				if (s[pi] == 'r') {
					int ni = i + K;
					if (ni < N && T[ni] == 'r') {
						s += 's';
					}
					else {
						s += 'p';
					}
				}
				else {
					s += 'r';
					ans += R;
				}
			}
			else if (T[i] == 'p') {
				if (s[pi] == 's') {
					int ni = i + K;
					if (ni < N && T[ni] == 's') {
						s += 'p';
					}
					else {
						s += 'r';
					}
				}
				else {
					s += 's';
					ans += S;
				}
			}
		}
		else {
			if (T[i] == 'r') {
				s += 'p';
				ans += P;
			}
			else if (T[i] == 's') {
				s += 'r';
				ans += R;
			}
			else {
				s += 's';
				ans += S;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

// header area


int main(){
    int N; cin >> N;
    string S; cin >> S;

    // 条件1を満たす数
    ll r_count=0;
    ll g_count=0;
    ll b_count=0;

    rep(i, N){
        if(S[i] == 'R') r_count++;
        if(S[i] == 'G') g_count++;
        if(S[i] == 'B') b_count++;
    }
    // あり得る数は、R, G, Bの数の積（それぞれの位置は考えない）。
    ll all = r_count*g_count*b_count;

    // 等間隔：j-i = k-j => 2*j-i = k を満たす数の中で、条件1を満たすものをカウント(i, j, kでループしなくて済む)
    ll count=0;
    rep(i, N){
        for(int j=i;j<N;j++){
            int k = 2*j-i;
            if(k < j) continue;
            if(k < N){
                if(S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i]){
                    // cout << "S[i]: " << S[i] << " S[j]: " << S[j] << " S[k]: " << S[k] << endl;
                    count++;
                }
            }
        }
    }

    // あり得る全体数から、補集合部分のカウントを引く
    cout << all - count << endl;
    return 0;
}

Measured memory_bytes: 3624
arr = list(input().split())
A=int(arr[0])
B=int(arr[1])
C=int(arr[2])
K=int(arr[3])


sum=0
#print('K : ' + str(K) + '   SUM : ' + str(sum))

if K > A :
	sum+=A
else:
	sum+=K
K-=A
#print('K : ' + str(K) + '   SUM : ' + str(sum))
if K > 0:

	K-=B
	#print('K : ' + str(K) + '   SUM : ' + str(sum))

	if K > 0:
		sum-=K
		#print('K : ' + str(K) + '   SUM : ' + str(sum))

print(sum)



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

using namespace std;

int main()
{
    int L,R;
    cin>>L>>R;
    if(L%2019==0||R/2019>L/2019)cout<<"0";
    else{
        int mini=2018;
        R=R%2019;
        L=L%2019;
        for(int i = R;i>=L;i--)
        {
            for(int j = L;j<=R;j++)
            {
                if(i!=j)mini=min(mini,(i*j)%2019);
            }
        }
        cout<<mini;
    }
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
b = []
for _ in range(n):
    c, *a = list(map(int, input().split()))
    b.append((c, a))

cost = -1
for bit in range(2 ** n):
    c = 0
    a = [0 for _ in range(m)]
    for i in range(n):
        if ((bit >> i) & 1) == 1:
            c += b[i][0]
            a = [a[j] + b[i][1][j] for j in range(m)]

    j = True
    for i in range(m):
        if x > a[i]:
            j = False
    if j:
        cost = min(cost, c) if cost >= 0 else c

print(cost)


Measured memory_bytes: 68716
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(n):
	if a[i] %2 == 0:
		if not (a[i] %3 == 0 or a[i] %5 ==0):
			c=1
print ( "APPROVED" if c==0 else "DENIED")

Measured memory_bytes: 3060
n, m = map(int, input().split())
cnt = [1] * n
red = [0] * n
red[0] = 1
for _ in range(m):
    x, y = map(lambda x: int(x) - 1, input().split())
    cnt[x] -= 1
    cnt[y] += 1
    if red[x]:
        red[y] = 1
        if cnt[x] == 0:
            red[x] = 0

print(sum(red))

Measured memory_bytes: 4596
#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	
	for(int i = 1; i < 10; i++){
		int flag = 0;
		for(int j = 1; j < 10; j++){
			if(i * j == n){
				flag = 1;
			}
		}
		
		if(flag == 1){
			printf("Yes");
			break;
		}
		else if(i == 9 && flag == 0){
			printf("No");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<queue>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<long long> a;
	for (int i = 0; i < n; i++) {
		long long tmp = 0;
		cin >> tmp;
		a.push(tmp);
	}



	while (m > 0) {

		a.push( floor(a.top() / 2));
		m--;
		a.pop();
		
	}

	long long ans = 0;
	
	for (int i = 0; i < n; i++) {
	
		ans += a.top();
		a.pop();
	}

	cout << ans;



	system("pause");
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
using namespace std;
using ll=long long;
int main(){

  int Q,H,S,D;
  cin>>Q>>H>>S>>D;
  int N;
  cin>>N;
  ll checkQ=0;
  ll checkH=0;
  ll checkS=0;
  ll checkD=0;
  checkQ=Q*8;
  checkH=H*4;
  checkS=S*2;
  checkD=D;
  ll check2=min({checkQ,checkH,checkS,checkD});
  ll ans=0;
  while(N>=2){
  
    ans+=check2;
    N-=2;
  }
  if(N==1){
    
    checkQ=Q*4;
    checkH=H*2;
    checkS=S; 
    ll check1=min({checkQ,checkH,checkS});
    ans+=check1;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,ans=0,p=5,val,ans2=0;
	cin>>n;
	if(n%2!=0)cout<<0;
	else if(n<10)cout<<0;
	else
	{
		n=n/2;
		val=n;
		while(val>0)
		{
			ans=ans+(n/p);
			val=n/p;
			p=p*5;
		}
		cout<<ans;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer gcd = null;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (gcd == null) {
                gcd = a;
            } else {
                gcd = gcd(gcd, a);
            }
        }

        System.out.println(gcd);
    }

    private static int gcd(int b, int a) {
        if (b % a == 0) return a;
        return gcd(a, b%a);
    }
}


Measured memory_bytes: 58552
/* 
  ╔╗         ╔╗              ╔═══╗                                  
  ║║        ╔╝╚╗             ║╔═╗║                                  
  ║║╔╗╔╗╔══╗╚╗╔╝    ╔══╗     ║╚═╝║╔═╗╔══╗╔══╗╔═╗╔══╗ ╔╗╔╗╔╗╔╗╔══╗╔═╗
╔╗║║║║║║║══╣ ║║     ╚ ╗║     ║╔══╝║╔╝║╔╗║║╔╗║║╔╝╚ ╗║ ║╚╝║║╚╝║║╔╗║║╔╝
║╚╝║║╚╝║╠══║ ║╚╗    ║╚╝╚╗    ║║   ║║ ║╚╝║║╚╝║║║ ║╚╝╚╗║║║║║║║║║║═╣║║ 
╚══╝╚══╝╚══╝ ╚═╝    ╚═══╝    ╚╝   ╚╝ ╚══╝╚═╗║╚╝ ╚═══╝╚╩╩╝╚╩╩╝╚══╝╚╝ 
                                         ╔═╝║                       
                                         ╚══╝                       */


//Header files
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#ifndef ONLINE_JUDGE
#include<Personal/debug.h>
#else
#define debug(x...)
#endif

//Short data-types declaration
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vii;  
typedef vector<vector<long long> >vll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;

//Macros
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define rep(i,start,end) for(int i=(int)start;i<(int)end;i++)
#define repr(i,start,end) for(int i=(int)start;i>(int)end;i--)
#define all(x) (x).begin(), (x).end()

//Constants
const int mod = 1e9+7;

//Some useful functions
ll binpow(ll num,ll pow);
inline int mul(int a,int b) {return (a*1ll*b)%mod;}
inline int add(int a,int b) {return (a+0ll+b)%mod;}
inline int sub(int a,int b) {return ((a+0ll-b)%mod+mod)%mod; }
/*------------------------------------------------------Code Starts------------------------------------------------------*/
inline void solve()
{
	int n;
	cin>>n;
	int count[4]={0,0,0,0};
	rep(i,0,n)
	{
		string s;
		cin>>s;
		if(s=="AC") count[0]++;
		else if(s=="WA") count[1]++;
		else if(s=="TLE") count[2]++;
		else count[3]++;
	}
	cout<<"AC x "<<count[0]<<'\n';
	cout<<"WA x "<<count[1]<<'\n';
	cout<<"TLE x "<<count[2]<<'\n';
	cout<<"RE x "<<count[3]<<'\n';

}

int main()
{
	auto start = high_resolution_clock::now();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
	cerr<<duration.count()<<" microseconds\n";
	return 0;
}
/*------------------------------------------------------Code ends------------------------------------------------------*/
ll binpow(ll num,ll pow)
{
	if(pow==0)
		return 1;
	ll val=binpow(num,pow/2);
	val*=val;
	if(pow&1) val*=num;
	return val;
}



Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <algorithm>
#define mpi make_pair
using namespace std;

const int maxN = 2005;
int N, X, Y, maxx[maxN][maxN], val[maxN];
pair<int, int> dp[2][maxN];
int myabs(int num) {
	return (num < 0) ? -num : num;
}
int work1(int l, int r, int num) {
	int ans = val[l];
	for(int i = l; i <= r; ++i)
	 if(myabs(ans - num) < myabs(val[i] - num)) ans = val[i];
	return ans;
}
int work2(int l, int r, int num) {
	int ans = val[l];
	for(int i = l; i <= r; ++i)
	if(myabs(ans - num) > myabs(val[i] - num)) ans = val[i];
	return ans;
}
int main() {
	scanf("%d%d%d", &N, &X, &Y);
	for(int i = 1; i <= N; ++i) scanf("%d", &val[i]);
	if(N == 1) {
		printf("%d", myabs(Y - val[1]));
		return 0;
	}
	//dp[0][N] = mpi(X, val[N]);
	//dp[1][N] = mpi(val[N], Y);
	for(int i = 1; i <= N - 1; ++i) 
	dp[0][i] = mpi(work1(i, N - 1, val[N]), val[N]);
	for(int i = 1; i <= N - 1; ++i)
	dp[1][i] = mpi(work2(i, N - 1, val[N]), val[N]);
	for(int i = N - 2; i >= 1; --i) {
		dp[0][i] = dp[1][i + 1];
		for(int j = i + 1; j < N; ++j) {
			if(myabs(dp[0][i].first - dp[0][i].second) < myabs(dp[1][j].first - dp[1][j].second)) 
			dp[0][i] = dp[1][j];
		}
		dp[1][i] = dp[0][i + 1];
		for(int j = i + 1; j < N; ++j) {
			if(myabs(dp[1][i].first - dp[1][i].second) > myabs(dp[0][j].first - dp[0][j].second))
			dp[1][i] = dp[0][j];
		}
	}
	printf("%d\n", max(myabs(dp[0][1].first - dp[0][1].second), myabs(val[N] - Y)));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define print(x) for(auto& i:x) cout<<i<<" "; cout<<'\n';
#define scan(x) for(auto& i:x) cin>>i;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define pii pair<int, int>
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<" "<<b<<endl
#define d3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define d4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define d5(a,b,c,d,e) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
ll mod=1e9+7;

void solve(){
	int n; cin>>n;
	vector<int> a(n); scan(a);
	sort(a.begin(),a.end());
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k]) ans++;
			}
		}
	}
	cout<<ans<<endl;
}

int main() {
	//freopen("test.txt", "r", stdin);
	FAST; int T=1;
	//cin>>T;
	while(T--) solve();
	return 0;
}

Measured memory_bytes: 3232
s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		
		long ans = 0;
		int temp = 0;
		for(int i = 0; i < Math.pow(2, str.length() - 1); i++) {
			StringBuilder sb = new StringBuilder(str);
			int cnt = 0;
			for(int j = 0; j < str.length() - 1; j++) {
				if((1 & i >> j) == 1) {
					sb.insert(j + cnt + 1, ",");
					cnt++;
				}
			}
			String ans_str = sb.toString();
			String str_array[] = ans_str.split(",");
			for(String s : str_array) {
				ans += Long.parseLong(s);
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;//長さNの文字列S
  cin >> S;

  /*
  * [問題] 
  * 文字列Sはそれぞれ0か1からなる
  * これらの文字列Sに対して，操作を行うことで0を1に，1を0に変えることができる
  * 最小の操作を繰り返して，文字列Sを，0と1が交互に現れるようにしたい
  * 最小の操作の繰り返し回数はいくらか？
  * 
  * [回答方針]
  * 文字列の長さをNとする
  * 偶数番の文字の数zはN/2，奇数番の文字の数yはN-N/2
  * 偶数番に現れる0の回数をA，奇数番に現れる0の回数をBとする
  * 偶数番に現れる1の回数は，x-A, 奇数番に現れる1の回数は，y-B
  * 交互に現れるようにする場合，偶数番が0かつ，奇数番が1，もしくは偶数番が1かつ奇数番が0のどちらか
  * よって，A+y-B もしくは，x-A+Bの小さい方の数値を出力すれば良い
  */

  int A=0; int B=0; int N = S.length();
  for(int i=0;i<N;i++){
    if(i%2==0 && S[i]=='0')
      A++;
    else if(i%2==1 && S[i]=='0')
      B++;
  }
  //cout << "A:" << A << ", B:" << B << endl;
  int y = N / 2; int x = N - y;
  //cout << "x:" << x << ", y:" << y << endl;
  int min;
  if(A+y-B > x-A+B)
    min = x-A+B;
  else
    min = A+y-B;

  cout << std::setprecision(20);
  cout << min << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.io.*;

// public class Main {
//     public static void main(String[] args){
//         System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
//         Scanner sc = new Scanner(System.in);
//     }
// }


public class Main {
    public static void main(String[] args){
        //System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        int sum = 0;
        int a1;
        int a2;

        a1 = Integer.parseInt(sc.next());
        sum += a1;

        for(int i = 0; i < n - 2; i++){
            a2 = Integer.parseInt(sc.next());

            if(a1 < a2) sum += a1;
            else sum += a2;

            a1 = a2;
        }
        sum += a1;

        System.out.print(sum);

    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cmath>
using namespace std;
long long n;
int main(){
	scanf("%lld",&n);
	for(register long long i=sqrt(n);i;i--){
		if(!(n%i)){
			printf("%lld",i+(n/i)-2);
			return 0;
		}
	}
}

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

using namespace std;

typedef long long i64;
typedef int Monoid;

struct SegmentTree{
    int n, sz;
    vector<Monoid> node;

    Monoid f(Monoid a, Monoid b){
        return min(a, b);
    }
    Monoid M1 = numeric_limits<Monoid>::max();

    SegmentTree(vector<Monoid> v){
        sz = v.size();
        n = 1;
        while(n < sz) n *= 2;
        node.assign(2 * n, M1);
        for(int i = 0; i < sz; ++i) node[n + i] = v[i];
        for(int i = n - 1; i > 0; --i) node[i] = f(node[i * 2], node[i * 2 + 1]);
    }

    void update(int k, Monoid val){
        k += n;
        node[k] = val;
        while(k >>= 1){
            node[k] = f(node[k * 2], node[k * 2 + 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid l = M1, r = M1;
        for(a += n, b += n; a != b; a >>= 1, b >>= 1){
            if(a & 1) l = f(l, node[a++]);
            if(b & 1) r = f(node[--b], r);
        }
        return f(l, r);
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> v(n, (1LL<<31) - 1);
    SegmentTree seg(v);
    for(int i = 0; i < q; ++i){
        int com, x, y;
        cin >> com >> x >> y;
        if(com == 0) seg.update(x, y);
        if(com == 1) cout << seg.query(x, y + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 4732
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

W, H, x, y = mapint()
if x==W/2 and y==H/2:
    print(W*H/2, 1)
else:
    print(W*H/2, 0)

Measured memory_bytes: 61892
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;

int n,m;

struct node
{
    double price,rate;
    int w;
    int id;
}a[maxn];

bool cmp(const node a,const node b)
{
    return a.rate<b.rate;
}

int main()
{
    for(int i=1;i<=4;i++)
    {
        scanf("%d",&a[i].w);
        if(i==1) a[i].price=0.25;
        if(i==2) a[i].price=0.50;
        if(i==3) a[i].price=1.00;
        if(i==4) a[i].price=2.00;
        a[i].rate=a[i].w*1.0/a[i].price;
        a[i].id=i;
    }
    scanf("%d",&n);
    sort(a+1,a+5,cmp);
    if(a[1].id!=4)
    {
        ll ans=(ll)(1.0*n/(a[1].price))*a[1].w;
        printf("%lld\n",ans);
    }
    else
    {
        if(n%2==0)
        {
            ll ans=(ll)(1.0*n/(a[1].price))*a[1].w;
            printf("%lld\n",ans);
        }
        else
        {
            ll ans=(ll)(1.0*(n-1)/(a[1].price))*a[1].w+(ll)(1.0/(a[2].price))*a[2].w;
            printf("%lld\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    while(1){
        cin >>m >>f >>r;
        if(m==-1 && f==-1 && r==-1){
            break;
        }
        if(m==-1 || f ==-1){
            cout<<"F"<<endl;
        
        
        }else if(m+f >=80){
            cout<<"A"<<endl;
        }else if(65<= m+f ){
            cout <<"B"<<endl;
        }else if(50 <= m+f){
            cout<<"C"<<endl;
        
        }else if (30<=m+f){
            if (r >=50){
                cout<<"C"<<endl;
            
            }else{
                cout<<"D"<<endl;
            }
        }else{
            cout<<"F"<<endl;
        }
    }return 0;
}



Measured memory_bytes: 3072
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> X >> A;
  if (X <A) cout <<0 << endl;
  else cout << 10 << endl;
  
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        l: i64,
    }
    let all = (0..n).map(|x| l + x).fold(0, |sum, x| sum + x);
    let (_min, ans) = (0..n)
        .map(|x| {
            let num = all - (l + x);
            ((all - num).abs(), num)
        })
        .min()
        .unwrap();
    println!("{}", ans);
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 1; i < n; i++) {
        int input;
        cin >> input;
        input--;
        a.at(input) = a.at(input) + 1;
    }
    for (int i = 0; i < n; i++) {
        cout << a.at(i) << endl;
    }
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define MAX 200000
#define MOD 1000000007
#define INF 4000000000000000000
#define EPS 0.0000000000001
//vector<int> A[MAX];
bool cnt[MAX];
int main()
{
    int N,K,i,j,d;
    int ss;
    scanf("%d %d",&N,&K);
    for(i=0;i<K;i++)
    {
        scanf("%d",&d);
        for(j=0;j<d;j++)
        {
            scanf("%d",&ss);
            cnt[ss]=true;
        }
    }
    int ans=0;
    for(i=1;i<=N;i++)
    {
        if(!cnt[i]) ans++;
    }
    printf("%d",ans);
    return 0;
}



Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
const int mn=1e5+10;
vector<int> pos,neg;
int main()
{
    int n,i,x,z=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(x>0)pos.push_back(x);
        else if(x<0)neg.push_back(x);
        else z++;
    }
    while(z--){
        if(pos.size()<neg.size())pos.push_back(0);
        else neg.push_back(0);
    }
    if(!pos.size()){
        sort(neg.begin(),neg.end());
        if(n==1)printf("%d",neg[0]);
        else{
            int sum=0,cum=neg[n-1];
            for(i=0;i<n;i++)sum-=neg[i];
            sum+=neg[n-1]*2;
            printf("%d\n",sum);
            for(i=n-2;i>=0;i--){
                printf("%d %d\n",cum,neg[i]);
                cum-=neg[i];
            }
        }
    }
    else if(!neg.size()){
        sort(pos.begin(),pos.end());
        if(n==1)printf("%d",pos[0]);
        else{
            int sum=0,cum=pos[0];
            for(i=0;i<n;i++)sum+=pos[i];
            sum-=pos[0]*2;
            printf("%d\n",sum);
            for(i=1;i<n-1;i++){
                printf("%d %d\n",cum,pos[i]);
                cum-=pos[i];
            }
            printf("%d %d\n",pos[n-1],cum);
        }
    }
    else{
        int sum=0;
        for(i=0;i<pos.size();i++)sum+=abs(pos[i]);
        for(i=0;i<neg.size();i++)sum+=abs(neg[i]);
        printf("%d\n",sum);
        for(i=1;i<pos.size();i++){
            printf("%d %d\n",neg[0],pos[i]);
            neg[0]-=pos[i];
        }
        for(i=0;i<neg.size();i++){
            printf("%d %d\n",pos[0],neg[i]);
            pos[0]-=neg[i];
        }
    }
}


Measured memory_bytes: 2424