akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i
ary = N.times.map{gets.chomp}

a = 0
w = 0
t = 0
r = 0
ary.each do |s|
  case s
    when "AC"
    	a += 1
    when "WA"
    	w += 1
    when "TLE"
    	t += 1
    when "RE"
    	r += 1
  end
end
puts "AC x #{a}
WA x #{w}
TLE x #{t}
RE x #{r}"

Measured memory_bytes: 20724
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

int p[100000];
ll sum[100001];

ll f(int i,int j){
	if(i>j) return 0;
	return sum[i]-sum[j+(j-i)%2];
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	int s[100000],t[100000];
	rep(i,n) scanf("%d%d",s+i,t+i);
	rep(i,m) scanf("%d",p+i);

	sort(p,p+m);

	sum[m-2]=p[m-1]-p[m-2];
	for(int i=m-1;i>=2;i--) sum[i-2]=sum[i]+p[i-1]-p[i-2];

	ll ans=0;
	rep(i,n){
		int mn=min(s[i],t[i]);
		int mx=max(s[i],t[i]);

		int l=lower_bound(p,p+m,mn)-p;
		int r=lower_bound(p,p+m,mx)-p-1;

		if(l==m || r==-1){
			ans+=mx-mn;
			continue;
		}
		if(l>r){
			ans+=mx-mn;
			continue;
		}
		if(s[i]<t[i] || (r-l)%2==1) ans+=p[l]-mn;
		if(s[i]<t[i]) ans+=f(l+1,r);
		else          ans+=f(l+(r-l)%2,r);
		if(s[i]>t[i] || (r-l)%2==1) ans+=mx-p[r];
	}

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 2672
#include <stdio.h>
#include <stdlib.h>

#define INIT_CAP 10
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PNumDis;

VecEdge adj[30 * 30 * 4];
PNumDis heap[30 * 30 * 4 * 4];
int hsize;
int d[30 * 30 * 4];

int w, h;
int field[30][30];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

inline void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

inline void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i, j, k, l;

	while (scanf("%d %d", &w, &h), w) {
		int c[4];

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf("%d", field[i] + j);

		for (i = 0; i < 4; i++)
			scanf("%d", c + i);

		init(h * w * 4);
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 4; k++)
					for (l = 0; l < 4; l++) {
						int nd = k + l & 3;
						int ni = i + di[nd], nj = j + dj[nd];
						if (ni >= 0 && ni < h && nj >= 0 && nj < w)
							add(i * w * 4 + j * 4 + k, ni * w * 4 + nj * 4 + nd, l == field[i][j] ? 0 : c[l]);
					}

		dijkstra(h * w * 4, 1);

		printf("%d\n", min(d[(h - 1) * w * 4 + (w - 1) * 4 + 1], d[(h - 1) * w * 4 + (w - 1) * 4 + 2]));
	}

	return 0;
}

Measured memory_bytes: 8888
#include<iostream>
#include<cstdio>
#include<algorithm>
#define Lens 2000005

using namespace std;
int N, h = 0;;
int A[Lens];
char com[20];

int parent(int i)
{
	return i / 2;
}
int lc(int i)
{
	return 2 * i;
}
int rc(int i)
{
	return 2 * i + 1;
}
void changeheapify(int i)
{
	int p = parent(i);
	if (p > 0)
	{
		if (A[i] > A[p])
		{
			swap(A[i], A[p]);
			changeheapify(p);
		}
	}
}
void Insert(int k)
{
	h++;
	A[h] = k;
	changeheapify(h);
}



void maxheapify(int i)
{
	int l = lc(i);
	int r = rc(i);
	int largest=i;
	if (A[l] > A[i] && l <= h)
		largest = l;
	if (A[r] > A[largest]&&r<=h)
		largest = r;
	if (largest != i)
	{
		swap(A[i], A[largest]);
		maxheapify(largest);
	}
}


int Delete()
{
	int tmp = A[1];
	A[1] = A[h];
	A[h] = 0;
	h--;
	maxheapify(1);
	return tmp;
}

int main()
{
	int k;
	while (cin >> com)
	{
		if (com[0]== 'i')
		{
			cin >> k;
			Insert(k);
		}
		else if (com[0] == 'e'&&com[1]=='x')
		{
			int tmp = Delete();
			cout << tmp<<endl;
		}
		else if (com[0]=='e'&&com[1]=='n')
			break;
	}
	return 0;
}



Measured memory_bytes: 6920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
//int mod = 1e9 + 7;
int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	int n;
	cin >> n;
	vector<int> div(n + 1, 1);
	for (int i = 2; i <= n; i++)
	{
		for (int j = i; j <= n; j += i)
		{
			div[j]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans += (i * div[i]);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 81340
#include<bits/stdc++.h>
using namespace std;
int main(){
 
  vector<int>ans(3);
  cin>>ans.at(0)>>ans.at(1)>>ans.at(2);
  
  int sum=0;
  
 
  for(int i=0;i<3;i++){
    if(i==0){
      sum++;
    }
    
    if(i==1&&ans.at(i)!=ans.at(i-1)){
      sum++;
    }
    if(i==2&&ans.at(i)!=ans.at(i-1)&&ans.at(i)!=ans.at(i-2)){
      sum++;
    }
  }
  cout<<sum<<endl;
}

    
    
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;
long long fac[MAXN];

long long quick_pow(long long a, long long b){
	long long ans = 1;
	while (b){
		if (b & 1){
			ans = (ans * a) % MOD;
		}
		a = (a * a) % MOD;
		b /= 2;
	}
	return ans;
}

long long C(long long n, long long m){
	if (n < m || n < 0 || m < 0) return 0;
	long long ans = (fac[n] % MOD * quick_pow(fac[n - m], MOD - 2) % MOD) % MOD;
	ans = (ans % MOD * quick_pow(fac[m], MOD - 2) % MOD) % MOD;
	return ans;
}

long long mul(long long a, long long b){
	long long ans = 0;
	while (b){
		if (b & 1){
			ans = (ans + a) % MOD;
		}
		a = (a + a) % MOD;
		b /= 2;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n, k;
	cin >> n >> k;
	if (k == 1){
		cout << 0;
		return 0;
	}
	fac[0] = 1;
	for (int i = 1; i <= n; ++i){
		fac[i] = (1ll * fac[i - 1] * i) % MOD;
	}
	vector<int> a(n);
	long long ans = 0;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; ++i){
		a[i] = ((a[i] % MOD) + MOD) % MOD;
		if (i >= k - 1){
			ans = (ans + mul(a[i], C(i, k - 1))) % MOD;
		}
		if (i <= n - k){
			ans = (ans - mul(a[i], C(n - i - 1, k - 1)) + MOD) % MOD;
		}
	}
	cout << ans;
	return 0;
}



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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,p; cin>>a>>p;
	cout<<(a*3+p)/2<<"\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nmxy = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int x = Console.ReadLine().Split().Select(int.Parse).ToArray().Max();
        int y = Console.ReadLine().Split().Select(int.Parse).ToArray().Min();
        for (int i = -1000; i < 1000; i++)
        {
            if (nmxy[2] < i && i <= nmxy[3] && x < i && i <= y)
            {
                Console.WriteLine("No War");
                return;
            }
        }
        Console.WriteLine("War");
    }
}


Measured memory_bytes: 11348
#include "bits/stdc++.h"
using namespace std;
long n;
 
int main() {
    cin >> n;
	vector<long> h(n);
    long count = 0;
    long maxCount = 0;
	for (long i = 0; i < n; i++)
	{
		cin >> h.at(i);
        if(i!=0){
            if(h.at(i-1)>=h.at(i)){
                count++;
            }else{
                maxCount = max(count, maxCount);
                count = 0;
            }
        }
	}
    cout << max(count, maxCount) << endl;
}

Measured memory_bytes: 1024
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

int n, x, t;

void read_input()
{
    cin >> n >> x >> t;
}

void solve()
{
    cout << (n + x - 1) / x * t << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll inv(ll a, ll b) {
    ll c = 1;
    while (b) {
        if (b % 2) c = c * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return c;
}

int main() {
    ios::sync_with_stdio(false);
    /*
     1 1 1 1 1
     1 2 3 4 5
     1 3 6 10 15
     1 4 10 20 35
     1 5 15 35 70
     */
    ll f[2000006] = {1}, g[2000006] = {}, r1, c1, r2, c2, z = 0;
    for (int i = 1; i <= 2000003; i++) f[i] = f[i - 1] * i % mod;
    g[2000003] = inv(f[2000003], mod - 2);
    for (int i = 2000002; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    cin >> r1 >> c1 >> r2 >> c2;
    for (ll i = r1; i <= r2; i++) {
        z += f[i + c2 + 1] * g[c2] % mod * g[i + 1] % mod;
        if (z >= mod) z -= mod;
        z -= f[i + c1] * g[c1 - 1] % mod * g[i + 1] % mod;
        if (z < 0) z += mod;
    }
    cout << z;
}


Measured memory_bytes: 34888
#include <stdio.h>

int main(){

  int i,j,N,flag,A[100],count=0,tmp;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  flag=1;
  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      
      if(A[j] < A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	count++;
      }
      
    }
    
  }
  for(j=0;j<N;j++){
    if(j>0) printf(" ");
    printf("%d",A[j]);
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define iter(i,a,b) for(i=a;i<b;i++)

int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
{



int a;
      cin>>a;
      cout<<a+a*a+a*a*a;
      





}

return 0;
}






Measured memory_bytes: 3644
#include <iostream>
#include <math.h>

using namespace std;

double square_calc(double x1, double y1, double x2, double y2, double x3, double y3)
{
	double square = 0;
	double a = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
	double b = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
	double c = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
	double s = (a + b + c) / 2;
	return(sqrt(s * (s - a ) * (s - b) * (s - c)));
}

void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		double xp1, yp1, xp2, yp2, xp3, yp3, xk, yk, xs, ys;
		cin >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3 >> xk >> yk >> xs >> ys;
		double square = square_calc(xp1, yp1, xp2, yp2, xp3, yp3);
		double square1 = square_calc(xk, yk, xp1, yp1, xp2, yp2) + square_calc(xk, yk, xp1, yp1, xp3, yp3) + square_calc(xk, yk, xp2, yp2, xp3, yp3);
		double square2 = square_calc(xs, ys, xp1, yp1, xp2, yp2) + square_calc(xs, ys, xp1, yp1, xp3, yp3) + square_calc(xs, ys, xp2, yp2, xp3, yp3);
		if(fabs(square - square1) <= 1e-6 && fabs(square - square2) >= 1e-6 ||
		   fabs(square - square1) >= 1e-6 && fabs(square - square2) <= 1e-6)
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << "NG" << endl;
		}
	}
}

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

Measured memory_bytes: 1220
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] H = new int[N];
            for(int i = 0; i < N; i++)
            {
                H[i] = int.Parse(str[i]);
            }
            int count = 0;
            int ans = 0;
            for(int i = 0; i < N-1; i++)
            {
                if (H[i] >= H[i + 1])
                {
                    count++;
                }
                else
                {
                    ans = Math.Max(ans, count);
                    count = 0;
                }
            }
            ans = Math.Max(ans, count);
            Console.WriteLine(ans);
        }
    }
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
	ll t = 1; 
	//cin >> t;
	while(t--){
	    ll n; cin >>  n;
	    ll ans = 0;
	    ans += (n / 500) * 1000;
	    n %= 500;
	    
	    ans += (n / 5) * 5;
	    cout << ans << endl;
	}
}

Measured memory_bytes: 256
/* /\ In The Name of ALLAH /\
    Author : Jawahiir Nabhan */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N  = 2e5 + 10;
const int MOD = 1e9 + 7;

ll a[N],b[N];
int main()
{
    int n; cin>>n;
    for(int i = 0;i < n;i++){
        cin>>a[i];
        b[i] = a[i];
        if(i) a[i] += a[i-1];
    }

    ll res = 0;
    for(int i = 0;i < n;i++)
    {
        res += (((a[n - 1] - a[i]) % MOD)*(b[i] % MOD))%MOD;
    }
    //(res %= MOD) += b[n-1]%MOD;
    cout<<res%MOD<<endl;
}


Measured memory_bytes: 6772
// 解説前
#include <algorithm>
#include <iostream>
#include <vector>

constexpr uint64_t INVALID_DISTANCE = UINT64_MAX;
constexpr uint64_t INVALID_COUNT = UINT64_MAX;

int solve_E() {
  size_t N, M;
  uint64_t L;
  std::cin >> N >> M >> L;

  std::vector<uint64_t> distances(N * N, INVALID_DISTANCE);
  for (size_t i = 0; i < N; ++i) {
    distances[i * N + i] = 0;
  }

  std::vector<std::vector<size_t>> graph(N);
  for (size_t i = 0; i < M; ++i) {
    size_t a, b;
    uint64_t c;
    std::cin >> a >> b >> c;
    graph[a - 1].push_back(b - 1);
    distances[(a - 1) * N + (b - 1)] = c;
    graph[b - 1].push_back(a - 1);
    distances[(b - 1) * N + (a - 1)] = c;
  }

  for (size_t k = 0; k < N; ++k) {
    for (size_t i = 0; i < N; ++i) {
      for (size_t j = 0; j < N; ++j) {
        const auto i2k_distance = distances[i * N + k];
        const auto k2j_distance = distances[k * N + j];
        if (i2k_distance != INVALID_DISTANCE && k2j_distance != INVALID_DISTANCE) {
          distances[i * N + j] = std::min(distances[i * N + j], i2k_distance + k2j_distance);
        }
      }
    }
  }

  std::vector<uint64_t> refueling_counts(distances.size(), INVALID_COUNT);
  for (size_t i = 0; i < N; ++i) {
    for (size_t j = 0; j < N; ++j) {
      if (i == j) {
        refueling_counts[i * N + j] = 0;
      } else if (distances[i * N + j] <= L) {
        refueling_counts[i * N + j] = 1;
      }
    }
  }

  for (size_t k = 0; k < N; ++k) {
    for (size_t i = 0; i < N; ++i) {
      for (size_t j = 0; j < N; ++j) {
        const auto i2k_refueling_count = refueling_counts[i * N + k];
        const auto k2j_refueling_count = refueling_counts[k * N + j];
        if (i2k_refueling_count != INVALID_COUNT && k2j_refueling_count != INVALID_COUNT) {
          refueling_counts[i * N + j] = std::min(refueling_counts[i * N + j], i2k_refueling_count + k2j_refueling_count);
        }
      }
    }
  }

  size_t Q;
  std::cin >> Q;
  
  std::vector<int64_t> results(Q, -1);
  for (auto& result : results) {
    size_t s, t;
    std::cin >> s >> t;

    const auto s2t_refueling_count = refueling_counts[(s - 1) * N + (t - 1)];
    if (s2t_refueling_count != INVALID_COUNT) {
      result = static_cast<int64_t>(s2t_refueling_count) - 1;
    }
  }

  for (const auto result : results) {
    std::cout << result << '\n';
  }

  return 0;
}

int main() { return solve_E(); }


Measured memory_bytes: 3840
n = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(str.lower(num2alpha(n)))

Measured memory_bytes: 9172
use std::io::{stdin, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: u64 = read().unwrap();
    let n_s: String = format!("{}", n);
    if n_s.contains("7") {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2072
v[20];char t[9],s[9],c;
int main(a,L,i,j,k){
	for(;scanf("%d%d",&a,&L),L;){
		for(v[0]=a,i=0,k=1;i==k-1;v[k++]=a){
			for(sprintf(s,"%%0%dd",L),sprintf(t,s,a),s[L]=0,i=0;i<L;s[i]=t[L-i-1],i++)for(j=1;j<L-i;j++)if(t[j]<t[j-1])c=t[j],t[j]=t[j-1],t[j-1]=c;
			for(a=atoi(s)-atoi(t),i=0;i<k;i++)if(v[i]==a)break;
			if(i<k)printf("%d %d %d\n",i,a,k-i);
		}
	}
}

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

using namespace std;
typedef long long ll;

const int N = 110, K = 1e5 + 5;
int n, k, a[N];
bool dp[K];

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	memset(dp, false, sizeof(dp));
	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (a[j] > i)
				continue;
			if (!dp[i - a[j]])
				dp[i] = true;
		}
	}
	if (dp[k])
		cout << "First";
	else
		cout << "Second";

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 101010
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
	ld n;
	in(n);
	ld div=n/3.0;
	ld rem=n-2*div;
	cout<<fixed<<setprecision(10)<<rem*div*div<<'\n';
}	
int main(){
	clock_t t1=clock();
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
	clock_t t2=clock();
	cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}	

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

int main() {
    string s1, s2;
    cin >> s1 >> s2;

    int mw = min(s1.size(), s2.size());
    int res = 0;
    for(int w=mw; w>0; --w) {
        set<vector<int>> s;
        vector<int> cnt1(26);
        for(int i=0; i<w; ++i) {
            cnt1[s1[i]-'a']++;
        }
        s.insert(cnt1);
        for(int i=1; i+w-1<s1.size(); ++i) {
            cnt1[s1[i-1]-'a']--;
            cnt1[s1[i+w-1]-'a']++;
            s.insert(cnt1);
        }

        bool f = false;
        vector<int> cnt2(26);
        for(int i=0; i<w; ++i) {
            cnt2[s2[i]-'a']++;
        }
        if(s.count(cnt2) == 1) {
            res = w;
            f = true;
        }
        if(f) {
            break;
        }
        for(int i=1; i+w-1<s2.size(); ++i) {
            cnt2[s2[i-1]-'a']--;
            cnt2[s2[i+w-1]-'a']++;
            if(s.count(cnt2) == 1) {
                res = w;
                f = true;
            }
        }
        if(f) {
            break;
        }
    }
    cout << res << endl;
}


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

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

int main() {
    ll sum = 0;
    int K;
    cin >> K;
    erep1(i,K){
        erep1(j,K){
            erep1(k,K){
                int tmp = 0;
                int m = gcd(i, j);
                int l = gcd(m, k);
                sum += l;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int m,n;
vi p,c,e;

int main(){
	cin>>m>>n;
	p=vi(m);
	c=e=vi(n);
	for(int i=0;i<m;i++) cin>>p[i];
	for(int i=0;i<n;i++) cin>>c[i]>>e[i];
	sort(p.begin(),p.end(),[](int x,int y){return x>y;});
	vi dp(m,inf);
	for(int i=0;i<n;i++) for(int j=m-1;j>=0;j--){
		int I=j-c[i];
		if(I>=0) dp[j]=min(dp[j],dp[I]+e[i]);
		else dp[j]=min(dp[j],e[i]);
	}
	int ans=0,sum=0;
	for(int i=0;i<m;i++){
		sum+=p[i];
		ans=max(ans,sum-dp[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GoToSchool | diff GoToSchool.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GoToSchool.cpp && ./a.out

/*
 
 9/28/2019
 
 5:08-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  vector<II> B(N);
  REP(i,N)B[i]={A[i],i};
  sort(ALL(B));
  REP(i,N) printf("%d ",B[i].second+1);
  println("");
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 2432
from math import floor, sqrt

def divisors(n):
    div = [1]
    for i in range(2, 1 + floor(sqrt(n))):
        if n % i == 0:
            div.append(i)
    return div

def f(a, b):
    return max(len(str(a)), len(str(b)))


if __name__ == '__main__':
    n = int(input())
    minimum = len(str(n))
    for a in divisors(n):
        b = n // a
        minimum = min(minimum, f(a, b))
    print(minimum)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
const int N=1e6+10;
using namespace std;
int a[N],b[N],c[N];
int n;
int ans=0;
int main() {
     cin>>n;
     for(int i=1;i<=n;i++){
         cin>>a[i];
     }
     for(int i=1;i<=n;i++){
         cin>>b[i];
     }
     for(int i=1;i<=n-1;i++){
         cin>>c[i];
     }
     for(int i=1;i<=n;i++){
         if(i>=2 && a[i]-a[i-1]==1){
             ans+=b[a[i]]+c[a[i-1]];
         }
         else
             ans+=b[a[i]];
     }


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

Measured memory_bytes: 4352
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);

#ifdef BUGGY
	bool DEBUG = 1;
#endif
#ifndef BUGGY
	bool DEBUG = 0;
#endif

void printPathRow(pair<int, int> p1, pair<int, int> p2) {
	if (p1.second == p2.second) {
		return;
	}

	if (p1.second < p2.second) {
		while(1) {
			printf("%d %d ", p1.first, p1.second);
			p1 = make_pair(p1.first, p1.second + 1);
			printf("%d %d\n", p1.first, p1.second);
			if (p1 == p2) {
				break;
			}
		}
	} else {
		while(1) {
			printf("%d %d ", p1.first, p1.second);
			p1 = make_pair(p1.first, p1.second - 1);
			printf("%d %d\n", p1.first, p1.second);
			if (p1 == p2) {
				break;
			}
		}
	}
}

void printPathCol(pair<int, int> p1, pair<int, int> p2) {
	if (p1.first == p2.first) {
		return;
	}

	if (p1.first < p2.first) {
		while(1) {
			printf("%d %d ", p1.first, p1.second);
			p1 = make_pair(p1.first + 1, p1.second);
			printf("%d %d\n", p1.first, p1.second);
			if (p1 == p2) {
				break;
			}
		}
	} else {
		while(1) {
			printf("%d %d ", p1.first, p1.second);
			p1 = make_pair(p1.first - 1, p1.second);
			printf("%d %d\n", p1.first, p1.second);
			if (p1 == p2) {
				break;
			}
		}
	}
}

std::vector<pair<int, int>> odd;
int rows, cols;
int mat[505][505];

struct X
{
	int first, second, third, fourth;
};

std::vector<X> ans;

int main()
{
	scanf("%d %d", &rows, &cols);

	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols; j++) {
			scanf("%d", &mat[i][j]); 
		}
	}

	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols - 1; j++) {
			if (mat[i][j] % 2) {
				X x;
				x.first = i + 1;
				x.second = j + 1;
				x.third = i + 1;
				x.fourth = j + 1 + 1;
				ans.push_back(x);
				// printf("%d %d %d %d\n", i + 1, j + 1, i + 1, j + 1 + 1);
				mat[i][j + 1]++;
				mat[i][j]--;
			}
		}
	}

	for (int i = 0; i < rows - 1; i++) {
		int j = cols - 1;
		if (mat[i][j] % 2) {
			X x;
			x.first = i + 1;
			x.second = j + 1;
			x.third = i + 1 + 1;
			x.fourth = j + 1;
			ans.push_back(x);
			mat[i][j]--;
			mat[i + 1][j]++;
			// printf("%d %d %d %d\n", i + 1, j + 1, i + 1 + 1, j + 1);
		}
	}

	printf("%d\n", ans.size());
	for(int i = 0; i < ans.size(); i++) {
		printf("%d %d %d %d\n", ans[i].first, ans[i].second, ans[i].third, ans[i].fourth);
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int h, a;
    cin >> h >> a;
    OUT((h + a - 1) / a);
}

Measured memory_bytes: 256
n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
mod=pow(10,9)+7
dp=[0]*(1<<n)
dp[0]=1
for i in range(1<<n):
    cnt=0
    v=[]
    #　bitが何個たつか調べる
    for j in range(n):
        if (i>>j)&1:
            cnt+=1
            v.append(j)
    for j in v:
        dp[i] += dp[i ^ (1 << j)] * a[j][cnt-1]
        dp[i]%=mod

print(dp[-1])


Measured memory_bytes: 58604
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,m;
        cin>>n>>m;
        int a[n];
        for(int i=0;i<n;i++)
        {
            a[i]=-1;
        }
        for(int i=0;i<m;i++)
        {
            int s,c;
            cin>>s>>c;
            if(a[s-1]==-1 || a[s-1]==c)
            {
                a[s-1]=c;
            }
            else
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
        if(a[0]==0 && n>1)
        {
            cout<<"-1"<<endl;
        }
        else if(a[0]==0 && n==1)
        {
            cout<<"0"<<endl;
        }
        else{
            if(a[0]==-1 && n>1)
            {
                a[0]=1;
            }
            else if(a[0]==-1 && n==1)
            {
                a[0]=0; 
            }
            
            
            for(int i=0;i<n;i++)
            {
                if(a[i]==-1)
                {
                    cout<<"0";
                }
                else
                {
                    cout<<a[i];
                }
            }
        }
    }

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

int main(void)
{
  string a, b, c;
  int x, y;
  cin >> a >> b;
  cin >> x >> y;
  cin >> c;
  if(a == c)
  {
    x--;
  }else if(b == c)
  {
    y--;
  }
  cout << x << " " << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)
int dsu[space];
pii arr[space];
unordered_map<int,vi> X,Y;
unordered_map<int,pair<unordered_set<int>,unordered_set<int>>> mp;
int parent(int x)
{
    if(dsu[x]==x) return x;
    else return dsu[x]=parent(dsu[x]);
}
void merge(int z,int p)
{
    dsu[parent(z)]=parent(p);
}
int main()
{
    int n,i,j,t;
    boost;

    cin>>n;

    rep(i,0,n)
    {
        cin>>arr[i].F>>arr[i].S;
        X[arr[i].F].pb(i);
        Y[arr[i].S].pb(i);
        dsu[i]=i;
    }

    for(auto it=X.begin();it!=X.end();it++)
    {
        rep(i,1,it->S.size())
        {
            merge(it->S[i],it->S[0]);
        }
    }
    for(auto it=Y.begin();it!=Y.end();it++)
    {
        rep(i,1,it->S.size())
        {
            merge(it->S[i],it->S[0]);
        }
    }
    
    rep(i,0,n)
    {
        mp[parent(i)].F.insert(arr[i].F);
        mp[parent(i)].S.insert(arr[i].S);
    }
    ll ans=0;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        ans+=it->S.F.size() * it->S.S.size();
    }
    cout<<ans-n;

    return 0;
}



Measured memory_bytes: 14616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    int ans = n % 10;
    if (ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9)
        cout << "hon"
             << "\n";
    else if (ans == 0 || ans == 1 || ans == 8 || ans == 6)
        cout << "pon"
             << "\n";
    else
        cout << "bon"
             << "\n";
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}

using namespace std;

struct UnionFind {
    vector<int> par; 
    vector<int> sizes;
    UnionFind(int N) : par(N),sizes(N,1) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        if (sizes[rx]<sizes[ry])swap(rx,ry);
        par[ry] = rx; 
        sizes[rx]+=sizes[ry];
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int size(int x){
        return sizes[root(x)];
    }

};


int n,k,ans,sum;



signed main(){
	
	cin>>n>>k;
	UnionFind uf(n);
	rep(i,k){
		int a,b;
		cin>>a>>b;
		a--;b--;
		uf.unite(a,b);
	}
	rep(i,n){
		ans=max(ans,uf.size(i));
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
long long int gcd(long long int a,long long int b){
  if(a==0) return b;
  if(b==0) return a;
  else return gcd(b,a%b);
}
int main(){
  long long int a,b;
  cin>>a>>b;
  vector<long long int> vect1;
  vector<long long int> vect2;
  int square_root = (int) sqrt(a) + 1;
	for (int i = 1; i < square_root; i++) { 
    if (a % i == 0&&i*i!=a){
        vect1.push_back(i);
        vect1.push_back(a/i);
    }
    if (a % i == 0&&i*i==a){
        vect1.push_back(i);
    }
  }
    square_root = (int) sqrt(b) + 1;
	for (int i = 1; i < square_root; i++) { 
    if (b % i == 0&&i*i!=b){
        vect2.push_back(i);
        vect2.push_back(b/i);
    }
    if (b % i == 0&&i*i==b){
       vect2.push_back(i);
	}
  }
  vector<long long int> vect;

  long long int ans=0;
  long long int l1=vect1.size();
  long long int l2=vect2.size();
  
  for(int i=0;i<l1;i++){
    for(int j=0;j<l2;j++){
      if(vect1[i]==vect2[j]){
          vect.push_back(vect1[i]);
          break;
      }
    }
  }
  int len=vect.size();
  sort(vect.begin(),vect.end());
  for(int i=len-1;i>=0;i--){
      int flag=0;
    for(int j=i;j>=0;j--){
        if(j!=i){
            if(gcd(vect[i],vect[j])!=1){
                flag=1;
                break;
            }
        }
    }
    if(flag==0) ans++;
  }
       
  cout<<ans;
return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int H,N,A,sum=0;
	cin >> H >> N;
	for(int i=0;i<N;i++){
		cin >> A;
		sum += A;
	}
	cout << ((sum < H) ? "No\n" : "Yes\n");
	return 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
    bool all_visited = true;
    rep(i,N) {
        if(visited[i]==false) all_visited = false;
    }
    if(all_visited) return 1;

    int ret = 0;
    rep(i, N) {
        if(graph[v][i]==false) continue;
        if(visited[i]) continue;
        visited[i] = true;
        ret += dfs(i,N,visited);
        visited[i] = false;
    }
    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }
    bool visited[nmax];
    rep(i,n) visited[i] = false;
    visited[0] = true;
    P(dfs(0,n,visited));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i=0; i<n; i++)
#define MAX 100000
using namespace std;
int main()
{
    int N, M;
    int P[MAX];
    int Y[MAX];
    int YEAR[MAX];

    cin >> N >> M;
    vector<int> res[MAX+1];

    rep(i, M){
        cin >> P[i] >> Y[i];
        res[P[i]].push_back(Y[i]);
    }

    rep(i, N){ 
        sort(res[i+1].begin(), res[i+1].end());
    }

    rep(i, M){
        cout << setfill('0') << right << setw(6) << P[i];
        cout <<  setfill('0') << right << setw(6)
            << (int)(lower_bound(res[P[i]].begin(), res[P[i]].end(), Y[i]) - res[P[i]].begin()) + 1
            << endl;
    }
}

Measured memory_bytes: 7808
require 'pp'

n, m = gets.chomp!.split(" ").map!(&:to_i)

k_m = Array.new(0, m)
s_m = Array.new(0, m)
m.times do |i|
    k, *s = gets.chomp!.split(" ").map!(&:to_i)
    k_m << k
    s_m << s
end

p_m = gets.chomp!.split(" ").map!(&:to_i)

sums = m.times.map do |i|
    sum = 0
    s_m[i].each {|s|
        sum += (2 ** (s-1)) 
    }
    sum
end

count = 0
(2 ** n).times do |i|
    ok = true
    sums.each_with_index {|sum, x|
        if (sum & i).to_s(2).count("1") % 2 != p_m[x]
          ok = false
          break
        end
    }

    count += (ok ? 1 : 0)
end

puts count


Measured memory_bytes: 4348
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void solve()
{
    double r;
    cin >> r;
    cout << fixed << setprecision(3) << (2*3.1415 * r) << "\n";
    return;  
}

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

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main (void) {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    double border = sum / (4.0 * M);
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());    

    bool ok = true;
    for (int i = 0; i < M; i++) {
        if (A.at(i) < border) {
            ok = false;
            break;
        }
    }
    
    cout << (ok ? "Yes" : "No") << endl;
    
}

Measured memory_bytes: 3604
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut A: Vec<usize> = sc.vec(N);
    let mut ans = 0usize;
    for i in 1..N {
        if A[i-1] > A[i] {
            ans += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }
    println!("{}", ans);
}


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

using namespace std;
int main() {
int64_t a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int r=min(d,e);
  int64_t t=100000000000;
  for(int i=0;i<r+1;i++)
 {
  int64_t g=c*i*2+(d-i)*a+(e-i)*b;
  t=min(t,g);
    
}
  if(d>e){
   for(int i=r+1;i<d+1;i++)
 {
  int64_t g=c*i*2+(d-i)*a;
  t=min(t,g);
     
}
  }
  else{
       for(int i=r+1;i<e+1;i++)
 {
  int64_t g=c*i*2+(e-i)*b;
  t=min(t,g);
}
  
  }
cout<<t;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int MX = 100005;

vector<pii> G[MX];
int ind[MX];
int N, H;

int f(int y){ return y <= H ? y + H : y - H; }

int vst[MX];
void dfs(int s){
	for(pii c : G[s]){
		if( vst[c.second] ) continue;
		vst[c.second] = 1;
		dfs(c.first);
	}
}

struct UF{
	int t[MX];
	int find(int x){ return t[x] ? t[x] = find(t[x]) : x; }
	int merge(int a, int b){
		a = find(a), b = find(b);
		return a == b ? 0 : (t[a] = b, 1);
	}
} uf;

int main()
{
	scanf("%d%d", &N, &H);
	for(int i = 1; i <= N; i++){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int x, y;
		if( c == 0 ) x = a + H;
		else x = c;
		if( d == 0 ) y = b + H;
		else y = d;
		G[x].emplace_back(f(y), i);
		uf.merge(x, f(y));
		ind[f(y)]++;
	}
	int s = -1, cnt = 0, e = -1;
	for(int i = H+1; i <= 2*H; i++){
		if( G[i].size() < ind[i] ) return !printf("NO\n");
	}
	for(int i = 1; i <= H; i++){
		if( G[i].size() > ind[i] ) return !printf("NO\n");
	}
	set<int> X;
	for(int i = 1; i <= 2*H; i++) X.insert(uf.find(i));
	for(int i = 1; i <= 2*H; i++){
		if( G[i].size() != ind[i] || G[i].size() == 0|| G[i].size() == 0) X.erase(uf.find(i));
	}
	if( X.size() ) return !printf("NO\n");
	printf("YES\n");
}


Measured memory_bytes: 4096
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

//a, bの最大公約数．a > b
ull gcd(ull a, ull b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
//a, bの最小公倍数
ull lcm(ull a, ull b) {
    return a*(b/gcd(a, b));
}

void solve(){
    int n, ans=0;
    int d[200005];
    cin >> n;
    rep(i, n) cin >> d[i];
    sort(d, d+n);
    if(n%2 == 0){
        ans = d[n/2] - d[(n/2)-1];
    }else{
    }
    cout << ans << endl;
}

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

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

int main () {
  int N;
  cin >> N;
  vector<int> x(N, 1);
  for (int i = 2; i <= N; i++) {
    int s = i;
    for (int j = 2; j <= i; j++) {
      while (s%j == 0) {
        x.at(j-1)++;
        s /= j;
      }
    }
  }
  long ans = 1;
  for (int i = 0; i < N; i++) {
    ans *= x.at(i);
    ans %= 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256