akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

void print_edge(int x, int y) {
    cout << x << " " << y << endl;
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    {
        int m = 1;
        while(m < n) m <<= 1;
        if(n <= 2 || n == m) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;

    print_edge(1, 2);
    print_edge(2, 3);
    print_edge(3, n+1);
    print_edge(n+1, n+2);
    print_edge(n+2, n+3);

    for(int i=4;i+1<=n;i+=2) {
        print_edge(i, i+1);
        print_edge(i+1, n+1);
        print_edge(n+1, n+i);
        print_edge(n+i, n+i+1);
    }

    if(n % 2 == 0) {
        for(int i=3;i<n;i+=2) {
            if(n & (i ^ 1)) {
                int a = i ^ 1;
                int b = n ^ a;
                print_edge(n, i);
                print_edge(n+b, 2*n);
                break;
            }
        }
    }

}

Measured memory_bytes: 2816
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vi;
struct edge { int v; ll w; };

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

ll f(int N) {
	vector<ll> x(N);
	rep(i, N) scanf("%lld", &x[i]);
	ll sum = 0;
	rep(i, N) {
		sum = (sum + i * x[i]) % MOD;
		sum = (sum + (i - N + 1) * x[i]) % MOD;
	}
	return sum;
}

int main() {
	int N, M; cin >> N >> M;
	ll ans = f(N);
	ans = ans * f(M) % MOD;
	ans = (ans + MOD) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 1024
package main

import (
	"bytes"
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := findEquivalentStrings(n)
	for _, val := range answer {
		fmt.Println(val)
	}
}

func findEquivalentStrings(n int) []string {
	kinds := make(map[int][]form, n+1)
	kinds[1] = append(kinds[1], form{"a", 1})
	for i := 2; i <= n; i++ {
		bases := kinds[i-1]
		for _, v := range bases {
			for j := 0; j < v.charPattern+1; j++ {
				charPattern := v.charPattern
				if j >= v.charPattern {
					charPattern++
				}
				var sb bytes.Buffer
				sb.WriteString(v.s)
				sb.WriteRune(getRune(j))
				kinds[i] = append(kinds[i], form{sb.String(), charPattern})
			}
		}
	}

	equivalentStrings := make([]string, len(kinds[n]))
	for i, v := range kinds[n] {
		equivalentStrings[i] = v.s
	}

	return equivalentStrings
}

type form struct {
	s           string
	charPattern int
}

func getRune(i int) rune {
	return rune(i + 97)
}


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

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

    int k, a;
    vector<int> ka[n];
    for (int i = 0; i < n; i++) {
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> a;
            ka[i].push_back(a);
        }
    }

    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        for (auto e : ka[i-1]) {
            mp[e]++;
        }
    }

    int cnt = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second == n) {
            cnt++;
        }
    }

    cout << cnt << endl;
}


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

int main() {
    ll n=10;
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin>>n;
    vector<ll> atbl(n,0);
    for(auto&& a:atbl){
        cin>>a;
    }
#if 0
    vector<ll> btbl;
    for(int i=1;i<=n;++i){
        btbl.push_back(i);
        std::reverse(btbl.begin(),btbl.end());
    }
#endif
    vector<ll> bs;
    for(ll i=n;i>0;i-=2){
        bs.push_back(i);
    }
    for(ll i=n%2+1;i<n;i+=2){
        bs.push_back(i);
    }
	for(int i = 0; i < bs.size(); ++i) {
		ll no = bs[i] - 1;
		if(i == 0)
			cout << atbl[no];
		else
			cout << " " << atbl[no];
	}
	cout << endl;
#if 0
    //output
	auto output = [](const vector<ll>& tbl) {
		for(int i = 0; i < tbl.size(); ++i) {
			if(i == 0)
				cout << tbl[i];
			else
				cout << " " << tbl[i];
		}
		cout << endl;
	};
    //output(btbl);
    output(bs);
#endif
    return 0;
}

Measured memory_bytes: 5488
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		long v[] = new long[N];
		
		for (int i = 0; i <= 50; i++) {
			Arrays.fill(comb[i], -1);
		}
		TreeMap<Long, Integer> map = new TreeMap<>();
		for (int i = 0; i < N; i++) {
			v[i] = sc.nextLong();
			int cnt = map.getOrDefault(v[i], 0);
			map.put(v[i], cnt + 1);
		}
		long[] V = new long[map.size()];
		int K = map.size() -1;
		for (Long vv: map.keySet()) {
			V[K--] = vv;
		}
		
		long sum[] = new long[N+1];
		long num[] = new long[N+1];
		for (int k = A; k <= B; k++) {
			int rest = k;
			for (int i = 0; i < V.length; i++) {
				int cnt = map.get(V[i]);
				if (rest > cnt) {
					sum[k] += V[i] * cnt;
					rest -= cnt;
				} else {
					sum[k] += V[i] * (rest);
					num[k] = comb(cnt, rest);
					break;
				}
			}
		}

		int ans = A;
		long pat = 0;
		for (int k = A; k <= B; k++) {
			if (sum[k] * ans > sum[ans] * k) {
				pat = num[k];
				ans = k;
			} else if (sum[k] * ans == sum[ans] * k) {
				pat += num[k];
			}
		}
		System.out.printf("%.8f\n", sum[ans] * 1. / ans);
		System.out.println(pat);
		
	}
	static long comb[][] = new long[51][51];
	static long comb(int n, int k) {
		if (n == k || k == 0) return 1;
		if (comb[n][k] >= 0) return comb[n][k];
		return comb[n][k] = comb(n-1, k-1) + comb(n-1, k);
	}
}


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


int main() {
  ll N; cin>>N;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin>>A[i];
  ll count=0;
  bool zou=1;
  bool gen=1;
  for(int i=1; i<N; i++){
    if(A[i]-A[i-1]==0) continue;
    if(A[i]-A[i-1]>0 && zou==1) gen=0;
    if(A[i]-A[i-1]<0 && gen==1) zou=0;
    if(A[i]-A[i-1]>0 && gen==1){
      count++;
      zou=1;
      gen=1;
    }
    if(A[i]-A[i-1]<0 && zou==1){
      count++;
      zou=1;
      gen=1;
    }
  }
  cout<<count+1<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

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

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

    if(a==0){
        printf("1\n");
    }else if(b==0){
        printf("2\n");
    }else if(c==0){
        printf("3\n");
    }else if(d==0){
        printf("4\n");
    }else{
        printf("5\n");
    }




    return 0;
}


Measured memory_bytes: 1664
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/
 
 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */
 
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    int dp[n][3];
    for(int i=0;i<n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c[i];
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,maxr;
  cin>>n;
  int arr[n];
  int out[n];
  for(i=0;i<n;i++){
    cin>>arr[i];
    if(i==0)
      out[i]=0;
    else if(arr[i-1]>=arr[i])
      out[i]=out[i-1]+1;
    else
      out[i]=0;
  }
  maxr=out[0];
  for(i=0;i<n;i++)maxr=max(maxr,out[i]);
  cout<<maxr<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	ll N, T;
	ll nex = 0;
	cin >> N >> T;
	ll res = 0;
	rep(i,N) {
		ll t;
		cin >> t;
		if(nex <= t) {
			res += T;
		}
		else {
			res += t-(nex-T);
		}
		nex = t+T;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class AAtCoderContest {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s; in >> s;
	    string s2, s3; in >> s2 >> s3;
	    out << 'A' << s2[0] << 'C' << el;
	}
};


int main() {
	AAtCoderContest solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=200000+10;

int n;

struct edge { int v,nxt; } e[N<<1];
int head[N];
void addEdge(int u,int v) {
    static int cnt=0;
    e[++cnt]=(edge){v,head[u]},head[u]=cnt;
}

int col[N];
void dfs(int u,int f,int c) {
    col[u]=c;
    for (int i=head[u];i;i=e[i].nxt)
        if (e[i].v!=f) dfs(e[i].v,u,c^1);
}

int main() {
    n=read();
    for (int i=1;i<n;++i) {
        int u=read(),v=read();
        addEdge(u,v),addEdge(v,u);
    }
    dfs(1,0,0); int sa=0,sb=0;
    for (int i=1;i<=n;++i) col[i]?++sb:++sa;
    int a=1,b=2,c=3;
    if (sa>n/3&&sb>n/3) {
        for (int i=1;i<=n;++i) {
            if (!col[i]) {
                if (a<=n) printf("%d ",a),a+=3;
                else printf("%d ",c),c+=3;
            } else {
                if (b<=n) printf("%d ",b),b+=3;
                else printf("%d ",c),c+=3;
            }
        }
    } else if (sa<=n/3) {
        for (int i=1;i<=n;++i) {
            if (!col[i]) printf("%d ",c),c+=3;
            else {
                if (a<=n) printf("%d ",a),a+=3;
                else if (b<=n) printf("%d ",b),b+=3;
                else printf("%d ",c),c+=3;
            }
        }
    } else {
        for (int i=1;i<=n;++i) {
            if (!col[i]) {
                if (a<=n) printf("%d ",a),a+=3;
                else if (b<=n) printf("%d ",b),b+=3;
                else printf("%d ",c),c+=3;
            }
            else printf("%d ",c),c+=3;
        }
    }
    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(x), end(x), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(x), rend(x), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T>
constexpr int sz(T a) { return (int)a.size(); }
template<class T, class ... Args>
constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args>
constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class T>
constexpr T ceils(T a, T b) { return (a + b - 1) / b; }
ll plusMod(ll& a, ll b) { return a = (a % mod + b % mod) % mod; }
template<typename A, size_t N, typename T>
constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

constexpr int MAXN = 1005;
constexpr int MAXV = MAXN * (MAXN - 1) / 2;
int n, a[MAXN][MAXN];
vector<int> to[MAXV];
int id[MAXN][MAXN];
int toId(int i, int j) {
    if (i > j)
        swap(i, j);

    return id[i][j];
}

int dp[MAXV];
bool visited[MAXV];
bool caluculated[MAXV];
int dfs(int v) {
    if (visited[v]) {
        if (!caluculated[v])
            return -1;
        return dp[v];
    }

    visited[v] = true;
    dp[v] = 1;
    for (auto& u : to[v]) {
        auto res = dfs(u);
        if (res == -1)
            return -1;
        maxs(dp[v], res + 1);
    }
    caluculated[v] = true;

    return dp[v];
}

void solve() {
    cin >> n;

    rep(i, n) rep(j, n - 1) {
        cin >> a[i][j];
        --a[i][j];
    }

    int V = 0;
    rep(j, n) rep(i, j) {
        id[i][j] = V++;
    }

    rep(i, n) {
        rep(j, n - 1)
            a[i][j] = toId(i, a[i][j]);
        rep(j, n - 2)
            to[a[i][j + 1]].push_back(a[i][j]);
    }

    int ans = 0;
    rep(i, V) {
        auto res = dfs(i);
        if (res == -1) {
            ans = -1;
            break;
        }
        maxs(ans, res);
    }

    cout << ans << endn;

}


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

    solve();

    cout << flush;

    return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 * 1000 + 13;

int n;
string s;

bool read () {
	static char buf[N];
	if (scanf("%s", buf) != 1)
		return false;
	s = buf;
	n = sz(s);
	return true;
}

int dp[N][2];

void solve() {
	forn(i, N) dp[i][0] = dp[i][1] = -INF;
	dp[1][0] = 1;
	dp[2][1] = 1;
	fore(i, 1, n) forn(j, 2) forn(k, 2){
		if (i >= j + 1 && i + k + 1 <= n && s.substr(i - j - 1, j + 1) != s.substr(i, k + 1)){
			dp[i + k + 1][k] = max(dp[i + k + 1][k], dp[i][j] + 1);
		}
	}
	printf("%d\n", max(dp[n][0], dp[n][1]));
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
const ll dx[4]={1,0,-1,0};
const ll dy[4]={0,1,0,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  cout << fixed << setprecision(16);
  ll n;
  cin>>n;
  vec dp(200000,MAX);
  dp[0]=0;
  dp[1]=1;
  loop(i,100010){
    chmin(dp[i+1],dp[i]+1);
    loop(j,5){
      chmin(dp[i+pow(9,j+1)],dp[i]+1);
    }
    loop(j,6){
      chmin(dp[i+pow(6,j+1)],dp[i]+1);
    }
  }
  putout(dp[n]);
}

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

int main() {
  double a, b, c, d, e, f;
  while (~scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)) {
    double y = (c * d - a * f) / (b * d - a * e);
    double x = (c - b * y) / a;
    printf("%.3lf %.3lf\n", x, y);
  }
}


Measured memory_bytes: 2700
# AOJ ITP2_4_B: Rotate
# Python3 2018.6.24 bal4u

from collections import deque
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
	b, m, e = map(int, input().split())
	s = a[b:e]
	a = a[:b] + s[m-b:] + s[:m-b] + a[e:]
print(*a)


Measured memory_bytes: 6208
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int h,w,cnt;
char c[60][60];
int ans[60][60],flag[60][60];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
queue<P> que;

int main(){
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c[i][j];
      if(c[i][j]=='.') cnt++;
    }
  }
  flag[0][0]=1;
  que.push(P(0,0));
  while(!que.empty()){
    P p=que.front();
    que.pop();
    for(int i=0;i<4;i++){
      int x=p.first+dx[i],y=p.second+dy[i];
      if(0<=x&&x<h&&0<=y&&y<w&&!flag[x][y]&&c[x][y]=='.'){
        flag[x][y]=1;
        ans[x][y]=ans[p.first][p.second]+1;
        que.push(P(x,y));
      }
    }
  }
  cout << (ans[h-1][w-1]?cnt-ans[h-1][w-1]-1:-1) << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll x,ll y){
  if(x%y == 0) return y;
  else return gcd(y,x%y);
}
int main(){
  ll n,m;
  cin >> n >> m;
  ll a[n],b[m];
  bool able = true;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i] < 1 || n*m < a[i]) able = false;
  }
  for(int i=0;i<m;i++){
    cin >> b[i];
    if(b[i] < 1 || n*m < b[i]) able = false;
  }
  sort(a,a+n);
  sort(b,b+m);
  for(int i=1;i<n;i++){
    if(a[i] == a[i-1]) able = false;
  }
  for(int i=1;i<m;i++){
    if(b[i] == b[i-1]) able = false;
  }
  ll ans = 1;
  if(!able) ans = 0;
  ll x,y;
  for(ll v=n*m;v>=1;v--){
    auto itrx = lower_bound(a,a+n,v);
    auto itry = lower_bound(b,b+m,v);
    x = itrx - a;
    y = itry - b;
    if(x == n || y == m){
      ans = 0;
      continue;
    }
    if(*itrx == v && *itry == v) continue;
    if(*itrx == v){
      ans *= m-y;
      ans %= MOD;
      continue;
    }
    if(*itry == v){
      ans *= n-x;
      ans %= MOD;
      continue;
    }
    ll mul;
    mul = (m-y)*(n-x)-(n*m-v);
    mul %= MOD;
    ans *= mul;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#define ll long long 
#define d double
using namespace std;

int main()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     
    int n,r;
    cin>>n>>r;
    
    if(n>=10){
     	cout<<r<<endl;
    }
  
	else{	
		cout<<r+100*(10-n)<<endl;	
	}
     
    return 0;
    
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int n, m, k, ans, mod=1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int i, j, temp=0;
	cin>>n>>m>>k;
	for(i=0;i<m;i++) cout<<k<<' ';
	for(;i<n;i++) cout<<(k==1e9?1:k+1)<<' ';
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main() {
	string a;
	cin >> a;
	if(a == "A"){
	    a = "T";
	}else if(a == "T"){
	    a = "A";    
	}else if(a == "C"){
	    a = "G";
	}else if(a == "G"){
	    a = "C";
	}
	cout << a << endl;
	
	
}


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

int main() {
    vector<int> A(3);
    for (int i = 0; i < 3; i++) cin >> A[i];
    sort(A.begin(), A.end());

    if ((A[0] == A[1] && A[0] != A[2]) || (A[1] == A[2] && A[0] != A[1])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def call(n):
    s = ""
    for x in range(1, n + 1):
        y = x
        if y % 3 == 0:
            s = s + " " + str(x)
        else:
            while y != 0:
                if y % 10 == 3:
                    s = s + " " + str(x)
                    break
                y = int(y / 10)
    return s

n = int(input())
print(call(n))

Measured memory_bytes: 7656
digitSum :: Int -> Int
digitSum 0 = 0
digitSum x = (x `mod` 10) + (digitSum $ x `div` 10)

solve :: [Int] -> Int
solve (n:a:b:_) = sum $ filter valid [1..n]
    where valid x = inInterval $ digitSum x
          inInterval x = a <= x && x <= b

main = interact $ show . solve . map read . words


Measured memory_bytes: 508
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b;

int main(){
  cin >> a >> b;
  if(a==1) a += 100;
  if(b==1) b += 100;
  if(a>b) cout << "Alice" << endl;
  else if(b>a) cout << "Bob" << endl;
  else cout << "Draw" << endl;

  
  return 0;
}



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

signed main(){
  int n;cin>>n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0;i<n;i++)cin>>s[i]>>t[i];
  string x;cin>>x;
  int ans=0;bool f=false;
  for(int i=0;i<n;i++){
    if(f)ans+=t[i];
    if(s[i]==x)f=1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 764
package main

import (
	"fmt"
	"math"
)

// 足場 i + 1 or i + 2

func main() {
	n := SingleInt()
	k := SingleInt()
	chs := make([]int, 0, n)
	for i := 0; i < n; i++ {
		chs = append(chs, SingleInt())
	}

	dp := make([]int, n, n)
	dp[0] = 0
	dp[1] = int(math.Abs(float64(chs[1] - chs[0])))
	for i := 2; i < n; i++ {
		cand := make([]int, 0, k)
		for j := 1; j <= k; j++ {
			if i-j >= 0 {
				cand = append(cand, dp[i-j]+int(math.Abs(float64(chs[i]-chs[i-j]))))
			}
		}
		dp[i] = Min(cand...)
	}

	fmt.Printf("%#v\n", dp[n-1])
}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 7552
X, N = map(int, input().split())
if N==0:
    print(X)
    exit()
P = set(map(int, input().split()))

Min = float("inf")
ans = int()
for i in range(-1, 102):
    if not i in P:
        if Min > abs(X-i):
            Min = abs(X-i)
            ans = i
print(ans)


Measured memory_bytes: 9188
import collections


N=int(input())
D=list(map(int,input().split()))
A=collections.Counter(D)
if D[0]==0 and len(set(D))==max(D)+1 and A[0]==1:
  c=1
  for i in range(max(D)):
    c*=A[i]**A[i+1]
  ans=c%998244353  
  print(ans)
else:
  print(0)

Measured memory_bytes: 22364
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B;
	scanf("%d %d",&A,&B);
	int a=A+B;
	int b=A-B;
	int c=A*B;
	int t=max(a,b);
	int maxx=max(t,c);
	printf("%d\n",maxx);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pf push_front
#define acm ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a-b>=c){
    cout<<"0";

}
else{
    cout<<c-(a-b);
}
}


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

using namespace std;

vector<int> v;

int main() {
    ios_base::sync_with_stdio( 0 );
    cin.tie( NULL );
    int n;
    cin >> n;
    v.push_back( 0 );
    for( int a, i=1; i<=n; i++ ) {
        cin >> a;
        v.push_back( a );
    }
    int wy=0;
    for( int i=1; i<=n; i++ ) {
        if( i == v[ v[i] ] ) {
            wy++;
        }
    }
    cout << wy/2;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int dp[3001][3001];
int dir[301][301];

int main() {
    string s,t;
    cin >> s >> t;

    int n = s.size();
    int m = t.size();
    dp[0][0] = 0;
    dp[1][0] = 0;
    dp[0][1] = 0;
    for(int i=1; i<=n; ++i) {
        for(int j=1; j<=m; ++j) {
            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 ans = "";
    int i = n, j=m;
    while(i > 0 && j > 0) {
        if(dp[i][j] == dp[i-1][j]) {
            --i;
        } else if(dp[i][j] == dp[i][j-1]) {
            --j;
        } else {
            ans += s[i-1];
            --i; --j;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>

using namespace std;

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

int main() {
    int n;
    cin >> n;
    int ans;
    cin >> ans;
    for (int i = 1; i < n; ++i) {
        int temp;
        cin >> temp;
        ans = gcd(ans, temp);
		if (ans == 1) {
			cout << ans;
			return 0;
		}
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int c = values[a];
			values[a] = values[b];
			values[b] = c;
		}
		for (int i = 0; i < w; i++) {
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 26184
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (d2 == 1)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main() {
  int n, a, b, c, total=0;
  vector<int> Va,Vb, Vc;
  cin>>n;
  Va.push_back(0);
  Vb.push_back(0);
  Vc.push_back(0);
  for(int i=1;i<=n;i++){
    cin>>a>>b>>c;
    Va.push_back(max(Vc[i-1], Vb[i-1])+ a);
    Vb.push_back(max(Va[i-1], Vc[i-1])+ b);
    Vc.push_back(max(Va[i-1], Vb[i-1])+ c);
  }
  int aux=max(Va.back(),Vb.back());
    total=max(aux, Vc.back());
  cout<<total<<endl;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() {
    while (true){
        ll n;
        cin >> n;
        if (n==0){
            break;
        }
        ll dp[n+1],odddp[n+1];
        fill(dp,dp+n+1,INF);
        fill(odddp,odddp+n+1,INF);
        dp[0]=odddp[0]=0;
        for (ll i=1;;i++){
            ll x=i*(i+1)*(i+2)/6;
            if (x>n)break;
            for (ll j=x;j<=n;j++){
                dp[j]=min(dp[j],dp[j-x]+1);
                if (x&1){
                    odddp[j]=min(odddp[j],odddp[j-x]+1);
                }
            }
        }
        cout << dp[n] << " " << odddp[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 18164
#include<stdio.h>

int main()
{
int a,b,s;
scanf("%d%d",&a,&b);
s=a+b;
if(s==24){
printf("0\n");
}
else if(s>24){
s=s-24;
printf("%d\n",s);
}
else{
printf("%d\n",s);
}

return 0;}



Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include <cmath>
using namespace std;
int main()
{
  int n,k,c,i,t,s=0;
  double res=0;
  cin >> n >> k;
  if(k==1){
    cout << "1" << endl;
    return 0;
  }
  c=(int)ceil(log2(k));
  for(i=c;i>0;i--){
    t=(int)floor((k-1)*exp2(1-i));
    t=min(t,n);
    res+=(t-s)*exp2(-i);
    if(t==n) break;
    s=t;
  }
  if(t<n) res+=n-t;
  res/=n;
  cout << fixed << setprecision(12) << res << endl;
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  S.erase(S.begin(), S.begin() + 5);
  S.erase(S.begin() + 2);
  int SS = stoi(S);
  if(SS > 430) cout << "TBD" << endl;
  else cout << "Heisei" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
long long gcd(long long a,long long b){
	if (b == 0)return a;
	return gcd(b, a%b);
}


int main(){
	long long c,n, m,i;
	
	char s[100001], t[100001];
	scanf("%lld%lld", &n, &m);
	scanf("%s%s", s, t);
	c = gcd(n, m);
	long long a = (n * m) / c;
	for (i = 0;i<c;i++) {
		if (s[(n / c)*i] != t[(m / c)*i]) {
			puts("-1\n");
			return 0;
		}
	}
	printf("%lld\n", a);
		return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

const int N = 100100;

int a[N];
int n, c, k;
int main() {
  scanf("%d %d %d", &n, &c, &k);
  for (int i = 0; i < n; i ++)
    scanf("%d", a + i);
  sort(a, a + n);
  int now = 0, ans = 0, cnt = 0;
  for (int i = 0; i < n; i ++) {
    if (a[i] > now || cnt == 0) now = a[i] + k, cnt = c, ans ++;
    cnt --;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
wether_cycle = {'Sunny':'Cloudy', 'Cloudy':'Rainy', 'Rainy':'Sunny'}

def receuve_input():
    input_string = str(input())
    return input_string

def predict_weather(input_string):
    print(wether_cycle[input_string])

if __name__ == '__main__':

    input_string = receuve_input()
    predict_weather(input_string)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ic pair <int, char>
#define sort(v) sort(v.begin(),v.end())
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <int> v;

/*int intConvert(string s){
    int n;
    stringstream geek(s);
    geek >> n;
    return n;
}*/

/*string strConvert(int n){
    string s;
    stringstream ss;
    ss << n;
    s=ss.str();
    return s;
}*/


int main(){
    int n;
    sf(n);
    int ans = n + (n*n) + (n*n*n);
    pf("%d\n",ans);

    return 0;
}


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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = a*c;
  ans = max(ans, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  cout << ans << '\n';
}

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

  return 0;
}


Measured memory_bytes: 3648
import sys


def read():
    return sys.stdin.readline().rstrip()


def main():
    n, m = map(int, read().split())
    a = {int(read()) - 1 for _ in range(m)}
    if n == 1:
        print(1)
        return
    mod = 10**9 + 7
    dp = [0] * n
    if 0 not in a:
        dp[0] = 1
    if 1 not in a:
        dp[1] = 1 + dp[0]
    for i in range(2, n):
        if i in a:
            continue
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 17540
var lines = [];

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var tmp = lines.shift().split(" ");

    var X = Number(tmp[0]);
    var Y = Number(tmp[1]);
    var Z = Number(tmp[2]);
    var K = Number(tmp[3]);

    tmp = lines.shift().split(" ");
    var A = Array(tmp.length)
    for (var i = 0; i < A.length; i++) {
        A[i] = Number(tmp[i]);
    }

    tmp = lines.shift().split(" ");
    var B = Array(tmp.length)
    for (var i = 0; i < B.length; i++) {
        B[i] = Number(tmp[i]);
    }

    tmp = lines.shift().split(" ");
    var C = Array(tmp.length)
    for (var i = 0; i < C.length; i++) {
        C[i] = Number(tmp[i]);
    }

    var result = [];
    
    A.sort(function(a,b){return(b-a);});
    B.sort(function(a,b){return(b-a);});
    C.sort(function(a,b){return(b-a);});

    for (var a = 0; a < A.length; a++) {
        for (var b = 0; b < B.length; b++) {

            if ((a + 1) * (b + 1) > K) { break; }
            for (var c = 0; c < C.length; c++) {
                if ((a + 1) * (b + 1) * (c + 1) > K) { break; }

                result.push(A[a] + B[b] + C[c]);
            }
        }
    }
    
    result.sort(function (a, b) { return (b - a); });

    for (var i = 0; i < Math.min(3000, K); i++) {
        console.log(result[i]);
    }
});

Measured memory_bytes: 30836
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,p[20],s[1<<20],s1[1<<10];

int main(){
	while(cin>>n){
		if(!n)return 0;
		int n2=n/2;
		fill(s1,s1+(1<<n2),0);
		int sum=0,dif=1e+9;
		for(int i=0;i<n;i++){cin>>p[i];sum+=p[i];}
		if(n<4){
			fill(s,s+(1<<n),0);
			for(int i=0;i<1<<n;i++){
				int sss=0;
				for(int j=0;j<n;j++)if((i/(1<<j))%2)sss+=p[j];
				dif=min(dif,abs(sss*2-sum));
			}
			cout<<dif<<endl;
		}
		else{
		for(int i=0;i<1<<n2;i++){
			for(int j=0;j<n2;j++)if(i>>j&1)s1[i]+=p[j];
		}
		sort(s1,s1+(1<<n2));
		int ans=1e+9;
		for(int i=0;i<1<<(n-n2);i++){
			int ss=0;
			
			for(int j=0;j<n-n2;j++)if(i>>j&1)ss+=p[j+n2];
			ans=min(ans,min(abs((*lower_bound(s1,s1+(1<<n2),(sum+1)/2-ss)+ss)*2-sum),abs((*(lower_bound(s1,s1+(1<<n2),(sum+1)/2-ss)-1)+ss)*2-sum)));
		}
		cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 0
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

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


par = [0]*202020
size = [0]*202020

def find(x):
	if par[x] == x:
		return x
	else:
		par[x] = find(par[x])
		return par[x]

def unite(x, y):
	x = find(x)
	y = find(y)
	res = size[x] * size[y]
	size[x] += size[y]
	par[y] = x
	return res

# main
n = int(input())
for i in range(202020):
	par[i] = i
	size[i] = 1

a = [0] + list(map(int, input().split()))
b = [0]*(n+1)
for i in range(1, n+1):
	b[a[i]] = i

ans = 0
for j in reversed(range(1, n+1)):
	i = b[j]
	ans += a[i]
	if i - 1 >= 1 and a[i-1] > a[i]:
		ans += unite(i-1, i) * a[i]
	if i + 1 <= n and a[i+1] > a[i]:
		ans += unite(i+1, i) * a[i]
print(ans)


Measured memory_bytes: 34344
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

vector<int> G[1 << 18];

queue<int> q;
bool used[1 << 18];
int n;
int cnt = -1;
int mostfar(int root) {
	cnt = -1;
	fill(used, used + n, false);
	used[root] = true; q.push(root);
	int ret;
	while (!q.empty()) {
		cnt++;
		int len = q.size();
		rep(aa, len) {
			int id = q.front(); q.pop();
			ret = id;
			rep(j, G[id].size()) {
				int to = G[id][j];
				if (used[to])continue;
				used[to] = true; q.push(to);
			}
		}
	}
	return ret;
}
void solve() {
	cin >> n;
	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int le = mostfar(0); int ri = mostfar(le);
	if ((cnt - 1) % 3 == 0) {
		cout << "Second" << endl;
	}
	else {
		cout << "First" << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 14976
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 300001
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
void solve()
{
    int n,m,k; cin>>n>>m>>k;
    vector<int> v(n+1),b(m+1);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        v[i]=v[i-1]+v[i];
        if(v[i]<=k)
        ans=i;
    }
    for(int i=1;i<=m;i++)
    {
        cin>>b[i];
        b[i]=b[i-1]+b[i];
    }
    int i=ans,j=1;
    while(i>=0 && j<=m)
    {
        if(b[j]<=k-v[i])
        j++;
        else
        i--;
        ans=max(ans,i+j-1);
    }
    cout<<ans<<endl;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1; //cin>>test;
    int x=1;
    while(test--)
    {
        //cout<<"Case #"<<x++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 6340
#include<bits/stdc++.h>
using namespace std;
double a,b,x,v;
double step;
int main(){
	scanf("%lf%lf%lf",&a,&b,&x);
	v=a*a*b;
	if(x<v/2){
		double l=0,r=90;
		while(r-l>=0.00000001){
			double mid=(l+r)/2;
			double result=tan(((90.00000000-mid)/180.0)*M_PI);
			step=(a*b*b*result)/2.0;
			if(abs(x-step)<=0.0000001){
				printf("%.8lf",mid);
				return 0;
			}
			if(step<x) r=mid;
			else l=mid+0.0000001;
		}
		printf("%.8lf",l);
	}
	else{
		double l=0,r=90;
		while(r-l>=0.0000001){
			double mid=(l+r)/2;
			double result=tan((mid/180.0)*M_PI);
			step=(a*a*a*result)/2.0;
			if(abs(v-x-step)<=0.0000001){
				printf("%.8lf",mid);
				return 0;
			}
			if(step+x>v) r=mid;
			else l=mid+0.0000001;
		}
		printf("%.8lf",l);
		
		
		
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main { 
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        System.out.print(d +" " + r + " ");
        System.out.printf("%.09f\n", f);
    }
}

Measured memory_bytes: 26484
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
/*
0-1 
bfs
*/



int main(){
	int r,c;
	cin>>r>>c;	
	int x,y;
	cin>>x>>y;
	x--;
	y--;
	int w,z;
	cin>>w>>z;
	w--;
	z--;
	vector<string> s;
	rep(i,0,r){
		string p;
		cin>>p;
		s.pb(p);
	}
	
	deque <pair<int,int>> dq;
	dq.pb({x,y});
	
	int dr[6] = {-2,-1,0,1,0,2};
	int dc[6] = {-2,0,-1,0,1,2};
	int ma = 1e9;
	int dp[r][c];
	rep(i,0,r){
		rep(j,0,c){
			dp[i][j] = ma;
		}
	}
	dp[x][y] = 0;
	
	
	while(!dq.empty()){
		x = dq.front().first;
		y = dq.front().second;
		
		dq.pop_front();
		
		rep(i,1,5){
				
						int nx = x+dr[i];
						int ny = y+dc[i];
						if(nx>=0 && nx<r && ny>=0 && ny<c){
							if(dp[nx][ny]>dp[x][y] && s[nx][ny]=='.'){
								//cout<<nx<<" "<<ny<<endl;
								dp[nx][ny]  = dp[x][y];
								dq.push_front({nx,ny});
							}	
						}
					
		}
	
		for(auto i : dr){
			for(auto j : dc){
				
				int nx = x+i;
				int ny = y+j;
				if(nx>=0 && nx<r && ny>=0 && ny<c){
					if(dp[nx][ny]>dp[x][y]+1 && s[nx][ny]=='.'){
						//cout<<nx<<"gggggg"<<ny<<endl;
						dp[nx][ny]  = dp[x][y]+1;
						dq.push_back({nx,ny});
					}	
				}
				
				
			}
		}
		
		
		
			
	}
	if(dp[w][z]==ma) cout<<-1;
	else cout<<dp[w][z];
	

	
	
}
		 

Measured memory_bytes: 8552
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a int
	var b []byte
	fmt.Scan(&a, &b)
	nb := make([]byte, 0)
	for i := range b {
		if b[i] != '.' {
			nb = append(nb, b[i])
		}
	}
	bn, _ := strconv.Atoi(string(nb))
	fmt.Println(int(a * bn / 100))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1756
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] h = ReadIntArray();
	int[] c = new int[n];
	c[0] = 0;
	c[1] = Math.Abs(h[1]-h[0]);
	for (int i = 2; i < n; i++)
	    c[i] = Math.Min(Math.Abs(h[i]-h[i-1]) + c[i-1],
			    Math.Abs(h[i]-h[i-2]) + c[i-2]);

	WriteLine(c[n-1]);
    }
}


Measured memory_bytes: 20064
import copy

n = int(input())
a = list(map(int, input().split()))
# print(a)

def f(org_a, odd):
    a = copy.copy(org_a)
    ans = 0
    if a[0] == 0:
        a[0] = 1 if odd else -1
        ans += 1
    elif a[0] > 0 and not odd:
        ans += a[0] + 1
        a[0] = -1
    elif a[0] < 0 and odd:
        ans += -a[0] + 1
        a[0] = 1
    current_sum = a[0]
    for i in range(1, len(a)):
        move = 0
        is_positive = current_sum > 0
        current_sum += a[i]
        if is_positive and current_sum >= 0:
            move = -current_sum - 1
        elif not is_positive and current_sum <= 0:
            move = -current_sum + 1

        current_sum += move
        # print(current_sum)
        a[i] += move
        ans += abs(move)
    return ans

# print(a)
print(min(f(a, True), f(a, False)))


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

int main(){
    string s;
    getline(cin,s);
    int ans = 0;
    for(int i = 0;i<s.length();++i){
        ans = (s[i]-48 + ans)%9;
    }
    if(ans){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#define MAX_SIZE 51
#define INF 10000
typedef long long int ll;
using namespace std;

int n;
int cnt[MAX_SIZE + 1][26];

int main()
{
    cin >> n;
    string s;
    for (int i = 0; i < n; i++){
        cin >> s;
        for (int j = 0; j < s.size(); j++){
            cnt[i][s[j] - 'a']++; //文字列当たりに何個あるか調べる
        }
    }

    for (int i = 0; i < 26; i++){
        cnt[MAX_SIZE][i] = INF; //最終的にアルファベットの使える個数を格納
    }

    for (int i = 0; i < n; i++){
        for (int j = 0; j < 26; j++){
            cnt[MAX_SIZE][j] = min(cnt[MAX_SIZE][j], cnt[i][j]);
        }
    }

    for (int i = 0; i < 26; i++){
        char alpha = 'a' + i;
        for (int j = 0; j < cnt[MAX_SIZE][i]; j++){
            cout << alpha;
        }
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256