akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define s second 
#define f first

typedef long long ll;
using namespace std;

int main(){
	ll m, d, ans=0;
	cin>>m>>d;
	for(int i=1; i<=m; i++){
		for(int j=1; j<=d; j++){
			ll o, t;
			o=j%10;
			t=(j%100 - o)/10;
			//cout<<j<<" "<<o<<" "<<t<<endl;
			if(o>=2&&t>=2&&o*t==i)
				ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	string s;
	cin>>s;
	for(int i=0;i<(int)s.length();++i)
	{
		if((i+1)&1)
		{
			if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
		{
			if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[0]*N
rel=[]
for i in range(N):
    tmp = []
    A[i] = int(input())
    for j in range(A[i]):
        tmp.append(list(map(int,input().split())))
    rel.append(tmp)


ans = 0
for i in range(1<<N):
    cond = [0] * N
    for j in range(N):
        if 1&(i>>j):
            cond[j] = 1
    
    mujun = False
    for j in range(N):
        if cond[j] == 1:
            for k in range(A[j]):
                if cond[rel[j][k][0]-1] != rel[j][k][1]:
                    mujun = True
    
    if not mujun:
        if ans < sum(cond):
            ans = sum(cond)

print(ans)

Measured memory_bytes: 3064
// Union Find 版
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func find(parent []int, i int) int {
	if parent[i] == -1 {
		return i
	}
	parent[i] = find(parent, parent[i])
	return parent[i]
}

func unite(parent []int, i, j int) {
	i = find(parent, i)
	j = find(parent, j)
	if i == j {
		return
	}
	parent[i] = j
}

func main() {
	n := readInt()
	k := readInt()
	l := readInt()

	roads := make([]int, n)
	rails := make([]int, n)
	for i := 0; i < n; i++ {
		roads[i] = -1
		rails[i] = -1
	}

	for i := 0; i < k; i++ {
		p := readInt()
		q := readInt()
		unite(roads, p-1, q-1)
	}

	for i := 0; i < l; i++ {
		p := readInt()
		q := readInt()
		unite(rails, p-1, q-1)
	}

	d := map[int]int{}
	result := make([]int, n)
	for i := 0; i < n; i++ {
		d[2000001*find(roads, i)+find(rails, i)]++
	}

	for i := 0; i < n; i++ {
		result[i] = d[2000001*find(roads, i)+find(rails, i)]
	}

	printIntln(result...)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func printIntln(v ...int) {
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	fmt.Println(string(b))
}


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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--, Y--;

    vector<vector<int>> G(N);
    for(int i = 0; i < N - 1; ++i) {
        G[i].emplace_back(i + 1);
        G[i + 1].emplace_back(i);
    }
    G[X].emplace_back(Y);
    G[Y].emplace_back(X);

    auto bfs = [&](int s) -> vector<int> {
        vector<int> dist(G.size(), -1);
        queue<int> que;
        dist[s] = 0;
        que.push(s);
        while(!que.empty()) {
            int cur = que.front();
            que.pop();
            for(auto &to : G[cur]) {
                if(dist[to] == -1) {
                    dist[to] = dist[cur] + 1;
                    que.push(to);
                }
            }
        }
        return dist;
    };

    vector<int> cnt(N);
    for(int i = 0; i < N; ++i)
        for(auto &d : bfs(i)) cnt[d]++;

    for(int i = 1; i < N; ++i)
        cout << cnt[i] / 2 << '\n';
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  
  vector<vector<bool>> adj(n,vector<bool>(n,false));
  vector<int> v(n);
  
  for ( int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    adj.at(a).at(b) = adj.at(b).at(a) = true;
  }
  
  for ( int i = 0; i < n; i++){
    v[i] = i;
  }
  
  int ans = 0;
 
  do{
      bool ok = true;
    for(int i = 1; i < n ; i++){
      if (!adj.at(v.at(i-1)).at(v.at(i))){
        ok = false;
        break;
      }
    }
    if ( ok ) ans++;
  } while ( next_permutation(++v.begin(),v.end()));
  
  cout  << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

N = input_one_number()

f = N %10

if f == 2 or f == 4 or f == 5 or f == 7 or f == 9:
	print("hon")
elif f == 3:
	print("bon")
else:
	print("pon")


Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
using namespace std;

int solve(int n, int k, const string & s) {
    int cnt = 0;
    REP (i, n - 1) {
        if (s[i] == s[i + 1]) {
            ++ cnt;
        }
    }
    return min(n - 1, cnt + 2 * k);
}

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    cout << solve(n, k, s) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

#define SIZE 4500

int main(){
    int N;
    char S[SIZE] = {};
    scanf("%d%s", &N, S);
    long r, g, b;
    r = g = b = 0;
    for(int i=0; i<N; i++){
        switch(S[i]){
            case 'R': r++; break;
            case 'G': g++; break;
            case 'B': b++; break;
        }
    }
    long ans = r*g*b; //int r, g, b だと途中でオーバーフロー
    
    long i, p;
    for(i=0; i<N-2; i++){
        for(p=1; i+p+p<N; p++){
            if(S[i]!=S[i+p] && S[i]!=S[i+p+p] && S[i+p]!=S[i+p+p]){
                ans--;
            }
        }
    }

    printf("%ld\n", ans);
}


Measured memory_bytes: 1708
n = int(input())
arr = [int(x) for x in input().split()]
res = 1
flag = False
for i in range(n):
    if flag == False:
        res *= arr[i]
    if arr[i] == 0:
        print(0)
        exit()
    if res > 10**18:
        flag = True
if res > 10**18:
    print(-1)
else:
    print(res)


Measured memory_bytes: 21768
def main():
    n, m = map(int, input().split())

    d = [-1] * n
    for _ in range(m):
        it = map(int, input().split())
        i = next(it) - 1
        x = next(it)
        if ~d[i] and d[i] != x:  # d[i]は代入済かつcではない
            print(-1)
            return
        d[i] = x

    if n > 1 and d[0] == 0:
        print(-1)
        return

    if ~d[0]:
        print(d[0], end='')
    else:
        if n == 1:
            print(0, end='')
        else:
            print(1, end='')

    for i in range(1, n):
        if ~d[i]:
            print(d[i], end='')
        else:
            print(0, end='')


if __name__ == '__main__':
    main()


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

ll solve() {
    string S;
    cin >> S;
    auto sa = atcoder::suffix_array(S);
    auto lcp = atcoder::lcp_array(S, sa);
    ll ans = 0;
    for ( int i = 0; i < S.size(); i++ ) {
        ans += S.size() - i;
        if ( i < S.size() - 1 ) ans -= lcp[i];
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
#define dbg(x) cout<<#x<<"="<<x<<" "
#define nl cout<<"\n"

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

    }
    sum=sum+b[a[n-1]-1];
    cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n, m, col[700];
bool e[700][700], can[701][701];

pi rec(int c, int type){
	col[c] = type;
	int a = 0, b = 0;
	if(type > 0) a++;
	else b++;
	rep(i, n) if(i != c && e[c][i]){
		if(col[i] && type == col[i]){
			cout << -1 << endl;
			exit(0);
		}
		else if(!col[i]){
			pi p = rec(i, -type);
			a += p.first;
			b += p.second;
		}
	}
	return pi(a, b);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	memset(e, 1, sizeof(e));
	cin >> n >> m;
	rep(i, m){
		int a, b; cin >> a >> b; a--; b--;
		e[a][b] = e[b][a] = 0;
	}
	vector<pi> v;
	rep(i, n) if(!col[i]) v.pb(rec(i, 1));
	
	int mn = inf;
	can[0][0] = 1;
	rep(i, v.size()) rep(j, n) if(can[i][j]){
		can[i + 1][j + v[i].first] = 1;
		can[i + 1][j + v[i].second] = 1;
	}
	rep(i, n + 1) if(can[v.size()][i]){
		mn = min(mn, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	}
	cout << mn << endl;
	
	return 0;
}

Measured memory_bytes: 1280
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    base%=MOD;
    exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base)%MOD;
      base=(1LL*base*base)%MOD;
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     string s;
     cin>>n>>k;
     ll sum=0;
     // sum+=z;
     ll xterms=0;
     ll dp[k+1];
     // cout<<sum<<endl;
     for(i=1;i<=k;i++)
     {
     	ll div=k/i;
     	dp[i]=power(div,n);
     }
     for(i=k;i>=1;i--)
     {
     	for(j=2;j*i<=k;j++)
     	{
     		dp[i]-=dp[j*i];
     		dp[i]+=MOD;
     		dp[i]%=MOD;
     	}
     }
     // ll sum=0;
     for(i=1;i<=k;i++)
     {
     	// cout<<dp[i]<<endl;
     	sum+=(i*dp[i])%MOD;
     	sum%=MOD;
     }
     cout<<sum;

     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 4628
#include <cstdio>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;
typedef complex<double> P;
static const double EPS = 1e-6;
static const double PI = acos(-1.0);
namespace std {
  bool operator<(const P& a, const P& b)
  {
    if (fabs(a.real() - b.real()) < EPS) {
      return a.imag() < b.imag() - EPS;
    } else {
      return a.real() < b.real() - EPS;
    }
  }
};
inline double dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

void move_to_origin(vector<P>& ps)
{
  P p(0, 0);
  for (vector<P>::const_iterator it = ps.begin(); it != ps.end(); ++it) {
    p += *it;
  }
  p /= ps.size();
  for (vector<P>::iterator it = ps.begin(); it != ps.end(); ++it) {
    *it -= p;
  }
}

vector<P> rot(const vector<P>& ps, double theta)
{
  const P p = polar(1.0, theta);
  vector<P> ans;
  for (vector<P>::const_iterator it = ps.begin(); it != ps.end(); ++it) {
    ans.push_back(*it * p);
  }
  sort(ans.begin(), ans.end());
  return ans;
}

bool equal(const vector<P>& ps, const vector<P>& qs)
{
  const int N = ps.size();
  for (int i = 0; i < N; i++) {
    if (abs(ps[i] - qs[i]) > EPS) {
      return false;
    }
  }
  return true;
}

int main()
{
  int N;
  while (scanf("%d", &N) != EOF && N != 0) {
    vector<P> ps, qs;
    for (int i = 0; i < N; i++) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      ps.push_back(P(x, y));
    }
    for (int i = 0; i < N; i++) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      qs.push_back(P(x, y));
    }

    move_to_origin(ps);
    move_to_origin(qs);
    sort(ps.begin(), ps.end());
    const double arg0 = fmod(arg(ps[0]) + 2*PI, 2*PI);
    double ans = 100;
    for (int i = 0; i < N; i++) {
      const double theta = arg0 - fmod(arg(qs[i]) + 2*PI, 2*PI);
      const vector<P> rs = rot(qs, theta);
      if (equal(ps, rs)) {
        const double t = fabs(theta);
        ans = min(ans, min(t, 2*PI-t));
      }
    }
    printf("%.7f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 956
#include<bits/stdc++.h>
using namespace std;
int n, a[105], avg;

int main () {
    cin >> n ;
    for (int i = 1 ;i <= n ; ++i ) {
        cin >> a[i];
        avg += a[i];
    }
    avg /= n;
    int mans = numeric_limits<int>::max();
    for (int dif = -1 ; dif <= 1 ; ++ dif) {
        int b = avg + dif ;
        int ans = 0;
        for (int i = 1 ;i <= n;  ++ i) {
            ans += (a[i] - b) * (a[i] - b);
        }
        mans = min (mans, ans);
    }
    cout << mans << endl;
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int l = a + b, r = c + d;
  if(l<r)
    cout << "Right" << endl;
  if(l==r)
    cout << "Balanced" << endl;
  if(l>r)
    cout << "Left" << endl;
}

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

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}
const int MAX_K = 5050;
vector<bool> slow(int N, int K, vector<int> A) {
    vector<bool> answer(N);
    REP(i, N) {
        bool dp[MAX_K] = {};
        dp[0] = true;
        REP(x, N) if(x != i) {
            bool ndp[MAX_K] = {};
            REP(y, K+1) {
                ndp[y] = (dp[y] || (y-A[x] >= 0 && dp[y-A[x]]));
            }
            REP(y, K+1) dp[y] = ndp[y];
        }
        REP(y, K) if(dp[y] && K <= y + A[i] && y < K) {
            answer[i] = true;
        }
    }
    return answer;
}

bool ok(vector<int> A, int i, int K) {
    int N = A.size();
    bool dp[MAX_K] = {};
    dp[0] = true;
    REP(x, N) if(x != i) {
        bool ndp[MAX_K] = {};
        REP(y, K+1) {
            ndp[y] = (dp[y] || (y-A[x] >= 0 && dp[y-A[x]]));
        }
        REP(y, K+1) dp[y] = ndp[y];
    }
    REP(y, K) if(dp[y] && K <= y + A[i] && y < K) {
        return true;
    }
    return false;
}

int main(){
    iostream_init();
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    vector<int> B;
    REP(i, N) {
        if(A[i] < K) {
            B.push_back(A[i]);
        }
    }
    A = B;
    N = A.size();

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

    if(N == 0 || !ok(A, 0, K)) {
        cout << N << endl;
        return 0;
    }

    int b = 0, e = N;
    while(e - b > 1) {
        int m = (b + e) / 2;
        if(ok(A, m, K)) {
            b = m;
        } else {
            e = m;
        }
    }
    cout << N - (b+1) << endl;
    return 0;
}



Measured memory_bytes: 384
n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
c = tuple(map(int, input().split()))
l = len(c)

ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if n - 1 > i and a[i] + 1 == a[i + 1]:
        ans += c[a[i] - 1]

print(ans)


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

using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define inf 1000000000
#define sz(x) (ll)x.size()
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef  double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair< int , pii> piii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
typedef pair<ld , ld> pdd;
typedef vector<pdd> vdd;
typedef vector<ld> vd;
const int MOD = 1e9 + 7; //998244353;
int dp[100005][3];
int main() {
    boost;
    int n;
    cin >> n;
    memset(dp , sizeof dp , 0);
    vvi a(n ,vi(3));
    for(int i = 0;i<n;i++)for(int j = 0;j<3;j++)cin >> a[i][j];
    for(int i = 0;i<3;i++)dp[0][i] = a[0][i];
    for(int i = 1;i<n;i++)for(int j = 0;j<3;j++)for(int k = 0;k<3;k++){
        if(j == k)continue;
        dp[i][j] = max(dp[i][j] , dp[i-1][k] + a[i][j]);
    }
    cout << max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2]));
}


Measured memory_bytes: 9952
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    int n;
    cin >> n;
    ll a[n], b[n];
    for(int i = 0 ; i < n ; i ++ ){
        cin >> a[i] >> b[i];
        a[i] %= b[i];
    }
    ll vl = 0;
    for(int i = n - 1; i >= 0 ; i -- ){
        a[i] += vl;
        a[i] %= b[i];
        if(a[i] > 0)
            vl += b[i] - a[i];
    }
    cout << vl << "\n";
    return 0;
}

Measured memory_bytes: 1792
// to format a document: ctrl + K -> ctrl + D

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

    cout << N - K + 1 << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{   int h,w,n;
    scanf("%d %d %d",&h,&w,&n);
    int cnt=0;
    if(h<w)
    {   for(int i=0;i<n;i=i+w)
         cnt++;
    }
    if(w<h)
    {
        for(int i=0;i<n;i=i+h)
         cnt++;

    }
    if(w==h)
    {
     cnt=w;
    }
    printf("%d",cnt);


}


Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<char, int>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
                if (d.ContainsKey(s[j])) d[s[j]]++;
                else d[s[j]] = 1;
        }
        var a = new int[d.Count()];
        var p = 0;
        foreach (var x in d) a[p++] = x.Value;
        var kg = 0;
        if (h % 2 == 0) kg++;
        if (w % 2 == 0) kg++;
        bool ret;
        if (kg == 2) ret = checkGG(a);
        else if (kg == 1) ret = checkKG(h, w, a);
        else ret = checkKK(h, w, a);
        Console.WriteLine(ret ? "Yes" : "No");
    }
    public static bool checkKK(int h, int w, int[] a)
    {
        if (h == 1 && w == 1) return true;
        var c4 = 0;
        var c2 = 0;
        for (int i = 0; i < a.Length; i++)
        {
            c4 += a[i] / 4;
            a[i] %= 4;
            c2 += a[i] / 2;
            a[i] %= 2;
        }
        if (h == 1 | w == 1)
        {
            c2 += 2 * c4;
            return c2 == h / 2 + w / 2;
        }
        else
        {
            var ww = (h * w - (h + w - 1)) / 4;
            if (c4 >= ww) c2 += (c4 - ww) * 2;
            else return false;
            var ww2 = (h + w - 1) / 2;
            return c2 == ww2;
        }
    }
    public static bool checkKG(int h, int w, int[] a)
    {
        var c4 = 0;
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] % 2 == 1) return false;
            c4 += a[i] / 4;
            a[i] %= 4;
        }
        int zc4;
        if (h % 2 == 0) zc4 = (h * w - h) / 4;
        else zc4 = (h * w - w) / 4;
        return c4 >= zc4;
    }
    public static bool checkGG(int[] a)
    {
        for (int i = 0; i < a.Length; i++)
            if (a[i] % 4 != 0) return false;
        return true;
    }
}


Measured memory_bytes: 13280
def f(a):
    if a%4 == 0:
        return a
    elif a%4 == 1:
        return 1
    elif a%4 == 2:
        return a^1
    elif a%4 == 3:
        return 0
A, B = list(map(int, input().split()))
print(f(A-1)^f(B))



Measured memory_bytes: 2940
<?php
$abx = explode(' ',trim(fgets(STDIN)));
$a = $abx[0];
$b = $abx[1];
$x = $abx[2];

$num = intdiv($b,$x)-intdiv($a,$x);
echo $a%$x == 0 ? $num+1 : $num;

?>

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

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int sunuke[101]={};
  int d;
  int tmp;
  for(int i=0;i<k;i++){
    scanf("%d",&d);
    for(int j=0;j<d;j++){
      scanf("%d",&tmp);
      sunuke[tmp]=1;}}

  int sum=0;
  for(int i=1;i<=n;i++){
    if(sunuke[i]==0) sum++;}

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


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n=0,p=0,count=0,answer=0;



while(1){
cin >> n >> p;
vector<int> v(n,0);
if(n==0&&p==0)
  return 0;
  while(1){
    for(int i=0;i<n;i++){
      if(p==0){

        if(v[i]!=0){
          p+=v[i];
          v[i]=0;
          count=0;
        }else{
          count++;
        }

      }else{
        v[i]++;
        p--;
        count=0;
      }
      if(count==n-1){
      //  cout << count << endl;
        break;
      }
    }if(count==n-1){
    //  cout << count << endl;
      break;
    }


  }


  for(int i=0;i<n;i++){
    if(v[i]!=0){
      answer = i;
    }
  }

  cout<<answer<<endl;
}
}



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

int main(){
  int64_t N;
  cin >> N;
  int64_t a=2;
  int64_t num=N;
  int64_t ans=0;
  int64_t count = 0;
  int64_t now=0;
  while(num>=a*a){
    while(num%a==0){
      num = num/a;
      count++;
      if(count>now){
        ans++;
        now = count;
        count = 0;
      }
    }
    a++;
    now=0;
    count = 0;
  }
  if(num>1)
    ans++;
  
  cout << ans << endl;
}


Measured memory_bytes: 3624
n = int(input())
flg = False

if n % 7 == 0:
    flg = True
else:
    for i in range(int(n/7) + 1):
        m = n - i * 7
        if m % 4 == 0:
            flg = True
            break

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int a, b, c, sum;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> sum;
    int count = 0;

    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= c; ++k) {
                if ((i * 500 + j * 100 + k * 50) == sum) {
                    count++;
                }
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    vector<vector<int>> C(3);
    rep (i, 0, 3) {
        rep (j, 0, 3) {
            int in; cin >> in;
            C[i].push_back(in);
        }
    }

    rrep (a1, 0, 100) {
        rrep (a2, 0, 100) {
            rrep (a3, 0, 100) {
                // b1
                if (C[0][0]-a1 != C[1][0]-a2) continue;
                if (C[0][0]-a1 != C[2][0]-a3) continue;
                if (C[1][0]-a2 != C[2][0]-a3) continue;
                // b2
                if (C[0][1]-a1 != C[1][1]-a2) continue;
                if (C[0][1]-a1 != C[2][1]-a3) continue;
                if (C[1][1]-a2 != C[2][1]-a3) continue;
                // b3
                if (C[0][2]-a1 != C[1][2]-a2) continue;
                if (C[0][2]-a1 != C[2][2]-a3) continue;
                if (C[1][2]-a2 != C[2][2]-a3) continue;
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

void outPut(int Array[],char mark){
	for(int i = 1; i <= 13; i++){
		if(Array[i] == 0) printf("%c %d\n",mark,i);
	}
}

int main(){
	char mark[2];
	int n,S[14],H[14],C[14],D[14],tmp;
	for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s %d",mark,&tmp);
		switch(mark[0]){
		case 'S':
			S[tmp] = 1;
			break;
		case 'H':
			H[tmp] = 1;
			break;
		case 'C':
			C[tmp] = 1;
			break;
		case 'D':
			D[tmp] = 1;
			break;
		}
	}
	outPut(S,'S');
	outPut(H,'H');
	outPut(C,'C');
	outPut(D,'D');
}



Measured memory_bytes: 2688
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, k := scanInt(), scanInt()
	a := scanInts(n)

	s := make([]int, n+1)
	s[0] = 0
	for i := 0; i < n; i++ {
		s[i+1] = (s[i]+a[i]-1) % k
	}

	ans := 0
	c := make(map[int]int)
	for i, e := range s {
		ans += c[e]
		c[e]++

		if i-(k-1) >= 0 {
			c[s[i-k+1]]--
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 14848
n = gets.chomp.to_i
a = gets.chomp
b = gets.chomp
c = gets.chomp

ans = 0

n.times do |i|
  if a[i] == b[i] 
    if b[i] == c[i]
      next
    else
      ans += 1
    end
  else # a[i] != b[i]
    if a[i] == c[i]
      ans += 1
    elsif b[i] == c[i]
      ans += 1
    else
      ans += 2
    end
  end
end

puts ans


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int k = Integer.parseInt(ss0[0]);
		int t = Integer.parseInt(ss0[1]);

		// 1行、複数文字、Listに格納
		List<String> listStr = Arrays.asList( br.readLine().trim().split(" ", 0) );

		// 数字のListに、文字列のListを変換しながら入れる
		List<Integer> list = new ArrayList<Integer>();
		for(String s: listStr) {
			list.add( Integer.parseInt(s) );
		}


		int i = 0;
		int j = 0;

		while (list.size() > 1) {
			//リストのソート
			Collections.sort(list); // 未指定ならば昇順
			
			i = list.get(0);
			j = list.get(list.size()-1);
			if (j>=i){
				list.set(list.size()-1, j-i);
				list.remove(0);
			} else {
			}
		}

		i = list.get(0) -1;
		i = (i < 0) ? 0 : i;
		System.out.println(i);
    }
}




Measured memory_bytes: 8276
#include <bits/stdc++.h>
using namespace std;
    string repeat(string s, int n)
{
    string s1 = s;
    for (int i=1; i<n;i++)
        s += s1; 
    return s;
}
int main () {
    string s = "ACL";
    int k;
    cin >> k;
    cout << repeat(s, k) << endl;
    return 0;
}


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

using namespace std;

typedef pair<int, int> P;

map<long long, int> ids;

long long D[100100];
int N;

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i){
		scanf("%lld", D + i);
		ids[D[i]] = i;
	}
}

int sz[100100];

vector<P> ans;

vector<int> G[100100];
int dis[100100];

void dfs(int v){
	for(int i = 0; i < G[v].size(); ++i){
		int u = G[v][i];
		dis[u] = dis[v] + 1;
		dfs(u);
	}
}

bool solve(){
	for(int i = 0; i < N; ++i){
		sz[i] = 1;
	}
	sort(D, D + N);
	for(int i = N - 1; i >= 1; --i){
		int v = ids[D[i]];
		int s = sz[v];
		int dif = N - 2 * s;
		if(dif <= 0) return false;
		long long nd = D[i] - dif;
		if(ids.count(nd) == 0) return false;
		int p = ids[nd];
		G[p].push_back(v);
		sz[p] += sz[v];
		ans.push_back(P(v, p));
	}
	int root = ids[D[0]];
	dis[root] = 0;
	dfs(root);
	long long sum = 0;
	for(int i = 0; i < N; ++i){
		sum += dis[i];
	}
	if(sum != D[0]) return false;
	return true;
}

int main(){
	input();
	bool flg = solve();
	if(!flg){
		printf("-1\n");
	}else{
		for(int i = 0; i < ans.size(); ++i){
			printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
		}
	}
	return 0;
}


Measured memory_bytes: 18920
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func dump(a []int){
    for i, v := range a {
        if i > 0{
            fmt.Print(" ")
        }
        fmt.Print(v)
    }
    fmt.Println("")
}


func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    
    n := nextInt()
    a1 := nextInt()
    mini := a1
    best := -a1
    for ; n > 1; n -= 1 {
        a := nextInt()
        best = Max(best, a-mini)
        mini = Min(mini, a)
    }
    
    fmt.Println(best)
    
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }




Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <cassert>
#define int long long
using namespace std;

int getKetasu0() {
	int beet = 1, i;
	for (i = 0; ; i++) {
		cout << "? " << beet << endl;
		cout.flush();
		char latte;
		cin >> latte;
		if (latte == 'N') break;
		beet *= 10;
	}
	return i;
}

int getKetasu9() {
	int beet = 1, usi = 0, i;
	for (i = 0; ; i++) {
		usi += beet * 9;
		beet *= 10;
		cout << "? " << usi << endl;
		cout.flush();
		char latte;
		cin >> latte;
		if (latte == 'Y') break;
	}
	return i + 1;
}

signed main() {
	int p10[11], i;
	p10[0] = 1;
	for (i = 1; i < 11; i++) p10[i] = p10[i - 1] * 10;
	
	//答えが10^nの形かを判定
	cout << "? " << p10[10] << endl;
	cout.flush();
	char res;
	cin >> res;
	if (res == 'Y') {
		int ketasu = getKetasu9();
		cout << "! " << p10[ketasu - 1] << endl;
		return 0;
	}
	
	//答えは10^nの形ではない
	int ketasu = getKetasu0();
	int ans = 0;
	
	//1. 先頭桁が1かどうかを判定する
	bool sento = false;
	cout << "? " << 19999999999 << endl;
	char tokura;
	cin >> tokura;
	if (tokura == 'Y') { sento = true; }
	ans += sento;
	
	//残り桁
	for (i = sento; i < ketasu; i++) {
		int st = -1, ed = 9, mid;	//(st, ed]
		while (ed - st >= 2) {
			mid = (st + ed) / 2;
			cout << "? " << (ans * 10 + mid) * p10[10 - i] + p10[10 - i] - 1 << endl;
			cout.flush();
			char kuti;
			cin >> kuti;
			if (kuti == 'Y') ed = mid;
			else st = mid;
		}
		ans *= 10;
		ans += ed;
	}
	cout << "! " << ans << endl;
	cout.flush();
	return 0;
}

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

int main(){

    int n,m,a;
    int sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a;
        sum+=a;
    }
    if(n>=sum) cout<<n-sum<<endl;
    else cout<<-1<<endl;




    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n,m;
   cin>>n>>m;
   if(n%2!=m%2)
   {
   	cout<<"IMPOSSIBLE";
   	return 0;
   }	
   cout<<(n+m)/2;	
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int h,w,K,a[303][303];
string s[303];
void solve(){
    cin>>h>>w>>K;
    rep(i,0,h) cin>>s[i];
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#'){
                a[i][j]=K--;
            }
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(a[i][j]==0){
                rep(k,j+1,w){
                    if(a[i][k]){
                        a[i][j]=a[i][k];
                        break;
                    }
                }
            }
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(a[i][j]==0){
                for(int k=j-1;k>=0;k--){
                    if(a[i][k]){
                        a[i][j]=a[i][k];
                        break;
                    }
                }
            }
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(a[i][j]==0){
                for(int k=i-1;k>=0;k--){
                    if(a[k][j]){
                        a[i][j]=a[k][j];
                        break;
                    }
                }
            }
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(a[i][j]==0){
                rep(k,i+1,h){
                    if(a[k][j]){
                        a[i][j]=a[k][j];
                        break;
                    }
                }
            }
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }    
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt(), nQ=fs.nextInt();
		
		int[] a=fs.readArray(n);
		int[] lastSeen=new int[n+10];
		Arrays.fill(lastSeen, n);
		BIT bit=new BIT(n+100);
		
		Query[] queries=new Query[nQ];
		ArrayList<Query>[] queriesAt=new ArrayList[n];
		for (int i=0; i<n; i++) queriesAt[i]=new ArrayList<>();
		for (int qq=0; qq<nQ; qq++) {
			int l=fs.nextInt()-1, r=fs.nextInt()-1;
			Query q=new Query(l, r);
			queries[qq]=q;
			queriesAt[l].add(q);
		}
		
		for (int l=n-1; l>=0; l--) {
			bit.update(lastSeen[a[l]], -1);
			bit.update(l, 1);
			lastSeen[a[l]]=l;
			
			for (Query qq: queriesAt[l]) {
				qq.ans=bit.read(qq.r);
			}
		}
		PrintWriter out=new PrintWriter(System.out);
		for (Query qq:queries)
			out.println(qq.ans);
		out.close();
	}
	
	static class Query {
		int l, r, ans;
		public Query(int l, int r) {
			this.l=l;
			this.r=r;
		}
	}
	
	static class BIT {
		int n;
		int[] tree;
		
		public BIT(int n) {
			this.n = n;
			tree = new int[n + 2];
		}
		
		int read(int i) {
			i++;
			int sum = 0;
			while (i > 0) {
				sum += tree[i];
				i -= i & -i;
			}
			return sum;
		}
		
		void update(int i, int val) {
			i++;
			while (i <= n) {
				tree[i] += val;
				i += i & -i;
			}
		}
 
		// if the BIT is a freq array, returns the
		// index of the kth item, or n if there are fewer
		// than k items.
		int getKth(int k) {
			int e=Integer.highestOneBit(n), o=0;
			for (; e!=0; e>>=1) {
				if (e+o<=n && tree[e+o]<=k) {
					k-=tree[e+o];
					o+=e;
				}
			}
			return o;
		}
		
	}
 
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}
 
}

Measured memory_bytes: 119132
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
char num_str[1002];
int num;
long sum=0;
int i;
char tmp;
while(1){
fgets(num_str,sizeof(num_str),stdin);
if(num_str[0]=='0')
break;
for(i=0;i<strlen(num_str)-1;i++){
tmp=num_str[i];
num=atoi(&tmp);
sum+=num;
}
printf("%ld\n",sum);
sum=0;
memset(num_str,1002,0);
}
return 0;
}

Measured memory_bytes: 532
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N, M, X;
  cin >> N >> M >> X;
  int v1 = 0, v2  =0;
  for(int i=0; i<M; ++i){
    int v;
    cin >> v;
    if(v < X) v1++;
    else v2++;
  }
  int ans = min(v1, v2);
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int ASC(const int *a,const int *b){
	return (*a - *b);
}

int main(int argc, char const *argv[])
{
	int n;
	int h[100003],k[100003];
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%d",&h[i]);
		k[i] = h[i];
	}
	qsort(k,n,sizeof(int),ASC);
	for (int i = 0; i < n; ++i)
	{
		if(h[i] - 1 > k[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[n - 1] - a[0] << endl;
}

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


int main() {
    long long int n;
    cin>>n;
    list<long long int> a;
    long long int temp;
    for (long long int i = 0; i < n; i++) {
      cin >> temp;
      a.push_back(temp);
    }
    long long int ans = 1;
    temp = a.front();
    a.pop_front();
    char current = 'n';
    // can be "i" or "d"
    while(!a.empty()){
        if(current == 'n'){
            if(temp < a.front()){
                current = 'i';
            } else if(temp == a.front()){
                current = 'n';
            } else {
                current = 'd';
            }
            temp = a.front();
            a.pop_front();
        } else if(current == 'i'){
            if(temp > a.front()){
                ans += 1;
                current = 'n';
            } else {
                current = 'i';
            }
            temp = a.front();
            a.pop_front();
        } else if(current == 'd'){
            if (temp < a.front()) {
                ans += 1;
                current = 'n';
            } else {
                current = 'd';
            }
            temp = a.front();
            a.pop_front();
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)

const int N = 3005, K = 100005;
int n, a[N];
long long dp[N][N][2];
bool solved[N][N][2];

long long calc(int i, int j, bool b)
{
    if (i > j)
    {
        return 0;
    }
    
    if (solved[i][j][b])
    {
        return dp[i][j][b];
    }
    
    if (b == 0)
    {
        dp[i][j][b] = max(a[i] + calc(i + 1, j, 1), a[j] + calc(i, j - 1, 1));
    }
    else
    {
        dp[i][j][b] = min(-a[i] + calc(i + 1, j, 0), -a[j] + calc(i, j - 1, 0));
    }
    
    solved[i][j][b] = 1;
    return dp[i][j][b];
}

int main()
{
    FaSt
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    cout << calc(0, n - 1, 0);
}


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

int main() {
	
	int X;
	cin >>X;
	
	if(X==7||X==5||X==3){
		
		cout <<"YES" <<endl;
		
	}
	else{
		
		cout <<"NO" <<endl;
		
	}
	
}

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

using namespace std;
typedef long long ll;

int main(){
	int m, k, a[102] = {0}, tmp;
	cin >> m >> k;
	for(int i = 0; i<k;i++){
		cin >> tmp;
		a[tmp] = 1;
	} 
	for(int i = 0; i<=100; i++){
			if(a[m-i] == 1){
				;
			}
			else if(a[m-i] != 1){
				cout << m-i;
				break;
			}
			if(a[m+i] == 1){
				;
			}
			else if(a[m+i] != 1){
				cout << m+i;
				break;
			}
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;

i64 modpow(i64 a, i64 n, i64 mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        i64 t = modpow(a, n / 2, mod);
        return t * t % mod;
    }
    return a * modpow(a, n - 1, mod) % mod;
}

i64 modinv(i64 a, i64 mod) {
    // mod is prime
    return modpow(a, mod - 2, mod);
}

struct Combination {
    const int MAX_N = 1 << 21;
    vi fact = vi(MAX_N);
    vi factinv = vi(MAX_N);

    Combination() {
        fact[0] = 1;
        for (int i = 1; i < MAX_N; i++) {
            fact[i] = fact[i - 1] * i % MOD;
        }
        factinv[MAX_N - 1] = modinv(fact[MAX_N - 1], MOD);
        for (int i = MAX_N - 2; i >= 0; i--) {
            factinv[i] = factinv[i + 1] * (i + 1) % MOD;
        }
    }

    i64 ncr(i64 n, i64 r) {
        if (r < 0 || r > n) return 0;
        return fact[n] * factinv[r] % MOD * factinv[n - r] % MOD;
    }

    i64 npr(i64 n, i64 r) {
        if (r < 0 || r > n) return 0;
        return fact[n] * factinv[n - r] % MOD;
    }

    i64 nhr(i64 n, i64 r) {
        if (n == 0 && r == 0) return 1;
        return ncr(n + r - 1, r);
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    if (n > k) {
        cout << 0 << endl;
        return 0;
    }
    Combination comb;
    cout << comb.ncr(k, n) << endl;
}


Measured memory_bytes: 35548
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
 
int main() {
  long long int L, R;
  cin >> L >> R;
  
  R = min(R, L+4038);
  
  long long int result = INF;
  for (long long int i=L; i<R; i++) {
    for (long long int j=i+1; j<=R; j++) {
      result = min((i * j) % 2019, result);
    }
  }
  
  cout << result << endl;
  
  return 0;
}

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

using namespace std;

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl

const int maxn = (int)3e5+5;
typedef long long ll;
int x, n;
int a[110];
bool isValid(int val){
   for(int i=0 ; i<n ; i++){
      if(a[i]==val){
         return true;
      }
   }
   return false;
}

void solve(){

   cin >> x >> n;
   int res = 200;
   for(int i=0; i<n ; i++) cin >> a[i];

   if(n==0) {
      cout << x << endl;
      return;
   }

   int point = 0 ;

   for(int i=0 ; i<=101 ; i++){
      if(isValid(i)) continue;

      int dif = abs(x-i);
      if(dif<res){
         res = dif;
         point = i;
      }
   }

   cout << point << endl;
}


int main()
{
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //cout << "Fi Amanillah" << endl;

    int t=1;
    //cin >> t;
    while(t--){
      solve();
    }


    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略

int main(){
  string s, t;
  cin >> s >> t;
  string ans = "Yes";
  for(int i = 0; i < t.size()-1; i++){
  	if(t[i] != s[i]){
      ans = "No";
  	}
  }
  cout << ans;
}

Measured memory_bytes: 3592