akhauriyash/Code-Regression huggingface dataset:
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     mt           make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1e3+10;

int dp[N][N];

vector<string> mat;
int n,m;

bool valid(int x,int y)
{
    return (x>=0 && x<n && y>=0 && y<m && mat[x][y]!='#');
}

int rec(int x,int y)
{
    if(x==0 && y==0)
        return 1;

    if(dp[x][y]!=-1)
        return dp[x][y];

    int res=0;

    if(valid(x-1,y))
        res=(res+rec(x-1,y))%M;
    if(valid(x,y-1))
        res=(res+rec(x,y-1))%M;

    return (dp[x][y]=res);
}

void solve()
{
    mem(dp,-1);

    cin>>n>>m;

    mat.resize(n);
    for(int i=0;i<n;++i)
        cin>>mat[i];

    cout<<rec(n-1,m-1);
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 9344
import sys
from collections import deque
import math

input = sys.stdin.readline


def solve():
    n_days, n_hw = map(int, input().split())
    a = list(map(int, input().split()))
    n_days_left =  n_days - sum(a)

    if n_days_left < 0:
        return -1
    else:
        return n_days_left



if __name__ == '__main__':
    answer = solve()
    print(answer)


Measured memory_bytes: 9936
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i > 0; i--)
#define reps(i, m, n) for(int i = m; i <= n; i++)
#define reprs(i, m, n) for(int i = n; i >= m; i--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}


int main(){

  double N,K;
  cin >> N>>K;

  double ans=0;

  reps(i,1,N){
    int poi=i;
    double poss=1/N;
    while(poi<K){
      poi=poi*2;
      poss=poss/2;
    }
    ans+=poss;
  }

  std::cout << std::fixed;
  cout << std::setprecision(15) << ans <<endl;
  return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll answer;
    for (int i = 1; i <= 9; i++)
    {
        answer = i * 111;
        if (answer >= N)
        {
            break;
        }
    }
    cout << answer << endl;
    return 0;
}


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

typedef pair<int, int> P;

int main() {
    int N, K;  cin >> N >> K;
    if (K > (N - 1) * (N - 2) / 2) {
        cout << -1 << endl;
        return 0;
    }

    vector<P> G;
    for (int i = 1; i < N; ++i) {
        G.push_back(P(0, i));
    }
    int cnt = (N - 1) * (N - 2) / 2 - K;
    int i = 1, j = 2;
    while (cnt--) {
        if (j == N) {
            ++i;
            j = i + 1;
        }
        G.push_back(P(i, j));
        ++j;
    }
    cout << G.size() << endl;
    for (P e : G) {
        cout << e.first + 1 << " " << e.second + 1 << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	string nd = "CODEFESTIVAL2016";
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < (int)nd.size(); i++) {
		ans += (s[i] != nd[i]);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3140
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long res = (((pow(10, n)% 1000000007  + pow(8, n)% 1000000007))% 1000000007 - 2 * pow(9, n)% 1000000007 + 1000000007)% 1000000007;
        System.out.println(res);
    }

    public static long pow(long a, long n) {
        long res = 1;
        while (n > 0) {
            if (n % 2 == 1) {
                res = ((res % 1000000007) * (a % 1000000007)) % 1000000007;
                n--;
            } else {
                a = ((a % 1000000007) * (a % 1000000007)) % 1000000007;
                n /= 2;
            }

        }
        return res % 1000000007;
    }
}


Measured memory_bytes: 35600
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  int n,ans;
  IN1(n);
  ans = 3*pow(n,2);
  OUT(ans);

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    multiset<int> rest;
    for(int i=0; i<(1<<n); ++i){
        int a;
        cin >> a;
        rest.insert(a);
    }

    vector<int> v(1<<n, -1);
    v[0] = *rest.rbegin();
    rest.erase(--rest.end());

    for(int i=0; i<n; ++i){
        int len = 1 << i;
        for(int i=0; i<len; ++i){
            auto it = rest.lower_bound(v[i]);
            if(it == rest.begin()){
                cout << "No" << endl;
                return 0;
            }
            -- it;
            v[len+i] = *it;
            rest.erase(it);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 13568
#include <unistd.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define istream ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define uint unsigned int
#define mod 1000000007
#define vec vector<int>
#define twod vector<vector<int>>
#define mp make_pair
#define pbc push_back
#define all(a) a.begin(),a.end()
#define debug1(x)                cout<<#x<<"="<<x<<endl;
#define debug2(x,y)              cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z)            cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define debugarray(arr,j,n)      for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";};

int32_t main()
{
     string s,t;
     cin>>s>>t;
     int n = s.size();
     int m = t.size();
     if(!n || !m){
          cout<<"";
          return 0;
     }
     vector<vector<int>> dp(n+1, vector<int> (m+1,0));
     int len=0;
     int row,col;
     for(int i=0;i<=n;i++){
          for(int j=0;j<=m;j++){
               if(i==0 || j==0)
                    dp[i][j] = 0;
               else{
                    if(s[i-1] == t[j-1])
                         dp[i][j] = dp[i-1][j-1]+1;
                    else
                         dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
               }
          }
     }
     string res = "";
     int i=n,j=m;
     while(i>0 && j>0){
          if(s[i-1] == t[j-1]){
               res = s[i-1]+res;
               i--; j--;
          }
          else if(dp[i][j-1]>dp[i-1][j])
               j--;
          else
               i--;
     }
     cout<<res;
     return 0;
}


Measured memory_bytes: 74044
#include <iostream>

int main(){
	int a;
	long double x1,y1,x2,y2,x3,y3,x4,y4;
	std::cin>>a;
	for(int s=0;s<a;s++){
		std::cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)){
			std::cout<<"YES"<<std::endl;
		}else{
			std::cout<<"NO"<<std::endl;
		}
		
    }
    return 0;
}

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

using namespace std;

bool is_prime(int num) {
    if (num > 0 && num <= 2)
        return true;

    if (num % 2 == 0)
        return false;

    float limit = sqrt(num);
    for (int i = 3; i <= limit; i += 2) {
        if (num % i == 0)
            return false;
    }
    return true;
}

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

    int num_of_prime = 0;
    for (int i = 0; i < n; ++i) {
        int num;
        cin >> num;
        if (is_prime(num))
            ++num_of_prime;
    }
    cout << num_of_prime << '\n';
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  long a,b,n,x=0,y=0,ans=100000,c=0;
  cin>>n>>x;
  int aa[n];
  rep(i,0,n) cin>>aa[i];
  int odd=0,even=0;
  rep(i,0,n){
    if(aa[i]%2==0) even++;
    else odd++;
  }
  
  c+=pow(2,even);
  if(odd!=0) c*=pow(2,odd-1);
  if(x==0) co(c);
  else co(long(pow(2,n)-c));
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mod 1000000007
int main()
{ 
    ll p;
    //cin>>p;
    p=1;
    while(p--)
    {
        ll a,b,c,d,e;
        cin>>a>>b>>c;
        if(a%b==0)
        a=a/b;
        else
        a=(a/b)+1;
        cout<<a*c<<endl;
    }
}

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

struct city {
    int p;
    int y;
    int n;
    string id;
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<city> c(m);
    for (int i = 0; i < m; i++) {
        cin >> c[i].p >> c[i].y;
        c[i].n = i;
    }

    sort(begin(c), end(c), [](auto a, auto b) { return a.p == b.p ? a.y < b.y : a.p < b.p ; });
    for (int i = 0, s = -1, t = 1; i < m; i++, t++) {
        if (c[i].p != s) s = c[i].p, t = 1;
        stringstream ss;
        ss << setfill('0') << setw(6) << c[i].p;
        ss << setfill('0') << setw(6) << t;
        c[i].id = ss.str();
    }

    sort(begin(c), end(c), [](auto a, auto b) { return a.n < b.n; });
    for (auto e : c) cout << e.id << endl;
}


Measured memory_bytes: 8576
// セグメント木 の ライブラリ を 使ってみる.
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3233348#1
// 初期化 → 子ノードから再帰的にO(n)
// 区間の最小値、更新→定数個のノードにしかアクセスしないのでO(log n)
// 利点
// 平衡処理が必要ない.
// ノードの個数 n + n / 2 + n / 4 + ... < 2n

// 木の持ち方
// 配列でノードに番号をつける.
// 上の段から、同じ段では左から順に番号を振る.
// この振り方だと, 番号n の 親: (n - 1) / 2 (を切り捨て)
//                          子: 2n + 1, 2n + 2,...
#include <bits/stdc++.h>
using namespace std;
// const int INT_MAX = 2147483647;
// const int MAX_N = 100010;
int n;
int dat[400040];
// 初期化
void init(){
    //全ての値を, INT_MAX にする.
    for(int i = 0; i < n * 2 - 1; i++) dat[i] = 2147483647;
}
 
// 値の更新
// 場所i に 対応する一番下のノードは, n + i - 1
// そこから (n - 1) / 2 を繰り返して親をたどる.
// i番目 の 値を x に変更.
void update(int i, int x){
    // 葉のノードの番号.
    i += n - 1;
    dat[i] = x;
    // 登りながら更新.
    while(i > 0){
        //親ノード
        i = (i - 1) / 2;
        //子ノードの中で小さいものを取る
        dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
}
 
// 最小値の取得 → 再帰
// 区間[i, j] と そのノードの区間が一致しない → INT_MAXを返しておく
// 区間[i, j] と そのノードの区間を完全に含む → その接点の持つ値を返す
// どちらでもない → 2つの子ノードについて再帰的に計算
// 要求区間[a, b) の min, いまのノードk, 対象区間[l, r) で 再帰的に計算, query(a, b, 0, 0, n) と呼ぶ
int query(int a, int b, int k, int l,int r){
    // 区間が交差しない
    if(r <= a || b <= l) return 2147483647;
    // 区間を完全に含む
    if(a <= l && r <= b) return dat[k]; //その接点の持つ値.
    else{
        // 子ノード[l, (l + r) / 2) について min を計算.
        int vl = query(a, b, k * 2 + 1,          l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2,(l + r) / 2,           r);
        return min(vl,vr);
    }
}
 
int main(){

    // 1. 入力情報取得.
    int q;
    scanf("%d %d", &n, &q);
    
    // 2. セグメント木構築.
    int n2 = 1;
    // n が 2 の階乗でない場合, nを 2の階乗 にする
    // → これを行うことでセグメント木は完全二分木となり扱いやすくなる
    for(int i = 0; i < 32; i++){
        if(n2 >= n){
            n = n2;
            break;
        }
        n2 *= 2;
    }
    init();
    
    // 3. 各判定クエリに対し, 出力を行う.
    for(int i = 0; i < q; i++){
        int c, x, y;
        scanf("%d %d %d", &c, &x, &y);
        if(c == 0) update(x,y);
        else       printf("%d\n", query(x, y + 1, 0, 0, n));
    }
    
    return 0;

}


Measured memory_bytes: 4240
# 2019-11-13 21:06:16(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, m = [int(x) for x in sys.stdin.readline().split()]
    
    on_off_patterns = [''.join(pattern) for pattern in itertools.product('01', repeat=n)]
    
    bulbs = [[int(x) for x in sys.stdin.readline()[1:].split()] for _ in range(m)]
    p = [int(x) for x in sys.stdin.readline().split()]

    combinations = 0
    for i in range(2**n):
        pattern = on_off_patterns[i]
        for j in range(m):
            switches = bulbs[j]
            on_count = 0
            for switch in switches:
                if pattern[switch-1] == '1':
                    on_count += 1
            if on_count % 2 == p[j]:
                continue
            else:
                break
        else:
            combinations += 1
    
    print(combinations)
    
    # enumerate on/off-patters by using binary number.


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
n = int(input()) #入力
def dfs(s): #DFSを使う
    if int(s) > n: #整数にキャスト
        return 0 #再帰の終了条件
    if s.count('3') > 0 and s.count('5') > 0 and s.count('7') > 0:
        cnt = 1 #３か、５か、７が、１回は出てくる⇒カウントアップ
    else:
        cnt = 0 #１回ずつ出てこなければ、カウントしない
    cnt += dfs(s + '3') #再帰、３か、５か、７か、を繰り返す
    cnt += dfs(s + '5') #DFSの結果を足している
    cnt += dfs(s + '7')
    return cnt #求めたいのは、出現回数
  
print(dfs('0')) #スタートはゼロ

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

int main()
{
    string s;
    cin >> s;
    int l;
    l = s.size();
    int ans = 753;
    int t;
    int t3,t2,t1;
    rep(i, l-2){
        t3 = s.at(i) - '0';
        t2 = s.at(i+1) - '0';
        t1 = s.at(i+2) - '0';
        t = t3 * 100 + t2 * 10 + t1;

        ans = min(abs(t - 753), ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
ls = []
ls2 = []
M = 0
A = 0
R = 0
C = 0
H = 0
for i in range(N):
    ls.append(input())
for i in range(N):
    ls2.append(ls[i][0])
M = ls2.count("M")
A = ls2.count("A")
R = ls2.count("R")
C = ls2.count("C")
H = ls2.count("H")
print(M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H)

Measured memory_bytes: 10540
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	long long int h, w; std::cin >> h >> w;
	long long int min_diff = LLONG_MAX;
	for (auto i = 1; i < w; ++i) {
		auto a = i * h;
		auto b = (w - i) / 2 * h;
		auto c = (w - i + 1) / 2 * h;
		min_diff = std::min(min_diff, std::max({ a, b, c }) - std::min({ a, b, c }));
	}
	for (auto i = 1; i < h; ++i) {
		auto a = i * w;
		auto b = (h - i) / 2 * w;
		auto c = (h - i + 1) / 2 * w;
		min_diff = std::min(min_diff, std::max({ a, b, c }) - std::min({ a, b, c }));
	}
	for (auto i = 1; i < w; ++i) {
		auto a = i * h;
		auto b = (w - i) * (h / 2);
		auto c = (w - i) * ((h + 1) / 2);
		min_diff = std::min(min_diff, std::max({ a, b, c }) - std::min({ a, b, c }));
	}
	for (auto i = 1; i < h; ++i) {
		auto a = i * w;
		auto b = (h - i) * (w / 2);
		auto c = (h - i) * ((w + 1) / 2);
		min_diff = std::min(min_diff, std::max({ a, b, c }) - std::min({ a, b, c }));
	}
	std::cout << min_diff << '\n';
}

Measured memory_bytes: 888
_, m = gets.split.map(&:to_i)
geo_data = []
1.upto m do |i|
  p_id, established_year = gets.split.map(&:to_i)
  geo_data.push({ idx: i, p_id:  p_id, established_year: established_year })
end
geo_data.group_by { |h| h[:p_id] }.map do |_, v|
  v.sort_by { |h| h[:established_year] }.map.with_index 1 do |h, i|
    { idx: h[:idx], id: "#{ "%#06d" % h[:p_id]}#{"%#06d" % i}" }
  end
end.flatten.sort_by { |a| a[:idx] }.each { |a| puts a[:id] }


Measured memory_bytes: 95584
#include <stdio.h>

int main(){
    int n,i,count = 0;
    int num[20];

    scanf("%d\n",&n);

    for(i = 0 ; i < n; i++){
        scanf("%d",&num[i]);
        
    }

    for(i = 1; i < n-1 ; i++){
        
        if((num[i] > num[i-1] && num[i] < num[i+1] )|| (num[i] < num[i-1] && num[i] > num[i+1])){

            count++;

        }
    }

    printf("%d\n",count);

    return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <math.h>

using namespace std;

int n;

int main(){
    cin >> n;

    int m, ans;
    int now;

    ans = -pow(10, 9.0);
    cin >> m;
    for (int i = 1; i < n; ++i) {
        cin >> now;

        ans = max(now - m, ans);

        m = min(now, m);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, k, x;
  cin >> n >> k;
  if(n == 0) {
    cout << 0 << '\n';
    return 0;
  }
  x = (n+k-1)/k;
  cout << min(n-(x-1)*k, x*k-n) << '\n';

  return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 2e9 + 9;
const ll LINF = 1e18;
using namespace std;

int kai(int n) {
	int w = 1;
	for(int i=1;i<=n;i++){
		w = w * i;
	}
	return w;
}

int main(){
	int n;
	int cnt = 0;
	int psize = 0, qsize = 0;
	cin >> n;
	vector<int> p(n), q(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> q.at(i);
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (p.at(i) > p.at(j))cnt++;
		}
		psize += cnt * kai(n - i - 1);
		cnt = 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (q.at(i) > q.at(j))cnt++;
		}
		qsize += cnt * kai(n - i - 1);
		cnt = 0;
	}
	
	cout << abs(psize - qsize) << endl;
	return 0;
}


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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int a, b, k; cin >> a >> b >> k;
    int g = gcd(a, b);
    vector<int> v;
    for (int i = 1; i <= g; i++) {
        if (g % i == 0) v.push_back(i);
    }
    
    cout << v[v.size() - k] << '\n';
    
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        if(a >= 13) Console.WriteLine(b);
        else if(6 <= a && a <= 12) Console.WriteLine(b/2);
        else Console.WriteLine("0");
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 nibab
#define y1 kebab

int n,k,t,id;

string s;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s; n=s.lg; t=n;
    for(int i=0;i<n;i++){
        if(s[i]=='1' && !id) t=n-i,id=!id;
        else if(s[i]=='0' && id) t=n-i,id=!id;
        //cout << t << '\n';
        if(t<i+1) break;
        k=i+1;
    }
    cout << k;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

N = int(input())
AAA = list(map(int, input().split()))
BBB = list(map(int, input().split()))
CCC = list(map(int, input().split()))

n_satisfy = 0
for i, A in enumerate(AAA):
    B = BBB[A - 1]
    if i == 0:
        n_satisfy += B
    elif AAA[i - 1] + 1 != A:
        n_satisfy += B
    else:
        n_satisfy += B + CCC[A - 1 - 1]

print(n_satisfy)


Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d %d", $N, $Y);
 
$k5 = 0;
$answer = "-1 -1 -1";
 
$k10max = floor($Y / 10000);
for ($k10 = 0; $k10 <= $k10max; $k10++) {
    $k1 = ($Y - $k10 * 10000) / 1000;
    if ((($k10 + $k1) - $N) % 4 == 0) {
        $k5 = (($k10 + $k1) - $N) / 4;
        $k1 -= $k5 * 5;
        if ($k5 < 0 || $k1 < 0) continue;
 
        $answer = "{$k10} {$k5} {$k1}";
        break;
    }
}
 
echo $answer . PHP_EOL;

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    long long A[N];
    long long B[N];
    long long sum = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        B[i] = A[i];
        sum += A[i];
    }
    long long sumA = sum;
    long long tmpA = 0;
    long long costA = 0;
    if(sumA % 2 == 1){
        sumA ++;
        costA++;
        A[N - 1]++;
    }
    long long minAbsA = abs(sumA / 2 - tmpA);
    for(int i = 0; i < N; i++){
        tmpA += A[i];
        minAbsA = min(minAbsA,abs(sumA / 2 - tmpA));
    }

    long long sumB = sum;
    long long tmpB = 0;
    long long costB = 0;
    if(sumB % 2 == 1){
        sumB ++;
        costB++;
        B[0]++;
    }
    long long minAbsB = abs(sumB / 2 - tmpB);
    for(int i = 0; i < N; i++){
        tmpB += B[i];
        minAbsB = min(minAbsB,abs(sumB / 2 - tmpB));
    }
    cout << min(minAbsA * 2 + costA, minAbsB * 2 + costB) << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
    using namespace std;
    
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define int long long 
    #define double long double
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n" 
         
    #define f(i,l,r) for(int i=l;i<=r;i++)
    #define rf(i,r,l) for(int i=r;i>=l;i--)    

    #define bp __builtin_popcountll
    #define inf 1e18
    
    const int N=1e5+5; 
    const int MOD=1e9+7;
    void solve()
    {
        int n;
        cin>>n;
        int ans=0;
        for(int i=1;i<=n;i++)
        {
        	if(i%3==0 || i%5==0)
        	{
        		
        	}
        	else
        	{
        		ans+=i;
        	}
        }
        cout<<ans;
    }
    
    signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
            solve();
        }
    }



Measured memory_bytes: 3612
from scipy.sparse import*
(n,m,s,*D),*t=[map(int,t.split())for t in open(0)]
R,C=[],[]
r=range(2501)
for u,v,a,b in t[:m]:
 for i in r:k=(i+a)*51;R+=k+u,k+v;C+=i*51+v,i*51+u;D+=b,b
i=0
for c,d in t[m:]:
 i+=1
 for j in r:R+=j*51+i,;C+=(j+c)*51+i,;D+=d,
d=csgraph.dijkstra(csr_matrix((D,(R,C)),[8**6]*2),1,min(2500,s)*51+1)
for i in range(2,n+1):print(int(min(d[i::51])))

Measured memory_bytes: 123668
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  200005
ll a[N],b[N],n;
ll check(ll x){
	ll i,j,sum=0;
	for(i=1;i<=n;i++){
		sum+=abs(a[i]-x);
	}
	//cout<<sum;
	return sum;
}
int main()
{
	ios
	ll i,j;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i],a[i]-=i;
	sort(a+1,a+n+1);
	cout<<min(check(a[n/2]),check(a[n/2+1]));
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int a[11];
long long n,ans=0;

long long dfs(int cnt,long long now,long long  sum){
  if(cnt==n){
    ans+=sum;
    return 0;
  }
  dfs(cnt+1,10,sum+a[cnt]);
  if(cnt!=0)dfs(cnt+1,now*10,sum+a[cnt]*now);
  return 0;
}

int main(){
  string s;
  cin>>s;
  n=s.size();
  for(int i=0;i<s.size();i++){
    a[n-i-1]=s[i]-'0';
  }
  dfs(0,1,0);
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
	int a[3][3];
	rep(i,0,3)rep(j,0,3){
		cin>>a[i][j];
	}
    int n;
    cin>>n;
	rep(i,0,n){
		int b;
		cin>>b;
		rep(i,0,3){
			rep(j,0,3)if(a[i][j]==b)a[i][j]=-1;
		}
	}
	int cnt=0;
	rep(i,0,3){
		if(a[i][0]==-1&&a[i][1]==-1&&a[i][2]==-1)return cout<<"Yes"<<endl,0;
		if(a[0][i]==-1&&a[1][i]==-1&&a[2][i]==-1)return cout<<"Yes"<<endl,0;
	}
	if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1)return cout<<"Yes"<<endl,0;
	if(a[2][0]==-1&&a[1][1]==-1&&a[0][2]==-1)return cout<<"Yes"<<endl,0;
	cout<<"No"<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
main = do
    ints <- getInts
    printResult ints

getInts :: IO [Int]
getInts = do
    str <- getLine
    let ints =  map (\x -> read [x]) str :: [Int]
    return ints

printResult :: [Int] -> IO ()
printResult ns
    | ns !! 0 == 0 = return ()
    | otherwise = do
        putStrLn $ show $ sum ns
        main

Measured memory_bytes: 4292
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string inpt = Reader.ReadLine();
        int[] goalPos = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();


        int xMoveRemain = 0;
        int yMoveRemain = 0;

        string[] tmp = inpt.Split('T');
        List<int> xMoveList = new List<int>();
        List<int> yMoveList = new List<int>();
        for (int i = 0; i < tmp.Length; i++) {
            if(i%2==0) {
                xMoveRemain += tmp[i].Length;
                xMoveList.Add(tmp[i].Length);
            } else {
                yMoveRemain += tmp[i].Length;
                yMoveList.Add(tmp[i].Length);
            }
        }

        bool xReach = CanReach(1, xMoveList[0], goalPos[0], xMoveList);
        dic = new Dictionary<int, Dictionary<int, bool>>();
        bool yReach = CanReach(0, 0, goalPos[1], yMoveList);
        Console.WriteLine((xReach&&yReach)?"Yes":"No");
    }

    private Dictionary<int, Dictionary<int, bool>> dic = new Dictionary<int, Dictionary<int, bool>>();
    private bool CanReach(int idx, int pos, int goal, List<int> mv) {
        if(idx>=mv.Count) {
            if(pos == goal) {
                return true;
            }
            return false;
        }
        if(!dic.ContainsKey(idx)) {
            dic.Add(idx, new Dictionary<int, bool>());
        }
        if(dic[idx].ContainsKey(pos)) {
            return dic[idx][pos];
        }
        bool ans = false;
        ans = ans || CanReach(idx + 1, pos + mv[idx], goal, mv);
        ans = ans || CanReach(idx + 1, pos - mv[idx], goal, mv);
        dic[idx][pos] = ans;
        return ans;
    }


    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


TTTT
1 0


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

#define pb push_back

const int MAXN = 1e5 + 21;

int n, k;
int ans;
vector <int> adj[MAXN];
int d[MAXN];

int bfs(int root, int j){
    queue <int> q;
    memset(d, -1, sizeof(d));
    d[root] = 0;
    q.push(root);
    
    if (j ^ -1) {
        d[j] = 0;
        q.push(j);
    }
    
    int node;
    int res = 0;

    while (!q.empty()){
        node = q.front();
        q.pop();
        res++;
        if (d[node] == (k / 2)) 
            continue;
        for (auto y: adj[node]){
            if (d[y] == -1){
                d[y] = d[node] + 1;
                q.push(y);
            }
        }
    }

    return res;
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    
    if (k & 1) {
        for (int i = 1; i <= n; i++)
            for (auto y: adj[i])
                ans = max(ans, bfs(i, y));
    }
    else {
        for (int i = 1; i <= n; i++)
            ans = max(ans, bfs(i, -1));
    }
    cout << n - ans;
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, w_mx;
    cin >> n >> w_mx;
    vint w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    vvll dp(n+1, vll(w_mx+1, 0));

    rep(i, n) {
        dp[i+1] = dp[i];
        rep(j, w_mx-w[i]+1) {
            dp[i+1][j+w[i]] = max(dp[i][j+w[i]], dp[i][j]+v[i]);
        }
    }

    cout << dp[n][w_mx] << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(long long i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<ll> score(3);
    score[0] = a;
    score[1] = b;
    score[2] = c;
    vector<string> s(n);
    vector<ll> input(n);
    rep(i, n) {
        cin >> s[i];
        if (s[i]=="AB") input[i] = 2;
        if (s[i]=="AC") input[i] = 1;
        if (s[i]=="BC") input[i] = 0;
    }
    string ans = "Yes";
    vector<char> res(n);

    rep(i, n) {
        int x = input[i];
        int y = (x+1)%3;
        int z = (x+2)%3;
        if (score[y]==0 && score[z]==0) {
            ans = "No";
            break;
        }
        if (score[y]>score[z]) {
            score[y]--;
            score[z]++;
            res[i] = z;
            //cout << score[0] << " " << score[1] << " " << score[2] << endl;
            continue;
        }
        if (score[y]<score[z]) {
            score[y]++;
            score[z]--;
            res[i] = y;
            //cout << score[0] << " " << score[1] << " " << score[2] << endl;
            continue;
        }
        if (i==n-1 && score[y]==score[z]) {
            score[y]--;
            score[z]++;
            res[i] = z;
        } 
        if (i!=n-1 && score[y]==score[z]) {
            int next = input[i+1];
            if (next==x) {
                score[y]++;
                score[z]--;
                res[i] = y;
                //cout << score[0] << " " << score[1] << " " << score[2] << endl;
            }
            else {
                if (next==y) {
                    score[y]--;
                    score[z]++;
                    res[i] = z;
                    //cout << score[0] << " " << score[1] << " " << score[2] << endl;
                }
                else {
                    score[y]++;
                    score[z]--;
                    res[i] = y;
                    //cout << score[0] << " " << score[1] << " " << score[2] << endl;
                }
            }
        }
    }
    
    
    
    cout << ans << endl;
    if (ans=="Yes") {
        rep(i, n) {
            char cc = 'A' + res[i];
            cout << cc << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7192
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
int n,ans=0;
int a[105];
int main(void){
	cin>>n;
	REP(i,n)cin>>a[i];
	sort(a,a+n);
	REP(i,n-2)FORN(j,i+1,n-1)FORN(k,j+1,n)if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k])ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3644
# https://atcoder.jp/contests/agc046/tasks/agc046_b

a, b, c, d= map(int, input().split())

MOD = 998244353

dp = [[0] * (d + 1) for _ in range(c + 1)]
dp[a][b] = 1

for i in range(a, c + 1):
  for j in range(b, d + 1):
    if i == a and j == b:
      continue
    dp[i][j] = dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1)
    dp[i][j] %= MOD
print(dp[-1][-1] % MOD)


Measured memory_bytes: 154252
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 3e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
bool prime(int n) {
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

bool f(string s) {
    string t = s;
    reverse(all(t));
    return s == t;
}

int main() {
    ios;
    double n;
    cin >> n;
    n /= 3;
    cout << fixed << setprecision(10) << n*n*n;
    return 0;
}



Measured memory_bytes: 256
// @iamnifer
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <iomanip>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ull unsigned long long
#define elif else if
#define pb push_back
#define add insert
#define fastio cout.tie(nullptr);cin.tie(nullptr);ios_base::sync_with_stdio(false)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define len(x) (ll)((x).size())
#define gcd __gcd
#define lcm(a,b) (a)/gcd((a),(b))*(b)
#define precision(x) cout<<setprecision((x))
#define endl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef pair<ll,ll>pll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>ordered_multiset;
typedef vector<vector<ll>>graph;

template<typename A,typename B>void umin(A&a,B b){if(a>b)a=b;}
template<typename A,typename B>void umax(A&a,B b){if(a<b)a=b;}
template<typename B,typename E,typename M>M binpow(B b,E e,M m){M r=1;while(e>0){if(e&1)r=r*b%m;b=b*b%m;e>>=1;}return r;}
string to_string(string&s){return "\""+s+"\"";}
template<typename A,typename B>string to_string(pair<A,B>v){return "{"+to_string(v.first)+" "+to_string(v.second)+"}";}
template<typename T>string to_string(set<T>v){string r="{",e;for(auto i:v)r+=e+to_string(i),e=", ";return r+"}";}
template<typename T>string to_string(vector<T>v){string r="{",e;for(auto i:v)r+=e+to_string(i),e=", ";return r+"}";}
void debug(){cerr<<endl;}template<typename Head,typename...Tail>void debug(Head H,Tail...T){cerr<<" "<<to_string(H);debug(T...);}
#ifdef LOCAL
#define debug(...)cerr<<"["<<#__VA_ARGS__<<"]:",debug(__VA_ARGS__)
#else
#define debug(...)
#endif

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma,sse4")
//#pragma comment(linker,"/STACK:128777216")

const ld pi  = 3.14159265358979323846264338327950288419716939937510;
const ld eps = 1e-8;
const ll inf = 1e12;
const ll MOD = 1e9+7; // 998244353
const ll maxN= 1e5+9;
graph g(maxN);
vector<bool>vis(maxN,false);
void dfs(ll v){
	vis[v]=true;
	for(auto&i:g[v]){
		if(!vis[i])dfs(i);
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	fastio;
	ll n,m,u,v;cin>>n>>m;
	ll ans=-1;
	while(m--){
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	for(ll i=1;i<=n;i++){
		if(!vis[i]){
			ans++;
			dfs(i);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 9800
s = input()
l = len(s)
m = [int(s[0])]
if l >= 2:
  for j in range(1,l):
    y = 0
    for k in range(1,j+1):
      y += m[k-1] + int(s[k:j+1]) *(2** (k-1))
    x = y + int(s[:j+1])
    m.append(x)
print(m[-1])



Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int N; cin >> N;
  VI xs(3,0);
  int acc = 0, pv = 100;
  REP(i,N){
	int x; cin >> x;
	if(pv == 1-x) ++acc;
	else{
	  if(acc) xs.PB(acc);
	  acc = 1;
	}
	pv = x;
  }
  xs.PB(acc);
  REP(i,3) xs.PB(0);
 
  int ans = 0;
  REP(i,SZ(xs)-2) ans = max(ans, xs[i]+xs[i+1]+xs[i+2]);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3356
#include<stdio.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Min(a, b) ((a < b)? a : b)
#define Max(a, b) ((a > b)? a : b)
#define Abs(x) ((x>=0)? x : -x)/*Return the absolute value of x.*/
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i, n, L, taste=0, min=100000;
	scanf("%d%d", &n, &L);
	int a[n+1];
	a[0]=0;
	loop(i, 1, n+1){
		a[i] = L + i - 1;
		taste += a[i];
		if(Abs(a[i]) < Abs(min)) min = a[i];
	}
	taste -= min;
	printf("%d", taste);
	return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int cnt5 = 0;
    int cnt7 = 0;
    if (a == 5) {
        cnt5++;
    }
    if (b == 5) {
        cnt5++;
    }
    if (c == 5) {
        cnt5++;
    }
    if (a == 7) {
        cnt7++;
    }
    if (b == 7) {
        cnt7++;
    }
    if (c == 7) {
        cnt7++;
    }
    if (cnt5 == 2 && cnt7 == 1) cout << "YES";
    else cout << "NO";
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(1 + N);
	for (int i = 1; i <= N; ++i) cin >> A[i];
	set<int> ans;
	for (int i = N; i > 0; --i) {
		int a = 0;
		for (int j = 2 * i; j <= N; j += i) {
			if (ans.count(j)) ++a;
		}
		if (A[i]) {
			if (0 == a % 2) ans.insert(i);
		}
		else {
			if (a % 2) ans.insert(i);
		}
	}
	cout << ans.size() << endl;
	if (ans.size()) {
		for (set<int>::iterator i = ans.begin(); i != prev(ans.end()); ++i) cout << *i << ' ';
		cout << *prev(ans.end());
	}
}

Measured memory_bytes: 7808