akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  vi h(n);
  rep(i,n) cin>>h[i];
  vi dp(n);
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
    mins(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout<<dp[n-1]<<endl;
}    


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

int main() {
  vector<int> as(5);
  for (auto &a : as) {
    cin >> a;
  }
  
  sort(as.begin(), as.end());
  
  int ans = (1 << 30);
  do {
    int tmp = 0;
    for (int i = 0; i < 4; i++) {
      tmp += (as[i] + 9) / 10 * 10;
    }
    tmp += as[4];
    ans = min(ans, tmp);
  } while (next_permutation(as.begin(), as.end()));
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll GCD(ll x, ll y) {//最大公約数：x%y!=0ならばGCD(y, x%y)、0ならばyを返す(x>y)
    return x % y ? GCD(y, x%y) : y;
}

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, g, m;
    cin >> n >> k;
    vll a(n, inf);
    m = 0;
    REP(i, n){
        cin >>a[i];
        if(a[i] > m) m = a[i];
        if(a[i] == k){
            cout << "POSSIBLE" <<"\n";
            return 0;
        }
    }
    g = a[0];
    FOR(i, 1, n-1){
        g = GCD(g, a[i]);
    }
    if(m >= k && k % g == 0){
        cout << "POSSIBLE" <<"\n";
    }else{
        cout << "IMPOSSIBLE" <<"\n";
    }
	return 0;
}

Measured memory_bytes: 1024
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

const static ul NMAX = 100000;

static ul N;
static sc S[NMAX];

void solve(void) {
  ul res = 0;
  sc prev = '\0';
  FOR0(i, N) {
    if (S[i] != prev) {
      res++;
    }
    prev = S[i];
  }
  cout << res << endl;
}

int main(void) {
  cin >> N;
  FOR0(i, N) {
    cin >> S[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int a[N] , b[N] ;
map<PII , int> mp ;
int work()
{
  int n , m , k ;
  scanf("%d%d%d" , &n , &m , &k) ;
  for(int i = 1; i <= k ;i ++ ) {
    int x , y ;
    scanf("%d%d" , &x , &y) ;
    a[x] ++ , b[y] ++ ;
    mp[{x , y}] = 1 ;
  }
  vector<int> va , vb ;
  int maxn = 0 ;
  for(int i = 1; i <= n ;i ++ )
   if(a[i] > maxn) maxn = a[i] , va.clear() , va.emplace_back(i) ;
   else if(a[i] == maxn) va.emplace_back(i) ;
  maxn = 0 ;
  for(int i = 1; i <= m ;i ++ ) {
    if(b[i] > maxn) maxn = b[i] , vb.clear() , vb.emplace_back(i) ;
    else if(b[i] == maxn) vb.emplace_back(i) ;
  }
  int ans = 0 ;
  for(auto x : va) {
    for(auto y : vb) {
      if(!mp[{x , y}])
       return cout << a[x] + b[y] << endl , 0 ;
    }
  }
  cout << a[va.back()] + b[vb.back()] - 1 << endl ;
  return 0 ;
}
int main()
{
  //   freopen("C:UsersspnooyseedDesktopin.txt" , "r" , stdin) ;
  //   freopen("C:UsersspnooyseedDesktopout.txt" , "w" , stdout) ;

  work() ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 23432
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MID = 8010;
const int MAX = 8005;
const int SZ = 2 * MAX + 10;

const int HOR = 0;
const int VER = 1;

string s;
int x, y;

int dp[2][SZ];
bool Can(int how, vi& d){
  if(how + MID < 0 || how + MID >= SZ)
    return false;

  //cout << "?" << how << endl;
  //for(int e : d) cout << e << ' ';
  //cout << endl;

  int* cdp = dp[0];
  int* ndp = dp[1];
  fill(cdp, cdp + SZ, 0);
  fill(ndp, ndp + SZ, 0);

  int lo = 0, hi = 0;
  cdp[0 + MID] = true;

  sort(all(d));
  for(int e : d){
    fill(ndp + lo + MID, ndp + hi + MID, 0);
    for(int i = lo;i <= hi;++i)
      if(cdp[i + MID]){
        ndp[i + e + MID] = true;
        ndp[i - e + MID] = true;
      }
    lo -= e;
    hi += e;
    swap(cdp, ndp);
  }

  return cdp[how + MID] == true;
}

int main(){
  ios_base::sync_with_stdio(false);

  cin >> s;
  cin >> x >> y;
  s += 'T';

  bool first = true;
  int dir = HOR;
  int len = 0;

  vi dx, dy;

  for(char c : s){
    if(c == 'T'){
      if(len){
        if(first) x -= len;
        else if(dir == HOR) dx.pb(len);
        else dy.pb(len);
      }
      first = false;
      dir ^= 1;
      len = 0;
    } else ++len;
  }

  if(Can(x, dx) && Can(y, dy)) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int n,r;
  cin >> n >> r;

  if(n >= 10) {
    cout << r << endl;
  } else {
    cout << r + (100 * (10 - n)) << endl;
  }

  return 0;
}


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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}



void solve() {
            
          ll n;
          cin >> n;
          
          ll sum = 0LL;
          ll ans = 0LL;
          for(ll i = 1; i <= n; i++) {
                    ll a;
                    cin >> a;
                    ll curr = (sum % mod) * (a % mod) % mod;
                    ans = (((ans % mod) + (curr % mod)) % mod);
                    sum += a;
          }
          
          cout << ans <<endl;
        
           
       
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3620
//#############################################################################
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define vec vector
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Helpers
void io_handler()
{
#ifdef LOCAL_TESTING
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
template <typename T>
void print_matrix(vector<vector<T>> mat){
    for(auto row: mat){
        for(auto e : row){cout << e << " ";}
        cout << endl;
    }
}
template <typename T>
void print_vector(vector<T> v){
    for(auto e : v){cout<< e <<" ";}
    cout<<endl;
}
template <typename T>
map<T,T> get_count(vector<T> v){
    map<T,T> count;
    for(auto e: v){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
//#############################################################################
//Solution
void solve(){
    int n;
    cin>>n;
    vec<double> p(n);
    vec<vec<double>> dp(n+1,vec<double>(n+1,0.0));
    dp[0][0] = 1;
    for(int i = 0; i<n; i++){
        cin>>p[i];
    }
    //print_vector(p);
    for(int i = 1; i<=n; i++){
        for(int j = 0; j<=i; j++){
            if(j==0){
                dp[i][0] = (1-p[i-1])*dp[i-1][0];
            }
             else{
                dp[i][j] = p[i-1]*dp[i-1][j-1]+(1-p[i-1])*dp[i-1][j];
            }
        }
    }
    //print_matrix(dp);
    double ans = 0.0;
    for(int i = n; i>n/2; i--){
        ans += dp[n][i];
    }
    cout<<setprecision(10)<<ans<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
#ifdef LOCAL_TESTING
    cout << "⏰ Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
//#############################################################################


Measured memory_bytes: 70784
N, M = map(int, input().split())
a = list(map(int, input().split()))

sums = sum(a)
count = 0

for i in a:
  #print(i, sum)
  if i >= (sums / ( M * 4 )):
    count += 1

if count >= M:
  print('Yes')
else:
  print("No")


Measured memory_bytes: 9116
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, int> w;
    int ans = 1;
    char last;
    rep(i, n) {
      string s;
      cin >> s;
      if (i > 0 && last != s[0]) {
        ans = 0;
        break;
      }
      last = s[s.size() - 1];

      if (w[s] == 0) {
        w[s] = 1;
      } else {
        ans = 0;
        break;
      }
    }

    if (ans) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
r,g,b,n = map(int,input().split())
cnt = 0
l = [r,g,b]
l.sort()
r = l[2]
g = l[1]
b = l[0]

for i in range(n//r + 1):
    for j in range((n-r*i)//g + 1):
        if (n-r*i-g*j)%b == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int row1, row2;
    int columns1, columns2;
    cin >> row1;
    cin >> columns1;
    cin >> row2;
    cin >> columns2;

    cout << (row1 - row2)*(columns1 - columns2) << endl;
    return 0;
}


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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;



int main()
{
    ll n;
    lscf(n);
    ll a[n];
    
    int c=0;

    rep(i,0,n)
    {
        lscf(a[i]);
        if(a[i]>1000000000)
        c++;
        if(a[i]==0)
        {
            pri(0);
            return 0;
        }
    }

    if(c>=2)
    {
        cout<<"-1";
        return 0;
    }

    sort(a,a+n);

    ll pro=1;
    rep(i,0,n)
    {
        pro=pro*a[i];
        if(pro>1000000000000000000||pro<0)
        {
            cout<<"-1";
            return 0;
        }
    }
    cout<<pro;
return 0;
}

Measured memory_bytes: 4492
#include <bits/stdc++.h>
#define ll long long int    
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const ll MOD = 1e9 + 7, N = 1e6 + 3;
vector<ll> fact[N];

void sieve(){
    for(int i = 1; i < N; ++i){
        for(int j = i; j < N; j += i){
            fact[j].push_back(i);
        }
    }
}

int main(){
    ll n;
    cin >> n;
    ll a[n], hash[N] = {0};
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        hash[a[i]]++;
    }
    sieve();
    ll cnt = 0;
    for(int i = 0; i < n; ++i){
        int d = 0;
        for(int j = 0; j < fact[a[i]].size(); ++j){
            if(fact[a[i]][j] == a[i]){
                if(hash[fact[a[i]][j]] > 1)
                    ++d;
                    break;
            }
            else if(hash[fact[a[i]][j]] > 0){
                ++d;
                break;
            }
        }
        if(d == 0)
            ++cnt;
    }
    cout << cnt;
    return 0;
}

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

int main(){
    int n,v,j,m,cnt,g;
    int a[1000000];
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];

    cnt = 0;
    m = 1;
    g = 1;
    for(g=1; g<= n/9; g=g*3+1){
        m += 1;
    };
    cout << m << endl;
    while(g>=1){
        cout << g << " ";
        for(int i=g; i<n; i++){
            v = a[i];
            j = i-g;
            while(j>=0 && a[j] > v){
                a[j+g] = a[j];
                j = j-g;
                cnt++;
            };
            a[j+g] = v;
        };
        g /= 3;
    };
    cout << endl << cnt << endl;
    for(int i=0; i<n; i++){
        cout << a[i] << endl;
    };
    return 0;
}


Measured memory_bytes: 6892
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
/*
std::vector<std::pair<std::set<int>, std::set<int>>> list;

int root_idx;

std::vector<int> FindLongestPathToRoot(int n){
	if(n == root_idx) {
      std::vector<int> v;
      v.push_back(n);
      return v;
    }
  	std::vector<int> max_path;
  	for(int parent : list[n].first){
    	auto tmp = FindLongestPathToRoot(parent);
    	if(tmp.size() > max_path.size()) max_path = tmp;
    }
  max_path.push_back(n);
  return max_path;
}

int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++){
    list.push_back(std::make_pair(std::set<int>(), std::set<int>()));
  }
  for(int i = 0; i < N - 1 + M; i++){
  	int from, to;
    scanf(" %d %d", &from, &to);
    list[to - 1].first.insert(from - 1);	// in
    list[from - 1].second.insert(to - 1);	// out
  }
  for(int i = 0; i < N; i++){
  	if(list[i].first.size() == 0){
      root_idx = i;
      break;
    }
  }
  for(int i = 0; i < N; i++){
    if(list[i].first.size() == 0){
    	printf("0\n");
      continue;
    }
    if(list[i].first.size() <= 1){
      printf("%d\n", *list[i].first.begin() + 1);
      continue;
    }
    auto path = FindLongestPathToRoot(i);
    for(int p : path){
    }
    int p = 0;
    while(path.size()){
      p = path.back();
      path.pop_back();
      if(list[i].first.find(p) != list[i].first.end()){
        break;
      }
    }
    for(auto it = list[i].first.begin(); it != list[i].first.end(); )
        if(*it != p){
          list[*it].second.erase(list[*it].second.find(i));
          it = list[i].first.erase(it);
        }
      else ++it;
    printf("%d\n", *list[i].first.begin() + 1);
  }
  return 0;
}
*/

std::multiset<int> list;

int main(){
  int N;
  scanf("%d", &N);
  for(int i = 0; i < N; i ++){
  	int tmp;
    scanf(" %d", &tmp);
    list.insert(tmp);
  }
  auto it = list.rbegin();
  int max = *(it);
  it++;
  int sum = 0;
  while(it != list.rend()) {
    sum += *it;
    it++;
  }
  printf("%s\n", sum > max ? "Yes" : "No");
  return 0;
}

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

int main(){
    int n,k;
    cin >> n;
    char s[n];
    cin >> s;
    cin >> k;
    for(int i=0;i<n;i++){
        if(s[k-1]!=s[i])s[i]='*';
    }
    cout << s <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a =scan.nextInt();
		String s = scan.next();
		scan.close();
		if(a>=3200){
			System.out.println(s);
		}else{
			System.out.println("red");
		}
	}

}

Measured memory_bytes: 23636
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static Node root = null;
	private static class Node {
		Node() {
			this.value = -1;
			this.leftNode = null;
			this.rightNode = null;
		}
		public int value;
		public Node leftNode;
		public Node rightNode;
	}

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		Scanner s = new Scanner(System.in);
		int cnt = new Integer(br.readLine()).intValue();
		for(int i=0 ; i<cnt ; i++) {
			String[] tmp = br.readLine().split(" ");
			if("insert".equals(tmp[0])) {
				Node n = new Node();
				n.value = new Integer(tmp[1]).intValue();
				insert(n);
			}else if("find".equals(tmp[0])) {
				Node n = new Node();
				n.value = Integer.parseInt(tmp[1]);
				boolean result = find(n);
				if(result)
					System.out.println("yes");
				else
					System.out.println("no");
			}
			else {
				inorder(root);
				System.out.println();
				preorder(root);
				System.out.println();
			}
		}
		if(br!=null) {
			br.close();
			br = null;
		}
	}

	public static void insert(Node node) {
		if(root==null){
			root = node;
			return;
		}
		Node targetNode = root;
		Node parent = null;
		while(targetNode != null) {
			parent = targetNode;
			if(targetNode.value > node.value)
				targetNode = targetNode.leftNode;
			else
				targetNode = targetNode.rightNode;
		}
		if(parent.value > node.value)
			parent.leftNode = node;
		else
			parent.rightNode = node;
	}

	public static boolean find(Node node) {
		if(root==null)
			return false;
		Node target = root;
		while(target!=null) {
			if(target.value==node.value)
				return true;
			else{
				if(target.value>node.value) {
					target = target.leftNode;
				}else{
					target = target.rightNode;
				}
			}
		}
		return false;
	}

	public static void preorder(Node root) {
		System.out.print(" " + root.value);
		if(root.leftNode != null)
			preorder(root.leftNode);
		if(root.rightNode != null)
			preorder(root.rightNode);
	}

	public static void inorder(Node root) {
		if(root.leftNode != null)
			inorder(root.leftNode);
		System.out.print(" " + root.value);
		if(root.rightNode != null)
			inorder(root.rightNode);
	}
}

Measured memory_bytes: 218260
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int nc = 0, nm = 1e9+1;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a < 0) {
            nc++;
        }
        a = abs(a);
        ans += a;
        nm = min(nm, a);
    }

    cout << (nc % 2 == 0 ? ans : ans - nm * 2) << endl;

    return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int s,x,y;
    cin>>s;
    x=RUP(s,1000000000);
    y=1000000000*x-s;
    cout<<"0 0 1 1000000000 "<<x<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
/* ITP1_8_C: Counting Characters */
/* 20181124 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <ctype.h>
#define N 1200
#define M 26

int main(void) {
	char str[N];
	char c;
	int cnt[M] = {0};
	int i = 0;

	while(scanf("%c", &str[i]) != EOF) {
		c = tolower(str[i++]);
		if(c >= 'a'  && c <= 'z') {
			cnt[c - 'a']++;
		}
	}

	for(i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a' + i, cnt[i]);
	}
}


Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll par[100005]={0};
vector<ll> node[100005];
ll ans=0;
ll dfs(ll pos,ll k){
  ll max_d=0;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    max_d=max(max_d,dfs(to,k)+1);
  }
  if(max_d>=k-1&&par[pos]!=1){
    ans++;
    return -1;
  }
  else return max_d;
}
int main(){
  ll n,k;
  cin>>n>>k;
  for(ll i=1;i<=n;i++){
    cin>>par[i];
    if(i!=1) node[par[i]].push_back(i);
  }
  if(par[1]!=1) ans++;
  par[1]=1;
  dfs(1,k);
  cout<<ans<<endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  if(n<4){cout<<"No"<<endl; return 0;}
  if(n==5){cout<<"No"<<endl; return 0;}
  if(n==6){cout<<"No"<<endl; return 0;}
  if(n==9){cout<<"No"<<endl; return 0;}
  if(n==10){cout<<"No"<<endl; return 0;}
  if(n==13){cout<<"No"<<endl; return 0;}
  if(n==17){cout<<"No"<<endl; return 0;}
  cout << "Yes" << endl;
  return 0;
}


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

int main () {
    int N, tmp;
    int satisfaction = 0;
    vector<int> A, B, C;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A.push_back(tmp);
    }
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        B.push_back(tmp);
    }
    for (int i = 0; i < N-1; i++) {
        cin >> tmp;
        C.push_back(tmp);
    }

    tmp = -1;
    for (int i = 0; i < N; i++) {
        satisfaction += B[A[i] - 1];
        if (A[i] - tmp == 1) {
            satisfaction += C[A[i] - 2];
        }
        tmp = A[i];
    }

    cout << satisfaction << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define i64 long long
#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);
#define pi 2.0*acos(0.0)
#define mod 1000000007
#define mp make_pair
#define pii pair<int,int>
#define pss pair<string,string>
#define fi first
#define se second
#define pb push_back
#define sortVA(v) sort(v.begin(),v.end())
#define sortVD(v) sort(v.begin(),v.end(),greater<int>())
#define ASC(a,n) sort(a,a+n);
#define DESC(a,n) sort(a,a+n,greater<int>());
#define out(x) cout <<x<<endl
#define outt(x,y) cout <<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))
bool col[5];
int main()
{
    fast_io
    int n;
    cin >>n;
    vector<char>v(n);
    //getchar();
    for(int i=0;i<n;i++){
        cin >>v[i];
        if(v[i]=='P'){col[0]=1;}
        if(v[i]=='W'){col[1]=1;}
        if(v[i]=='G'){col[2]=1;}
        if(v[i]=='Y'){col[3]=1;}
    }

    int c=0;
    for(int i=0;i<n;i++){
        if(col[i]==1)c++;
    }
    if(c==3){out("Three");}
    else{out("Four");}
    return 0;
}







Measured memory_bytes: 256
s = input()

Amemo = 0
result = 0
A = False
B = False
C = False
for c in s:
    if c == 'A':
        if B:
            Amemo = 0
        A = True
        B = False
        C = False
        Amemo += 1
    elif c == 'B':
        if A or C:
            A = False
            B = True
            C = False
        else:
            Amemo = 0
            A = False
            B = False
            C = False
    elif c == 'C':
        if B:
            result += Amemo
            A = False
            B = False
            C = True
        else:
            Amemo = 0
            A = False
            B = False
            C = False
print(result)

Measured memory_bytes: 3628
// Vicfred
// https://atcoder.jp/contests/abc174/tasks/abc174_e
// binary search
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

long n, k;
long[] a;

bool check(long x) {
    long cuts = 0;
    for(long i = 0; i < n; i++)
        cuts += (a[i] - 1)/x;
    return cuts <= k;
}

void main() {
    readf("%s %s\n", &n, &k);

    a = readln.split.map!(to!long).array;

    long left = 0;
    long right = 10^^9+1;

    while(right - left > 1) {
        const long mid = (left + right)/2;
        if(check(mid)) right = mid;
        else left = mid;
    }

    right.writeln;
}



Measured memory_bytes: 10416
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>21){
    cout << "bust" <<endl;
  }
  else {
    cout << "win" <<endl;
  }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int rev(int x, int l, int r){
    int n = x-l;
    return r-n;
}

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

    vector<int> x(m),y(m),z(m);
    rep(i,m){
        cin >>x[i] >>y[i] >>z[i];
        --y[i];
        --z[i];
    }

    int k;
    cin >>k;
    --k;

    int idx = k;
    for(int i=m-1; i>=0; --i){
        if(x[i]==0){
            if(y[i]<=idx && idx<=z[i]) idx = rev(idx, y[i], z[i]);
        }
    }

    ll val = a+idx*d;
    rep(i,m){
        if(y[i]<=idx && idx<=z[i]){
            if(x[i]==0) idx = rev(idx, y[i], z[i]);
            if(x[i]==1) ++val;
            if(x[i]==2) val /= 2;
        }
    }
    cout << val << endl;
    return 0;
}



Measured memory_bytes: 4940
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
        return
    dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
    dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))

s = input()

dfs(0, s[0], int(s[0]))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,a[200005];
	long long ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n-k;i++) ans+=a[i];
	cout<<ans<<endl;
	return 0;
} 

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string n; cin>>n;
	int sum=0;
	for(auto&&i:n)sum=(sum+i-'0')%9;
	cout<<(sum?"No"s:"Yes"s)<<"\n"s;
}


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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;

lli n;
lli a[100005];
lli DP[100005];
lli cal(lli pos)
{
    if(pos==(n))
        return 0;
    if(pos>n)
        return MAX;
    if(DP[pos]!= -1)
        return DP[pos];
    lli res,res2;
    if((pos+1)<=n)
        res =abs(a[pos+1]-a[pos])+cal(pos+1);
    else
        res=MAX;
    if((pos+2)<=n)
         res2 = abs(a[pos+2]-a[pos])+cal(pos+2);
    else
        res2=MAX;
    DP[pos]= min(res,res2);
    return DP[pos];
}
int main ()
{
    mem(DP,-1);
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    cout << cal(1)<<endl;
    return 0;
}



Measured memory_bytes: 4992
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
		Arrays.sort(a);
		System.out.println(a[2] == a[1] + a[0] ? "Yes" : "No");
	}
}

Measured memory_bytes: 21716
#include <stdio.h>

int main(void)
{
    int A, B;
    int sum = 0;

    scanf("%d %d", &A, &B);
 
    for( int i = 0; i < 2; ++i){

        if( A > B ){
            sum = sum + A;
            A   = A - 1;
        }
        else{
            sum = sum + B;
            B   = B - 1;
        }
    }
    printf("%d", sum);
    
    return 0;
}


Measured memory_bytes: 128
n,d = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(n)]

def dist_squere(x, y):
    d = 0
    for i,j in zip(x,y):
        d += (i-j)**2
    return d

squares = set([i*i for i in range(10000)])
def is_square(x):
    return x in squares

from itertools import combinations

ans = 0
for x,y in combinations(X, 2):
    if is_square(dist_squere(x, y)):
        ans += 1

print(ans)

Measured memory_bytes: 10008
def fact(n):
    if n == 0:
        return 1
    else:
        return n*fact(n-1)
def conb(n,r):
    return fact(n)//(fact(r)*fact(n-r))

N,A,B = map(int,input().split())
v = list(map(int,input().split()))
v.sort()
v.reverse()
d_all = {}
for i in range(N):
    if v[i] not in d_all:
        d_all[v[i]] = 0
    d_all[v[i]] += 1
import numpy as np
avg = np.cumsum(np.array(v))
avg = [0]*N
avg[0]=v[0]
for i in range(N-1):
    avg[i+1]=avg[i]+v[i+1]
for i in range(N):
    avg[i]=avg[i]/(i+1)
    
avg = avg[A-1:B]
ans = max(avg)
print(ans)
avg=np.array(avg)
indices = np.where(avg==ans)[0]
ans = 0
for index in indices:
    d_use = {}
    use = A + index
    v_use = v[:use]
    choose=1
    for item in v_use:
        if item not in d_use:
            d_use[item] = 0
        d_use[item] += 1
    for item in d_use:
        choose *= conb(d_all[item],d_use[item])
    ans += choose

print(ans)

Measured memory_bytes: 21312
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

#define MAX 1000002

typedef unsigned char byte;
byte mask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
 
int *Lv;
int n, k;
 
bool cmp_Lv(const int i, const int j){ return Lv[i] < Lv[j]; }
 
bool cmp(const int i, const int j){
    if(Lv[i] != Lv[j]){ return Lv[i] < Lv[j]; }
    int L_i = (i + k >= n ? -1 : Lv[i + k]);
    int L_j = (j + k >= n ? -1 : Lv[j + k]);
 
    return L_i < L_j;
}
 
int main()
{
    int *A;
    char c[MAX];
    scanf("%s", c);
    std::string T = std::string(c);
    n = T.size();

	A = new int[n + 1], Lv = new int [n + 1];

    byte *t;
    t = new byte [(n >> 3) + 1];
    bool act;
    int l, r;
 
    int i;
    for(i = 0; i < n; i++){ A[i] = i; }
    for(i = 0; i < n; i++){ Lv[i] = T[i]; }
 
    int bkt[129];
    for(i = 0; i < 129; i++){ bkt[i] = 0; }
    for(i = 0; i < n; i++){ bkt[Lv[i]]++; }
    int sum = 0;
    for(i = 0; i < 129; i++){ sum += bkt[i]; bkt[i] = sum; }
    for(i = 0; i < n; i++){ A[--bkt[Lv[i]]] = i; }
 
    //std::sort(A, A + n, cmp_Lv);
 
    for(i = 1; i < n; i++){
        t[i >> 3] = (Lv[A[i]] != Lv[A[i - 1]] ? t[i >> 3] | mask[i & 7] : t[i >> 3] & ~mask[i & 7]);
    }
    t[n >> 3] = t[n >> 3] | mask[n & 7];
 
    Lv[A[0]] = 0;
    for(i = 1; i < n; i++){
        Lv[A[i]] = Lv[A[i - 1]] + !!(mask[i & 7] & t[i >> 3]);
    }
 
    k = 1;
    while(1){
        if(k > n) break;
 
        act = true;
        for(i = 1; i <= n; i++){
            if(act){
                if(!!(mask[i & 7] & t[i >> 3])){ continue; }
                else{ l = i - 1; act = false; }
            }else{
                if(!!(mask[i & 7] & t[i >> 3])){
                    r = i; std::sort(A + l, A + r, cmp); act = true; }
                    else{ continue; }
            }
        }
 
        for(i = 1; i < n; i++){
            t[i >> 3] = (cmp(A[i - 1], A[i]) ? t[i >> 3] | mask[i & 7] : t[i >> 3] & ~mask[i & 7]);
        }
        t[n >> 3] = t[n >> 3] | mask[n & 7];
 
        Lv[A[0]] = 0;
        for(i = 1; i < n; i++){
            Lv[A[i]] = Lv[A[i - 1]] + !!(mask[i & 7] & t[i >> 3]);
        }
 
        if(Lv[A[n - 1]] == n - 1) break;
        k <<= 1;
    };
 
    char p[1000];
    int q, left, right, mid, crit;
    bool exist;
    scanf("%d", &q);
 
    A[n] = n;
 
    while(q){
        scanf("%s", p);
        std::string P = std::string(p);
        left = 0, right = n, exist = false;
        while(left < right){
 
            if(n < P.size()){ exist = false; break; }
 
            mid = (left + right) / 2;
            crit = T.compare(A[mid], P.size(), P);
 
            if(crit > 0){ right = mid; }
            else if(crit < 0){ left = mid + 1; }
            else{ exist = true; break; }
        };
        if(T.compare(A[right], P.size(), P) == 0) exist = true;
        if(exist){ printf("1\n"); }else{ printf("0\n"); }
        q--;
    }
    return 0;
}

Measured memory_bytes: 11112
#include<stdio.h>

int main() {
	int a,b,c,k;
	scanf("%d %d %d %d", &a, &b, &c, &k);
	if (a >= k) {
	   printf("%d", k);
   }else if (a+b >= k) {
		printf("%d",a);
	}else if (a+b < k) {
		printf("%d", 2*a+b-k);
   }
   printf("\n");
   return 0;
}


Measured memory_bytes: 1728
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<unordered_map>
#include<ctime>
const  int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef long double ld;
#define pa pair<int,int>
#define sc(n) scanf("%lld",&n)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
int n, m;
unordered_map<char, int> mp;
int a[N], b[N];
//struct cmp
//{
//	bool operator () (int x, int y)
//	{
//		return x > y;
//	}
//};
int main()
{
	int t;
	int cnt = 0;
	sc(n);
	fo(i, 0, n)
		sc(a[i]);
	sort(a, a + n);
	int l = n / 2 - 1, r = l + 1;
	cout << a[r] - a[l] << endl;
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   string s;
   cin>>s;
   int r=0;
   int c=0;
   for(int i=0; i<s.length(); i++){
       if(s[i]=='R'){
           c++;
       }else{
           r = max(r, c);
           c=0;
       }
   }
   r=max(r,c);
   cout<<r<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
vector<lli> arr;
int count = 0;
lli solve(int start, int end, lli x, lli y, bool x_turn = true)
{
    //        cout<<x<<" "<<y<<"\n";
    //count++;
    if (start > end)
    {

        return x - y;
    }
    int res1, res2;

    if (x_turn)
    {
        if (start == end)
        {

            return (x + arr[start]) - y;
        }
        res1 = solve(start + 1, end, x + arr[start], y, !x_turn);
        res2 = solve(start, end - 1, x + arr[end], y, !x_turn);
        return max(res1, res2);
    }
    else
    {
        if (start == end)
        {
            return x - (arr[start] + y);
        }
        res1 = solve(start + 1, end, x, arr[start] + y, !x_turn);
        res2 = solve(start, end - 1, x, arr[end] + y, !x_turn);
        return min(res1, res2);
    }
}

lli solve2(int N)
{
    vector<vector<lli>> dp(N, vector<lli>(N, 0));
    for (int i = 0; i < N; i++)
        dp[i][i] = arr[i];
    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j < N - i; j++)
        {
            dp[j][i + j] = max(arr[j] - dp[j + 1][i + j], arr[j + i] - dp[j][j + i - 1]);
        }
    }
    return dp[0][N - 1];
}
int main()
{
    int N;
    cin >> N;
    arr = vector<lli>(N);
    for (int i = 0; i < N; i++)
    {
        cin >> arr[i];
    }
    //cout << solve(0, N - 1, 0, 0) << " ";
    cout<<solve2(N);
}

Measured memory_bytes: 73748
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int result = 1;
		int tap = A;
		while(B > tap) {
			tap += A - 1;
			result++;
		}
		if(B == 1) {
			result = 0;
		}
		System.out.println(result);
		sc.close();
	}

}
/*
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□■■□□
■■■■■■□□□■□■■■□□□
□□□□□■□□□■■■□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□■■■□□□■□□□□□□□
□■■■□■□□□■□□□□□■□
■■□□□■□□□■■□□□■■□
□□□□□■□□□□■■■■■□□
□□□□□■□□□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
■■■■■■■■■■■■■■■■□
□□□□□□□■□□□□□□□□□
□□□□□□■■■□□□□□□□□
□□□□□□■□■□□□□□□□□
□□□□□□■□■■□□□□□□□
□□□□□■■□□■□□□□□□□
□□□□□■□□□■■□□□□□□
□□□□■■□□□□■■□□□□□
□□□■■□□□□□□■■□□□□
□□■■□□□□□□□□■■□□□
■■■□□□□□□□□□□■■■□
*/

Measured memory_bytes: 23636
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1], X = ip[2];
	int[][] As;
	int[] Cs;
	foreach(i; 0..N) {
		auto ip2 = readAs!(int[]);
		auto C = ip2[0];
		auto A = ip2[1..$];
		As ~= A;
		Cs ~= C;
	}

	int res = int.max;
	foreach(k; 0..2^^N) {
		auto b = format(format("%%.%db", N), k);

		int[] learns = new int[](M);
		int S;
		foreach(i, c; b) {
			if(c == '1') {
				S += Cs[i];
				foreach(j, v; As[i]) {
					learns[j] += v;
				}
			}
		}
		if(learns.all!(v => v >= X)) {
			res = min(res, S);
		}
	}
	if(res == int.max) {
		writeln(-1);
	} else res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main(){
    ll n,k,q;
    cin >> n >> k >> q;
    vector <int> a(q);
    vector <int> ten(n+1);
    rep(i,q){
        cin >> a[i];
        ++ten[a[i]];
    }

    rep(i,n){
        if(ten[i+1]+k-q>0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    



    

    return 0;
}

Measured memory_bytes: 1408