akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

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

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define val const auto
#define var auto

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

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template<typename T,std::size_t N>
struct _v_traits {using type = std::vector<typename _v_traits<T,N-1>::type>;};
template<typename T>
struct _v_traits<T,1> {using type = std::vector<T>;};
template<typename T,std::size_t N=1>
using vec = typename _v_traits<T,N>::type;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            os << ",";
        }
        os << *it;
    }
    return os << "}";
}

template <typename T>
T read_next(){
    T ret; cin >> ret;
    return ret;
}


template<typename T>
void isort(std::vector<T>& v, std::function<bool(T,T)> comp=less<T>()){
    sort(v.begin(), v.end(), comp);
}
template<typename T>
std::vector<T> sort(std::vector<T> v, std::function<bool(T,T)> comp=less<T>()){
    isort(v);
    return v;
}
template<typename T1, typename T2>
std::vector<T2> rmap(const std::vector<T1>& v, std::function<T2(T1)> f){
    std::vector<T2> t; t.reserve(v.size());
    for(const auto& i: v) t.push_back(f(i));
    return t;
}
std::vector<std::string> split(std::string str, char delim){
    std::vector<std::string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != std::string::npos){
        res.push_back(std::string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(std::string(str, current, str.size() - current));
    return res;
}
string join(const std::vector<string>& v, string delim){
    string ret = "";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            ret += delim;
        }
        ret += *it;
    }
    return ret;
}


using i64 = int64_t;
using i32 = int32_t;

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

    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    for(int &i : a) cin >> i;
    isort(a);
    int ans = a[T-1] - (K-a[T-1]) - 1;
    ans = max(ans, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main(){
    int n,l; cin >> n >> l;
    if(l >= 0)cout << n * (l + (l + n - 1)) / 2 - l;
    else if((l + n - 1) <= 0)cout << n * (l + (l + n - 1)) / 2 - (l + n - 1);
    else  cout << n * (l + (l + n - 1)) / 2 << endl; 
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

ll C(int n,int r){
    ll ret = 1;
    rep(i,r) ret*=(n-i);
    rep(i,r) ret/=r-i;
    return ret;
}

signed main(){
    int n;
    cin>>n;
    
    vector<int> c(5,0);
    rep(i,n){
        string s;
        cin>>s;
        if(s[0]=='M')c[0]++;
        if(s[0]=='A')c[1]++;
        if(s[0]=='R')c[2]++;
        if(s[0]=='C')c[3]++;
        if(s[0]=='H')c[4]++;
    }
    
    int sum = accumulate(all(c),0);
    ll ans = C(sum,3);
    
    rep(i,5){
        ans -= C(c[i],3);
        ans -= C(c[i],2)*(sum-c[i]);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

w = input()
s = []
cnt = 0

for i in sys.stdin.readlines():
    if i == 'END_OF_TEXT\n':
        break
    for j in [x.strip('.').lower() for x in i.split()]:
        s.append(j)

for i in s:
    if w == i:
        cnt += 1

print(cnt)

Measured memory_bytes: 7520
#include <iostream>
#include <algorithm>

using namespace std;

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

const int N = 2e5 + 10;

PII m[N];
LL diff[N];

bool cmp(PII a, PII b)
{
    return a.first < b.first;
}

int locate(LL x, LL left, LL right)
{
    int l = left, r = right;
    while (l < r) {
        int mid = l + r + 1 >> 1;
        if (m[mid].first <= x)
            l = mid;
        else
            r = mid - 1;
    }
    return l;
}

int main()
{
    LL n, d, a;
    LL res = 0;
    scanf("%lld%lld%lld", &n, &d, &a);
    for (int i = 1; i <= n; ++i) {
        int x, h;
        scanf("%d%d", &x, &h);
        m[i] = {x, h};
    }
    
    sort(m + 1, m + n + 1, cmp);
    
    for (int i = 1; i <= n; ++i) {
        diff[i] += diff[i - 1];
        m[i].second -= diff[i];
        if (m[i].second <= 0)
            continue;
        LL cnt = m[i].second / a;
        if (m[i].second % a)
            cnt++;
        res += cnt;
        LL k = m[i].first + d * 2;
        diff[i] += a * cnt;
        diff[locate(k, i, n) + 1] -= a * cnt;
    }
    
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 6696
#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <math.h>

using namespace std;

int main(){
   int K;
   cin>>K;
   string A;
   for(int i=0;i<K;i++){
       A += "ACL";
   }
   cout<<A;

   }









Measured memory_bytes: 3000
#<順列全探索>
#n!通りの順列の組み合わせを全探索する方法。
#pythonにはitertoolsが存在するからそれを利用
#<ex.1(ABC150-C)>
import itertools 

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
ls = list(itertools.permutations(range(1, n + 1))) #順列作成

print(abs(ls.index(p) - ls.index(q)))


Measured memory_bytes: 13816
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
int main(){
	long long x,k,d;
	cin>>x>>k>>d;
	if(x==0){
		if(k%2==0){
			cout<<0<<endl;
		}else{
			cout<<d<<endl;
		}
		return 0;
	}
	x=abs(x);
	if(x/d>=k){
		cout<<x-d*k<<endl;
	}else{
		long long hoge=x%d;
		long long b=k-x/d;
		if(b%2==0){
			cout<<hoge<<endl;
		}else{
			cout<<abs(hoge-d)<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e5+5;
int n,p[N],foo[N],bar[N],fa[N],mx[N<<2];long long ans;
int Max(int x,int y){
	return 1ll*foo[x]*bar[y]>1ll*foo[y]*bar[x]?x:y;
}
void build(int x,int l,int r){
	if(l==r){mx[x]=l;return;}
	int mid=l+r>>1;
	build(x<<1,l,mid);build(x<<1|1,mid+1,r);
	mx[x]=Max(mx[x<<1],mx[x<<1|1]);
}
void modify(int x,int l,int r,int p){
	if(l==r)return;int mid=l+r>>1;
	p<=mid?modify(x<<1,l,mid,p):modify(x<<1|1,mid+1,r,p);
	mx[x]=Max(mx[x<<1],mx[x<<1|1]);
}
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;++i)scanf("%d",&p[i]);
	for(int i=1;i<=n;++i)scanf("%d",&bar[i]),foo[i]=1-bar[i],fa[i]=i;
	build(1,1,n);
	for(int i=1;i<=n;++i){
		int x=mx[1],y=find(p[x]);
		fa[x]=y;ans+=1ll*foo[x]*bar[y];
		foo[y]+=foo[x];bar[y]+=bar[x];foo[x]=-1;bar[x]=1;
		modify(1,1,n,x);modify(1,1,n,y);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6400
# -*- coding: utf-8 -*-

import sys
import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
#        for line in sys.stdin:
#            lines.append(line)
        lines.append(input())
        (h, w) = [int(e) for e in lines[0].split(" ")]
        for i in range(h):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        (h, w) = [int(e) for e in lines[0].split(" ")]
    
    s = []
    for i in range(1, h + 1):
        s.append(lines[i])
        

    return (h, w, s)

def solve(h, w, s):


    result = -1
    for i in range(h):
        for j in range(w):

            if s[i][j] == "#":
                continue
            
            d = 0
            resolved = set() 
            last_resolved = set()
            last_resolved.add((i, j))
            for r in last_resolved:
                resolved.add(r)

            while True:
                neighbors_of_last_resolved = set()
                for (m, n) in last_resolved:

                    for (dm, dn) in [(1, 0), (-1, 0), (0, 1), (0, -1)]:

                        if m+dm < 0 or h - 1 < m+dm:
                            continue

                        if n+dn < 0 or w - 1 < n+dn:
                            continue
                        
                        if s[m+dm][n+dn] == "#":
                            continue
                        else:
                            r = (m+dm, n+dn)
                            if not r in resolved:
                                neighbors_of_last_resolved.add(r)
                
                last_resolved = neighbors_of_last_resolved
                for r in last_resolved:
                    resolved.add(r)

                if len(last_resolved) == 0:
                    break
                else:
                    d = d + 1

            if d > result:
                result = d

    return result

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3444
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int dp[100010];
int N, W;
int w[100010], v[100010];

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

	cin >> N >> W;
	rep(i, 0, N)cin >> w[i] >> v[i];

	rep(i, 0, N)
	{
		rrep(j, 0, W + 1)
		{
			if (j >= w[i])
			{
				chmax(dp[j], dp[j - w[i]] + v[i]);
			}
		}
	}

	cout << dp[W] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000
#define NIL -1

typedef struct node {
    int p;
    int l;
    int r;
} Node;

Node no[MAX];
int D[MAX];



int setDepth(int u, int p){
    D[u] = p;
    if(no[u].l != NIL){
        setDepth(no[u].l, p + 1);
    } 
    if (no[u].r != NIL){
        setDepth(no[u].r, p);
    }
}

void print(int u){
    int i, c;
    printf("node ");
    printf("%d: ", u);

    printf("parent = %d, ", no[u].p);
    printf("depth = %d, ",  D[u]);
    if(no[u].p == NIL) printf("root, ");
    else if (no[u].l == NIL ) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(i = 0, c = no[u].l; c != NIL; i++, c = no[c].r){
        if(i) printf(", ");
        printf("%d", c);
    }
    printf("]");

    printf("\n");


}

int main(){
    int n, i, j, v, l = 0;
    int tmp;
    int a[10];

    scanf("%d", &n);
    /* initialize */
    for(i = 0; i < n; i++){
        no[i].p = no[i].l = no[i].r = NIL;
    }

    for(i = 0; i < n; i++){
        int id, k;
        scanf("%d%d", &id, &k);
    
        for(j = 0; j < k; j++){
            int c;
            tmp = scanf("%d", &c);
            if(j == 0) no[id].l = c;
            else no[l].r = c;
            l = c;
            no[c].p = id;
        }
    }

    int r;
    for(i = 0; i < n; i++){
        if(no[i].p == NIL) r = i;
    }
    setDepth(r, 0);
    for(i = 0; i < n; i++) print(i);
    return 0;
}


Measured memory_bytes: 3276
#include <stdio.h>
long long int gcd(long long int a,long long int b){
  if(b==0)return a;
  else return gcd(b,a%b);
}
int main(){
  long long int a,b;
  long long int d;
  long long int m;
  while(scanf("%lld %lld",&a,&b)!=EOF){
  d=gcd(a,b);
  m=a/d*b;
  printf("%lld %lld\n",d,m);
  }
  return 0;
}

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  rep(i,n) cin >> a[i] >> b[i] >> c[i];

  ll dp[n][3] = {};

  rep(i, n){
    dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i];
    dp[i+1][1] = max(dp[i][2], dp[i][0]) + b[i];
    dp[i+1][2] = max(dp[i][0], dp[i][1]) + c[i];
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}




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

int main(){
   string s,s2;
    cin>>s;
    s2=s;
    int n=s.size(),ans1=0,ans2=1;
    
    for(int i=1;i<n;i++){
        if(s.at(i)==s.at(i-1)){
            if(s.at(i)=='1'){
                s.at(i)='0';
            }
            else{
                s.at(i)='1';
            }
            ans1+=1;
        }
        else{
        }
    }
    
    if(s2.at(0)=='1'){
        s2.at(0)='0';
    }
    else{
        s2.at(0)='1';
    }
    
    for(int i=1;i<n;i++){
        if(s2.at(i)==s2.at(i-1)){
            if(s2.at(i)=='1'){
                s2.at(i)='0';
            }
            else{
                s2.at(i)='1';
            }
            ans2+=1;
        }
        else{
        }
    }    
    cout<<min(ans1,ans2)<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void) {

	int n;
	
	scanf("%d", &n);
	int i, k;

	for (i = 1; i < 10; i++) {
		for (k = 1; k < 10; k++) {
			if (n == i * k) {
				printf("Yes");
				return 0;
				

			}
			
		}
		

	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
# Union-Findデータ構造
class UnionFind:
    def __init__(self, numV):
        self.pars = [i for i in range(numV)]
        self.ranks = [0] * numV

    def find(self, x):
        if self.pars[x] == x:
            return x
        else:
            self.pars[x] = self.find(self.pars[x])
            return self.pars[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
        else:
            self.pars[y] = x
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1


N, K, L = map(int, input().split())
pqs = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(K)]
rss = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(L)]

# 道路
UFRoad = UnionFind(N)
for p, q in pqs:
    UFRoad.union(p, q)

# 鉄道
UFRailway = UnionFind(N)
for r, s in rss:
    UFRailway.union(r, s)

Ts = [(UFRoad.find(i), UFRailway.find(i), i) for i in range(N)] + [(N, N, N)]
Ts.sort()

anss = [0] * N
iFr = 0
for i in range(N):
    if Ts[i][0:2] != Ts[i + 1][0:2]:
        for j in range(iFr, i + 1):
            anss[Ts[j][2]] = i - iFr + 1
        iFr = i + 1

print(' '.join(map(str, anss)))


Measured memory_bytes: 80260
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=1;i<=N;i++)

signed main(){
  int A,B;
  cin>>A>>B;
  string ans="No";
  rep(i,3){
    if(A*B*i%2==1)ans="Yes";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] *= (-1)
heapq.heapify(a)

for i in range(m):
    b = heapq.heappop(a)
    b = - (b * (-1) // 2)
    heapq.heappush(a, b)
    
print(-sum(a))

Measured memory_bytes: 72300
#include <iostream>
#include <string>
#include <set>

using namespace std;

//const int MAXN = 10000500;
const int MAXN = 5000;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;

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

	int n = 0;
	cin >> n;

	string s = "";
	cin >> s;

	int num_r[MAXN];
	int num_g[MAXN];
	int num_b[MAXN];

	int rx = 0;
	int gx = 0;
	int bx = 0;


	for (int i = n-1; i >= 0; --i) {
		char s0 = s[i];
		if (s0 == 'R') {
			rx += 1;
		}
		else if (s0 == 'G') {
			gx += 1;
		}
		else {
			bx += 1;
		}
		num_r[i] = rx;
		num_g[i] = gx;
		num_b[i] = bx;
	}

	char a;
	char b;

	long long int res = 0;

	for (int i = 0; i <= n - 3; ++i) {
		a = s[i];
		for (int j = i + 1; j <= n - 2; ++j) {
			b = s[j];
			if (b != a) {
				if ((a == 'R' || b == 'R') && (a == 'G' || b == 'G')) {
					res += num_b[j + 1];
					if (2*j - i <= n - 1) {
						if (s[2 * j - i] == 'B') {
							res -= 1;
						}
					}
				}
				else if ((a == 'R' || b == 'R') && (a == 'B' || b == 'B')) {
					res += num_g[j + 1];
					if (2 * j - i <= n - 1) {
						if (s[2 * j - i] == 'G') {
							res -= 1;
						}
					}
				}
				else if ((a == 'B' || b == 'B') && (a == 'G' || b == 'G')) {
					res += num_r[j + 1];
					if (2 * j - i <= n - 1) {
						if (s[2 * j - i] == 'R') {
							res -= 1;
						}
					}
				}
			}
		}
	}

	if (n < 3) {
		cout << 0 << endl;
	}
	else {
		cout << res << endl;
	}
	

	//system("pause");
	return 0;
}
	
	


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

void solve(void){
  int n, x, t;
  std::cin >> n >> x >> t;

  std::cout << (n+x-1)/x * t << std::endl;
  return;
}
int main(void){
  solve();
  return 0;
}





Measured memory_bytes: 3632
using System;
using System.Collections.Generic;

class Program
{
    public void Proc()
    {
        int s = int.Parse(Console.ReadLine());
        int h = s / 3600;
        s = s % 3600;
        int m = s / 60;
        s = s % 60;
        Console.WriteLine(h + ":" + m + ":" + s);
    }



    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,a[31];

int main(){
	a[1]=1;a[2]=2;a[3]=4;
	for(int i=4;i<31;i++)a[i]=a[i-1]+a[i-2]+a[i-3];
	while(cin>>n){
		if(!n)return 0;
		cout<<(a[n]+3649)/3650<<endl;
	}
}

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

const int N = 110;

typedef long long LL;

vector<int> G[N];

int dep[N], mx, pos, tmp[N], fuck[N], n;

void dfs(int u, int f) {
    dep[u] = dep[f] + 1, tmp[u] = u, fuck[u] = dep[u];
    if (dep[u] > mx) mx = dep[u], pos = u;
    for (auto v : G[u]) if (v != f) {
        dfs(v, u);
        if (fuck[v] > fuck[tmp[u]]) tmp[u] = v;
        fuck[u] = max(fuck[u], fuck[v]);
    }
}

int ans1;

inline LL work1(int pos) {
    mx = 0, dfs(pos, 0);
    if (mx != ans1) return 1e18;
    vector<int> A, B; A.push_back(pos);
    for (auto v : G[pos]) B.push_back(v);
    LL nw = B.size();
    while (233) {
        swap(A, B), B.clear(); int t = 0;
        for (auto u : A) {
            t = max((int)G[u].size() - 1, t);
            for (auto v : G[u]) if (dep[v] > dep[u]) 
                B.push_back(v);
        }
        if (!t) return nw;
        if (1e18 / t < nw) return 1e18;
        nw *= t;
    }
}

inline LL work2(int A, int B) {
    int nw = n + 1;
    for (auto &v : G[A]) if (v == B) { v = nw; break; }
    for (auto &v : G[B]) if (v == A) { v = nw; break; }
    G[nw].push_back(A), G[nw].push_back(B);
    ans1++; LL ans = work1(nw); ans1--;
    for (auto &v : G[A]) if (v == nw) { v = B; break; }
    for (auto &v : G[B]) if (v == nw) { v = A; break; }
    G[nw].clear();
    return ans;
}

int main() {
    scanf("%d", &n);
    for (int i = 1, a, b; i < n; i++) 
        scanf("%d%d", &a, &b), G[a].push_back(b), G[b].push_back(a);
    dfs(1, 0); int A = pos; mx = 0;
    dfs(A, 0); int B = pos;
    vector<int> hh;
    while (233) {
        hh.push_back(A);
        if (A == B) break;
        A = tmp[A];
    } 
    printf("%d ", ans1 = (hh.size() + 1) / 2); 
    LL ans2 = 1e18;
    for (int i = 1; i <= n; i++)
        for (auto j : G[i]) if (i < j) ans2 = min(ans2, work2(i, j));
    if (hh.size() & 1) {
        int mid = hh[hh.size() / 2];
        printf("%lld\n", min(work1(mid), ans2));
    } else {
        printf("%lld\n", ans2);
    }
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    a, b = input().split()
    if a == b:
        print('H')
    else:
        print('D')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9020
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
void solve(){
	int n;
	cin >> n;
	int a[n];
	for(int &i : a) cin >> i;
	int count = 1;
	int mini = a[0];
	for(int i = 1; i < n; i++){
		if(a[i] < mini)
			count++, mini = a[i];
	}
	cout << count << endl;
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
		
		public static double[] equation(double a,double b,double c,double d,double e,double f){
			double det = a*e-b*d;
			double[] ans = new double[2];
			double x = (c*e-b*f)/det;
			double y = (a*f-c*d)/det;
			if(x==-0)
				x = 0;
			if(y==-0)
				y = 0;
			ans[0] = x;
			ans[1] = y;
			return ans;
		}
		
		public static String[] kommmaReader(String sc) {
			String line = sc;
			String[] array = line.split(",");
			return array;
		}

		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			do{
				double[] p = new double[8];
				for(int i=0; i<8; i++) p[i] = sc.nextDouble();
				double[] ans = equation(p[0]-p[2],p[4]-p[2],p[6]-p[2],p[1]-p[3],p[5]-p[3],p[7]-p[3]);
			
				if(ans[0]+ans[1]<1 && ans[0]>0 && ans[1]>0) System.out.println("YES");
				else System.out.println("NO");
			} while(sc.hasNext());
		}

}

Measured memory_bytes: 12000
#!/usr/bin/env pypy
from __future__ import division, print_function
 
import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase
 
import __pypy__
 
def pi(s):
    p = [0] * len(s)
    g = 0
    for i in range(1, len(s)):
        while g and (s[i] != s[g]):
            g = p[g - 1]
        p[i] = g = g + (s[i] == s[g])

    return p


def match(s, pat, uniq='\0'):
    return [i + 1 - c for i, c in enumerate(pi(pat + uniq + s)[len(pat) + 1:]) if c == len(pat)]
 
 
def main():
    s = input()
    t = input()
 
    if len(s) < len(t):
        s *= (len(t) + len(s) - 1) // len(s)
    n = len(s)
    s *= 3
 
    lo, hi = 0, (len(s) + len(t) - 1) // len(t)
    while lo < hi:
        mi = (lo + hi) // 2
        u = mi * t
        if not match(s, u):
            hi = mi
        else:
            lo = mi + 1
 
    if len(t * (lo - 1)) >= 2 * n:
        print(-1)
        return
 
    print(lo - 1)
 
 
# region fastio
 
BUFSIZE = 8192
 
 
class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()
 
 
class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)
 
    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()
 
 
def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 183924
#include <cstdio>
#include <cstring>
#define maxn (ll)1e5+10
using namespace std;
typedef long long ll;
char s[maxn];
int len;
int main() {
	scanf("%s",s);
	len=strlen(s);
	if (len==2) {
		if (s[0]==s[1])
			printf("1 2\n");
		else printf("-1 -1\n");
	}
	else {
		bool t=true;
		for (int i=0;i+2<len;i++) {
			if (s[i]==s[i+1]||s[i]==s[i+2]||s[i+1]==s[i+2]) {
				printf("%d %d\n",i+1,i+3);
				t=false;
				break;
			}
		}
		if (t)
			printf("-1 -1\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
    int N, ans=0, tmp=0;
    std::string S;
    std::cin >> N >> S;

    for (char c: S){
        if (c == 'I') ++tmp;
        else --tmp;
        if (ans < tmp) ans = tmp;
    }

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


Measured memory_bytes: 3612
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int32_t main()
{
	char c;
	cin >> c;
	if(c=='z'){
		cout<<"a";
	}
	else{
		char m = c+1;
		cout<<m;
	}

}


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

sp = []

for i in range(n):
    s, p = input().split()
    sp.append([s, int(p), i+1])

sp.sort(key=lambda n: n[1], reverse=True)
sp.sort(key=lambda n: n[0])

for a in range(n):
    print(sp[a][2])



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define vc vector
ll mod=1e9+7;
void read(vector<int>& arr){
    for(int i=0;i<arr.size();i++)
        cin>>arr[i];
}
ll helper(int sum,vc<ll>& dp){
    if(sum==0)return 1;
    if(dp[sum]!=-1)return dp[sum];
    dp[sum]=0;
    for(int i=3;i<=sum;i++){
        if(sum-i<0)break;
        dp[sum]=(dp[sum]+helper(sum-i,dp))%mod;
    }
    return dp[sum];
}
void solve(){
    int s;
    cin>>s;
    vc<ll> dp(s+1,-1);
    cout<<helper(s,dp)%mod;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
N = int(input())
Ball = []
for i in range(N):
    x, y = map(int, input().split())
    x, y = min(x, y), max(x, y)
    Ball.append((x, y))

Ball.sort()  # ソートしておく
X = [x for x, y in Ball]
Y = [y for x, y in Ball]

# 全体のMIN, MAX
MIN = X[0]
MAX = max(Y)

# 確定2玉を別グループに
ans = (max(X) - MIN) * (MAX - min(Y))

# 確定2玉を同じグループに

# 全体のMAX・MINが確定している場所は、もう片方を使うしかない
MIN_index, MAX_index = X.index(MIN), Y.index(MAX)

# 選ばざるを得ないやつ
MIN_O = X[MAX_index]
MAX_O = Y[MIN_index]
MIN_O, MAX_O = min(MIN_O, MAX_O), max(MIN_O, MAX_O)

# 選択肢がないやつを削除
Ball = [Ball[i] for i in range(N) if i not in (MIN_index, MAX_index)]

# つくりおし
X = [x for x, y in Ball]
Y = [y for x, y in Ball]

# とりあえず小さいほうを集めたことにしておく
B = [x for x in X] + [MAX_O, MIN_O]
B_max = max(B)

for i in range(len(Ball)):
    x, y = X[i], Y[i]
    if B_max - x > B_max - y >= 0:
        B[i] = y
    else:
        break

ans = min(ans, (MAX - MIN) * (max(B) - min(B)))
print(ans)


Measured memory_bytes: 36288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    OUT(b*(int)((t+0.5)/a));
}

Measured memory_bytes: 892
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String n=sc.next();
    for(int i=0; i<n.length(); i++){
      if(n.charAt(i)=='9'){
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21716
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

enum class Dir {
  None, Up, Left, Down, Right
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W, K;
  cin >> H >> W >> K;
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--; y1--; x2--; y2--;
  vector<string> cs(H);
  F0R(i, H) {
    cin >> cs[i];
  }

  int inf = 10000000;
  vector<vector<int>> dp(H, vector<int>(W, inf + 1));

  queue<tuple<int, int, int, Dir>> qu;
  qu.emplace(x1, y1, 0, Dir::None);
  dp[x1][y1] = 0;

  while (qu.size()) {
    auto [r, c, d, dir] = qu.front();
    qu.pop();

    if (r == x2 && c == y2) break;
    d++;

    int up = 0, left = 0, down = 0, right = 0;

    if (dir != Dir::Down) {
      FOR(i, 1, min(K + 1, r + 1)) {
        if (cs[r - i][c] == '@') break;
        up++;
      }
    }
    if (dir != Dir::Right) {
      FOR(i, 1, min(K + 1, c + 1)) {
        if (cs[r][c - i] == '@') break;
        left++;
      }
    }
    if (dir != Dir::Up) {
      FOR(i, 1, min(K + 1, H - r)) {
        if (cs[r + i][c] == '@') break;
        down++;
      }
    }
    if (dir != Dir::Left) {
      FOR(i, 1, min(K + 1, W - c)) {
        if (cs[r][c + i] == '@') break;
        right++;
      }
    }

    RFO(i, 1, up + 1) {
      if (dp[r - i][c] > d) {
        dp[r - i][c] = d;
        qu.emplace(r - i, c, d, Dir::Up);
      }
    }
    RFO(i, 1, left + 1) {
      if (dp[r][c - i] > d) {
        dp[r][c - i] = d;
        qu.emplace(r, c - i, d, Dir::Left);
      }
    }
    RFO(i, 1, down + 1) {
      if (dp[r + i][c] > d) {
        dp[r + i][c] = d;
        qu.emplace(r + i, c, d, Dir::Down);
      }
    }
    RFO(i, 1, right + 1) {

      if (dp[r][c + i] > d) {
        dp[r][c + i] = d;
        qu.emplace(r, c + i, d, Dir::Right);
      }
    }
  }


  cout << (dp[x2][y2] > inf ? -1 : dp[x2][y2]);
}
#endif


Measured memory_bytes: 12168
#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
ll ALL,n,a[1010],N,tmp;
ll dp[2][606][606];
int vis[1010]; 
inline void add(ll &a,const ll &b){
	a=a+b;
	if (a>=ljc) a-=ljc;
} 
signed main(){
	n=read();N=2*n;
	for (int i=1;i<=N;i++){
		a[i]=read();
	}
	ALL=n;
	ll fac=1;
	for (int i=1;i<=N;i+=2){
		if (~a[i]&&~a[i+1]){
			vis[a[i]]=vis[a[i+1]]=2;ALL--;
		}else if (a[i]*a[i+1]<0){
			vis[max(a[i],a[i+1])]=1;ALL--; 
		}
	}
	for (ll i=2;i<=ALL;i++) fac=fac*i%ljc;
	bool cur=0;
	dp[cur][0][0]=1;
	// i -1 0
	for (int i=N+1;i>1;i--){
		for (int j=0;j<=N;j++){
			for (int k=0;k<=N;k++){
				if (vis[i-1]==1){
					add(dp[cur^1][j+1][k],dp[cur][j][k]); 
					if (k) add(dp[cur^1][j][k-1],dp[cur][j][k]); 
				}else if (vis[i-1]==0){
					add(dp[cur^1][j][k+1],dp[cur][j][k]); 
					if (j) add(dp[cur^1][j-1][k],1ll*j*dp[cur][j][k]%ljc);
					if (k) add(dp[cur^1][j][k-1],dp[cur][j][k]);
				}else{
					dp[cur^1][j][k]=dp[cur][j][k];
				}
			}
		}
		memset(dp[cur],0,sizeof dp[cur]);
		cur^=1;
	} 
	cout<<fac*dp[cur][0][0]%ljc;
    return 0;
}


Measured memory_bytes: 9400
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=2e3+7;
int dp[N][N];
int a[N],b[N];
const ll mod=1e9+7;
int n,m;
ll solve(int i,int j){
	if(dp[i][j]!=-1) {
		return dp[i][j];
	}
	if(i==n+1||j==m+1) {
		return 0;
	}
	ll ans=0;
	if(a[i]==b[j]) {
		ans= 1+solve(i,j+1)+solve(i+1,j);
	}
	else {
		ans=solve(i,j+1)+solve(i+1,j)-solve(i+1,j+1);
	}
	ans+=mod;
	ans%=mod;
	return dp[i][j]=ans;
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	cin>>n>>m;
	memset(dp,-1,sizeof dp);
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=m; i++) cin>>b[i];
	ll ans=solve(1,1)+1;
	//ans%=mod;
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 16256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Manjyu{
	Manjyu(int arg_price){
		price = arg_price;
	}
	bool operator<(const struct Manjyu &arg) const{
		return price < arg.price;
	};
	int price;
};

struct Box{

	Box(int arg_price,int arg_num_contain,double arg_per_manjyu){
		price = arg_price;
		num_contain = arg_num_contain;
		per_manjyu = arg_per_manjyu;
	}
	bool operator<(const struct Box &arg) const{
		return per_manjyu > arg.per_manjyu;
	};
	int price,num_contain;
	double per_manjyu;
};


int main(){

	int M,N;
	scanf("%d %d",&M,&N);
	int table[M+1];

	priority_queue<Manjyu> M_Q;
	int tmp;
	for(int i = 0; i < M; i++){
		scanf("%d",&tmp);
		M_Q.push(Manjyu(tmp));
	}

	table[0] = 0;
	table[1] = M_Q.top().price;
	M_Q.pop();
	for(int i = 2; i <= M; i++){
		table[i] = M_Q.top().price;
		table[i] += table[i-1];
		M_Q.pop();
	}

	int dp[M+1];
	dp[0] = 0;
	for(int i = 1; i <= M; i++)dp[i] = BIG_NUM;

	int num,price;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d",&num,&price);

		if(num > M){
			dp[M] = min(dp[M],price);
		}else{
			for(int i = M; i-num >= 0; i--){
				if(dp[i-num] != BIG_NUM){
					dp[i] = min(dp[i],dp[i-num]+price);
				}
			}
		}
		for(int i = M-1; i >= 0; i--){
			dp[i] = min(dp[i],dp[i+1]);
		}
	}

	int maximum = 0;
	for(int i = 1; i <= M; i++){
		maximum = max(maximum,table[i]-dp[i]);
	}

	printf("%d\n",maximum);

	return 0;
}

Measured memory_bytes: 3368
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
 
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//infinity
#define INTINF 2000000000
#define LONGINF 20000000000
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(){
  int n; cin >> n;
  REP(i, 100){
		REP(j, 100){
			if( (4*i+7*j) == n ){
				cout << "Yes" << endl;
				return 0;
			}
		}
  }
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int main() {
//cout << fixed << setprecision(10);
ll n,k;
cin>>n>>k;
set<ll> S;
ll a;
ll b=0;
ll ok=0;
for(ll i=0; i<k; i++){
cin>>a;
S.insert(a);}
a=0;
for(ll i=n; i<100000; i++){
b=i;
while(b){
if(S.count(b%10)){
a=1;
break;}
else{
b/=10;}}
if(a==0){
b=i;
break;}
a=0;}
cout<<b<<endl;}


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

int main()
{
	string s; bool chk=true;
	cin>>s;
	for(int i=0;i<s.size();i++)
    {
        if(s[2]==s[3] && s[4]==s[5])
            {
                cout<<"Yes"<<endl;
                chk=false;
                break;
            }

    }
    if(chk)
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

NO = "IMPOSSIBLE"  # type: str

def solve(A: int, B: int):
    d = A-B
    if d % 2 != 0:
        print(NO)
        return
    print((A + B) // 2)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
##======================================python3
import sys
import collections
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

class Run:
    def build(gv):
        gv.L = int(input())

    def solve(gv):
        side = gv.L / 3
        ans = side**3
        ans = round(ans, 12)
        print(ans)
        
if __name__ == '__main__':
    run = Run()
    run.build()
    run.solve()


Measured memory_bytes: 3316
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
    struct num{
        int place;
        int name;
    };
    int N; cin >> N;
    vector<num> A(N);
    rep(i,N){
        cin >> A[i].place;
        A[i].name = i+1;
    }
    sort(ALL(A),sort_key(num, place));
    rep(i,N) cout << A[i].name << " ";
    cout << endl;

}



Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}


int main(){
	int x;
	while(cin >> x,x){
		int num = 2;
		ll int cnt = 0;
		while(1){
			if((x-((num)*(num-1)/2)) <= 0) break;
			if((x-((num)*(num-1)/2))%num == 0) {
				if(x!=1) cnt++;
			}
			num++;
		}
		cout << cnt << endl;
	}
}

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

/*
 * 桁DP
 * ・非負整数 X が X≤K の範囲を動くときの、〜〜〜の最大値を求めよ
 * ・非負整数 X が X≤K の範囲を動くときの、〜〜〜という条件を満たすものは何通りあるか
 * の時に有効
 *
 * dp[i][smaller]  i: i桁目,  smaller: Kと一致するか否かの「未満フラグ」
 * 格納する値はその時点の最大値など
 *
 * dpの流れ
 * ⓪初期化
 * ⓵初期条件を代入する
 * ⓶逐次代入
 *
 * XOR は a ^ b の演算でできる
 *
 * */
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MAX_DIGIT = 50; // とりあえず50桁までと決めて行う
long long dp[100][2]; // dp[上から i 桁まで][ smaller ]

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    memset(dp, -1, sizeof(dp)); // DP 配列を -1 で初期化

    dp[0][0] = 0; // 初期条件


    for (int d = 0; d < MAX_DIGIT; ++d) {
        long long mask = 1LL<<(MAX_DIGIT - d - 1);

        // A で元々 d 桁目にビットが立っているものの個数
        int num = 0;
        for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;

        // X の d 桁目を 0, 1 にしたときのコスト
        long long cost0 = mask * num;
        long long cost1 = mask * (N - num);

        // smaller -> smaller
        if (dp[d][1] != -1) {
            chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1)); // 0 でも 1 でも自在に大きい方
        }

        // exact -> smaller
        if (dp[d][0] != -1) {
            if (K & mask) { // K の d 桁目が 1 だったら、X の d 桁目は 0 にする
                chmax(dp[d+1][1], dp[d][0] + cost0);
            }
        }

        // exact -> exact (K にぴったり合わせる)
        if (dp[d][0] != -1) {
            if (K & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
            else chmax(dp[d+1][0], dp[d][0] + cost0);
        }
    }
    cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod 1000000007
using namespace std;
vector<ll> prime,sfac;
vector<ll>ps;
void sieve(ll n)
{
	prime.assign(n+1,1);
	sfac.assign(n+1,1);    
    for (int p=2; p*p<=n; p++) 
    {         
        if (prime[p] == 1) 
        { 	sfac[p]=p;  			  
            for (int i=p*p; i<=n; i += p) 
              {  prime[i] = 0; sfac[i]=p;}
        } 
    } 
	for(ll i=2;i<=n;i++)
	{
		if(prime[i])
			ps.push_back(i);
	}
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
int isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return 0; 
    if (n <= 3)  return 1; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return 0; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return 0; 
  
    return 1; 
} 

int main()
{
    ll n,k;
    cin>>n>>k;
    ll p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
    sort(p,p+n);
    ll sum=0;
    for(int i=0;i<k;i++)
        sum+=p[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR(i,k,n) for(ll i=(k);(k)<(n)?i<(n):i>(n);(k)<(n)?i+=1:i-=1)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int INF = 1<<29;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define sz(a) ll((a).size())
#define all(o) (o).begin(), (o).end()
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define TR(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
template<class T> T** arr2D(int n,int m,T init){
    T** mat=new T*[n];
    FOR(i,0,n){
        mat[i]=new T[m];
        FOR(j,0,m){
            mat[i][j]=init;
        }
    }
    return mat;
}
template<class T> void initialise(T** mat,T init,int n,int m){
    FOR(i,0,n){
        FOR(j,0,m){
            mat[i][j]=init;
        }
    }
}
template<class T> void destroy(T** mat,int n,int m){
    FOR(i,0,n){
        delete[] mat[i];
    }delete[] mat;
}
const int MOD = 1000000007;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }

/////////////////////////////////////////////////////////////////////
void solve(){
    int N;
    cin>>N;
    ll inf=1e10;
    vector<ll> height(N+1);
    vector<ll> cost(N+1,inf);
    FOR(i,1,N+1){
        cin>>height[i];
    }
    height[0]=height[1];cost[0]=0;
    FOR(i,0,N+1){
        FOR(j,i+1,i+3){
            if(j<=N){
                chmin(cost[j],cost[i]+abs(height[i]-height[j]));
            }
        }
    }
    cout<<cost[N]<<'\n';
}
int main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    solve();
    return 0;
}


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

char maze[51][51];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++) cin >> maze[i][j];
    }

    bool ans = true;
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j] == '#'){
                bool flag = false;
                for(int k=0; k<4; k++){
                    int ny = i + dy[k];
                    int nx = j + dx[k];
                    if(0 <= nx && nx < w && 0 <= ny && ny < h && maze[ny][nx] == '#') flag = true;
                }
                if(flag == false) ans = false;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256