akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



// レベルiの厚み、パティ
ll n, x, h[55], p[55];

// n,x=n,xの問題の答え
ll rec(ll n, ll x) {
	if (n==0) return (x>0);
	if (x<=1) return 0;
	if (x<=h[n-1]+1) return rec(n-1,x-1);
	return p[n-1]+1 + rec(n-1,x-2-h[n-1]);
}

signed main() {
	cin >> n >> x;
	h[0] = p[0] = 1;
	rep(i,n) h[i+1] = h[i]*2+3, p[i+1] = p[i]*2+1;
	cout << rec(n,x) << endl;
}

Measured memory_bytes: 256
# from sys import stdin
# input = stdin.readline
(H,W,M) = map(int, input().split())
hsum = [0]*H
wsum = [0]*W
bombs = set()
for _ in range(M):
    h,w = map(int, input().split())
    hsum[h-1] += 1
    wsum[w-1] += 1
    bombs.add((h-1,w-1))

hmax = max(hsum)
wmax = max(wsum)

cross_w_zero = False
hargmax = sum(1 for x in hsum if x == hmax)
wargmax = sum(1 for x in wsum if x == wmax)
cnt = sum(1 for h,w in bombs if hsum[h] == hmax and wsum[w] == wmax)
if hargmax * wargmax == cnt:
    print(hmax + wmax - 1)
else:
    print(hmax + wmax)

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf = (ll)1e14;
const ll N = (ll)1e3+77;
const ll mod = (ll)1e9+7;

int n,m,k,x,y,ans;
string s;

int main() {
    fast;
    cin >> s;
    n = sz(s);
    map<char, int> mp;
    forn(i, n) {
        mp[s[i]]++;
    }

    for (auto x : mp) {
        if (x.first == 'x') continue;
        if (x.second & 1) m++, k = x.first;
    }
    if (m > 1) return cout << "-1\n", 0;

    x = mp[k] / 2;
    x++;
    m = -1;
    forn(i, n) {
        if (s[i] == k) x--;
        if (x == 0) {
            m = i;
            break;
        }
    }

    if (m == -1) {
        int l = 0, r = n - 1;
        while (l < r) {
            while (l < r and s[l] == 'x' and s[r] == 'x') l++, r--;
            while (l < r and s[l] == 'x') l++, ans++;
            while (l < r and s[r] == 'x') r--, ans++;

            if (l >= r) break;

            if (s[l] != s[r]) return cout << "-1\n", 0;
            l++, r--;
        }

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

    map<char, int> left, right;

    forn(i, m) left[s[i]]++;
    fore(i, m + 1, n - 1) right[s[i]]++;

    forn(i, 26) {
        if ('a' + i == 'x') continue;
        if (left['a' + i] != right['a' + i]) return cout << "-1\n", 0;
    }

    int l = m - 1, r = m + 1;

    while (l >= 0 and r < n) {
        while (l >= 0 and r < n and s[l] == 'x' and s[r] == 'x') l--, r++;
        while (l >= 0 and s[l] == 'x') l--, ans++;
        while (r < n and s[r] == 'x') r++, ans++;

        if (l < 0 or r >= n) break;
        if (s[l] != s[r]) return cout << "-1\n", 0;

        l--, r++;
    }

    while (l >= 0) {
        if (s[l] != 'x') return cout << "-1\n", 0;
        ans++;
        l--;
    }

    while (r < n) {
        if (s[r] != 'x') return cout << "-1\n", 0;
        ans++;
        r++;
    }

    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<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
  cout << fixed << setprecision(10);
  double n;
  cin >> n;
  vdouble X(n);
  vdouble Y(n);
  rep(i,n){
    cin >> X[i] >> Y[i];
  }
  vdouble order(n);
  rep(i,n) order[i] = i;
  double ans = 0;
  do{
    double nowx = X[order[0]];
    double nowy = Y[order[0]];
    rep1(i,n){
      ans += sqrt(pow(X[order[i]]-nowx,2) + pow(Y[order[i]]-nowy,2));
    }
  }while(next_permutation(order.begin(),order.end()));
  double nnn = 1;
  erep1(i,n) nnn *= i;
  cout << ans / nnn << endl;
}

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


void solve(long long K, long long N, std::vector<long long> A){
	sort(A.begin(), A.end()); 
	
	long long pairwise_max = -1; 
	for (auto i = 0; i < A.size()-1; ++i) {
			long long diff = abs(A[i+1] - A[i]); 
			pairwise_max = max(pairwise_max, diff); 
		}

	pairwise_max = max(pairwise_max, K-A.back() + A[0]);
	cout << K - pairwise_max << endl; 
}

// 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 K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

signed main()
{
    speed
    int n;cin>>n;
    string s=to_string(n);
    int tot=s.length();
    int pres=1;
    int ans=0;
    for(int i=1;i<tot;++i)
    {
        if(i%2)
        {
            ans+=(9*pres);
        }
        pres*=10;
    }
    if(tot%2){ans+=(n-pres+1);}
    cout<<ans<<"\n";
}

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

using namespace std;

int main(){
	int k,t,tmp;
	vector<int> a;
	cin >> k >> t;
	for(int i=0;i<t;i++){
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(),a.end());
	int ans;
	ans = 2*a[a.size()-1]-k-1;
	if(ans>0) cout << ans << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    set<int> s;
    for (int i = 0 ; i < n ; i++) {
        int v; cin >> v;
        s.insert(v);
    }
    if (s.size() == n)
        cout << "YES\n";
    else
        cout << "NO\n";
}


Measured memory_bytes: 9600
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;
import std.typecons;
import std.algorithm : permutations, nextPermutation;

alias Location = Tuple!(int, "x", int, "y");

void main() {
  auto N = readln.chomp.to!int;
  Location[] locations;
  foreach(i; 0..N) {
    int x, y; readf("%d %d\n", &x, &y);
    locations ~= Location(x, y);
  }

  real distance = 0;
  int count = 0;
  foreach(route; iota(N).permutations) {
    int prev = route[0];
    foreach(next; route[1..N]) {
      auto distance_x = locations[prev].x - locations[next].x;
      auto distance_y = locations[prev].y - locations[next].y;
      distance += (cast(real)(distance_x*distance_x + distance_y*distance_y)).sqrt;
      prev = next;
    }
    count++;
  }

  writefln("%.10f", distance/count);
}


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

const int INF = 1 << 30;

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int x, y, z;
	int ans = 0;
	while(true) {
		if(a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
			ans++;
		else break;
		if(a == b && b == c && c == a) {
			ans = -1;
			break;
		}
		x = a, y = b, z = c;
		a = (y + z) / 2;
		b = (x + z) / 2;
		c = (x + y) / 2;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>

#define INF (1e+9)
#define LLINF (1e+18)
#define LL long long

using namespace std;

typedef struct info{
	int nx;
	int ny;
	int cost;
	int target;
	info(int a,int b,int c,int d){
		nx = a;
		ny = b;
		cost = c;
		target = d;
	}
}info;

bool isNumChar(char c){
	if((0 <= c-48)&&(c-48 <= 9))return true;
	return false;
}

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

int W,H;
int N;

int sx[16] = {0};
int sy[16] = {0};

char field[1024][1024] = {""};
int record[1024][1024][12] = {0};
bool flag[16] = {false};

queue<info> que;


int ans;



int recordReset(){
	for(int i = 0;i < 1024;i++){
		for(int j = 0;j < 1024;j++){
			for(int k = 0;k < 12;k++){
				record[i][j][k] = INF;
			}
		}
	}
}

int bfs(){
	info now(0,0,0,0);
	info next(0,0,0,0);
	for(int i = 0;i < N;i++){
		next = info(sx[i],sy[i],0,i+1);
		que.push(next);
	}

	recordReset();
	while(!que.empty()){
		now = que.front();
		que.pop();
		if(!flag[now.target]){
			//printf("###(%d,%d):::cost<%d>:::target<%d>\n",now.nx,now.ny,now.cost,now.target);
			if(record[now.nx][now.ny][now.target] > now.cost){
				record[now.nx][now.ny][now.target] = now.cost;
				if((sx[now.target] == now.nx)&&(sy[now.target] == now.ny)){
					flag[now.target] = true;
					//printf("###target<%d> completed\n",now.target);
					ans += record[now.nx][now.ny][now.target];
				}
				else{
					switch(field[now.nx][now.ny]){
					case 'X':
						break;
					default:
						for(int i = 0;i < 4;i++){
							next = info(now.nx + dx[i],now.ny + dy[i],now.cost + 1,now.target);
							que.push(next);
						}
						break;
					}
				}
			}
		}
	}
}


int main (void){
	//while(true){
		scanf("%d%d",&H,&W);
		scanf("%d",&N);
		//if((W == 0)&&(H == 0))break;

		ans = 0;

		//Reset Field
		for(int i = 0;i < 1024;i++){
			for(int j = 0;j < 1024;j++){
				field[j][i] = 'X';
			}
		}

		//Reset Flag
		for(int i = 0;i < 16;i++){
			flag[i] = false;
		}

		//Reading Data
		for(int i = 1;i <= H;i++){
			scanf(" ");
			for(int j = 1;j <= W;j++){
				scanf("%c",&field[j][i]);
				if(isNumChar(field[j][i])){
					sx[field[j][i]-48] = j;
					sy[field[j][i]-48] = i;
					//printf("###<%d>(%d,%d)\n",field[j][i] - 48,sx[field[j][i] - 48],sy[field[j][i] - 48]);

				}
				else if(field[j][i] == 'S'){
					sx[0] = j;
					sy[0] = i;
					//printf("###<S>(%d,%d)\n",j,i);
				}
			}
		}

		//DBG
		/*for(int i = 0;i < N;i++){
			printf("<%d>(%d,%d)\n",i,sx[i],sy[i]);
		}*/

		bfs();

		printf("%d\n",ans);
	//}

	return 0;
}

Measured memory_bytes: 51404
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
        int N;
        string str,s;
        cin >> N;
        map<string,bool> dictionary;
        for(int i=0 ; i<N ; i++ ){
                cin >> str >> s;
                if(str=="insert"){
                        dictionary[s]=true;
                }else{
                        if(dictionary[s])
                                cout<<"yes"<<endl;
                        else
                                cout<<"no"<<endl;
                }
        }
        return 0;
}



Measured memory_bytes: 52544
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1),True)
    under = reduce(mul, range(1,r + 1),True)
    return over // under

N,K = [int(x) for x in input().split()]
for i in range(K):
    if N-K-i >= 0:
        print((cmb(K-1,i)*cmb(N-K+1,i+1))%(10**9+7))
    else:
        print(0)

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



int main() {
  int A, B, M; cin >> A >> B >> M;
  vector<int> a(A);
  vector<int> b(B);
  int minA = 100001;
  int minB = 100001;
  
  rep(i,A){
    cin >> a[i];
    minA = min(minA,a[i]);
  }
  rep(i,B){
    cin >> b[i];
    minB = min(minB,b[i]);
  }
  
  int ans = minA + minB;
  rep(i,M){
    int x,y,c; cin >> x >> y >> c;
    x--;
    y--;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;



  return 0;
}



Measured memory_bytes: 3928
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  s = 0
  ans = []
  for i in range(50):
    if (n - s) % (2**(i+1)) == 0:
      ans.append('0')
    else:
      ans.append('1')
      s += ((-2) ** i)
    if s == n:
      break
  print(''.join(ans[::-1]))
    
if __name__=='__main__':
  main()



Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	long long int ans = k * pow(k - 1, n - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
N = STDIN.gets.chomp.to_i                                               
modNum = 1000000007

dp = Array.new(101).map{Array.new(4).map{Array.new(4).map{Array.new(4, 0)}}}

dp[0][3][3][3] = 1

for num in 0..N - 1 do
  # 0=A 1=G 2=C 3=T
  for c1 in 0..3
    for c2 in 0..3
      for c3 in 0..3
        for tugi in 0..3
 #         if dp[num][c1][c2][c3] == 0 then
 #           next
 #         end
          if c2 == 0 && c3 == 1 && tugi == 2 then
            next
          end
          if c2 == 1 && c3 == 0 && tugi == 2 then
            next
          end
          if c2 == 0 && c3 == 2 && tugi == 1 then
            next
          end
          if c1 == 0 && c3 == 1 && tugi == 2 then
            next
          end
          if c1 == 0 && c2 == 1 && tugi == 2 then
            next
          end
          dp[num + 1][tugi][c3][c2] += dp[num][c3][c2][c1]
          #dp[num + 1][tugi][c3][c2] %= modNum
        end
      end
    end
  end
end

result = 0
for c1 in 0..3
  for c2 in 0..3
    for c3 in 0..3
      result += dp[N][c3][c2][c1]
    end
  end
end

puts result % modNum  

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll x, y, z, k;
    cin >> x >> y >> z >> k;

    vi a(x), b(y), c(z), ab(x*y), abc(3000*z);
    rep(i, x) cin >> a[i];
    rep(i, y){
        cin >> b[i];
        rep(j, x) ab[i*x+j] = b[i] + a[j];
    }
    sort(all(ab), greater<ll>());

    rep(i, z){
        cin >> c[i];
        rep(j, min((ll)ab.size(), k)) abc[i*min((ll)ab.size(), k)+j] = c[i] + ab[j];
    }
    sort(all(abc), greater<ll>());
    rep(i, k) cout << abc[i] << endl;
}

Measured memory_bytes: 34624
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int D = scan.nextInt();

		int left = A + B;
		int right = C + D;

		if (left > right) {
			System.out.println("Left");
		} else if (left == right) {
			System.out.println("Balanced");
		} else {
			System.out.println("Right");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27028
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

struct Edge {
  ll from, to, cost;
  Edge(ll f, ll t, ll c) : from(f), to(t), cost(c) {}
};

bool find_negative_loop(ll n, const vector<Edge> &edges) {
  vl d(n, INF);
  d[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < edges.size(); j++) {
      Edge e = edges[j];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        if (i == n - 1) {
          return true;
        }
      }
    }
  }
  return false;
}

ll bellman_ford(ll n, const vector<Edge> &edges) {
  vl dist(n, INF);
  dist[0] = 0;

  for (int k = 0; k < n; ++k) {
    bool update = false;
    for (int i = 0; i < edges.size(); ++i) {
      Edge e = edges[i];
      if (dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost) {
        dist[e.to] = dist[e.from] + e.cost;
        update = true;
      }
    }
    if (!update) break;
  }
  return dist[n - 1];
}

int main() {
  //
  ll n, m, p;
  cin >> n >> m >> p;
  vl a(m), b(m), c(m);
  vvl edge(n), edge2(n);
  set<ll> reachable, reachable2;
  reachable.insert(0);
  reachable2.insert(n - 1);

  rep(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    edge[a[i]].push_back(b[i]);
    edge2[b[i]].push_back(a[i]);
  }
  queue<ll> que;
  que.push(0);
  while (!que.empty()) {
    ll u = que.front();
    que.pop();
    for (auto &v : edge[u]) {
      if (reachable.find(v) == reachable.end()) {
        que.push(v);
        reachable.insert(v);
      }
    }
  }
  que.push(n - 1);
  while (!que.empty()) {
    ll u = que.front();
    que.pop();
    for (auto &v : edge2[u]) {
      if (reachable2.find(v) == reachable2.end()) {
        que.push(v);
        reachable2.insert(v);
      }
    }
  }
  vector<Edge> edges;
  rep(i, m) {
    if (reachable.find(a[i]) != reachable.end() &&
        reachable2.find(a[i]) != reachable2.end() &&
        reachable.find(b[i]) != reachable.end() &&
        reachable2.find(b[i]) != reachable2.end()) {
      //
      edges.push_back(Edge(a[i], b[i], p - c[i]));
    }
  }
  if (find_negative_loop(n, edges)) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = bellman_ford(n, edges);
  cout << max(0LL, -ans) << endl;
  return 0;
}


Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
const int MOD = 1e9+7;

int main() {
	int n,k;
	std::cin>>n;
	std::cin>>k;
	std::vector<int> a(n,0);
	int total = 0;
	for (int i = 0; i < n; ++i) {
		std::cin>>a[i];
		total += a[i];
	}
	if (k > total) {
		printf("0\n");
		return 0;
	}
	long long dp[n+1][k+1];
	long long s[k+2];
	memset(dp, 0, sizeof(dp));
	memset(s, 0, sizeof(s));
	for (int i = 0; i<=k; ++i)
		dp[0][i] = 0;
	for (int i = 0; i<=n; ++i)
		dp[i][0] = 1;
	for (int i = 1; i<=n; ++i) {
		s[0] = 0;
		for (int j = 1; j <= k+1; ++j)
			s[j] = s[j-1] + dp[i-1][j-1];
		for (int j = 1; j <=k; ++j) {
			dp[i][j] = s[j+1] - s[std::max(0, j - a[i-1])];
			dp[i][j] %= MOD;
		}
	}
	printf("%lld\n", dp[n][k]);

	return 0;
}


Measured memory_bytes: 80000
#include<cstdio>
using namespace std;
int n,m,k;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;++i) for(int j=0;j<=m;++j) if(i*m+j*n-i*j*2==k) {printf("Yes\n");return 0;}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

// 先手勝ち:1, 後手勝ち: 2, 未確定:0
int dp[2][100001] = {};
int a[100] = {};
int n, k;

int memo(int i, int k)
{
  if (dp[i][k] != 0)
  {
    return dp[i][k];
  }

  REP(j, n)
  {
    int tmp = INF;
    if (k - a[j] >= 0)
    {
      tmp = memo((i + 1) % 2, k - a[j]);
    }
    if (tmp == i + 1)
    {
      dp[i][k] = i + 1;
      return dp[i][k];
    }
  }
  if (i == 1)
  {
    dp[i][k] = 1;
  }
  else
  {
    dp[i][k] = 2;
  }
  return dp[i][k];
}

int main()
{
  cin >> n >> k;
  REP(i, n)
  {
    cin >> a[i];
  }

  dp[1][0] = 1;
  dp[0][0] = 2;
  if (memo(0, k) == 1)
  {
    cout << "First" << endl;
  }
  else
  {
    cout << "Second" << endl;
  }
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int n,k,h[110000];
  cin >> n >> k;
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    cin >> h[i];
    if(h[i] >= k) cnt++;
  }
  
  cout << cnt << endl;  
}

Measured memory_bytes: 3988
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
xy = [LI() for i in range(N)]

# 円の中心の半径は、ある2点の中点か、ある3点の外心かである

ans = []

def distance(A,B):
    x1,y1 = A
    x2,y2 = B
    return ((x1-x2)**2+(y1-y2)**2)**.5

for i in range(N-1):
    for j in range(i+1,N):
        x1,y1 = xy[i]
        x2,y2 = xy[j]
        x,y = (x1+x2)/2,(y1+y2)/2
        r = distance((x,y),(x1,y1))
        for k in range(N):
            if k == i or k == j:
                continue
            else:
                if distance(xy[k],(x,y)) > r+10**-8:
                    break
        else:
            ans.append(r)


def gaishin(A,B,C):
    x1,y1 = A
    x2,y2 = B
    x3,y3 = C
    a = 2*((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))
    b = x2**2-x1**2+y2**2-y1**2
    c = x3**2-x1**2+y3**2-y1**2
    if a == 0:
        return (10000,10000)
    else:
        x = ((y3-y1)*b-(y2-y1)*c)/a
        y = (-(x3-x1)*b+(x2-x1)*c)/a
    return (x,y)

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            x,y = gaishin(xy[i],xy[j],xy[k])
            if x == 10000 and y == 10000:
                continue
            else:
                r = distance((x,y),xy[i])
                for l in range(N):
                    if l == i or l == j or l == k:
                        continue
                    else:
                        if distance(xy[l],(x,y)) > r+10**-8:
                            break
                else:
                    ans.append(r)

print(min(ans))

Measured memory_bytes: 76172
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,i,l,t,w,x,pos,a[100010];
int main(){
	scanf("%lld%lld%lld",&n,&l,&t);
	for(i=0;i<n;i++){
		scanf("%lld%lld",&x,&w);
		if(w==1){
			a[i]=(x+t)%l;
			pos+=(x+t)/l;
		}
		 else{
		 	a[i]=(x-t)%l;
		 	pos+=(x-t)/l;
		 	if(a[i]<0){
		 		pos--;a[i]+=l;
			 }
		 }
	}
	sort(a,a+n);
	pos=(pos%n+n)%n;
	for(i=pos;i<n;i++)printf("%lld\n",a[i]);
	for(i=0;i<pos;i++)printf("%lld\n",a[i]);
}

Measured memory_bytes: 1920
from scipy.sparse.csgraph import dijkstra
import numpy as np 

N,X,Y = map(int,input().split())

edge = [[0]*N for i in range(N)]

for i in range(N-1):
    edge[i][i+1] = 1
    edge[i+1][i] = 1

edge[X-1][Y-1] = 1
edge[Y-1][X-1] = 1

edge_n = np.array(edge)
ans = dijkstra(edge_n)
ans = np.array(ans,dtype="int32")
cnt = [0]*N
for i in range(N):
    for j in ans[i]:
        cnt[j] += 1

for i in range(1,N):
    print(cnt[i]//2)


Measured memory_bytes: 131252
#include<cstdio>
#include<algorithm>
using namespace std;
int a[206];
int main(){
  int n;scanf("%d",&n);
  for(int i=1;i<=n*2;++i)scanf("%d",a+i);
  sort(a+1,a+(2*n)+1);
  int ans=0;
  for(int i=1;i<=n;++i)ans+=a[i*2-1];
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    ll c=0,x=1,g=0,n,h,w,k,m,l,ans=0,ptr=0;
    string s,s1,s2;
    cin >> n >> s;
    char ss = s[0];
    ans = n;
    for(int i=1;i<s.size();i++){
        if(ss==s[i]){
            ans--;
            //cout << ss << endl;
        }
        else{
            ss = s[i];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
n, m = map(int, input().split())
s = []
for i in range(m):
    st = list(map(int, input().split()))
    s.append(st[1 :])
p = list(map(int, input().split()))

ans = 0
#あるつき方について
for i in range(1 << n):
    al = True
    #つき方二進数
    v = [bool(i & (1 << x)) for x in range(n)]
    #電球全体
    for j in range(m):
        #onになってるスイッチの個数
        num = 0
        #スイッチの番号
        for t in s[j]:
            num += v[t - 1]
        if p[j] != num % 2:
            al = False
    ans += al
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int> > A(H, vector<int>(W, 0));
    for (auto &a : A) for (auto &_a : a) cin >> _a;
    vector<pair<int, int> > C(H*W);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            C[A[i][j]-1] = make_pair(i, j);
        }
    }
    vector<int> sum(H*W, 0), dp(H*W+1, 0);
    for (int i = D; i < W*H; i++) {
        dp[i] = abs(C[i].first-C[i-D].first)+abs(C[i].second-C[i-D].second);
    }
    for (int i = D; i < W*H; i++) {
        sum[i+1] = sum[i-D+1]+dp[i];
    }
    int Q;
    cin >> Q;
    vector<pair<int, int> > LR(Q);
    for (auto &lr : LR) cin >> lr.first >> lr.second;
    for (auto lr : LR) printf("%d\n", sum[lr.second]-sum[lr.first]);
    return 0;
}

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

int main(){
    int x, j = 2;
    int maxval = 1;
    std::cin >> x;
    
    for(int i=2;i<=x;i++){
        j = 2;
        while((int)std::pow(i,j) <= x){
            maxval = std::max((int)std::pow(i,j),maxval);
            j++;
        }
    }
    
    std::cout << maxval << "\n";
    return 0;
}

Measured memory_bytes: 384
import itertools

N, M, X = map(int, input().split())
C = [0 for _ in range(N)]
A = [[] for _ in range(N)]
for i in range(N):
  lis = list(map(int, input().split()))
  C[i] = lis[0]
  A[i] = lis[1:]
  
junretu = list(itertools.product([0, 1], repeat=N))
mini = [10**10]
for jun in junretu:
  count = 0
  und = [0 for _ in range(M)]
  for i, j in enumerate(jun):
    if j == 1:
      count += C[i]
      for k in range(M):
        und[k] += A[i][k]
  flag = 0
  for i in range(M):
    if und[i] >= X:
      continue
    flag = 1
    break
  if flag == 0:
    mini.append(count)
if min(mini) == 10**10:
  print(-1)
else:
  print(min(mini))

Measured memory_bytes: 69700
import java.util.Scanner;
public class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      String list[] = sc.next().split("");
      if(list[2].equals(list[3]) && list[4].equals(list[5])){
        System.out.print("Yes");
      }else{
        System.out.print("No");
      }
    }
}

Measured memory_bytes: 21716
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  $str = trim(fgets(STDIN));
  $map[$i] = $str."#";
}
$map[$H] = str_repeat("#", $W);
for($i = 0; $i < $H; $i++){
  $h = 0;
  for($j = 0; $j < $W+1; $j++){
    if($map[$i][$j] === "#"){
      for($k = 0; $k < $h; $k++){
        $p[$i][$j - 1 - $k] = $h;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
$max = 0;
for($i = 0; $i < $W; $i++){
  $h = 0;
  for($j = 0; $j < $H+1; $j++){
    if($map[$j][$i] === "#"){
      for($k = 0; $k < $h; $k++){
        $max = max($max, $p[$j - 1 - $k][$i] + $h);
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
echo $max - 1;

Measured memory_bytes: 154104
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i <= N - 3; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]

count = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if (A[j] < A[minj]):
            minj = j

    if (minj != i):
        A[i],A[minj] = A[minj],A[i]
        count += 1

for k in range(n-1):
    print(str(A[k])+" ",end = "")
print(str(A[n-1]))
print(count)



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

int main()
{
  static const int numberOfWords = 3;
  string words[numberOfWords];
  for(int i = 0; i < numberOfWords; ++i)
  {
    cin >> words[i];
  }
  char initisls[numberOfWords];
  for(int i = 0; i < 3; ++i)
  {
      initisls[i] = words[i].front();
  }
  	cout << initisls << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main()
{  
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    string a;
    int ans=0;
    cin>>a;
	for (int i = 0;i<3;i++){
		if(a[i]=='7'){
			cout<<"Yes";
			ans =1;
			break;
		}
	}
	if (ans==0){
		cout<<"No";
	}
	
    
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void)
{
    int n;
    cin >> n;
    int m[2][n];
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int a;
            cin >> a;
            m[i][j] = a;
        }
    }

    int s = 0;
    int d = 0;
    while (d < n)
    {
        int t = 0;
        for (int i = 0; i < n; i++)
        {
            if (d == i)
            {
                t += m[0][i];
                t += m[1][i];
            }
            else if (d < i)
            {
                t += m[1][i];
            }
            else
            {
                t += m[0][i];
            }
        }
        if (t > s)
        {
            s = t;
        }
        d++;
    }

    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			long[] numArray=new long[n];
			long[] resArray=new long[n];
			int ptr=0;
			for(int i=0;i<n;i++){
				long num=sc.nextInt();
				long price=sc.nextInt();
				long volume=sc.nextInt();
				boolean flag=true;
				int j;
				for(j=0;j<ptr;j++){
					if(numArray[j]==num){
						flag=false;
						break;
					}
				}
				if(flag){
					numArray[i]=num;
					resArray[i]=price*volume;
					ptr++;
				}else{
					resArray[j]+=(price*volume);
				}
			}
			boolean flag=false;
			for(int i=0;i<n;i++){
				if(resArray[i]>=1000000l){
					System.out.println(numArray[i]);
					flag=true;
				}
			}
			if(!flag){
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 25432
A,B,C,X,Y = map(int,input().split())
A_and_B = A*X + B*Y
plus1AB = -(A+B)+2*C
if(plus1AB >= 0):
    print(A_and_B)
else:
    ABs= 2*C*min(X,Y)
    amari = abs(X-Y)
    if(X>=Y):
        only = amari*A
    else:
        only = amari*B
    ABonly = amari*2*C
    if(only >= ABonly):
        print(ABs + ABonly)
    else:
        print(ABs +only )

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll vv[111111];
ll fin[111111];
ll ps[111111];
ll tree[444444];
ll lef, rig, mid, best, n, C;

ll query(ll l, ll r)
{
	ll ret=0;
	for(l+=C , r+=C ; l<r ; l>>=1, r>>=1)
	{
		if(l&1) ret+=tree[l++];
		if(r&1) ret+=tree[--r];
	}
	return ret;
}

void upd(ll loc, ll val)
{
	loc+=C; tree[loc]+=val;
	for( ; loc>1 ; loc>>=1) tree[loc>>1]=tree[loc]+tree[loc^1];
}

bool isok(ll x) // m_{l,r}>=x인 #[l,r] * 2 >= (n+1)C2
{
	int i; ll ret=0; C=2*n+4;
	for(i=0 ; i<=444400 ; i++) tree[i]=0;
	for(i=0 ; i<=n ; i++) ps[i]=0;
	for(i=1 ; i<=n ; i++)
	{
		if(vv[i]>=x) fin[i]=1;
		else fin[i]=-1; 
	}
	for(i=1 ; i<=n ; i++) ps[i]=ps[i-1]+fin[i];
	for(i=0 ; i<=n ; i++) ps[i]+=n;
	for(i=0 ; i<=n ; i++)
	{
		ret+=query(0,ps[i]+1);
		upd(ps[i],1);
	}
	if(2*ret>=(n+1)*n/2) return true;
	return false;
}

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n; int i;
	for(i=1 ; i<=n ; i++) cin>>vv[i];
	lef=1; rig=1e9+7;
	while(lef<=rig)
	{
		mid=(lef+rig)/2;
		if(isok(mid)) best=mid, lef=mid+1;
		else rig=mid-1;
	}
	cout<<best; return 0;
}



// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 6144
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {


	double l;
	cin >> l;

	l /= 3;


	cout << setprecision(10) << l * l * l << endl;


	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
const int MAXN = 100010;
using namespace std;

int N, M, cnt[MAXN];
char state[MAXN]; //0: No 1: Maybe 2: Must

int main() {
	int i;
	scanf("%d%d", &N, &M);
	for(i = 1; i <= N; i++) cnt[i] = 1;
	state[1] = 2;
	
	while(M--) {
		int x, y;
		scanf("%d%d", &x, &y);
		if(state[x] == 2) {
			if(cnt[x] == 1) {
				state[x] = 0;
				state[y] = 2;
			}
			else {
				state[x] = 1;
				state[y] = 1;
			}
		}
		else if(state[x] == 1) {
			if(state[y] != 2) {
				state[y] = 1;
			}
			if(cnt[x] == 1) state[x] = 0;
		}
		cnt[x]--, cnt[y]++;
	}

	int Ans = 0;
	for(i = 1; i <= N; i++) if(state[i]) Ans++;
	printf("%d", Ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/
int gcd(int a, int b) {
	if (a==b || b==0) {return a;}
	if (b>a) {return gcd(b,a);}
	return gcd(b,a%b);
	}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int x;
	cin>>x;
	cout<<360/gcd(360,x)<<endl;
    return 0;
}


Measured memory_bytes: 3648
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

long long A, B;

int main()
{
	scanf("%lld %lld", &A, &B);

	if(B >= A) {
		printf("%lld\n", A);
	}
	else {
		printf("%lld\n", A - 1);
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/
	

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
ans = 100 * A, 0
w = set()
for a in range(0, F + 1, 100 * A):
    for b in range(0, F - a + 1, 100 * B):
        if a + b:
            w.add(a + b)
s = set()
for c in range(0, F + 1, C):
    for d in range(0, F + 1 - c, D):
        s.add(c + d)
for wi in w:
    for sj in s:
        if wi + sj <= F and 100 * sj / wi <= E:
            ans = max(ans, (wi + sj, sj), key=lambda x: x[1] / x[0])

print(*ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,m;

vector<P> vp[100000];

string make(int num){
	string res = "000000";
	rep(i,6){
		res[i] += num%10;
		num /= 10;
	}
	reverse(ALL(res));
	return res;
}

int main(){
	cin >> n >> m;
	rep(i,m){
		int p,y;
		cin >> p >> y;
		p--;
		vp[p].push_back(P(y,i));
	}
	rep(i,n){
		if(vp[i].size() == 0)continue;
		sort(ALL(vp[i]));
	}
	vector<string> vs;
	vs.resize(m);
	rep(i,n){
		rep(j,vp[i].size()){
			string s = make(i+1);
			s += make(j+1);
			vs[vp[i][j].second] = s;
		}
	}
	rep(i,m){
		cout << vs[i] << endl;
	}
}


Measured memory_bytes: 12416
#include<iostream>
#include<vector>
#define MAX 1000010
using namespace std;
int prime[MAX];
bool is_prime[MAX];
void prime_make(int n){
	int p=0;
	for(int i=0;i<=n;i++)
	is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=i*2;j<=n;j+=i)
			is_prime[j]=false;
		}
	}
}
int main(){
	int n,m;
	prime_make(MAX);
	while(cin>>n>>m,n||m){
		bool dp[MAX];
		int p[40];
		vector<int> box;
		for(int i=0;i<=m;i++)
		dp[i]=0;
		dp[0]=1;
		for(int i=0;i<n;i++)
			cin>>p[i];
		for(int i=0;i<=m;i++){
			for(int j=0;j<n;j++){
				if(i-p[j]>=0&&dp[i-p[j]]){
					//cout<<i<<endl;
					dp[i]=1;
					box.push_back(i);
					break;
				}
			}
		}
		int ans=-1;
		for(int i=box.size()-1;i>=0;i--){
			int j;
			for(j=0;prime[j]<box[i];j++){
				if(box[i]%prime[j]==0){
			//		cout<<box[i]<<endl;
					break;
				}
			}
			if(prime[j]>=box[i]){
				ans=box[i];
				break;
			}
		}
		if(ans==-1)
		cout<<"NA"<<endl;
		else
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 7204
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    long long n, k;
    cin >> n >> k;
    long long g = n % k;
    cout << min(g, abs(g - k)) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    if(str[0]=='7'||str[1]=='7'||str[2]=='7')
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define MEM(a,b) memset(a,b,sizeof(a));
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int rn = uniform_int_distribution<int>(0, MAXN)(rng);
    
    ll n,m;
    string str1, str2;
    cin>>n>>m;
    cin>>str1>>str2;

    if(n<m) {
        swap(n,m); swap(str1, str2);
    }

    ll l = (n*m)/__gcd(n,m);
    
    map<int, char> mp;
    REP(i,n) mp[i*(l/n)+1] = str1[i];
    bool flag = true;
    REP(i,m) {
        if(mp.find(i*(l/m)+1) != mp.end() && mp[i*(l/m)+1] != str2[i]) {
            flag = false;
            break;
        }
    }
    if(flag) cout<<l;
    else cout<<"-1";
    
    
    // if(n%m != 0) {
    //     if(str1[0] == str2[0]) cout<<lcm;
    //     else cout<<"-1"; 
    // }
    // else {
    //     assert(0);
    //     ll k = n/m;
    //     ll l = 0, r = 0;
    //     bool flag = true;
    //     while(l<n && r<m) {
    //         if(str1[l] != str2[r]) {
    //             flag = false; break;
    //         } else {
    //             l += k;
    //             r += 1;
    //         }
    //     }
    //     if(flag) cout<<lcm;
    //     else cout<<"-1";
    // }
    return 0;
}

Measured memory_bytes: 4992