akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
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; }

// union by size + path having
class UnionFind {
public:

    //素集合の要素の親（木構造の根）を配列*3で保持している．初期状態では頂点間の辺は存在せず，孤立した状態のため，自分自身を根として初期化している（par: parent の略）．
    vector <ll> par;

    // 各集合（木）の大きさ．根をたどるとその木の大きさが返されるように実装されている．この配列を用意しておくとある頂点の連結成分の大きさを簡単に求められる
    vector <ll> siz;

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    int N, M, A, B;
    cin >> N >> M ;
    vector<pair<ll, ll> > v(M);
    rep(i, M){
        cin >> A >> B;
        A--;
        B--;
        v.at(i) = make_pair(A, B);
    }

    ll ans = 0;
    UnionFind uf(N);
    rep(i, M){
        uf.init(N);
        rep(j, M){
            if(i == j) continue;
            uf.merge(v[j].first, v[j].second);
        }
        if(uf.size(0) < N) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

/// t より前にくる文字列がいくつあるか
int countLessOrEqual(string t, string[] ss) {
    return cast(int) ss.map!(e => e.replace("?", "a")).count!(e => e <= t);
}

/// t より後ろにくる文字列がいくつあるか
int countGreaterOrEqual(string t, string[] ss) {
    return cast(int) ss.map!(e => e.replace("?", "z")).count!(e => e >= t);
}

void calc(string t, string[] ss) {
    int n = cast(int) ss.length;

    int a = countGreaterOrEqual(t, ss);
    int high = n - a + 1;

    int b = countLessOrEqual(t, ss);
    int low = b + 1;

    auto ans = iota(high, low + 1).map!(e => e.to!string).join(" ");
    writeln(ans);
}

void main() {
    int n = readint;
    string[] ss;
    for (int i = 0; i < n; i++) ss ~= read!string;
    string t = read!string;
    calc(t, ss);
}


Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0;
	ll all=k;
	all-=a;
	if(all<=0)
	{
		sum=k;
		cout<<k;
	}
	else
	{
		all-=b;
		sum+=a;
		if(all<=0)
		{
			sum=a;
			cout<<sum;
		}else
		{
			sum-=all;
			cout<<sum;
		}
	}
	return 0;
 } 

Measured memory_bytes: 3588
from collections import deque
n = input()

C = [None]*n
P = [None]*n
for i in xrange(n):
    ipt = map(int, raw_input().split())
    C[i] = ipt[1:]
    for c in C[i]:
        P[c] = i
LEV = (n+1).bit_length()
parent = [[None]*(LEV + 1) for i in xrange(n)]
for i in xrange(n):
    parent[i][0] = P[i]
for k in xrange(LEV):
    for i in xrange(n):
        if parent[i][k] is None:
            parent[i][k+1] = None
        else:
            parent[i][k+1] = parent[parent[i][k]][k]
depth = [None]*n
deq = deque()
deq.append(0)
depth[0] = 0
while deq:
    v = deq.popleft()
    for c in C[v]:
        deq.append(c)
        depth[c] = depth[v] + 1

q = input()
for t in xrange(q):
    u, v = map(int, raw_input().split())
    if not depth[u] < depth[v]:
        u, v = v, u
    for k in xrange(LEV+1):
        if ((depth[v] - depth[u]) >> k) & 1:
            v = parent[v][k]
    if u == v:
        print u
        continue

    for k in xrange(LEV, -1, -1):
        if parent[u][k] != parent[v][k]:
            u = parent[u][k]
            v = parent[v][k]
    print parent[u][0]

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

int64_t l_num(int x){
  int64_t l[x],i;
  if(x==0){
  return 2;
  }
  if(x==1){
  return 1;
  }
for(int i=2;i<=x;i++){
l[i] =0;
}
for(int i=2;i<=x;i++){
l[0]=2;
l[1]=1;
l[i]+=l[i-1]+l[i-2];
}
return l[x];

}

int main(){
int N;
cin >> N;
cout << l_num(N) <<endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

template<typename T, typename U>
T gcd(T u, U v) {
	if (u == 0)return v;
	if (v == 0)return u;
	T r;
	while (v) {
		r = u % v;
		u = v;
		v = r;
	}
	return u;
}

template<typename T>
T gcd(vector<T> a) {
	int l = a.size();
	T res = 0;
	for (int i = 0; i < l; ++i) {
		res = gcd(res, a[i]);
	}
	return res;
}


template<typename T, typename U>
long long lcm(T u, U v) {
	long long res = (long long)u / gcd(u, v);
	res *= v;
	return res;
}

template<typename T>
long long lcm(vector<T> a) {
	int l = a.size();
	long long res = 1;
	for (int i = 0; i < l; ++i) {
		res = lcm(res, a[i]);
	}
	return res;
}

ll hlcm(ll a, ll b) {
	ll ha = a / 2, hb = b / 2;
	if (a % hb == 0 || b % ha == 0) {
		return -1;
	}

}

int main() {
	IOS;
	ll n, m;
	cin >> n >> m;
	m *= 2;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	ll lc = a[0];
	ll res;
	
	FOR(i, 1, n) {
		ll nlc = lcm(lc, a[i]);
		if ((nlc / lc) % 2 == 0  || (nlc / a[i]) % 2 == 0) {
			put(0);
			return 0;
		}
		lc = nlc;
		if (lc > m) {
			put(0);
			return 0;
		}
	}
	if (lc % 2 == 0) {
		res = (m / lc + 1) / 2;
	}
	put(res);
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  string ans;
  for(int i = 0; i < 2; i++){
    
    S[i*2] -= '0';	//int変換
    S[i*2+1] -= '0';
    int temp = S[i*2]*10 + S[i*2+1];
    if(temp > 0 && temp < 13)	ans += "MM";
    else	ans += "YY";
  }
  
  if(ans == "YYYY")	cout << "NA" << endl;
  else if(ans == "MMMM")	cout << "AMBIGUOUS" << endl;
  else	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;

string s;

int main(){
    cin >> s;
    int g=0,p=0;
    int n = s.size();
    rep(i,n){
        if(s[i]=='g')g++;
        else p++;
    }
    int wp = n/2;
    int wg = n-wp;
    cout << wp - p << endl;

    return 0;
}


Measured memory_bytes: 512
n = int(input())
high, low , max = 0, 1000000000, -1000000000
for i in range(n):
    a = int(input())
    if high < a and i > 0:
        high = a
    if max < high - low:
        max = high - low
    if low > a:
        low, high = a, 0
print(max)


Measured memory_bytes: 5616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        long remain = k - a;
        if (remain == 0) {
            System.out.printf("%s %s", 0, b);
            System.exit(0);
        } else if (remain < 0) {
            System.out.printf("%s %s", a - k, b);
            System.exit(0);
        }

        long aoki = b - remain;
        if (aoki <= 0) {
            System.out.printf("%s %s", 0, 0);
        } else {
            System.out.printf("%s %s", 0, aoki);
        }
    }
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define M_PI 3.14159265358979323846
template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

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

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
	os << "["; for (auto& vv : V) os << vv << ","; os << "]";
	return os;
}

template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

int32_t main(int32_t argc, char ** argv) {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<vector<int>> inp(3, VI(n));
	REP(k, 3)
		REP(i, n) {
			cin >> inp[k][i];
		}
	REP(k, 3) {
		sort(ALL(inp[k]));
	}
	int current = 0;
	int idx1 = 0;
	vector<int> res(n);
	REP(i, n) {
		while(idx1 != n && inp[0][idx1] < inp[1][i]) {
			current++;
			idx1++;
		}
		res[i] = current;
	}
	current = 0;
	int idx2 = 0;
	int trueRes = 0;
	REP(i, n) {
		while (idx2 != n && inp[1][idx2] < inp[2][i]) {
			current += res[idx2];
			idx2++;
		}
		trueRes += current;
	}
	cout << trueRes << "\n";
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)

int main() { 
  int a,b,c;cin>>a>>b>>c;
  cout << ((a+b>=c)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
N=gets.to_i;puts N<3?-1:N<4?'a..
a..
.bb':(0..N-4).step(4).map{|j|([f=%w(aabc ddbc efgg efhh),%w(affgg axe bxe b.dyy ccdhh),%w(aabc ddbc ..eefg ..hhfg ij..kk ij..ll),%w(ag..g ag..g b.ss.ss bg..g cg..g c.ss.ss .ppqqrr)][N-j-4]||f).map{|g|(?.*j+g+?.*N)[0,N]}}

Measured memory_bytes: 6908
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int ls=s.size(),lt=t.size(),flag=1;
	for(int i=0;i<ls;i++) 
	{
		if(s[i]!=t[i]) flag=0;
	}
	if(flag&&ls+1==lt) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {
    string  S;
    cin >> S;
 
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
   if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }

    if (S == "Rainy") {
    cout << "Sunny" << endl;
  }
}

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

int main(){
    int a ;
    int p,q,r ;
    cin >> a ;
    p = a / 100 ;
    q = a / 10 - p * 10 ;
    r = a -  (q * 10 + p * 100);
    cout << p + q + r << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split(" "))
A = input().split(" ")
A = [int(i) for i in A]
A = sorted(A)
D = [0] * (N+1)
for i in range(len(A)):
    D[A[i]] += 1

flag = 0
for i in range(len(D)):
    if D[i] > 0:
        flag += 1
if flag <= K:
    print(0)
else:
    DIF = flag - K
    D = sorted(D)
    E = []
    for i in range(len(D)):
        if D[i] > 0:
            E.append(D[i])
    ans = 0
    for i in range(DIF):
        ans += E[i]
    print(ans)

Measured memory_bytes: 25732
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int N){
    vector<int>S;
    rep(i,N)if(bit & (1<<i))S.push_back(i);
    return S;
}

int main(){
    int n,k;cin>>n>>k;
    VEC(ll,a,n);

    ll res = INF*INF;
    for(int bit=0;bit<(1<<n);bit++){
        vector<int>S = bitSearch(bit,n);
        ll cost = 0,mx = 0;
        if(S.size()<k)continue;
        rep(i,n){
            if(i==*lower_bound(ALL(S),i) && mx>=a[i]){
                cost += mx-a[i]+1;
                mx++;
            }
            mx = max(mx,a[i]);
            //cout<<mx<<endl;
        }
        res = min(res,cost);
    }
    cout<<res<<endl;
}



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

int main(){
  int q;
  deque<int>Q;
  cin>>q;
  while(q--){
    int a,b,c;
    cin>>a>>b;
    if(!a){
      cin>>c;
      if(b)Q.push_back(c);
      else Q.push_front(c);
    }
    else if(a==1)cout<<Q[b]<<endl;
    else{
      if(b)Q.pop_back();
      else Q.pop_front();
    }
  }
}


Measured memory_bytes: 4640
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
 
//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
/////////////////////////
 
 
 
//Answer
 
 
int main() {
long A,B,C;
long K;
cin>>A>>B>>C>>K;
while(B<=A&&K>0){
    B=B*2;
    K--;
}
while(C<=B&&K>0){
    C=C*2;
    K--;
}
if(A<B&&B<C){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
 
 
}

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

int main(int argc, char *argv[], char *envp[]){
	int x, y, KAI=0;
	cin >> x >> y;
	if(x == 1){
		KAI += 300000;
	}else if(x == 2){
		KAI += 200000;
	}else if(x == 3){
		KAI += 100000;
	}
	if(y == 1){
		KAI += 300000;
	}else if(y == 2){
		KAI += 200000;
	}else if(y == 3){
		KAI += 100000;
	}
	if(x == 1 && y == 1){
		KAI += 400000;
	}
	cout << KAI << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <type_traits>
#include <limits>
#include <random>

using namespace std;

using ll = long long;

#define rep(i,N) for(long long i = 0;i < (long long)N; ++i)

int N, K;
int tree[100000];
int ans = 10000000000;

int main() {
	cin >> N >> K;
	rep(i, N) {
		cin >> tree[i];
	}
	sort(tree, tree + N);
	for (int i = 0; i < N - K + 1; i++) {
		ans = min(ans, tree[i + K - 1] - tree[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
int main(){
    int N;
    ll ans=0;
   string s;
   cin>>s;
   N=s.size()-1;
 for(int i=0;i<(1<<N);i++){
     ll now=0,sum=0;
     for(int j=0;j<=N;j++){
         now*=10;
         now+=s.at(j)-'0';
         if(i&(1<<j)){
             sum+=now;
             now=0;
         }
     }
     sum+=now;
     ans+=sum;
 }
   cout<<ans<<endl;
   return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int H,W,i;
    string o;
    while(cin>>H>>W && (H!=0 || W!=0)){
        o = string(W,'#');
        for (i=0;i<H;i++) {
            cout << o << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  } 
  int minus = 0;
  for(int i = 0; i < n; i++) if(a[i] < 0) minus++;
  ll result = 0;
  for(auto e : a)
  {
    result += abs(e);
  }
  if(minus % 2 != 0)
  {
    ll smallest = abs(a.front());
    for(auto e : a)
    {
      smallest = min(smallest, abs(e));
    }
    result -= smallest * 2;
  }
  cout << result << endl;
}


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

double PI=3.141592653589793238462643383279;

int main(){
  double a,b,x; cin >> a >> b >> x;
  cout << setprecision(10);
  if(a*b*0.5<=x/a){
    cout << atan2(max((a*b-x/a)*2./a,0.),a)/PI*180. << endl;
  }else{
    cout << atan2(b,max(2.*x/(a*b),0.))/PI*180. << endl;
  }
}

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

string s;
int pos[26];

int main() {
    fill_n(pos, 26, -3);
    cin >> s;
    int N = s.size();

    for (int i = 0; i < N; i++) {
        if (i - pos[s[i] - 'a'] < 3) {
            cout << pos[s[i] - 'a'] + 1 << " " << i + 1 << endl;
            return 0;
        }
        pos[s[i] - 'a'] = i;
    }
    cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  ll sum = 0;
  cin >> sum;
  ll sum_sum = ll(sum) * ll(sum) * ll(sum);
  if ((sum_sum % 3 == 0) || (sum_sum >= 800))
    cout << (ll(sum) * ll(sum) * ll(sum)) / ll(27.0);
  else
    cout << (ld(sum) * ld(sum) * ld(sum) / ld(27.0));
}

Measured memory_bytes: 256
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(w_max+1, 0)
items.each do |w, v|
  prev = dp.dup
  prev.each_with_index do |pv, pw|
    nw = pw + w
    nv = pv + v
    dp[nw] = nv if nw <= w_max && prev[nw] < nv
  end
end
puts dp.last


Measured memory_bytes: 69004
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 1e5+5;
typedef pair<int,int> pii;


void TEST_CASES(int cas)
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];

    }
    n--;
    sort(a.begin(),a.end());
    ll ans = a.back();
    a.pop_back();
    n--;
    while(n)
    {
        ll now = a.back();
        a.pop_back();
        ans+= now;
        n--;
        if(!n)
            break;
        ans+= now;
        n--;
    }
    printf("%lld\n",ans);


}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 4856
#include<iostream>
using namespace std;
int main() {
  int A,B;
  char S[5];
  cin >> S;
  A = (S[0] - '0')*10 + (S[1] - '0');
  B = (S[2] - '0')*10 + (S[3] - '0');
  if(0 < A && A <= 12) {
    if(0 < B && B <= 12)cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  } else {
    if(0 < B && B <= 12)cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

ll calc(int N, ll C, vll& x, vll& v) {
    vll l_v_sum(N + 1);
    rep(i, N) {
        l_v_sum[i + 1] = l_v_sum[i] + v[N - i - 1];
    }

    vll l_max(N + 1);
    l_max[0] = 0;
    ll lm = 0;
    REP(i, 1, N + 1) {
        l_max[i] = max(lm, l_v_sum[i] - (C - x[N - i]));
        lm = l_max[i];
    }
    ll ans = 0;
    vll r_v_sum(N + 1);
    rep(i, N) {
        r_v_sum[i + 1] = r_v_sum[i] + v[i];
    }

    rep(i, N) {
        ans = max(ans, r_v_sum[i + 1] - x[i]);
        ans = max(ans, (r_v_sum[i + 1] - 2 * x[i]) + l_max[N - (i + 1)]);
    }
    return ans;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    ll C;
    cin >> N >> C;
    vll x(N), v(N), x_rev(N), v_rev(N);
    rep(i, N) cin >> x[i] >> v[i];

    rep(i, N) {
        x_rev[i] = C - x[N - i - 1];
        v_rev[i] = v[N - i - 1];
    }

    ll ans = 0;
    ans = max(ans, calc(N, C, x, v));
    ans = max(ans, calc(N, C, x_rev, v_rev));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    String S = sc.next();

    if(S.length() <= K) {
      System.out.println(S);
    } else{
      System.out.println(S.substring(0, K) + "...");
    }
  }
}


Measured memory_bytes: 38604
n = int(input())
march = {}
for s in "MARCH":
  march[s] = 0
for _ in range(n):
  s = input()[0]
  if s in "MARCH":
    march[s] += 1
ans = 0
for i in range(5):
  s1 = "MARCH"[i]
  n1 = march[s1]
  for j in range(i + 1, 5):
    s2 = "MARCH"[j]
    n2 = march[s2]
    for k in range(j + 1, 5):
      s3 = "MARCH"[k]
      n3 = march[s3]
      ans += n1 * n2 * n3
print(ans)

Measured memory_bytes: 74488
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	string s, t; cin >> s;
	t = s; reverse(t.begin(), t.end());
	s += t;
	struct opt {
		int start;
		int size;
		char c;
	};
	string ans(n, 'z');
	if(k == 1){
		for(int i = 0; i <= n; i++){
			string now = s.substr(i, n);
			if(now < ans) ans = now;
		}
		cout << ans << endl;
		return 0;
	}
	for(int i = 0; i <= n; i++){
		opt now = {i, 0, s[i + n - 1]};
		for(int j = i + n - 1; j >= i && s[j] == now.c; j--, now.size++);
		int first_off = i + n - 1 - now.size;
		for(int j = 0; j < k - 2 && now.size < n; j++){
			now.size *= 2;
		}
		string here;
		int len_here = 0;
		for(int j = 0; len_here < n && j < now.size; j++){
			here.push_back(now.c);
			len_here++;
		}
		for(int j = first_off; len_here < n && j >= i; j--){
			here.push_back(s[j]);
			len_here++;
		}
		reverse(here.begin(), here.end());
		string up = here;
		reverse(up.begin(), up.end());
		here += up;
		int p = n - 1;
		while(p >= 0 && here[p] == here[n - 1]) p--;
		p++;
		string tr = here.substr(p, n);
		if(tr < ans) ans = tr;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

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

  ll n;
  std::cin>>n;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];

  std::vector<ll> left(n+1,0),right(n+1,0);

  rep(i,0,n)left[i+1]=left[i]+a[i];
  for(ll i=n-1;i>=0;i--)right[i]=right[i+1]+a[i];

  ll ans=LLONG_MAX;

  rep(i,0,n){
    chmin(ans,std::abs(left[i]-right[i]));
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 5504
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int addmod(int a, int b, int m)
{
    return ((a % m) + (b % m)) % m;
}

int mulmod(int a, int b, int m)
{
    int result = a;
    for (int i = 1; i < b; i++) {
        result = addmod(result, a, m);
    }
    return result;
}

int main()
{
    char str[100007];
    int wNum = 1;
    int aCount = 0, aCountNew = 0, abCount = 0, abCountNew = 0, abcCount = 0, abcCountNew = 0, len, modNum = 1e9 + 7;
    gets(str);
    if (str[0] == 'A')
    {
        aCountNew = ++aCount;
    }
    else if (str[0] == '?')
    {
        aCountNew = ++aCount;
        wNum = 3;
    }
    len = strlen(str);
    for (int i = 1; i < len; i++) {
        if (str[i] == 'A') {
            aCountNew = addmod(aCount, wNum, modNum);
        }
        else if (str[i] == 'B') {
            abCountNew = addmod(aCount, abCount, modNum);
        }
        else if (str[i] == 'C') {
            abcCountNew = addmod(abCount, abcCount, modNum);
        }
        else {
            aCountNew = addmod(mulmod(aCount, 3, modNum), wNum, modNum);
            abCountNew = addmod(mulmod(abCount, 3, modNum), aCount, modNum);
            abcCountNew = addmod(mulmod(abcCount, 3, modNum), abCount, modNum);
            wNum = mulmod(wNum, 3, modNum);
        }
        aCount = aCountNew;
        abCount = abCountNew;
        abcCount = abcCountNew;
    }
    printf("%d", abcCount);
    return 0;
}


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

int zh(string s)
{
	int tmp=0,i;
	for(i=0;i<s.size();i++)
	tmp=tmp*10+(s[i]-'0');
	return tmp; 
}

int main()
{
	string a,b;
	int d;
	cin>>a>>b;
	d=zh(a+b);
	if(int(sqrt(d))==sqrt(d))  cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return  0;
}

Measured memory_bytes: 256
ABCDE = [int(input()) for _ in range(5)]
w_time = []
for i in ABCDE:
    r = i % 10
    if r != 0:
        r = 10 - r
    w_time.append(r)
    
w_max = max(w_time)

ans = sum(ABCDE) + sum(w_time) - w_max

print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

	public static void main (String[] args){

		Scanner sc = new Scanner(System.in);
		int number= sc.nextInt();
		int curtain= sc.nextInt();
		curtain= 2 *curtain;

		if (curtain> number)
			System.out.println("0");
		else
			System.out.println(number-curtain);


	}

}

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

ll gc(ll a, ll b){
	if(a==0 || b==0){
		return a+b;
	}
	return gc(b%a,a);
}
ll lc(ll a, ll b){
	return a*b/gc(a,b);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll sz = lc(n,m);
	ll x = sz/n;
	ll y = sz/m;
	ll maxi = lc(x,y);
	bool ok = true;
	for(ll i = 0; i<sz; i+=maxi){
		ok &= s[(int)(i/x)]==t[(int)(i/y)];
	}
	cout << (ok?sz:-1) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
  int k;
  cin >> k;
  vector<int> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << v.at(k-1);
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict
from bisect import bisect_left


class Solution:
    def main(self):
        N = int(input())
        AB = []
        for i in range(N):
            a, b = map(int, input().split())
            AB.append((a, b))
        AB = sorted(AB, key=lambda x: x[1])

        crr = 0
        for i in range(N):
            crr += AB[i][0]
            if crr > AB[i][1]:
                print('No')
                break
        else:
            print('Yes')


if __name__ == '__main__':
    Solution().main()

Measured memory_bytes: 33756
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int r;
cin>>r;
double pi = 3.14;
cout<<(double)2*pi*r;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 3776
n , k = map(int, input().split())
v = list(map(int,input().split()))
ma = float('INF')*(-1)
m = min(n,k)
for i in range(m+1):
    for j in range(m+1-i):
        vl=v[:i]
        vr=v[n-j:]
        ans = sum(vl)+sum(vr)
        vb=vl+vr
        vb.sort()
        m2 = min(k-i-j, len(vb))
        for l in range(m2):
            if vb[l]<0:
                ans-=vb[l]
            else:
                break
        ma = max(ans,ma)
if ma<0:
    ma = 0
print(ma)


Measured memory_bytes: 9164
a = list(map(int, input().split()))
b = []
for i in range(a[0]):
    b.append(list(map(int, input().split()[1:])))

c = []
for i in b:
    for j in i:
        c.append(j)
cco = 0

for k in b[0]:
    if c.count(k) == a[0]:
        cco = cco + 1

print(cco)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int n, a, b, i, count =0, t, c;
	scanf("%d", &n);
	scanf("%d", &a);
	for(i=1; i<n; i++)
	{
		c = 0;
		scanf("%d", &b);
		while(b<=a && i<n)
		{
			c++;
			a=b;
			scanf("%d", &b);
			i++;
		}
		if(c>count) count = c;
		a=b;
	}
	printf("%d\n", count);
}

Measured memory_bytes: 256
//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register int
#define fr first
#define sd second
#define pa pair<int,int>
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define lowbit(x) (x&(-x))
#define Z(x) (x>=mod?x-mod:x)
#define N 100010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n,sum1[N],sum2[N],val[N];
int a[N],Maxn=N-10;
int main()
{
	//ios::sync_with_stdio(false);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	FOR(i,1,n)a[i]=read();
	FOR(i,1,n)if(i&1)sum1[a[i]]++;else sum2[a[i]]++;
	int Max=0;
	FOR(i,1,Maxn)
	{
		val[i]=max(val[i],sum1[i]+Max);
		Max=max(sum2[i],Max);
	}
	Max=0;
	REP(i,Maxn,1)
	{
		val[i]=max(val[i],sum1[i]+Max);
		Max=max(sum2[i],Max);
	}
	int ans=inf;
	FOR(i,1,Maxn)ans=min(ans,n-val[i]);
	printf("%d\n",ans);
	return 0;
}
//check first submit second


Measured memory_bytes: 5292
# ABC136C - Build Stairs
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    cur = A[0]
    for i in A[1:]:
        if i > cur + 1:
            cur = i - 1
        if i < cur:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 14524
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define LL long long
#define ULL unsigned long long 
#define y second
#define sqr(x) ((x)*(x))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define MEM(x) memset(x,0,sizeof(x))
#define pi acos(-1)
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
int dis[105][105];
int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    char c[105][105];
    for(int i = 1 ;i<=h;i++){
        scanf("%s",c[i]+1);
    }
    queue<pii> q,q2;
    MEMS(dis);
    q.push(mp(1,1));
    if(c[1][1]=='#')dis[1][1]=1;
    else dis[1][1]=0;
    while(!q.empty()){
        while(!q.empty()){
            pii p=q.front();
            q.pop();
            int X[2]={0,1};
            int Y[2]={1,0};
            for(int i=0;i<2;i++){
                int x=p.x+X[i],y=p.y+Y[i];
                if(x>0&&x<=h&&y>0&&y<=w&&dis[x][y]==-1){
                    if(c[x][y]==c[p.x][p.y]){
                        q.push(mp(x,y));
                        dis[x][y]=dis[p.x][p.y];
                    }
                    else{
                        q2.push(mp(x,y));
                        dis[x][y]=dis[p.x][p.y]+1;
                    }
                }
            }
        }
        swap(q,q2);
    }
    int ans=dis[h][w];
    if(c[h][w]=='#')ans++;
    printf("%d\n",ans/2);
}
/*

5
AACCMMAA
A
AA
MM
ACA
ACMAA


5
0 9 7 1 100
-1 0 -1 -1 91
-1 5 0 -1 96
-1 8 9 0 99
-1 -1 -1 -1 0
3 4
3 5
5 6
5 7
3 or 4
3 or 5
5 or 6
5 or 7

dp[x]=max(dp[x-w_i*j]+j*t_i-delta t_i*j*(j-1)/2)
dp[x]=max(dp[j]+x*t_i-j*t_i-delta t_i*(x-j)*(x-j-1)/2)
dp[x]=max(dp[j]-j*t_i-delta t_i *(j^2/2+j/2) - 
        delta t_i * xj + x*t_i + delta t_i * (x^2/2-x/2))
dp[x]=max(dp[j] + g(j) - delta t_i *xj + w(i) )
g(j)= dp[j]-j*t_i-delta t_i *(j^2/2+j/2)
w(i)=  x*t_i + delta t_i * (x^2/2-x/2)
x^2/2 -xj -x/2  +j^2/2 +j/2
*/

/*
 

*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
ll n;
ll F(ll x) {
	ll ret = 1;
	for (ll i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			ret += 2;
			if (x / i == i) ret--;
		}
	}
	return ret;
}
ll G(ll x) {
	ll ret = 1, tp;
	for (ll i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			ll tmp = x / i;
			tp = x;
			while (tp % i == 0) {
				tp /= i;
			}
			if (tp > i) tp %= i;
			ret += (tp == 1);
			if (tmp != i) {
				tp = x;
				while (tp % tmp == 0) {
					tp /= tmp;
				}
				if (tp > tmp) tp %= tmp;
				ret += (tp == 1);
			}
		}
	}
	return ret;
}
int main() {
	cin >> n;
	if (n == 2) {
		cout << 1;
		return 0;
	}
	cout << F(n - 1) + G(n);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  i64 n;
  cin >> n;
  string ans;
  do {
    ans += (char) ('a' + (n - 1) % 26);
    n = (n - 1) / 26;
  } while (n);
  reverse(all(ans));
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N >> K;
    vi d(K);
    cin >> d;
    vi x(10);
    REP(i, K)
    x[d[i]]++;
    REP(i, 1e5 + 1) {
        if (i >= N) {
            int n = i;
            bool flag = true;
            while (n) {
                int tmp = n - n / 10 * 10;
                if (x[tmp])
                    flag = false;
                n /= 10;
            }
            if (flag) {
                cout << i << endl;
                return 0;
            }
        }
    }
}

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

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

  char A[H][W];
  for (int i=0; i<H; ++i) {
    for (int j=0; j<W; ++j) cin >> A[i][j];
  }

  int H_rest[H];
  int W_rest[W];

  for (int i=0; i<H; ++i) H_rest[i]=i;
  for (int j=0; j<W; ++j) W_rest[j]=j;

  bool isWhite;

  //行チェック
  for (int i=0; i<H; ++i) {
    isWhite = true;
    for (int j=0; j<W; ++j) {
      if (A[i][j] == '#') {
        isWhite = false;
        break;
      }
    }
    if (isWhite) {
      H_rest[i] = -1;
    }
  }
  //列チェック
  for (int j=0; j<W; ++j) {
    isWhite = true;
    for (int i=0; i<H; ++i) {
      if (A[i][j] == '#') {
        isWhite = false;
        break;
      }
    }
    if (isWhite) {
      W_rest[j] = -1;
    }
  }

  //Output
  for (int i=0; i<H; ++i) {
    if (H_rest[i] == -1) {
      continue;
    }
    else {
      for (int j=0; j<W; ++j) {
        if (W_rest[j] == -1) {
          continue;
        }
        else {
          cout << A[i][j];
        }
      }
      cout << endl;
    }
  }

  return(0);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int L, A, B, C, D, a, b, R;
  scanf("%d", &L);
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  if(A % C == 0){
    a = A / C;
  }else{
    a = A / C + 1;
  }
  if(B % D == 0){
    b = B / D;
  }else{
    b = B / D + 1;
  }
  if(a >= b){
    R = L - a;
  }else{
    R = L - b;
  }
  printf("%d\n", R);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;
 
 
int main()
{
string s;
cin>>s;
 
if(s[0]=='R' && s[1]=='R' && s[2]=='R')cout<<"3";
else if((s[0]=='R'&&s[1]=='R') || (s[1]=='R'&&s[2]=='R'))cout<<"2";
else if(s[0]=='R' || s[1]=='R' || s[2]=='R')cout<<"1";
else cout<<"0";
 
 
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    b.resize(n);
    for(auto &i : b) cin >> i;
    vector <int> ans;
    while(b.size()){
        int idx = -1;
        for(int i = 0 ; i < (int)b.size() ; i++){
            if(b[i] == i + 1) idx = i;
        }
        if(idx == -1) finish(-1);
        ans.push_back(idx + 1);
        b.erase(b.begin() + idx);
    }
    reverse(ans.begin(), ans.end());
    for(auto &i : ans) cout << i << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

const int N = 2e5 + 5;

int32_t main()
{
    IOS;
    int t=1;
    // cin>>t;
    while(t--)
    {
        int x;
        cin>>x;
        if(x>=30) cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3636