akhauriyash/Code-Regression huggingface dataset:
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=parseMap(split(readline()))
    k=parseInt(readline())
    while b<=a
        b*=2
        k-=1
    end
    while c<=b
        c*=2
        k-=1
    end
    if k<0
        println("No")
    else
        println("Yes")
    end
end
main()

Measured memory_bytes: 161052
#include<iostream>
using namespace std;
double a[1005];
int main() {
	int m;
	double sum = 0;
	cin >> m;
	for (int i = 1; i <= m; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++)
	{
		sum += 1 / a[i];
	}
	sum = 1 / sum;
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_12_B: Single Source Shortest Path I

#include <algorithm>
#include <cstdio>

using uint = unsigned int;

class Graph {
  const uint n_;
  uint* const g_;
  const uint INFINIT;
  
public:

  Graph(uint n) : n_(n), g_(new uint[(n_*n_)]), INFINIT(100000*n_) {
    std::fill_n(g_, (n_*n_), INFINIT);
  }

  ~Graph() { delete[] g_; }
  
  uint* operator [](uint i) const { return g_+(n_*i); }

  void dijkstra(uint* dist)
  {
    std::fill_n(dist, n_, INFINIT);
    bool visited[n_];
    std::fill_n(visited, n_, false);
    auto i = 0u; // 0-start
    visited[i] = true;
    dist[i] = 0u;
    for (auto n = 0u; n < n_-1; ++n) {
      auto cur_min = INFINIT;
      auto es = (*this)[i];
      auto base_dist = dist[i];
      for (auto j = 0u; j < n_; ++j) {
        if (visited[j]) continue;
        dist[j] = std::min(dist[j], base_dist+es[j]);
        if (cur_min > dist[j]) {
          cur_min = dist[j];
          i = j;
        }
      }
      visited[i] = true;
      dist[i] = cur_min;
    }
  }
};

int main()
{
  uint n;
  std::scanf("%u", &n);

  Graph g(n);

  uint u, k, c, v;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u %u", &u, &k);
    for (auto j = 0u; j < k; ++j) {
      std::scanf("%u %u", &c, &v);
      g[u][c] = v;
    }
  }

  uint dist[n];
  g.dijkstra(dist);
  for (auto i = 0u; i < n; ++i) {
    std::printf("%u %u\n", i, dist[i]);
  }
}

// eof

Measured memory_bytes: 2744
#include<bits/stdc++.h>
#define N 200010
using namespace std;

int main()
{
  int n;
  cin>>n;
  int flag=0;
  int a[N];
  for(int i=0;i<n;i++)
  {cin>>a[i];}
  sort(a,a+n);
  for(int i =1 ;i< n;i++)
  {if(a[i-1]==a[i]) {flag=1;
    break;}
    else flag=0;}
    if(flag==0) cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 1024
items = {}
recipes = {}


def reset():
    items.clear()
    recipes.clear()


def algorithm():
    while True:
        item_number = int(input())
        if item_number == 0:
            break
        reset()

        for _ in range(item_number):
            item, price = input().split()
            items[item] = int(price)

        recipe_number = int(input())
        for _ in range(recipe_number):
            recipe = input().split()
            r = []
            for i in range(int(recipe[1])):
                r.append(recipe[i + 2])
            recipes[recipe[0]] = r

        for _ in range(len(recipes)):
            for k, v in recipes.items():
                total = 0
                for i in range(len(v)):
                    total += items[v[i]]
                items[k] = items[k] if items[k] < total else total

        target = input()
        print(items[target])


def main():
    algorithm()


if __name__ == '__main__':
    main()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, M, C;
	cin >> N >> M >> C;
	vector<ll> B(M);
	vector<ll> A[N];
	REP(i, M) cin >> B[i];
	REP(i, N){
		REP(j, M){
			ll x;
			cin >> x;
			A[i].push_back(x);
		}
	}

	ll res = 0;
	REP(i, N){
		ll tmp = C;
		REP(j, M){
			tmp += A[i][j]*B[j];
		}
		if(tmp>0) res++;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = c - a; int y = d - b;
	printf("%d %d %d %d", c - y, d + x, a - y, b + x);
	return 0;
}

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

int main(){
    ll N;
    cin >> N;
    double sum=0.0;
    rep(i,N){
        double ai;
        cin >> ai;
        sum += 1.0/ai;
    }
    cout << 1.0/sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX-100;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int N; int K;
    cin >> N;
    cin >> K;
    vector<int> h(N+1);
    for(auto i = 1; i <= N; i++){
        cin >> h[i] ;
    }
    
    vector<int> dp(N+1,INF);
    //残りNステップ
    
    dp[N] = 0;

    for(auto i = N-1; i>=1; i--){
        
        for(auto k = 1; k<=K; k++){
            
            if (i+k>N)continue;
            dp[i] = min(dp[i],dp[i+k] + abs(h[i+k]-h[i]) );
        }
        
        
    }
    
    cout << dp[1] << endl;

    return 0;
}




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

bool ba[1000][1000];
int tate[1000];
int yoko[1000];

int main() {
  int h,w;
  cin >> h >> w;
  for (int i=0; i<h; ++i) {
    for (int j=0; j<w; ++j) {
      cin >> ba[i][j];
      if (ba[i][j]) tate[j]++,yoko[i]++;
    }
  }
  for (int i=0; i<h; ++i) {
    for (int j=0; j<w; ++j) {
      if (j) cout << " ";
      if ((tate[j]+yoko[i]+ba[i][j])%2==0) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }  
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=j;i<k;i++)
using namespace std;
const int N=605;
int d[12][N][N],a[N][N],n,d1,d2;
void cao(int n,int d1,int dep){
	if (d1%4){
		if (d1%2)
			For(i,0,2*n) For(j,0,2*n)
				d[dep][i][j]=(i+j+1)&1;
		else
			For(i,0,2*n) For(j,0,2*n)
				d[dep][i][j]=(i+1)&1;
	}
	else{
		cao(n,d1/4,dep+1);
		For(i,0,2*n) For(j,0,2*n)
			d[dep][i][j]=d[dep+1][i/2][j/2];
	}
}
int main(){
	int cnt=0;
	scanf("%d%d%d",&n,&d1,&d2);
	cao(n,d1,0);
	For(i,0,2*n) For(j,0,2*n)
		a[i][j]=d[0][i][j];
	cao(n,d2,0);
	For(i,0,2*n) For(j,0,2*n)
		a[i][j]&=d[0][i][j];
	For(i,0,2*n) For(j,0,2*n)
		if (a[i][j]){
			printf("%d %d\n",i,j);
			if ((++cnt)==n*n) exit(0);
		}
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
int n,a[200005];
inline bool check(int x){
	if(x==1){
		bool flag=1;
		for(int i=1;i<n;i++)	if(a[i+1]<=a[i])	flag=0;
		return flag;
	}
	map<int,int> mp;
	int cur=0;
	for(register int i=1;i<=n;i++){
		if(a[i]<=cur){
			cur=a[i];
			while(1){
				if(mp[cur]<x-1)	break;
				mp[cur]=0;
				cur--;
			}
			mp[cur]++;
			if(cur<=0)	return 0;
		}
		else	cur=a[i];
		mp.erase(mp.upper_bound(cur),mp.end());
	}
	return 1;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	int l=1,r=300000,ans;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))	ans=mid,r=mid-1;
		else			l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import Foundation

var input = readLine()!.split(separator: " ")
let n = Int(input[0])!
let x = Int(input[1])!
let m = Int(input[2])!
var s: [Int] = .init(repeating: 0, count: 100001)
var f = x
var first = 1
var last = 0
s[f] = 1
for i in 2...n {
    f = (f * f) % m;
    if s[f] != 0 {
        first = s[f]
        last = i
        break
    } else {
        s[f] = i
        first = i
    }
}
var t = s.enumerated().filter { $0.element != 0 }.sorted { $0.element < $1.element }.map { $0.offset }
if first == n {
    print(t.reduce(0, +))
} else {
    first -= 1 ; last -= 1
    let x = (n - first) / (last - first)
    let y = (n - first) % (last - first)
    print(t[..<first].reduce(0, +) + t[first..<last].reduce(0, +) * x + (t[first..<(first+y)].reduce(0, +)))
}

Measured memory_bytes: 15748
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	
	int n,m; 
  	cin>>n>>m;
	vector<int> a(n);
	double sum{};
	for(int i=0; i<n; i++) 
    {
		cin>>a.at(i);
		sum+=a.at(i);
	}
	sort(a.rbegin(),a.rend());
	if(a.at(m-1)>=sum/4/m) 
      cout <<"Yes"<<endl;
	else 
      cout << "No" <<endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else: 
        if B[i] >= (A[i] + A[i+1]):
            ans += (A[i] + A[i+1])
            A[i+1] = 0
        
        elif B[i] < (A[i] + A[i+1]):
            ans += B[i]
            A[i+1] = (A[i] + A[i+1]) - B[i]
print(ans)





Measured memory_bytes: 18624
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl a(N);
  rep(i, N) cin >> a[i];

  stable_sort(a.begin(), a.end());

  cout << a[N - 1] - a[0] << endl;
  
  return 0;
}


Measured memory_bytes: 256
N=input()

if len(N)==1:
    print(N)
    exit()

def calc(str):
    l=list(map(int,str))
    all=sum(l)
    
    return all

cand1=str(int(N)-int(N[-1])-1)
cand2=str(int(N[0])*10**(len(N)-1)-1)

print(max(calc(cand1),calc(cand2),calc(N)))

Measured memory_bytes: 3060
def gcd(a_gcd, b_gcd):
    while b_gcd != 0:
        a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
    return a_gcd


def lcm(a_lcm, b_lcm):
    return a_lcm * b // gcd(a_lcm, b_lcm)


def max_sum(N_max_sum, a_max_sum):
    dp = [0] * (N_max_sum + 1)
    for i in range(N_max_sum):
        dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
    return dp[N]


def knapsack(N_knapsack, W, weight, value):
    inf = float("inf")
    dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
    for i in range(W+1):
        dp[0][i] = 0

    for i in range(N_knapsack):
        for w in range(W+1):
            if weight[i] <= w:
                dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    return dp[N_knapsack][W]


# # s = input()
# # N = int(input())
# N, K = map(int, input().split())
# # b = list(map(int, input().split()))
# # c = [list(map(int, input().split())) for _ in range(N)]
#
#
#
# print(N-K+1)

R, G, B, N = map(int, input().split())
ans = 0

for r_i in range(N + 1):
    if r_i * R > N:
        break
    for g_i in range(N + 1):
        if r_i * R + g_i * G > N:
            break
        if (N - (r_i * R + g_i * G)) % B == 0:
            ans += 1

print(ans)

















Measured memory_bytes: 40428
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int a, b, c, n = 0, iIn;
	register int i;
	cin >> a >> b >> c;
	for (i = 1; i <= a; ++i){
		cin >> iIn;
		if (iIn < b || iIn >= c)
			++n;
	}
	cout << n << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
A = []
for i in range(6):
  a = int(input())
  A.append(a)

k = A[5] 
judge = 1
for i in range(5):
  for j in range(5):
    if(abs(A[i]-A[j]) > k):
      judge = 0
      break
   
if(judge == 0):
  print(':(')
else:
  print('Yay!')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,ans = 10;
char s[100007];
int main(){
  scanf("%s",s);
  n = strlen(s);
  for(int i=1;i<n;i++){
    if( n%i == 0 ){
      string max_t = "", min_t,cur;
      rep(i,1e3) min_t += '9';
      rep(j,n){
        cur += s[j];
        if( (j+1)%i == 0 ){
          max_t = max( max_t, cur);
          min_t = min( min_t, cur);
          cur = "";
        }
      }
      rep(j,min_t.size()+1){
        if( i == j+1 )ans = min( ans, max_t[j]-min_t[j]);
        if( max_t[j] != min_t[j] )break;
      }
    }
  }
  int max_t = 0, min_t=9;
  rep(i,n){
    int p = s[i]-'0';
    if(i!=n-1&&s[i]=='1')p = p*10 + s[i+1]-'0',i++;
    max_t = max( max_t, p);
    min_t = min( min_t, p);
  }
  cout << min( ans, max_t - min_t) << endl;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  
  vector<int> IDX;
  
  // 連続する1or0の最初のindexを取得
  IDX.push_back(0);
  for(int i = 0; i < N - 1; i++){
    if( S[i+1] != S[i] ){ IDX.push_back(i+1); }
  }
  IDX.push_back(N); // 終端文字のindexになる
  
  vector<int> Cnts;
  int k, idx;
  
  for(auto i = IDX.begin(); i < IDX.end(); i++){
    //cout << *i << " ";
    
    if( S.compare(*i, 1, "1") == 0 ){ k = 2 * K + 1; }
    else if( S.compare(*i, 1, "0") == 0 ){ k = 2 * K; }
    
    // 範囲外アクセス防止
    idx = distance( IDX.begin(), i );
    if( idx + 1 + k > IDX.size() ){ k = IDX.size() - (idx + 1); } 
    //cout << k << " ";
    
    Cnts.push_back( *(i + k) - *i );
  }
 
  int max = *max_element( Cnts.begin(), Cnts.end() );
  cout << max;
  
  return 0;
}

Measured memory_bytes: 1528
from collections import deque

h, w = map(int, input().split())
INF = float("inf")
vect = ((0, 1), (0, -1), (1, 0), (-1, 0))
field = [[INF] * w for _ in range(h)]
bcnt = 0

for i in range(h):
    for j, s in enumerate(input()):
        if s == "#":
            field[i][j] = -1
            bcnt += 1

q = deque([(0, 0)])
field[0][0] = 0

while q:
    y, x = q.popleft()
    if y == h-1 and x == w-1: break
    for dy, dx in vect:
        ny, nx = y + dy, x + dx
        if ny < 0 or ny >= h or nx < 0 or nx >= w or field[ny][nx] != INF: continue
        q.append((ny, nx))
        field[ny][nx] = field[y][x] + 1

res = field[h-1][w-1]
if res == INF or res == -1: print(-1)
else: print(h*w - bcnt - (res + 1))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
using namespace std;
//     for(i=0;i<n;i++)
//     for(j=0;j<n;j++

int main()
{
    ll i,j,k,n,q,t=1,c=0;
    ll a,b;
    cin>>a>>b;
    if(a==0&&b==100)cout<<101<<endl;
    else if(a==1&&b==100)cout<<10100<<endl;
    else if(a==2&&b==100)cout<<1010000<<endl;
    else
    {
        while(a--)
        {
            b*=100;
        }
        cout<<b<<endl;
    }

}


Measured memory_bytes: 256
#include<iostream>

int main(){
	int i,N,A[20],B[20],C[20];
  int sum=0;
  scanf("%d",&N);
  for(i=0;i<=N-1;i++){
    scanf("%d",&A[i]);
  }
    for(i=0;i<=N-1;i++){
    scanf("%d",&B[i]);
      sum=sum+B[i];
  }
    for(i=0;i<=N-2;i++){
    scanf("%d",&C[i]);
  }
  for(i=1;i<=N-1;i++){
  	if(A[i-1]+1==A[i]){
        	sum=sum+C[A[i-1]-1];
    }
  }
  printf("%d",sum);
}

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

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

int main(){
	int N,X;
	cin>>N>>X;
	int x[N];
	for(int i=0;i<N;i++){
		cin>>x[i];
		x[i]=abs(x[i]-X);
	}
	if(N==1){
		cout<<x[0]<<endl;
		return 0;
	}
	
	int ans = gcd(x[0],x[1]);
	
	for(int i=2;i<N;i++){
		ans=gcd(ans,x[i]);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

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

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int m, d;

int main(){
  scanf("%d %d", &m, &d);
  int ans = 0;
  for(int i = 1; i <= m; ++i){
    for(int j = 10; j <= d; ++j){
      if(j % 10 >= 2 && j / 10 >= 2 && (j % 10) * (j / 10) == i){
        ++ans;
      }
    }
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

ll N;
ll a[100010];
map<ll,ll> s;
set<ll> t;
ll ans;

int main() {
    cin >> N;
    rep(i,N) cin >> a[i];
    rep(i,N){
        s[a[i]]++;
    }
    for(auto i = s.begin();i!=s.end();i++){
        if ((i->se-i->fi) >= 0){
            ans += (i->se-i->fi);
        }
        else{
            ans+=i->se;
        }
    }
    cout << ans << endl;
   
    return 0;
}


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

int main()
{
    int A, B, ans;
    cin >> A >> B;

    ans = 0;

    for (int j = 0; j <= B - A; j++)
    {
        int T, F;
        T = 10000;
        F = 1;
        int a = A + j;
        int sub = 0;
        for (int i = 0; i < 2; i++)
        {
            int p1, p2;
            p1 = (a - (a % T)) / T;
            p2 = a % (F * 10) / F;
            if (p1 == p2)
            {
                sub += 1;
            }

            a = a - p1 * T - p2 * F;
            T /= 10;
            F *= 10;
        }

        if (sub == 2)
        {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a=0,b=0,c=0;
    
    scanf("%d %d %d\n",&a,&b,&c);
    
    if((a<b)&&(b<c)&&(a<c))
    {
        printf("Yes\n");
    }else
    {
        printf("No\n");
    }
    
    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string str; cin >> str;
    ll n = str.size();
    reverse(str.begin(), str.end());
    ll dp[n+1][2]; // dp[i][0]: nocarry, dp[i][1]: carry
    dp[0][0] = 0; dp[0][1] = 1e18;
    for(int i=0;i<n;i++){
        ll d = ll(str[i] - '0');

        if(d == 9){
            dp[i+1][0] = dp[i][0] + d;
            dp[i+1][1] = min(dp[i][0] + (10 - d), dp[i][1]);
        }else{
            dp[i+1][0] = min(dp[i][0] + d, dp[i][1] + d + 1);
            dp[i+1][1] = min(dp[i][0] + (10 - d), dp[i][1] + (10 - (d + 1)));
        }
    }
    cout << min(dp[n][0], dp[n][1] + 1) << endl;
}

Measured memory_bytes: 17052
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    h = list(map(int, input().split()))
    res = 0
    for i in h:
        if i >= k:
            res += 1
    print(res)


if __name__ == '__main__':
    main()

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

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

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

    const int MAX = 305;
    double dp[MAX][MAX][MAX];

    for(int c = 0; c<=n; c++)
    {
        for(int b = 0; b +c <= n; b++)
        {
            for(int a = 0; a + b +c<=n;a++)
            {   
                if(a==0&&b==0&&c==0 || a+ b+ c>n)
                    continue;

                double pw =  (double) n/(a+b+c);
                double pa = (double) a/(a+b+c);
                double pb = (double) b/(a+b+c);
                double pc = (double) c/(a+b+c);

                if(c)
                {
                    dp[a][b][c] += pc*dp[a][b+1][c-1];
                }
                if(b)
                {
                    dp[a][b][c] += pb*dp[a+1][b-1][c];
                }
                if(a)
                {
                    dp[a][b][c] += pa*dp[a-1][b][c];
                }

                dp[a][b][c] += pw;
            }
        }
    }

    cout<<setprecision(12)<<dp[cnt[1]][cnt[2]][cnt[3]]<<"\n";
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int cnt2 = 0;
    int cnt4 = 0;
    inc(i, 0, n){
        int a;cin >> a;
        if(a%4 == 0){
            cnt4++;
        }else if(a%2 == 0){
            cnt2++;
        }
    }
    if(cnt2 > 0){
        cout << ((n-cnt2+1)/2 <= cnt4?"Yes":"No") << endl;
    }else{
        cout << ((n-cnt2)/2 <= cnt4?"Yes":"No") << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;

int n;
ll a,b,c,d;

int main(){
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	--n;
	ll dt=qmax(a,b)-qmin(a,b);
	rep(neg,0,n){
		ll pc=(n-neg)*c,pd=(n-neg)*d;
		ll nc=neg*c,nd=neg*d;
		if(pc-nd<=dt&&dt<=pd-nc) return puts("YES"),0;
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;

fn main() {
    
    let (x, y, _, k) = {
        let i = read::<usize>();
        (i[0], i[1], i[2], i[3])
    };

    let ax = read::<usize>();
    let by = read::<usize>();
    let cz = read::<usize>();
    let mut ab = Vec::new();
    for a in ax.iter() { for b in by.iter() {
        ab.push(a + b);
    }}

    ab.sort();
    ab.reverse();
    let mut abc = Vec::new();
    for i in 0..cmp::min(k, x * y) { for c in cz.iter() {
        abc.push(ab[i] + c);
    }}

    abc.sort();
    abc.reverse();
    for i in 0..k {
        println!("{}", abc[i]);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 44276
#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>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
struct UnionFind{
	//
	vector<int> par,ran;
	//
	UnionFind(int n){
		init(n);
	}
	//
	void init(int n){
		par.resize(n);
		ran.resize(n,0);
		for(int i=0;i<n;i++){
			par[i]=i;
		}
	}
	//
	int find(int x){
		return (x==par[x]?x:par[x]=find(par[x]));
	}
	//
	bool same(int x,int y){
		return find(x)==find(y);
	}
	//
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y){
			return;
		}else{
			if(ran[x]<ran[y]){
				par[x]=y;
			}else{
				par[y]=x;
				if(ran[x]==ran[y]){
					ran[x]++;
				}
			}
		}
	}
	//
};
//
int main(){
	int N,K,L;
	cin>>N>>K>>L;
	UnionFind road(N),train(N);
	for(int i=0;i<K;i++){
		int p,q;
		cin>>p>>q;
		p--;q--;
		road.unite(p,q);
	}
	for(int i=0;i<L;i++){
		int r,s;
		cin>>r>>s;
		r--;s--;
		train.unite(r,s);
	}
	int r[200000],t[200000];
	for(int i=0;i<N;i++){
		r[i]=road.find(i);
		t[i]=train.find(i);
	}
	map<pair<int,int>,int> M;
	for(int i=0;i<N;i++){
		M[make_pair(r[i],t[i])]++;
	}
	for(int i=0;i<N;i++){
		if(i){
			cout<<" ";
		}
		cout<<M[make_pair(r[i],t[i])];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	string s;
	cin >> s;
	bool ans = true;
	for (int i = 0; i < 3; i++) {
		if (s.at(i) != s.at(2 - i)) ans = false;
	}
	ansYes(ans);
}

Measured memory_bytes: 256
import sys
n=int(input())
x,y=0,0
for i in range(n):
  t,nx,ny=map(int,input().split())
  dist=abs(nx-x)+abs(ny-y)
  if(dist>t):
    print("No")
    sys.exit()
  elif((t-dist)%2!=0):
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto x:v) cout<<" "<<x; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int gcd(int a,int b){
	if(!a)
		return b;
	return gcd(b%a,a);
}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	ll n;
	cin>>n;
	if(n%2)
		cout<<0<<endl;
	else{
		ll d=5,ans=0;
		while(d<=n){
			ans+=(n/d)/2;
			d*=5;
		}
		cout<<ans<<endl;
	}
}


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

int main(void){
  int x[4],y[4];
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  x[2] = x[1] - (y[1] - y[0]);
  y[2] = y[1] + (x[1] - x[0]);
  x[3] = x[2] - (y[2] - y[1]);
  y[3] = y[2] + (x[2] - x[1]);
  cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
  return 0;
}


Measured memory_bytes: 256
#0522
def count(text,part):
    return sum(text.startswith(part,i) for i in range(len(text)))

while True:
    try:
        y = str(input())
    except:
        break
    x = count(y,'JOI')
    z = count(y,'IOI')
    print(x)
    print(z)


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  if(__builtin_popcountll(N)==1){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  cout<<1<<" "<<N+2<<endl;
  cout<<N+2<<" "<<3<<endl;
  cout<<3<<" "<<N+1<<endl;
  cout<<N+1<<" "<<2<<endl;
  cout<<2<<" "<<N+3<<endl;
  for(ll i=4;i<N;i+=2){
    cout<<N+1<<" "<<i<<endl;
    cout<<N+1<<" "<<i+1<<endl;
    cout<<i<<" "<<i+1+N<<endl;
    cout<<i+1<<" "<<N+i<<endl;
  }
  if(!(N&1)){
    cout<<N-1<<" "<<N<<endl;
    cout<<(N^1^(N-1))<<" "<<2*N<<endl;
  }
  return 0;
}


Measured memory_bytes: 2816
n, k = gets.split.map(&:to_i)
sunukes = (1..n).to_a
d = Array.new k
a = Array.new k
k.times do |i|
  d[i] = gets.to_i
  a[i] = gets.split.map(&:to_i)
  sunukes = sunukes - a[i]
end

puts sunukes.size

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

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

    int kisu = 0;
    for(int i = 0; i<N; i++) {
        if(A[i] % 2 == 1)kisu++;
    }

    string res = "YES";
    if(kisu % 2 == 1) res = "NO";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//数値
		String str = sc.next();
		int n[] = new int[4];

        	int A = Character.getNumericValue(str.charAt(0)); 
		    int B = Character.getNumericValue(str.charAt(1)); 
		    int C = Character.getNumericValue(str.charAt(2)); 
		    int D = Character.getNumericValue(str.charAt(3)); 
		    if(A+B+C+D==7) {
		    	System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");
		    	return;
		    	}
		    else if(A+B+C-D==7) {
		    	System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
		    	return;
		    	}
		    else if(A+B-C+D==7) {
		    	System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
		    	return;
		    	}
		    else if(A+B-C-D==7) {
		    	System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
		    	return;
		    	}
		    
		    else if(A-B+C+D==7) {
		    	System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");
		    	return;
		    	}
		    else if(A-B+C-D==7) {
		    	System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
		    	return;
		    	}
		    else if(A-B-C+D==7) {
		    	System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
		    	return;
		    	}
		    else if(A-B-C-D==7) {
		    	System.out.println(A+"-"+B+"-"+C+"-"+D+"=7");
		    	return;
		    	}
		}
}

Measured memory_bytes: 39584
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  double_t l,l1,ans;
  cin >>l;
  l1 =l/3;

  ans =l1*l1*l1;
  cout << fixed << setprecision(11);
  cout<<ans<<endl;;
return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b; cin>>a>>b;
  ((a+b)%2)?cout<<"IMPOSSIBLE"<<endl:cout<<(a+b)/2<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll X; cin >> X;
    // N個買うと合計金額は 100N ~ 105Nの間の金額は全て取れる
    bool flag = false;
    rep2(n, 1, 1001){
        if (100 * n <= X && X <= 105 * n){
            flag = true;
            break;
        }
    }
    cout << flag << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int arr[55];
int main(){
	int n; cin >> n;
  	for(int i = 0; i < n; ++i) cin >> arr[i];
  	sort(arr,arr+n);
  	double ans = arr[0];
    for(int i = 1; i < n; ++i){
    	ans = (ans+arr[i])/2;
    }
  	cout << ans << "\n";
  	
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]


H, W = map(int, input().split(" "))
S = []
for _ in range(H):
    S.append(input())

# calc connected componets
con_comp = UnionFind(H * W)
for i in range(H):
    for j in range(W):
        for (dh, dw) in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            if i + dh < 0 or j + dw < 0 or i + dh >= H or j + dw >= W:
                continue
            if S[i][j] != S[i + dh][j + dw]:
                con_comp.union(i * W + j, (i + dh) * W + j + dw)

# enum white
white = {}
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            if con_comp.find(i * W + j) in white:
                white[con_comp.find(i * W + j)] += 1
            else:
                white[con_comp.find(i * W + j)] = 1

# count black
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#' and con_comp.size(i * W + j) > 1:
            ans += white[con_comp.find(i * W + j)]

print(ans)

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

int main(){
    ll n, m; cin >> n >> m;
    vector<ll> h(n); rep(i,n) cin >> h[i];

    vector<vector<int>> g(n);

    rep(i,m){
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ll ans = 0;
    rep(i,n){
        ll tmp = h[i];
        bool jud = true;

        for(auto e: g[i]){
            if(h[e] >= tmp) jud = false;
        }

        if(jud) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 9028
#include <bits/stdc++.h>
#include <unordered_set>
#include <stdio.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI 3.141592653589793
#define vi vector<int>
#define p pair<int,int>
const int MOD = 1000000007;
inline double degcos(double ang) {return cos(ang*PI/180);}
inline double degsin(double ang) {return sin(ang*PI/180);}
#define for(i,j,k,in) for (int i = j; i < k; i += in)


/*---END OF TEMPLATE---*/




int main() {
    //cin.sync_with_stdio(0);
    //cin.tie(0);
    //ifstream fin("data.in");
    //ofstream fout("data.out");
    int l;
    cin >> l;
    double penetration = (double)l/3;
    penetration = penetration*penetration*penetration;
    printf("%.12f",penetration);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



class SCC_BI {
public:
    int NV = 0, time;
    vector<vector<int> > E;
    vector<int> ord, llink, inin;
    stack<int> roots, S;
    vector<int> M; //point to group
    vector<int> ART; // out
    vector<vector<int> > SC; // out
    vector<pair<int, int> > BR; // out

    void init(int NV) { this->NV = NV; E.clear(); E.resize(NV); }
    void add_edge(int x, int y) { assert(NV); E[x].push_back(y); E[y].push_back(x); }
    void dfs(int cur, int pre) {
        int art = 0, conn = 0, i, se = 0;
        ord[cur] = llink[cur] = ++time;
        S.push(cur); inin[cur] = 1; roots.push(cur);
        rep(i, 0, E[cur].size()) {
            int tar = E[cur][i];
            if (ord[tar] == 0) {
                conn++; dfs(tar, cur);
                llink[cur] = min(llink[cur], llink[tar]);
                art += (pre != -1 && ord[cur] <= llink[tar]);
                if (ord[cur]<llink[tar]) BR.push_back(make_pair(min(cur, tar), max(cur, tar)));
            }
            else if (tar != pre || se) {
                llink[cur] = min(llink[cur], ord[tar]);
                while (inin[tar] && ord[roots.top()]>ord[tar]) roots.pop();
            }
            else se++; // double edge
        }

        if (cur == roots.top()) {
            SC.push_back(vector<int>());
            while (1) {
                i = S.top(); S.pop(); inin[i] = 0;
                SC.back().push_back(i);
                M[i] = SC.size() - 1;
                if (i == cur) break;
            }
            sort(SC.back().begin(), SC.back().end());
            roots.pop();
        }
        if (art || (pre == -1 && conn>1)) ART.push_back(cur);
    }
    void scc(int s = 0) {
        SC.clear(), BR.clear(), ART.clear(), M.resize(NV);
        ord.clear(), llink.clear(), inin.clear(), time = 0;
        ord.resize(NV); llink.resize(NV); inin.resize(NV);
        //for (int i = 0; i<NV; i++) if (!ord[i]) dfs(i, -1);
        dfs(s, -1);
        sort(BR.begin(), BR.end()); sort(ART.begin(), ART.end());
    }
};
//-----------------------------------------------------------------------------------
int VV, EE;
SCC_BI g;
//-----------------------------------------------------------------------------------
int main() {
    cin >> VV >> EE;
    
    g.init(VV);
    rep(i, 0, EE) {
        int a, b; scanf("%d %d", &a, &b);
        g.add_edge(a, b);
    }
    g.scc();

    for (int a : g.ART) printf("%d\n", a);
}

Measured memory_bytes: 5332
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n = 0;//長さ　6
    scanf("%d",&n);
    
    char s[n];//文字列
    scanf("%s",s);
    
    char strA[100];
    char strB[100];
    char hikaku[100];
    int result = 0;
    int count = 0;
    
    
    
    for (int i = 0; i < n-1; i++) {
        strA[i] = s[i];
//        printf("%c,",s[i]);
        for (int j = i+1; j < n; j++) {//0  1,2,3,4,5
            strB[j-(i+1)] = s[j];
//            printf("%c",s[j]);
        }
//        printf(" ");
        //1:5,2:4,3:3,4:2,5:1ができてるはず
        
        for(int ii = 0; ii < i+1; ii++){
            for(int jj = 0; jj < n-(i+1); jj++){
//                printf("strB = %c  ",strB[jj]);
                if (strA[ii] == strB[jj]) {
//                    printf("strA = %c,strB = %c",strA[ii],strB[jj]);
                    //同じのをカウントしない
                    if (count == 0) {
                        hikaku[count] = strA[ii];
                        count++;
                        break;
                    }else{
                        int sameFlag = 0;
                        for (int k = 0; k < count; k++) {
                            if (hikaku[k] == strA[ii]) {
                                sameFlag = 1;
                                break;
                            }
                        }
                        if (sameFlag == 1) {
                            break;
                        }else{
                            hikaku[count] = strA[ii];
                            count++;
                            break;
                        }
                    }
                }
            }
        }
        
        
        if(count >= result){
            result = count;
//            printf("%d",result);
        }
//        printf("\n");
        count = 0;
    }
    
    printf("%d",result);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//string alp = "abcdefghijklmnopqrstuvwxyz";
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  
  int i, d = 0, a;
  for(i = 0; i < m; i++){
    cin >> a;
    if(a < x) d++;
  }
  
  cout << min(d, m - d) << endl;
}

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

namespace ProgrammingContest
{
    class MainClass
    {
        Scanner sc;
        static void Main(string[] args)
        {
            new MainClass().Solve();
        }

        void Solve()
        {
#if DEBUG
            string backPath = "..";
            char dirSep = System.IO.Path.DirectorySeparatorChar;
            string inFilePath = backPath + dirSep + backPath + dirSep + "in.txt";
            sc = new Scanner(new System.IO.StreamReader(inFilePath));
#else
            sc = new Scanner();
#endif

            string s = sc.Next;
            string ans = string.Empty;
            for (int i = 0; i < s.Length; i += 2)
            {
                ans += s[i];
            }
            Write(ans);
        }

        void Write(object val)
        {
            Console.WriteLine(val.ToString());
        }
        void Write(string format, params object[] vals)
        {
            Console.WriteLine(format, vals);
        }
        void fill<T>(T[] ar, T val)
        {
            for (int i = 0; i < ar.Length; i++)
            {
                ar[i] = val;
            }
        }
    }
    class Scanner
    {
        Queue<String> buffer;
        char[] sep;
        System.IO.TextReader reader;
        public Scanner(System.IO.TextReader reader = null)
        {
            this.buffer = new Queue<string>();
            this.sep = new char[] { ' ' };
            this.reader = (reader ?? Console.In);
        }
        private void CheckBuffer()
        {
            if (this.buffer.Count == 0 && this.reader.Peek() >= 0)
            {
                string[] sreArray = this.reader.ReadLine().Split(this.sep);
                foreach (String elStr in sreArray)
                {
                    this.buffer.Enqueue(elStr);
                }
            }
        }

        public String Next
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Dequeue();
            }
        }

        public int NextInt
        {
            get
            {
                return int.Parse(this.Next);
            }
        }
        public double NextDouble
        {
            get
            {
                return double.Parse(this.Next);
            }
        }

        public long NextLong
        {
            get
            {
                return long.Parse(this.Next);
            }
        }
        public bool IsEmpty
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Count == 0;
            }
        }
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     

int32_t main()
{
     IOS;
     
     int n;
     cin>>n;
     string a,b,c;
     cin>>a>>b>>c;
     
     int ans=0;
     
     for(int i=0;i<n;i++)
     {
          if(a[i]==b[i] && a[i]==c[i])
               continue;
          if(a[i]==b[i] && a[i]!=c[i])
               ans++;
          else if(a[i]==c[i] && a[i]!=b[i])
               ans++;
          else if(b[i]==c[i] && a[i]!=b[i])
               ans++;
          else
               ans+=2;
     }
     cout<<ans;
     return 0;     
}



Measured memory_bytes: 256