akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
 
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
 
int main()
{
  int n;
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n+1);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  b[n] = 0;
  ll ans = 0;
  ll rem = 0;
  rep(i, n+1)
  {
    ans += min(a[i], (rem + b[i]));
    rem = max(0LL, b[i] - max(0LL, (a[i]-rem)));
  }
  cout << ans << endl;
 
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<vector<ll>> info(n, vector<ll>(n, -1));
  // -1はコメントなし 0は不明 1は正直者
  REP(i, n) {
    ll a;
    cin >> a;
    REP(j, a) {
      ll x, y;
      cin >> x >> y;
      x--;
      info[i][x] = y;
    }
  }

  // REP(i, n) REP(j, n) {
  //   DUMP(i);
  //   DUMP(j);
  //   DUMP(info[i][j]);
  // }

  ll ans = 0;
  REP(i, (1 << n)) {
    ll cnt = 0;
    REP(j, n) {
      if (i & (1 << j)) cnt++;
    }
    // jの情報と矛盾あるか
    bool ok = true;
    REP(j, n) {
      REP(k, n) {
        if (i & (1 << j)) {
          if (info[j][k] == -1) continue;
          if (info[j][k] == 1 && (i & (1 << k))) continue;
          if (info[j][k] == 0 && !(i & (1 << k))) continue;
          ok = false;
        }
      }
    }
    //矛盾なし
    if (ok) ans = max(ans, cnt);
  }
  cout << ans << endl;
}

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

typedef long long ll;

#define MOD 1000000007

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

int main(){
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u){
    cout << a-1 << " " <<  b << endl;
  }
  else cout << a << " " << b-1 << endl;
  return 0;
}


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

#define EPS (1e-7)
#define INF (1e11)
#define PI (acos(-1))
#define MAXN 110
#define MAXV 100010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

ll dp[MAXN][MAXV];
int n, W, w[110], v[110];

int main() {
    cin >> n >> W;
    rep(i, n) {
        cin >> w[i] >> v[i];
    }

    rep(i, n+1) {
        rep(val, MAXV) {
            dp[i][val] = ll(INF);
        }
    }

    dp[0][0]=0;
    rep(i, n) {
        rep(val, MAXV) {
            if (val < v[i]) {
                dp[i+1][val] = dp[i][val];
            } else {
                dp[i+1][val] = min(dp[i][val], dp[i][val-v[i]] + w[i]);
            }
            //cout << dp[i+1][val] << " ";
        }
    }

    int ans = 0;
    rep(val, MAXV) if(dp[n][val] <= W) ans = max(ans, val);
    cout << ans << endl;
}



Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
// #define first first
// #define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;


signed main(){
    int n;
    while(cin >> n){
        vector<int> ans;
        rep(i, 0, 10){
            int t = 1 << i;
            if(n & t){
                ans. push_back(t);
            }
        }
        rep(i, 0, ans.size()){
            if(i != 0) cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3040
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	int a, b;
	cin >> a >> b;
	int total = 0;
	total += max(a, b);
	if (a > b)
		a--;
	else
		b--;
	total += max(a, b);
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int cnt;
  int A[3];
  int B[3];
  int path[5] = {0,};
  int i;


  for (i=0; i<3; i++) {
    cnt = scanf("%d %d", &A[i], &B[i]);
    path[A[i]]++;
    path[B[i]]++;
  }

  for (i=1; i<5; i++) {
    if (path[i] > 2) {
      printf("NO");
      return 0;
    }
    if (path[i] == 0) {
      printf("NO");
      return 0;
    }
  }

  printf("YES");
  return 0;
}



Measured memory_bytes: 128
N = input()
S = input()
li = list(S)
ans = []
alp = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')

for i in range(len(li)):
  k = alp.index(li[i]) + int(N)
  if k < 26:
    ans.append(alp[k])
  else:
    ans.append(alp[k-26])
 
print(''.join(ans))

Measured memory_bytes: 3188
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int [][][]ho =new int[4][3][10];
int n =sc.nextInt();
for(;n>0;n--){
int a =sc.nextInt();
int b =sc.nextInt();
int c =sc.nextInt();
int d =sc.nextInt();
ho[a-1][b-1][c-1] += d;
}
for(int e=0; e<4; e++){
	for(int f=0; f<3; f++){
		for(int g=0; g<10; g++){
			System.out.print(" "+ho[e][f][g]);
		if(g ==9) System.out.println();
	}
	
	}
if(e<3) System.out.println("####################");
}
}
}

Measured memory_bytes: 20680
#include <iostream>
#include <string>

int main(void){
  int ans[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  std::cin >> K;
  
  std::cout << ans[K - 1] << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

map<ll, int> mp;
int x2 = 0, x4, x14 = 0, x24 = 0, x74 = 0;

ll comb_count(int n, int m) {
  if (m == 0)
    return 1;
  if (n == 0)
    return 0;
  return (n * comb_count(n - 1, m - 1) / m);
}

void judge(int x) {
  if (mp[x] == 2)
    x2++;
  else if (mp[x] == 4) {
    x4++;
    x2--;
  } else if (mp[x] == 14)
    x14++;
  else if (mp[x] == 24)
    x24++;
  else if (mp[x] == 74)
    x74++;
}

void prime_factor(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
      judge(i);
    }
  }
  if (n != 1) {
    mp[n]++;
    judge(n);
  }
}

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

  int n;
  cin >> n;

  rep(i, 2, n + 1) { prime_factor(i); }

  int g_four = x4 + x14 + x24 + x74;
  int g_two = x2 + g_four;
  int ans = comb_count(x4, 2) * (x2 + x4 - 2);
  ans += x14 * (x4 - 1);
  ans += x24 * (x2 + x4 - 1);
  ans += x74;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

template <typename T, typename Compare>
T bisection(T left, T right, Compare cmp, const bool rev = false,
            const T end = -1) {
    // [left, right)の区間を二分法で探索する
    // 単調増加関数を想定しているので、単調減少関数を cmp
    // に指定する場合、rev=true とすること！

    left--;
    T ret       = !rev ? right : left;
    const T MAX = !rev ? right : left;
    if (!rev) {
        while (1 < right - left) {
            T mid = left + ((right - left) / 2);
            if (cmp(mid)) {
                left = mid;
                ret  = left;
            } else {
                right = mid;
            }
        }
    } else {
        while (1 < right - left) {
            T mid = left + ((right - left) / 2);
            if (cmp(mid)) {
                right = mid;
                ret   = right;
            } else {
                left = mid;
            }
        }
    }
    return ret != MAX ? ret : end;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    scan(N, K);
    vector<ll> a(N), f(N);
    scan(a);
    scan(f);
    sort_(a);
    rsort(f);
    auto cmp = [&](ll t) {
        ll cnt = 0;
        rep(i, N) { cnt += max(a[i] - t / f[i], 0LL); }
        return cnt <= K;
    };
    ll ans = bisection<ll>(0, 1e15, cmp, true);
    print(ans);

    return 0;
}

Measured memory_bytes: 3328
io = STDIN
s=io.gets.chomp.chars.sort
t=io.gets.chomp.chars.sort
def check(s,t)
  if s.size < t.size
    (t.join.include? s.join) || (s.min < t.max)
  else
    s.min < t.max
  end
end
puts check(s,t) ? 'Yes' : 'No'


Measured memory_bytes: 1788
n = int(input())
ans = [0]*10**5


def xyz():
    count = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                ans[zyx] += 1


xyz()
for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 75116
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int x, y, a, b, c;
ll p[100005], q[100005], r[100005];

int main(void) {
    cin >> x >> y >> a >> b >> c;
    rep(i, 0, a) scanf("%lld", &p[i]);
    rep(i, 0, b) scanf("%lld", &q[i]);
    rep(i, 0, c) scanf("%lld", &r[i]);

    sort(p, p+a, greater<ll>());
    sort(q, q+b, greater<ll>());
    sort(r, r+c, greater<ll>());

    priority_queue<ll> pq;

    rep(i, 0, x) pq.push(-1*p[i]);
    rep(i, 0, y) pq.push(-1*q[i]);
    
    int i = 0;
    ll sum = 0;
    while(i<c) {
        ll t = -1*pq.top();
        if (r[i]>t) {
            sum += r[i++];
            pq.pop();
        }
        else break;
    }
    while (!pq.empty()) {
        sum += -1*pq.top(); pq.pop();
    }

    cout << sum << endl;

	return 0;
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
int main(){
string A,B,C;
  cin>>A>>B>>C;
  string a = A ;
    transform(a.begin(), a.end(), a.begin(), ::toupper);

    string b = B ;
    transform(b.begin(), b.end(), b.begin(), ::toupper);
  
  string c = C ;
    transform(c.begin(), c.end(), c.begin(), ::toupper);

  cout<<a.at(0)<<b.at(0)<<c.at(0)<<endl;

 

  
  
  
  
  

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define ls k * 2
#define rs k * 2 + 1
#define maxn 100005
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
//using namespace Graph;
int n, m, ans, a[maxn];
char c[maxn];
signed main() {
	n = ans = read(), m = read();
	rep(i, 1, m) {
		int x = read();
		rep(j, 1, x) {
			int y = read();
			if(!a[y]) a[y] = 1, -- ans;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int p = 0;
	bool flag = false;
	while (p < S.length()) {
		bool fl = false;
		if (p+5 <= S.length() && S.substr(p, 5) == "dream") {
			p += 5;
			if (p+2 <= S.length() && S.substr(p, 2) == "er") {
				p += 2;
				fl = true;
			}
		} else if (p+5 <= S.length() && S.substr(p, 5) == "erase") {
			p += 5;
			if (p+1 <= S.length() && S.substr(p, 1) == "r") {
				p += 1;
				fl = true;
			}
		} else if (flag && p+3 <= S.length() && S.substr(p, 3) == "ase") {
			p += 3;
			if (p+1 <= S.length() && S.substr(p, 1) == "r") {
				p += 1;
				fl = true;
			}
		} else break;
		flag = fl;
	}
	cout << (p == S.length() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[N];
    rep(i, N) cin >> A[i];
    sort(A, A+N);
    int G = A[0];
    rep(i, N) G = gcd(G, A[i]);
    //dump(G);
    if(K >= A[0] && K <= A[N-1] && K % G == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}



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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D)
    cout << "Left" << endl;
  else if (A+B == C+D)
    cout << "Balanced" << endl;
  else
    cout << "Right" <<endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
i64 N;
i64 A[MAX_N];
i64 B[MAX_N];
i64 C[MAX_N];

void solve() {
    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    i64 cnt = 0;

    REP(i, N) {
        cnt += distance(A, lower_bound(A, A + N, B[i])) * distance(upper_bound(C, C + N, B[i]), C + N);
    }

    cout << cnt << endl;
}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N) cin >> C[i];

    solve();

    return 0;
}

Measured memory_bytes: 2560
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n, k = nm()
x=n//k
n=n-(x-1)*k
while n>k/2:
    n=abs(n-k)
print(n)


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

signed main(){
	string S, T;
	cin >> S >> T;
	bool flg = true;
	for(int i = 0; i < S.length(); i++)
		if(S[i] != T[i])
			flg = false;

	cout << (flg?"Yes":"No") << endl;

	return 0;	
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	string s; cin>>s;
	ll ans=0,mem=0;
	rep(i,s.sz){
		if(s[i]=='W'){
			ans+=(i-mem);
			mem++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg = 20000001;
#define ff(i,n) for(i=0;i<n;i++) 
int main()
{
  		ll i,n,u,v;
		cin>>n;
		ll ans = (n*(n+1)*(n+2))/6;
		ff(i,n-1)
		{
			cin>>u>>v;
			ans-=((min(u,v))*(n-max(u,v)+1));	
		}    
		cout<<ans;
		return 0;
} 

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int i,n,F[50];
  scanf("%d",&n);
  
  F[0] = 1;
  F[1] = 1;
  for (i=2;i<=n;i++){
    F[i] = F[i-2] + F[i-1];
  }
  printf("%d\n",F[i-1]);
  return 0;

}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

bool dp[105][10005];

void Main()
{
    arrayFill(dp, false);
    int n = in();
    vint s = in(n);

    dp[0][0] = true;
    rep(i, n) rep(j, 10005)
    {
        dp[i + 1][j] |= dp[i][j];
        dp[i + 1][j + s[i]] |= dp[i][j];
    }
    int ans = 0;
    for (int i = 10002; i >= 0; --i)
    {
        if (dp[n][i] && i % 10 != 0)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  int coin=0;
  int day=0;
  while(1){
      if(coin>=c){
          break;
      }
      coin=coin+a;
      day=day+1;
      if(day%7==0){
          coin=coin+b;
      }
  }
      cout<<day<<endl;
      return 0;
  }



Measured memory_bytes: 3116
#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

long long f(long long x, long long a, long long b){
    long long xa=(a+x-1)/x;
    long long xb=(b+x-1)/x*x;
    xb=xb==b ?xb : xb-x;
    xb=xb/x;
    return xb-xa+1;
}

long long gcd(long long x, long long y){
    if(x%y==0) return y;
    else return gcd(y, x%y);
}

int main(){
    long long a, b, c, d; cin >> a >> b >> c >> d;
    cout << b-a+1-(f(c, a, b)+f(d, a, b)-f(c*d/gcd(c, d), a, b)) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,i,j,x;
	scanf("%d",&n);
    i=100000;
	for(j=0;j<n;j++){
	    i=i*5/100+i;
		x=i%1000;
		if(x!=0){
		    x=1000-x;
			i=i+x;
		}
	}
	printf("%d\n",i);
	return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, x, n) for(ll i=x; i<(ll)n; ++i)
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    sort(ab.begin(), ab.end(), [](auto l, auto r){
        return l.second < r.second;
    });
    ll t = 0;
    rep(i, n){
        t += ab[i].first;
        if(t>ab[i].second){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;


signed main(){

    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i)
        cout << char((s[i] + n - 'A') % 26 + 'A');
    cout << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 2e3 + 5;
const ll INF = 1e18;

int mx,n,x,a[N],mn[N][N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> x;
  for (int i = 1 ; i <= n ; i++)
    cin >> a[i];

  for (int i = 1 ; i <= n ; i++) {
    mn[i][i] = a[i];
    for (int j = i + 1 ; j <= n ; j++)
      mn[i][j] = min(mn[i][j - 1],a[j]);
  }

  ll ans = INF;

  for (int k = 0 ; k <= n - 1 ; k++) {
    ll res = 0;
    for (int i = 1 ; i <= n ; i++) {
      if (i - k >= 1)
        res += mn[i - k][i];
      else
        res += min(mn[1][i] , mn[n - k + i][n]);
    }
    ans = min(ans,res + (ll) k * x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
int a[(int)2e5];
int b[(int)2e5];
int main()
{

    string s;
    ll ans = 0;
    cin >> s;
    int k =0;
    for(int i = 0; i< s.size(); i++)
    {
        if(s[i] == 'B')
            k++;
        if(s[i] == 'W')
            ans+=k;

    }
    cout << ans;
}


Measured memory_bytes: 640
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,M = inpl()
XX = inpl()
XX.sort()
dist = []
for i in range(1,M):
    dist.append(XX[i] - XX[i-1])

dist.sort()
if N >= M:
    print(0)
else:
    print(sum(dist[:M-N]))


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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 100000


using namespace std;

using ll =long long;
using P = pair<int,int>;

string replaceAll(string &replacedStr, string from, string to) {
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();
 
    if (from.empty()) {
        return replacedStr;
    }
 
    while ((pos = replacedStr.find(from, pos)) != string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//22
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int gettt(long long int num){
    int digit=0;
if(num<10){
digit=0;
}else{
    while(num>1){
        num /= 10;
        digit++;
    }
}
    return digit;
}

string sfg[27]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",""};





int main() {

long long alls=0;

ios::sync_with_stdio(false);
cin.tie(0);
int h,w,k;
cin>>h>>w>>k;

int data[h][w]={};
int data2[h][w]={};
for(int i=0;i<h;i++){
string s;
cin>>s;
for(int j=0;j<w;j++){
if(s[j]=='.'){
}else{
data[i][j]=1;
}
 
}
}

for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
data2[i][j]=data[i][j];
}
}



 for (int bit = 0; bit < (1<<h); ++bit) {
long long int ress=0;


        vector<int> S;
        for (int i = 0; i < h; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
    for (int bit2 = 0; bit2 < (1<<w); ++bit2) {
        vector<int> S2;
        for (int i2 = 0; i2 < w; ++i2) {
            if (bit2 & (1<<i2)) { // 列挙に i が含まれるか
                S2.push_back(i2);
            }
        }
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
data2[i][j]=data[i][j];
}
}




for(int jj=0;jj<S.size();jj++){
for(int kk=0;kk<w;kk++){
data2[S[jj]][kk]=-1;
}
}
for(int jj=0;jj<S2.size();jj++){
for(int kk=0;kk<h;kk++){
data2[kk][S2[jj]]=-1;
}
}
ress=0;
for(int tt=0;tt<h;tt++){
for(int tt2=0;tt2<w;tt2++){
if(data2[tt][tt2]==1)ress++;
}
}

if(ress==k){
alls++;


}




    }



    }

cout<<alls<<endl;


}
//double res=10.11;
//printf("%.10f",ans);
//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;


Measured memory_bytes: 3640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<ll> A(N+2);
    vector<ll> B(N);
    vector<ll> C(N+2);
    for(int i = 1; i <= N; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++){
        cin >> B.at(i);
    }
    for(int i = 1; i <= N; i++){
        cin >> C.at(i);
    }
    A.at(0) = -1;
    A.at(N+1) = 10000000000;
    C.at(0) = -1;
    C.at(N+1) = 10000000000;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    ll ans = 0;
    for(int i = 0; i < N; i++){
        int x = B.at(i);
        //Aの中でx未満のものの数を求める。
        int left = -1,right = N+2;
        int middle;
        while(right - left > 1){
            middle = (left + right) / 2;
            if(x <= A.at(middle)){
                right = middle;
            }
            else{
                left = middle;
            }
        }
        ll a = left;
        left = -1;
        right = N+2;
        while(right - left > 1){
            middle = (left + right) / 2;
            if(x < C.at(middle)){
                right = middle;
            }
            else{
                left = middle;
            }
        }
        ll c =  N - left;
        ans += a * c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
     cin>>n;

      set<int>p;
       for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
         p.insert(i*j);


       if(p.find(n)!=p.end())
       cout<<"Yes";

       else
       cout<<"No";
}


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

#define all(v) v.begin(), v.end()
typedef long long ll;
using namespace std;

int binarysearch(vector<int> vec, int key) {
    int left = 0;
    int right = vec.size() - 1;
    int mid;
    while(left <= right) {
        mid = (left + right) / 2;
        if (key == vec.at(mid)) return 1;
        if (key > vec.at(mid)) left = mid + 1;
        else right = mid - 1;
    }
    return -1;
}

int main() {
    int n; cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s.at(i);
    int q; cin >> q;
    vector<int> t(q);
    rep(i, q) cin >> t.at(i);
    int count=0;

    rep(i, q) {
        if (binarysearch(s, t.at(i)) == 1) count++;
    }
    cout << count << endl;
}



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

int main(){
    int k,n,ans=0;
    cin>>k>>n;
    vector<int> a(n),sub;
    rep(i,n)
        cin>>a[i];
    rep(i,n){
        if(i==n-1)
            sub.push_back(abs((k-a[i])+a[0]));
        else
            sub.push_back(abs(a[i]-a[i+1]));
        ans+=sub[i];
    }
    cout<<ans-*max_element(sub.begin(),sub.end())<<endl;
}


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

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

int main() {
    int H, W;
    cin >> H >> W;
    string s[60];
    for (int i = 0; i < H; i++) cin >> s[i];

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '.') continue;
            bool ok = false;
            for (int k = 0; k < 4; k++) {
                int x = i + dx[k], y = j + dy[k];
                if (x < 0 || x >= H || y < 0 || y >= W) continue;
                if (s[x][y] == '#') ok = true;
            }
            if (!ok) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

int main (){
    int n;
    cin >> n;
    int i;
    int a[n],c[n-1];
    for(i=0;i<n;i++){
        cin >> a[i];
        
    }
    int x,y=0;
    for(i=0;i<n;i++){
        cin >> x;
        y+=x;
        
    }
    for(i=0;i<n-1;i++){
        cin>>c[i];
        
    }
    for(i=1;i<n;i++){
        x=a[i]-a[i-1];
         if(x == 1){
            x=a[i-1]-1;
            y+=c[x];
        }
    }
    cout << y;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<double,double>P;

const int MAX_N = 100005;

template<class V> class BIT {
private:
	int n;
	vector<V> bit;

public:
	void add(int i,V x)
	{
		while(i < n){
			bit[i] += x;
			i += i & -i;
		}
	}
	V sum(int i)
	{
		V s = 0;
		while(i>0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	//初期値がすべて0の場合
	BIT(int sz){
		n = sz + 1;
		bit.resize(n,0);
	}
	BIT(vector<V> v) {
		int sz = (int)v.size();
		n = sz + 1;
		bit.resize(n);
		rep(i,sz){
			 add(i+1,v[i]);
		}
	}
	void print()
	{
		cout << "0 ";
		for(int i=1;i<n;i++){
			cout << sum(i) - sum(i-1) << " ";
		}
		cout << endl;
	}
	void print_sum()
	{
		rep(i,n){
			cout << sum(i) << " ";
		}
		cout << endl;
	}
};

int n;

int comp(vector<double>& s,vector<double>& t,double cri)
{
    vector<P> vec(n);
    rep(i,n){
        vec[i] = P(cri*s[i]+t[i],i);
    }
    sort(all(vec));
    BIT<int> bt(n+5);
    int num = 0;
    rep(i,n){
        int hoge = round(vec[i].se);
        num += bt.sum(hoge+1);
        bt.add(hoge+1,1);
    }
    return num;
}

double solve(vector<P>& vec)
{
    vector<double> tilt(n),tang(n);
    rep(i,n){
        tilt[i] = vec[i].fi,tang[i] = vec[i].se;
    }
    double l = -INF,h = INF;
    double mid;
    rep(i,100){
        mid = (l+h)/2;
        if(comp(tilt,tang,mid) < (n*(n-1)/2+1)/2){
            l = mid;
        }else{
            h = mid;
        }
    }
    return mid;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<P> v1(n),v2(n);
    rep(i,n){
        int a,b,c;
        cin >> a >> b >> c;
        v1[i] = P((double)a/-b,(double)c/b);
        v2[i] = P((double)b/-a,(double)c/a);
    }
    sort(all(v1)),sort(all(v2));
    printf("%.12lf %.12lf\n",solve(v1),solve(v2));
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
    ll n;cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int ij=i^j;
            int ret=1;
            for(int k=0;;k++){
                if(ij&1){
                    cout<<ret<<" ";
                    break;
                }
                ij>>=1;
                ret++;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> h(n);
    for(int &i : h) cin >> i;

    for(int i=n-2; i>-1; --i){
        if(h[i]>h[i+1]) --h[i];
    }
    bool flg=1;
    for(int i=0; i<n-1; ++i){
        if(h[i]>h[i+1]){
            flg=0;
            break;
        }
    }
    cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
#define MN 4000
int a[MN+5][MN+5],b[MN+5][MN+5];
int q(int x[][MN+5],int a,int b,int c,int d){return x[c][d]-x[a-1][d]-x[c][b-1]+x[a-1][b-1];}
int main()
{
	int n,k,i,j,x,y,ans=0;char c[5];
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;++i)
		scanf("%d%d%s",&x,&y,c),
		++(c[0]=='B'?a:b)[x%(2*k)+1][y%(2*k)+1],
		++(c[0]=='B'?a:b)[x%(2*k)+2*k+1][y%(2*k)+1],
		++(c[0]=='B'?a:b)[x%(2*k)+1][y%(2*k)+2*k+1],
		++(c[0]=='B'?a:b)[x%(2*k)+2*k+1][y%(2*k)+2*k+1];
	for(i=1;i<=4*k;++i)for(j=1;j<=4*k;++j)
		a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1],
		b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
	for(i=1;i<=2*k;++i)for(j=1;j<=2*k;++j)
		ans=max(ans,q(a,i,j,i+k-1,j+k-1)+q(a,i+k,j+k,i+2*k-1,j+2*k-1)+
					q(b,i+k,j,i+2*k-1,j+k-1)+q(b,i,j+k,i+k-1,j+2*k-1));
	printf("%d",ans);
}

Measured memory_bytes: 125440
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val H = readLine()!!.split(" ").map{it.toInt()}.toTypedArray()

    for (i in H.indices.reversed()) {
        if (i == 0) continue
        if (H[i - 1] > H[i]) {
            H[i - 1]--
        }
    }

    println(if (H.mapIndexed { index, h -> index == H.size - 1 || H[index] <= H[index + 1] }.all {it}) "Yes" else "No")
}


Measured memory_bytes: 59480
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;

#define MAX_N 10000
int a[MAX_N];

int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input
  int N, M;
  cin >> N >> M;

  // -----------------------------

  if ( N == M ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<int> v(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }

    int cnt = 0;
    for (int i = 1; i < N + 1; i++) 
    {
        if (v[i - 1] != i)
        {
            cnt++;
        }
    }
    
    if (cnt <= 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  long long n, k; cin >> n >> k;
  long long ans = 0;
  for(long long i=k; i<=n+1; i++) {
    long long mx = (n + n - i + 1) * i / 2;
    long long mn = (i-1) * i / 2;
    ans += mx - mn + 1;
    ans %= mod;
  }
  cout << ans << endl;
}

// EOF

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}



int main(){

    int K;
    cin >> K;
    
    vl lun;
    
    queue<ll> A;
    reps(i,1,10) A.push((ll)i);
    while (!A.empty()) {
        ll a = A.front();
        lun.pb(a);
        A.pop();
        
        ll b = a%10;
        A.push(a*10+b);
        if(b+1 <= 9) A.push(a*10+b+1);
        if(b-1 >= 0) A.push(a*10+b-1);
        if(lun.size() > K*2) break;
    }
    
    sort(all(lun));
    
    cout << lun[K-1] << endl;

    
    
    
    

    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  while(n!=0)
  {
    int i,j,k;
    vector<int> w(n);
    rep(i,n)cin>>w[i];
    vector<vector<int>> dp(n,vector<int>(n,0));
    rep(i,n-1)
    {
      if(abs(w[i]-w[i+1])<=1)dp[i][i+1]=2;
    }
    for(i=2;i<n;i++)
    {
      rep(j,n-i)
      {
        for(k=0;k<i;k++)
        {
          dp[j][j+i]=max(dp[j][j+i],dp[j][j+k]+dp[j+k+1][j+i]);
        }
        if(dp[j+1][j+i-1]==i-1&&abs(w[j]-w[j+i])<=1)
        {
          dp[j][j+i]=i+1;
        }
      }
    }
    cout<<dp[0][n-1]<<endl;
    cin>>n;
  }
}



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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

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

  int w, h, n; cin >> w >> h >> n;
  int xl = 0, xr = w, yl = 0, yr = h;
  for(int i=0;i<n;++i) {
    int x, y, a; cin >> x >> y >> a;
    if(a == 1) {
      if(xr < x) {
        cout << 0 << endl;
        return 0;
      }
      xl = max(xl, x);
    } else if(a == 2) {
      if(xl > x) {
        cout << 0 << endl;
        return 0;
      }
      xr = min(xr, x);
    } else if(a == 3) {
      if(yr < y) {
        cout << 0 << endl;
        return 0;
      }
      yl = max(yl, y);
    } else {
      if(yl > y) {
        cout << 0 << endl;
        return 0;
      }
      yr = min(yr, y);
    }
  }

  cout << max(0, (xr - xl)) * max(0, (yr - yl)) << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a;
	scanf("%d",&a);
	int digit[3]={a, a*a, a*a*a};
	int sum=0;
	sum= digit[0] + digit[1] + digit[2];
	
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
int L;
vector<pair<pair<int , int> , int> > edges;
int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);
	cin >> L;
	int maxBit;
	for(int i = 19; i >= 0; i--)
	{
		if(L & (1 << i))
		{
			maxBit = i;
			break;
		}
	}
	for(int i = maxBit - 1; i >= 0; i--)
	{
		edges.PB({{maxBit - i , maxBit - i + 1} , 0});
		edges.PB({{maxBit - i , maxBit - i + 1} , (1 << i)});
	}
	int curVal = (1 << maxBit);
	for(int i = maxBit - 1; i >= 0; i--)
	{
		if(L & (1 << i))
		{
			edges.PB({{1 , maxBit - i + 1} , curVal});
			curVal += (1 << i);
		}
	}
	cout << maxBit + 1 << " " << edges.size() << endl;
	for(int i = 0; i < edges.size(); i++)
		cout << edges[i].first.first << " " << edges[i].first.second << " " << edges[i].second << endl;
	return 0;
}


Measured memory_bytes: 256