akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi L(n);
  vi count(2001,0);
  rep(i, n){
    cin >> L[i];
    count[L[i]]++;
  }
  vi sum(2001,0);
  sum[0] = 0;
  rep(i, 2000) sum[i+1] = sum[i] + count[i];// sum[i+1]:i以下の数の個数 sum[i]:i未満

  ll ans = 0;
  rep(a, n) rep(b, n){
    if(a == b) continue;
    int right = L[a]+L[b];
    int left = abs(L[a]-L[b])+1;

    int cnt = sum[right] - sum[left];
    if(left <= L[a] && L[a] < right) cnt--;
    if(left <= L[b] && L[b] < right) cnt--;

    ans += max(cnt,0);
    
  }
  std::cout << ans/6 << '\n';
}


Measured memory_bytes: 256
from collections import deque

dq = deque()
n = int(input())

for _ in range(n):
    command = input()
    if command == "deleteFirst":
        dq.popleft()
    elif command == "deleteLast":
        dq.pop()
    else:
        command, x = command.split()
        if command == "insert":
            dq.appendleft(x)
        else:
            if x in dq:
                dq.remove(x)
            else:
                pass
            
print(*dq)


Measured memory_bytes: 69732
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ld r; cin >> r;

  ld ans = 2 * M_PI * r;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3796
import numpy as np

n, k = map(int, input().split())
xyc = [list(input().split()) for _ in range(n)]

b = np.zeros((2 * k, k), np.int32)

for x, y, c in xyc:
    x = int(x)
    y = int(y)

    q, r = divmod(x, k)
    if q % 2:
        y += k
    x = r

    if c == "W":
        y += k

    y %= 2 * k

    b[y][x] += 1

b = np.vstack([b, b])
b = np.hstack([b, np.roll(b, k, axis=0)])

b = np.pad(b, (1, 0), "constant")
b = np.cumsum(b, axis=0)
b = np.cumsum(b, axis=1)

cnt = b[k:, k:] - b[k:, :-k] - b[:-k, k:] + b[:-k, :-k]
ans = cnt.max()
print(ans)


Measured memory_bytes: 194408
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int 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()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll a,b,c; cin >> a >> b >> c;
  cout << min(c,a+b+1) + b << endl;
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def gen(N, M):
    if N == 0:
        for i in range(1, M+1):
            yield [i]
    else:
        prefixes = gen(N-1, M)
        for prefix in prefixes:
            for end in range(prefix[-1], M+1):
                prefix.append(end)
                yield prefix
                prefix.pop()
    

def solve():
    N, M, Q = read_ints()
    a, b, c, d = [], [], [], []
    for _ in range(Q):
        x, y, z, w = read_ints()
        a.append(x)
        b.append(y)
        c.append(z)
        d.append(w)
    max_score = 0
    for A in gen(N, M):
        total_score = 0
        for i in range(Q):
            if A[b[i]-1]-A[a[i]-1] == c[i]:
                total_score += d[i]
        max_score = max(max_score, total_score)
    return max_score


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 9260
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) rep(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i++)
#define reprev(i, n) reprrev(i, 0, n)

typedef vector<int> vi;
typedef vector<string> vs;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int ans = 0;

	repr(i, 1, N + 1) {
		string num = to_string(i);
		int n = 0;

		for (char x: num) {
			n += x - '0';
		}

		if (n >= A && n <= B) {
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}



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

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

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 16; j++) {
			if (4 * i + 7 * j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
N,M,Q = map(int, input().split())
ab = tuple(tuple(map(int, input().split())) for _ in range(Q))
ans = 0
def dfs(A):
    global ans
    if len(A) == N:
        tmp = 0
        for i in range(Q):
            a,b,c,d = ab[i]
            if (A[b-1]-A[a-1]) == c:
                tmp += d
        if tmp > ans:
            ans = tmp


    else:
        last = A[-1] if len(A) > 0 else 1
        for i in range(last, M+1):
            A.append(i)
            dfs(A)
            A.pop()
dfs([])
print(ans)

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

void solve()
{
	ll n;  cin >> n;
	string seq = "abcdefghijklmnopqrstuvwxyz";
	int rem = 0;
	string ans = "";
	while (n > 0){
		rem = n % 26;
		if (rem == 0){
			rem = 26;
		}
		ans += seq[rem-1];
		n -= rem;
		n = ll(n/26);
	}
	reverse(ans.begin(), ans.end()); 
	cout << ans << '\n';
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r ,c,sum;
  cin >> r >> c;
  int a[101][101]= {};

  for(int i=0;i<r;i++)
    for(int j=0;j<c;j++) cin >> a[i][j];
  
  for(int i =0;i<r;i++)
    for(int j=0;j<c;j++) a[r][c] += a[i][j];

  for(int i=0;i<r;i++){
    sum = 0;
    for(int j=0;j<c;j++) sum += a[i][j];
    a[i][c] = sum;
  }

  for(int j=0;j<c;j++){
    sum = 0;
    for(int i=0;i<r;i++) sum += a[i][j];
    a[r][j] = sum;
  }

  for(int i=0;i<=r;i++){
    for(int j=0;j<=c;j++){
      if(j) cout << " ";
      cout << a[i][j];
    }
  cout <<endl;
}
  
   
 
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>

#define INF 10000000000
using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;


long long fac[MAX], finv[MAX], inv[MAX];

//テーブルの前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        //そのまま計算すると負の値になるのでMODを足す
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//二分累乗法
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    COMinit();

    long long i;
    long long ans = 0;
    for(i = 0; i < min(n, k+1); i++){
        ans += (COM(n, i) * COM(n-1, i)) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 23680
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
 
using namespace std;
 
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long ll;
 
ll A,B,C,D,F;
double E;
ll cnt = 0;
 
vector <pair<ll,ll>> cup;
 
 
//順番を構造体に入れておいて
// ans[kozo.junban] = kozo.first;
//とかで出力する
int saiki(ll water, ll sugar)
{
 
    if(water + sugar >= F)return 0;
    cup.push_back(make_pair(water,sugar));
    
 
    saiki(water + 100*A,sugar);
    saiki(water + 100*B,sugar);
    saiki(water, sugar + C);
    saiki(water, sugar + D);
    return 0;
}
 
 
int main()
{

 
 
    cin >> A >> B >> C >> D >> E >> F;

    E = 100*E/(100+E);

    vector <ll> v_water;
    vector <ll> v_sugar;


    for(ll i = 0; i <= F; i++)
    {
        if(100*A*i >= F)break;
        for(ll j = 0; j <= F; j++)
        {
            if(j == 0 && i == 0) continue;
            if(100*A*i + 100*B*j > F)break;
            v_water.push_back(100*A*i + 100*B*j);
        }
    }
    
    for(ll i = 0; i <= F; i++)
    {
        if(C*i >= F)break;
        for(ll j = 0; j <= F; j++)
        {
            //if(j == 0 && i == 0) continue;
            if(C*i + D*j > F)break;
            v_sugar.push_back(C*i + D*j);
        }
    }
    //saiki(0,0);
 
    ll resWater,resSugar;
    double iMax = -1.0;
    double concentration;

    sort(v_water.begin(),v_water.end());
    sort(v_sugar.begin(),v_sugar.end());
 
    for(auto v_w:v_water)
    {
        for(auto v_s:v_sugar)
        {
            if(v_w + v_s > F)break;
            concentration = 100.0 * v_s /(v_w + v_s);

            //濃度チェック
            if(concentration <= E)
            {
                if( iMax < concentration)
                {
                    iMax = concentration;
                    resWater = v_w;
                    resSugar = v_s;
                }
            }
        }
    }
    cout << resWater + resSugar << " " << resSugar << endl;
 
    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
int h,n;
cin>>h>>n;
int sum=0;
int a;
for(int i=0;i<n;i++){
    cin>>a;
    sum+=a;
}
if(h>sum){
    cout<<"No"<<endl;
}else{
    cout<<"Yes"<<endl;
}
}









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

int main()
{
	int i, a, b;

	cin >> a;
	if (a <= 1000)cout << 1000 - a;
	else {
		while (1) {
			if (a <= 1000) {
				cout << 1000 - a;
				break;
			}
			else {
				a = a - 1000;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(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 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path;
//***********//
int main() {
	cin >> N;
	ll now = 0;
	while (now < N) {
		now += 1000;
	}
	cout << now - N;
}

Measured memory_bytes: 3592
N = gets.to_i
words = N.times.map { gets.chomp }
used = {}
last_ch = nil
is_ok = words.all? do |w|
  break false if used[w]
  used[w] = true
  ret = true
  if last_ch
    ret = last_ch == w[0]
  end
  last_ch = w[-1]
  ret
end
puts(is_ok ? 'Yes' : 'No')


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;

int h[1500];
int w[1500];

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

	int N, M;
	while(cin >> N >> M, N) {
		map<int, int> hm;
		for(int i = 0; i < N; i++) {
			cin >> h[i];
		}
		for(int i = 0; i < M; i++) {
			cin >> w[i];
		}

		for(int i = 0; i < N; i++) {
			int sum = 0;
			for(int j = 1; i + j <= N; j++) {
				sum += h[i + j - 1];
				hm[sum]++;
			}
		}

		int ans = 0;
		for(int i = 0; i < M; i++) {
			int sum = 0;
			for(int j = 1; i + j <= M; j++) {
				sum += w[i + j - 1];
				if(hm.find(sum) != hm.end()) {
					ans += hm[sum];
				}
			}
		}

		cout << ans << endl;
	}

}

Measured memory_bytes: 14636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e3 + 50;
const int mod = 996873654;
int ar[MAX][MAX],top[MAX],vis[MAX]={0};
int main(){
	int n;
	sfi(n);
	for(int i=1;i<=n;i++){
		top[i]=1;
		for(int j=1;j<=n-1;j++){
			sfi(ar[i][j]);
		}
	}
	int cnt=1;
	while(1){
		bool flag=false;
		for(int i=1;i<=n;i++){
			if(top[i]>=n || vis[i]==cnt) continue;
			int v=ar[i][top[i]];
			if(vis[v]!=cnt && ar[v][top[v]]==i){
				top[v]++; top[i]++;
				vis[i]=vis[v]=cnt;
				flag=true;
			}
		}
		if(!flag) break;
		cnt++;
	}
	for(int i=1;i<=n;i++){
		if(top[i]!=n){
			pfi(-1);
			return 0;
		}
	}
	pfi(cnt-1);
	return 0;
}


Measured memory_bytes: 4352
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define pb push_back


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)

#define repeach(i, a) for(auto i: a)


#define endl '\n'


typedef vector<int> vii;


class Solution {
public:
    const int static MAX = 10;
    vii adj[MAX];
    int ans = 0, n;
    bool vis[MAX];

    void dfs(int from, int x) {
        vis[from] = true;
        x++;
        if (x == n) ans++;
        repeach(to, adj[from]) {
            if (vis[to] == false) {
                dfs(to, x);
            }
        }
        vis[from] = false;
    }

    void solve(std::istream& in, std::ostream& out) {
		int m, x, y;
        in >> n >> m;
        rep(i, 0, n+1, 1) vis[i] = false;
        rep(i, 0, m, 1) {
            in >> x >> y;
            adj[x].pb(y);
            adj[y].pb(x);
        }
        dfs(1, 0);
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <cassert>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair
 
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;
 
const int INF = 1001001001;
 
// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
 
int W, H;
char map[20][20];
int can_buy[20][20];
int N;
int G[8], D[8], S[8], E[8];
int dp[1<<8][20][20][101];
 
bool didGoSame(int state, int v){
    REP(i, N){
        if(state >> i & 1 && G[i] == G[v]){return true;}
    }
    return false;
}
 
int rec(int state, int x, int y, int t){
    // printf("%d, %d, %d\n", x, y, t);
    if(t > 100){return 0;}
    if(dp[state][x][y][t] != -1){return dp[state][x][y][t];}
 
    int res = 0;
    REP(j, N){
        // printf("%d, %d: %d\n", x, y, t);
        if(!(state >> j & 1) && !didGoSame(state, j) && can_buy[y][x] >> G[j] & 1 && S[j] <= t && t < E[j]){
            res = std::max(res, D[j] + rec(state | 1 << j, x, y, t));
        }
    }

    REP(i, 4){
        int nx = x + dx[i], ny = y + dy[i];
        if(0 <= nx && nx < W && 0 <= ny && ny < H && map[ny][nx] == '.'){
            res = std::max(res, rec(state, nx, ny, t+1));
        }
    }
 
    return dp[state][x][y][t] = res;
}
 
int main(){
    while(std::cin >> W >> H, W){
        REP(i, 20){
            REP(j, 20){
                can_buy[i][j] = 0;
            }
        }
 
        REP(i, 1<<8){
            REP(j, 20){
                REP(k, 20){
                    REP(l, 101){
                        dp[i][j][k][l] = -1;
                    }
                }
            }
        }
 
        int sx, sy;
        REP(i, H){
            REP(j, W){
                std::cin >> map[i][j];
                if(map[i][j] == 'P'){
                    map[i][j] = '.';
                    sx = j; sy = i;
                }
            }
        }
 
        REP(y, H){
            REP(x, W){
                REP(k, 4){
                    if(map[y][x] == '.'){continue;}
                    int nx = x + dx[k], ny = y + dy[k];
                    if(0 <= nx && nx < W && 0 <= ny && ny < H && map[ny][nx] == '.'){
                        can_buy[ny][nx] |= 1 << (map[y][x] - '0');
                    }
                }
            }
        }
 
        std::cin >> N;
 
        REP(i, N){
            std::cin >> G[i] >> D[i] >> S[i] >> E[i];
        }
 
        std::cout << rec(0, sx, sy, 0) << std::endl;
    }
}

Measured memory_bytes: 41572
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

template<typename T>
T absi(T x) {
    if (x < static_cast<T>(0)) {
        x *= static_cast<T>(-1);
    }
    return x;
}

int main()
{
    int64_t x, y;
    std::cin >> x >> y;

    auto xx = x * -1;
    auto yy = y * -1;

    int64_t count = INT64_MAX;

    if (x < y) {
        count = y - x;
    }
    if (xx <= y) {
        count = std::min(count,  y - xx + 1);
    }
    if (x <= yy) {
        count = std::min(count,  yy - x + 1);
    }
    if (xx <= yy) {
        count = std::min(count,  yy - xx + 2);
    }

    std::cout << count << std::endl;

#if 0
    auto xx = absi(x);
    auto yy = absi(y);

    if (x < y) {
        if (0 <= x || y <= 0) {
            // 0 <= x < y, x < y <= 0
            std::cout << y - x << std::endl;
        }
        else {
            // x < 0 < y
            auto p = y - x;
            if (xx <= yy) {
                // 符号反転してから追いつくパターン
                p = std::min(p, yy - xx + 1);
            }
            if (xx >= yy) {
                // 同じ位置に到達してから反転するパターン
                p = std::min(p, xx - yy + 1);
            }
            std::cout << p << std::endl;
        }
    }
    else {
        // y < x
        if (0 <= y) {
            // 0 <= y < x  反転してそのまま+, 反転して足して反転, 
            auto p = xx + y + 1;
            auto p2 = 1 + absi(xx - yy) + 1;
            std::cout << std::min(p, p2) << std::endl;
        }
        else if (x <= 0) {
            // y < x <= 0 反転して足して反転, たして反転
            auto p = absi(xx - yy) + 2;
            auto p2 = yy + xx + 1;
            std::cout << std::min(p, p2) << std::endl;
        }
        else {
            // y < 0 < x 反転してそのままたす or 足して反転する
            auto p = absi(xx - yy) + 1;
            std::cout << p << std::endl;
        }
    }
#endif

    return 0;
}


Measured memory_bytes: 256
s = list(input())
for i in range(int(input())):
    cmd, a, b, *c = input().split()
    a = int(a); b = int(b)
    if cmd == "print":
        print(*s[a:b+1], sep='')
    elif cmd == "reverse":
        s[a:b+1] = reversed(s[a:b+1])
    else:
        s[a:b+1] = c[0]



Measured memory_bytes: 5736
N = int(input())
S = input()

rs = set()
gs = set()
bs = set()
for i, s in enumerate(S):
    if s == 'R':
        rs.add(i+1)
    elif s == 'G':
        gs.add(i+1)
    elif s == 'B':
        bs.add(i+1)

count = 0
for i in rs:
    for j in gs:
        a = min(i, j)
        b = max(i, j)
        d = b - a
        e = 0
        if (a - d) in bs:
            e += 1
        if (b + d) in bs:
            e += 1
        if d % 2 == 0 and (b - (d // 2)) in bs:
            e += 1
        count += (len(bs) - e)
print(count)

Measured memory_bytes: 69116
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var m = int.Parse(_[1]);

            Console.WriteLine(n % m == 0 ? 0 : 1);
        }
    }
}


Measured memory_bytes: 11220
#include <stdio.h>

using namespace std;

int main(){
	int m,f,r;
	char grade;
	while(true){
		scanf("%d %d %d",&m,&f,&r);
		if(m == -1 && f == -1 && r == -1) break;
		if(m == -1 || f == -1){
			grade = 'F';
		}else if(m+f >= 80){
			grade = 'A';
		}else if(m+f >= 65){
			grade = 'B';
		}else if(m+f >= 50){
			grade = 'C';
		}else if(m+f >= 30){
			grade = (r >= 50)? 'C':'D';
		}else{
			grade = 'F';
		}
		printf("%c\n",grade);
	}
}



Measured memory_bytes: 2684
#include<iostream>
#include<limits.h>
using namespace std;
const int MAX = 502, NIL = INT_MAX;
int main(){
    int n, heap[MAX];
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> heap[i];
    }
    for (int i = 1; i <= n+1; i++)
    {
        heap[n+i] = NIL;
    }
    heap[0] = NIL;
    
    for (int i = 1; i <= n; i++)
    {
        cout << "node " << i << ": key = " << heap[i] << ", ";
        if (heap[i/2] != NIL)
        {
            cout << "parent key = " << heap[i/2] << ", ";
        }
        
        if (heap[2*i] != NIL)
        {
            cout << "left key = " << heap[2*i] << ", ";
        }
        if (heap[2*i+1] != NIL)
        {
            cout << "right key = " << heap[2*i+1] << ", ";
        }
        cout << endl;
    }
}


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

int main() {
  
  string S; cin >> S;
  
  int countA = 0, countB = 0, countC = 0;
  
  for (int i = 0; i < S.size(); i++) {
    
    char tmp = S.at(i);
    
    if (tmp == 'a') countA++;
    if (tmp == 'b') countB++;
    if (tmp == 'c') countC++;
    
  }
  
  int maxCount = max(countA, max(countB, countC));
  
  int minCount = min(countA, min(countB, countC));
  
  if (maxCount - minCount < 2) cout << "YES" << endl;
  
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>
#include <math.h>
#define ld long double

using namespace std;

int main(){

    ld W,H,x,y;
    cin >> W >> H >> x >> y;

    int flag = 0;

    if(x == W/2 && y == H/2){
        flag = 1;
    }

    cout << W*H/2 << " " << flag <<endl;




    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int maxn=20001;
int a[maxn],b[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){	 
     b[a[i]]++;
	 if(i+1<=n) 
     b[a[i]*10+a[i+1]]++;
     if(i+2<=n)
	 b[a[i]*100+a[i+1]*10+a[i+2]]++;
	 if(i+3<=n)
	 b[a[i]*1000+a[i+1]*100+a[i+2]*10+a[i+3]]++;
    }
	for(int i=0;i<=10000;i++)
	if(!b[i]){
	cout<<i<<endl;
	break;
    }
   // while(1);
	return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	scanf("%lld",&n);
	long long A=n;
	string s="";
	while(A>0)
	{
		if(A%26==0)
		{
			s.append(1,'z');
			A/=26;
			A--;
		}
		else
		{
			s.append(1,(char)(A%26+96));
			A/=26;
		}
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
}


Measured memory_bytes: 3688
import java.io.*;
import java.util.*;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                long X = scan.nextLong();

                long ganpon = 100;

                long year = 0;

                while (ganpon < X) {
                        year++;
                        ganpon *= 1.01;
                }

                System.out.println(year);
        }

}

Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

lint dp[212345][2][3];

template<class T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
    lint n;
    cin >> n;

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    fill(&dp[0][0][0], &dp[212345][0][0], -1e18);
    dp[0][0][0] = 0;
    for(lint i=0; i<n; i++)
    for(lint p=0; p<2; p++)
    for(lint m=0; m<3; m++) {
        if(p == 0) {
            chmax(dp[i+1][1][m], dp[i][p][m] + a[i]);
            if(m+1 < 3) chmax(dp[i+1][0][m+1], dp[i][p][m]);
        } else {
            chmax(dp[i+1][0][m], dp[i][p][m]);
        }
    }

    if(n%2) {
        cout << max(dp[n][0][1], dp[n][1][2]) << endl;
    } else {
        cout << max(dp[n][0][0], dp[n][1][1]) << endl;
    }
}

Measured memory_bytes: 14872
/*
// Sample code to perform I/O:

#include <iostream>

using namespace std;

int main() {
	int num;
	cin >> num;										// Reading input from STDIN
	cout << "Input number is " << num << endl;		// Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
bool prime[1000005];
void give(){
	for(int j=0;j<1000005;j++){
		prime[j]=1;
			
	}
	for(int j=2;j*j<=1000003;j++){
		if(prime[j]==1){
			for(int i=j*j;i<1000003;i+=j){
				prime[i]=0;
			}
		}
			
	}
}



long long int solve(long long int brr[][2],long long int n ){
	long long int dp[n];
	dp[0]=1;
	for(int j=1;j<n;j++){
		dp[j]=1;
		for(int k=0;k<j;k++){
			if(min(brr[j][0],brr[j][1])>min(brr[k][0],brr[k][1])){
				if(dp[j]<dp[k]+1){
					dp[j]=dp[k]+1;
				}
			}
		}
	}
	long long int ans=dp[0];
	for(int j=1;j<n;j++){
		ans=max(ans,dp[j]);
	}
	return ans;
}
int main(){
	float s,d,t;
	cin>>d>>t>>s;
	if(s>=(d/t)){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 3708
K,N=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)
d=(A+A.map{|i|i+K}).each_cons(2).map{|l,r|r-l}
a=s=d[0...(N-1)].sum
N.times do |i|
  s-=d[i]
  s+=d[i+N-1]
  a=[a,s].min
end
p a

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int s = (a + b) == 15;
    int m = (a * b) == 15;
    if(s) cout << '+' <<endl;
    else if (m) cout << '*' <<endl;
    else {
    cout << 'x' <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
 
using namespace std;
 
int main( ){
    string l;
    int t=0;
    string max="???";
    map<string,int> str;
    string s;
    while(cin>>s){
      if(s.length()>max.length())max=s;
        str[s]++;
        if(str[s]>t){
           t=str[s];
           l=s;
            }
    }
    cout<<l<<" "<<max<<endl;
    return 0;
}

Measured memory_bytes: 1192
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> values(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &values[i]);

  lint result = 0LL;
  map<lint, int> count;
  lint sum = 0LL;
  ++count[sum];
  for (int i = 0; i < n; ++i) {
    sum += values[i];
    int &count_sum = count[sum];
    result += count_sum;
    ++count_sum;
  }
  printf("%lld\n", result);

  return 0;
}


Measured memory_bytes: 13568
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > a;
    for(int i=0;i<n;i++){
        int b;
        cin >> b; 
        a.push_back(make_pair(b,i+1));
    }

    sort(a.begin(),a.end());

    for(int i=0;i<n;i++) cout << a.at(i).second << ' ';
    cout << endl; 
}

Measured memory_bytes: 4320
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, A, B;
  cin >> N >> A >> B;

  cout << min(A, B) << " " << max((ll)0, A+B-N) << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  int64_t sumN = 0;
  
  for (int64_t i = 0; i < N; i++) {
    int64_t num = i+1;
    if (num % 3 != 0 && num % 5 != 0) {
      sumN = sumN + num;
    }
  }
  
  cout << sumN << endl;

}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define _GLIBCXX_DEBAC
using namespace std;
	

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









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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

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

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

signed main(){
	int n;
	cin>>n;
	rep(i,10)rep(j,10)if(i*j==n){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}


int A[N];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j;
    int k;
    cin>>n>>k;
    fr(i,n)cin>>A[i];
    int ans =0;
    if(k>=n)ans=1;
    else{
    	n-=k;
    	ans= 1+(n+k-2)/(k-1);

    }
    cout<<ans<<"\n";

    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r, d, x;
    cin >> r >> d >> x;

    rep(i, 10) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    int zoro = 0;
    int i = 0;
    while (zoro != 3 && i < n)
    {
        int left, right;
        cin >> left >> right;
        if (left == right)
        {
            zoro++;
        }
        else
            zoro = 0;
        i++;
    }
    if (zoro >= 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<utility>
#include<algorithm>

using namespace std;

void maxHeapify(int A[],int i,int H);
void buildMaxHeap(int A[],int H);

int main(){
	int H; cin>>H;
	int *A;
	A = new int[H]; A = A-1;

	for(int i=1;i<=H;i++) cin>>A[i];

	buildMaxHeap(A,H);

	for(int i=1;i<=H;i++)
		cout<<" "<<A[i];
	cout<<endl;

	delete [] (A+1);
}

void maxHeapify(int A[],int i,int H){
	int left = i*2, right = left+1;
	int largest;
	if(left<=H && A[i]<A[left])
		largest = left;
	else
		largest = i;
	if(right<=H && A[largest]<A[right])
		largest = right;

	if(largest!=i){
		swap(A[i],A[largest]);
		maxHeapify(A,largest,H);
	}
}

void buildMaxHeap(int A[],int H){
	for(int i=H/2;i>=1;i--)
		maxHeapify(A,i,H);
}

Measured memory_bytes: 4580
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int t = sc.nextInt();
    if (x>=t){
      System.out.println(x-t);
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 21844
import sys

MOD = 10 ** 9 + 7


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    print((pow(10, n, MOD) - (pow(9, n, MOD) * 2 - pow(8, n, MOD))) % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9220
n,y=gets.split.map(&:to_i)
$x,$y,$z=-1,-1,-1
(n+1).times{|i|(n+1-i).times{|j|$x,$y,$z=i,j,n-i-j if i*10000+j*5000+(n-i-j)*1000 == y}}
puts "#{$x} #{$y} #{$z}"

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int ans = 0;
  cin >> N;
  vector<int> H(N);
  REP(i, N) cin >> H[i];
  for(int i = 0; i < N; i++) {
    //うみみれる
    bool flag = true;
    for(int j = 0; j < i; j++) {
      if(H[j] > H[i]) {
        flag = false;
        break;
      }
    }
    if(flag) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[201000], P[201000];
long long D[201000], Mod = 1000000007, C[201000];
int main() {
	int i;
	scanf("%d", &n);
	D[0] = 1;
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		D[i] = D[i - 1];
		if (w[i] != w[i - 1]) {
			D[i] = (D[i] + C[w[i]]) % Mod;
			C[w[i]] = D[i];
		}
		P[w[i]] = i;
	}
	printf("%lld\n", D[n]);
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll n;
V abc(3);

ll calc(V state, V l) {
    V labc(3, 0);
    V cnt(3, -1);
    rep(i, n) {
        if (state[i] != 3) {
            labc[state[i]] += l[i];
            cnt[state[i]]++;
        }
    }

    ll ret = 0;
    if (*min_element(all(labc)) == 0) ret = inf;
    else {
        rep(i, 3) ret += abs(abc[i] - labc[i]) + cnt[i]*10;
    }
    return ret;
}

ll dfs(ll depth, V state, V l) {
    if (depth == n) return calc(state, l);

    ll ret = inf;
    rep(i, 4) {
        state[depth] = i;
        ret = min(ret, dfs(depth+1, state, l));
    }
    return ret;
}

int main() {
    cin >> n;
    rep(i, 3) cin >> abc[i];
    V l(n);
    rep(i, n) cin >> l[i];
    
    V state(n);
    ll ret = dfs(0, state, l);
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll ans=0;
  rep(i,1000){
    string sum="";
    if(i<10) sum+="00";
    else if(i<100) sum+="0";
    sum+=to_string(i);
    ll cu=0;
    rep(j,n){
      if(sum[cu]==s[j]){
        cu++;
      }
      if(cu==3) break;
    }
    if(cu==3)ans++;
  }
  COUT(ans);
}

Measured memory_bytes: 3712
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, X = MAP()

if 0 <= X-A <= B:
	print("YES")
else:
	print("NO")


Measured memory_bytes: 5580
def f_f():
    n, *s = map(int, open(0).read().split())
    s.sort()
    ps, next_ps, cs = [s.pop()], [], []
    for _ in range(n):
        for p in ps:
            while s:
                c = s.pop()
                if p>c:
                    next_ps.append(c)
                    break
                else:
                    cs.append(c)
        s, ps, next_ps, cs = s+cs[::-1], sorted(ps+next_ps, reverse=True), [], []

    print("No" if s else "Yes")

if __name__ == "__main__":
    f_f()


Measured memory_bytes: 32044
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  int N;
  cin >> N;
  vector<llong> A(N);
  for(int i=0; i<N; ++i) cin >> A[i];
  llong nowmax = A[0];
  llong sum = 0;
  for(int i=1; i<N; ++i){
    if(nowmax <= A[i]){
      nowmax = A[i];
    }else{
      sum += nowmax - A[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4756
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5010;

ll dp[MAX_N][MAX_N];  // dp[i][j] : s[i]とs[j](i < j)から始まる共通部分文字列の長さの最大値

int main() {
    ll n;
    string s;
    cin >> n >> s;

    for(ll i = n-2; i >= 0; i--) {
        for(ll j = n-1; j >= i+1; j--) {
            if(s[i] != s[j]) {
                dp[i][j] = 0;
            }
            else {
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }

    ll ans = 0;
    exrep(i, 0, n-2) {
        exrep(j, i+1, n-1) {
            ll u = min(j-i, dp[i][j]);
            chmax(ans, u);
        }
    }

    out(ans);
    re0;
}

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

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

 long long arr[n];
 long long  sum=0;
 for(int i=0;i<n;i++) {
     cin>>arr[i];
     sum+=arr[i];
 }
 sort(arr,arr+n);

 if(k==0) cout<<sum;

 else if(k>=n) cout<<"0";

 else {
   long long  cnt=0;
     for(int i=0;i<n-k;i++){
         cnt+=arr[i];
     }
     cout<<cnt;
 }



 return 0;
}


Measured memory_bytes: 1792