akhauriyash/Code-Regression huggingface dataset:
def solve():
  n = int(input())
  total_numbers = [int(i) for i in range(1, n+1)]
  odd_numbers = total_numbers[0::2]  
  result = float(len(odd_numbers)/len(total_numbers))
  print('{:.10f}'.format(result))


if __name__ == '__main__':
  solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
using namespace std;

void dfs(int u, bool visited[], vector<int> adj[]){
  visited[u] = true;
  for(auto x: adj[u]){
    if(!visited[x])
      dfs(x, visited, adj);
  }
  return;
}

int32_t main(){
    int t;
    t = 1;
    while(t--){
        int n, m;
        cin >> n >> m;
        int a[m],b[m];
        vector<int> adj[n+1];
        for(int i=0; i<m; i++){
          cin >> a[i] >> b[i];
          adj[a[i]].push_back(b[i]);
          adj[b[i]].push_back(a[i]);
        }
        bool visited[n+1]={0};
        int count = 0;
        for(int i=1; i<=n; i++){
          if(!visited[i]){
            count++;
            dfs(i, visited, adj);
          }
        }
        cout << count-1 << endl;
    }
}



Measured memory_bytes: 12368
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

// using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}

	ll getRemainNum(const std::vector<ll>&h, int n, ll a, ll b, ll num) {
		ll res = 0;
		ll eachDamage = a - b;
		ll accumDamage = b * num;
		rep(i, n) {
			if (h[i] > accumDamage) {
				res += (h[i] - accumDamage - 1LL) / eachDamage + 1LL;
			}
		}
		return res;
	}
}

int main() {

	int n;
	ll a, b;
	std::cin >> n >> a >> b;
	std::vector<ll> h(n);
	rep(i, n) std::cin >> h[i];
	std::sort(allof(h), std::greater<ll>());
	// 1回攻撃するたびに敵全員のHPをBだけ減らす
	// さらに，敵一帯に対してa - bダメージ与える

	// あと追加のa-bダメージが何回必要か
	ll right = (h[0] - 1) / b + 2;
	ll left = -1;
	// 左の境界線を探す
	while (right - left > 1LL) {
		ll mid = (right + left) / 2LL;
		ll remain = getRemainNum(h, n, a, b, mid);
		if (remain > mid) {
			// 右を探す
			left = mid;
		}
		else right = mid;
	}
	// mid = low, right = low + 1 = mid + 1 となっている
	ll ans = right;

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9012337203685477580
using ll = long long;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<P> A(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A[i].second >> A[i].first;
    }
    sort(ALL(A));
    int cnt = 1;
    int t = A[0].first;
    for (int i = 0; i < M; i++)
    {
        if (A[i].second >= t) {
            cnt++;
            t = A[i].first;
        }
    }
    cout << cnt << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1024
function Main(input){ 
  var inputs = input.split(" ");
  var A = parseInt(inputs[0],10);
  var B = parseInt(inputs[1],10);
  var C = parseInt(inputs[2],10);
  var count = 0;
  for(i=0;B>=0;i++){
    B -= A;
    count += 1;   
  }
  count -= 1;
  if(C<=count){
    console.log(C);
  }else{
    console.log(count);
  }

  
}
    Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 11468
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm> // min()
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>
#include <random>

#include <climits> // INT_MAX
#include <cmath> // ceil()
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define b2e(vec) vec.begin(), vec.end()

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


random_device rnd;     // 非決定的な乱数生成器を生成
mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
uniform_int_distribution<> rand26(0, 25);        // [0, 99] 範囲の一様乱数

const int type_num = 26;
int D;
vector<int> c(type_num);
vector<vector<int>> s;

int decrease_satis(vector<int>& c, vector<int>& last, int d) {
	int y = 0;
	rep(i, type_num) y += c[i] * (d + 1 - last[i]);
	return y;
}


int calc_satis(vector<int>& t) {
	int satis = 0;
	vector<int> last(type_num);
	rep(i, D) {
		last[t[i]] = i + 1;
		satis += s[i][t[i]] - decrease_satis(c, last, i);
	}
	return satis;
}


int main() {
	cin >> D;

	rep(i, type_num) cin >> c[i];

	vector<int> t(D);
	rep(i, D) {
		vector<int> temp(type_num);
		rep(j, type_num) {
			cin >> temp[j];
		}
		auto iter = max_element(b2e(temp));
		size_t index = distance(temp.begin(), iter);
		t[i] = index;
		s.emplace_back(temp);
	}

	rep(i, D) cout << t[i] + 1 << endl;

}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MAX_N = 100010;

int N, P;
string S;

int solve() {
    vector<int> cs(N); // S の累積和 % P
    reverse(S.begin(), S.end());

    // cs の作成
    int mul = 1;
    REP(i, N) {
        int num = S[i] - '0';
        if(i > 0) {
            cs[i] = cs[i-1] + ((mul * num) % P);
        }
        else {
            cs[i] = num;
        }
        cs[i] %= P;

        mul *= 10;
        mul %= P;
    }

    int ans = 0;
    // 今までに数 i が何回出てきたか
    vector<int> cnt(10010, 0);
    REP(i, N) {
        if(cs[i] == 0) { ans++; }
        ans += cnt[cs[i]];
        cnt[cs[i]]++;
    }
    return ans;
}

int corner() {
    // 2 か 5 なら 1 の位を見るだけでよい
    reverse(S.begin(), S.end());
    int ret = 0;
    REP(i, N) {
        int num = S[i] - '0';
        if(num % P == 0) {
            ret += N - i;
        }
    }
    return ret;
}

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

    cin >> N >> P >> S;

    int ans = (P == 5 || P == 2) ? corner() : solve();
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 2196
#!/usr/bin/env python3
import sys
from collections import deque
import heapq

def solve(N: int, M: int, A: "List[int]"):
    a = sorted(A, reverse=False)
    a = deque(a)
    # ai(day) bi(reward)
    b_cands = []
    heapq.heapify(b_cands)

    ans = 0
    for M in range(M+1):
        while (len(a)!=0) and (a[0][0]==M):
            heapq.heappush(b_cands, -a.popleft()[1])
            # print(b_cands)
        if len(b_cands)>0:
            ans -= heapq.heappop(b_cands)

    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = []

    for i in range(N):
        A.append((int(next(tokens)),int(next(tokens))))
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 65628
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======

void speed_solve(){
    ll k, n;
    cin >> n >> k;
    ll a[k];
    rep(i,k){
        cin >> a[i];
    }
    vll v;
    rep(i,k - 1){
        v.pb(a[i + 1] - a[i]);
    }
    v.pb(a[0] + n - a[k - 1]);
    ll tot = 0;
    for(auto it : v){
        tot += it;
    }
    ll mn = inf;
    for(auto it : v){
        mn = min(mn, tot - it);
    }
    cout << mn;
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define X ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
// long long p = 1e9+7;
 
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<int> VI;
typedef vector<pair<ll,ll>> VP;
typedef vector<ll> VL;
typedef vector<bool> VB;
 
// typedef pair<ll, ll> PL;
typedef unordered_map<ll, ll> UMP;
#define FOR(i,b) for(i=0;i<b;i++)
#define pb push_back
#define mp make_pair
 
// typedef  unordered_set<ll>;
 
 
void printa(VI &x,ll n){
    ll i;
    FOR(i, n){
        cout<<x[i]<<" ";
    }
    cout<<endl;
}
 
 
/////GLOABLS VARS
ll MOD = 1e9+7;
ll gmx = 1e6+7; 

VL fact(gmx, 1);
//////FUNCTIONS
ll powp(ll val, ll deg)
{
    // debug(val, deg);
    if (!deg)
        return 1;
    if (deg & 1)
        return (powp(val, deg - 1) * val) % MOD;
    ll res = powp(val, deg >> 1);
    // debug(res);
    return (res * res) % MOD;
}





//It is not easy but it can be fun, if you think!!!

//
// ll mx = 2*1e5+7;


int main(){
      ios::sync_with_stdio(0);
      cin.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
    // #endif
    ll tc;
    cin>>tc;
    cout<<3*pow(tc,2);
    // }    
    
}

Measured memory_bytes: 11036
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  sort(all(A), greater<int>());
  vector<int> sum(N + 1);
  repr(i, N - 1, 0) {
    sum[i] = sum[i + 1] + A[i];
  }

  int ans = 1;
  repp(i, 1, N - 1) {
    if (A[i - 1] <= 2 * sum[i])
      ans++;
    else
      break;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

#define PI 3.14159265358979

int main() {

	double r;
	scanf("%lf", &r);

	printf("%.6lf %.6lf", r*r*PI, r*2.0*PI);

	return 0;
}




Measured memory_bytes: 2072
import collections
N=int(input())
A=list(map(int,input().split()))

hako = [0 for i in range(N)]
sum = 0

c = collections.Counter(A)

for v in c.values():
    sum += int(v * (v-1) / 2)


for k in range(N):
    print(sum-(c[A[k]] - 1))

Measured memory_bytes: 26772
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	long long x,k,d,ans,m=0;
	cin>>x>>k>>d;
	if(x<0){
		m=1;
		x*=-1;
	}
	if(x/d>k){
		cout<<x-d*k<<endl;
		return(0);
	}
	else{
		long long a=x;
		x%=d;
		k-=a/d;
		if(k%2==1){
			if(abs(x-d)>=abs(x+d)){
				x+=d;
			}
			else{
				x-=d;
			}
		}
	}
	cout<<abs(x)<<endl;
    return(0);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, t_in, c, t;
  cin >> n >> t_in;
  int ans = 100000;
  for(int i = 0; i < n; ++i)
  {
    cin >> c >> t;
    if (t <= t_in) ans = min(ans, c);
  }
  if (ans == 100000) cout << "TLE";
  else cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3572
//
//
// {
//        // if (dp[N][V]!=10000000000000000000) {return dp[N][V];                    }
//   if (V==0        ) {return dp[N][V]=0; }
//   else if (N==0 && V!=0) {return dp[N][V]=100000000000000000;                   }
//   else if (v[N]<=V     ) {return dp[N][V]=min(dpf(N+1,V),w[N]+dpf(N-1,V-v[N])); }
//   else if (v[N]>V      ) {return dp[N][V]=dpf(N-1,V);                           }
//   // return 0;
// }
// int main()
// {  ios_base::sync_with_stdio(false); cin.tie(NULL);
//    for(int i=0;i<=101;i++)
//    {
//      for(int j=0;j<=100001;j++)
//      {
//        dp[i][j]=1000000000000000000;
//      }
//    }
//    cin>>N>>W;
//    V=0;
//    for(int i=1;i<=N;i++)
//    {
//        cin>>w[i]>>v[i];
//        V+=v[i];
//    }
//   ll a=dpf(1,0);
//   int i;
//      for(i=V;i>=0;i--)
//    {
//      if(dp[N][i]<=W&&dp[N][i]>=0)
//      {
//        break;
//      }
//    }
//    for(int i=0;i<=N;i++)
// {
//   for(int j=0;j<=V;j++)
//   {
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<"\n";
// }
//    // for(int i=0;i<=N;i++)
//    // {
//    //  cout << w[i]<<"  ";
//    // }
//    cout<<"\n";
//    return 0;
// }
// //&&dp[N][j]!=-1)
//
//
//
//
//

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
ll dp[101][100003];
ll w[101];
ll v[101];
ll N,W,V=0;
ll dpf(ll N,ll V)
{
  if      (dp[N][V]!=-1) {return dp[N][V];                                      }
  else if (V==0        ) {return dp[N][V]=0;                                    }
  else if (N==0        ) {return dp[N][V]=1000000000000;                        } //12
  else if (v[N]<=V     ) {return dp[N][V]=min(dpf(N-1,V),w[N]+dpf(N-1,V-v[N])); }
  else                   {return dp[N][V]=dpf(N-1,V);                           }
  return 0;
}
int main()
{  ios_base::sync_with_stdio(false); cin.tie(NULL);
   memset(dp,-1,sizeof(dp));
   cin>>N>>W;
   int i;
   for(i=1;i<=N;i++)
   {
       cin>>w[i]>>v[i];
       V=V+v[i];
   }
   for(i=0;i<=V;i++)
    {
      dp[0][i]=1000000000000;
    }
    for(i=0;i<=N;i++)
     {
       dp[i][0]=0;
     }
   for(i=V;i>=0;i--)
   {
   ll a=dpf(N,i);
   }
   for(i=V;i>0;i--)
   {
     if(dp[N][i]<=W&&dp[N][i]>0)
     break;
   }
   cout<<i;
   return 0;
}


Measured memory_bytes: 79232
def sign(x):
    if x < 0:
        return -1
    elif x > 0:
        return 1
    else:
        return 0


def cumsum(a):
    c= [0] * len(a)
    c[0] = a[0]
    for i in range(1, len(a)):
        c[i] = a[i] + c[i-1]
    return c


def calc(a, signs):
    s = cumsum(a)

    op = 0
    ans = 0
    for i, sig in enumerate(signs):
        s[i] = s[i] + op
        mysign = sign(s[i])

        if mysign != sig:
            delta = sig*(abs(s[i]) + 1)
            op += delta
            s[i] += delta
            ans += abs(delta)
    return ans


def solve():
    N = int(input())
    a = [int(x) for x in input().split()]

    signs1 = [1] * N
    for i in range(N):
        if i%2==0:
            signs1[i] = -1
    signs2 = list(map(lambda x: -x, signs1))

    return min(calc(a, signs1), calc(a, signs2))


def main():
    print(solve())


if __name__ == '__main__':
    main()

Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  double y;
  for ( int i = 0; i < n; i++) {
    double x;
    cin >> x;
    string u;
    cin >> u;
    if ( u.at(0) == 'B' ) x *= 380000;
    
    y += x;
  }
  cout << y << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace SquareSearch
{
    class Program
    {
        static char GetCharOrDefault(string s, int index, char defaultChar)
        {
            if (s.Length <= index)
            {
                return defaultChar;
            }
 
            return s[index];
        }
 
 
 
        static bool SearchSquare(string line, int[] lengthOfColumns, int targetSquareLength)
        {
            var isFound = false;
 
            var count = 0;
            for (var i = 0; i < lengthOfColumns.Length; ++i) { 
                if (GetCharOrDefault(line, i, ' ')  != '*') {
                    ++lengthOfColumns[i];
                }
                else {
                    lengthOfColumns[i] = 0;
                }
 
                if (targetSquareLength <= lengthOfColumns[i])
                {
                    ++count;
                    if (targetSquareLength <= count)
                    {
                        isFound = true;
                    }
                }
                else
                {
                    count = 0;
                }
            }
 
            return isFound;
        }
 
 
        static int GetLargetSquareLength(int rank, IEnumerable<string> lines)
        {
            var columns = new int[rank];
            var targetSquareLength = 1;
            foreach (var s in lines)
            {
                if (SearchSquare(s, columns, targetSquareLength))
                {
                    ++targetSquareLength;
                }
            }
            return targetSquareLength - 1;
        }
 
 
        static IEnumerable<string> ReadLines(int count)
        {
            for (var i = 0; i < count; ++i)
            {
                yield return Console.ReadLine();
            }
        }
 
 
        static void Main(string[] args)
        {
            var answer = new List<int>();
 
            while (true) 
            {
                var input = Console.ReadLine();
                var rank = 0;
                {
                    if (int.TryParse(input, out rank) == false)
                    {
                        break;
                    }
 
                    if (rank == 0)
                    {
                        break;
                    }
                }
 
                var length = GetLargetSquareLength(rank, ReadLines(rank));
                answer.Add(length);
            }
 
            foreach (var n in answer) {
                Console.WriteLine(n);
            }
        }
    }
}

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

int main(){
  int n,x,d=0,i=0;
  cin>>n>>x;
  vector<int> num(n);
  for(int &x:num){
    cin>>x;
  }
  while(d<=x){
    i++;
    if(i==n+1) break;
    d+=num[i-1];
  }
  cout<<i<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int GCD(int a, int b) {
	if (!b) return a;
	else {
		return GCD(b, a % b);
	}
}

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

	int n, m;
	n = S / 100;
	m = S % 100;

	bool a, b;
	a = b = 1;

	if ((m < 1) || (m > 12)) a = false;
	if ((n < 1) || (n > 12)) b = false;

	if (a & b) cout << "AMBIGUOUS" << endl;
	else if (a) cout << "YYMM" << endl;
	else if (b) cout << "MMYY" << endl;
	else cout << "NA" << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,q,a,t,x;
	vll v;
	cin >> n >> q;
	vector<stack<ll>> vs(n);
	rep(i,q){
		cin >> a >> t;
		if(a==0){
			cin >> x;
			vs[t].push(x);
		}
		else if(a==1 && !(vs[t].empty())) v.pb(vs[t].top());
		else if(a==2 && !(vs[t].empty())) vs[t].pop();
	}
	for(auto& e:v) cout << e << endl;
	return 0;
}


Measured memory_bytes: 5148
#include<stdio.h>

int main()
{
	char s[110],t[110];
	int n, i, j, k,count, tmp,ans=0;
	n = 0;
	i = 0;
	scanf("%s%s", s, t);
	while (s[i] != NULL)
	{
		i++;
		n++;
	}
	for (i = 0; i < n; i++)
	{
		count = 0;
		tmp = s[n - 1];
		for (j = n-2; j >= 0; j--)
		{
			s[j+1] = s[j];
		}
		s[0] = tmp;
		for (k = 0; k < n; k++)
		{
			if (s[k] == t[k])
			{
				count++;
			}
		}
		if (count == n)
		{
			ans = 1;
		}
	}
	if (ans==1)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

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

using namespace std;

int main(){
    long n;
    cin >> n;
    long long num = n;
    int i = 2;
    while(num%n != 0 || num%2 != 0){
        num *= i;
        i ++;
    }
    
    cout << num << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int l, r, ans = 2019;
    cin >> l >> r;
    for(int i = l; i < r && i <= l + 2019; i++){
        for(int j = i + 1; j <= r && j <= l + 2019; j++){
            if(ans > ((i % 2019) * (j % 2019)) % 2019)
                ans = ((i % 2019) * (j % 2019)) % 2019;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
count = 0
flag = False

for i in range(n):
  a, b = map(int, input().split())
  if a == b:
    count += 1
  else:
    count = 0
  if count == 3:
    flag = True
    break
if flag:
  print('Yes')  
else:
  print('No')

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

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

int main()
{
    int r, c;
    cin >> r >> c;

    //m×nの2次元配列
    int table[r + 1][c + 1];

    int sum_row = 0;
    int sum_colomn = 0;
    int sum_total = 0;

    rep(i, r)
    {
        rep(j, c)
        {
            cin >> table[i][j];
        }
    }
    rep(i, r)
    {
        rep(j, c)
        {
            sum_row += table[i][j];
            sum_total += table[i][j];
        }
        table[i][c] = sum_row;
        sum_row = 0;
    }
    rep(i, c)
    {
        rep(j, r)
        {
            sum_colomn += table[j][i];
        }
        table[r][i] = sum_colomn;
        sum_colomn = 0;
    }
    table[r][c] = sum_total;
    rep(i, r + 1)
    {
        rep(j, c + 1)
        {
            if (j != 0)
            {
                cout << " ";
            }
            cout << table[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int A, H, res;
    cin >> H >> A;
    if (H%A != 0) res = H/A + 1;
    else res = H/A;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int x, ans = 1;
	cin >> x;
	for (int i = 1; i < x; i++) {
		for (int j = 2; j < x; j++) {
			if ((long long)pow(i, j) <= x) {
				ans = max(ans, (long long)pow(i, j));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
input=sys.stdin.readline
n=int(input())
B=[]
ans=0
for i in range(n):
	a,b=map(int,input().split())
	ans+=a
	if a>b:
		B.append(b)
if len(B)==0:
	print(0)
else:
	print(ans-min(B))

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

void main_()
{
    string S;
    cin >> S;

    ll ans = 0;
    ll w_count = 0;
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] == 'W') {
            ans += i - w_count;
            w_count++;
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 720
#include<iostream>
using namespace std;
int main(){
 int l,n,a;
 cin>>l;
  cin>>n>>a;

  int b;
  cin>>b;
  if(n==2)
  {
      cout<<min(b-a,l-(b-a));
      return 0;
  }
  int k=b-a;


  int c;
  for(int i=0;i<n-2;i++){
    cin>>c;
    k=max(k,c-b);

    if(i!=n-3)
        b=c;

  }

  k=max(k,l-c+a);
    cout<<l-k;
}


Measured memory_bytes: 256
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}

fn main() {
    input! {
        n:i32, m:i32,
    }
    let mut r = 0;
    if n > 1 {
        r += n * (n - 1) / 2;
    }
    if m > 1 {
        r += m * (m - 1) / 2;
    }
    println!("{}", r);
}


Measured memory_bytes: 4352
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int n;scanf("%d",&n);
    vector<ll> list(n);
    vector<ll> dp(n,INF);
    REP(i,n){
        ll tmp;scanf("%lld",&tmp);
        list[i]=tmp;
    }
    FOR(i,0,n){
        *lower_bound(dp.begin(),dp.end(),list[i])=list[i];
    }
    cout << lower_bound(ALL(dp),INF) - dp.begin() << endl;
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(100010, 0);
  vector<ll> dp(100010, 1000000007);

  for (int i = 0; i < n; i++) {
    cin >> h[i + 1];
  }

  dp[0] = 0;
  dp[1] = 0;

  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; j <= k; j++) {
      if (i - j > 0) {
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }
    }
  }

  cout << dp[n] << endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	map<int,int> mp;
	int n; cin>>n;
	rep(i,0,n){
		int a; cin>>a;
		mp[a-1]++;
		mp[a]++;
		mp[a+1]++;
	}
	int ans=0;
	for(auto c:mp){
		ans=max(ans,c.second);
	}
	cout<<ans;
		
	return 0;
}

Measured memory_bytes: 4736
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    a, b = list(map(int,ipti().split()))

    print(a+b) if a + b < 10 else print("error")

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <iomanip>
#include <math.h>
#include <mutex>

//#include "Data.h"


using namespace std;


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

	cout << (H / A) + ((H%A > 0) ? 1 : 0) << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
tree=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=MI()
    u-=1
    v-=1
    tree[u].append([v,w])
    tree[v].append([u,w])
q=deque([[0,0]])
al=[-1 for i in range(n)]
al[0]=0
col=[0 for i in range(n)]
while q:
    a,b=q.popleft()
    #print(a,b)
    for x,y in tree[a]:
        if (b+y)%2==1:
            col[x]=1
            if al[x]==-1:
                q.append([x,1])
                al[x]=0
        else:
            if al[x]==-1:
                q.append([x,0])
                al[x]=0
#print(col)
for i in range(n):
    print(str(col[i]))

    
    


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

int main(){
  int X,A;
  int Y,B;
  cin >> X >> A;
  cin >> Y >> B;
  if(Y == X + 1 && B == 1){
    cout << 1 << endl;
    }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#include <string.h>

#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
set <int> st;

int main(int argc,char const* argv[])
{
  int n,a;
  cin >> n >> a;
  int gohyaku=n/500;
  n-=gohyaku*500;
  if(n>a) 
    {
      cout << "No" << endl;
    }
  else
    {
      cout << "Yes" <<endl;
    }
  return 0;
}


Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;


int main(void) {
    ll N,K,S;
    cin>>N>>K>>S;
    vector<ll> A(N);
    if (S!=1000000000) {
        rep(i,0,K) A[i] = S;
        rep(i,K,N) A[i] = S+1;
    } else if (N!=K){
        ll now = S/2;
        rep(i,0,K+1) A[i] = now;
        rep(i,K+1,N) A[i] = now+1;
    } else {
        rep(i,0,N) A[i] = S;
    }
    rep(i,0,N) cout<<A[i]<<" ";
    cout<<endl;




   return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include <cstdio>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
ll sum[N];
//ll ans[N];
 
ll gao(int l,int r){  //求区间l,r的和
    return sum[r]-sum[l-1];
}
 
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    int n ;
    cin >>n;
    for(int i=1;i<=n;i++)   cin >> a[i];
    for(int i=1;i<=n;i++)   sum[i]=sum[i-1]+a[i]; //求前缀和
    ll l=1,r=3;
    ll ans=1e18+8;
    for(int i=2;i<=n-2;i++){
         while(l+1<i&&abs(gao(1,l)-gao(l+1,i))>=abs(gao(1,l+1)-gao(l+2,i)))//若[1,l+1]和[l+1,i]的距离比[1,l+1]和[l+2,i]的距离小，那么我们就继续加，使得两边尽可能平衡
            l++;
         while(r+1<n&&abs(gao(i+1,r)-gao(r+1,n))>=abs(gao(i+1,r+1)-gao(r+2,n)))
            r++;
         set<ll>st;///利用set的log排序
         st.insert(gao(1,l));
         st.insert(gao(l+1,i));
         st.insert(gao(i+1,r));
         st.insert(gao(r+1,n));
         ans=min(ans,abs(*st.begin()-*prev(st.end())));
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<cstring>
#include<sstream>
#include<cmath>
#include<iomanip>  


using namespace std;

const int M = 1e9 + 7;
int a[100005], b[100005], dp[100005];



int main(){

    int n, m;
    cin >> n >> m;


    for(int i = 0; i < m; i++){
          cin >> a[i];
          b[a[i]] = 1;
       }
    

    dp[0] = 1;
    
    if(!b[1]){
        dp[1] = dp[0];
    }
    else{
        dp[1] = 0;
    }


    for(int i = 2; i <= n; i++){
           if(!b[i]){
              dp[i] = (dp[i-1] + dp[i-2])%M;
           }
           else{
               dp[i] = 0;
           }

       }
    
    
    cout << dp[n];



   return 0;
 
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <utility>

const int N = 100000;

char s[N + 1];
int sum[N + 1];

std::pair<int, int> solve()
{
    int n = strlen(s);
    for (int c = 'a'; c <= 'z'; ++ c) {
        sum[0] = 0;
        for (int i = 0; i < n; ++ i) {
            sum[i + 1] = sum[i] + (s[i] == c ? 1 : -1);
        }
        std::pair<int, int> mi {0, 0};
        for (int i = 2; i <= n; ++ i) {
            mi = std::min(mi, std::make_pair(sum[i - 2], i - 2));
            if (mi.first < sum[i]) {
                return {mi.second + 1, i};
            }
        }
    }
    return {-1, -1};
}

int main()
{
    scanf("%s", s);
    auto result = solve();
    printf("%d %d\n", result.first, result.second);
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;

int a[15];
int b[15];




int main() {
	for (int i = 0; i < 15; i++)a[i] = 1000000;
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 1; i < n+1; i++) {
		int u = s[i-1] - '0';
		if (a[u] == 1000000)a[u] = i;
		b[u] = i;
	}
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			set<int> ti;
			for (int u = a[i]+1; u < b[j]; u++) {
				int k = s[u - 1] - '0';
				ti.insert(k);
			}
			ans += ti.size();
		}
	}
	cout << ans;
}

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

#define int long long
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).end()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a,n) sort(a, a+n)
#define sortvec(V) sort(all(V))

typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

void solve()
{
    int n;
    cin >> n;
    int ans = (n + 2) * (n + 1) * (n) / 6;
    for(int i = 0; i < n - 1; i++){
        int x, y;
        cin >> x >> y;
        if(x > y)   swap(x, y);
        --x, --y;
        ans -= ((x + 1) * (n - y));
    }
    cout << ans << endl;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}

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

typedef long long ll;
const int N = 1000 + 10;
int v[N*2], u[N*2], cost[N*2];
ll dis[N];
bool vis[N];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++)
    {
        scanf("%d%d%d", &v[i], &u[i], &cost[i]);
        cost[i] = -cost[i];
    }
    memset(dis, 0x3f, sizeof dis);
    memset(vis, 0, sizeof vis);
    dis[1] = 0;
    for(int i = 1; i <= n-1; i++)
        for(int j = 1; j <= m; j++)
            dis[u[j]] = min(dis[u[j]], dis[v[j]] + cost[j]);
    ll ans = -dis[n];
    for(int i = 1; i < n; i++)
        for(int j = 1; j <= m; j++)
        {
            if(dis[u[j]] > dis[v[j]] + cost[j])
            {
                dis[u[j]] = dis[v[j]] + cost[j];
                vis[u[j]] = true;
            }
        }
    if(vis[n]) puts("inf");
    else printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
#define f(i,l,r) for(ll i=l;i<=r;i++)
using namespace std;
int main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   ll X;
   cin >> X;
   ll a[1005] = {0};
   f(i,1,1004) a[i] = pow(i,5);
   bool Y = false;
   f(i,0,1004){
      if(a[i] == X){
          cout << i << " 0";
          return 0;
      }
      else{
         f(j,1,1004) if(a[i] - a[j] == X){
            cout << i << " " << j;
            Y  = true;
            return 0;
         }
         if(Y == false) f(j,1,1004) if(a[i] + a[j] == X){
             cout << i << " " << -j;
             return 0;
         }
      }
   }
   return 0;
}


Measured memory_bytes: 4124
#include<iostream>
#include<string>
using namespace std;
int main(){
  int s;
  cin >> s;
  int t=s%100;
  s/=100;
  string ans;
  if(0<s&&s<13){
    if(0<t&&t<13){
      ans="AMBIGUOUS";
    }else ans="MMYY";
  }else if(0<t&&t<13) ans="YYMM";
  else ans="NA";
  cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define debug(x) cerr<<#x<<":"<<x<<endl;

signed main() {
  int mul=1, num=0;
  int n;cin>>n;
  for(int i=0;i<n;++i){
    int q,x; cin>>q>>x;
    switch(q){
    case 1:
      mul *= x;
      num *= x;
      break;
    case 2:
      num += x;
      break;
    case 3:
      num -= x;
      break;
    }
    // debug(num);
    // debug(mul);
  }
  cout << -num << " " << mul << endl;
  return 0;
}



Measured memory_bytes: 3120
//Awwawa! Dis cold yis ratten buy waxberry!
#include <bits/stdc++.h>
#define ll long long
#define maxn 500005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int n, k;
int a[maxn];
int d[maxn];
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (int i = 1; i <= min(k, 50); i++) {
		memset(d, 0, sizeof(d));
		for (int i = 1; i <= n; i++) {
			int ls = max(1, i - a[i]);
			d[ls]++;
			int rs = min(n, i + a[i]);
			d[rs + 1]--;
		}
		for (int i = 1; i <= n; i++)
			d[i] += d[i - 1], 
			a[i] = d[i];
	}
	for (int i = 1; i <= n; i++)
		printf("%d ", a[i]);
	return 0;
}


Measured memory_bytes: 6556
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main() {
	//freopen("in","r",stdin);
	int n; cin>>n;
	int a,b; 
	a = b = 0;
	string tmp1, tmp2;
	for(int i=0;i<n;i++) {
		cin>>tmp1>>tmp2;
		if(tmp1.compare(tmp2)==0) {
			a++; b++;
		} else if(tmp1.compare(tmp2)>0) a += 3;
		else b += 3;
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 3172
program main
  
  implicit none
  character(100) :: s
  integer :: i,j,k,n
  
  read(*,*) s
  n = len_trim( s )
  
  j = 0
  do i = 1, n
    if ( mod(i,2) == 0 ) then
      if ( s(i:i) == "R" ) then
        print*, "No" 
        j = 1
        exit
      end if
    else
      if ( s(i:i) == "L" ) then
        print*, "No" 
        j = 1
        exit
      end if
    end if
  end do
  if( j == 0 ) print*, "Yes" 
end program main


Measured memory_bytes: 256