akhauriyash/Code-Regression huggingface dataset:
from collections import deque
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))

def cal_dist(sx, sy):
    # スタートからの距離を格納
    x_max, y_max = h, w
    dist = [[float('inf')] * w for _ in range(h)]

    # キューを作成
    que = deque([])
    que.append((sx, sy))
    dist[sx][sy] = 0

    # ゴールにたどり着くまで探索
    dist_max = 0
    while len(que) > 0:
        x, y = que.popleft()

        dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]
        for i in range(0, 4):
            nx, ny = x + dx[i], y + dy[i]
            if 0 <= nx < x_max and 0 <= ny < y_max and \
               s[nx][ny] != '#' and dist[nx][ny] == float('inf'):
                que.append((nx, ny))
                dist[nx][ny] = dist[x][y] + 1
                dist_max = max(dist[nx][ny], dist_max)

    return dist_max

dist_max = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        dist = cal_dist(i, j)
        if dist == float('inf'):
            continue
        dist_max = max(dist, dist_max)
print(dist_max)

Measured memory_bytes: 49644
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,x;
  cin>>a>>b>>x;

  long long start = a;
  if(a%x!=0)start+=(x-a%x);
  
  long long end = b;
  if(b%x!=0)end-=b%x;
  
  if(end<start)cout<<0;
  else{
  	//end = start+(n-1)*x
    //(end-start)/x+1=n
    cout<<(end-start)/x+1;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B;
    int C,D,E;
    scanf("%d%d",&A,&B);
    C=A+B;
    D=A-B;
    E=A*B;

    if(C>=D&&C>=E)
    {
        printf("%d",C);
    }
    else if(D>=C && D>=E)
    {
        printf("%d",D);
    }
    else if(E>=C&&E>=D)
    {
        printf("%d",E);
    }
    else if(C==0&&D==0&&E==0)
    {
        printf("0");
    }


    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(){
  int n,r,a[100];
  double min=1e9,ave=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    ave+=a[i];
  }
  ave/=n;
  for(int i=0;i<n;i++){
    if(fabs(ave-a[i])<min){
      r=i;
      min=fabs(ave-a[i]);
    }
  }
  printf("%d",r);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int N;
  scanf("%d",&N);
  if(N>0&&N<10)
  {
    printf("%d",N);
  }
  else if(N>=10&&N<100)
  {
    printf("9");
  }
  else if(N>=100&&N<1000)
  {
    printf("%d",(N-99)+9);
  }
  else if(N>=1000&&N<10000)
  {
    printf("909");
  }
  else if(N>=10000&&N<100000)
  {
    printf("%d",(N-9999)+909);
  }
  else
  {
    printf("90909");
  }
}

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

using namespace std;

#define ll long long
#define Coming ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0); 
#define endl "\n"

int main()
{
	Coming 
	
	ll n, arr[100005];
	
	cin >> n;
	
	ll sum = 0, coun = 0;
	
	for(ll i = 1; i <= n; i++)
	{
	    cin >> arr[i];
	    
	    if(arr[i] < 0)
	    {
			coun++;
			arr[i] *= -1;
		}
		
		sum += arr[i];
	}
	
	sort(arr, arr+n+1);
	
	if(coun % 2) sum -= 2 * (arr[1]);
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			int n = sc.nextInt();

			int count = 0;

			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					for (int k = 0; k < 10; k++) {
						for (int l = 0; l < 10; l++) {
							if (n == i + j + k + l) {
								count++;
							}
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, a, b, k);
  for (int i = a; i <= b;) {
    wt(i);
    ++i;
    if (i > b) break;
    if (b - i < k) continue;
    if (i - a >= k) i = b - k + 1;
  }
}


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

vector<vector<int>> board;
int H;


int solve(){
    int res = 0, look = 0, cnt = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<3; j++){
            look = board[i][j];
            cnt = 1;
            for(int k = j+1; k<5; k++){
                if(board[i][j] == board[i][k]) cnt++;
                else break;
            }
            if(cnt >= 3){
                res += look * cnt;
                for(int k=j, count=0; count < cnt; k++, count++){
                    board[i][k] = 0;
                }
                break;
            }
        }
    }
    return res;
}

void dump(){
    for(int i=H-1; i>-1; i--){
        for(int j=0; j<5; j++) {
            if(board[i][j] == 0) {
                for(int k=i-1; k>-1; k--) {
                    if(board[k][j] != 0){
                        board[i][j] = board[k][j];
                        board[k][j] = 0;
                        break;
                    }
                }
            }
        }
    }
}

int main(){
    int res,tmp;
    while(true){
        cin >> H;
        if(H==0) break;
        res = 0;
        board = vector<vector<int>>(H, vector<int>(5));
        for(int i = 0; i<H; i++){
            cin >> board[i][0] >> board[i][1] >> board[i][2] >> board[i][3] >> board[i][4];
        }

        while(true){
            tmp = solve();
            res += tmp;
            dump();
            if(tmp == 0) break;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3080
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 200005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;


#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int



bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }



int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

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


    ll total = 0;
        
    for(ll i = k; i <= n+1; i++)
    {
        ll ans = (n*(n+1))/2 - ((n-i)*(n-i+1))/2 - (i*(i-1))/2 + 1;
        total = (mod+(total + ans)%mod)%mod;
    }    

    cout<<total%mod;










    return 0;
}

Measured memory_bytes: 3624
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	ll n;
	cin >> n;
	if (n >= 30)
		cout << "Yes\n";
	else
		cout << "No\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S;
  cin >> S;
  int N = S.length() + 1;
  VEC<int> A(N, 0);
  int i = 0;
  while (i < N - 1) {
    while (S[i] == '<') {
      A[i + 1] = A[i] + 1;
      i++;
    }
    // DUMP(i, A);
    int j = i;
    while (S[j] == '>') {
      j++;
    }
    int m = j - i;
    REP(k, 0, m) { A[j - k] =  k; }
    A[i] = max(A[i], j - i);
    // DUMP(i, j, A);
    i = j;
  }
  // DUMP(A);
  LL sum = 0;
  // int base = (A[N - 1] < 0 ? abs(A[N - 1]) : 0);
  // A[N - 1] += base;
  // VEC<int> B(A);
  // for (int i = N - 2; i >= 0; i--) {
  //   if (base == 0) {
  //     if (A[i] < 0) {
  //       base = abs(A[i]);
  //       A[i] += base;
  //     }
  //   } else {
  //     if (S[i] == '>') {
  //       A[i] += base;
  //     } else {
  //       base = 0;
  //     }
  //   }
  // }
  REP(i, 0, N) sum += A[i];
  // DUMP(A);
  cout << sum << endl;

  return 0;
}


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


int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri(), m = ri(), p = ri();
	int a[m], b[m], c[m];
	std::vector<std::pair<int, int> > hen[n];
	for (int i = 0; i < m; i++) {
		a[i] = ri() - 1;
		b[i] = ri() - 1;
		c[i] = ri() - p;
		hen[b[i]].push_back({a[i], c[i]});
	}
	std::vector<int> score(n, -1000000000);
	score[0] = 0;
	for (int i = 0; i + 1 < n; i++) {
		for (int j = 0; j < m; j++) {
			if (score[a[j]] == -1000000000) continue;
			score[b[j]] = std::max(score[b[j]], score[a[j]] + c[j]);
		}
	}
	std::vector<bool> reachable(n);
	std::queue<int> que;
	que.push(n - 1);
	reachable[n - 1] = true;
	while (que.size()) {
		int cur = que.front();
		que.pop();
		for (auto &i : hen[cur]) if (!reachable[i.first]) reachable[i.first] = true, que.push(i.first);
	}
	for (int j = 0; j < m; j++) {
		if (score[a[j]] == -1000000000) continue;
		if (score[b[j]] < score[a[j]] + c[j] && reachable[a[j]]) {
			std::cout << -1 << std::endl;
			return 0;
		}
	}
	std::cout << std::max(0, score[n - 1]) << std::endl;
	
	return 0;
}


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

int H, W, N;
int ix, iy;
string S, T;

bool solve() {
    // left, right
    int left = 0, right = W;
    if (S[N-1] == 'L') ++left;
    if (S[N-1] == 'R') --right;
    for (int i = N-2; i >= 0; --i) {
        if (T[i] == 'L') right = min(right+1, W);
        else if (T[i] == 'R') left = max(0, left-1);
        if (S[i] == 'L') left = left + 1;
        else if (S[i] == 'R') right = right - 1;
        if (left >= right) return false;
    }
    if (iy < left || iy >= right) return false; 

    // up, down
    left = 0, right = H;
    if (S[N-1] == 'U') ++left;
    if (S[N-1] == 'D') --right;
    for (int i = N-2; i >= 0; --i) {
        if (T[i] == 'U') right = min(right+1, H);
        else if (T[i] == 'D') left = max(0, left-1);
        if (S[i] == 'U') left = left + 1;
        else if (S[i] == 'D') right = right - 1; 
        if (left >= right) return false;
    }
    if (ix < left || ix >= right) return false;

    return true;
}

int main() {
    while (cin >> H >> W >> N >> ix >> iy >> S >> T) {
        --ix, --iy;
        if (solve()) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 776
import itertools
import numpy as np

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=N):
    tmp = np.sum(items[np.where(c)], axis=0)
    if np.any(tmp):
      if M == np.count_nonzero(tmp[1:] >= X):
        out = min(out, tmp[0])
if out == 10**18:
  print(-1)
else:
  print(out) 

Measured memory_bytes: 27388
while 1:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65 or 30 <= m + f < 50 <= r:
        print('C')
    elif 30 <= m + f < 50:
        print('D')
    else:
        print('F')

Measured memory_bytes: 6720
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, X: int, x: "List[int]"):
    return reduce(gcd, [abs(X - xx) for xx in x])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, X, x)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21440
N, M = map(int, input().split())
ACed = [0] * (N + 1)
WAed = [0] * (N + 1)
WA_count = 0
AC_count = 0
WA_sum = 0

for i in range(M):
    p, s = input().split()
    p = int(p)

    if s == 'WA':
        WAed[p] += 1

    if s == 'AC' and ACed[p] == 0:
        ACed[p] = 1
        AC_count += 1
        WA_sum += WAed[p]

print(AC_count, WA_sum)


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

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

    int A;
    int B;
    cin >> A;
    cin >> B;
    int array[3];
    array[0] = 1;
    array[1] = 2;
    array[2] = 3;
    int result;
    for(int i=0; i<3;i++) {
        if ((array[i]!=A) && (array[i]!=B)) {
            result=array[i];
        }
        else{
            continue;
        }
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define mp(x,y) make_pair((x),(y))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int mod=1000000007;
int n,k,f[4005][2005],fac[16000005],ifc[16000005];
inline void inc(int& x,int y){x=x+y<mod?x+y:x+y-mod;}
inline void dec(int& x,int y){x=x-y>=0?x-y:x-y+mod;}
inline int power(int b,int n){int ans=1;for(;n;n>>=1,b=1ll*b*b%mod)if(n&1)ans=1ll*ans*b%mod;return ans;}
inline int C(int n,int m){return (n<0||m<0||n<m)?0:1ll*fac[n]*ifc[m]%mod*ifc[n-m]%mod;}

int main(){
	// freopen("in.in","r",stdin);
	n=read(),k=read();
	REP(i,fac[0]=1,16000001)fac[i]=1ll*fac[i-1]*i%mod;
	ifc[16000001]=power(fac[16000001],mod-2);
	DREP(i,16000001,1)ifc[i-1]=1ll*ifc[i]*i%mod;
	if(k==1)return puts("1"),0;
	f[0][0]=1;
	REP(i,0,n+n-1)REP(j,0,i>>1)if(f[i][j]){
		if(i-j>j)inc(f[i+1][j+1],f[i][j]);
		int num=(i-j)*(k-1)+j+1;
		inc(f[i+1][j],1ll*(n-i+j)*f[i][j]%mod*C(k-2+num-1,num-1)%mod);
	}
	printf("%d\n",f[n+n][n]);
	return 0;
}


Measured memory_bytes: 156288
using System;

namespace ABC064A
{
    class Program
    {
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            string a = input[0];
            string b = input[1];
            string c = input[2];
            int product = int.Parse(a + b + c);

            if (product % 4 == 0)
            {
                Console.Write("YES");
            }
            else
            {
                Console.Write("NO");
            }
        }
    }
}


Measured memory_bytes: 13140
import sys
l, r = map(int, input().split())
mod = 0
tmp = 0

for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = (i*j % 2019)
        if (i == l and j == l+1) or tmp < mod:
            mod = tmp
            if mod == 0:
                print(mod)
                sys.exit()
print(mod)

Measured memory_bytes: 3060
N = int(input())
H = list(map(int, input().split()))
Flag = True
for i in reversed(range(1,N)):
    if H[i-1] - H[i] >= 2:
        Flag = False
        break
    elif H[i-1] - H[i] == 1:
        H[i-1] = H[i]
    
if Flag:
    print("Yes")
else:
    print("No")
    



Measured memory_bytes: 14396
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		int[] gap = new int[n-k+1];
		for(int i = 0; i < n-k+1; i++) {
			gap[i] = h[i+k-1] - h[i];
		}
		Arrays.sort(gap);
		System.out.println(gap[0]);
	}

}

Measured memory_bytes: 50452
#include<bits/stdc++.h>
#define INF 10000000
#define NIL -1
#define BLACK 2
#define WHITE 0
#define GRAY 1
#define MAX 100
using namespace std;

int color[MAX]={},d[MAX]={},pi[MAX]={},n;

void initializeSingleSource(int w[MAX][MAX]){
    for(int v=0;v<n;v++){
        d[v]=INF;
        pi[v]=NIL;
    }
    d[0]=0;
}

void relax(int u,int v,int w[MAX][MAX]){
    if(d[v]>d[u]+w[u][v]){
        d[v]=d[u]+w[u][v];
        pi[v]=u;
    }
}

void dijkstra(int w[MAX][MAX]){
    int mincost,i,v,u;
    initializeSingleSource(w);
    while(1){
        mincost=INF;
        u=NIL;
        for(i=0;i<n;i++){
            if(color[i]!=BLACK&&d[i]<mincost){
                mincost=d[i];
                u=i;
            }
        }
        if(u==NIL)break;
        color[u]=BLACK;
        for(v=0;v<n;v++){
            if(color[v]!=BLACK&&d[u]+w[u][v]<d[v]){
                pi[v]=u;
                d[v]=d[u]+w[u][v];
                color[v]=GRAY;
            }
        }
    }
}

void prim(int w[MAX][MAX]){
    int u,i,v,mincost,j;
    for(u=0;u<n;u++){
        d[u]=INF;
        pi[u]=NIL;
        color[u]=WHITE;
    }
    d[0]=0;
    while(1){
        mincost = INF;
        u=-1;
        for(i=0;i<n;i++){
            if(color[i]!=BLACK&&d[i]<mincost){
                mincost=d[i];
                u=i;
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(v=0;v<n;v++){
            if(color[v]!=BLACK&&w[u][v]!=INF){
                if(d[v]>w[u][v]){
                    pi[v]=u;
                    d[v]=w[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(i=0;i<n;i++){
        if(pi[i]!=NIL)sum+=w[i][pi[i]];
    }

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            cout<<w[i][j]<<" ";
        }
        cout<<endl;
    }

    cout<<endl;

    for(i=0;i<n;i++){
        cout<<pi[i]<<" ";
    }
    cout<<endl;
}

int main(){
    int w[MAX][MAX],i,j,id,k,weight,gow,ans;
    cin>>n;
    for(i=0;i<MAX;i++){
        for(j=0;j<MAX;j++){
            w[i][j]=INF;
        }
    }
    for(i=0;i<n;i++){
        cin>>id>>k;
        for(j=0;j<k;j++){
            cin>>gow>>weight;
            w[id][gow]=weight;
        }
    }
    dijkstra(w);
    for(i=0;i<n;i++){
        cout<<i<<" "<<d[i]<<endl;
    }
}


Measured memory_bytes: 3144
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

ll floor_sum(ll n,ll m,ll a,ll b){
  ll ans=0;
  if(a>=m){
    ans+=(n-1)*n*(a/m)/2;
    a%=m;
  }
  if(b>=m){
    ans+=n*(b/m);
    b%=m;
  }

  ll y_max=(a*n+b)/m;
  if(y_max==0) return ans;
  ans+=floor_sum(y_max,a,m,a*n-y_max*m+b);
  return ans;
}

int main(){
  int t;
  cin>>t;
  
  rep(i,t){
    int n,m,a,b;
    cin>>n>>m>>a>>b;
  
    cout<<floor_sum(n,m,a,b)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3588
import math

A,B,H,M = map(int,input().split())

short_tick = {"x":0,"y":0}
long_tick = {"x":0,"y":0}

short_deg = 0
if (H >= 12) :
    H -= 12
short_deg = H * 30 + M * 0.5
long_deg = M * 6

short_tick["x"] = A * math.cos(math.radians(short_deg))
short_tick["y"] = A * math.sin(math.radians(short_deg))

long_tick["x"] = B * math.cos(math.radians(long_deg))
long_tick["y"] = B * math.sin(math.radians(long_deg))

# print("ld", long_deg, "sd", short_deg)
# print("lt", long_tick, "st", short_tick)

d = pow(long_tick["x"] - short_tick["x"],2) + pow(long_tick["y"] - short_tick["y"],2)
distance = math.sqrt(d)

print(distance)

Measured memory_bytes: 9616
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();++i)
		if(s[i]=='9')
		{
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
	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);
		int inLength;
		inLength = sc.nextInt();
		
		long[] input = new long[inLength];
		for(int i =0 ; i < inLength;i++) {
			input[i] = sc.nextInt();
		}
		int result = 0;
		boolean flg = false;
		while(flg == false) {
			for(int j =0 ; j < inLength;j++) {
				if(input[j] % 2 == 1) {
					flg = true;
					break;
				}
				input[j] = input[j] / 2;
				if(input[j] == 0) {
					flg = true;
				}
				
			}
			if(flg == false) {
				result++;
			}
		}
		
		System.out.println(result);

	}

}

Measured memory_bytes: 21972
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	static boolean debug = true;
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String str=sc.nextLine();
		int[] map=new int[3];
		for(char c:str.toCharArray()){
			if(c=='a') map[0]++;
			else if(c=='b') map[1]++;
			else map[2]++;
		}
		int max=Math.max(map[0],Math.max(map[1], map[2]));
		int min=Math.min(map[0],Math.min(map[1], map[2]));
		if(max-min<2)
			System.out.println("YES");
		else
			System.out.println("NO");
			
	}

}

Measured memory_bytes: 26312
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

# print count
def solve(count, hpList):
	q = hpList - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(m, ll):
		r = m
	else:
		l = m

if r == 2:
	if solve(1, ll):
		r = 1

print r

Measured memory_bytes: 18580
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int H,W;
vector<vector<char> > s;
int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};
bool isCanGrid(int i, int j){
  if(s[i][j] == '#'){
    int n;REP(n,4){
      if(i+dx[n]<0 || i+dx[n]>=H
          || j+dy[n]<0 || j+dy[n]>=W)continue;
      if(s[i+dx[n]][j+dy[n]] == '#') return true;
    }
    return false;
  }else return true;
}

int main(void){
  cin >> H >> W;
  int i,j;
  s.resize(H,vector<char>(W));
  REP(i,H)REP(j,W) cin >> s[i][j];
  bool isSucc = true;
  REP(i,H)REP(j,W){
    if(!isCanGrid(i,j)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
N,C=map(int,input().split())

Dmat=[]
for i in range(C):
  array=list(map(int,input().split()))
  Dmat.append(array)
#print(Dmat)

cmat=[]
for i in range(N):
  array=list(map(int,input().split()))
  cmat.append(array)
#print(cmat)
grid_list=[{},{},{}]
for i in range(N):
  for j in range(N):
    c=cmat[i][j]-1
    mod=(i+j)%3
    if c in grid_list[mod]:
      grid_list[mod][c]+=1
    else:
      grid_list[mod][c]=1
#print(grid_list)

min_cost=10**9
for i in range(C):
  for j in range(C):
    if i==j:
      continue
      
    for k in range(C):
      if i==k or j==k:
        continue
          
      cost=0 
      for c in grid_list[0]:
        num=grid_list[0][c]
        cost+=Dmat[c][i]*num
      for c in grid_list[1]:
        num=grid_list[1][c]
        cost+=Dmat[c][j]*num
      for c in grid_list[2]:
        num=grid_list[2][c]
        cost+=Dmat[c][k]*num
          
      if cost<min_cost:
        #print(i,j,k,cost)
        min_cost=cost
          
print(min_cost)

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000003
#define mod(mod_x) (((long long)mod_x)%modulo)

//aのb乗
int beki(int a,int b){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=mod(x*a);
		}
		a=mod(a*a);
		b>>=1;
	}
	return x;
}

//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	void kaijou_set(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		/*
		int a = kaijou[n];int b = 1;int m = modulo-2;
		while(m!=0){
			if(m%2){
				b=mod(b*a);
			}
			a=mod(a*a);
			m/=2;
		}
		*/
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
};

int main(){
	
	int Q;
	cin>>Q;
	
	combi c;
	c.kaijou_set(modulo-1);
	
	for(int i=0;i<Q;i++){
		long long x,d,n;
		cin>>x>>d>>n;
		
		if(d==0){
			cout<<beki(x,n)<<endl;
			continue;
		}
		x = mod(x*gyakugen(d));
		if(x/modulo!=(x+n-1)/modulo){
			cout<<0<<endl;
			continue;
		}
		x = mod(c.kaijou[x+n-1]*c.kaijou_[x-1]);
		x=mod(x*beki(d,n));
		cout<<x<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 9088
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void prim() {
    int u, min_value;
    int d[MAX], color[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0]=GRAY;
    while (true) {
        min_value = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (min_value > d[i] && color[i] != BLACK) {
                u = i;
                min_value = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > d[u]+M[u][v]) {
                    d[v] = d[u]+M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY?-1:d[i]) << endl;
    };
}

int main() {
    int k,l,u,v;
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }
    for (int i=0;i<n;i++){
        cin >> u >> k;
        for(int j=0;j<k;j++){
            cin >> v >> l;
            M[u][v]=l;
        }
    }
    prim();
    return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000007
#define endl "\n"
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;

int main()
{
  string S;
  cin >> S;
  string numS;

  string ch;
  
  

  REP(i,10)
    {
      numS = "";

      ch = to_string(i);
      

      REP( j , SIZ(S) )
	{
	  numS += ch ;
	  
	}

      if( S <= numS )
	{
	  break;
	  
	}
      
      
    }

  cout << numS << endl;
  
  
}


Measured memory_bytes: 256
///https://atcoder.jp/contests/arc059/tasks/arc059_b
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main()
{
    fastio;
    string str;
    cin>>str;

    for(int i=0; i<str.size(); i++){
        if(str[i]==str[i+1]){
            cout<<i+1<<" "<<i+2;
            return 0;
        }
        else if(str[i]==str[i+2]){
            cout<<i+1<<" "<<i+3;
            return 0;
        }
    }
    cout<<"-1"<<" "<<"-1";

    return 0;
}




Measured memory_bytes: 3752
S = input()
T = input()
ns = len(S)
nt = len(T)
if ns - nt < 0:
    print('UNRESTORABLE')
    exit()
answer = []
for i in range(ns - nt + 1):
    ans = ''
    t = True
    for j in range(ns):
        if j < i:
            if S[j] == "?":
                ans = ans + 'a'
            else:
                ans = ans + S[j]
        elif j - i >= nt:
            if S[j] == "?":
                ans = ans + 'a'
            else:
                ans = ans + S[j]

        else:
            if S[j] == "?":
                ans = ans + T[j-i]
            else:
                if S[j] == T[j-i]:
                    ans = ans + T[j-i]
                else:
                    t = False
                    break
    if t:
        answer.append(ans)

if len(answer) == 0:
    print('UNRESTORABLE')
else:
    answer.sort()
    print(answer[0])

Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,sum=1,p=1,l=1000000000000000000LL;
  int a[10000000];
  bool f=true,k=false;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum*=a[i];
    if(sum>l||sum<p){
      f=false;
    }
    if(a[i]==0) k=true;
    p=sum;
  }
  if(f||k) cout<<sum<<"\n";
  else cout<<"-1\n";
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();

  vector<pair<int, int>> v(n);
  for (auto &i : v) cin >> i;

  sort(v.rbegin(), v.rend());

  cout << v[0].first + v[0].second << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Q = sc.nextInt();
    String S = sc.next();
    int[] l = new int[Q];
    int[] r = new int[Q];
    for (int i = 0; i < Q; i++) {
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }
    Main abc122C = new Main();
    abc122C.solve(S, N, Q, l, r);
  }

  public void solve(String S, int N, int Q, int[] l, int[] r) {
    int[] dp = new int[N];
    for (int i = 0; i < N - 1; i++) {
      if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
        dp[i + 1] = dp[i] + 1;
      } else {
        dp[i + 1] = dp[i];
      }
    }
    for (int i = 0; i < Q; i++) {
      System.out.println(dp[r[i]-1] - dp[l[i]-1]);
    }
  }
}


Measured memory_bytes: 77760
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N, R;
    cin >> N >> R;
    cout << R + 100 * max(0, 10 - N) << endl;
}


Measured memory_bytes: 256
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
#define MAX 200005
int main()
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll count=0;
	for (int i = l; i <=r ; ++i)
	{
		if(i%d==0)
			count++;
	}
	cout<<count<<endl;
}






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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N; cin >> N;
    long long max = 0;
    long long tmp;
    for(int i = 0;i < N;i++){
        cin >> tmp;
        if(tmp > max) max = tmp;
        else{
            if((max - tmp) >= 2){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
n, a, b = gets.chomp.split(" ").map(&:to_i)

total = 0
(1..n).each do |v|
  ary = v.to_s.split("").map(&:to_i)
  
  sum = 0
  ary.each do |e|
    sum += e
  end
  
  if a <= sum && sum <= b
    total += v
  end
end

p total

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

using namespace std;

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

	int tcnt = 0, scnt = 0;
	for(int i = 0; i < (int)X.size(); ++i)
	{
		if(X[i] == 'S')
		{
			++scnt;
		}	
		else
		{
			++tcnt;
			if(scnt > 0)
				--scnt, --tcnt;
		}
	}
	
	cout << tcnt + scnt << endl;
	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n;
  cin >> n;

  string ans;

  while(n > 0){

    n--;
    ans += char('a' + int(n % 26));
    n /= 26;

  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 3620
n,k=map(int,input().split())
if n%2==0:
    if (2+k-1)+(n//2*3+k-1)>2*n+1+k-1:
        print(-1)
    else:
        cc=3*n
        bb=3*n//2+1
        for aa in range(n-1,0,-2):
            print(aa+k-1,bb+k-1,cc+k-1)
            bb+=1
            cc-=1
        bb=n+1
        for aa in range(n,0,-2):
            print(aa+k-1,bb+k-1,cc+k-1)
            bb+=1
            cc-=1
else:
    if (2+k-1)+((n*3-1)//2+k-1)>2*n+1+k-1:
        print(-1)
    else:
        cc=3*n
        bb=(3*n+1)//2
        for aa in range(n,0,-2):
            print(aa+k-1,bb+k-1,cc+k-1)
            bb+=1
            cc-=1
        bb=n+1
        for aa in range(n-1,0,-2):
            print(aa+k-1,bb+k-1,cc+k-1)
            bb+=1
            cc-=1

Measured memory_bytes: 50136
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  ll n; cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  reverse(a,a+n);
  ll ans = a[0];
  for(int i = 1; i <= (n-2)/2; i++){
    ans += a[i] * 2;
  }
  if(n%2 == 1){
    ans += a[int((n-2)/2)+1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5204
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = IR(5)
    k = I()
    if max(s)-min(s) > k:
        print(":(")
    else:
        print("Yay!")
    return

#B
def B():
    n = I()
    return

#C
def C():
    n = I()
    return

#D
def D():
    n = I()
    return

#Solve
if __name__ == "__main__":
    A()


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

struct UnionFind {
	vector<int> parent, size;

	UnionFind(int n) : parent(n), size(n, 1) {
		for (int i = 0; i < n; i++) {
			parent[i] = i;
		}
	}

	int operator[](int x) {
		if (parent[x] == x) return x;
		return parent[x] = operator[](parent[x]);
	}

	bool merge(int x, int y) {
		x = operator[](x);
		y = operator[](y);
		if (x == y) return false;
		if (size[x] < size[y]) swap(x, y);
		parent[y] = x;
		size[x] += size[y];
		return true;
	}
};

vector<int> build_suffix_array(string s) {
	int n = s.size();

	vector<int> sa(n + 1), rank(2 * n + 1, -1), next_rank(2 * n + 1, -1);

	for (int i = 0; i <= n; i++) {
		sa[i] = i;
		rank[i] = i < n ? s[i] : -1;
	}

	for (int k = 1; k <= n; k *= 2) {
		auto comp = [&](int i, int j) {
			return rank[i] != rank[j] ? rank[i] < rank[j] : rank[i + k] < rank[j + k];
		};

		sort(sa.begin(), sa.end(), comp);
		next_rank[sa[0]] = 0;
		for (int i = 1; i <= n; i++) {
			next_rank[sa[i]] = next_rank[sa[i - 1]] + comp(sa[i - 1], sa[i]);
		}
		swap(rank, next_rank);
	}

	return sa;
}

vector<int> build_rank(vector<int> sa) {
	vector<int> rank(sa.size());
	for (int i = 0; i < rank.size(); i++) {
		rank[sa[i]] = i;
	}
	return rank;
}

vector<int> build_lcp(string s, vector<int> sa) {
	vector<int> rank = build_rank(sa);
	int h = 0;
	vector<int> lcp(sa.size());
	lcp[0] = 0;
	for (int i = 0; i < s.size(); i++) {
		int j = sa[rank[i] - 1];
		if (h > 0) h--;
		while (i + h < s.size() && j + h < s.size() && s[i + h] == s[j + h]) h++;
		lcp[rank[i] - 1] = h;
	}
	return lcp;
}

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

	vector<int> sa = build_suffix_array(s);
	vector<int> lcp = build_lcp(s, sa);
	vector<int> inv_sa = build_rank(sa);

	int n = s.size();

	UnionFind uf(n + 1);

	vector<vector<int>> pos(n + 2);
	for (int i = 0; i < n; i++) {
		pos[lcp[i]].push_back(i);
	}

	int ans = 0;
	int num_cc = 0;

	for (int i = n; i >= 1; i--) {
		num_cc++;

		for (int id : pos[i]) {
			num_cc -= uf.merge(id, id + 1);
		}

		ans = max(ans, num_cc);
	}

	cout << ans << endl;
}

Measured memory_bytes: 7776