akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputLine = Console.In.ReadLine();
            var inputs = inputLine.Split(new char[] { ' ', '\t', '　' });
            if (inputs.Length != 2)
            {
                return;
            }

            var integers = new List<int>();
            foreach (var s in inputs)
            {
                integers.Add(int.Parse(s));
            }

            var a = integers[0];
            var b = integers[1];

            var d = a / b;
            var r = a % b;
            var f = a / (double)b;

            Console.WriteLine("{0} {1} {2:0.00000}", d, r, f);
        }
    }
}


Measured memory_bytes: 18080
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iomanip>

using namespace std;

int a,b,c;

int main()
{
	cin>>a>>b>>c;
	if(a==b||b==c||c==a)
	{
		if(a!=b||a!=c||c!=b)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		
	}
	cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second



int main() {
	int n;
	cin >> n;
	vector<double> p(n);
	forn(i, n) cin >> p[i];
	double dp[n+1][n+1];
	forn(i, n+1) dp[0][i]=0;
	dp[0][0]=1;
	dp[1][0] = 1-p[0];
	for(int i = 2; i <n+1; i++){
		dp[i][0] = dp[i-1][0]*(1-p[i-1]);
	}
	for(int i = 1; i < n+1; i++)
		dp[i][i] = p[i-1];
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			dp[i][j] = p[i-1]*dp[i-1][j-1] + (1-p[i-1])*dp[i-1][j];
		}
	}
	ld res = 0;
	for(int i = n/2+1; i <= n; i++){
		res += dp[n][i];
	}
	cout << fixed << setprecision(9) << res << endl;
	return 0;

}



Measured memory_bytes: 70528
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int a, b, c, d, e;
	int k;
	cin >> a >> b >> c >> d >> e >> k;

	if (e - a <= k)print("Yay!");
	else print(":(");






	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
class UnionFind():
    def __init__(self, n):
        self.parent = [-1]*n
    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]
    def union(self, x,y):
        root_x = self.root(x)
        root_y = self.root(y)
        if root_x == root_y:
            return False
        # root_xのほうが要素が多い
        if self.parent[root_x] < self.parent[root_y]:
            self.parent[root_x] += self.parent[root_y]
            self.parent[root_y] = root_x
        else:
            self.parent[root_y] += self.parent[root_x]
            self.parent[root_x] = root_y
        return True
    def lists(self):
        d = defaultdict(list)
        for i in range(len(self.parent)):
            parent = self.root(i)
            d[parent].append(i)
        return d

def main():
    n, m = map(int, input().split())
    ps = list(map(int, input().split()))
    UF = UnionFind(n)
    for i in range(m):
        x, y = list(map(int, input().split()))
        UF.union(x-1, y-1)
    ans = 0
    for indices in UF.lists().values():
        indices_set = set(indices)
        p_set = set(ps[i]-1  for i in indices)
        ans += len(p_set & indices_set)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 30684
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n;
    cin >>n;
    // max possible answer can be n - 1 if a and b are 1 and n - 1
    long long int ans = n - 1;
    for(long long int i = 1; i <= 1000000; i++){
        if(n%i == 0){
            ans = min(ans, i + n / i - 2);
        }
    }
    cout <<ans;    
    return 0;
}


Measured memory_bytes: 256
#include "iostream"

using namespace std;

int main() {

	int n, q;
	int s[10000], t[500];

	int a = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> t[i];
	}

	for (int i = 0; i < q; i++) {
		for (int j = 0; j < n; j++) {
			if (t[i] == s[j]) {
				a++;
				break;
			}
		}
	}

	cout << a << endl;

	return 0;
}

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

using namespace std;

#define EPS 1e-10

int main() {
	int n;
	while (cin >> n, n) {
		vector<int> I(n);
		for (auto& a : I) cin >> a;
		int s, a, c;
		double h = 1e18;
		for (int i = 0; i < 16; ++i) {
			for (int j = 0; j < 16; ++j) {
				for (int k = 0; k < 16; ++k) {
					int cnt[256] = {};
					int r = i;
					for (int h = 0; h < n; ++h) {
						r = (j * r + k) % 256;
						cnt[(I[h] + r) % 256]++;
					}
					double tmp = 0;
					for (int h = 0; h < 256; ++h) {
						if (cnt[h] == 0) continue;
						tmp -= (double)cnt[h] / n * log((double)cnt[h] / n);
					}
					if (tmp + EPS < h) h = tmp, s = i, a = j, c = k;
				}
			}
		}
		cout << s << " " << a << " " << c << endl;
	}

	return 0;
}


Measured memory_bytes: 3248
#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); }
template<int MOD>
struct ModInt {
	static const int kMod = MOD;
	unsigned x;
	ModInt() :x(0) {}
	ModInt(signed x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; }
	ModInt(signed long long x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; }
	int get()const { return (int)x; }
	ModInt &operator+=(ModInt m) { if ((x += m.x) >= MOD)x -= MOD; return *this; }
	ModInt &operator-=(ModInt m) { if ((x += MOD - m.x) >= MOD)x -= MOD; return *this; }
	ModInt &operator*=(ModInt m) { x = (unsigned long long)x*m.x%MOD; return *this; }
	ModInt &operator/=(ModInt m) { return *this *= m.inverse(); }
	ModInt operator+(ModInt m)const { return ModInt(*this) += m; }
	ModInt operator-(ModInt m)const { return ModInt(*this) -= m; }
	ModInt operator*(ModInt m)const { return ModInt(*this) *= m; }
	ModInt operator/(ModInt m)const { return ModInt(*this) /= m; }
	ModInt operator-()const { return ModInt(MOD - (signed)x); }
	bool operator==(ModInt m)const { return x == m.x; }
	bool operator!=(ModInt m)const { return x != m.x; }
	ModInt inverse()const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		if (u < 0)u += MOD;
		return ModInt(u);
	}
};
template<int MOD>
ostream &operator<<(ostream &os, const ModInt<MOD> &m) { return os << m.x; }
template<int MOD>
istream &operator>>(istream &is, ModInt<MOD> &m) { signed long long s; is >> s; m = ModInt<MOD>(s); return is; };

template<int MOD>
ModInt<MOD> pow(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while (k) {
		if (k & 1)r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}

using mint = ModInt<MOD>;


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; string S;
	cin >> N >> S;
	int cnt[26] = {};
	rep(i, 0, N) {
		cnt[S[i] - 'a']++;
	}
	mint ans = 1;
	rep(i, 0, 26) {
		if (cnt[i]) {
			ans *= (cnt[i] + 1);
		}
	}
	ans -= 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const [N, A, B] = lines[0].split(' ').map(Number)

    const diff = Math.abs(A - B)

    console.log(diff % 2 ? 'Borys' : 'Alice')

})(input)


Measured memory_bytes: 29488
import java.util.Scanner;

//ACならず。いちぶWA。悔しい。

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		

		double Ax;
		double Ay;
		double Bx;
		double By;
		double AB;
		double AB2;
		double sita = H/12+M/60/12-M/60;
		//System.out.println(H/12);
		//System.out.println(M/60/12);
		//System.out.println(M/60);
		double sita2;
		
		/*
		if(sita>180) {
			sita = sita -180;
		}
		if(sita<0) {
			sita = -sita;
			if(sita>180) {
				sita = sita -180;
			}
			
		}
		*/
		
				
		//System.out.println(sita);

		//AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(sita)));
		AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));
	/*	System.out.println(2*Math.PI*sita);
		System.out.println(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));


		Ax = A*Math.cos(Math.toRadians((60*H+M)/2));
		Ay = A*Math.sin(Math.toRadians((60*H+M)/2));
		Bx = B*Math.cos(Math.toRadians(6*M));
		By = B*Math.sin(Math.toRadians(6*M));

		AB2 = Math.sqrt(Math.pow(Ax-Bx, 2)+Math.pow(Ay-By, 2));
	 */
		System.out.println(AB);
		//System.out.println(AB2);


	}

}


Measured memory_bytes: 37444
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

int binary_search(ll x, vel a) {
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin();
    } else {
        return -1;
    }
}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll L,R,d,ans = 0;
    cin >> L >> R >> d;
    FOR(i, L, R + 1){
        if(i % d == 0)
            ans++;
    }
    cout << ans << endl;
}

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

#define int long long

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

int N;
int A[111111];

// 1-indexed
int l[111111]; // 左から累積
int r[111111]; // 右から累積

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

signed main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < N; i++) {
    l[i+1] = gcd(l[i], A[i]);
  }
  for (int i = N; i >= 1; i--) {
    r[i] = gcd(r[i+1], A[i-1]);
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int a = l[i-1], b = r[i+1];
    if (a > b) swap(a, b);
    int tmp = a == 0 ? b : gcd(a, b);
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const int MAXN=2e5+5;

int N, K;
ll cnt[MAXN];
vi ds;

int main(){
	scan(N, K);
	for(int i=1; i<=N; i++) cnt[i%K]++;
	ll ans=0;
	for(int a=0; a<K; a++){
		int b = (K-a)%K;
		if((b*2)%K == 0){
			ans += cnt[a]*cnt[b]*cnt[b];
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a, b , k;
    cin >> a >> b >> k;
    set<int> S;
    for (int i = a; i < a+k; i++) 
        S.insert(i);
    for (int i = b-k+1; i <= b; i++)
        S.insert(i);
    FOR_ALL(i,S) if (a <= *i && *i <= b)
        cout << *i << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,x;
	bool flag=true;
	cin>>n>>k;
	int b=n-1;
	vector<int>d;
	vector<int>ans;
	const int N=n;
	const int K=k;
	int a[K][N];
	for(int i=0;i<k;i++){
		cin>>x;
		d.push_back(x);
		for(int j=0;j<d[i];j++){
			cin>>a[i][j];
			if(flag){
				ans.push_back(a[i][j]);
				flag=false;
			}
			else{
				sort(ans.begin(),ans.end());
				if(!binary_search(ans.begin(),ans.end(),a[i][j])){
					b--;
					ans.push_back(a[i][j]);
				}
			}
		}
	}
	cout<<b<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<pair<long long, long long>> job_list(N, make_pair(0, 0));

	for (int i = 0; i < N; i++)
	{
		cin >> job_list[i].first >> job_list[i].second;
	}

	sort(job_list.begin(), job_list.end(), [](const pair<long long, long long>& l, const pair<long long, long long>& r)
	{
		if (l.second == r.second)
		{
			return l.first < r.first;
		}
		return l.second < r.second;
	});

	long long curr_time = 0;
	for (int i = 0; i < N; i++)
	{
		curr_time += job_list[i].first;
		if (curr_time > job_list[i].second)
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N];
  int cnt = 0;
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  for(int i=0; i<N; i++){
    while(a[i]%2 == 0){
      a[i] /= 2;
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main(){
    int n;
    cin>>n;
    int a[n],dp[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
        dp[i]=0;
    }
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){

        dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],dp[i-1]+abs(a[i]-a[i-1]));
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
return 0;
}


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

int main() {
    int n, a[21], b, c[21];
    cin >> n;
    int ans=0;
    for (int i=0;i<n;i++) cin >> a[i];
    for (int i=0;i<n;i++) {
        cin >> b;
        ans+=b;
    }
    for (int i=0;i<n-1;i++) cin >> c[i];
    for (int i=0;i<n-1;i++) {
        if (a[i]+1 == a[i+1]) ans += c[a[i]-1];
    }
    cout << ans << endl;
}

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

const int N = 1e5 + 5;

#define int long long

int n, m;
vector<int> adj[N];
int color[N];
int f[2];
bool visit[N];

void dfs(int u,int col) {
	if (color[u]) {
		if (color[u] == col) {
			cout << n * (n - 1) / 2 - m << endl;
			exit(0);
		}
		return;
	}
	f[col - 1]++;
	color[u] = 3 - col;
	visit[u] = true;
	for (int v : adj[u]) {
		dfs(v, 3 - col);
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 0;i < m;++i) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v), adj[v].push_back(u);
		
	}
	dfs(1, 1);
	cout << f[0] * f[1] - m << endl; 
}

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

int main() {
  int n,a,b,c;
  cin >> n;
  a = n / 3600;
  n = n % 3600;
  b = n / 60;
  c = n % 60;
  cout << a << ':' << b << ':' << c << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MAXN 3009

double dp[MAXN][MAXN], p[MAXN], n;
bool calc[MAXN][MAXN];

double cont(int i, int head){
    if (calc[i][head])    return dp[i][head];
    if (i == 0){ 
        calc[i][head] = 1;
        return dp[i][head] = 1;
    }
    double prob = 1, res = 0;
    prob *= p[i]*cont (i - 1, head);
    res += prob;
    prob = 1;
    if (head > (n/2 + 1)){
        prob *= (1 - p[i])*cont(i -1, head - 1);
        res += prob;
    }   
    calc[i][head] = 1;
    return dp[i][head] = res;
}

int main() {
    //cin.sync_with_stdio(0); cin.tie(0);
    //cin.exceptions(cin.failbit);
    cin >> n;
    //memset(dp, 0, sizeof dp);
    memset(calc, 0, sizeof calc);
    //rep(i,0 , MAXN) cout << dp[i] << ' ';
    //cout << '\n';
    rep(i, 1, n + 1)
        cin >> p[i];

    printf("%.10lf\n", cont(n, n));
    //cout << cont(n, n) << '\n';
    return 0;
}


Measured memory_bytes: 78592
fs = require("fs");

buf = fs.readFileSync('/dev/stdin').toString();
lines = buf.split('\n');
w = lines[1].split(' ').map(Number);

sorted = [].concat(w).sort((a, b) => { return a - b; });

indeces = w.map((x) => { return sorted.indexOf(x); });

groups = (() => {
    let done = new Array(w.length); // undefined or true
    let res = [];
    for (let i = 0; i < w.length; ++i) {
        if (done[i]) continue;
        let g = [];
        let j = i;
        while (!done[j]) {
            done[j] = true;
            g.push(w[j]);
            j = indeces[j];
        }
        res.push(g);
    }
    return res;
})();

groups = groups
    .filter((g) => { return g.length >= 2; })
    .map((g) => { return g.sort((a, b) => { return a - b; }); });

function sum(ary) { return ary.reduce((a, b) => { return a + b; }, 0); }

function calc_cost(group, min) {
    let min1 = sum(group.slice(1)) + group[0] * (group.length - 1);
    let min2 = sum(group) + group[0] + min * (group.length + 1);
    //console.log("group.slice(1) = ", group.slice(1));
    //console.log("min1 = ", min1, ", min2 = ", min2);
    return Math.min(min1, min2);
}

cost = sum(groups.map((g) => { return calc_cost(g, sorted[0]); }));

//console.log(w);
//console.log(sorted);
//console.log(indeces);
//console.log(groups);
console.log(cost);


Measured memory_bytes: 17572
N = int(input())
H = list(map(int, input().split()))

count=[0]*len(H)
h_temp=H[0]
j=0
for i in range(1,len(H)):
  if h_temp>= H[i]:
    count[j] +=1
    h_temp =H[i]
  else:
    j+=1
    h_temp =H[i]
print(max(count))

Measured memory_bytes: 15020
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,k;
    cin >> n >>k;
    vector<ll> a(n);
    cin >> a;
    for(int i=0;i+k<n;i++){
        if(a[i] < a[i+k]) cout << "Yes" <<endl;
        else cout <<"No" <<endl;
    }

}

Measured memory_bytes: 4732
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>

using namespace std;

const long long oo = 1000000000000ll;
const int maxN = 200000;

#define foru(i, l, r) for (int i = l; i <= r; ++i)
#define ford(i, r, l) for (int i = r; i >= l; --i)
#define repu(i, r) for (int i = 0; i < r; ++i)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pint pair < ll, int >

int n, a[maxN], A, B;
ll res;

bool check(ll x) {
    ll y = 0;
    foru(i, 1, n) {
        ll t = A - B;
        if (x * B >= a[i]) continue;
        ll p = a[i] - (x * B);
        y += (p % t) ? (p / t) + 1 : (p / t);
        if (y > x) return false;
    }
    return true;
}

int main() {
    cin >> n >> A >> B;
    foru(i, 1, n) cin >> a[i];
    int l = 1, r = 1000000000;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) res = mid, r = mid - 1;
        else l = mid + 1;
    }
    cout << res;
}


Measured memory_bytes: 640
function Main(input) {
  input = input.trim().split("\n");
  const n = parseInt(input[0], 10);
  const as = input[1].split(" ").map((a) => parseInt(a, 10));

  let minHeight = as[0];
  let totalSteps = 0;

  for (let i=1; i<n; i++) {
    const height = as[i];
    if (minHeight > height) {
      totalSteps += minHeight - height;
    } else {
      minHeight = height;
    }
  }

  console.log(totalSteps);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 50108
#include <iostream>
    #include <string>
    #include <algorithm>
    using namespace std;
    int main()
    {
        string s; cin>>s;
        sort(begin(s), end(s));
        for(int i=0; i<s.size(); i+=2)
            if (s[i]!=s[i+1]) { cout<<"No"<<endl; return 0; }
        cout<<"Yes"<<endl;
    }

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


int main() {
    string s;
    cin>>s;
    int n=s.length();
    if(s[n-1]=='s')
    {
        cout<<s;
        cout<<"es";
    }
    else if(s[n-1]!='s')
    {
        cout<<s;
        cout<<"s";
    }
}

Measured memory_bytes: 3628
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        for (int i = x;; i++)
        {
            if (p(i))
            {
                Console.WriteLine(i);
                return;
            }
        }
    }

    private bool p(int i)
    {
        for (int j = 2; j * j <= i; j++)
        {
            if (i % j == 0)
            {
                return false;
            }
        }

        return true;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
s = []
for i in range(N):
    s += [str(i+1)]*A[i]
for i in range(H):
    s_,s = s[:W],s[W:]
    if i % 2 == 1:
        s_ = s_[::-1]
    print(' '.join(s_))

Measured memory_bytes: 3828
N = int(input())
A = list(map(int, input().split()))

count = 0
ans = 0
for i in range(N):
  if A[i] % 2 == 0:
    count += 1
  if A[i] % 6 == 0 or A[i] % 10 == 0:
    ans += 1

print("APPROVED" if count == ans else "DENIED")

Measured memory_bytes: 3060
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] arrS = Console.ReadLine().Split(' ');
			for(int i = 0; i < arrS.Length; i++)
			{
				string tmp = arrS[i].ToUpper();
				Console.Write(tmp[0]);
			}
			Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13140
abc = list(map(int, input().split()))
count = 0
while abc[0] != abc[1] or abc[1] != abc[2] or abc[2] != abc[0]:
    abc = sorted(abc)
    if len(set(abc)) == 2:
        if abc[0] == abc[1]:
            abc[0] += 1
            abc[1] += 1
        else:
            abc[0] += 2
    else:
        abc[0] += 1
        abc[1] += 1
    count += 1
print(count)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n, base, out, score;
    static String input;
    public static void main(String[] args) {
        while(read()){

        }
    }

    static boolean read(){
        if(!sc.hasNext())return false;
        n = sc.nextInt();
        for(int i = 0; i < n; i++){
            solve();
        }
        return true;
    }

    static void solve(){
        while(out != 3){
            input = sc.next();
            if(input.equals("HIT")){
                base++;
                if(base == 4){
                    score++;
                    base--;
                }
            }else if(input.equals("OUT")){
                out++;
            }else if(input.equals("HOMERUN")){
                score += base + 1;
                base = 0;
            }
        }
        System.out.println(score);
        score = 0;
        base = 0;
        out = 0;
    }

}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
using pll=pair<long long,long long>;
int main(){
    int N,M;cin>>N>>M;
    vector<long long>A(N),B(M),C(M);
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A.begin(),A.end());
    B.resize(M);
    C.resize(M);
    for(int i=0;i<M;i++)cin>>B[i]>>C[i];

    vector<int> id(M);
    iota(id.begin(),id.end(),0);
    //cout<<"hihihi"<<endl;
    //for(int i=0;i<M;i++)cout<<id[i]<<endl;
    sort(id.begin(),id.end(),[&](int i,int j){
        return C[i]>C[j];
    });
    //cout<<"hihihi"<<endl;
    //for(int i=0;i<M;i++)cout<<id[i]<<endl;
    long long sum=0;
    long long K=0;
    for(auto i:id){
        for(int j=0;j<B[i];j++){
            if(K>=N)break;
            sum+=max(A[K++],C[i]);
        }
    }
    for(int i=K;i<N;i++)sum+=A[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 2944
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

struct unionfind {
    vec<i32> data;
    unionfind(i32 size) : data(size, -1) { }
    void unite(i32 x, i32 y) {
        x = find(x); y = find(y); if (x == y) return;
        if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x;
    }
    i32 find(i32 x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
    i32 size(i32 x) { return -data[find(x)]; }
    bool same(i32 x, i32 y) { return find(x) == find(y); }
};

 i64 solve() {
     indef(i32, n);
     vec<pair<i32, i32>> xs(n), ys(n);
     times(n, ni) {
         in(xs[ni].first, ys[ni].first);
         xs[ni].second = ys[ni].second = ni;
     }
     sortall(xs); sortall(ys);
     vec<tuple<i32, i32, i32>> es;
     times(n-1, ni) {
         i32 d = xs[ni+1].first - xs[ni].first;
         i32 a = xs[ni].second;
         i32 b = xs[ni+1].second;
         es.append(make_tuple(d, a, b));
     }
     times(n-1, ni) {
         i32 d = ys[ni+1].first - ys[ni].first;
         i32 a = ys[ni].second;
         i32 b = ys[ni+1].second;
         es.append(make_tuple(d, a, b));
     }
     sortall(es);
     i64 ans = 0;
     unionfind uf(n);
     times(es.size(), ei) {
         i32 d, a, b;
         tie(d, a, b) = es[ei];
         if (uf.same(a, b)) continue;
         uf.unite(a, b);
         ans += d;
     }
     return ans;
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    cout << fixed << setprecision(9);
    out(solve());

    return 0;
}

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

int main(int argc, char *argv[])
{
    int n;
    int m;
    cin >> n >> m;

    vector<int> balls(n, 1);
    vector<int> red(n, 0);
    red[0] = 1;

    for(int i = 0; i < m; ++i)
    {
        int x, y;
        cin >> x >> y;

        --x;
        --y;

        balls[x]--;
        balls[y]++;
        red[y] |= red[x];
        if(balls[x] == 0) red[x] = 0;
    }

    cout << accumulate(red.begin(), red.end(), 0) << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int n, q;
int A[2000], M[2000];
int ans;

int  solve(int i,int m) {
    if ( m == 0 ) return 1;
    if ( i >= n ) return 0;
    
    ans = solve(i+1,m) || solve(i+1,m-A[i]);
    return ans;
}

int main() {

    cin >> n;
    for ( int i = 0; i < n; ++i ) {
        cin >> A[i];
    }
    cin >> q;
    for ( int i = 0; i < q; ++i ) {
        cin >> M[i];
    }

    for ( int a = 0; a < q; ++a ) {
        if ( solve(0,M[a]) ) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define F first
#define S second
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)   //test cases
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define error(x) fixed<<setprecision(x) //cout<<error(5)<<someDouble    -> example - 3.14159
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll it = 0; it < n; it++)    cin>>a[it];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
	boost;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

string k;
ll dp[10001][2][101], d;
ll count(ll i, bool tight, ll sum){
	if(i == k.size())	return (sum == 0);
	if(dp[i][tight][sum] != -1)	return dp[i][tight][sum];
	ll ans = 0, high = tight ? k[i]-'0' : 9;
	for(ll j = 0; j <= high; j++)
		ans = mop(ans, +, count(i+1, tight & (j == high), (sum+j)%d));
	return dp[i][tight][sum] = ans;
}
int main(){
	init();	fill(dp, -1);
	cin>>k>>d;
	cout<<(count(0, 1, 0) + mod - 1) % mod;
}


Measured memory_bytes: 20172
#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>

#define Rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())

#define eb emplace_back
#define dbg(x) cout<<#x" = "<<((x))<<endl
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  string str;

  cin >> str;

#ifdef DEBUG
  cout << "str=" << str << endl;
#endif

  ll acc = 0;
  ll sum = 0;
  for(size_t i = 0; i < str.length(); ++i){
    if(str[i] == 'B') acc += 1;
    else{
      sum += acc;
    }
  }

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


Measured memory_bytes: 640
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

s = v()
w_a = [1 if i=="W" else 0 for i in s]
w_cnt = list(itertools.accumulate(w_a))

for i in range(len(s)):
    if s[i] == "B":
        ans += w_cnt[-1]-w_cnt[i]

print(ans)


Measured memory_bytes: 19932
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Cost = [10**9] * n
    Cost[0] = 0
    Cost[1] = abs(A[1] - A[0])
    for i in range(2, n):
        onejump = Cost[i-1] + abs(A[i] - A[i-1])
        twojump = Cost[i-2] + abs(A[i] - A[i-2])
        Cost[i] = min(onejump, twojump)

    print(Cost[n-1])

resolve()

Measured memory_bytes: 52208
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,c = inpl()
if a + b + 1 >=  c:
    print(b+c)
else:
    print(a+b+1+b)



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

using namespace std;

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

    int n,m;
    vector<int> a;
    cin >> n;
    while (n--) {
        cin >> m;
        a.push_back(m);
    }
    reverse(a.begin(), a.end());
    for_each(a.begin(), a.end()-1, [](int x){cout << x << ' ';});
    cout << *(a.end()-1) << endl;
    
    return 0;
}



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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll answer = 0;
    for (int i = 1; i <= N; i = i + 2)
    {
        ll count = 0;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
            {
                count++;
            }
        }
        if(count == 8)
        {
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void) {
    int max,num;
    int total;
    int i;
    char snake[201];
    scanf("%d",&max);
    for(num = 0;num < max;num++) {
        scanf("%s",snake);
        if(strlen(snake) < 2 || snake[0] != '>'){
            printf("NA\n");
            continue;
        }
        if(snake[1] == '\'') {
            total = 0;
            i = 2;
            while(snake[i] == '=') {
                i++;
                total++;
            }
            if(snake[i] != '#' || total <= 0)printf("NA\n");
            else {
                i++;
                while(snake[i]=='=') {
                    i++;
                    total--;
                }
                if(total != 0)printf("NA\n");
                else if(snake[i] != '~' || snake[i+1] != 0)printf("NA\n");
                else printf("A\n");
            }
        }
        else if(snake[1] == '^') {
            i = 2;
            while(snake[i]=='Q' && snake[i+1] == '=')i += 2;
            if(i == 2)printf("NA\n");
            else if(snake[i] != '~' || snake[i+1] != '~' || snake[i+2] != 0) printf("NA\n");
            else printf("B\n");
        }
        else printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  ll x,y;
  cin>>x>>y;
  ll ans=(ll)INF*INF;
  if(x<=y)ans=min(ans,y-x);
  if(x<=-y)ans=min(ans,1+(-y)-x);
  if(-x<=y)ans=min(ans,1+y-(-x));
  if(-x<=-y)ans=min(ans,2+(-y)-(-x));
  cout<<ans<<endl;
}


Measured memory_bytes: 384
import math
N = int(input())
A = list(map(int, input().split()))

maxA = max(A) + 1

C = [0] * maxA

g = 0

for a in A:
    C[a] += 1
    g = math.gcd(g, a)

pairwise = True

is_prime = [True] * maxA

for i in range(2, maxA):
    if is_prime[i]:
        cnt = 0
        for j in range(i, maxA, i):
            cnt += C[j]
            is_prime[j] = False

        if cnt > 1:
            pairwise = False

if pairwise:
    print("pairwise coprime")
    exit()

if g == 1:
    print("setwise coprime")

else:
    print("not coprime")

Measured memory_bytes: 132592
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int N;
long long int num[300000];
long long int ans;

int main() {
	cin >> N;
	for (int i = 0; i < N*3; i++) {
		cin >> num[i];
	}
	stable_sort(num, num + N * 3);
	for (long long int i = N * 3 - 2, j = 0; j < N; i -= 2, j++) {
		ans += num[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using Int = long long unsigned;
Int const INF = 1e10;
typedef vector<pair<Int,Int>> pvec;

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

    int n,m; cin>>n>>m;
    cout<<(n%(2*m+1)?n/(2*m+1)+1:n/(2*m+1))<<'\n';
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int qtd_a = 0;
	long long ans = 0 ;
	for (int i = 0; i < s.size(); ++i) {
		if(s[i] == 'A') {
			qtd_a++;
		} else if(s[i] == 'B') {
			if(i+1 < s.size()) {
				if(s[i+1] == 'C') {
					ans +=  qtd_a;
					i++;
				}
				else {
					qtd_a = 0;
				}
			}
		} else {
			qtd_a = 0;
		}
	}
	cout << ans << endl;

}

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	scanf("%s",s);
	for(int i=0;s[i];i++)
		printf("x");
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int A,B,C,X;



int main(int argc, char const *argv[])
{
    cin>>A>>B>>C>>X;
    int ans=0;
for(int i_a=0;i_a<=A;i_a++){
    for(int i_b=0;i_b<=B;i_b++){
        for(int i_c=0;i_c<=C;i_c++){
            if(i_a*500+i_b*100+i_c*50==X) ans++;
        }
    }
}
cout<<ans<<endl;
    return 0;
}


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

int main(){

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

  sort(numbers.begin(),numbers.end());
  int former = 0;
  int count = 0;
  for(int i=0;i<n;++i){
    if (former != numbers[i]){
      count += 1;
    }
    former = numbers[i];
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256