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

using ll=long long;
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin>>a[i];

  int lb=0;
  int ub=1e8;
  while(ub-lb>1){
    ll mid=(ub+lb)/2;
    stack<pair<pair<int,int>,int>> st;
    st.push({{0,a[0]},0});
    
    auto shrink=[&st](int sz){
      while(true){
	auto tmp=st.top(); st.pop();
	if(tmp.first.first<sz){
	  st.push({{tmp.first.first,sz},tmp.second});
	  break;
	}
      }
    };

    auto incl=[&st,mid](){
      int head=-1;
      while(true){
	if(st.size()==0){
	  return false;
	}
	auto tmp=st.top(); st.pop();

	if(tmp.second<mid-1){
	  if(tmp.first.first+1==tmp.first.second){
	    st.push({tmp.first,tmp.second+1});
	  }
	  else{
	    st.push({{tmp.first.first,tmp.first.second-1},tmp.second});
	    st.push({{tmp.first.second-1,tmp.first.second},tmp.second+1});
	  }
	  if(head!=-1) st.push({{tmp.first.second,head},0});
	  break;
	}
	if(head==-1) head=tmp.first.second;
      }
      return true;
    };
		    
    bool isok=true;
    for(int i=1;i<n;i++){
      if(a[i-1]<a[i]){
	st.push({{a[i-1],a[i]},0});
      }
      else{
	shrink(a[i]);
	if(!incl()){
	  isok=false;
	  break;
	}
      }

    }
    if(isok){
      ub=mid;
    }
    else{
      lb=mid;
    }
  }
  cout<<ub<<endl;
}

Measured memory_bytes: 4288
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String s = sc.next();
      	int num = 0;
      	for (int i=0; i<s.length(); i++){
        	if(s.charAt(i)=='1') num++;
        }
      	System.out.println(num);
    }
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(n!=6){puts("No");return 0;}
	if(s[3]!=s[4]){puts("No");return 0;}
	if(s[5]!=s[6]){puts("No");return 0;}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
t = [input() for i in range(3)]
array1 = []
array2 = []
array3 = []

for i in range(len(t[0])):
  array1.append(t[0][i])
for i in range(len(t[1])):
  array2.append(t[1][i])
for i in range(len(t[2])):
  array3.append(t[2][i])

who_turns = 0  
a_count = 0
b_count = 0
c_count = 0

for i in range(len(array1)+len(array2)+len(array3)):
  
  if who_turns ==0 :
    for j in range(a_count, len(array1)):
      if a_count != len(array1):
        a_count = a_count +1
        if array1[j] == "a":
          continue
        elif array1[j] == "b":
          who_turns = 1
          break
        elif array1[j] == "c":
          who_turns = 2
          break
      else:
        break
  
  if who_turns == 1:
    for j in range(b_count,len(array2)):
      if b_count != len(array2):
        b_count = b_count + 1
        if array2[j] == "a":
          who_turns = 0
          break
        elif array2[j] == "b":
          continue
        elif array2[j] == "c":
          who_turns = 2
          break
      else:
        break
        
  if who_turns == 2:
    for j in range(c_count,len(array3)):
      if c_count != len(array3):
        c_count = c_count +1
        if array3[j] == "a":
          who_turns = 0
          break
        elif array3[j] == "b":
          who_turns = 1
          break
        elif array3[j] == "c":
          continue
      else:
        break
      
  if who_turns == 0 and a_count == len(array1):
    print("A")
    break
  elif who_turns == 1 and b_count == len(array2):
    print("B")
    break
  elif who_turns == 2 and c_count == len(array3):
    print("C")
    break


    
    

      
   


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int memo[45];

int fibonacchi(int num)
{
    if (memo[num] != -1) {
        return memo[num];
    } else if (num == 0 || num == 1) {
        memo[num] = 1;
        return memo[num];
    } else {
        int result = fibonacchi(num - 1) + fibonacchi(num - 2);
        memo[num] = result;
        return memo[num];
    }
}

int main()
{
    for (int i = 0; i < 45; ++i)
        memo[i] = -1;

    int n;
    cin >> n;
    cout << fibonacchi(n) << '\n';
}



Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define MOD 1000000007

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,y;
    cin >> n >> y;
    bool disc=false;
    y/=1000;
    for(int i=0;i<=n;i++) {
        for(int j=0;j<=n-i;j++) {
            if(i*9+j*4+n==y) {
                cout << i << " " << j << " " << n-i-j << endl;
                disc=true;
                break;
            }
        }
        if(disc) break;
    } 
    if(!disc) cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 1000000007;

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

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

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

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

    UnionFind uf(n);

    for (ll i = 0; i < m; ++i) {
        ll x, y, z;
        cin >> x >> y >> z;
        --x;
        --y;
        uf.unite(x, y);
    }

    ll res = 0;
    for (ll i = 0; i < n; ++i) {
        if (uf.root(i) == i) {
            ++res;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

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

  ll ans = 0;
  rrep(b,n) {
    // n = p*b + r;
    int p = n/b;
    int r = n%b;
    ans += p*max(0,b-k) + max(0,r-k+1) - max(0,0-k+1);
  }

  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define CLR(a, b) memset((a), (b), sizeof((a)))
template <typename t> bool ckmin(t& a, const t& b) {return a > b ? a = b, true : false;}
template <typename t> bool ckmax(t& a, const t& b) {return a < b ? a = b, true : false;}

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

    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    
    vi first(n), last(n);
    int cnt = 0;
    F0R(i, n) {
        if(s[i] == 'x') continue;

        first[i] = ++cnt;
        if(cnt == k)
            break;
        i += c;
    }
    R0F(i, n - 1) {
        if(s[i] == 'x') continue;

        last[i] = cnt--;
        if(!cnt)
            break;
        i -= c;
    }
    F0R(i, n)
        if(first[i] && first[i] == last[i])
            cout << i + 1 << endl;

    
}




Measured memory_bytes: 3348
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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

int a[91][91];
int M1;
void f(int i,int j,int s,int a[91][91]){

	if(a[i][j-1]==0 && a[i][j+1]==0 && a[i-1][j]==0 && a[i+1][j]==0){

		s++;
		if(M1<s) M1=s;

	}
	else{

	a[i][j]=0;

	if(a[i][j-1]==1) f(i,j-1,s+1,a);
	if(a[i][j+1]==1) f(i,j+1,s+1,a);
	if(a[i-1][j]==1) f(i-1,j,s+1,a);
	if(a[i+1][j]==1) f(i+1,j,s+1,a);

	a[i][j]=1;
	}
}

int main(){

	int m,n,ice;
	while(1){

		cin >> m >> n;
		if(m==0 && n==0) break;

		REP(i,1,n){
		REP(j,1,m){
			cin >> ice;
			a[i][j]=ice;
		}
	}
        int M=0;
		REP(i,1,n){
		REP(j,1,m){
		if(a[i][j]==1){

			M1=0;
			f(i,j,0,a);
			if(M<M1) M=M1;
		}
		}
		}


		cout << M << endl;

		REP(i,1,n) REP(j,1,m) a[i][j]=0;
	}

	return 0;

}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll n;
vector<pair<ll,ll>>ch[16];
bool man[16];
ll ans;
void cal(){
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(man[i]==0){
			continue;
		}
		cnt++;
		for(ll j=0;j<ch[i].size();j++){
			ll next=ch[i][j].first;
			if(ch[i][j].second!=man[next]){
				return;
			}
		}
	}
	ans=max(ans,cnt);
}
void dep(ll now){
	if(now==n){
		cal();
		return;
	}
	man[now]=0;dep(now+1);
	man[now]=1;dep(now+1);
}
int main() {
	cin>>n;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		for(ll j=0;j<now;j++){
			ll x,y;
			cin>>x>>y;
			x--;
			ch[i].push_back(make_pair(x,y));
		}
	}
	dep(0);
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3624
n,m = map(int, input().split())
d = list(map(int, input().split()))
inf = float('inf')
dp = [inf for i in range(n+1)]
dp[0] = 0
for i in range(m):
    for j in range(d[i], n+1):
        dp[j] = min(dp[j], dp[j-d[i]]+1)

print(dp[-1])


Measured memory_bytes: 7648
#include <cstdio>
#include <algorithm>
#define ll long long
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=2e3+5,mod=1e9+7;
int n,m,l,k,i,j,p,q,ans,g[2][N],s[N];
int main()
{
//	freopen("eternal.in","r",stdin);
//	freopen("eternal.out","w",stdout);
	scanf("%d%d%d",&n,&m,&k);
	l=(n+m-1)/(k-1);
	g[0][0]=1; p=0; q=1;
	rep(i,1,l)
	{
		swap(p,q);
		s[0]=g[q][0];
		rep(j,1,n) s[j]=(g[q][j]+s[j-1])%mod;
		rep(j,0,min(n,k-1)) g[p][j]=s[j];
		rep(j,k,n) g[p][j]=(s[j]-s[j-k]+mod)%mod;
		rep(j,1,n)
			if ( j%(k-1)==n%(k-1) && (k-1-j%(k-1))%(k-1)==(m-1)%(k-1) && (k-1)*i-j<=m-1)
			  ans=((ll)ans+mod+g[p][j]+s[j-1]-s[j])%mod;
	}
	printf("%d\n",ans);
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int N, Q;
string s;
int x, y;
int q;

int main()
{
  while(cin >> N >> Q, N){
    vi data(N);
    map<int, pair<int, string> > hm;
    rep(i, N){
      cin >> s >> x >> y;
      data[i] = y - x + 1;
      hm[y - x + 1] = mp(y, s);
    }
    sort(ALL(data));

    while(Q--){
      cin >> q;
      int pos = upper_bound(ALL(data), q) - data.begin();
      if(hm[data[pos - 1]].first >= q){
        cout << hm[data[pos - 1]].second << ' ' << q - data[pos - 1] + 1 << endl;
      }
      else cout << "Unknown" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<vector<int> > F(n, vector<int>(10));
  vector<vector<ll> > P(n, vector<ll>(11));
  rep(i,n) {
    rep(j,10) cin >> F[i][j];
  }
  rep(i,n) {
    rep(j,11) cin >> P[i][j];
  }
  ll ans = -1001001001;
  for (int bit = 1; bit < (1<<10); ++bit) {
    vector<int> cnt(n,0);
    rep(j,10) {
      if (!(bit & (1<<j))) continue;
      rep(i,n) {
        if (F[i][j] == 1) cnt[i]++;
      }
    } 
    ll res = 0;
    rep(i,n) {
      // debug(bit, cnt[i]);
      res += P[i][cnt[i]];
    }
    chmax(ans, res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[105];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
        scanf("%d",&a[i]);
    int res=100000000;
    for (int i=-100;i<=100;++i) {
        int tmp=0;
        for (int j=1;j<=n;++j)
            tmp+=(a[j]-i)*(a[j]-i);
        res=min(res,tmp);
    }
    printf("%d\n",res);
    return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

inline bool is_in(const int x, const int a, const int b) {
    return a <= x && x <= b;
}

int main() {
    int n;
    cin >> n;
    vi a(n), lm(n), rm(n);
    int max_a = INT_MIN;
    lm[0] = INT_MIN;
    rm[n - 1] = INT_MIN;
    REP(i, n) {
        cin >> a[i];
        if(i > 0) {
            max_a = max(max_a, a[i - 1]);
            lm[i] = max_a;
        }
    }
    max_a = INT_MIN;
    REPR(i, n - 1) {
        max_a = max(max_a, a[i + 1]);
        rm[i] = max_a;
    }
    REP(i, n) {
        cout << max(lm[i], rm[i]) << "\n";
    }

    return 0;
}


Measured memory_bytes: 3968
from collections import defaultdict
import bisect
s = list(input())
t = list(input())
ds = defaultdict(int)
dsl = defaultdict(list) 
for i in range(len(s)):
    ds[s[i]] += 1
    dsl[s[i]].append(i)


ans = 0
now = -1  # ここが-1じゃないと、最初の遷移でsの最初の文字を使えない
for i in range(len(t)):
    if ds[t[i]] == 0:
        print("-1")
        exit()
    else:
        index = bisect.bisect_right(dsl[t[i]], now)
        if index == len(dsl[t[i]]):
            index = -1
        if dsl[t[i]][index] > now:
            ans += (dsl[t[i]][index] - now)
            now = dsl[t[i]][index]
        else:
            ans += dsl[t[i]][0] + (len(s) - now)
            now = dsl[t[i]][0]

print(ans)


Measured memory_bytes: 9308
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int n = s.length;
        int max = 0;
        for (int i = 0 ; i < n ; i++) {
            for (int j = i ; j < n ; j++) {
                boolean flg = true;
                for (int k = i ; k <= j ; k++) {
                    if (s[k] != 'A' && s[k] != 'T' && s[k] != 'C' && s[k] != 'G') flg = false;
                }
                if (flg) max = Math.max(max, j - i + 1);
            }
        }
        System.out.println(max);

    }

}


Measured memory_bytes: 22740
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanVecInt(A, N);
    ll sum = 0;
    for (auto& a : A){
        sum += a;
    }
    ll temp = 0;
    ll result = INT_MAX;
    loop(i, N - 1){
        auto& a = A[i];
        temp += a;
        const ll m = abs((sum - temp) - temp);
        result = min(result, m);
    }
    printf("%lld\n", result);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define f1(i,n) for(int i=1 ; i<=n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)

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

int n ,ans,a[mx2],b[mx2],c[mx2];

int main() {
    ios::sync_with_stdio(false);
    int t;
    //cin>>t;while(t--)
    {
        cin>>n;
        fo(i,n-1)cin>>b[i];
        ans+=b[0];
        fo(i,n-2)
        {
        	//cout<<b[i]<<"\n";
            ans+=min(b[i],b[i+1]);
        }
        cout<<ans+b[n-2];
    }
    
    
    return 0;
}


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


int main(){
    ll n, m = 1e+18;
    cin >> n;
    rep(i, 5){
        ll c;
        cin >> c;
        m = min(m, c);
    }
    ll res;
    if (n % m == 0) res = n / m;
    else res = n / m + 1;
    cout << res + 4 << endl;
}

Measured memory_bytes: 384
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long ans = ((N - 1) * N) / 2;

		Console.WriteLine(ans);
	}
}

//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 27488
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int r = n%10;
    if(r==3){cout<<'b';}
    else if(r==0||r==1||r==6||r==8){cout<<'p';}
    else{cout<<'h';}
    cout<<"on";
}

Measured memory_bytes: 3652
#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>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll n,W; cin>>n>>W;
	vvl dp(n+10,vl(100100));
	rep(i,0,n){
		rep(j,0,100100){
			dp[i][j]=MOD;
		}
	}
	
	dp[0][0]=0;
	vl v(n),w(n);
	rep(i,0,n) cin>>v[i]>>w[i];
	rep(i,0,n){
		rep(j,0,100100){
			dp[i+1][j]=dp[i][j];
			if(j-v[i]>=0)chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
		}
	}
	ll ans=0;
	rep(i,0,100100){
		if(dp[n][i]<=W){
			ans=i;
		}
	}
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 89984
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	vector<int> vec(3);
	for (auto& v : vec) {
		cin >> v;
	}

	for (int i = 0; i < vec.size(); i++) {
		for (int j = 0; j < vec.size(); j++) {
			if (i == j) {
				continue;
			}

			if (vec[i] == vec[j]) {
				vec[i] = vec[j] = INF;
			}
		}
	}

	for (auto v : vec) {
		if (v != INF) {
			cout << v << endl;
			return 0;
		}
	}

	return 0;
}


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

using ll = long long;
int main() {
        int N;
        int A[100005];
        ll sum = 0, d = 2;
        cin >> N;
        for (int i = 0; i < N; i++) {
                cin >> A[i];
                if (i == 0) sum += A[i] - 1;
                else if (d == A[i]) d++;
                else sum += (A[i] - 1) / d;
        }
        cout << sum << endl;
        return (0);
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    string a;
    while(cin>>a)
    {
        int s1=0,s=700;
        int n;
        n=a.length();
        for(int i=0;i<n;i++)
        {
           if(a[i]=='o')s1+=100;
        }
        s+=s1;
       cout <<s <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N, K, S;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> N >> K >> S;
        if(N == 0) break;
        int ans = 0;
        for(int i = 0; i < (1 << N); i++) {
            int now = 0;
            int num = 0;
            for(int j = 0; j < N; j++) {
                if(i & (1 << j)) {
                    num++;
                    now += j + 1;
                }
            }
            ///cerr << i << " " << num <<
            if(num == K && now == S) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
s=int(input())
p=10**9+7
if s<=2:
    print(0)
    exit()
n=s//3
ans=0
def f(n,k,p):
    if k==0:
        return 1
    elif k%2==0:
        return (f(n,k//2,p)**2)%p
    else:
        return (n*f(n,k-1,p))%p

for k in range(1,n+1):
    a=1
    b=1
    for j in range(k-1):
        a=(a*(s-3*k+1+j))%p
        b=(b*(j+1))%p
    ans=(ans+a*f(b,p-2,p))%p

print(ans%p)



Measured memory_bytes: 76524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int even[110000] = {};
int odd[110000] = {};
pair<int, int> mae1, mae2;
pair<int, int> mao1, mao2;

int main()
{
    int n;
    cin >> n;
    mae1 = mae2 = mao1 = mao2 = make_pair(0, 0);
    int mi = INT_MAX;
    int ma = INT_MIN;
    for (int i = 1; i <= n; i++)
    {
        int tmp;
        cin >> tmp;
        mi = min(mi, tmp);
        ma = max(ma, tmp);
        if (i % 2 == 0)
            even[tmp]++;
        else
            odd[tmp]++;
    }
    for (int i = mi; i <= ma; i++)
    {
        if (mae1.first < even[i])
        {
            mae2 = mae1;
            mae1.first = even[i];
            mae1.second = i;
        }
        else if (mae2.first < even[i])
        {
            mae2.first = even[i];
            mae2.second = i;
        }
        if (mao1.first < odd[i] && mao1.second != i)
        {
            mao2 = mao1;
            mao1.first = odd[i];
            mao1.second = i;
        }
        else if (mao2.first < odd[i])
        {
            mao2.first = odd[i];
            mao2.second = i;
        }
    }
    if (mao1.second != mae1.second)
    {
        cout << (n - mao1.first - mae1.first) << endl;
    }
    else
    {
        int an = (n - mao1.first - mae2.first);
        int ans = (n - mao2.first - mae1.first);
        cout << min(an, ans) << endl;
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t;
  cin>>t;
  string s;
  cin>>s;
  string str="...";
  if(s.length()<=t){
    str=s;
    cout<<str<<endl;
  }
  else{
    str=s.substr(0,t)+str;
    cout<<str<<endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a[200001],mn;
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n);
  if(a[n/2]==a[n/2-1]) cout << 0 << endl;
  else cout << (a[n/2]-a[n/2-1]) << endl;
  return 0; 
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

struct T{
	int id,p,rank;
	T():id(-1),p(0),rank(-1){}
	T(int id,int p,int rank):id(id),p(p),rank(rank){}
	bool operator < (const T& t) const{
		return p>t.p;
	}
};
bool comp (const T& t1,const T& t2){
		return t1.id<t2.id;
}

int main(){
	int N;cin >>N;
	vector<T> ts(N);
	for(int i=0;i<N;i++){
		ts[i].id=i;
	}
	for(int i=0;i<N*(N-1)/2;i++){
		int f,t,fp,tp;cin >> f>>t>>fp>>tp;f--;t--;
		if(fp<tp)ts[t].p+=3;
		else if(fp>tp)ts[f].p+=3;
		else{
			ts[f].p+=1;ts[t].p+=1;
		}
	}
	sort(ALL(ts));
	int rank=0;int p=-1;int dup=1;
	for(int i=0;i<N;i++){
		if(ts[i].p==p){
			dup++;
			ts[i].rank=rank;
		}else{
			rank+=dup;
			ts[i].rank=rank;
			dup=1;p=ts[i].p;
		}
	}
	sort(ALL(ts),comp);
	for(int i=0;i<N;i++){
		cout<<ts[i].rank<<endl;	
	}
	return 0;
}

Measured memory_bytes: 1200
N = int(input())
W = list(map(int,input().split()))

res = 10**10

for i in range(1,N):
    tmp1 = W[:i]# + W[i:]
    tmp2 = W[i:]

    sum_tmp1 = sum(tmp1)
    sum_tmp2 = sum(tmp2)

    ans = abs(sum_tmp1 - sum_tmp2)

    if(ans < res):
        res = ans
print(res)

Measured memory_bytes: 3064
n = gets.to_i
t = []
gets.chomp.split(' ').map(&:to_i).each do |e|
	t << e
end
m = gets.to_i
px = []
while line = gets
	(p, x) = line.chomp.split(' ').map(&:to_i)
	px << [p, x]
end

sum = t.inject(0) { |s, i| s + i }

px.each_with_index do |p, i|
  # puts "#{sum} - #{t[p[0] - 1]} + #{p[1]}"
  puts sum - t[p[0] - 1] + p[1]
end


Measured memory_bytes: 1788
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int n, k, x, sum;
	sum = 0;
	cin >> n >> k;
	for (int i = 0; i<n; i++) {
		cin >> x;
		sum += min(x, k - x);
	}
	cout << sum * 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int h[200001];
long long a[200001],t[800004];
void put(int i,int l,int r,int pos,long long x)
{
    if(l==r)
        t[i]=x;
    else
	{
        int mid=(l+r)/2;
        if(pos<=mid)
            put(2*i+1,l,mid,pos,x);
        else
            put(2*i+2,mid+1,r,pos,x);
        t[i]=max(t[2*i+1], t[2*i+2]);
    }
}
long long RMQ(int i, int ll,int rr,int l,int r)
{
    if (l<=ll&&rr<=r)
        return t[i];
    int mid=(ll+rr)/2;
    long long ret=0;
    if(l<=mid)
        ret=max(ret,RMQ(2*i+1,ll,mid,l,r));
    if(r>mid)
        ret=max(ret,RMQ(2*i+2,mid+1,rr,l,r));
    return ret;
}
int main()
{
	int n,i;
	scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    	scanf("%lld",&h[i]);
    	h[i]--;
	}
    for(i=0;i<n;i++)
    	scanf("%d",&a[i]);
    for(i=n-1;i>=0;i--)
        put(0,0,n-1,h[i],a[i]+RMQ(0,0,n-1,h[i],n-1));
    printf("%lld",RMQ(0,0,n-1,0,n-1));
    return 0;
}

Measured memory_bytes: 8832
#include<cstdio>
#include<algorithm>

int main(void){
	int i,j;
	bool z[1024]; //???????????????????????????????????????????????¨false)
	int x[1024],y[1024],k=0; //k=???????????????????????°
	for(i=0;i<1024;i++){
		x[i]=-1;
		y[i]=-1;
		z[i]=true;
	}
	while(true) {
	
		int n,m,Sa=0,Sb=0;
		int a[100],b[100];
	
		scanf("%d%d",&n,&m);
		
		if((n==0)&&(m==0)) break;
		
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(i=0;i<m;i++){
			scanf("%d",&b[i]);
		}
	
		std::sort(a,a+n);
		std::sort(b,b+m);
	
	//for(i=0;i<n;i++){
	//	printf("a[%d]=%d\n",i,a[i]);
	//}
		for(i=0;i<n;i++){
			Sa+=a[i];
		}
		for(i=0;i<m;i++){
			Sb+=b[i];
		}
	
		int d=Sa-Sb;
		
		if(d%2==0){
			d=d/2;
			
			//printf("d=%d\n",d);
			
			for(i=0;i<n;i++){
				if(z[k]==false) break;
				for(j=0;j<m;j++){
					if(a[i]-d==b[j]){
						x[k]=a[i];
						y[k]=b[j];
						z[k]=false;
					//	printf("x=%d,y=%d,k=%d\n",x[k],y[k],k);
					}
					if(z[k]==false) break;
				}
			}
		}
		k++;
		//printf("k=%d\n",k);
	}	
		
	for(i=0;i<k;i++){	
		if(z[i]){
			printf("-1\n");
		} else {
			printf("%d %d\n",x[i],y[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 2656
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 105;
int a[maxn];
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int as = 0;
	for(int i = 0;i < n; ++i)
	{
		cin>>a[i];
		as += a[i];
	}
	int p = 1e9,index = 0;
	for(int i = 0;i < n; ++i)
	{
		if(abs(a[i] * n - as) < p)
		{
			index = i;
			p = abs(a[i] * n - as);
		}
	}
	cout<<index<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
	int N, A, B, C;
	cin >> N >> A >> B >> C;

	vector<int> L(N);
	for (int i = 0; i < N; i++)
		cin >> L[i];

	int mx = pow(4, N);
	int ans = 1e5;
	for (int i = 0; i < mx; i++) {
		vector<int> bit(N);
		int temp = i;
		for (int j = 0; temp > 0; j++) {
			bit[j] = temp % 4;
			temp /= 4;
		}
		int a = 0, b = 0, c = 0;
		int fa = 0, fb = 0, fc = 0;
		int cost = 0;
		for (int k = 0; k < N; k++) {
			if (bit[k] == 0) {
				a += L[k];
				fa++;
				if (fa >= 2)
					cost += 10;
			}
			if (bit[k] == 1) {
				b += L[k];
				fb++;
				if (fb >= 2)
					cost += 10;
			}
			if (bit[k] == 2) {
				c += L[k];
				fc++;
				if (fc >= 2)
					cost += 10;
			}

			
		}
		if (!fa || !fb || !fc) continue;
		cost += abs(A - a) + abs(B - b) + abs(C - c);
		ans = min(ans, cost);
		//cout << "cost=" << cost << endl;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); i++)
typedef pair<ll,ll> P;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

vector<ll> a(51);
vector<ll> p(51);

ll solve(ll n,ll x){

  if(n==0){
    if(x<=0){
      return 0;
    }else{
      return 1;
    }
  }else if(x <= 1+a[n-1]){
    return solve(n-1, x-1);
  }else{
    return p[n-1] + 1 + solve(n-1, x-2-a[n-1]);
  }
}


int main(){

  ll n, x;
  cin >> n >> x;
  
  a[0] = 1;
  p[0] = 1;

  rep(i,50){
    a[i+1] = a[i]*2 + 3;
    p[i+1] = p[i]*2 + 1;
  }

  cout << solve(n,x) << endl;

  return 0;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  li a,v,b,w; cin >>a >>v >>b >>w;
  li d=max(a-b,b-a);
  li t; cin >>t;
  if(v<=w){
    print("NO");
    return 0;
  }
  if((v-w)*t>=d){
    print("YES");
  }else{
    print("NO");
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using ll = long long;
int main() {
    vector<int> a(3); cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    int c = (a[2]-a[1])/2;
    int d = (a[2]-a[0])/2;
    a[1] += 2*c;    a[0] += 2*d;
    sort(a.begin(),a.end());
    for(int i=0;i<3;i++) a[i] = a[i]%2;
    int res = c+d;
    if(a[0]==a[1]&&a[1]!=a[2]) res+=1;
    if(a[0]!=a[1]&&a[1]==a[2]) res+=2;
    if(a[0]!=a[1]&&a[1!=a[2]]) res+=3;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
a = int(input())
Ans = 0
for i in range(1,a+1):
	if i%3 != 0 and i%5 != 0:
		Ans += i
print(Ans)

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


int main(){
    int N, M; cin >> N >> M;
    vector<int> A(M), B(M), X(M);
    vector<vector<int>> table(N+3);
    for(int i=0; i<table.size(); i++){
        for(int j=0; j<=i; j++){
            table[i].push_back(0);
        }
    }
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i] >> X[i];
        B[i]--; 
        table[A[i]][B[i]]++;
        table[A[i]][B[i]+1]--;
        table[A[i]+X[i]+1][B[i]]--;
        table[A[i]+X[i]+2][B[i]+1]++;
        table[A[i]+X[i]+1][B[i]+X[i]+2]++;
        table[A[i]+X[i]+2][B[i]+X[i]+2]--;
    }
    for(int i=0; i<table.size(); i++){
        for(int j=1; j<=i; j++){
            table[i][j]+=table[i][j-1];
        }
    }
    for(int i=1; i<table.size(); i++){
        for(int j=0; j<i; j++){
            table[i][j]+=table[i-1][j];
        }
    }
    for(int i=1; i<table.size(); i++){
        for(int j=1; j<=i; j++){
            table[i][j]+=table[i-1][j-1];
        }
    }
    int cnt=0;
    for(int i=0; i<table.size(); i++){
        for(int j=0; j<=i; j++){
            if(table[i][j] > 0) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 70092
#include<iostream>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    int i,a[n],b[n],c[n-1];
    int p,j,points=0;
    for(i=0; i<n; i++){
        cin>>a[i];
    }
    for(i=0; i<n; i++){
        cin>>b[i];
    }
    for(i=0; i<n-1; i++){
        cin>>c[i];
    }
    for(j=0; j<n; j++)
    {   if(j>=1)
        {
            if(a[j] == a[j-1]+1){
             p= a[j];
             points =points+b[p-1]+c[p-2];}
            else{
            p=a[j];
            points = points+ b[p-1];}
        }
        else{
            p=a[j];
            points = points+ b[p-1];}
            
    }
    
    cout<<points;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
a=[]
b=[]
for _ in range(N):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
a=sorted(a)
b=sorted(b)
if N%2==1:
    print(b[N//2]-a[N//2]+1)
else:
    print((b[N//2-1]+b[N//2])-(a[N//2-1]+a[N//2])+1)

Measured memory_bytes: 27048
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>
#include<map>
#include<iomanip>



using namespace std;


int main() 
{
    double L;
    cin >> L;
    double volume;
    volume = (double)(L * L * L) / 27.0;
    cout <<setprecision(10)<< volume;



}
    




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (int)1e9+7
#define EPS 1e-8
#define INF 1e9+10
#define INFL 1e18
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  if(N%2==0){
      cout << N << endl;
  }
  else{
      cout << 2*N << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            99999999999999


void solve()
{
   int cnt=0,temp=0,now;
   cin>>now;
   vector<string>v;
   v.push_back("1"); v.push_back("2"); v.push_back("3");
   v.push_back("4"); v.push_back("5"); v.push_back("6");
   v.push_back("7"); v.push_back("8"); v.push_back("9");
   vector<string>ans;
   ans=v;
   cnt=9;
   while(1)
   {
       vector<string>another;
       //for(int i=0;i<v.size();i++) cout<<v[i]<<endl;
       for(int i=0;i<v.size();i++)
       {
           string dup=v[i];
           int sizes=dup.size();
           char x=dup[sizes-1]-1;
           if(x!='/')
           {
              another.push_back(dup+x);
              ans.push_back(dup+x);
              cnt++;
           }
           x=dup[sizes-1];
           another.push_back(dup+x);
           ans.push_back(dup+x);
           cnt++;
           x=dup[sizes-1]+1;
           if(x>='1'&&x<='9')
           {
              another.push_back(dup+x);
              ans.push_back(dup+x);
              cnt++;
           }
           if(cnt>=now) { temp=1; break; }
       }
       if(temp==1) break;
       v.clear();
       v=another;
   }
   sort(v.begin(),v.end());
   //for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
   //cout<<endl;
   cout<<ans[now-1]<<endl;


}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; cin>>t; while(t--) solve();
    solve();
}


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

#define ll long long
int main() {
  int N;
  cin >> N;
  
  vector<ll> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  ll ans = 0;
  ll submax = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < submax) {
      ans += submax - A[i];
    } else {
      submax = A[i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(1==n%2){
        cout<<"No";
        return 0;
    }else{
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]){
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define N 200001
long long p = 998244353;
long long a, b, c, d, e, k, l, m, n, ans, tx[400];
long long x[N], y[N], zx[N], zy[N], nx[N], ny[N], nz[N], r[N];
int main() {
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", x + i, y + i);
		x[i] += 2 * p;
		y[i] += 2 * p;
		zx[i] = x[i] * N + i;
		zy[i] = y[i] * N + i;
	}
	std::sort(zx, zx + n);
	std::sort(zy, zy + n);
	for (int i = 0; i < n; i++) {
		nx[zx[i] % N] = i;
		ny[zy[i] % N] = i;
	}
	m = (n - 1) / 500 + 1;
	for (int i = 0; i < n; i++) {
		l = nx[zy[i] % N];
		k = l/500;
		tx[k]++;
		for (int j = 0; j < k; j++) {
			nz[zy[i] % N] += tx[j];
		}
		for (int j = 500 * k; j < l; j++) {
			if (ny[zx[j] % N] < i)nz[zy[i] % N]++;
		}
	}
	r[0] = 1;
	for (int i = 1; i <= n; i++) {
		r[i] = r[i - 1] * 2 % p;
	}
	for (int i = 0; i < n; i++) {
		a = nz[i];
		b = ny[i] - a;
		d = nx[i] - a;
		c = n - 1 - a - b - d;
		ans += r[n] - 1;
		ans -= r[a + b] + r[b + c] + r[c + d] + r[d + a];
		ans += r[a] + r[b] + r[c] + r[d] + 4 * p;
		ans %= p;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
	int cur = 1, ans = 0, p = -1;
	for(int i = 0; i < n ; ++i){
		if(v[i] != cur){
			++ans;
		}else{
			p = 1;
			++cur;
		}
	}
	if(p == -1) ans = -1;
	printf("%d\n", ans); 
	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;
const int MM = 1e5+2;

int n;
pair<ll, ll> a[MM];
map<ll, ll> dp;

int main(){
    
    scan(n);
    for(int i = 0; i < n; i++){
        ll m, l;
        scan(m, l);
        a[i] = {m+l, m-l};
    }
    sort(a, a+n);
    dp[-1e10] = dp[1e10] = 0;
    auto pre = dp.lower_bound(-1e10);
    for(int i = 0; i < n; i++){
        ll l = a[i].second;
        while(1){
            ll ov = pre->second;
            pre++;
            pre->second = max(pre->second, ov);
            //print(pre->first, pre->second);
            if(pre->first > l){
                pre--;
                break;
            }
        }
        ll nx = a[i].first;
        dp[nx] = max(dp[nx], pre->second+1);
    }
    
    ll ans = 0;
    for(auto i: dp)
        ans = max(ans, i.second);
    print(ans);
    
    return 0;
}

Measured memory_bytes: 8064