akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

#define MAX 101
#define INV (-1)

using namespace std;

int piles[MAX][MAX];
int pile_size[MAX];
int places[MAX];

void ResetPiles(int m){
	for(int i = 0; i < MAX; ++i){
		places[i]=INV;
		pile_size[i] = 0;
		for(int j = 0; j < MAX; ++j)
			piles[i][j] = INV;
	}
	for(int i = 1; i <= m; ++i){
		places[i] = i;
		pile_size[i] = 1;
		piles[i][0] = i;
	}
}
void Print(){
	for(int i = 1; i < MAX; ++i){
		if( pile_size[ i ] > 0 ){
			cout << i << ": ";
			for(int j = 0; j < pile_size[ i ]; ++j){
				if( piles[i][j] != INV )
					cout << piles[i][j] << ' ';
			}
			cout << endl;
		}
	}
	cout << endl;
}
void PutOn(int I, int J){
	if( I == J )
		return ;
	
	if( J == 0 ){
		int place = places[I];

		if( pile_size[ place ] == 1 )
			return ;

		for(int i = 0; i < pile_size[ place ]; ++i){
			if( piles[ place ][ i ] == I ){
				int decrease = 0;
				if( i == 0 )
					break;
				for(int j = i; j < pile_size[ place ]; ++j){
					piles[ piles[place][j] ][0] = piles[place][j];
					pile_size[ piles[place][j] ] = 1;
					places[ piles[place][j] ] = piles[place][j];
					piles[ place ][j] = INV;
					++decrease;
				}
				pile_size[ place ] -= decrease;
				break;
			}
		}
		//Print();
	}else{
		int placei = places[I];
		int placej = places[J];
		int heighti, heightj;

		for(int i = 0; i < pile_size[ placei ]; ++i){
			if( piles[ placei ][i] == I ){
				heighti = i;
			}
		}
		for(int i = 0; i < pile_size[ placej ]; ++i){
			if( piles[ placej ][i] == J ){
				heightj = i;
			}
		}

		if( placei == placej ){		
			if( heighti < heightj ){
				int decrease = 0;
				for(int j = heighti + 1; j < pile_size[ placei ]; ++j){
					++decrease;
					piles[ piles[ placei ][j] ][ pile_size[ piles[placei][j] ] ] = piles[ placei ][j];
					pile_size[ piles[ placei ][j] ] = 1;
					places[ piles[ placei ][j] ] = piles[ placei ][j];
					piles[ placei ][j] = INV;
				}
				pile_size[ placei ] -= decrease;
				placej = places[J];
				
				piles[ placej ][ pile_size[ placej ] ] = I;
				++pile_size[ placej ];
				--pile_size[ placei ];
				places[ I ] = placej;
				piles[ placei ][ heighti ] = INV;
			}
		}else{
			int decrease = 0;
			for(int i = heighti + 1; i < pile_size[ placei ]; ++i){
				++decrease;
				piles[ piles[ placei ][i] ][0] = piles[ placei ][ i ];
				pile_size[ piles[ placei ][ i ] ] = 1;
				places[ piles[ placei ][i] ] = piles[ placei ][ i ];
				piles[ placei ][ i ] = INV;
			}
			++decrease;
			pile_size[ placei ] -= decrease;
			piles[ placej ][ pile_size[ placej ] ] = I;
			places[ I ] = placej;
			++pile_size[ placej ];
			piles[ placei ][ heighti ] = INV;
			
		}
		//Print();
	}
}

int main(){
	while(true){
		int m;
		vector<int> sizes;
		
		scanf("%d", &m);
		if( m == 0 ) break;
		ResetPiles( m );
		while(true){
			int I,J;
			scanf("%d%d", &I, &J);
			if( I == 0 && J == 0 ) break;
			PutOn( I, J );
		}
		for(int i = 1; i <= m; ++i){
			sizes.push_back( pile_size[ i ] );
		}
		sort( sizes.begin(), sizes.end() );
		for(unsigned int i = 0; i < sizes.size(); ++i){
			if( sizes[i] > 0 )
				printf("%d\n", sizes[i] );
		}
		printf("end\n");
	}
	return 0;
}

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

using namespace std;

int main(){
    long long int N,K,u=1e18,l=-1;
    cin >> N >> K;

    vector<long long int> A(N),F(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    for(int i=0;i<N;i++){
        cin >> F[i];
    }

    sort(A.begin(),A.end());
    sort(F.begin(),F.end());

    while(1<u-l){
        long long int mid = (u+l)/2,move=0;

        for(int i=0;i<N;i++){
            long long int tmp = A[i]*F[N-1-i] - mid;
            if(0<tmp){
                move += (tmp+F[N-1-i]-1)/F[N-1-i];
            }
        }

        if(K<move){
            l = mid;
        }else{
            u = mid;
        }
    }

    cout << u << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {
  
  int N;
  cin >> N;
  int count = 0;
  rep(i,N) {
    int x, y;
    cin >> x >> y;
    if (x == y) count++;
    else count = 0;
    if (count >= 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    set<int> s;
    s.insert(1);
    s.insert(2);
    s.insert(3);
    cin>>i>>j;
    s.erase(i);
    s.erase(j);
    cout<<*s.B;

    return 0;
}



Measured memory_bytes: 256
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>
using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define toUpper(x) transform(x.begin(), x.end(), x.begin(),::toupper);
#define toLower(x) transform(x.begin(), x.end(), x.begin(),::tolower);
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> pii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

const int no=3e6+5;
const int modulo=1e9+7;
const int inf=1e18+9;
const int N=1001;
int a[no]={},b[no]={},cc[no]={},suma[no]={},mat[N][N]={{0}};
stack<int> S;
stack<int> ma;

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

int poww(int x, int y, int modulo) { int res=1;while(y) { if(y%2!=0) { res*=x;res%=modulo;y--; } else { x*=x;x%=modulo;y/=2; } } return res; }  //MODULAR EXPONENTIATION
bool comp(int a, int b) {
    return (a < b);   // MAXIMUM
    return (a > b);   // MINIMUM
}

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

vi adj[no],prime;
int used[no]={},q=1,t=1;
int dist[no]={},c_comp[no]={},siz;

void dfs(int node,int d) {
    used[node]=1;
    dist[d]+=1;
    for(int v : adj[node]) {
        if(!used[v]) {
            dfs(v,d+1);
        }
    }
}

/**/
void solve (){
    int n,x,m;
    cin>>n>>x>>m;
    if(n%x==0) {
        cout<<m*(n/x)<<en;
    }
    else {
        cout<<m*(n/x)+m<<en;
    }
}

void runn(){
        #ifndef ONLINE JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif
    }

signed main()
{
    night_rider
    //runn();
    t=1;
    //cin>>t;
    q=t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 73968
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long t , n , m , a[100001];
pair<int , int> bc[100001];
int main()
{
    cin >> n >> m;
    for (int i = 1 ; i <= n ; i++)
        cin >> a[i];
    sort(a + 1 , a + n + 1);
    for (int i = 1 ; i <= m ; i++)
        cin >> bc[i].second >> bc[i].first;
    sort(bc + 1 , bc + m + 1 , greater<pair<int , int> >());
    for (int i = 1 , j = 1 ; i <= m && j <= n ; i++)
        while (bc[i].second-- > 0)
        {
            if (j > n || a[j] >= bc[i].first)
            {
                j = n + 1;
                break;
            }
            else a[j++] = bc[i].first;
        }
    for (int i = 1 ; i <= n ; i++)
        t += a[i];
    cout << t;
    return 0;
}


Measured memory_bytes: 1792
import heapq

n, m = map(int,input().split())
ab = [[0] * 2 for i in range(n)]
for i in range(n):
    a, b = map(int,input().split())
    ab[i][0], ab[i][1] = a, -1*b
heapq.heapify(ab)

b = [0]
heapq.heapify(b)
ans = 0
for i in range(1, m+1):
    while ab:
        tmp = heapq.heappop(ab)
        if tmp[0] <= i:
            heapq.heappush(b, tmp[1])    
        else:
            heapq.heappush(ab, tmp)
            break
    if b:
        ans -= heapq.heappop(b)
print(ans)

Measured memory_bytes: 94780
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vishal Burman
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BAlgae solver = new BAlgae();
        solver.solve(1, in, out);
        out.close();
    }

    static class BAlgae {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int r = in.nextInt();
            int d = in.nextInt();
            int x = in.nextInt();
            int arr[] = new int[11];
            arr[0] = x;
            for (int i = 1; i < 11; i++) {
                arr[i] = (r * arr[i - 1]) - d;
            }
            for (int i = 1; i < 11; i++)
                out.println(arr[i]);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 19668
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef pair<ll, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (ll i = 0; i < x; i++)
#define rep1(i, x) for (ll i = 1; i <= x; i++)
#define rrep(i, x) for (ll i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (ll i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const ll INF = 100000000;
const ll M = 100000000;
const ll dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const ll dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */
const ll UF_SIZE = 100010;

ll par[UF_SIZE]; // 親
ll siz[UF_SIZE]; // 木の深さ

// n要素で初期化
void init(ll n) {
    for (ll i = 0; i < n; i++) {
        par[i] = i;
        siz[i] = 1;
    }
}

// 木の根を求める
ll find(ll x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (siz[x] < siz[y]) {
        par[x] = y;
        siz[y] += siz[x];
    } else {
        par[y] = x;
        siz[x] += siz[y];
    }
}

// xとyが同じ集合に属するか否か
bool same(ll x, ll y) {
    return find(x) == find(y);
}

// xが属する集合の要素数
ll size(ll x) {
    return siz[find(x)];
}

ll n, m, a[100010], b[100010];
int main() {
    scanf("%lld%lld", &n, &m);
    rep(i, m) scanf("%lld%lld", &a[i], &b[i]);
    rep(i, m) {
        a[i]--;
        b[i]--;
    }

    init(n);
    ll rets[100010];
    rets[m] = n * (n - 1) / 2;
    rrep(i, m) {
        if (same(a[i], b[i])) {
            rets[i] = rets[i + 1];
        } else {
            rets[i] = rets[i + 1] - size(a[i]) * size(b[i]);
        }
        unite(a[i], b[i]);
    }

    rep1(i, m) {
        printf("%lld\n", rets[i]);
    }

    /* --------------------------------- */
    printf("\n");
    return 0;
}

Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int R=scan.nextInt();
		int d=0,r=0;
		if(N<=10)
		{
			d=100*(10-N);
			r=d+R;
			System.out.println(r);
		}
		else
		{
			System.out.println(R);
		}

	}

}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int X, Y; cin >> X >> Y;
  cout<<X+Y/2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,m,n;
while(cin>>m>>n){
    int x[m];
    for(i=0;i<m;i++)cin>>x[i];
    sort(x,x+m); k=x[m-1]-x[0];
    for(i=0;i<=m-n;i++){
        l=x[i+n-1]-x[i];
       if(k>l)k=l;
    }
    cout<<k<<endl;
} return 0;
}

Measured memory_bytes: 640
x, y = map(int, input().split())
val = [100000, 200000, 300000]

res = 0
if x == 1:
	res += 300000
elif x == 2:
	res += 200000
elif x == 3:
	res += 100000

if y == 1:
	res += 300000
elif y == 2:
	res += 200000
elif y == 3:
	res += 100000

if x == 1 and y == 1:
	res += 400000
	print(res)
else:
	print(res)

Measured memory_bytes: 3064
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
A=[]
B=[0,0,0,0,0]
aa=int((n-0.1)//a)+1
ba=int((n-0.1)//b)+1
ca=int((n-0.1)//c)+1
da=int((n-0.1)//d)+1
ea=int((n-0.1)//e)+1
A.extend([aa,ba,ca,da,ea])
for i in range(4):
    for j in range(i+1,5):
        if A[i]<A[j]:
            A[j]=A[j]-A[i]
        else:
            A[j]=0
ans = 5+A[0]+A[1]+A[2]+A[3]+A[4]-1
print(ans)
            

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

#define PI 3.14159265358979323846264338327950L

int main(void)
{
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);

    long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *  b) * cosl(rad);

    printf("%20.20Lf\n", sqrtl(rsq));

    return 0;
}

Measured memory_bytes: 2520
#include <iostream>
#include <cstdlib>

using namespace std;
int main(){
int a,b,c,d;
	cin >> a >> b >> c >> d ;
	if( abs(a-c) <= d || (abs(a-b) <= d && abs(b - c) <= d  ) ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

void solve(){
	ll n,m1;
	cin >> n >> m1;
	m1--;
	ll a[n];
	map<ll,v64> m;
	map<ll,ll> in;
	forn(i,n){
		cin >> a[i];
		m[a[i]].pb(i);
		in[a[i]]=0;
	}
	p64 nx[n];
	forn(i,n){
		if(in[a[i]]+1<m[a[i]].size()){
			in[a[i]]++;
			ll index = m[a[i]][in[a[i]]];
			if(index+1<n){
				nx[i]=mp(index+1,0);
			}
			else{
				nx[i]=mp(0,1);
			}
		}
		else{
			ll index = m[a[i]][0];
			if(index+1<n){
				nx[i]=mp(index+1,1);
			}
			else{
				nx[i]=mp(0,2);
			}
		}
		// cout << nx[i].fi << " " << nx[i].se << ln;
	} 
	v64 st;
	st.pb(0);
	ll in1 = 0;
	ll curin = 0;
	while(1){
		ll t=0;
		while(t!=nx[curin].se){
			st.pb(n);
			in1++;
			t++;
		}
		curin = nx[curin].fi;
		st[in1] = curin;
		if(curin==0) break;
	}
	st.pop_back();
	// forn(i,sz(st)) cout << st[i] << " ";
	// cout << ln;
	ll per = sz(st);
	m1 %= per;
	ll stin = st[m1];
	// cout << stin << ln;
	v64 vec;
	map<ll,ll> mm;
	forsn(i,stin,n){
		if(mm[a[i]]==1){
			while(vec.back()!=a[i]){
				mm[vec.back()]=0;
				vec.pop_back();
			}
			mm[vec.back()]=0;
			vec.pop_back();
		}
		else{
			vec.pb(a[i]);
			mm[a[i]]=1;
		}
	}
	forn(i,sz(vec)) cout << vec[i] << " ";
	cout << ln;
}

int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}


Measured memory_bytes: 56180
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int S,W; cin>>S>>W;
	cout<<(W>=S ? "unsafe" : "safe")<<"\n";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    vector<ll> v(n, 0);
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }
    ll nexti = 0;
    ll cnt = 0;

    for(size_t i = 0; i != 1;) {
        i = nexti;
        v[i]++;
        nexti = a[i] - 1;
        if(v[i] > 1) {
            cout << -1 << endl;
            return 0;
        }

        cnt++;
    }
    cout << cnt - 1 << endl;
}


Measured memory_bytes: 1792
s = input()

n = len(s)
amari = [0] * 2019
amari[0] += 1
tmp = 0
digit = 1
for i in range(n):
    tmp += int(s[n-i-1]) * digit
    tmp %= 2019
    amari[tmp] += 1
    digit = (digit * 10) % 2019

ans = 0
for i in amari:
    ans += i * (i - 1) // 2

print(ans)

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

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

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        string str = to_string(i);
        if (str.length() % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=2005;
int v[N];
bitset<N * N> dp;

int main(){

//	freopen("in.txt","r",stdin);

	int n,sum=0;
	scanf("%d",&n);
	for(int i=0;i < n;i++){
		scanf("%d",&v[i]);
		sum+=v[i];
	}
	sort(v,v + n);
	dp[0]=1;
	for(int i=0;i < n;i++){
		dp=(dp << v[i]) | dp;
	}
	int temp=0,mx=1e9;
	for(int i=0;i <= sum;i++){
		if(dp[i] && i >= (sum - i) && 2 * i - sum < mx){
			mx=2 * i - sum;
			temp=i;
		}
	}
	cout << temp << endl;

}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  int n,tmp;
  long long ans;
  long long min=INF,max=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(tmp<min)min=tmp;
    if(tmp>max)max=tmp;
  }
  ans=max-min;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

const int N = 300 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;
const int L = 63;

using ll = unsigned long long;

int n;
long long K;
int a[N + N], nx[N + N];
vector<int> vec[N];
ll up[N][L];

bool read() {
    if (!(cin >> n >> K))
        return false;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[n + i] = a[i];
    }

    return true;
}

void solve() {
    for (int i = 0; i < n + n; ++i)
        vec[a[i]].emplace_back(i);

    for (int i = 0; i < n; ++i) {
        nx[i] = *upper_bound(vec[a[i]].begin(), vec[a[i]].end(), i);
        up[i][0] = nx[i] - i + 1;
    }

    for (int j = 1; j < L; ++j)
        for (int i = 0; i < n; ++i) {
            ll d1 = up[i][j - 1];
            ll i1 = i + d1;
            ll d2 = up[i1 % n][j - 1];
            ll res = 0ull;

            if (d1 != 0 && d2 != 0 && !__builtin_uaddll_overflow(d1, d2, &res))
                up[i][j] = res; // pizdec spasibo blackav
            else
                up[i][j] = 0;
        }

        ll cur = 0;

        for (int j = L - 1; j >= 0; --j) {
            auto i = cur % n;
            ll res = 0ull;
            
            if (up[i][j] != 0 && !__builtin_uaddll_overflow(cur, up[i][j], &res) && res < K * n)
                cur = res;
        }

        assert(cur / n == K - 1);
        vector<int> res;

        for (int i = cur % n; i < n; )
            if (nx[i] < n) {
                i = nx[i] + 1;
            } else {
                res.emplace_back(a[i++]);
            }

        for (const auto& i : res)
            cout << i << ' ';

        cout << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 120184
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e6 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	cout << n / 3 << endl;
	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++)
int main(){
long A, c=0; string B, C=""; cin >> A >> B;
REP(i, B.size()){ if(B[i]!='.'){ C+=B[i]; } }
int l=1, m=C.size();
REP(i, m){ c+=l*(C[m-i-1]-'0'); l*=10; }
cout << A*c/100 << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

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

    int cnt[100009];
    fill_n(cnt,100009,0);
    REP(i,N){
        cnt[A[i]+1]++;
        cnt[A[i]+2]++;
        cnt[A[i]]++;
    }
    cout<<*max_element(cnt,cnt+100009)<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    ll N = input<ll>();
    ll n_odd = 0, n_even = 0;

    for (ll i = 0; i < N; i++)
    {
        ll a = input<ll>();
        if (a % 2 == 0)
        {
            n_even++;
        }
        else
        {
            n_odd++;
        }
    }
    if (n_odd % 2 != 0)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }

    return 0;
}

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

int main()
{
    int n;
    std::cin >>n;
    std::vector<char> s(1);
    std::cin >>s[0];
    for (int i = 1; i < n; i++) {
        char c;
        std::cin >>c;
        if (c != s.back())
            s.push_back(c);
    }

    std::cout << s.size() << std::endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// ?¨??????\???????????????????????????????????????
Scanner sc = new Scanner(System.in);
int w = sc.nextInt();
int n = sc.nextInt();
int blank;
int[] values = new int[w];
for (int i = 0; i < values.length; i++) {
values[i] = i + 1;
}
for (int i = 0; i < n; i++) {
String str = sc.next();
String[] ab = str.split(",");
int a = Integer.parseInt(ab[0]) - 1;
int b = Integer.parseInt(ab[1]) - 1;
blank=values[a];
values[a]=values[b];
values[b]=blank;// a??¨b????????£???values??????????????????
}
for(int i = 0; i < values.length; i++){
System.out.println(values[i]);// values??????????????????
}
}
}

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

typedef long long ll;

int main() {
    int N, K;
    ll L, R;
    cin >> N >> K >> L >> R;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    int N1 = N / 2, N2 = N - N1;
    vector<vector<ll>> v(N1 + 1);
    rep(i, 1 << N1) {
        ll s = 0;
        int k = 0;
        rep(j, N1) {
            if ((i >> j) & 1) {
                s += a[j];
                k++;
            }
        }
        v[k].push_back(s);
    }
    rep(i, N1 + 1) {
        sort(v[i].begin(), v[i].end());
    }
    ll ans = 0;
    rep(i, 1 << N2) {
        ll s = 0;
        int k = K;
        rep(j, N2) {
            if ((i >> j) & 1) {
                s += a[N1 + j];
                k--;
            }
        }
        if (k < 0 || k > N1) continue;
        ll l = lower_bound(v[k].begin(), v[k].end(), L - s) - v[k].begin();
        ll r = upper_bound(v[k].begin(), v[k].end(), R - s) - v[k].begin();
        ans += r - l;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.geom.Point2D;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Comparator;
 
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
ArrayList<Point2D> array;
while(!(line=br.readLine()).equals("0")){
int n=Integer.parseInt(line);
Point2D[] points=new Point2D[n];
for(int i=0;i<n;i++){
line=br.readLine();
String[] values=line.split(",");
points[i]=new Point2D.Double(Double.parseDouble(values[0]),Double.parseDouble(values[1]));
}
Arrays.sort(points,new Comparator<Point2D>(){
public int compare(Point2D p1,Point2D p2){
return (p1.getY()>p2.getY())?1:(p1.getY()<p2.getY())?-1:(p1.getX()>p2.getX())?1:(p1.getX()<p2.getX())?-1:0;
}
});
array=new ArrayList<Point2D>();
Point2D start=points[0];
array.add(start);
double px=start.getX();
double py=start.getY();
Point2D prev=start;
while(true){
Point2D min=null;
double minx=0;
double miny=0;
double maxcos=-1;
for(Point2D p : points){
if(p==prev){
continue;
}
double nx=p.getX()-prev.getX();
double ny=p.getY()-prev.getY();
double cos=(px*nx+py*ny)/(Math.hypot(px,py)*Math.hypot(nx,ny));
if(cos>maxcos){
maxcos=cos;
minx=nx;
miny=ny;
min=p;
}
}
if(min==start){
break;
}
px=minx;
py=miny;
prev=min;
array.add(min);
}
System.out.println(points.length-array.size());
}
}
}

Measured memory_bytes: 17000
#include <iostream>
using namespace std;
const int INF=0x3f3f3f3f;
//vector<int>v[maxn];
//map<int,string>mp[maxn];
//queue<int>q[maxn];
int n,m;
int main()
{
//	int i,j,k,ans=0;
	cin>>n>>m;
	int x,y;
	x=n*2;
	if(x>m)
		cout<<"No"<<endl;
	else
	{
		y=(m-x)/2;
		x=n-y;
		//cout<<x<<y;
		if(x*2+y*4!=m || x<0 || y<0)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	return 0;
}


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

int main(){
	string str, order, p, print_str;
	//string::iterator str_bgn = str.begin();
	int ordr_num, start, end;
	cin >> str;
	cin >> ordr_num;
	for(int i=0;i<ordr_num;i++){
		cin>>order;
		if(order == "replace"){
			cin >> start >> end >> p;
			str.erase(start, end - start + 1);
			str.insert(start, p, 0, end - start + 1);
		}else if(order == "reverse"){
			cin >> start >> end;
			reverse(str.begin()+start, str.begin()+end+1);
		}else if(order == "print"){
			cin >> start >> end;
			print_str = str.substr(start, end - start + 1);
			cout << print_str << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

bool palindrome(string &s, int l, int r) {
    while (l < r) {
        if (s[l++] != s[r--])
            return false;
    }

    return true;
}

int solve()
{
    string str;
    std::cin >> str;

    int len = str.length();

    if (palindrome(str, 0, len - 1) &&
        palindrome(str, 0, (len - 1) / 2 - 1))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(string S) {
  map<string,int> m {
    {"SUN",7},
    {"MON",6},
    {"TUE",5},
    {"WED",4},
    {"THU",3},
    {"FRI",2},
    {"SAT",1},
  };
  cout << m[S] << endl;
}

int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        if(S.charAt(S.length()-1) == 's'){
            System.out.println(S+"es");
        }else{
            System.out.println(S+"s");
        }

    }

}


Measured memory_bytes: 38432
#include <bits/stdc++.h>
using namespace std;
 
#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int> 

bool compare(const pii &a, const pii &b){
	return atan2(a.ss,a.ff) < atan2(b.ss,b.ff);
}
 
long double dis(pair<ll,ll> a, pair<ll,ll> b){
	long double x = abs(a.ff-b.ff), y = abs(a.ss-b.ss);
	return (x*x + y*y);
}
 
int main(){
	int n;
	cin >> n;
	vector <pii> v(n);
	for(int i=0;i<n;i++)	cin >> v[i].ff >> v[i].ss;
	sort(v.begin(), v.end(), compare);
	vector < pair<ll,ll> > prefix(2*n);
	prefix[0] = v[0];
	for(int i=1;i<2*n;i++)	
		prefix[i] = mp(prefix[i-1].ff+v[i%n].ff, prefix[i-1].ss+v[i%n].ss);
	long double ans = 0.0;
	for(int i=0;i<n;i++)
		for(int j=i;j<i+n;j++)
			ans = max(ans, dis(prefix[j], i>0?prefix[i-1]:mp(0LL,0LL)));
	cout << fixed << setprecision(50) << sqrt(ans) << endl;
	return 0;
}

Measured memory_bytes: 384
import math
n, l = map(int, input().split())
a_l = [l + i for i in range(n)]

min1 = 100
min2 = 10000

for j in a_l:
    if j ** 2 <= min2:
        min2 = j **2
        min1 = j
print(sum(a_l) - min1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int a,b;
    cin >> a>>b;
    cout<<a*b<<endl;
}
    



Measured memory_bytes: 3592
from collections import deque
import time, sys


H, W = map(int, input().split())
fields = [""]*(H + 2)
fields[0] = ["#"] * (W + 2)
fields[H + 1] = ["#"] * (W + 2)
sx, sy = 1, 1
gx, gy = W, H
for i in range(1, H + 1):
    fields[i] = ["#"] + list(input()) + ["#"]

    
p = deque()
p.appendleft([sx, sy])

dist = [[None] * (W + 2) for _ in range(0, H + 2)] 
dist[sy][sx] = 0
delta = [[0, 1], [1, 0], [0, -1], [-1, 0]]
while p:
    x, y = p.pop()
    
    # goal チェック
    if (x == gx) & (y == gy):
        break
    
    # 次のマスへ
    for dx, dy in delta:
        nx = x + dx
        ny = y + dy
        
        if fields[ny][nx] == "#":
            continue
        
        if dist[ny][nx] is not None:
            continue
        
        # 未踏の場合
        p.appendleft([nx, ny])
        dist[ny][nx] = dist[y][x] + 1
        
if dist[gy][gx] is None:
    print(-1)
    sys.exit()
        
# 白塗のマスを数える
white_cnt = 0

for line in fields:
    for j in line:
        if j == ".":
            white_cnt += 1

# スタートとゴールは白かつ塗れない
white_cnt = white_cnt - 2

# 必要な移動数分だけ残す
white_cnt = white_cnt - dist[gy][gx] + 1

print(white_cnt)

Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll n; cin>>n;
    ll arr[n];
    rep(i,0,n) cin>>arr[i];
    ll last=arr[n-1];
    for(ll i=n-2; i>=0; --i)
    {
        if(arr[i]>last) 
        {
            if(arr[i]-last>1) 
            {
                cout<<"No\n";
                return;
            }
            else 
            {
                arr[i]--;
            }
        }
        else last=arr[i];
    }cout<<"Yes\n";
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 4480
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

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

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

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

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

signed solve()
{
	int n;
	cin >> n;
	map<int, int> mp;
	REP(i, n)
	{
		int d;
		cin >> d;
		mp[d]++;
	}
	print(SIZE(mp));
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

//関数
bool ans2(long A,long B,long C,long D){
    
    if(A<B) return false;//最初から無理なやつ
    
    if(C<A){//補充域に入れるかチェック
    A=A%B;
    A=(C+B-A)-(C+B-A)%B-B+A;//Aとmod Bで等しいようなC以下の整数で最大のもの(補充直前)にする。
    
    if(A<0) return false;//最初から無理なやつ
    }
    
    if(B==D) return true;//補充できたならこいつは即OK
    
    if(B>D) return false;//補充できたならこいつは即OUT
    
    //0<=A<=Cから補充が始まる、B<Dなる状況を考える。
    
    if(C>=B) return true;//必ず補充域に入る。
    
    //0<=A<=Cから補充が始まる、C<B<Dなる状況を考える。→本数が昼で(C,B)に入ることと不可能が同値
    
    long d=D%B;//D足してBを引いていくと前よりどのくらい増えるか→Aからmod Bでd増やしてって(C,B)に入るとOUT
    d=__gcd(d,B);//最大公約数とって、mod dでAと同値な元が(C,B)にあるか見る。
    A=A%d;
    if((C-A)-(C-A)%d+d+A <B) return false;//Cより真に大きいmod dでAになる元がBより小さい⇔mod dでAと同値な元が(C,B)にある
    
    return true;
}
//main関数
int main() {
    
    
    //入力
        
    
    //計算
    
    
    //出力
    long T;
    cin>>T;
    
    for(int i=0;i<T;i++){
        long A,B,C,D;
        cin>>A>>B>>C>>D;
        if(ans2(A,B,C,D)){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }

}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}



fn main() {
    let a: Vec<u16> = (0..3).map(|_| read()).collect();

    let sum:u16 = a.iter().sum();

    if sum >= 22 {
        println!("bust");
    }else{
        println!("win")
    }
    
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; i++)
#define fornd(i, n) for (int i = n - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define for1d(i, n) for (int i = n; i >= 1; i--)
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> iii;

const int maxn = 100010;
int c[] = {0, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6}, n, a[11];

struct node { int cnt[11] = {0}, size = 0; };

node dp[10010];

bool grt(node a, node b) {
	if (a.size != b.size) return a.size > b.size;
	for1d(i, 9) if (a.cnt[i] != b.cnt[i]) return a.cnt[i] > b.cnt[i];
	return false;
}

void print(node a) { for1d(i, 9) while (a.cnt[i]--) cerr << i; cerr << ' '; }

int main() {
	int ndig;
	cin >> n >> ndig;
	forn(i, n) scanf("%d", &a[i]);
	for1(i, n) {
		forn(j, ndig) {
			if (i >= c[a[j]]) {
				if (dp[i - c[a[j]]].size == 0 && i - c[a[j]])
					continue;
				node tmp;
				for1(k, 9) tmp.cnt[k] = dp[i - c[a[j]]].cnt[k];
				tmp.cnt[a[j]]++; tmp.size = dp[i - c[a[j]]].size;
				tmp.size++;
				//cerr << i << ' '; print(tmp); print(dp[i]); cerr << tmp.size << ' ' << dp[i].size << endl;
				if (grt(tmp, dp[i])) {
					for1(k, 9) dp[i].cnt[k] = tmp.cnt[k];
					dp[i].size = tmp.size;
				}
			}
		}
	}
	//for1(i, n) { for1d(j, 9) while (dp[i].cnt[j]--) printf("%d", j); cerr << ' '; }
	for1d(i, 9) 
		while (dp[n].cnt[i]--) printf("%d", i);
    return 0;
}


Measured memory_bytes: 768