akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 5100;
PII t[MAX];
int n;
int dp[MAX][MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n){
    cin >> t[i].FI >> t[i].SE;
  }
  sort(t, t + n, [](PII a,PII b){
    return a.FI + a.SE < b.FI + b.SE;
  });
  R(i,MAX)R(j,MAX)dp[i][j] = 1e15;
  dp[0][0] = 0;
  R(i,n)R(j,i+1){
    mini(dp[i+1][j], dp[i][j]);
    if(dp[i][j] <= t[i].FI){
      mini(dp[i+1][j+1], dp[i][j] + t[i].SE);
    }
  }
  int res = 0;
  R(i,n+1)if(dp[n][i] < 1e14){
    maxi(res,i);
  }
  cout << res << "\n";
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

int dp[3][100005] ;
int cost[3] ;

int win ( char c )
{
    if ( c == 'r' )
        return 2 ;

    else if ( c == 'p' )
        return 1 ;

    else
        return 0 ;
}

void solve ( int test_case )
{
    int n , k ;
    cin >> n >> k ;

    for ( int i=0 ; i < 3 ; i ++ )
        cin >> cost[i] ;

    string con ;
    cin >> con ;

    for ( int j = 0 ; j < n ; j ++ )
    {
        int win_indx = win ( con[j] ) ;
        dp[win_indx][j] += cost[win_indx] ;

        if ( j >= k )
        {
            dp[0][j] += max ( dp[1][j - k] , dp[2][j - k] ) ;
            dp[1][j] += max ( dp[2][j - k] , dp[0][j - k] ) ;
            dp[2][j] += max ( dp[0][j - k] , dp[1][j - k] ) ;
        }
    }

    int ans = 0 ;
    for ( int j=0 ; j < k ; j ++ )
    {
        int temp = -1 ;
        for ( int i = 0 ; i < 3 ; i ++ )
            temp = max ( temp , dp[i][n - 1 - j] ) ;

        ans += temp ;
    }

    cout << ans ; line
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
int main(){
    int B=1,C=0,D=0,F,G=0,H=0,I=0,S;
    string A;
    cin >> A;
    S=A.size();
    for(int i=0;i<S;i++){
        C=0;
        for(int j=i;j<S;j++){
            if(A[j]=='A'||A[j]=='T'||A[j]=='G'||A[j]=='C'){
                C++;
                if(C>D)D=C;
            }
            else C=0;
        }
    }
    cout << D << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

int main(){
    ll ans = 0;
    ll N,R = 0,B = 0,G = 0;
    string S;
    cin >> N >> S;
    rep(i,N){
        if(S[i] == 'R'){
            R++;
            S[i] = '1';
        }else if(S[i] == 'B'){
            B++;
            S[i] = '2';
        }else if(S[i] == 'G'){
            G++;
            S[i] = '9';
        }
    }
    rep(i,N){
        ll cnt = 0;
        FOR(j,1,min(i,N-i-1)+1){
            if((S[i-j] - '0') + (S[i+j] - '0') + (S[i] - '0') == 12) cnt++;
        }
        ans -= cnt;
    }
    ans += R * B * G;
    cout << ans << endl;
}


Measured memory_bytes: 3632
#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 comb(int a, int b){
  if (a < b) return 0;
  int c=1, m=1;
  rep(i, b) m *= (a-i);
  rep(i, b) c *= (b-i);
  return m / c;
}

int main() {
  int n, m;
  cin >> n >> m;

  cout << comb(m, 2) + comb(n, 2) << endl;
  return 0;
}

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

using ll=long long;
const int SIZE=2*1e5+3;
int main(){
    int n,m; cin>>n>>m;
    vector<int> cntA(SIZE);
    map<int,int> mpB;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        cntA[a]++;
    }
    for(int i=0;i<m;i++){
        int b; cin>>b;
        mpB[b]++;
    }
    vector<ll> event(SIZE);
    for(auto& e:mpB){
        int x=e.first;
        for(int i=x;i<SIZE;i+=x){
            event[i]-=ll(e.first)*e.second;
        }
    }

    ll sum=0;
    ll res=0;
    for(int i=0;i<SIZE;i++){
        sum+=event[i];
        res+=sum*cntA[i];
        sum+=m;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 14324
def inint(): return int(input())
def inlint(): return list(map(int, input().split()))
def infloat(): return float(input())
def inlffloat(): return list(map(float, input().split()))
def inl(): return list(input())
def putlint(): return "".join(list(map(str, ans)))

a,b = inlint()

a=a+b
if a>23:
    a=a-24

print(a)

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll d1=(a1-b1)*t1, d2=(a2-b2)*t2;
    if(d1>0){
        d1*=-1, d2*=-1;
    }

    if(d2<0) cout << 0 << endl;
    else if(d1+d2==0) cout << "infinity" << endl;
    else if(d1+d2<0) cout << 0 << endl;
    else{
        ll ans=2*(ll)((-d1)/(d1+d2));
        if((-d1)%(d1+d2)!=0) ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    let m = (sum as) `div` n
    print $ min (sum (map (\a -> (a - m)^2) as)) (sum (map (\a -> (a - m - 1)^2) as))

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

int main() {
	int S, W;
	cin >> S >> W;

	if(S <= W)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;

	return 0;
}

Measured memory_bytes: 3624
import math
a, b, c = map(int, input().split())
h = b * math.sin(math.radians(c))
s = a * h * 1 / 2
l = a + b + math.sqrt(a ** 2 + b ** 2 -
                      2 * a * b * math.cos(math.radians(c)))
print(s, l, h)


Measured memory_bytes: 5704
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int a,b,c,d,l,cnt=0;
	scanf("%d%d%d%d%d",&l,&a,&b,&c,&d);
	while(a>0 || b>0){
		a-=c;
		b-=d;
		cnt++;
	}
	printf("%d\n",l-cnt);
	return 0;
}

Measured memory_bytes: 1192
a=[list(map(int,input().split())) for j in range(3)]
n = int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
              a[j][k]=0
ans="No"

for i in range(3):
    if a[0][i]==a[1][i]==a[2][i]==0:
      ans="Yes"
    if a[i][0]==a[i][1]==a[i][2]==0:
      ans="Yes"
    if a[0][0]==a[1][1]==a[2][2]==0:
      ans="Yes"
    if a[2][0]==a[1][1]==a[0][2]==0:
      ans="Yes"
print(ans)


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

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

// the code that we provide requires everything above this line to compile

int N;
int dp[100000], h[100000];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> h[i];
    
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < N; i++)
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    cout << dp[N - 1];
}


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

#define ll long long
#define pll pair<ll,ll> 
vector<ll> M;
ll  func(ll A[],ll n,ll p, ll x,ll k){
	if(p==n-1)
		return 0;
	if(p>=n-1)
		return INT_MAX;
	ll &ans=M[p];
	if(ans==-1){
		ans=INT_MAX;
		for(ll i=1;i<=k && (i+p)<n;i++){
		ans=min(ans, func(A, n,p+i,A[p],k)+abs(A[p]-A[p+i]));
		}
	}
	return ans;
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n,k;
	cin>>n>>k;
	ll A[n];
	M.resize(n,-1);
	for(ll i=0;i<n;i++)
		cin>>A[i];
	
	cout<<func(A,n,0, 0,k);



}


Measured memory_bytes: 12660
#include <iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int BLACK=2;
static const int GRAY=1;
int n,M[MAX][MAX];
int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }
    
    d[0]=0;
    while(1){
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1)sum+=M[i][p[i]];
    }
    return sum;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int e;cin>>e;
            M[i][j]=(e==-1)?INFTY:e;
        }
    }
    cout<<prim()<<endl;
    return 0;
}



Measured memory_bytes: 3124
// https://atcoder.jp/contests/abc165/tasks/abc165_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
    [[nodiscard]]
#elif defined(__GNUC__) && \
    (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
    __attribute__((warn_unused_result))
#endif
    FixPoint : private F {
 public:
  explicit constexpr FixPoint(F && f) noexcept : F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
      noexcept(noexcept(
          F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) makeFixPoint(F&& f) noexcept {
  return FixPoint<F>{std::forward<F>(f)};
}

void solve() {
  ll N, M, Q;
  cin >> N >> M >> Q;

  struct Const {
    ll a, b, c, d;
  };

  V<Const> cs(Q);

  rep(i, Q) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b;
    cs[i] = {a, b, c, d};
  }

  ll res = 0;

  auto dfs = makeFixPoint([&](auto f, ll len, VL& arr) -> void {
    if (len == N) {
      ll sum = 0;

      for (auto c : cs) {
        if (arr[c.b] - arr[c.a] == c.c) sum += c.d;
      }

      chmax(res, sum);
      return;
    }

    ll last_value = len == 0 ? 1 : arr[len - 1];

    for (ll v = last_value; v <= M; ++v) {
      arr[len] = v;
      f(len + 1, arr);
    }
  });

  VL arr(N, 0);
  dfs(0, arr);

  cout << res << "\n";
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi cnt(n);
  for(int i = 1; i <= n; i++){
    for(int j = 0; j < n; j += i){
      cnt[j]++;
    }
  }
  ll ans = 0;
  for(int i = 1; i < n; i++) ans += cnt[i];
  cout << ans;
  return 0;
}


Measured memory_bytes: 7136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x) cerr<<#x<<"="<<x<<endl;
#define forin(a,b) for(ll i=(a); i<(b); i++) 
#define forjn(a,b) for(ll j=(a); j<(b); j++)

int main()
{
	ll n;
	cin>>n;
	ll val = n%1000;
	ll change = (val!=0) ? 1000-val : 0;
	cout<<change<<endl;
}

Measured memory_bytes: 3632
loop do
  n = gets.to_i
  break if n.zero?
  a, b, c, d = 0, 0, 1, 0
  n.times do
    d = a + b + c
    a, b, c = b, c, d
  end
  q = 365 * 10
  p (d + (q - 1)) / q
end

Measured memory_bytes: 8616
#include<iostream>
#include<math.h>
using namespace std;
int digitSum(int N) {
	int t = 0;
	while (N % (int)pow(10, t) != N) {
		t++;
	}
	int ans = 0;
	int tmp = 0;
	for (int i = 0; i < t; i++) {
		tmp = N % (int)pow(10, i+1);
		ans += tmp/(int)pow(10, i);
	}
	return ans;
}

int main()
{
	int N,A,B,ans,sum;
	cin >> N;
	if (N == 2) {
		cout << 2 << endl;
		return 0;
	}
	else if (N == 3) {
		cout << 3 << endl;
		return 0;
	}
	for (int i = 1; i < N / 2; i++) {
		A = i;
		B = N - i;
		sum = digitSum(A) + digitSum(B);
		if (i == 1) {
			ans = sum;
		}
		else if(sum < ans){
			ans = sum;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
      int N = in.nextInt();
      int M = N / 1000;
       if (N%1000 == 0)
            System.out.println(0);
       else if (N > 1000)
            System.out.println((M+1)* 1000 - N);
       else 
         System.out.println(1000-N);
    }
}

Measured memory_bytes: 35652
#include <iostream>
#include <algorithm>
using namespace std;
int n,t,ans,b;
int main(void){
    cin>>n>>t>>b;
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        if(b+t<a)ans+=t;
        else ans+=(a-b);
        b=a;
    }
    cout<<ans+t<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

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

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b, c, d;

	cin >> a >> b >> c >> d;

	int dis1 = abs(c - a);
	int dis2 = abs(b - a);
	int dis3 = abs(c - b);

	if(dis1 <= d){
		cout << "Yes" << endl;
	}else if(dis2 <= d){
		if(dis3 <= d){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#define MOD1 1e9 + 7
#define MOD2 1e9 + 9
#define inf  (int)2e9
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))



using namespace std;


typedef long long ll;

int main() {

    double n;
    SCLF(n);
    double a = n / 3;
    double ans = a * a * a;
    printf("%lf", ans);
    return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int a,b,k; cin >> k >> a >> b;
  for(int i=1;;i++){
    int x=k*i;
    if(a<=x&&x<=b){
      puts("OK");
      return 0;
    }

    if(b<x){
      puts("NG");
      return 0;
    }
  }
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int n;
int a[4005];
char col[4005];
int cw[2005][2005];
int cb[2005][2005];
int b[2005];
int w[2005];
int counts_b[2005];
int counts_w[2005];
int dp[2005][2005];

int main() {
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> col[i] >> a[i];
    a[i]--;
    if (col[i] == 'W') w[a[i]] = i;
    else b[a[i]] = i;
  }

  for (int i = 0; i < n; i++) {
    int count_b = 0;
    int count_w = 0;
    for (int j = 0; j < i; j++) {
      if (b[i] < b[j]) count_b++;
      if (w[i] < w[j]) count_w++;
    }
    counts_b[i] = count_b;
    counts_w[i] = count_w;
  }

  cb[0][0] = 0;
  cw[0][0] = 0;
  for (int i = 0; i < n; i++) {
    cb[i][0] = counts_b[i];
    cw[i][0] = counts_w[i];
    int count_b = counts_b[i];
    int count_w = counts_w[i];
    for (int j = 0; j < n; j++) {
      if (b[i] < w[j]) count_b++;
      if (w[i] < b[j]) count_w++;
      cb[i][j + 1] = count_b;
      cw[i][j + 1] = count_w;
    }
  }

  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] + cb[i - 1][0];
    dp[0][i] = dp[0][i - 1] + cw[i - 1][0];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = min(dp[i - 1][j] + cb[i - 1][j], dp[i][j - 1] + cw[j - 1][i]);
    }
  }
  cout << dp[n][n];
}


Measured memory_bytes: 47360
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int N,K,C;
int A[100001];
int B[100001];
vector<int> ans;



int main(){
    cin >> N >> K;
    cout << (N+K-1)/K << endl;
    
}

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

const long long MOD = 998244353;
using ll = long long;

void solve(long long N, long long S, std::vector<long long> A){
    vector<vector<ll>> dp(N + 1, vector<ll>(S + 1));
    dp[0][0] = 1;
    for(int i = 0;i < N;i++){
        for(int j = 0;j <= S;j++){
            dp[i][j] %= MOD;
            dp[i+1][j] += dp[i][j] * 2;
            if(A[i] + j <= S){
                dp[i+1][A[i] + j] += dp[i][j];
            }
        }
    }
    cout<<dp[N][S]%MOD<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long S;
    scanf("%lld",&S);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, S, std::move(A));
    return 0;
}


Measured memory_bytes: 73752
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

int main(){
    string  S;
    cin >> S;
    ll ans = 0;
    ll tmp_ans = 0;
    rep(i,3){
        if(S[i] == 'R'){
            tmp_ans++;
            ans = max(tmp_ans,ans);
        }
        else{
            tmp_ans = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	vector<string>p;
	for (int i = 0; i < a; i++) {
		string g;
		cin >> g;
		p.push_back(g);
	}
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			int r = 0;
			for (int y = -1; y < 2; y++) {
				if (y + i < 0)continue;
				if (y + i >= a)break;
				
				for (int x = -1; x < 2; x++) {
					if (x + j < 0)continue;
					if (x + j >= b)break;
					if (p[y + i][x + j] == '#')r++;
				}
			}
			if (p[i][j] != '#')p[i][j] = r + '0';
		}
	}
	for (int i = 0; i < a; i++) {
		cout << p[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
const int mod = 1000000007;

int S;
ll dp[2005];
int main() {
  cin >> S;
  dp[0] = 1;
  rep2(i,3,S) {
    rep2(j, 0, i-3) {
      (dp[i] += dp[j]) %= mod;
    }
  }
  printf("%lld\n", dp[S]);
  return 0;
}


Measured memory_bytes: 3764
import java.io.PrintWriter;
import java.util.*;

public class Main {
    int n, q;
    int[] s, t, x;
    int[] ds;
    int[] d;
    long INF = 1L << 60;

    // d + xi が [li, ri) に含まれる最初のxi
    // li <= d + xi < ri
    // li - xi <= d < ri - xi

    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        q = sc.nextInt();
        s = new int[n];
        t = new int[n];
        x = new int[n];

        PriorityQueue<Event> que = new PriorityQueue<>();

        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();

            que.add(new Event(s[i] - x[i], x[i], 1));
            que.add(new Event(t[i] - x[i], x[i], 0));
        }

        ds = new int[q];
        int c = 0;
        for (int i = 0; i < q; i++) {
            ds[i] = sc.nextInt();
            que.add(new Event(ds[i], i, 2));
        }

        TreeSet<Integer> set = new TreeSet<>();
        int[] ans = new int[q];
        while (!que.isEmpty()) {
            Event e = que.remove();
            switch (e.type) {
                case 0:
                    set.remove(e.idx);
                    break;
                case 1:
                    set.add(e.idx);
                    break;
                case 2:
                    ans[e.idx] = set.isEmpty() ? -1: set.first();
            }
//            debug(e.t, e.type, e.idx, set);
        }
        PrintWriter out = new PrintWriter(System.out);
        for (int i = 0; i < q; i++) {
            out.println(ans[i]);
        }
        out.flush();
    }

    class Event implements Comparable<Event> {
        int t;
        int idx;
        // 0: end, 1: start, 2: query
        int type;

        Event(int t, int idx, int type) {
            this.t = t;
            this.idx = idx;
            this.type = type;
        }

        @Override
        public int compareTo(Event o) {
            if (t == o.t) {
                return type - o.type;
            }
            return t - o.t;
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 208304
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn dist(x: (i64, i64), y: (i64, i64)) -> i64 {
    (x.0 - y.0).abs() + (x.1 - y.1).abs()
}

fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.cin();
    let w: usize = sc.cin();
    let d: usize = sc.cin();

    let mut pos = vec![(0, 0); h * w + d + 3];
    for i in 0..h {
        for j in 0..w {
            let a: usize = sc.cin();
            pos[a - 1] = (i as i64, j as i64);
        }
    }

    let mut memo = vec![0; h * w + d + 10];
    // memo[i] = sum [0, d, 2d, .., i)
    for i in 0..(h * w) {
        memo[i + d] = memo[i] + dist(pos[i], pos[i + d]);
        // trace!(i + d, memo[i + d]);
    }
    // trace!(&memo);

    let q: usize = sc.cin();
    for _ in 0..q {
        let l = sc.cin::<usize>() - 1;
        let r = sc.cin::<usize>() - 1;
        put!(memo[r] - memo[l]);
    }
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 10620
import java.util.*;
import java.lang.*;

public class Main {

    static int n;
    static int[] a;
    static int count;
    
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        count = 0;
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        mergeSort(0, n);
        for (int i = 0; i < n; i++) {
            System.out.print(a[i]);
            if (i != n - 1) {
                System.out.print(' ');
            }
        }
        System.out.println();
        System.out.println(count);
    }
    
    static void merge(int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        int[] l = new int[n1 + 1];
        int[] r = new int[n2 + 1];
        
        for (int i = 0; i < n1; i++) {
            l[i] = a[left + i];
        }
        for (int i = 0; i < n2; i++) {
            r[i] = a[mid + i];
        }
        l[n1] = Integer.MAX_VALUE;
        r[n2] = Integer.MAX_VALUE;
        int i = 0, j = 0;
        for (int k = left; k < right; k++) {
            if (l[i] <= r[j]) {
                a[k] = l[i];
                i++;
            } else {
                a[k] = r[j];
                j++;
            }
            count++;
        }
    }

    static void mergeSort(int left, int right) {
        if (left + 1 >= right) {
            return;
        }
        int mid = (left + right) / 2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
        /*
         System.out.print("(" + left + ", " + right + ")  ");
        for (int i = 0; i < n; i++) {
            System.out.print(a[i]);
            if (i != n - 1) {
                System.out.print(' ');
            }
        }
        System.out.println();
         */
        return;
    }
}



Measured memory_bytes: 174256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const ll INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

vector<vector<pii>> blocks(4);
vector<string> draw(4);
bool ins(int y, int x){
	return y>=0&&y<4&&x>=0&&x<10;
}

bool solve(int y, int x, int place){
	if(place==3)return true;
	if(draw[y][x]=='#')return solve(y+(x+1)/10, (x+1)%10, place);
	vector<pii> logger;
	bool flag = true;
	foreach(i, blocks[place]){
		if(!ins(y+i.first, x+i.second)){
			flag = false;
			break;
		}
		if(draw[y+i.first][x+i.second]=='#'){
			flag = false;
			break;
		}
		draw[y+i.first][x+i.second]='#';
		logger.push_back(pii(y+i.first, x+i.second));
	}
	if(!flag){
		foreach(i, logger)draw[i.first][i.second]='.';
		return false;
	}
	bool res = solve(y+(x+1)/10, (x+1)%10, place+1);
	foreach(i, logger)draw[i.first][i.second]= '.';
	return res;
}

bool func(){
	foreach(i, draw){
		cin >> i;
	}
	sort(all(blocks));
	do{
		if(solve(0, 0, 0))return true;
	}while(next_permutation(all(blocks)));
}

int main(){
	rep(i, 4){
		int h, w;
		cin >> h >> w;
		bool flag = false;
		int sx = 0;
		int sy = 0;
		rep(y, h){
			rep(x, w){
				char d;
				cin >> d;
				if(d=='#'){
					if(!flag){
						sx = x;
						sy = y;
						flag = true;
					}
					blocks[i].push_back(pii(y-sy, x-sx));
				}
			}
		}
	}
	int n;
	cin >> n;
	rep(i, n){
		cout << (func()?"Yes":"No") << endl;
	}


	return 0;
}



Measured memory_bytes: 3216
MOD = 10 ** 9 + 7
n, k = map(int, input().split())

def calc(a):
    smallest = a * (a-1) // 2
    largest = smallest + a * (n-a+1)
    return largest - smallest + 1


ans = 0
for a in range(k, n+2):
    ans += calc(a)
    ans %= MOD

print(ans)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=100000000000000000;
ll MOD=1000000007;

ll mpow(ll x, ll n){
ll ans = 1;
while(n != 0){
if(n&1) ans = ans*x % MOD;
x = x*x % MOD;
n = n >> 1;
}
return ans;
}
ll kj(ll x){
ll s = 1;
for(ll i = 1; i <= x; i++){
s = s * i % MOD;
}
return s;
}
ll combination(ll a, ll b){
if(a == 0 && b == 0) return 1;
if(a < b || a < 0) return 0;
return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n+1);
    ll ans=1,r;
    r=mpow(2,n);
    a.at(0)=1;
    for (ll i=1;i<n+1;i++){
        if (i<m) {ans=ans*2%MOD;a.at(i)=ans;continue;}
        else if (i==m) ans=(ans*2-1)%MOD;
        else ans=(ans*2-a.at(i-m-1))%MOD;
        a.at(i)=ans;
    }
    cout << (MOD+r-ans)%MOD << endl;
}



Measured memory_bytes: 3588
# f(cu) = cu円取り出すのに必要な最小回数
import numpy as np

N = int(input())

dp = dict()
dp[0] = 0
for n in range(1, N+1):
  ans = dp[n-1] + 1
  
  x = 6
  while x <= n:
    ans = min(ans, dp[n-x]+1)
    x *= 6
  
  x = 9
  while x <= n:
    ans = min(ans, dp[n-x]+1)
    x *= 9
    
  dp[n] = ans
  
print(dp[N])
    

Measured memory_bytes: 24104
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

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

	int N;
	int A[100100], B[100100];
	while (cin >> N) {
		for (int i=0; i<N; i++)
			cin >> A[i];

		if (N == 2) {
			cout << abs(A[0] - A[1]) << '\n';
			continue;
		}

		B[0] = 0;
		B[1] = abs(A[0] - A[1]);
		for (int i=2; i<N; i++)
			B[i] = min(abs(A[i] - A[i-1]) + B[i-1],
					abs(A[i] - A[i-2]) + B[i-2]);

		cout << B[N-1] << '\n';
	}
	return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author math2do
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int t = in.nextInt();

            int[] cost = new int[n];
            int[] time = new int[n];
            for (int i = 0; i < n; i++) {
                cost[i] = in.nextInt();
                time[i] = in.nextInt();
            }
            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                if (time[i] <= t) ans = Math.min(ans, cost[i]);
            }
            if (ans == Integer.MAX_VALUE) out.println("TLE");
            else out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21204
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf8");

const range = (n: number) => Array.from(Array(n), (_, i) => i);

const N = BigInt(input);

const getNo = (n: bigint): string => {
  const alphabets: string[] = Array.from(Array(26), (_, i) => String.fromCharCode("a".charCodeAt(0) + i));

  const getNo = (n: bigint, l: bigint): string => {
    const m = 26n ** l;
    if (n <= m) {
      return range(Number(l)).reduce(
        ({ num, str }, _) => {
          return {
            num: num / 26n,
            str: alphabets[Number(num % 26n)] + str,
          };
        },
        { num: n - 1n, str: "" }
      ).str;
    } else {
      return getNo(n - m, l + 1n);
    }
  };

  return getNo(n, 1n);
};

console.log(getNo(N));


Measured memory_bytes: 29624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long dig_sum(long long x) {
  long long sum=0;
  while (x>0) {
    sum += x%10;
    x = x/10;
  }
  return sum;
}

int main() {
  ll n;
  cin >> n;
  if (n%dig_sum(n)==0) cout << "Yes";
  else cout << "No";
}

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

typedef long long ll;

string s;

int main() {
    cin >> s;

    stack <char> sta;
    rep(i, s.size()) {
        // cout << s[i] << endl;
        if (s[i] == 'B') {
            if (sta.size() > 0) {
                sta.pop(); 
            }
        } else {
            sta.push(s[i]);
        }
    }

    string ans = "";
    while (!sta.empty()) {
        char d = sta.top();
        sta.pop();
        // cout << d << endl;
        ans += d; 
    }
   
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//                    #include <ext/pb_ds/assoc_container.hpp>
//                    #include <ext/pb_ds/tree_policy.hpp>

                    using ll = long long;
                    using ld = long double;
                    #define rep(i, a, n) for(ll i = (a); i < (n); i++)
                    #define per(i, a, n) for(ll i = (n-1); i >= (a); i--)
                    #define F first
                    #define S second
                    #define maxx(a, b) a = max(a, b)
                    #define minn(a, b) a = min(a, b)
                    #define db(x) cerr << #x << " = " << x << endl
                    #define N 1111111
                    #define mod 1000000007
                    #define rt return
                    #define inf 1234567891123456789ll

                    using namespace std;
                    random_device rd;
                    mt19937 mt(rd());
//                    using namespace __gnu_pbds;
//
//                    typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

                    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

                    void err(istream_iterator<string> it) {}
                    template<typename T, typename... Args>
                    void err(istream_iterator<string> it, T a, Args... args)
                    {
                        cerr << *it << " = " << a << endl;
                        err(++it, args...);
                    }

                    ll modlaber(ll a, ll m = mod)
                    {
                        rt ((a+m)%m+m)%m;
                    }

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

                        ld a,b,h,m; cin>>a>>b>>h>>m;
                        ld hour = h*30+m*0.5;
                        ld minu = m*6;
//                        error(hour,minu);
                        if(hour == 0)
                            hour = 360;
                        if(minu == 0)
                            minu = 360;
                        cout.precision(10);
                        cout<<fixed;
                        cout<<sqrt(a*a+b*b-2*a*b*cos(acos(-1)/180*fabs(hour-minu)));

                        rt 0;
                    }























Measured memory_bytes: 4160
N,K,*A=map(int,open(0).read().split())
a=0
b=0
for i in range(N):
    for j in range(N):
        if A[j]>A[i]:
            a+=1
            if j<i:b+=1
print((b*K+a*K*(K-1)//2)%(10**9+7))


Measured memory_bytes: 70452
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (1000006)
#define MOD (1000000007)


// べき乗余
int64_t modpow(int64_t b, int64_t e)
{
    int64_t result = 1;
    while(e>0)
    {
        if(e&1) result = (result * b) % MOD;
        e >>= 1;
        b = (b * b) % MOD;
    }
    return result;
}

// 組み合わせ数
// nCk % MOD
ll cf[MAXN+1]; // 1*2*3*...*i
ll ci[MAXN+1]; // 1/ 1*2*3*...*i
void CombInit(ll n)
{
    cf[0] = 1;
    for(int i=1;i<=n;i++) cf[i] = cf[i-1] * i %MOD;
    ci[n] = modpow(cf[n],MOD-2);
    for(int i=n-1;i>=0;i--) ci[i] = ci[i+1] * (i+1) %MOD;
}
ll Comb(ll a,ll b)
{
    return cf[a]*ci[b]%MOD*ci[a-b]%MOD;
}
// カタラン数 2nまで参照することに注意
ll Catalan(ll n)
{
    return cf[2*n]*ci[n+1]%MOD*ci[n]%MOD;
}



int main(void)
{
    ll x,y;
    scanf("%ld %ld",&x,&y);
    CombInit(MAXN);

    if((x+y)%3!=0)
    {
        printf("0\n");
        return 0;
    }
    ll c2 = x - ((x+y)/3);
    ll c1 = ((x+y)/3) - c2;
    if(c2<0||c1<0)
    {
        printf("0\n");
        return 0;
    }
    printf("%ld\n",cf[c1+c2]*ci[c1]%MOD*ci[c2]%MOD);
    return 0;
}


Measured memory_bytes: 15872
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
auto xor_fn = [](auto x, auto y) { return x ^ y; };
void err() {
    std::cout << -1 << '\n';
    exit(0);
}
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 n; std::cin >> n;
    auto compress = [n](auto a) {
        vec<u32> m = a;
        std::sort(ALL(m));
        m.resize(std::unique(ALL(m)) - m.begin());
        for (u32& x: a) x = std::lower_bound(ALL(m), x) - m.begin();
        return a;
    };
    vec<u32> a(n), b(n);
    for (u32& x: a) std::cin >> x;
    for (u32& x: b) std::cin >> x;
    a.push_back(std::accumulate(ALL(a), u32{0}, xor_fn));
    b.push_back(std::accumulate(ALL(b), u32{0}, xor_fn));
    {
        auto a_ = a;
        auto b_ = b;
        std::sort(ALL(a_));
        std::sort(ALL(b_));
        if (a_!=b_) err();
    }

    a = compress(a);
    b = compress(b);
    u32 sz = 1 + *std::max_element(ALL(a));
    vec<vec<u32>> g(sz);
    REP (i, n+1) if (a.at(i)!=b.at(i)) {
        g.at(a.at(i)).push_back(b.at(i));
        g.at(b.at(i)).push_back(a.at(i));
    }

    vec<u32> ckd(sz);
    auto dfs = [&](auto&& f, u32 x) -> void {
        ckd.at(x) = true;
        for (u32 y: g.at(x)) if (!ckd.at(y)) f(f, y);
    };

    u32 ans = 0;
    REP (i, sz) ans += g.at(i).size();
    ans /= 2;
    for (u32 i=0; i<sz; i++) if (!ckd.at(i)) {
        dfs(dfs, i);
        if (!g.at(i).empty()) ans++;
    }
    if (!g.at(a.at(n)).empty()) {
        if (a.at(n)!=b.at(n)) ans-=2;
        else ans--;
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 9040
n = int(input())
li = []
for _ in range(n):
    li.append(int(input()))

idx = 0
tryed = 0
for _ in range(10 ** 5):
    idx = li[idx]-1
    tryed += 1
    if idx == 1:
        print(tryed)
        break
else:
    print('-1')

Measured memory_bytes: 7084