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

ll dp[3009][3009];
ll S[3009][3009];
ll E[3009][3009];
ll Ei[3009][3009];
ll mod =998244353;
ll exp(ll a, ll b){
    if(!b) return 1;
    if(b & 1) return a * exp(a*a % mod, (b-1)/2) % mod;
    return exp(a*a%mod, b/2);

}
main(){
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    dp[a][b] = 1;
    for(ll i = 0; i <= c+1; i++)
        for(ll j = 0; j <= d+1; j++)
            if(!j) E[i][j] = 1; else E[i][j] = E[i][j-1] * i % mod;
    for(ll i = 0; i <= c+1; i++)
        for(ll j = 0; j <= d+1; j++)
            if(!j) Ei[i][j] = 1; else
            if(j == 1) Ei[i][j] = exp(i, mod - 2);
            else Ei[i][j] = Ei[i][j-1] * Ei[i][1] % mod;
    for(ll x = a; x <= c; x++){
        for(ll y = b; y <= d; y++){
            if(x == a) {if(y > b) dp[x][y] = dp[x][y-1] * x % mod;} else
            dp[x][y] =( dp[x-1][y] * y + S[x-1][y-1] * E[x][y-1])% mod;
            S[x][y] = (S[x][y - 1] + dp[x][y] * y % mod * Ei[x+1][y])% mod;
        }
    }
    cout << dp[c][d]<<endl;

}


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

int main(){
    unsigned long long n;
    cin>>n;
    int ans=1e9;
    for(long long i=1;i<=sqrt(n);i++){
        int f;
        if(n%i==0) f =  max(to_string(i).length(), to_string(n/i).length());
        ans = min(ans,f);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#author : dokueki

import sys
from math import gcd
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def Gcd(a, b, c):
    return gcd(a, gcd(b, c))


def main():
    n = int(sys.stdin.readline())
    ans = 0
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            for k in range(1, n + 1):
                ans += Gcd(i, j, k)
    print(ans)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 9200
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#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 = 100010;

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

    if(n == 1 && m == 1) {
        out(1);
    }
    else if(n == 1) {
        out(m-2);
    }
    else if(m == 1) {
        out(n-2);
    }
    else {
        out((n-2)*(m-2));
    }

    re0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[200005][2];
signed main(){
	int n,x;cin>>n;
	char ch;
	for(int i=1;i<=n;++i){
		cin>>ch;
		if(ch=='#') x=0;
		else x=1;
		f[i][0]=min(f[i-1][0],f[i-1][1])+(x!=0);
		f[i][1]=f[i-1][1]+(x!=1);
	} 
	cout<<min(f[n][0],f[n][1]);
	return 0;
}

Measured memory_bytes: 5164
from operator import add
from functools import reduce

N, L = map(int, input().split())

l = []
for i in range(1, N + 1):
    l.append(L + i - 1)

if L < 0 and abs(L) >= N:
    l.pop(-1)
elif L < 0 and abs(L) < N:
    pass
else:
    l.pop(0)

print(reduce(add, l))


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int mi=n+1,count=0;
    for(int i=0;i<n;i++){
        int x;cin >> x;
        mi=min(mi,x);
        if(mi>=x) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3532
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

string ans;

void ps(int n,char a){
    for(int i=0;i<n;i++) ans+=a;
    return;
}

int sumd(int n){
    int res=0;
    while(n>0){
        res=n%10;
        n/=10;
    }
    return res;
}

int F(ll a,ll b){
    string s,t;
    s=to_string(a);
    t=to_string(b);
    return max(s.size(),t.size());
}
int main(){
    string s;cin>>s;
    string devide[4]={"dream","dreamer","erase","eraser"};
    reverse(s.begin(),s.end());
    for(int i=0;i<4;i++){
        reverse(devide[i].begin(),devide[i].end());
    }

    bool flag=true;
    for(int i=0;i<s.size();){
        bool flag2=false;
        for(int j=0;j<4;j++){
            string d=devide[j];
            if(s.substr(i,d.size())==d){
                flag2=true;
                i+=d.size();
            }
        }
        if(!flag2){
            flag=false;
            break;
        }
    }
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}    

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

main() {
    int N; cin >> N;
    int A[N]; rep(i,N) cin >> A[i];
    int ans=0;
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            ans=max(ans,abs(A[i]-A[j]));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<algorithm> //sort,min_element,next_permutation

using namespace std;

long gcd_vec(vector<long> V){
  //#include<vector>
  //#include<algorithm>
  long ans=V.at(0);
  //cout<<V.at(0)<<','<<V.at(1)<<endl;
  for(int i=1;i<V.size();i++){
    //cout<<ans<<V.at(i)<<endl;
    ans = __gcd(ans,V.at(i));
  }
  //cout<<ans<<endl;
  return ans;
}

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N,X;
  cin>>N>>X;
  vector<long> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);

  if(N==1){
    cout<<abs(A.at(0)-X)<<endl;
    return 0;
  }

  for(int i=0;i<N;i++){
    A.at(i)=abs(A.at(i)-X);
    //cout<<A.at(i)<<endl;
  }

  //vector<long> B;
  //for(int i=0;i<N-1;i++){
  //  B.push_back(A.at(i+1)-A.at(i));
  //  cout<<B.at(i)<<endl;
  //}

  cout<<abs(gcd_vec(A))<<endl;
}

Measured memory_bytes: 1792
/*/ Author:amar1503/*/
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize ("Ofast")
//common
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,n) for(int i=0;i<n;i++)
#define Afor(i,v) for(auto i:(v))
//#define bfor(i,a,b) for(int i=a;i<b;i++)
//#define rfor(i,n) for(int i=n-1;i>=0;i--)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
//containers
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz(v) (v).size()
//#define sortv(v)  sort((v).begin(),(v).end())
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)   (v).erase(unique(all(v)),(v).end())
//#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
//#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//equal range can also be used

typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;

/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template < class T >
using indexed_set= tree < T , null_type,less < T > , rb_tree_tag , tree_order_statistics_node_update >;*/

/*/-----------------------------Code begins----------------------------------/*/
int main(){
string s;
cin>>s;
int n=s.size()/2;
//abcabc;
int c=0,i=0,j=s.size()-1;
while(i<j){
    if(s[i]!=s[j])
        c++;
    i++;j--;
}
cout<<c;

return 0;}








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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    sort(all(vec));
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    vector<bool> factors(1000001,true);
    for (int i = 1; i * vec[0] <= 1000000; i++){
        factors[i * vec[0]] = false;
    }
    int ans = N;
    vector<bool> ok(N,true);
    for (int i = 1; i <= N - 1; i++){
        int count = 1;
        if (vec[i] == vec[i - 1]){
            ok[i] = false;
            ok[i - 1] = false;
        }
        else{
            if (factors[vec[i]]){
                for(int j = 1; j * vec[i] <= 1000000; j++){
                    factors[j * vec[i]] = false;
                }
            }
            else{
                ok[i] = false;
            }
        }
    }
    rep(i,N){
        if (!ok[i]) ans--;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4248
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ff first
#define ss second
using namespace std;
using ll = long long int;

void solve(){

	ll n,k;
	cin>>n>>k;

	ll sum=0;

	ll arr[n];

	int i=0;
	rep(i,n){
		cin>>arr[i];
	}

	sort(arr,arr+n);


	rep(i,n-k){
		sum+=arr[i];
	}
	

	db1(sum);


}



int main(){

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


while(t--){
  solve();
  }
      
  



	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

#define NEW(p,n) {p = malloc(n * sizeof(p[0]));}

typedef int* vector;

vector make_vector(int n)
{
    vector v;
    NEW(v,n);
    for(int i = 0; i < n; i++)
    {
        v[i] = 0;
    }
    return v;
}

int max(int n, vector v)
{
    int ret = 0;
    for(int i = 0; i < n; i++)
    {
        if (v[i] > ret) ret = v[i];
    }
    return ret;
}

int sum(int n, vector v)
{
    int ret = 0;
    for(int i = 0; i < n; i++)
    {
        ret += v[i];
    }
    return ret;
}

int main()
{
    int N;
    vector p;

    scanf("%d",&N);
    p = make_vector(N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&p[i]);
    }
    printf("%d\n",sum(N,p) - max(N,p) / 2);
}

Measured memory_bytes: 128
var = (input())
end = var[-1]
end = int(end)

hon_list = [2, 4, 5, 7, 9]
pon_list = [0, 1, 6, 8]
bon_list = [3]

HON = "hon"
PON = "pon"
BON = "bon"

if end in hon_list:
    print(HON)
elif end in pon_list:
    print(PON)
elif end in bon_list:
    print(BON)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  vector<int> s(n);
  vector<int> f(n);
  rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
  for (int i = 0; i < n - 1; i++) {
    int ans = 0;

    for (int j = i; j < n - 1; j++) {
      int now = s[j];
      while (now < ans) {
        now += f[j];
        // cout << now << " " << f[j] << endl;
      }
      ans = now + c[j];
    }
    cout << ans << endl;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
eval'N,K,*A='+`dd`.split*?,
K.times{b=[t=0]*N*3
N.times{b[[0,_1-A[_1]].max]+=1
b[_1-~A[_1]]-=1}
A=(0...N).map{t+=b[_1]}
A.min<N||break}
p *A

Measured memory_bytes: 123128
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int X = scanner.nextInt();
        final int Y = scanner.nextInt();
        final int Z = scanner.nextInt();
        System.out.println(Z + " " + X + " " + Y);
        scanner.close();
    }
}

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

int main(){
    string s;
    cin >> s;
    int cnt0=0,cnt1=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0') cnt0++;
        else cnt1++;
    }
    int ans=min(cnt0,cnt1);
    cout << 2*ans << endl;
}

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

#define nl                 "\n"
#define ll                 long long
#define pb                 push_back
#define pf                 push_front
#define np                 next_permutation
#define pp                 prev_permutation
#define sqr(x)             ((x)*(x))
#define pi                 acos(-1)
#define setprecision(x)    fixed<<setprecision((int)(x))
#define mem1(x)            memset(x,0,sizeof(x))
#define mem2(x)            memset(x,-1,sizeof(x))
#define all(x)             (x).begin(),(x).end()
#define sort1(x)           sort(all(x))
#define csort(x,c)         sort(all(x),c)
#define rsort(x)           sort(x.rbegin(),x.rend())

using namespace std;
void solve()
{
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0; i<n; i++)
    {
        string a;
        cin>>a;
        if(a=="AC")
            ac++;
        else if(a=="WA")
            wa++;
        else if(a=="TLE")
            tle++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int t; cin>>t; while(t--){solve();}
    solve();
    return 0;
}



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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;
    cout << max(t2-t1-k, 0) << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
  int N, *P, i, j, min = 0, count = 1;
  scanf("%d", &N);

  P = (int *)malloc(N * sizeof(int));
  for(i=0; i<N; i++){
    scanf("%d", &P[i]);
    if(P[i] < P[min]){
      min = i;
      count++;
    }
  }

  printf("%d\n", count);
  
  return 0;
}


Measured memory_bytes: 896
/*AOJ  Volume1-0100*/
using System;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        int DataNum;
        List<Employee> Employees = new List<Employee>();
        string[] InputData;
        int ID;
        long Price, Qutantity;

        
        while(true){
            
            DataNum = int.Parse(Console.ReadLine());
            if(DataNum == 0){
                break;
            }
        
            Employees.Clear();
            
            for(int i = 0; i < DataNum; i++){
                InputData = Console.ReadLine().Split(' ');
                
                ID = int.Parse(InputData[0]);        
                Price = long.Parse(InputData[1]);
                Qutantity = long.Parse(InputData[2]);
                
                int n;
                for(n = 0; n < Employees.Count; n++){
                    if(Employees[n].ID == ID){
                        Employees[n].SalesAdd(Price * Qutantity);
                    }
                }
                if(n == Employees.Count){
                    Employees.Add(new Employee(ID, Price * Qutantity));
                }
            }
            
            int OneMegaOverNum = 0;
            for(int i = 0; i < Employees.Count; i++){
                if(Employees[i].Sales >= Consts.QUOTA){
                    Console.WriteLine(Employees[i].ID);
                    OneMegaOverNum++;
                }
            }
            if(OneMegaOverNum <= 0) Console.WriteLine("NA");

        }
    }
}

public static class Consts{
    public static long QUOTA = 1000000;
}

public class Employee{
    public int ID{get;set;}
    public long Sales{get;set;}
    public Employee(int InitID, long InitSales){
        ID = InitID;
        Sales = InitSales;
    }
    public void SalesAdd(long InputSales){
        Sales += InputSales;
    }
}

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() 
{
	fastio
	//t_case
	{
		ll n,m,ans=0,f=1,k=0,x,y,sum=0,h,l  ;cin>>n ;
		string s; cin>>s;
		int r=0,w=0;
		fr(i,0,n)
			if (s[i]=='W') w++;
		for (int i=n-1;i>=n-w;i-- ){
			if (s[i]=='R') r++;
		}
		cout<<r;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3664
a, b = map(int, input().split())
e = []
f = [True] * b
for i in range(a):
    c = list(input())
    d = True
    for j in range(b):
        if c[j] == "#" and d:
            d = not d
        if c[j] == "#" and f[j]:
            f[j] = not f[j]
    if not d:
        e.append(c)
for i in range(len(e)):
    g = ""
    for j in range(b):
        if not f[j]:
            g += e[i][j]
    print(g)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+5,mod=1e9+7;
int r[N],c[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;cin>>n>>m;
    for(ll i=1;i<=n;i++){
        ll x;cin>>x;
        if(r[x])return cout<<"0" , 0;
        r[x]=i;
    }
    for(ll i=1;i<=m;i++){
        ll x;cin>>x;
        if(c[x])return cout<<"0" , 0;
        c[x]=i;
    }
    ll ans=1,x=0,y=0;
    for(ll val=n*m;val>=1;val--){
        if(r[val]||c[val]){
            if(r[val]&&c[val])x++,y++;
            else if(r[val]){
                ans*=y;
                ans%=mod;
                x++;
            }
            else{
                ans*=x;
                ans%=mod;
                y++;
            }
        }
        else{
            ll tmp= x*y - (n*m - val);
            ans*=tmp;
            ans%=mod;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first > b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,W;
    cin >>N>>W;
    //vector<ll>w(N),v(N);
    vector<ll>v1,v2,v3,v4;
    ll w1,v11;
    cin>>w1>>v11;
    v1.pb(v11);

    rep(i,N-1){
        ll w,v;
        cin>>w>>v;
        if(w==w1){
            v1.pb(v);
        }else if(w==w1+1){
            v2.pb(v);
        }else if(w==w1+2){
            v3.pb(v);
        }else{
            v4.pb(v);
        }
    }
    sort(all(v1));
    reverse(all(v1));
    sort(all(v2));
    reverse(all(v2));
    sort(all(v3));
    reverse(all(v3));
    sort(all(v4));
    reverse(all(v4));
    ll s1,s2,s3,s4;
    s1=v1.size();
    s2=v2.size();
    s3=v3.size();
    s4=v4.size();
    vector<ll>sum1(s1+1),sum2(s2+1),sum3(s3+1),sum4(s4+1);
    rep(i,s1){
        sum1[i+1]=sum1[i]+v1[i];
        //cout<<sum1[i+1]<<endl;
    }
    rep(i,s2){
        sum2[i+1]=sum2[i]+v2[i];
    }
    rep(i,s3){
        sum3[i+1]=sum3[i]+v3[i];
    }
    rep(i,s4){
        sum4[i+1]=sum4[i]+v4[i];
    }
    ll ans=0;
    rep(i,N+1){
        rep(j,min(i+1,s1+1)){
            rep(k,min(i-j+1,s2+1)){
                rep(m,min(i-j-k+1,s3+1)){
                    rep(n,min(i-j-k-m+1,s4+1)){
                        ll we=w1*j+(w1+1)*k+(w1+2)*m+(w1+3)*n;
                        if(we<=W){
                            //cout<<i<<" "<<j<<endl;
                            chmax(ans,sum1[j]+sum2[k]+sum3[m]+sum4[n]);
                        }
                    }
                }
            }
        }
    }
    
    cout<<ans<<endl;

    return 0;
    

}

Measured memory_bytes: 3640
import sys

from numba import njit

input = sys.stdin.readline


@njit
def make_n_divisor_table(n):
    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    return table


def main():
    N = int(input())

    table = make_n_divisor_table(N)

    ans = 0
    for i, v in enumerate(table):
        ans += i * v

    print(ans)


if __name__ == "__main__":
    main()


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

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

int main()
{
    long long N, M;
    cin >> N >> M;
    vector<long long> H(N);
    rep(i, N){
        cin >> H.at(i);
    }
    vector<pair<long long, long long>> AB;
    rep(i, M){
        long long A, B;
        cin >> A >> B;
        AB.push_back(make_pair(A, B));
        AB.push_back(make_pair(B, A));
    }
    /*for (int j = 0; j < AB.size();j++){
        long long A = AB.at(j).first;
        long long B = AB.at(j).second;
        cout << A << ":" << B << endl;
    }*/
    sort(AB.begin(), AB.end());
    long long logger = -1;
    long long Highest = -1;
    bool most = true;
    long long ans = -1;
    long long A = 0;
    long long B = 0;
    vector<long long> check(N);
    for (int i = 0; i < AB.size();i++){
        A = AB.at(i).first;
        check.at(A - 1)++;
        if(logger != A){
            if(most){
                ans++;
            }
            Highest = H.at(A - 1);
            logger = A;
            most = true;
        }

        B = AB.at(i).second;
        if(H.at(B - 1) >= Highest){
            most = false;
        }
    }
    if(most){
        ans++;
    }
    rep(i, N){
        if(check.at(i) == 0){
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 8248
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
typedef long long ll;

using namespace std;
int main(){
    int a,b;
    cin >> a>>b;
    if(a%2==b%2){
        cout<<(a+b)/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

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

int main() {

  int N;
  string S;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (i == N-1){
      cout << "Three" << endl;
    }
    else{
      continue;
    }
  }
}

Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int INF=(1<<29);
  vector<int> x(100010,INF);
  vector<vector<int> > g(100010);
  int a,b,n,m,i,j;
  cin >> n >> m;
  for(i=0;i<m;i++){
    cin >> a>> b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> que;
  que.push(0);
  x[0]=0;
  while(!que.empty()){
    int q=que.front();
    que.pop();
    for(i=0;i<g[q].size();i++){
      if(x[g[q][i]]>x[q]+1){
        x[g[q][i]]=x[q]+1;
        que.push(g[q][i]);
      }
    }
  }
  printf("Yes\n");
  for(i=1;i<n;i++){
    for(j=0;j<g[i].size();j++){
      if(x[i]-1==x[g[i][j]]){
        printf("%d\n",g[i][j]+1);
        break;
      }
    }
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

const int MAX = 10000000;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl a;
/******* define variable end *******/
int solve() {
	cin >> n;
	a.resize(n);
	REP(i, n){
		cin >> a[i];
	}
	ll ans = 0;
	FOR(i, 1, n){
		if(a[i-1] > a[i]){
			ans += a[i-1] - a[i];
			a[i] = a[i-1];
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 4796
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <set>
#include <map>

using namespace std;



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

	string filename = "date";

	//ifstream cin(filename + ".in");
	//ofstream cout(filename + ".out");

	string s;
	cin >> s;

	array<int, 26> freq;
	freq.fill(0);

	for (int i = 0; i < s.length(); ++i) {
		++freq[s[i] - 'a'];
	}

	bool modified = false;
	for (int i = 0; i < 26; ++i) {
		if (freq[i] == 0) {
			s.push_back('a' + i);
			modified = true;
			break;
		}
	}

	if (modified) {
		if (s.empty()) cout << "-1";
		else cout << s;
	}
	else {
		while (true) {
			char last = s.back();
			while (last <= 'z' && freq[last - 'a'] != 0) {
				++last;
			}

			if (last > 'z') {
				--freq[s.back() - 'a'];
				s.pop_back();

				if (s.empty()) break;
				continue;
			}
			else {
				s.pop_back();
				s.push_back(last);
				break;
			}
		}

		if (s.empty()) cout << "-1";
		else cout << s;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>

using namespace std;

int main(void){
  long long int N;
  scanf("%lld", &N);
  long long int ans = N - 1;
  for(long long int i = 2; i * i < N + 1; i++){
    if(N % i == 0){
      ans = min(ans, (N / i - 1) + (i - 1));
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1LL<<60
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<int> G[500005];
ll dp[500005][2];
ll ch[500005];
ll depth[500005];

int dfs(int v,int d){
	if(v==(n-1))return 1;
	int cnt=0;
	depth[v]=d;
	for(int i=0;i<G[v].size();i++){
		cnt+=dfs(G[v][i],d+1);
	}
	return (ch[v]=cnt);
}

void solve(int v){
	for(int i=0;i<G[v].size();i++){
		if(G[v][i]!=(n-1)){
			solve(G[v][i]);
		}
	}
	int l=G[v][0];
	int r=G[v][1];
	dp[v][0]=ch[v]+dp[l][0]+dp[r][0];
	dp[v][1]=min(dp[l][0]+ch[l]+1+dp[r][1],dp[l][1]+1+ch[r]+dp[r][0]);
	dp[v][1]=min(dp[v][1],dp[l][1]+depth[v]+dp[r][1]+2);
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[i].push_back(a);
		G[i].push_back(b);
	}
	for(int i=0;i<n-1;i++){
		dp[i][0]=INF;
		dp[i][1]=INF;
	}
	dfs(0,0);
	ch[n-1]=1;
	solve(0);
	printf("%lld\n",min(dp[0][0],dp[0][1]));
	return 0;
}


Measured memory_bytes: 69560
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
ll a, b;
ll Gcd(ll a, ll b) {
    if(!b)
        return a;
    else
        return Gcd(b, a % b);
}

int main() {
    scanf("%lld %lld", &a, &b);
    printf("%lld\n", Gcd(a, b));
    return 0;
}


Measured memory_bytes: 2764
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	char[] S = sc.next().toCharArray();
    	int[] num = new int[26];
    	for(int i=0; i<S.length; i++) {
    		num[S[i] - 'A']++;
    	}
    	int x = 0;
    	for(int i=0; i<26; i++) {
    		if(num[i] == 2) {
    			x++;
    		} else if(num[i] != 0) {
    			System.out.println("No");
    			return;
    		}
    	}
    	if(x == 2) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    static void shuffleArray(long[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }
}


Measured memory_bytes: 21332
import java.util.*;

public class Main{
	public static void main(String[] args){

		// 値取得
		Scanner sc = new Scanner(System.in);
		String wether = sc.next();

		// 天気条件
		if(wether.equals("Sunny")){

			System.out.println("Cloudy");
		}else if(wether.equals("Cloudy")){

			System.out.println("Rainy");
		}else{

			System.out.println("Sunny");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;

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


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

int main() {
  vector<int> A(32);
  A = {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;
  cin >> K;
  int ans;
  ans = A.at(K - 1);
  cout << ans << endl;
  
}

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

const int mod = 1e9 + 7;
int n;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	long long cur = 1, sub = 1, exc = 1;
	for(int i = 0; i < n; i++){
		cur = (cur * 10) % mod;
		sub = (sub * 9) % mod;
		exc = (exc * 8) % mod;
	}
	sub = (2 * sub) % mod;
	cout << (((cur - sub) % mod + mod) % mod + exc) % mod << '\n';
	return 0;
}

Measured memory_bytes: 3620
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let r: isize = iterator.next().unwrap().parse().unwrap();
    let g: isize = iterator.next().unwrap().parse().unwrap();

    let ans = 2 * g - r;
    return ans.to_string();
}


Measured memory_bytes: 2108
#!/usr/bin/env python

import sys
from operator import itemgetter

n = int( sys.stdin.readline().strip() )
rest= []
for i in range(n):
    k,v = sys.stdin.readline().strip().split()
    rest.append( [i+1,k,int(v)] )
#
for x in sorted( rest,key=lambda x: (x[1],-x[2]) ):
    print( x[0] )

    


Measured memory_bytes: 3188
N, M = map(int, input().split())

ball = [1 for _ in range(N)]
red = [0 for _ in range(N)]
red[0] = 1

now_red = 0

for i in range(M):
    xx, yy = map(int, input().split())
    x = xx-1
    y = yy-1
    
    ball[x] -= 1
    ball[y] += 1
    
    if red[x]:
        if ball[x] == 0:
            red[x] = 0

        red[y] = 1
        now_red = y
    # print("ball", ball)
    # print("red", red)
    # print("now_red", now_red)

print(sum(red))
    


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	string s;
	string x=string(m+2,'#');
	cout << x << endl;
	for (int i=0; i<n; i++)
		cin>>s, cout << "#" << s << "#" << endl;
	cout << x << endl;
	return 0;
}


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

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

	int y = 0, m = 0, d = 0;
	sscanf(s.c_str(), "%d/%d/%d", &y, &m, &d);

	if (2019 < y || (2019 == y && 5 <= m)) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}

	return 0;
}

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

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


using ll = long long;
using ull = unsigned long long;
using namespace std;

int main()
{
    string S, H;
    cin >> S >> H;
    if (H.substr(0, S.length()) == S)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  rep(i,N) {
    int t;
    cin >> t;
    if (i+1 != t) ++cnt;
  }
  if (cnt == 0 || cnt == 2) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3128
ls = [[int(_) for _ in input().split()] for _ in range(3)]

cnt = [0] * 4

for i in range(3):
    for j in range(2):
        if ls[i][j] == 1:
            cnt[0] += 1
        elif ls[i][j] == 2:
            cnt[1] += 1
        elif ls[i][j] == 3:
            cnt[2] += 1
        elif ls[i][j] == 4:
            cnt[3] += 1

if min(cnt) == 0 or max(cnt) == 3:
    print("NO")
else:
    print("YES")

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

int main(void){
    int x;
    cin >> x;
    int kyu = 8;
    x -= 400;
    while(x >= 200) x -= 200, --kyu;
    cout << kyu << endl;
    return 0;
}

Measured memory_bytes: 3592
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
string s = "aeiou";
void yes() {
    cout << "YES" << endl;
}
void no() {
    cout << "NO" << endl;
}
void solve() {
    while(cin >> s) {
        int n = s.size();
        int i = 0;
        reverse(s.begin(), s.end());
        bool f = 1;
        while(i < n) {
            if(s[i] == 'm') {
                if(i + 5 <= n) {
                    string t = s.substr(i, 5);
                    if(t == "maerd") {
                        i += 5;
                    } else {
                        f = 0;
                        break;
                    }
                } else {
                    f = 0; break;
                }
                continue;
            }
            if(s[i] == 'r') {
                if(i + 6 <= n) {
                    string t = s.substr(i, 6);
                    if(t == "resare") {
                        i += 6;
                        continue;
                    }
                }
                if(i + 7 <= n) {
                    string t = s.substr(i, 7);
                    if(t == "remaerd") {
                        i += 7;
                        continue;
                    }
                }
                f = 0;
                break;
            }
            if(s[i] == 'e') {
                if(i + 5 <= n) {
                    string t = s.substr(i, 5);
                    if(t == "esare") {
                        i += 5;
                    } else {
                        f = 0; break;
                    }
                } else {
                    f = 0; break;
                }
                continue;
            }
            f = 0;
            break;
        }
        if(f) yes();
        else no();
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define D_MAX 1 << 21
#define N_MAX 10000
using namespace std;

int dis[N_MAX];
int n;

struct node {
  int to;
  int cost;
  node(int to,int cost) {
    this->to = to;
    this->cost = cost;
  }
};

void dijkstra(int st,vector< vector<node*> > &nodes) {
  for(int i=0;i<n;i++) dis[i] = D_MAX;
  dis[st] = 0;
  bool visited[n]; for(int i=0;i<n;i++) visited[i] = false;
  vector<int> vertexes;
  visited[st] = true;
  vertexes.push_back(st);
  int pre_cost = 0;
  while(vertexes.size() < n) {
    // update distance list
    int v = vertexes[vertexes.size()-1];
    for(int j=0;j<nodes[v].size();j++) {
      int u = nodes[v][j]->to;
      if(visited[u]) continue;
      int cost = nodes[v][j]->cost + pre_cost;
      dis[u] = min(dis[u],cost);
    }
    // find vertex which has smallest distance.
    int next_v;
    int minimum = D_MAX;
    for(int i=0;i<n;i++) {
      if(visited[i]) continue;
      if(dis[i] < minimum) {
        minimum = dis[i];
        next_v = i;
      }
    }
    visited[next_v] = true;
    vertexes.push_back(next_v);
    pre_cost = dis[next_v];
  }
}

int main() {
  scanf("%d",&n);
  int u,k,v,c;
  vector<vector< node*> > nodes;
  nodes.resize(n);
  for(int i=0;i<n;i++) {
    scanf("%d %d",&u,&k);
    for(int j=0;j<k;j++) {
      scanf("%d %d",&v,&c);
      nodes[u].push_back(new node(v,c));
    }
  }

  // check
  /*
  for(int i=0;i<nodes.size();i++) {
    for(int j=0;j<nodes[i].size();j++) {
      printf("%2d :%2d %2d\n",i,nodes[i][j]->to,nodes[i][j]->cost);
    }
  }
  */

  dijkstra(0,nodes);
  for(int i=0;i<n;i++) {
    printf("%d %d\n",i,dis[i]);
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n;
  int x;
  cin >> x;
  --x;
  for (int i = 1; i < n; ++i) {
    int y;
    cin >> y;
    if (x > y) {
      cout << "No\n";
      return;
    }
    if (x < y) {
      x = y - 1;
    }
  }
  cout << "Yes\n";
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb() push_back()
#define INF 1000000000
using namespace std;

const int mod = 1e9+7;
int main(){
	ll x,y,t;
	char d;
	
	cin>>x>>y;
	cin>>d;
	cin>>t;
	
	ll res = (x*(100*y+t));
	cout<<res/100;
		return 0;
}


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

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T... ar) {
        for (T i : ar) {
            out.print(i + " ");
        }
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException {

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc) {
        int a = sc.ni(), b = sc.ni();
        out.println(Integer.max(a + b, Integer.max(a - b, a * b)));
    }

    static class MyScanner {

        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc() {
            return nn().charAt(0);
        }

        int ni() {
            return Integer.parseInt(nn());
        }

        long nl() {
            return Long.parseLong(nn());
        }

        double nd() {
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n) {
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        int[] niArr1(int n) {
            int[] ar = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        long[] nlArr0(int n) {
            long[] ar = new long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nl();
            }
            return ar;
        }

        long[] nlArr1(int n) {
            long[] ar = new long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nl();
            }
            return ar;
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

using pi = pair<int,int>;

int main() {
  int N, M;
  while (cin >> N >> M and N != 0 and M != 0) {
    vector<pi> pc[N+1];
    int R, Q;
    cin >> R;
    int t,n,m,s;
    rep(i, R) {
      cin >> t >> n >> m >> s;
      pc[n].push_back(pi(t, m));
    }

    cin >> Q;
    int ts, te, mq;
    rep(i, Q) {
      int ans = 0;
      vector<bool> flag(1300, false);
      cin >> ts >> te >> mq;
      for (int i = 1; i <= N; ++i) {
        for (int j = 0; j < pc[i].size(); j += 2) {
          pi begin = pc[i][j], end = pc[i][j+1];
          if (begin.second != mq) continue;
          // cout << begin.first << " " << end.first << endl;
          int ps = max(ts, begin.first);
          int pe = min(te, end.first);
          rep_r(i, pe, ps) flag[i] = true;
        }
      }
      rep_r(i, te, ts) if(flag[i]) ans += 1;
      cout << ans << endl;
    }
  }
}



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

int main() {
  long long h1, h2, m1, m2, k, a, b, c, t;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  a=h1*60+m1;
  b=h2*60+m2;
  c=b-k;
  t=c-a;
  cout << t << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  int n;
  scanf("%d", &n);
  if (n < 1200) {
    printf("ABC\n");
  } else if (n < 2800) {
    printf("ARC\n");
  } else {
    printf("AGC\n");
  }



  return 0;
}


Measured memory_bytes: 128
Q, H, S, D = map(int, input().split())
N = int(input())

if min(8 * Q, 4 * H, 2 * S, D) == D:
    ans = (N // 2) * D
    if N % 2 == 1:
        ans += min(4 * Q, 2 * H, S)
else:
    ans = min(4 * Q, 2 * H, S) * N

print(ans)

Measured memory_bytes: 9024