akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:u32,
        m:usize,
        data:[(usize,usize);m]
    }
    let mut start = ((10_isize).pow(n-1));
    if n == 1{
        start = 0;
    }
    for i in start..((10_isize).pow(n)){
        let num:Vec<char> = i.to_string().chars().collect();
        let mut flag = true;
        for j in 0..m{
            let index = data[j].0 - 1;
            if index >= num.len(){
                flag = false;
                break;
            }
            let expect_number = std::char::from_digit(data[j].1 as u32, 10).unwrap();
            if num[index] != expect_number {
                flag = false;
            }
        }
        if flag{
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

signed main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> h(N);
    FOR(i,0,N)cin >> h[i];
    ll DP[N];
    FOR(i,0,N){
        if(i == 0){
            DP[i] = 0;
        }
        else{
            DP[i] = LINF;
            FOR(j,max((ll)0,i-K),i){
               DP[i] = min(DP[i],DP[j]+abs(h[i]-h[j])); 
            }
        }
    }
    cout << DP[N-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

int N;

// N!はnで何回割り切れるか
int numDiv(int n) {
	int result = 0;
	int t = n;
	while(t <= N) {
		result += N / t;
		t *= n;
	}
	return result;
}

bool isPrime(int n) {
	if(n <= 1) {
		return false;
	} else if(n == 2) {
		return true;
	} else if(n % 2 == 0) {
		return false;
	}

	for(int i = 3; i * i <= n; i += 2) {
		if(n % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	cin >> N;

	vector<int> primeList;
	for(int n = 2; n <= N; n++) {
		if(isPrime(n)) {
			primeList.push_back(n);
		}
	}

	int n74 = 0;		// 74以上
	int n24 = 0;		// 24以上
	int n14 = 0;		// 14以上
	int n4 = 0;			// 4以上
	int n2 = 0;			// 2以上
	for(const auto &n : primeList) {
		const auto x = numDiv(n);
		if(x >= 74) {
			n74++;
		}
		if(x >= 24) {
			n24++;
		}
		if(x >= 14) {
			n14++;
		}
		if(x >= 4) {
			n4++;
		}
		if(x >= 2) {
			n2++;
		}
	}

	int result = 0;

	result += (n4 * (n4 - 1) / 2) * (n2 - 2);
	result += n14 * (n4 - 1);
	result += n24 * (n2 - 1);
	result += n74;

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
c = input()
ans_c = "".join(sorted(c))

total = 0
miss_dct = {"R": 0, "W": 0}
for i in range(n):
    if c[i] != ans_c[i]:
        total += 1
        miss_dct[c[i]] += 1

swap = min(miss_dct["R"], miss_dct["W"])
cnt = swap
total -= swap*2
print(cnt+total)

Measured memory_bytes: 11288
#include <cstdio>
#include <cmath>
using namespace std;
int n,d,cnt;
long long x,y;
int K(long long v){
	long long l=0,r=v,mid;
	if(r>=200005)r=2000005;
	while(l<r){
		mid=(l+r)/2;
		if(mid*mid<v){
			l=mid+1;
		}else{
			r=mid;
		}
	}
	return (int)l;
}
bool dis(){
	long long v=x*x+y*y;
	int t=K(v);
	if(t>d)return false;
	else return true;
}
int main(){
	scanf("%d%d",&n,&d);
	while(n--){
		scanf("%lld%lld",&x,&y);
		if(dis())++cnt;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1732
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
T = [[] for _ in range(n)]
for i in range(1, n):
  a = int(input())
  a -= 1
  T[a].append(i)

def dfs(v):
  if not T[v]:
    return 0
  L = [dfs(i)+1 for i in T[v]]
  L.sort()
  for i in range(len(T[v]) - 1):
    L[i+1] = max(L[i]+1, L[i+1])
  return L[-1]

ans = dfs(0)
print(ans)

Measured memory_bytes: 227944
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int n;
int a[100010];


void solve(){
	if(n == 2){
		if(a[0] < a[1]) cout << a[1] << ' ' << a[0] << endl;
		else cout << a[0] << ' ' << a[1] << endl;
		return;
	}
	int x = *max_element(RNG(a, n));
	int y;
	int err = INF;
	rep(i, 0, n){
		if(abs(a[i]-x/2) < err) y = a[i], err = abs(a[i]-x/2);
	}
	cout << x << ' ' << y << endl;
}


signed main(){
	cin >> n;
	rep(i, 0, n) cin >> a[i];

	solve();
	
	return 0;
}

Measured memory_bytes: 640
IMPLICIT NONE
 INTEGER :: N, A, B, C, D
 READ*, N
 A = N / 1000
 B = (N - A*1000) / 100
 C = (N - A*1000 - B*100) / 10
 D = (N - A*1000 - B*100 - C*10)
 
 IF ( A == B ) THEN
     IF ( A == C ) THEN 
     	PRINT*, "Yes"
     ELSE
        PRINT*, "No"
     END IF
 ELSE IF( B == C ) THEN
     IF( B == D ) THEN
        PRINT*, "Yes"
     ELSE
        PRINT*, "No"
     END IF
 ELSE
     PRINT*, "No"
 END IF
END

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  string s ;
  cin >> n >> s ;
  int ans = 0;
  int now = 0;
  
  rep(i,n){
    if(s.at(i) =='I')
      now++;
    else 
      now--;
    
    ans = max(ans,now);
  }
  
  cout << ans ;
  
  


}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

ll MOD = 1e9 + 7;

int main()
{

    int n;
    cin >> n;

    vector<int> a(n), b(n), c(n);

    REP(i, n)
    {
        int t;
        cin >> t;
        t--;
        a[i] = t;
    }

    REP(i, n)
    cin >> b[i];
    REP(i, n - 1)
    cin >> c[i];

    int ans = 0;
    REP(i, n)
    {
        int bo = 0;
        if (a[i] + 1 == a[i + 1])
        {
            bo = c[a[i]];
        }
        ans += b[a[i]] + bo;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
const ll INF=99999999999999999;
ll a,b,c,d,e,f,g,ans=0;
int main(){
    ll n,k,s;
    cin>>n>>k;
    vl x(n+2,0);
    x[1]=1;
    s=1;
    x[s-1]=-1;
    x[s+1]=-1;
    rep(i,k){
        cin>>a>>b;
        swap(x[a],x[b]);
        if(a==s)s=b;
        else if(b==s)s=a;
        x[s-1]=-1;
        x[s+1]=-1;
    }

    for(int i=1;i<n+1;i++){
        if(x[i]!=0)ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;
  cin>>N>>M;
  vector<ll> a(M),b(M),c(M),dist(N,INFLL);
  REP(i,M){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;c[i]=-c[i];
  }

  dist[0]=0;

  REP(loop,N-1){
    REP(i,M){
      if(dist[a[i]]!=INFLL){
        dist[b[i]] = min(dist[b[i]],dist[a[i]]+c[i]);
      }
    }
  }

  ll ans=-dist[N-1];

  vector<bool> negative(N,false);

  REP(loop,N){
    REP(i,M){
      if(dist[a[i]]==INFLL)continue;
      if(dist[b[i]]>dist[a[i]]+c[i]){
        dist[b[i]]=dist[a[i]]+c[i];
        negative[b[i]]=true;
      }

      if(negative[a[i]]){
        negative[b[i]]=true;
      }
    }
  }

  if(negative[N-1]){
    cout<<"inf"<<endl;
  }else{
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 384
#include<cstdio>
int abs(int x) {return x>0?x:-x;}
int main()
{
	int n,mx,px,mn,pn;scanf("%d",&n);
	scanf("%d",&mx);mn=mx;px=pn=1;
	for(int i=1;i<n;i++)
	{
		int x;scanf("%d",&x);
		if(x>mx) mx=x,px=i+1;
		if(x<mn) mn=x,pn=i+1;
	}
	printf("%d\n",2*n-1);
	if(abs(mx)<abs(mn))
	{
		for(int i=1;i<=n;i++) printf("%d %d\n",pn,i);
		for(int i=n;i>1;i--) printf("%d %d\n",i,i-1);
	}
	else
	{
		for(int i=1;i<=n;i++) printf("%d %d\n",px,i);
		for(int i=1;i<n;i++) printf("%d %d\n",i,i+1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int h,w; cin>>h>>w;
    char c[h][w]; rep(i,h)rep(j,w) cin>>c[i][j];
    int hh[h]={},ww[w]={};
    rep(i,h)rep(j,w){
        if(c[i][j]=='#') hh[i]=1;
    }
    rep(i,w)rep(j,h){
        if(c[j][i]=='#') ww[i]=1;
    }
    rep(i,h){
        bool flg=0;
        rep(j,w){
            if(!hh[i]||!ww[j]) continue;
            cout<<c[i][j];
            flg=1;
        }
        if(flg) cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::cmp::{max, min};
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w:i64 = read();
    let a:i64 = read();
    let b:i64 = read();
    println!("{}", max(0, max(a,b) - (min(a,b) + w)));
}

Measured memory_bytes: 2040
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}


int a[101];

int main(){
    cin.tie(0);
    int N; cin >> N;
    string S; cin >> S;
    int cnt = 0;
    for (int i = 0; i < N; i++){
        if (S[i] == 'R') cnt++;
    }
    if (cnt > N-cnt){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem161b(n, m, a))
}

fun problem161b(n: Int, m: Int, a: List<Int>): String {
    val a = a.sorted()
    val x = a.sum() / (4.0 * m)
    val take = a.takeLast(m)
    for (i in 0 until take.size) {
        if (take[i] < x) return "No"
    }
    return "Yes"
}

Measured memory_bytes: 35916
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FL "a"
using namespace std;
typedef long long ll;
typedef long double dd;
const int N=2e5+10;
const int inf=2147483647;
const dd pi=acos(-1);
const ll INF=1ll<<60;
const int mod=998244353;
inline ll read(){
  ll data=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

int n,t[N];ll suft[N],dp[N][3][3],ans;
inline void upd(ll &a,ll b){a=a<b?a:b;}
inline int calc(int x,int r){
  if(r==0)return x;
  if(r==1)return x&1?0:1;
  if(r==2){if(!x)return 2;else return x&1?1:0;}
}
int main()
{
  n=read();for(int i=1;i<=n;i++)t[i]=read();
  for(int i=n;i;i--)suft[i]=suft[i+1]+t[i];ans=suft[1];
  memset(dp,63,sizeof(dp));dp[0][0][0]=0;
  for(int i=0;i<=n;i++)
    for(int a=0;a<3;a++)
      for(int b=0;b<3;b++){
	//printf("dp[%d][%d][%d]=%lld\n",i,a,b,dp[i][a][b]);
	if(a==0){
	  upd(dp[i+1][a][b],dp[i][a][b]+t[i+1]);
	  if(b!=2)upd(dp[i+1][a+1][b+1],dp[i][a][b]+calc(t[i+1],1));
	  upd(dp[i+1][a+2][b],dp[i][a][b]+calc(t[i+1],2));
	}
	if(a==1){
	  if(b!=2)upd(ans,dp[i][a][b]+suft[i+1]);
	  upd(dp[i+1][a][b],dp[i][a][b]+calc(t[i+1],1));
	  if(b!=2)upd(dp[i+1][a+1][b+1],dp[i][a][b]+calc(t[i+1],2));
	}
	if(a==2){
	  upd(ans,dp[i][a][b]+suft[i+1]);
	  if(b!=2)upd(dp[i+1][a-1][b+1],dp[i][a][b]+calc(t[i+1],1));
	  upd(dp[i+1][a][b],dp[i][a][b]+calc(t[i+1],2));
	}
      }
  printf("%lld\n",ans);
  return 0;
}


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

struct Tower {
  int h;
  vector<int> r;
};
int main() {
  int n, m;
  cin >> n >> m;
  Tower T[n + 1];
  for (int i = 1; i < n + 1; i++) {
    cin >> T[i].h;
  }

  for (int i = 1; i < m + 1; i++) {
    int a, b;
    cin >> a >> b;
    T[a].r.push_back(b);
    T[b].r.push_back(a);
  }
  int ans = 0;
  for (int i = 1; i < n + 1; i++) {
    bool f = true;
    for (int j = 0; j < T[i].r.size(); j++) {
      if (T[i].h <= T[T[i].r[j]].h) {
        f = false;
        continue;
      }
    }
    if (f) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9488
#include<bits/stdc++.h>
using namespace std;
int main()

{
    int a;
    double sum=0;
    cin>>a;
    for(int i=1; i<=a; i++)
    {
        if(i%2==1)
        {
            sum++;
        }
        else
        {
            sum = sum + 0;
        }
    }
    cout<<fixed<<setprecision(10)<<sum/a;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int a[4];
signed main(){
	int N;
	cin>>N;
	while(N--){
		string s;cin>>s;
		if(s=="AC")a[0]++;
		else if(s=="WA")a[1]++;
		else if(s=="TLE")a[2]++;
		else a[3]++;
	}
	cout<<"AC x "<<a[0]<<endl;
	cout<<"WA x "<<a[1]<<endl;
	cout<<"TLE x "<<a[2]<<endl;
	cout<<"RE x "<<a[3]<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<vector<char> > s(H, vector<char>(W));

  rep(i, H) {
    rep(j, W) {
      cin >> s[i][j];
    }
  }

  vector<vector<int> > z(H);
  queue<int> q;
  rep(i, H) {
    bool isExist = false;
    rep(j, W) {
     if (s[i][j] == '#') {
       isExist = true;
       break;
     }
    }

    if (isExist) {
      z[i].push_back(i);
      while(!q.empty()) {
        int k = q.front(); q.pop();
        z[i].push_back(k);
      }
    } else {
      q.push(i);
      z[i].push_back(-1);
    }
  }

  if (!q.empty()) {
    for (int i = H-1; H >= 0; i--) {
      if (z[i][0] != -1) {
        while(!q.empty()) {
          int k = q.front(); q.pop();
          z[i].push_back(k);
        }
        break;
      }
    }
  }
      

  vector<vector<int> > ans(H, vector<int>(W));
  int cnt = 1;
  rep(i, H) {
    if (z[i][0] == -1) continue;
    int L = 0;
    rep(j, W) {
      if (s[i][j] == '#') {
        rep(k, z[i].size()) {
          int idx = z[i][k];
          for (int a = L; a <= j; a++) ans[idx][a] = cnt;
        }
        cnt++;
        L = j + 1;
      }
    }

    rep(k, z[i].size()) {
      int idx = z[i][k];
      for (int a = L; a < W; a++) ans[idx][a] = cnt - 1;
    }
  }


  rep(i, H) {
    rep(j, W-1) {
      cout << ans[i][j] << " ";
    }
    cout << ans[i][W-1] << endl;
  }

    


  return 0;
}


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

namespace CP
{
    class Atria
    {
        //訪問済みかどうかを保存する配列
        static bool[] vs;
        static long ans;
        static bool[,] graph;
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int m = s[1];
            //無向グラフを隣接行列を用いて受け取る
            graph = new bool[n, n];
            for (int i = 0; i < m; i++)
            {
                int[] scan = ReadLine().Split(' ').Select(x => int.Parse(x)-1).ToArray();
                graph[scan[0], scan[1]] = true;
                graph[scan[1], scan[0]] = true;
            }
            //訪問済みかどうかを保存する配列
            vs = new bool[n];
            vs[0] = true;
            ans = 0;
            DFS(0);
            WriteLine(ans);
        }

        static void DFS(int v)
        {
            if (vs.Count(x => x == true) == vs.Count())
            {
                ans++;
                return;
            }

            for (int i = 0; i < vs.Count(); i++)
            {
                if (graph[v,i]&&vs[i] == false)
                {
                    vs[i] = true;
                    DFS(i);
                    vs[i] = false;
                }
            }

            return;
        }
    }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, w; cin >> n >> w;
  vector<int> c(n), v(n);
  REP(i, n) cin >> c[i] >> v[i];
  ll v_max = 100000;
  vector<vector<ll>> dp(n, vector<ll>(v_max+1, LINF));
  for(int i=0;i<n;++i) {
    dp[i][0] = 0;
  }
  dp[0][v[0]] = c[0];

  for(int i=1;i<n;++i) {
    for(int j=0;j<v_max+1;++j) {
      dp[i][j] = dp[i-1][j];
      if(j - v[i] >= 0 && dp[i-1][j-v[i]] != LINF) {
        ll tmp = dp[i-1][j-v[i]] + c[i];
        if(tmp <= w) dp[i][j] = min(dp[i][j], tmp);
      }
    }
  }
  for(int j=v_max;j>=0;--j) {
    if(dp[n-1][j] != LINF) {
      cout << j << endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 79488
package main

import (
	"fmt"
)

func main() {
	var str string
	fmt.Scanf("%s", &str)
	sum := 0

	for _, c := range str {
		sum += int(c - '0')
	}

	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

int main()
{
	int n, m;
	cin >> n >> m;
	auto e = vector<vector<int>>(n + 1);
	for(auto i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	auto solve = [&e](auto solve, int p, vector<bool> chk, int rem) -> int {
		if(rem == 0){
			return 1;
		}
		int ret = 0;
		for(auto next : e[p]){
			if(chk[next]) continue;
			chk[next] = true;
			ret += solve(solve, next, chk, rem - 1);
			chk[next] = false;
		}
		return ret;
	};
	auto c = vector<bool>(n + 1);
	c[1] = true;
	
	cout << solve(solve, 1, c, n - 1) << endl;
	return 0;
}

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

#define INF (int)(1e9)
#define MOD (int)((int)1e9+7)
#define MAX 110000

pair<long double ,pair<int,int> > vw[MAX];
int main(){
  cout<<fixed<<setprecision(7);
  int N, W;

  cin>>N>>W;
  
  for(int i = 0; i < N; i++){
    cin>>vw[i].second.first>>vw[i].second.second;
    vw[i].first = (long double)vw[i].second.first/vw[i].second.second;
  }

  sort(vw, vw+N);
  long double temp = 0, ans = 0;
  for(int i = N-1; i >= 0; i--){//cout<<temp<<" "<< vw[i].first <<endl;
    if(fabs(W-ans) <= 1e-7) break;
    //  cout<<W-ans<<" "<<vw[i].second.second<<endl;
    if(W-temp <= vw[i].second.second){
      ans += (long double)vw[i].second.first*((long double)(W-temp)/vw[i].second.second);
      break;
    } else {
      ans += vw[i].second.first;
      temp += vw[i].second.second;
    }
  }

  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 6268
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
vi hoge;
ll L,R;
int main(){
	cin>>L>>R;
	if(R-L>=2019){
		cout<<0<<endl;
	}else{
		ll ans=2019;
		for(ll i=L;i<=R;i++){
			for(ll j=i+1;j<=R;j++){
				ans=min(ans,(i*j)%2019);
			}
		}
		cout<<ans<<endl;
	}
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	int a[n], b[n];
	ll aSum = 0, bSum = 0;
	FOR(i,0,n){
		cin >> a[i];
		aSum += a[i];
	}
	FOR(i,0,n){
		cin >> b[i];
		bSum += b[i];
	}
	ll cnt1 = 0, cnt2 = 0;
	FOR(i,0,n){
		if(a[i] > b[i]){
			cnt1 += a[i] - b[i];
		}
		if(a[i] < b[i]){
			cnt2 += (b[i] - a[i] + 1) / 2;
		}
	}
	Yes(max(cnt1, cnt2) <= bSum - aSum);
	return 0;
}


Measured memory_bytes: 384
N = int(input())
s = input()
t = input()

c = -1
# i文字一致している
for i in range(N):
    sp = s[i:]
    tp = t[:N-i]
    # print(sp, tp)
    if sp == tp:
        c = i
        break

if c == -1:
    print(2*N)
else:
    match = N - c
    ans = 2 * N - match
    # print(':', match)
    print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>21)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}
 

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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
int dy[]={0, 1, 0, -1};
int dx[]={1, 0, -1, 0};

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    string s = "CODEFESTIVAL2016";
    string ss; cin >> ss;
    int cnt = 0;
    rep(i,s.size()){
        if(s[i] != ss[i]) cnt++;
    }
    cout << cnt << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    res = []
    for i in s:
        if i == "0":
            res.append("0")
        elif i == "1":
            res.append("1")
        else:
            if len(res) > 0:
                res.pop()

    print("".join(res))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Comparator;;

class Point{
    int x; int y;
    public Point(int x, int y){
        this.x = x;
        this.y = y;
    }
}

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        ArrayList<Point> array = new ArrayList<>();
        int x,y;
        for(int i=0;i<n;i++){
            x = Integer.parseInt(sc.next());
            y = Integer.parseInt(sc.next());
            array.add(new Point(x,y));
        }
        sc.close();
        Collections.sort(array, new Comparator<Point>() {
            @Override
            public int compare(Point a, Point b){
                if(a.x==b.x){
                    return a.y - b.y;
                }else{
                    return a.x - b.x;
                }
            }
        });
        ArrayList<Point> diffs = new ArrayList<>();
        int len = 0;
        for(int i=0;i<n;i++){
            int ix = array.get(i).x;
            int iy = array.get(i).y;
            for(int j=i+1;j<n;j++){
                int jx = array.get(j).x;
                int jy = array.get(j).y;
                diffs.add(new Point(jx-ix, jy-iy));
                len++;
            }
        }
        Collections.sort(diffs, new Comparator<Point>() {
            @Override
            public int compare(Point a, Point b){
                if(a.x==b.x){
                    return a.y - b.y;
                }else{
                    return a.x - b.x;
                }
            }
        });
        int count = 1;
        int max = 1;
        for(int i=1;i<len;i++){
            Point pa = diffs.get(i);
            Point pb = diffs.get(i-1);
            if(pa.x==pb.x && pa.y==pb.y){
                count++;
            }else{
                if(max < count){
                    max = count;
                }
                count = 1;
            }
        }
      	if(n==1){
          System.out.println(1);
        }else{
          System.out.println(n - max);
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_N = 2e5;
ll fac[MAX_N+1], ifac[MAX_N+1], inv[MAX_N+1];

//mpow(x,n)で(x^n)をO(log(n))で計算
ll mpow(ll x, ll n){
    ll res = 1, now = x;
    while(n > 0){
        if(n & 1) res *= now, res %= MOD;
        now *= now, now %= MOD;
        n >>= 1;
    }
    return res;
}

//setcomb()でfac,ifac,invを全て計算
void setcomb(){
    rep2(i, 1, MAX_N){
        inv[i] = mpow(i, MOD-2);
    }
    //i!とi!の逆元
    fac[0] = 1, ifac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = (fac[i-1]*i) % MOD;
        ifac[i] = (ifac[i-1]*inv[i]) % MOD;
    }
}

//comb(n, k)でnCk
ll comb(int n, int k){
    ll c = fac[n];
    c *= ifac[n-k], c %= MOD;
    c *= ifac[k], c %= MOD;
    return c;
}

//perm(n, k)でnPk
ll perm(int n, int k){
    return(fac[n]*ifac[n-k])%MOD;
}

int main(){
    setcomb();
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    ll a = A*inv[A+B]%MOD, b = B*inv[A+B]%MOD, c = C*inv[A+B]%MOD;
    //cout << a << ' ' << b << ' ' << c << endl;
    ll ans = 0;
    //AがN勝、Bがi勝である場合
    rep(i, N){
        ll p = comb(N-1+i, i);
        p *= mpow(a, N), p %= MOD;
        p *= mpow(b, i), p %= MOD;
        ll cnt = (N+i)*(c+1)%MOD;
        ans += p*cnt;
        ans %= MOD;
    }
    //Aがi勝、BがN勝である場合
    rep(i, N){
        ll p = comb(N-1+i, i);
        p *= mpow(b, N), p %= MOD;
        p *= mpow(a, i), p %= MOD;
        ll cnt = (N+i)*(c+1)%MOD;
        ans += p*cnt;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(100100);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    rep(i, 100100) {
        if (cnt[i] % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

#define INF 1000050000

double dp[3002][3002];

int main()
{
	int n;
	scanf("%d", &n);
	double prob[n+1];
	for(int i = 0; i < n; i++) {
		scanf("%lf", &prob[i]);
	}
	dp[1][1] = prob[0];
	dp[1][0] = 1-prob[0];
	for(int i = 2; i <= n; i++) {
		for(int j = 0; j <= i; j++) {
			dp[i][j] += dp[i-1][j] * (1-prob[i-1]);
			if(j == 0) continue;
			dp[i][j] += dp[i-1][j-1]*prob[i-1];
		}
	}
	double ans = 0;
	for(int i = n; i > n/2; i--) ans += dp[n][i];
	printf("%.10lf\n", ans);
}


Measured memory_bytes: 68992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,sz[105],cnt[105][26],ans[26];
int nxt[200005],a[200005];
char s[200005];
void query(ll now,ll c)
{
	//printf("query(%lld,%lld)\n",now,c);
	if(now<=n)
	{
		for(int i=1;i<=now;i++) ans[a[i]]+=c;
		return;
	}
	int i=1;
	while(sz[i]<=now&&sz[i]>0) i++;
	for(int j=0;j<26;j++) ans[j]+=cnt[i-1][j]*c;
	query(now-sz[i-1],c);
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'a';
	n/=2;
	for(int i=2,j=0;i<=n;i++)
	{
		while(j&&a[j+1]!=a[i]) j=nxt[j];
		if(a[i]==a[j+1]) j++;
		nxt[i]=j;
		//printf("nxt[%d]=%d\n",i,j);
	}
	sz[0]=n,sz[1]=n+n-nxt[n];
	//printf("%lld %lld\n",sz[0],sz[1]);
	for(int i=1;i<=n;i++) cnt[0][a[i]]++,cnt[1][a[i]]++;
	for(int i=1;i<=n-nxt[n];i++) cnt[1][a[i]]++;
	for(int i=2;i<=100;i++)
	{
		sz[i]=sz[i-1]+sz[i-2];
		//printf("sz[%d]=%lld\n",i,sz[i]);
		for(int j=0;j<26;j++) cnt[i][j]=cnt[i-1][j]+cnt[i-2][j];
	}
	ll l,r;
	scanf("%lld%lld",&l,&r);
	query(r,1);
	query(l-1,-1);
	for(int i=0;i<26;i++) printf("%lld ",ans[i]);
	return 0; 
}

Measured memory_bytes: 1664
""" My template """
# x0,y0,ax,ay,bx,by = list(map(int,input().split()))
# xs,ys,t = list(map(int,input().split()))
# V = []
# for i in range(61):
#     V.append([x0,y0])
#     x0=ax*x0+bx;y0=ay*y0+by;
# A=0
# for i in range(61):
#     for j in range(i,61):
#         ans=min(abs(xs-V[i][0])+abs(ys-V[i][1]),abs(xs-V[j][0])+abs(ys-V[j][1]))
#         for k in range(i,j):
#             ans=ans+abs(V[k+1][0]-V[k][0])+abs(V[k+1][1]-V[k][1])
#         if ans<=t:
#             A=max(A,j-i+1);
# print(A)

# def f(s):
#     s = str(s)
#     ans = 0
#     for i in s:
#         ans += int(i)
#     return ans

# s = input()
# x = int(s)
# ans = f(x)
# n = len(s)

# for i in s:
#     t = int(i)

# TC = int(input())
# for _ in range(TC):
#     n, m = list(map(int, input().split()))
#     print(2**(n*m)*(3**(n+m)))

l = int(input())
x = l/3
print(x**3)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;



int main(int argc, const char * argv[]) {
    
    int N, X, m;
    
    cin >> N >> X;
    
    int minPiece = 10000;
    for(int i=0; i<N; ++i){
        cin >> m;
        X -= m;
        if(minPiece > m) minPiece = m;
    }
    
    int count = N + X/minPiece;
    
    cout << count;
    
    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

int main()
{
	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);

	if( a < b ){
		if( b < c ) printf("Yes\n");
		else printf("No\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    ll ans = 0;
    ll RL = 0;
    ll LR = 0;
    REP(i, S.size()-1){
        if (S[i] == S[i+1]) {
            ans += 1;
        } else if (S[i] == 'R' && S[i+1] == 'L') {
            RL += 1;
        } else if (S[i] == 'L' && S[i+1] == 'R') {
            LR += 1;
        }
    }
    ll N2 = min(K, min(RL, LR));
    ans += 2 * N2;
    ans += 1 * min(K-N2, max(RL-N2, LR-N2));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
  int n,m;
  cin >> n >> m;
  VI x(m);
  rep(i,m) cin >> x[i];
  
  if(n >= m){
    cout << 0;
    return 0;
  }
  
  sort(x.begin(), x.end());
  
  int ans = x[m-1] - x[0];
  
  VI d(m-1);
  rep(i,m-1){
    d[i] = x[i+1] - x[i];
  }
  
  sort(d.begin(), d.end(), greater<int>());
  
  rep(i,n-1){
    ans -= d[i];
  }
  
  cout << ans;
  
  return 0;
}

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

using namespace std;

typedef long long int lli;

int n,t,sol;
vector<int> all(3);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    for(int i=0;i<3;i++)cin>>all[i];
    sort(all.begin(),all.end());
    for(int i=1;i<3;i++)sol+=all[i]-all[i-1];
    cout<<sol;
    return 0;
}


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

 using namespace std;
 int main() {
   int A, B;
   cin >> A >> B;
   if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
   else cout << "Impossible" << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int a, b;
	cin >> a >> b;
	int s = 1;
	for(int i = 0; i < 100; i++){
		if(s >= b){
			cout << i;
			return 0;
		}
		else{
			s--;
			s += a;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=2e3+20;
const int mod=1e9+7;

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

struct Edge {
	int u,v,w;
};
Edge E[maxn];
int n,m,vis[maxn];
ll X,min_cost;

int fa[maxn],sz[maxn],ffw[maxn];

int fin(int x){ return x==fa[x]?x:fa[x]=fin(fa[x]);}

int ff[maxn],deep[maxn];

inline void Find_deep(int x)
{
	if(deep[x])return;
	if(x!=ff[x])Find_deep(ff[x]);
	deep[x]=deep[ff[x]]+1;
}

inline void init()
{
	n=read();m=read(); scanf("%lld",&X);
	REP(i,1,m)
	{
		int u=read(),v=read(),w=read();
		E[i]=(Edge){u,v,w};
	}
	sort(E+1,E+m+1,[](Edge a,Edge b){ return a.w<b.w;});
	REP(i,1,n)ff[i]=fa[i]=i,sz[i]=1;
	REP(i,1,m)
	{
		int x=E[i].u,y=E[i].v,w=E[i].w;
		x=fin(x); y=fin(y);
		if(x==y)continue;
		vis[i]=1;
		min_cost+=w;
		if(sz[x]<sz[y])swap(x,y);
		fa[y]=x; ff[y]=x; ffw[y]=w;
		sz[x]+=sz[y];
	}
	REP(i,1,n)Find_deep(i);
}

inline int Edge(int u,int v)
{
	int ans=0;
	while(u!=v)
	{
		if(deep[u]>deep[v])swap(u,v);
		chkmax(ans,ffw[v]);
		v=ff[v];
	}
	return ans;
}

inline void doing()
{
	if(X<min_cost)puts("0");
	else if(X==min_cost)
	{
		int num=0;
		REP(i,1,m)if(!vis[i])
		{
			int u=E[i].u,v=E[i].v,w=E[i].w;
			if(Edge(u,v)==w)num++;
		}else num++;
		int ans=(power(2,m)-(ll)power(2,m-num)*2+mod*2)%mod;
		printf("%d\n",ans);
	}else
	{
		int num=0,num1=0;
		REP(i,1,m)if(!vis[i])
		{
			int u=E[i].u,v=E[i].v,w=E[i].w;
			ll W=min_cost-Edge(u,v)+w;
			if(W<X)num++;
			else if(W==X)num1++;
		}else num++;
		int ans=(ll)2*(power(2,m-num)-power(2,m-num-num1)+mod)%mod;
		printf("%d\n",ans);
	}
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long start, end;
    cin >> start >> end;

    int no_of_terms = 1;
    long long a = start;

    while(2*a <= end)
    {
        a = a << 1;
        no_of_terms++;
    }

    cout << no_of_terms;
    return 0;
}


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

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

	int A , B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B > C + D) {
		cout << "Left";
		return 0;
	}
	if (A + B < C + D) {
		cout << "Right";
		return 0;
	}
	if (A + B == C + D) {
		cout << "Balanced";
		return 0;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int maxWeight, number;
    int C = 0;
    while(cin >> maxWeight >> number && maxWeight){
        int dp[1001] = {};
        rep(i,number){
            int a,b;
            char c;
            cin >> a >> c >> b;
            for(int j = maxWeight; j >= b; j--){
                dp[j] = max(dp[j], dp[j - b] + a);
                /*持てる重さの最大値から、入力された重さまでのループ
                 *入力した宝を持つべきか判断。
                 *持つ場合、持てる重さから宝の重さを引いて、
                 *　その添字の部分に宝の価値を入力する。
                 *　それがdp[j]にはいる。
                 *それを何度も繰り返す。
                 */
            }
        }
        int x = 0, y = 0;
        for(int i = 0; i <= maxWeight; i++){
            if(x < dp[i]){
                x = dp[i];
                y = i;
            }
        }
        cout << "Case " << ++C << ":\n" << x << "\n" << y << "\n";
    }
}

Measured memory_bytes: 1164
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> k;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  rep(i, k) ans += a[i];
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3628