akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    static int[] par;
    static int[] rank;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        par = new int[n];
        rank = new int[n];
        int[] p = new int[n];
        List<Integer>[] h = new ArrayList[n];
        for(int i=0; i<n; i++){
            p[i] = Integer.parseInt(sc.next());
            par[i] = i;
            h[i] = new ArrayList<>();
        }
        
        for(int i=0; i<m; i++){
            int x = Integer.parseInt(sc.next())-1;
            int y = Integer.parseInt(sc.next())-1;
            unite(x, y);
        }
        
        for(int i=0; i<n; i++){
            int tmp = find(i);
            h[tmp].add(i);
        }
        
        int ans = 0;
        for(int i=0; i<n; i++){
            if(same(i, p[i]-1)){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
    
    public static int find(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = find(par[x]);
            return par[x];
        }
    }
    
    public static void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return;
        
        if(rank[x]<rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }
    
    public static boolean same(int x, int y){
        return find(x)==find(y);
    }
}


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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;

    
    cout << c << " " << a << " " << b << " " << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

ll LCM(ll a, ll b){
    return a/GCD(a,b) * b;
}

int main(){
    int N; cin >> N;
    vector<ll> T(N);
    rep(i,N) cin >> T[i];
    ll ans = 1;
    rep(i,N) ans = LCM(ans,T[i]);
    cout << ans << endl;
}
    



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

int N, M, indeg[100005], prt[100005], dth[100005];
vector<int> edge[100005];
void dfs(int x, int p){
	--indeg[x];
	if(dth[x]<dth[p]+1){
		dth[x] = dth[p]+1;
		prt[x] = p;
	}
	if(indeg[x]) return;
	for(auto &i: edge[x]){
		dfs(i, x);
	}
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1; i<N+M; ++i){
		int x, y; scanf("%d%d",&x,&y);
		edge[x].push_back(y);
		++indeg[y];
	}
	int root = 0;
	for(int i=1; i<=N; ++i) if(indeg[i]==0) root = i;
	indeg[root] = 1;
	dfs(root, 0);
	for(int i=1; i<=N; ++i) printf("%d\n",prt[i]);
}

Measured memory_bytes: 10624
N = int(input())
ans = 0
A = range(1, N)
for a in A:
    b = N - a
    a_ = list(str(a))
    sum_a = sum(int(i) for i in a_)

    b_ = list(str(b))
    sum_b = sum(int(i) for i in b_)

    if a == 1:
        ans = sum_a + sum_b
    elif ans > sum_a + sum_b:
        ans = sum_a + sum_b
print(ans)

Measured memory_bytes: 3064
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

visited=[False]*(10**5)
ans=[-1]*(10**5)

def f(n,edges,s):
  all_visited=True
  for i in range(n):
    if visited[i]==False:
      all_visited=False
      break
  if all_visited:
    return

  for x,c in edges[s]:
    if visited[x]:
      continue
    if ans[s]==0:
      if c%2==1:
        ans[x]=1
      else:
        ans[x]=0
    else:
      if c%2==1:
        ans[x]=0
      else:
        ans[x]=1
    visited[x]=True
    f(n,edges,x)

def main():
  n=I()

  edges=[[] for _ in range(n)]
  for _ in range(n-1):
    a,b,c=LI()
    a-=1
    b-=1
    edges[a].append([b,c])
    edges[b].append([a,c])

  ans[0]=0
  visited[0]=True

  f(n,edges,0)

  for x in ans[:n]:
    print(x)

main()
# print(main())


Measured memory_bytes: 88008
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}


/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   set<int> s;
   int n;
   while(cin>>n)
    s.insert(n);
  cout<<sz(s)<<endl;

}


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll n,i,tmp,ans;
    cin>>n;
    ans=n;
    for(i=1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            tmp=n/i+i-2;
            ans=min(ans,tmp);

        }
    }
    cout<<ans<<endl;


    return 0;
}





Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m;
char a[1055][1055];
ll dp[1099][1099];


int main(){
	ll mod=1000000007;
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			cin >> a[i][j];
		}
	}
	for (int i=1; i<=n; i++){
		for (int j=1; j<=m; j++){
			if(i==1 && j==1)dp[i][j]=1;
			else{
				if(a[i][j]=='.')dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
			}
		}
	}
	cout << dp[n][m]%mod << endl;
}

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

int main(void)
{
    int n, m, l=1, r;
    cin >> n >> m;
  	r = n;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }
    cout << max(0, r-l+1) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n;
	vector<ll> v(3);
	cin >> n >> v[0] >> v[1] >> v[2];
	vector<string> str(n+1);
	REP(i, n)cin >> str[i];
	str[n] = "ABC";

	map<char, ll> mp;
	mp['A'] = 0, mp['B'] = 1, mp['C'] = 2;
	vector<char> ans;
	REP(i, n){
		ll a = mp[str[i][0]], b = mp[str[i][1]];
		ll na = mp[str[i+1][0]], nb = mp[str[i+1][1]];
		bool flag = true;
		v[a]++;v[b]--;
		if(v[a] < 0 || v[b] < 0)flag = false;
		if(i != n-1 && v[na] <= 0 && v[nb] <= 0)flag = false;
		if(flag){
			ans.EB(str[i][0]);
			continue;
		}
		v[a]--;v[b]++;

		flag = true;
		v[a]--;v[b]++;
		if(v[a] < 0 || v[b] < 0)flag = false;
		if(i != n-1 && v[na] <= 0 && v[nb] <= 0)flag = false;
		if(flag){
			ans.EB(str[i][1]);
			continue;
		}

		cout << "No" << "\n";
		return 0;
	}

	cout << "Yes" << "\n";
	REP(i, n)cout << ans[i] << "\n";

	return 0;
}


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

int main() 
{
	int a,b,i,xx=1;
	cin>>a>>b;
	for(i=1;i<=30;i++)
	{
		xx*=b;
		if(a<xx)break;
	}
	cout<<i;
	return 0;
}

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

using ll = long long;

vector<ll> calc_devisors(ll a)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= a; i++)
    {
        if (a % i != 0)
            continue;
        ret.push_back(i);
        ll another = a / i;
        if (i != another)
            ret.push_back(another);
    }
    sort(ret.begin(), ret.end()); // 使いやすいように大きい順にソートしておく
    return ret;
}

void solve(long long X)
{
    vector<ll> divx = calc_devisors(X);

    for (int i = 0; i < divx.size(); i++)
    {
        // cout << divx[i] << endl;

        for (long long b = -1000; b < 1000; b++)
        {
            long long test = 0;
            test += (divx[i] + b) * (divx[i] + b) * (divx[i] + b) * (divx[i] + b);
            test += (divx[i] + b) * (divx[i] + b) * (divx[i] + b) * b;
            test += (divx[i] + b) * (divx[i] + b) * b * b;
            test += (divx[i] + b) * b * b * b;
            test += b * b * b * b;

            if (X / divx[i] == test)
            {
                cout << divx[i] + b << " " << b << endl;
                return;
            }
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3688
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(i, a, b) for(ll i = a; i <= b; i++)
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define rrep(i, b, a) for(ll i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
ll h[100005], f[100005];

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    mem(f, MOD)
    quickio
    ll n;
    cin >> n;
    repp(i, 1, n) cin >> h[i];
    f[1] = 0, f[2] = abs(h[1] - h[2]);
    repp(i, 3, n) f[i] = min(f[i - 2] + abs(h[i] - h[i - 2]), f[i - 1] + abs(h[i] - h[i - 1]));
    cout << f[n];
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 1792
n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))

Measured memory_bytes: 52908
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
N = int(input())
count = 0
for i in range(1, N + 1, 2):
    if len(make_divisors(i)) == 8:
        count+=1

print(count)

Measured memory_bytes: 3060
using System;

class Program {
    static void Main( string[] args )
    {
        while ( true ) {
            string[] line = Console.ReadLine().Split();

            int m = int.Parse( line[ 0 ] );
            int f = int.Parse( line[ 1 ] );
            int r = int.Parse( line[ 2 ] );

            int n = m + f;

            if ( -3 == n + r ) {
                break;
            }

            if ( -1 == m || -1 == f ) {
                Console.WriteLine( 'F' );

            } else if ( n >= 80 ) {
                Console.WriteLine( 'A' );

            } else if ( n >= 65 ) {
                Console.WriteLine( 'B' );

            } else if ( n >= 50 ) {
                Console.WriteLine( 'C' );

            } else if ( n >= 30 ) {
                if ( r < 50 ) {
                    Console.WriteLine( 'D' );

                } else {
                    Console.WriteLine( 'C' );
                }

            } else {
                Console.WriteLine( 'F' );
            }
        }
    }
}

Measured memory_bytes: 8648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  if (N <=9 && M <=9) {
    cout << N*M << endl;
  }
  else {
    cout << -1 << endl;
  }
  
 
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

l = []
for i in range(a, min(a + k, b + 1)):
    if i not in l:
        l.append(i)
for i in range(max(a, b - k + 1), b + 1):
    if i not in l:
        l.append(i)

ans = '\n'.join(map(str, l))
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;

int main(int argc, char* argv[]){
	long long D,T,S;
	scanf("%lld %lld %lld", &D,&T,&S);
	if(D <= T*S){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

}


Measured memory_bytes: 3716
N, K = map(int, input().split())
*h, = map(int, input().split())
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
	for j in range(1, min(K + 1, N - i)):
		dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N - 1])


Measured memory_bytes: 60000
def resolve():
    N = int(input())
    A = [int(input()) for _ in range(N)] + [0]

    ans = 0
    for i in range(N):
        ans += A[i] // 2
        A[i] %= 2
        if A[i] > 0 and A[i + 1] > 0:
            ans += 1
            A[i] -= 1
            A[i + 1] -= 1

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 13776
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
D = sorted(iil())

print(D[n//2] - D[n//2-1])

Measured memory_bytes: 14428
#include <stdio.h>
int main(){
    char x[1];
    long long count = 0;
    scanf("%c",&x[0]);
    while( x[0] != 10 && x[0] != ' ' ){
        count += x[0]- 48;
        scanf("%c",&x[0]);
    }
    if( count % 9 == 0)
    printf("Yes\n");
    else printf("No\n");
    return 0;
}


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


int main(){
    int k=2,n=2;
    cin >> k >> n;
    int a[n];
    unsigned int minCandidate=0;
    unsigned int min=k;
    int judge=1;
    int diffSave[n];
    for (int i=0;i<n;i++){cin >> a[i];}
    
    for(int i=0;i<n;i++){
        if(i!=n-1){
        diffSave[i]=a[i+1]-a[i];
        }else{
            diffSave[n-1]=a[0]+(k-a[n-1]);
        }
        //cout << "diffSave[" << i << "]->" << diffSave[i] << endl;//debug
    }
    //find max
    int max=0;
    for(int i=0;i<n;i++){
      if(diffSave[i]>max){
          max=diffSave[i];
      }
  } 


    min=k-max;
   //cout << "max->" << max << endl; //debug
   cout << min << endl; 
    

}

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

using namespace std;

typedef pair<int,int> P;

const int nmax = 1000;
char table[nmax][nmax];

int bfs(int H,int W){
    queue<P> q;
    P pos;
    int n_x,n_y,x,y,count1,count2,ans;
    int direction[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

    count1 = 0;
    count2 = 0;
    ans = 0;
    for(int y = 0;y < H;y++){
        for(int x = 0;x < W;x++){
            if(table[y][x] == '#'){
                q.push(P(x,y));
                count1++;
            }
        }
    }
    while(!q.empty()){
        pos = q.front();
        q.pop();
        count1--;
        n_x = pos.first;
        n_y = pos.second;
        for(int i = 0;i < 4;i++){
            x = n_x + direction[i][0];
            y = n_y + direction[i][1];
            if(x < 0 || W <= x || y < 0 || H <= y) continue;
            if(table[y][x] == '#') continue;
            table[y][x] = '#';
            q.push(P(x,y));
            count2++;
        }
        if(count1 == 0){
            ans++;
            count1 = count2;
            count2 = 0;
        }
    }
    return --ans;
}

int main(){
    int H,W;

    cin >> H >> W;
    for(int y = 0;y < H;y++){
        for(int x = 0;x < W;x++){
            cin >> table[y][x];
        }
    }

    cout << bfs(H,W) << endl;
}

Measured memory_bytes: 9360
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,q,a[100005],m;
bool half_find(int x)
{
    int l=0;
    int r=n;
    while(l<r)
    {
        int mid=(l+r)/2;
        if(x==a[mid])
            return true;
        else if(x>a[mid])
            l=mid+1;
        else
            r=mid;
    }
    return false;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    scanf("%d",&m);
    int ant=0;
    for(int i=0;i<m;i++)
    {
        scanf("%d",&q);
        if(half_find(q))
            ant++;
    }
    printf("%d\n",ant);
    return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;

const int MAX_N = 1e5;

int main(){
    string S; cin >> S;
    mint dp[MAX_N+1][4]; // dp[i][j] := i番目の文字まででの、j(A,AB,ABC)が作れる数
    int N = S.size();
    dp[0][0] = 1;

    rep(i, 1, N + 1){
        if(S[i-1] == '?'){
            rep(j, 0, 4){
                dp[i][j] = (mint)3 * dp[i-1][j];
            }
        }else{
            rep(j, 0, 4){
                dp[i][j] = dp[i-1][j];
            }
        }
        if(S[i-1] == 'A') dp[i][1] += dp[i-1][0];
        else if(S[i-1] == 'B') dp[i][2] += dp[i-1][1];
        else if(S[i-1] == 'C') dp[i][3] += dp[i-1][2];
        else if(S[i-1] == '?'){
            dp[i][1] += dp[i-1][0];
            dp[i][2] += dp[i-1][1];
            dp[i][3] += dp[i-1][2];
        }
    }
    cout << dp[N][3] << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
using namespace std;
 
int main(){
int time;
cin >> time;
 
int hour = time / 3600;
int minute = (time % 3600) / 60;
int second = time % 60;
 
stringstream ss;
ss << hour << ":" << minute << ":" << second;
cout << ss.str() << endl;
return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  int n;
  cin >> n;
  vector<int> like(n+1,0);
  REP(i,n) cin >> like[i+1];
  int answer=0;
  REP(i,n) if(like[like[i+1]]==i+1) ++answer;
  cout << answer/2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cmath>

int main() {
    int N, K, t;

    std::cin >> N >> K;

    double prob = 0;
    for (int i = 1; i <= N; i++) {
        if (i >= K) t = 0;
        else t = ceil(log2(K / (double)i));
        prob += 1 / pow(2, t);
    }

    std::cout << std::setprecision(20);
    std::cout << prob / N << std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int answer;
  if(x <= a){
    answer = x;
  }
  else if(x <= a+b){
    answer = a;
  }
  else{
    answer = a - (x-a-b);
  }
  cout << answer <<endl;
}
  

Measured memory_bytes: 3620
#include <iostream>
#include<cmath>

using namespace std;

int N, A[100000+5], B[100000+5], C[100000+5], DP[100000+5][3], ans;

void solve(){
    DP[0][0] = 0; DP[0][1] = 0; DP[0][2] = 0;

    for(int i = 1; i <= N; i++){
        DP[i][0] = A[i] + max(DP[i-1][1], DP[i-1][2]);
        DP[i][1] = B[i] + max(DP[i-1][0], DP[i-1][2]);
        DP[i][2] = C[i] + max(DP[i-1][0], DP[i-1][1]);
    }

    ans = max(DP[N][0], DP[N][1]);
    ans = max(ans, DP[N][2]);

    cout << ans << endl;
}

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i] >> B[i] >> C[i];

    solve();
}

Measured memory_bytes: 2560
#include<stdio.h>
#define MAX 100000
int A[MAX],n;
int partition(int p,int r)
{
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++)
    {
        if(A[j]<=x)
        {
            i++;
            t=A[i];
            A[i]=A[j];
            A[j]=t;
        }
        
    }
    t=A[r];
    A[r]=A[i+1];
    A[i+1]=t;
    return i+1;
}
int main()
{
    int i,q;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    q=partition(0,n-1);
    for(i=0;i<n;i++)
    {
        if(i) printf(" ");
        if(i==q) printf("[");
        printf("%d",A[i]);
        if(i==q) printf("]");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2192
#include<bits/stdc++.h>
#define rep(i,k,n)     for (ll i = k; i < n; ++i)
#define repr(i,k,n)    for (ll i = k; i >= n; --i)
#define repp(p,a)      for (p=a.begin();p!=a.end();++p)
#define all(a)         a.begin(),a.end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define reppn(p,a,n)    for (p=a.begin();(p+n)!=a.end();++p)
#define F              first
#define S              second
#define ll             long long
#define hell           1000000007
#define god            LLONG_MAX
#define lb             lower_bound
#define ub             upper_bound
#define pb             push_back
#define ct             continue
#define endl           '\n'
#define setprecision(n) sp(n)
#define srt(a)         sort(all(a))
#define srtd(a)        sort(a.rbegin(),a.rend())
#define sz(a)          ll((a).size())
#define sum(a)         accumulate(all(a),(ll) 0)
#define pdt(a)         accumulate(all(a),double(1),multiplies<double> ())
#define dotpdt(a,b)    inner_product(all(a),b.begin(),0)
#define mkp(a,b)       make_pair(a,b)
#define REP(x,s)       for (auto x : s)
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll t=1;
  //cin>>t;
  while(t--)
  {
      string s,t;
      cin>>s>>t;
      cout<<t+s;
  }
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int main(){
	//	freopen("in.txt","r",stdin);
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	const int dx = tx - sx;
	const int dy = ty -sy;
	cout << string(dy,'U') << string(dx,'R');
	cout << string(dy,'D') << string(dx,'L');
	cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
	cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
	cout << endl;
	return 0;
}

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

void Main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}

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



Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

ll n, m, a, b, p[100005];
vector<vector<int>> g(100005);
queue<int> q;

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

  q.push(1);

  while (!q.empty()) {
    int cnode = q.front();
    q.pop();
    rep(i, g[cnode].size()) {
      if (p[g[cnode][i]] == 0) {
        p[g[cnode][i]] = cnode;
        q.push(g[cnode][i]);
      }
    }
  }

  cout << "Yes" << endl;
  for (int i = 2; i <= n; i++) {
    cout << p[i] << endl;
  }
}

Measured memory_bytes: 10668
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=100005;

void solve()
{
    int a,b,x;
    cin>>x>>a>>b;
    if(a>=b)
{
    cout<<"delicious"<<endl;
}
    else
    {
        if(b<=(a+x))
            cout<<"safe"<<endl;
        else
            cout<<"dangerous"<<endl;
    }
}

int32_t main()
{
    IOS;
    
    int t;
    t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
for i in range(n):
    t=a[i]-b[i]
    if t>=0:
        a[i]=t
    else:
        a[i]=0
        _t=a[i+1]-(-1*t)
        if _t>=0:
            a[i+1]=_t
        else:
            a[i+1]=0
print(s-sum(a))

Measured memory_bytes: 19156
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if 10000 * i + 5000 * j + 1000 * (n-i-j)==y:
            print(i, j, n-i-j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define VI vector<int>
using namespace std;
const int N=10005,inf=1e9;
int n,sz_a,sz_b,ans; VI a,b; char s[N],t[N];
void work(VI &a,char *s){
	rep (i,1,n-1) if (s[i]!=s[i+1]) a.push_back(i);
}
int main(){
	scanf("%d%s%s",&n,s+1,t+1);
	work(a,s); sz_a=a.size();
	work(b,t); sz_b=b.size();
	ans=inf;
	rep (dif,-sz_a-1,sz_b+1)
		if ((dif+(s[1]==t[1]))&1){
			int now=0;
			rep (i,min(-dif,0),max(sz_a,sz_b-dif)-1){
				int j=i+dif,px,py;
				px=i<0?0:i>=sz_a?n:a[i],py=j<0?0:j>=sz_b?n:b[j];
				now+=abs(px-py);
			}
			ans=min(ans,now);
		}
	printf("%d",ans);
	return 0;
}

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

int main()
{
  int d;

  while (~scanf("%d", &d)){
    int s = 0;
    for (int i = 0; i < 600; i += d){
      s += i * i * d;
    }
    printf("%d\n", s);
  }
  
  return (0);
}

Measured memory_bytes: 1188
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	int n;cin >> n;
	printf("%d\n",n^1);
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define int long long
using namespace std;
map<int, int> l, ans;
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, x, p;
	cin>>n>>m>>x>>p;
	vector<int>v;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		v.push_back(k);
	}
	sort(v.begin(), v.end());
	int ans=0;
	long long cur=0;
	v.push_back(INT_MAX);
	for(int i=0;i<=n;i++){
		if(i==0) cur++;
		else if(v[i]==v[i-1]) cur++;
		else{
			ans+=cur;
			l[v[i-1]]=ans;
			cur=1;
		}
	}
	v.pop_back();
	reverse(v.begin(), v.end());
	int cnt=0, cnt2=1;
	cur=v[p-1];
	for(int i=0;i<n;i++){
		//cout<<v[i]<<endl;
		long long need=(x-(p-1)-l[v[i]])*m, maxi=v[i]+m;
		if(i<p){
			cnt++;
			continue;
		}
		if(v[p-1]>maxi) break;
		if(i>=p){
			//cout<<cnt2<<" "<<maxi<<" "<<cur<<" "<<need<<endl;
			if(cnt2*maxi-cur>=need) cnt++;
			else break;
			cur+=v[i];
			cnt2++;
			//else break;
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 7284
import numpy as np

n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))

X = 0
for i in range(40, -1, -1):
    count_1 = np.sum((A >> i) & 1)
    count_0 = n - count_1

    if count_0 > count_1:
        X += 2**i
        if X > k:
            X -= 2 ** i
    else:
        continue

ans = np.sum(X ^ A)
print(ans)


Measured memory_bytes: 23580
def solve():
    N = int(input())
    
    if N % 2 != 0:
        print(0)
        exit()
    
    ans, denominator = 0, 10
    while denominator <= N:
        ans += N // denominator
        denominator *= 5
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  vi a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  
  if (a[0] + a[1] == a[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    std::cout<<(std::find(ALL(s),'7')!=s.end()?"Yes":"No")<<'\n';
}


Measured memory_bytes: 3652
def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    if N >= M:
        print(0)

    else:
        X.sort()
        dist = [abs(X[i] - X[i+1]) for i in range(M-1)]
        dist.sort()
        ans = sum(dist[:(M-N)])
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13968
/*

厳密にいうと今回はpair<bool,int>の最大値なんですよね

前はinvalidかvalidか、後が実際の最大値
単位元は(false,0)
めんどくさいから-infで代用してる

doi [20:14]
<false,理想的な最大値>になるのはx=<kの条件を外したときという理解で大丈夫でしょうか


*/
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MAX_DIGIT = 50;
long long dp[100][2]; // dp[上から i 桁まで][ smaller ]

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    memset(dp, -1, sizeof(dp)); // DP 配列を -1 で初期化
    dp[0][0] = 0; // 初期条件
    for (int d = 0; d < MAX_DIGIT; ++d) {
        long long mask = 1LL<<(MAX_DIGIT - d - 1);
        
        // A で元々 d 桁目にビットが立っているものの個数
        int num = 0;
        for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
        
        // X の d 桁目を 0, 1 にしたときのコスト
        long long cost0 = mask * num;
        long long cost1 = mask * (N - num);
        
        // smaller -> smaller
        if (dp[d][1] != -1) {
            chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1)); // 0 でも 1 でも自在に大きい方
        }
        
        // exact -> smaller
        if (dp[d][0] != -1) {
            if (K & mask) { // K の d 桁目が 1 だったら、X の d 桁目は 0 にする
                chmax(dp[d+1][1], dp[d][0] + cost0);
            }
        }
        
        // exact -> exact (K にぴったり合わせる)
        if (dp[d][0] != -1) {
            if (K & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
            else chmax(dp[d+1][0], dp[d][0] + cost0);
        }
    }
    cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int dp[3030][3030];
P prev_pos[3030][3030];
bool used[3030][3030];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    vector<int> A(N), B(N);
    rep(i, 0, N) cin >> A[i] >> B[i];
    rep(i, 0, T + 1) rep(j, 0, N + 1) prev_pos[i][j] = P(-1, -1);
    rep(i, 1, T + 1) rep(j, 1, N + 1) {
        dp[i][j] = dp[i][j - 1];
        prev_pos[i][j] = P(i, j - 1);
        if (i - A[j - 1] >= 0 && dp[i][j] < dp[i - A[j - 1]][j - 1] + B[j - 1]) {
            dp[i][j] = dp[i - A[j - 1]][j - 1] + B[j - 1];
            prev_pos[i][j] = P(i - A[j - 1], j - 1);
            used[i][j] = true;
        }
    }
    int ans = 0;
    rep(i, 1, T + 1) {
        if (i == T) {
            ans = max(ans, dp[i][N]);
            break;
        }
        int max_b = 0;
        int tmp;
        int now_i = i, now_j = N;
        while (now_i >= 0 && now_j >= 0) {
            if (!used[now_i][now_j]) {
                max_b = max(max_b, B[now_j - 1]);
            }
            tmp = now_i;
            now_i = prev_pos[now_i][now_j].first;
            now_j = prev_pos[tmp][now_j].second;
        }
        ans = max(ans, dp[i][N] + max_b);
    }
    cout << ans << endl;
    return 0;
}

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

if n % 2 == 1:
  print(0)
elif n < 10:
  print(0)
else:
  count = 2
  while n >= 2 * (5 ** count):
    count += 1
  result = 0
  for i in range(count - 1):
    result += n // (2 * (5 ** (i + 1)))
  print(result)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int max = w;
		if(h > w)
			max = h;

		int n = sc.nextInt();
		sc.close();
		if(n % max == 0)
		System.out.println(n / max);
		else
			System.out.println(n / max + 1);


	}

}


Measured memory_bytes: 24020
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():
    d = Debug()
    d.off()
    X, A, B = getIntList()
    if abs(X-A) < abs(X-B):
        return 'A'
    else:
        return 'B'


ans = prob()
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int l;
  cin >> l;
  cout << 1.0 * l / 3 * l / 3 * l / 3 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int card[100][100];
    
    for(int i=0;i<n;i++){
        int num;
        string mark;
        cin>>mark>>num;
        
        int g;
        if(mark == "S") g=1;
        if(mark == "H") g=2;
        if(mark == "C") g=3;
        if(mark == "D") g=4;
        card[g][num]=1;
    }
    
    string str[5] = {"G","S","H","C","D"};
    for(int x=1;x<=4;x++){
        for(int y=1;y<=13;y++){
            
            if(card[x][y]==1) continue;
            else cout <<str[x]<<" "<<y<<endl;
        }
    }
    return 0;
}


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

int main(){
  int i, j, H, W;
  cin >> H >> W;

  vector<char> picture(H*W);

  for(i=0; i<H*W; i++)
    cin >> picture.at(i);

  for(i=0; i<W+2; i++)
    cout << '#';

  cout << "\n";

  for(i=0; i<H; i++){
    cout << '#';
    for(j=0; j<W; j++)
      cout << picture.at(i*W + j);
    cout << '#' << "\n";
  }

  for(i=0; i<W+2; i++)
    cout << "#";

  cout << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main() {
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(b<=a) {
		while(b<=a) {
			b*=2;
			k--;
		}
	} if(c<=b) {
		while(c<=b) {
			c*=2;
			k--;
		}
	}
	if(k<0) {
		cout<<"No\n";
	} else cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using ll_t = long long;

std::vector<int> pos[26];

ll_t solve(const std::string &s, const std::string &t) {
  int s_len = s.length();
  for (int i = 0; i < s_len; ++i) {
    pos[s[i] - 'a'].emplace_back(i);
  }
  int num = 1, index = -1;
  int t_len = t.length();
  for (int i = 0; i< t_len; ++i) {
    int ch = t[i] - 'a';
    if (pos[ch].empty()) return -1;
    auto iter = std::upper_bound(pos[ch].begin(), pos[ch].end(), index);
    if (iter == pos[ch].end()) {
      ++num;
      index = -1;
      iter = std::upper_bound(pos[ch].begin(), pos[ch].end(), index);
    }
    index = *iter;
  }
  return (ll_t)s_len * (num - 1) + index + 1;
}

int main() {
  std::string s, t;
  std::cin >> s >> t;
  std::cout << solve(s, t) << std::endl;
  return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define N 20000000
using namespace std;
typedef long long ll;
bool used[N];

ll SumD(ll a,ll d,ll n){return (n*(2*a+(n-1)*d))/2;}

bool mark(ll n){
  bool res=1;
  for(ll i=1;i*i<=n;i++){
    if(n%i)continue;
    if(i<N)res&=!used[i],used[i]=1;
    if(i!=n/i&&n/i<N)res&=!used[n/i],used[n/i]=1;
  }
  return res;
}

int main(){
  while(1){
    ll n,m,p[21];
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<m;i++)cin>>p[i];
    sort(p,p+m);

  
    ll sum=0,cnt=0;
    for(int i=0;i<m;i++){
      sum+=SumD(p[i],p[i],n/p[i]);
      cnt+=n/p[i];
      memset(used,0,sizeof(used));
      for(int j=0;j<i;j++){
	ll gcd=__gcd(p[i],p[j]);
	ll lcm=(p[i]/gcd)*p[j];
	if(!mark(lcm))continue;
	sum-=SumD(lcm,lcm,n/lcm);
	cnt-=n/lcm;
      }
    }
    double ans=1.0*(SumD(1,1,n)-sum)/max(1,(int)(n-cnt));
    if(p[0]==1)ans=0;
    printf("%.8f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 22800
#include <stdio.h>

int main(){

int x,y,temp;

while (1) {
 scanf("%d %d",&x, &y);

 if (x == 0 && y == 0)
    break;


if (x > y) {
 temp = y;
 y = x;
 x = temp;
}

printf("%d %d\n", x, y);
}

 return 0;
}

Measured memory_bytes: 596
// D - Make Them Even
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using I4 = tuple<int,int,int,int>;
using VI4 = vector<I4>;

int main(){
	int H,W; cin>>H>>W;
	vi A(W);
	VI4 YX;
	int a;
	rpz(h, H) rpz(w, W){
		cin>>a;
		A[w]^=a&1;
		if(h+1<H && A[w]) YX.emplace_back(h+1,w+1,h+1+1,w+1);
	}
	a = 0;
	rpz(w, W) if(w+1<W && (a^=A[w])) YX.emplace_back(H,w+1,H,w+1+1);
	cout<< YX.size() <<endl;
	for(auto t:YX){
		int a,b,c,d; tie(a,b,c,d) = t;
		printf("%d %d %d %d\n",a,b,c,d);
	}
}

Measured memory_bytes: 4212
N = int(input())
A = [int(a)-1 for a in input().split()]
X = [0] * N
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x * (x-1) // 2

for a in A:
    print(s - (X[a] - 1))


Measured memory_bytes: 81868
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[510][510];
int ss[30][2];

int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	rep(i,0,h)scanf(" %s",s[i]);
	rep(c,0,26)ss[c][0]=ss[c][1]=-1;
	
	rep(c,0,26){
		int x1=-1,x2,y1,y2;
		rep(i,0,h)rep(j,0,w)if(s[i][j]=='A'+c){
			if(x1==-1){
				x1=i;
				y1=j;
			}else{
				x2=i;
				y2=j;
			}
		}
		if(x1!=-1){
			//間にある文字を求める
			if(x1==x2){
				if(abs(y1-y2)!=1){
					ss[c][0]=0;
					rep(j,y1+1,y2)if(s[x1][j]!='.')ss[c][0]|=1LL<<(s[x1][j]-'A');
				}
			}else if(y1==y2){
				if(abs(x1-x2)!=1){
					ss[c][0]=0;
					rep(i,x1+1,x2)if(s[i][y1]!='.')ss[c][0]|=1LL<<(s[i][y1]-'A');
				}
			}else{
				ss[c][0]=ss[c][1]=0;
				if(y1<y2){
					//左上から右下
					rep(i,x1+1,x2+1)if(s[i][y1]!='.')ss[c][0]|=1LL<<(s[i][y1]-'A');
					rep(j,y1+1,y2  )if(s[x2][j]!='.')ss[c][0]|=1LL<<(s[x2][j]-'A');
					rep(j,y1+1,y2+1)if(s[x1][j]!='.')ss[c][1]|=1LL<<(s[x1][j]-'A');
					rep(i,x1+1,x2  )if(s[i][y2]!='.')ss[c][1]|=1LL<<(s[i][y2]-'A');
				}else{
					//右上から左下
					rep(i,x1+1,x2+1)if(s[i][y1]!='.')ss[c][0]|=1LL<<(s[i][y1]-'A');
					rep(j,y2+1,y1  )if(s[x2][j]!='.')ss[c][0]|=1LL<<(s[x2][j]-'A');
					rep(j,y2+1,y1  )if(s[x1][j]!='.')ss[c][1]|=1LL<<(s[x1][j]-'A');
					rep(i,x1  ,x2  )if(s[i][y2]!='.')ss[c][1]|=1LL<<(s[i][y2]-'A');
				}
			}
		}
	}
	
	
	int flag=1;
	int ans=0;
	while(flag){
//	rep(i,0,26)printf("%c %d %d\n",'A'+i,ss[i][0],ss[i][1]);
		flag=0;
		rep(c,0,26)if(ss[c][0]==0||ss[c][1]==0){
			flag=1;
			ans+=2;
			ss[c][0]=ss[c][1]=-1;
			rep(i,0,26)rep(k,0,2)if(ss[i][k]!=-1)ss[i][k]&=~(1LL<<c);
		}
	}
	printf("%d\n",ans);
	
}


Measured memory_bytes: 2140