akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	ll n;

	cin >> n;

	if (n == 1) {
		cout << 0 << endl;
	}
	else if (n == 2) {
		cout << 1 << endl;
	}
	else if (n % 2 == 1) {
		//cout << (n - 1) * ((n - 1) / 2) << endl;
		cout << n * ((n - 1) / 2) << endl;
	}
	else if (n % 2 == 0) {
		ll num = n - 1;
		//cout << (num - 1) * ((num - 1) / 2) + (num - 1) << endl;
		//cout << num * ((num - 1) / 2) + (num - 1) << endl;
		//cout << num * 2 << endl;
		cout << n * ((n - 2)/2) + (n / 2) << endl;
	}



	//for (int j = 1; j <= 13; j++) {
	//	for (int i = 1; i <= 13; i++) {
	//		if (j == i)continue;
	//		cout  << j << "%" << i << " " << j % i << endl;
	//	}
	//}

	return 0;
}

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

using namespace std;

int main(){
    vector<int> lunch(5);
    for(int i = 0; i < 5; i++){
        cin >> lunch[i];
    }

    int sum = 1e9;
    do{

        int ans = 0;
        for(int i = 0; i < 5; i++){
            while(ans % 10 != 0) ans++;
            ans += lunch[i];
        }

        sum = min(sum,ans);
    }while (next_permutation(lunch.begin(),lunch.end()));

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n;
  	cin>>n;
  	bool f=false;
	char c;
	for(int i=0;i<n;i++){
		scanf("%c",&c);
		if(c=='Y') f=true;
	}
	if(f) cout<<"Four"<<endl;
	else cout<<"Three"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;
  ll ans = 0;
  rep(i, n) {
    int cnt = 2;
    if(a[i] == b[i]) cnt--;
    if(b[i] == c[i]) cnt--;
    if(c[i] == a[i]) cnt--;
    cnt = max(0, cnt);

    ans += cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

vector<int> E[110000];
int parent[110000];
int depth[110000];

void f(int u, int d){
	depth[u] = d;
	for(int i = 0; i < E[u].size(); i++){
		f(E[u][i], d + 1);
	}
}

int main(){
	
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		parent[i] = -1;
	}
	
	for(int i = 0; i < n; i++){
		int id, num;
		cin >> id >> num;
		for(int j = 0; j < num; j++){
			int c;
			cin >> c;
			E[id].push_back(c);
			parent[c] = id;
		}
	}
	
	for(int i = 0; i < n; i++){
		if(parent[i] == -1){
			f(i, 0);
			break;
		}
	}
	
	for(int i = 0; i < n; i++){
		cout << "node " << i << ": parent = " << parent[i];
		cout << ", depth = " << depth[i] << ", ";
		if(parent[i] == -1){
			cout << "root";
		}else if(E[i].size() == 0){
			cout << "leaf";
		}else{
			cout << "internal node";
		}
		cout << ", [";
		if(E[i].size() > 0){
			cout << E[i][0];
		}
		for(int j = 1; j < E[i].size(); j++){
			cout << ", " << E[i][j];
		}
		cout << "]" << endl;
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i = 0; i < n; i++) cin >> d[i];
    sort(d, d + n);
    cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int p[n];
    int total = 0;
    rep(i,n){
        cin >> p[i];
        if (i >= 2)
        {
            if ((p[i-2] < p[i-1] && p[i-1] < p[i]) || (p[i-2]>p[i-1]&&p[i-1]>p[i]))
            {
                total++;
            }
        }
    }
    cout << total;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,m,a,sum=0;
    cin >> n >> m;
    for(i=1;i<=m;i++)
    {
        cin >> a;
        sum+=a;
    }
    if(sum>n) cout << -1 << endl;
    else cout << n-sum << endl;

}


Measured memory_bytes: 3636
s = input()
n = len(s)
k = int(input())
dp = [[[0 for _ in range(2)] for _ in range(k + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for a in range(n):
    for b in range(k + 1):
        for c in range(2):
            nd = int(s[a])
            for d in range(10):
                na, nb, nc = a + 1, b, c
                if 0 != d:
                    nb += 1
                if k < nb:
                    break
                if 0 == nc:
                    if nd > d:
                        nc = 1
                    if nd < d:
                        break
                dp[na][nb][nc] += dp[a][b][c]
print(sum(dp[-1][-1]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    VL v(n);
    VL add(n);
    VL sub(n);
    rep(i, n)
    {
        cin >> v[i];
        add[i] = v[i] + i;
        sub[i] = v[i] - i;
    }
    map<ll, ll> msub;
    rep(i, n)
    {
        msub[sub[i]]++;
    }
    ll ans = 0;
    rep(i, n)
    {
        msub[sub[i]]++;
        ans += msub[-add[i]];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 30716
//Name: Flowers
//Level: 3
//Category: 貪欲,Greedy,Priority queue
//Note:

/**
 * 水をWリットル与えてから、それぞれの花ごとに肥料で調整していくので、Wを決定すれば全体のコストも求められる。
 * WをΔWだけ増やすと、それぞれの花で後で必要な肥料の量がvwΔW / vfだけ減少するから、肥料のコストはpf × vwΔW / vfだけ減少する
 * （vwが負の場合、コストは増加することになる）。
 * また、水そのものの費用がpwΔWだけかかる。
 *
 * 水を増やしていくと発生するイベントは
 * ・ある花のvitalityがthを超え、肥料のコストが影響しなくなる。
 * ・ある花のvitalityがthを割り、それまで必要のなかった肥料を増やす必要が出てくる。
 * これらのいずれも、水やりのコストを上げる方向に作用する。
 * したがって、ΔWの係数 pw - Σpf_i × vw_i / vf_i は水やりを進めるにしたがって単調増加していく。
 * この係数が負になっている間は、水やりを続けると得をするが、正になると肥料のみに切り替えたほうがよくなる。
 *
 * このようなイベントが発生する時刻は固定なので、あらかじめ求めてからソートしておき、係数の変化をシミュレーションすればよい。
 * オーダーは O(N log N)。
 */

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;
    
    double PW;
    cin >> PW;
    vector<pair<double,double>> ds;
    double ans = 0;
    double cur_eff = PW;
    for(int i = 0; i < N; ++i) {
        double vw, pf, vf, th;
        cin >> vw >> pf >> vf >> th;
        if(th >= 0) ans += th / vf * pf;
        const double t = th / vw;
        const double eff = pf * vw / vf;
        if(th >= 0 && vw > 0) {
            ds.emplace_back(t, eff);
            cur_eff -= eff;
        } else if(th <= 0 && vw < 0) {
            ds.emplace_back(t, -eff);
        } else if(th >= 0 && vw < 0) {
            cur_eff -= eff;
        }
    }
    sort(begin(ds), end(ds));
    double prev = 0;
    for(auto &d : ds) {
        if(cur_eff > 0) break;
        //cout << cur_eff << ": " << ans << endl;
        ans += cur_eff * (d.first - prev);
        cur_eff += d.second;
        prev = d.first;
    }
    cout << ans << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

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

int main() {
  
  long long A, B;
  
  cin >> A >> B;
  long long t;
  long long r;
  long long x = A * B;
  if(A < B){
    t = A;
    A = B;
    B = t;
  }
 
  r = A % B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
  cout << x / B << endl;
}


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

void up_sort(int* a, int N);

int main(void)
{
  int N;
  // cout << "please input the number of cards" << endl;
  cin >> N;
  // cout << "please input the card number" << endl;
  int a[N];
  for(int i=0; i<N; i++)
  {
    cin >> a[i];
  }

  int Alice_sum,Bob_sum;
  Alice_sum = Bob_sum = 0;
  //得点をソートする b[N]
  up_sort(a,N);

  for(int j=0; j<N; j++)
  {
    if(j%2==0)
      Alice_sum += a[j];
    else
      Bob_sum += a[j];
  }

  cout << Alice_sum-Bob_sum << endl;
  return 0;
}

void up_sort(int* a, int N)
{
  for(int i=0; i<N-1; i++){
    int temp=a[i];
    for(int j=0; j<N-i-1; j++){
      if(a[i]<a[i+j+1]){
        temp=a[i];
        a[i]=a[i+j+1];
        a[i+j+1]=temp;
      }
    }
  }
}


Measured memory_bytes: 256
#pragma region
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
#pragma endregion
const int maxn = 3005;
ll a[maxn], dp[maxn][maxn];
int main() {
    IO;
    int n;
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    per(l, 1, n) rep(r, l, n)
        dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
    cout << dp[1][n] << endl;
}

Measured memory_bytes: 49784
// 2020-07-06 01:43:12
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  ll ans = 0;
  REPC(i, 1, n) {
    ans += ll(i) * (n-i+1);
  }
  rep(_, n-1) {
    int u, v;
    cin >> u >> v;
    if(u > v) swap(u, v);
    ans -= ll(u) * (n-v+1);
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main()
{
    long long n,i,s=0;
    cin>>n;
    long long a[n+1];
    long long b[n];
    for(i=0;i<n+1;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        if(b[i]<a[i])
        {
            s=s+b[i];
        }
        else
        {
            s=s+a[i];
            b[i]=b[i]-a[i];
            if(b[i]<a[i+1])
            {
                s=s+b[i];
                a[i+1]=a[i+1]-b[i];
            }
            else
            {
                s=s+a[i+1];
                a[i+1]=0;
            }

        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 5216
#include<stdio.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
int main(){
  ll h,w;
  scanf("%lld%lld",&h,&w);
  if((h*w)%3==0){
    puts("0");
    return 0;
  }
  ll ans = h*w;
  if(h>w){
    ll t=w;
    w=h;
    h=t;
  }
  //ll x=h/2,y=h/2+h%2;
  for(int i=1;i<w;i++){
    ll x=(w-i)*(h/2),y=(w-i)*(h/2+h%2),z=i*h;
    ans=min((max(y,z)-min(x,z)),ans);
  }
  ans=min(ans,h);
  if(h<w){
    ll t=w;
    w=h;
    h=t;
  }
  ll s,t=1;
  //ll x=h/2,y=h/2+h%2;
  for(int i=1;i<w;i++){
    ll x=(w-i)*(h/2),y=(w-i)*(h/2+h%2),z=i*h;
    ans=min((max(y,z)-min(x,z)),ans);
    if(s!=ans)t=i;
    s=ans;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(a>=c){
		cout<<a-c<<" "<<b<<endl;
		return 0;
	}
	else{
		cout<<0<<" "<<max(0ll,b-(c-a))<<endl;
		return 0;
	}
	return 0;
} 

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

int main()
{
	int N, u, v;
	cin >> N >> u >> v;
	--u; --v;
	
	vector<vector<int>> G(N, vector<int>());
	for (int i = 0; i < N - 1; ++i)
	{
		int A, B;
		cin >> A >> B; --A; --B;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	
	vector<int> t_dist(N, 0), a_dist(N, 0);
	vector<bool> t_visited(N, false), a_visited(N, false);
	queue<int> q;
	
	t_visited[u] = true;
	t_dist[u] = 0;
	q.push(u);
	while (!q.empty())
	{
		int c = q.front(); q.pop();
		for (int n : G[c])
		{
			if (t_visited[n])
				continue;
			t_visited[n] = true;
			t_dist[n] = t_dist[c] + 1;
			q.push(n);
		}
	}
		
	a_visited[v] = true;
	a_dist[v] = 0;
	q.push(v);
	while (!q.empty())
	{
		int c = q.front(); q.pop();
		for (int n : G[c])
		{
			if (a_visited[n])
				continue;
			a_visited[n] = true;
			a_dist[n] = a_dist[c] + 1;
			q.push(n);
		}
	}

	int best_i = 0, best_d = 0;
	for (int i = 0; i < N; ++i)
	{
		if (t_dist[i] <= a_dist[i] && a_dist[i] > best_d)
		{
			best_i = i;
			best_d = a_dist[i];
		}
	}
	
	cout << best_d - 1 << '\n';
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{int n,m,s[106],sum;
scanf("%d%d",&n,&m);sum=0;
 for(int i=1;i<=n;i++)
    scanf("%d",&s[i]);
 sort(s+1,s+1+n);
 int i;
    for( i=1;i<=n&&m;i++)
    {
        if(s[i]<=m)sum++,m-=s[i];
        else break;
        //cout<<1;
    }
   if(sum==0)puts("0");
    else
   if(m&&i==n+1)printf("%d",sum-1);
   else printf("%d",sum);

    return 0;
}


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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define trace(...)
#endif

lld a[100010];

struct dsu{
	vector <int> P, rank, sz;//, sm;
	dsu(int n) : P(n), rank(n), sz(n) {
		for(int i = 0; i < n; i++){
			P[i] = i;
			rank[i] = 0;
			sz[i] = 1;

		}
	}
	int fnd(int i){
		if(i != P[i]) P[i] = fnd(P[i]);
		return P[i];
	}
	void join(int x, int y){
		int PX = fnd(x);
		int PY = fnd(y);
		if(rank[PX] > rank[PY]) {
			P[PY] = PX;
			sz[PX] += sz[PY];
		}
		else {
			P[PX] = PY;
			sz[PY] += sz[PX];
		}
		if(rank[PX]==rank[PY]) {
			rank[PY]++;
		}
	}
};

bool vis[100010];
vector <lld> vpp[100010];

main(){
    int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	dsu d(n+2);
	for(int x, y, i = 0; i < m; ++i){
		cin >> x >> y;
		d.join(x, y);
	}
	if(n == 1){
		return cout << 0 << endl, 0;
	}
	lld ans = 0;
	vector <lld>  vct;
	for(int i = 0; i < n; ++i){
		int pp = d.fnd(i);
		// trace(i, pp);
		if(vis[pp]) continue;
		vis[pp] = 1;
		vct.pb(d.sz[pp]);
	}
	sort(all(vct));
	reverse(all(vct));
	int res = vct[0];
	for(int i = 1; i < vct.size(); ++i){
		if(res == 0) return cout << "Impossible\n", 0;
		res = res + vct[i] - 2;
	}
	for(int i = 0; i < n; ++i){
		int pp = d.fnd(i);
		vpp[pp].pb(a[i]);
	}
	int cntr = 0;
	vector <lld> others;
	for(int i = 0; i < n; ++i){
		if(vpp[i].size() > 0){
			cntr++;
			sort(all(vpp[i]));
			// trace(vpp[i][0]);
			ans += vpp[i][0];
			for(int j = 1; j < vpp[i].size(); ++j) others.pb(vpp[i][j]);
		}
	}
	sort(all(others));
	for(int i = 0; i < cntr-2; ++i){
		ans += others[i];
	}
	if(cntr == 1) ans = 0;
	cout << ans << endl;
}


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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	int a, b, c, k, ans = 0;
	cin >> a >> b >> c >> k;
	while (b <= a) {
		ans++;
		b *= 2;
	}
	while (c <= b) {
		ans++;
		c *= 2;
	}

	cout << (ans <= k ? "Yes" : "No");
	return 0;
}

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

int main() {
    int N;cin >> N;
    int p[N] = {};int q[N] = {};
    for (int i = 0;i < N;i++){
        cin >> p[i];
    }
    for (int i = 0;i < N;i++){
        cin >> q[i];
    }
    int v[N] = {};
    for (int i = 0;i < N;i++){
        v[i] = i + 1;
    }

    int a,b;int X = 1;

    do{
        int pflag = 0;int qflag = 0;
        for (int i = 0;i < N;i++){
            if (v[i] != p[i]) pflag = 1;
            if (v[i] != q[i]) qflag = 1;
        }
        if(pflag == 0) a = X;
        if(qflag == 0) b = X;
        X++;
    }while(next_permutation(v,v + N));
    cout << abs(a-b) << endl;
}

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

int main() {
    ll N;
    cin >> N;
    ll ans = 1;
    ll ans1 = 1;
    ll ans2 = 1;
    for(int i = 0; i < N; i++) {
        ans *= 10;
        ans %= 1000000007;
        ans1 *= 8;
        ans1 %= 1000000007;
        
    }
    for(int i = 0; i < N; i++) {
        ans2 *= 9;
        ans2 %= 1000000007;
        
    }
    if((ans2 - ans1) % 1000000007 < 0) ans2 = (ans2 - ans1 + 1000000007) % 1000000007;
     else ans2 = (ans2 - ans1) % 1000000007;
    if((ans - ans1) % 1000000007 < 0) ans = (ans + 1000000007 - ans1) % 1000000007;
    else ans = (ans - ans1) % 1000000007;
    if((ans - ans2) % 1000000007 < 0) ans = (ans + 1000000007 - ans2) % 1000000007;
    else ans = (ans - ans2) % 1000000007;
    if((ans - ans2) % 1000000007 < 0) ans = (ans + 1000000007 - ans2) % 1000000007;
    else ans = (ans - ans2) % 1000000007;
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3620
#include<iostream>

int main(){
    
    int x;
    std::cin >> x;

    int h = x/3600;
    int m = (x - h*3600) / 60;
    int s = (x - h*3600 - m*60 );
    
    std::cout << h << ":" << m << ":" << s << std::endl;
    
    return 0;
    
}


Measured memory_bytes: 3092
x1, y1, x2, y2 = map(int, input().split())

x_dif = x2 - x1
y_dif = y2 - y1

x3, y3 = (x2 - y_dif, y2 + x_dif)
x4, y4 = (x1 - y_dif, y1 + x_dif)

print(x3, y3, x4, y4)


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

bool check_sqrt(int n) {
    for (int i = 0; i * i <= n; i++) {
        if (i * i == n)
            return true;
    }
    return false;
}

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> v(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> v[i][j];
        }
    }

    int res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int sum = 0;
            for (int k = 0; k < D; k++) {
                int diff = abs(v[i][k] - v[j][k]);
                sum += diff * diff;
            }
            if (check_sqrt(sum))
                res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		
		System.out.println(a+(int)Math.pow(a, 2)+(int)Math.pow(a, 3));
	}
 
}

Measured memory_bytes: 27024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

int main() {
	int s, w;
	scanf ("%d%d",&s,&w);
	if (w >= s) printf ("unsafe\n");
	else printf ("safe\n");
	return 0;
}


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

void solve(long long N, long long p[]){
	long long max = 0;
	long long res = 0;
	for(int i = 0 ; i <= N-1 ; i++){
		if (p[i] > max) max = p[i];
		res += p[i];
	}
	res -= max/2;
	printf("%lld\n", res);
}

int main(){
	long long N;
	scanf("%lld",&N);
	long long p[N];
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&p[i]);
	}
	solve(N, p);
	return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X, Y = MI()
    ans = 0
    while X<=Y:
        X*=2
        ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

char toUpper(const char c) {
    if ('a' <= c && c <= 'z') {
        return c + 'A' - 'a';
    } else {
        return c;
    }
}

int main(){
    string a, b, c;
    cin >> a >> b >> c;

    cout << toUpper(a[0]) << toUpper(b[0]) << toUpper(c[0]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    double x1;
    double y1;
    double x2;
    double y2;

    cin >> x1 >> y1 >> x2 >> y2;

    double dispow = pow(x2 - x1, 2) + pow(y2 - y1, 2);
    double distance = sqrt(dispow);

    printf("%.5f\n", distance);

    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a1(n), a2(n);
    rep(i, n) cin >> a1[i];
    rep(i, n) cin >> a2[i];
    vint s1(n), s2(n);
    s1[0] = a1[0];
    s2[0] = a2[0];
    rep(i, n-1) s1[i+1] = s1[i] + a1[i+1];
    rep(i, n-1) s2[i+1] = s2[i] + a2[i+1];
    int ans = 0;
    rep(i, n) {
        int tmp = s1[i]+s2[n-1];
        if (i != 0) tmp -= s2[i-1];
        ans = max(ans, tmp);
    }

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  ll n; cin >> n;
  
  ll cnt = 0;
  rep(i,n){
    ll a,b; cin >> a >> b;
    if(a == b) cnt++;
    else{
      if(cnt >= 3){
        cout << "Yes" << endl;
        return 0;
      }
      else cnt = 0;
    }
  }
  
  if(cnt >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

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


int main()
{
    ll n;
    cin >> n;
    vector<ll> d(n);
    for(ll i = 0; i < n; i++) cin >> d[i];
    ll ans = 0;
    for(ll i = 0; i < n - 1; i++){
        for(ll j = i + 1; j < n; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n, l; 
    cin >> n >> l;
    int tot = n*(n+2*l-1)/2;
    if (l > 0) tot -= l;
    if (n+l-1 < 0) tot -= l+n-1; 
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
t=input()
ls,lt=[],[]
for cs in s:
    ls.append(cs)
for ct in t:
    lt.append(ct)
ls.sort()
lt.sort(reverse=True)
s="".join(ls)
t="".join(lt)
if s<t: print("Yes")
else: print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;


int main(){
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m = min(a, b);
    m = min(m, c);
    m = min(m, d);
    m = min(m, e);

    ll res = (n - 1) / m + 1;
    res += 4;

    cout << res << endl;



    return 0;
}


Measured memory_bytes: 256
D=int(input())
c = list(map(int,input().split()))
s=[[0 for e in range(26)] for f in range(D)]
for i in range(D):
 s[i]=list(map(int,input().split()))
last=[0]*26
ans=0
point=[0]*D
for i in range(D):
 saidai=-(10**10)
 kouho=1
 for j in range(26):
  if s[i][j]+c[j]*((i+1)-last[j])>=saidai:
   kouho=j+1
   saidai=s[i][j]+c[j]*((i+1)-last[j])
 print(1)

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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 A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    ll K, A, B;
    cin >> K >> A >> B;

    ll tmp = B - A;
    ll num = 1;
    if (tmp > 1) {
        if (A < K) {
            num += A - 1;
            K -= A - 1;
        } else {
            num += K;
            cout << num << endl;
            return 0;
        }
        num += tmp * (K / 2);
        num += K % 2;
        cout << num << endl;
    } else {
        cout << num + K << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for (int i=1; i<=n; ++i){
        int num = i;
        int dig = 0;
        while(num > 0){
            num /= 10;
            dig++;
        }
        if(dig % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            string[] str2 = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            long aa =0;
            foreach(string aaa in str2 )
            {
                aa += long.Parse(aaa);
            }
            if(long.Parse( str[0])<=aa)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int n;
int INF=300000;
vector<int> p(200000);
int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  int min=INF;
  int res=0;
  for(int i=0;i<n;i++){
    if(p.at(i)<=min){
      min=p.at(i);
      res+=1;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 1000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int m,d;
cin>>m>>d;
int cnt=0;
rep(i,0,d+1)
{
  int x;
  x=i%10;
  int y=i/10;
  y=y%10;
  if(x>=2&&y>=2)
  {
  	if(x*y>=1&&x*y<=m)
  	cnt++;
  }
}
cout<<cnt;
}

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



int main() {
    int N,M;
    cin>>N>>M;
    int ans1,ans2;
    ans1=N*(N-1)/2;
    ans2=M*(M-1)/2;
    cout<<ans1+ans2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int k, s;
    cin >> k >> s;

    int cnt = 0;
    for( int i = 0; i <= k; ++i ) {
        for( int j = 0; j <= k; ++j ) {
            if( s - ( i + j ) <= k && s - ( i + j ) >= 0 ) ++cnt;

        }
    }

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



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


int main() {
    int n;
    cin >> n;
    for(int i = 0; i <= n; ++i) {
        int x = (int)(i * 1.08);
        if(x == n) {
            cout << i;
            return 0;
        }
    }
    cout << ":(";
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X, A, B;
    cin >> X >> A >> B;

    if (A >= B)
    {
        cout << "delicious";
    }
    else if (X - (B - A) >= 0)
    {
        cout << "safe";
    }
    else
    {
        cout << "dangerous";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 400;
const int INF = 19191919;
int dp[N];

int main(){
    int n;
    cin >>n;
    vector<int> s(n),l(n),p(n);
    rep(i,n) cin >>s[i] >>l[i] >>p[i];

    int m;
    cin >>m;
    vector<int> w(m);
    rep(i,m) cin >>w[i];

    rep(i,N) dp[i] = -INF;
    dp[0] = 0;

    rep(i,N){
        if(dp[i] < 0) continue;

        rep(j,n){
            for(int k=s[j]; k<=l[j]; ++k){
                if(i+k >= N) continue;
                dp[i+k] = max(dp[i+k], dp[i]+p[j]);
            }
        }
    }

    vector<int> a(m);
    rep(i,m){
        int ans = dp[w[i]];
        if(ans<0){
            cout << -1 << "\n";
            return 0;
        }
        a[i] = ans;
    }

    rep(i,m) cout << a[i] << "\n";
    return 0;
}



Measured memory_bytes: 3112
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
a = III()

count = [0]*(10**5+1)
for i in range(N):
    count[a[i]] += 1

ans = 0
for i in range(1,10**5):
    temp = count[i]+count[i-1]+count[i+1]
    if temp>ans:
        ans = temp

print(ans)

Measured memory_bytes: 52804
#include<bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int counts[100010]={};

int main(){_;
  string s;cin>>s;
  int n=s.size();

  int index=0;
  while(index<n){
    int rnum=0;
    int lnum=0;
    while(s[index]=='R'){
      rnum++;
      index++;
    }
    int flip=index;
    while(s[index]=='L'){
      lnum++;
      index++;
    }
    int rhalf=rnum/2;
    int lhalf=lnum/2;
    counts[flip-1]=(rnum-rhalf)+lhalf;
    counts[flip]=rhalf+(lnum-lhalf);
  }
  REP(i,n){
    cout<<counts[i];
    if(i==n-1) cout<<endl;
    else cout<<" ";
  }
}


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

pair<int, int> d[101];

bool cmp(pair<int, int> l, pair<int, int> r){
  if(l.first>r.first) return true;
  if(l.first==r.first) return l.second < r.second;
  return false;
}

int main(){
  int n;
  for(int i=0; i<101; i++){
    d[i].first = 0;
    d[i].second = i;
  }
  while(cin >> n){
    d[n].first++;
  }
  sort(d, d+101, cmp);
  for(int i=0; i<101; i++){
    if(d[0].first > d[i].first)break;
    cout << d[i].second << endl;
  }
  return 0;
}

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

int val[100010], l[100010], r[100010];
queue<int> wl;
vector<int> graph[100010];
int n, u, v, k, p;
bool had_val[100010];

int main() {
    memset(r, 63, sizeof(r));
    memset(l, -63, sizeof(l));
    scanf("%d", &n);
    for(int i = 1; i < n; i++) {
        scanf("%d%d", &u, &v);
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    scanf("%d", &k);
    for(int i = 0; i < k; i++) {
        scanf("%d%d", &v, &p);
        val[v] = l[v] = r[v] = p;
        had_val[v] = true;
        wl.push(v);
    }
    while(not wl.empty()) {
        u = wl.front(); wl.pop();
        for(int v : graph[u]) {
            if(l[v] < l[u] - 1) wl.push(v);
            l[v] = max(l[v], l[u]-1);
        }
    }
    for(int i = 1; i <= n; i++) {
        if(had_val[i]) wl.push(i);
    }
    while(not wl.empty()) {
        u = wl.front(); wl.pop();
        for(int v : graph[u]) {
            if(r[v] > r[u] + 1) wl.push(v);
            r[v] = min(r[v], r[u] + 1);
        }
    }
    for(int i = 1; i <= n; i++) {
        if(l[i] > r[i]) return !printf("No");
        if(l[i] == r[i]) had_val[i] = true, val[i] = l[i];
        if(had_val[i]) wl.push(i);
    }
    while(not wl.empty()) {
        u = wl.front(); had_val[u] = true; wl.pop();
        for(int v : graph[u]) {
            if(had_val[v] && abs(val[v] - val[u]) < 2 && abs(val[v] - val[u]) % 2 == 0) return !printf("No");
            else if(not had_val[v]) {
                int L = val[u]-1, R = val[u]+1;
                if(l[v] <= L && L <= r[v]) val[v] = L;
                else if(l[v] <= R && R <= r[v]) val[v] = R;
                wl.push(v);
            }
        }
    }
    printf("Yes\n");
    for(int i = 1; i <= n; i++) printf("%d\n", val[i]);
}


Measured memory_bytes: 8440
N,K=map(int,input().split())
*X,=map(int,input().split())
i=0
ans=[]
while i+K-1<N:
    a,b=X[i],X[i+K-1]
    if b<0:
        ans.append(abs(a))
    elif a>0:
        ans.append(b)
    else:
        a=abs(a)
        ans.append(a+b+min(a,b))
    i+=1
print(min(ans))

Measured memory_bytes: 20084
#include<stdio.h>

int main(void)
{
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);

  int i,c[100],j=0;
  for(i=1;(i<=a)||(i<=b);i++)
    if((a%i==0)&&(b%i==0)){
      j++;
      c[j]=i;
    }

  printf("%d\n",c[j-k+1]);
  return 0;
}

Measured memory_bytes: 128