akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1001001001;

char mp[1005][1005];
int dist[1005][1005];

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  rep(y, h) rep(x, w) {
    cin >> mp[x][y];
    dist[x][y] = INF;
  }
  priority_queue<PP, vector<PP>, greater<PP>> q;
  q.emplace(0, make_pair(cw, ch));
  while (!q.empty()) {
    int x = q.top().second.first;
    int y = q.top().second.second;
    int d = q.top().first;
    q.pop();
    if (d >= dist[x][y]) continue;
    dist[x][y] = d;
    rep(v, 4) {
      int nx = x + dx[v];
      int ny = y + dy[v];
      if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
      if (mp[nx][ny] == '#') continue;
      q.emplace(d, make_pair(nx, ny));
    }
    for (int ex = -2; ex <= 2; ex++) {
      for (int ey = -2; ey <= 2; ey++) {
        int nx = x + ex;
        int ny = y + ey;
        if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
        if (mp[nx][ny] == '#') continue;
        q.emplace(d + 1, make_pair(nx, ny));
      }
    }
  }
  int ans = dist[dw][dh];
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

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

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

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int n; cin >> n; 
    int p[100005];
    p[0] = 0;
    p[1] = 0;
    p[2] = 0;
    for(int i = 3; i < 100005; i++){
        int k = (i+1)/2;
        if(IsPrime(i) && IsPrime(k)) p[i] = 1;
        else p[i] = 0;
    }
    int sum[100005];
    sum[0] = 0;
    for(int i = 0; i < 100004; i++){
        sum[i+1] = sum[i] + p[i];
    }
    rep(i,n){
        int l,r;
        cin >> l >> r;
        cout << sum[r+1] - sum[l] << endl;
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define       M                        1000000007
#define       ll                       long long
#define       FIO                      ios_base::sync_with_stdio(false);cin.tie(NULL)
#define       ifor(st,lim)             for(int i=st;i<lim;i++)
#define       jfor(stt,llim)           for(int j=stt;j<llim;j++)
#define       eifor(st,lim)            for(int i=st;i<=lim;i++)
#define       ejfor(stt,llim)          for(int j=stt;j<=llim;j++)
#define       blank                    cout<<'\n' 

void solve()
{
    int n; cin>>n;
    int a[n];
    ifor(0,n) cin>>a[i];
    int mx = -1;
    ll ans = 0;
    ifor(0,n) {
       mx = max(mx,a[i]);
      int x = mx;
      ans+=x-a[i];
    }
    cout<<ans;
}

int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
int t=1; 
  while(t--){
    solve();
   } 
}


Measured memory_bytes: 4380
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	VL a(N);
	ll x = 0, y = 0 , absmin = (ll)1e18;
	REP(i, N) {
		cin >> a[i];
		y += a[i];
	}
	REP(i, N-1) {
		x += a[i];
		y -= a[i];
		absmin = min(absmin, abs(x - y));
	}
	cout << absmin << endl;
	//cin >> N;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
using namespace std;
int main(){
    int A, B, C, D;
    int total = 0;
    cin >> A >> B >> C >> D;
    if(A > B){
        if(C > D)
            total = B + D;
        else
            total = B + C;
    }else{
        if(C > D)
            total = A + D;
        else
            total = A + C;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

S = list(input())

N = len(S)

S1 = S[:int((N-1)/2)]
S2 = S[int((N+3)/2-1):]

#print(S1, S2)

if S == S[::-1]:
    if S1 == S1[::-1]:
        if S2 == S2[::-1]:
            print("Yes")
            sys.exit()

print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 5005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,M;
int64 sum[MAXN][MAXN],A[MAXN],B[MAXN][205],st[MAXN][15],len[MAXN];
int maxpos(int l,int x,int y) {
    return B[x][l] > B[y][l] ? x : y;
}
int Query(int x,int l,int r) {
    int t = len[r - l + 1];
    return maxpos(x,st[l][t],st[r - (1 << t) + 1][t]);
}
void dfs(int x,int l,int r) {
    if(l > r) return;
    int p = Query(x,l,r);
    sum[l][p] += B[p][x];
    sum[l][r + 1] -= B[p][x];
    sum[p + 1][p] -= B[p][x];
    sum[p + 1][r + 1] += B[p][x];
    dfs(x,l,p - 1);dfs(x,p + 1,r);
}
void Solve() {
    read(N);read(M);
    for(int i = 1 ; i < N ; ++i) {
        read(A[i]);
        A[i] += A[i - 1];
    }
    for(int i = 1 ; i <= N ; ++i) {
        for(int j = 1 ; j <= M ; ++j) {
            read(B[i][j]);
        }
    }
    for(int i = 2 ; i <= N ; ++i) len[i] = len[i / 2] + 1;
    for(int j = 1 ; j <= M ; ++j) {
        for(int i = 1 ; i <= N ; ++i) st[i][0] = i;
        for(int k = 1 ; k <= 13 ; ++k) {
            for(int i = 1 ; i <= N ; ++i) {
                if(i + (1 << k) - 1 > N) break;
                st[i][k] = maxpos(j,st[i][k - 1],st[i + (1 << k - 1)][k - 1]);
            }
        }
        dfs(j,1,N);
    }
    for(int i = 1 ; i <= N ; ++i) {
        for(int j = 1 ; j <= N ; ++j) {
            sum[i][j] += sum[i][j - 1];
        }
    }
    for(int i = 1 ; i <= N ; ++i) {
        for(int j = 1 ; j <= N ; ++j) {
            sum[i][j] += sum[i - 1][j];
        }
    }
    int64 ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
        for(int j = i ; j <= N ; ++j) {
            ans = max(sum[i][j] - (A[j - 1] - A[i - 1]),ans);
        }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

int main(){
    int n, ans=0;
    cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];

    for(int i = 1; i < n - 1; ++i){
        vector<int> s(3);
        s[0] = p[i-1];
        s[1] = p[i];
        s[2] = p[i+1];
        sort(s.rbegin(), s.rend());
        s.erase(s.begin());
        if(s[0]==p[i])ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  if(n>1 && m>1){
    printf("%d",n*(n-1)/2 + m*(m-1)/2);
  	return 0;
  }
  int x = (n>1 ? n:m);
  printf("%d",x*(x-1)/2);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<P>> G(n + 1);
    vector<ll> t(n + 1), e(n + 1), x(n + 1, LINF);
    x[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t[i] >> e[i];
        G[0].emplace_back(i, t[i]);
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        G[b].emplace_back(a, c - 1);
    }
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, 0));
    while (!q.empty()) {
        int v = q.top().second;
        if (q.top().first > x[v]) {
            q.pop();
            continue;
        }
        q.pop();
        for (auto &e : G[v]) {
            if (x[e.first] > x[v] + e.second) {
                x[e.first] = x[v] + e.second;
                q.push(P(x[e.first], e.first));
            }
        }
    }
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        res += e[i] * x[i];
    }
    cout << res << '\n';
}



Measured memory_bytes: 15352
#include <cstdio>
#define maxn 100010
int cnt[2][maxn], M[2], Q[2], m[2], q[2];
int n;
int main() {
    scanf("%d", &n);
    for (int i = 1, x, p; i <= n; i++) {
        scanf("%d", &x); p = i % 2;
        cnt[p][x]++;
        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;
    }
    if (Q[0] != Q[1]) {
        printf("%d\n", n - M[0] - M[1]);
        return 0;
    }
    for (int i = 1; i <= 100000; i++) {
        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;
        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;
    }
    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);
    else printf("%d\n", n - m[0] - M[1]);
    return 0;
}

Measured memory_bytes: 4008
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	const vector<char> A = {'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};
    while (1) {
		string S; cin >> S;
		if (S == "#") break;
		int N = S.size();
		vector<bool> B(N);
		rep(i,N) {
			for (auto j : A) {
				if (S[i] == j) B[i] = true;
			}
		}
		int cnt = 0;
		rep(i,N-1) {
			if (B[i] != B[i+1]) cnt++;
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    vector<int> lite[26];
    string s;
    cin >> s;

    int slen = s.length();

    rep(i, slen){
        lite[s[i]-'a'].push_back(i);
    }

    if(slen == 2){
        if(s[0] == s[1]){
            cout << 1 << " " << 2 << endl;
        }else{
            cout << -1 << " " << -1 << endl;
        }
        return 0;
    }

    rep(i, 26){
        if(lite[i].size() <= 1) continue;
        else{
            rep(j, lite[i].size()-1){
                //cout << j << endl;
                if(lite[i][j+1] - lite[i][j] > 2) continue;
                else{
                    cout << lite[i][j]+1 << " " << lite[i][j+1]+1 << endl;
                    return 0;
                }
            }
        }
    }

    cout << -1 << " " << -1 << endl;

    return 0;
}


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

int main() {
  int x=0;
  int n;
  int ans=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='I'){
      x++;
      ans=max(ans,x);
    }
    else x--;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
A,B,H,M=map(int,input().split())
time=60*H+M
Adeg=(time/720)*360
Bdeg=(M/60)*360
kakudo=abs(Adeg-Bdeg)
if kakudo==0  :
  print(abs(A-B))
elif kakudo== 180:
  print(A+B)
elif kakudo>180:
  kakudo=360-kakudo
  ans=math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(kakudo)))
  print(ans)
else:
  ans=math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(kakudo)))
  print(ans)

Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long l, r;
	cin>>l>>r;
	long long i = l;
	long long j = r;
	long long res = 1e12;
	if(abs(j - i) >= 5000){
		cout<<0<<endl;
		return 0;
	}
	else{
		for(i = l; i < r; ++i){
			for(j = l + 1; j <= r; j++){
				res = min(i * j % 2019, res);
			}
		}
		cout<<res<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main()
{
    ll n,m,i,j,u,s=0,r,q=1,p;
    cin>>n;
    p=n;
    u=1;
    while(p>1)
    {
        p=p/2;
        s=s+u;
        u=u*2;
        q=2*q;
    }
    r=s+q;
    cout<<r<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b,c) for(int i=a;i<b;i+=c)
#define b(i,a,b,c) for(int i=a;i>=b;i-=c)
int main(){
  int n;
  cin>>n;
  long long int ans=n+(n*n)+(n*n*n);
  cout<<ans;
    
  
}

Measured memory_bytes: 3572
import std.stdio;
import std.conv;
import std.string;

void main()
{
    int[] input = readln.split.to!(int[]);
    int a = input[0];
    int b = input[1];

    if (a + b == 15){
        writeln("+");
    } else if (a * b == 15){
        writeln("*");
    } else {
        writeln("x");
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');

            if(a[0] == a[1] && a[1] != a[2])
            {
                Console.WriteLine("Yes");
            }
            else if(a[1] == a[2] && a[2] != a[0])
            {
                Console.WriteLine("Yes");
            }
            else if (a[2] == a[0] && a[0] != a[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

using namespace std;

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

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

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

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

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

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

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

ll f(ll b, ll n){
  if(b<2) return -1;
  if(n<b) return n;
  else return f(b, n/b) + n%b;
}

ll binary_search(ll b_start, ll b_end, ll n, ll s){
  if(b_start<2) b_start=2;
  if(b_end<2) return -1;
  if(b_start>b_end) return -1;
  if(b_start==b_end) return b_start;
  if(b_end-b_start==1){
    if(f(b_start, n)==s) return b_start;
    else return b_end;
  }
  ll b_middle = (b_start+b_end)/2;
  if(f(b_middle, n)>=s) return binary_search(b_middle, b_end, n, s);
  else return binary_search(b_start, b_middle, n, s);
}

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

  ll n;
  ll s;
  cin >> n >> s;

  ll ans = n+10;

  ll n_middle = (ll)sqrt((long double)n)+1;

  if(f(n+1, n)==s) ans = n+1;
  for(ll k_start=2; k_start<n_middle+2; ++k_start){
    ll b_start = (n/k_start);
    ll b_end = (n/(k_start-1));
    if(f(b_start, n)==s && b_start>1) ans = min(ans, b_start);
    if(b_start==b_end) continue;
    if(f(b_end, n)==s && b_end>1) ans = min(ans, b_end);
    ll cand = binary_search(b_start, b_end, n, s);
    if(f(cand, n)==s && cand>1) ans = min(ans, cand);
  }
  for(ll b=2; b<=max(max(n/n_middle, n_middle), (ll)2); ++b){
    if(f(b, n)==s){
      ans = min(ans, b);
      break;
    }
  }

  if(ans==n+10) ans = -1;
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int ll
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
/*inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int n,m,x[100001],y[100001],ans;
bool check[401][401],c[401];
signed main(){
	n=rd(),m=rd();
	Rep(i,1,m)x[i]=rd(),y[i]=rd();
	Rep(i,1,n){
		check[i][i]=true;
		Dep(j,m,1){
			bool b1=check[i][x[j]],b2=check[i][y[j]];
			if(b1&&b2){c[i]=true;break;}else if(b1)check[i][y[j]]=true;else if(b2)check[i][x[j]]=true;  
		}
	}
	rep(i,1,n)if(!c[i])Rep(j,i+1,n)if(!c[j]){
		bool flag=true;
		for(int k=1;k<=n;++k)if(check[i][k]&&check[j][k]){flag=false;break;}
		ans+=flag;
	}
	writeln(ans);
}


Measured memory_bytes: 1920
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int k,t;
	while(cin >> k >> t){
		vector<int> a(t);
		REP(i,t) cin >> a[i];
		int ta = -1;
		bool conf = true;
		int ans = 0;
		while(conf){
			conf = false;
			REP(i,t) if(a[i] != 0) conf = true;
			if(!conf) break;
			bool f = false;
			REP(i,t) if(i != ta and a[i] != 0){
				f = true;
			}
			if(f){
				int ma = -1;
				int tt = -1;
				REP(i,t) if(i != ta){
					if(chmax(ma,a[i])){
						tt = i;
					}
				}
				a[tt]--;
				ta = tt;
			}else{
				ans++;
				a[ta]--;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
from math import log10

K = int(input())
  
def find(K):
  if K % 2 == 0 or K % 5 == 0:
    return -1
  
  if K % 7 == 0:
    L = K * 9 // 7
  else:
    L = K * 9

  count = max(int(log10(L)), 1)
  
  quotient = 10**count % L
  
  while True:
    if quotient == 1:
      return count
    quotient = quotient * 10 % L
    count += 1
    
    
print(find(K))

Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include<sstream>
#include<cmath>
#include <iomanip>

using namespace std;

int main() {
	double n; double k; long double prob=0;
	cin >> n >> k;
	
	for (int i = 1; i <= n; i++) {
		int multi = i; int times = 0; long double io = 1;
		while (multi < k) {
			multi = multi * 2;
			times++;
		}

		for (int j = 0; j < times; j++) {
			io = io * 0.5;
		}
		prob = prob + (1 / n) * io;
	}

	cout << setprecision(12) << prob;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int H,N; cin >> H >> N;
    vector<int> A(N), B(N);
    rep(i,N) {
        cin >> A.at(i) >> B.at(i);
    }

    vector<ll> DP(H+1, 1LL<<62);
    DP[0] = 0;
    for (int i = 0; i<= H; i++) {
        if (DP[i] == 1LL<<62) continue;
        rep(j,N) {
            int n = i + A[j];
            if (n > H) n = H;
            DP[n] = min(DP[n], DP[i] + B[j]);
        }
    }
    cout << DP[H] << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define fi first
#define se second
#define reset(n,k) memset((n),k,sizeof(n))
#define all(n) n.begin(),n.end()
#define pb push_back
using namespace std;
using ll=long long;
using pii=pair<int,int>;

vector<ll> v;
ll arr[200005];
ll n,k;

ll check(ll x){
	v.clear();
	v.pb(arr[1]);
	ll ans=0;
	for(int i=2;i<=n;i++){
		if(arr[i]>0){	
			if(v[0]*arr[i] < x) {
				ll l = 0,r = v.size()-1;
				while(l<r){
					int m = (l+r+1)>>1;
					if(v[m]*arr[i] >= x){
						r=m-1;
					}	
					else{
						l=m;
					}
				} 
				//cout<<arr[i]<<" "<<l<<'\n';
				ans += l+1;
			}	
		}
		else{
			if(v[v.size()-1]*arr[i]<x) {
				ll l = 0,r = v.size()-1;
				while(l<r){
					int m = (l+r)>>1;
					if(v[m]*arr[i] >= x){
						l=m+1;
					}	
					else{
						r=m;
					}
				} 
				//cout<<arr[i]<<" "<<v.size()-l<<'\n';
				ans += v.size()-l;
			}	
		}
		v.pb(arr[i]);
	}
	//cout<<x<<" "<<ans<<'\n';
	return ans;
}
int main(){
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>arr[i];
	sort(arr+1,arr+n+1);
	ll l = -1e18, r = 1e18;
	while(l<r){
		ll m = (l+r+1)>>1;
		if(check(m)<k) l=m;
		else r=m-1;
	}
	cout<<l<<'\n';

}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  int ans = 0;
  cin >> N;
  for (int i = 1; i < N+1; i++) {
    if (to_string(i).length() % 2 != 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
const int Mod=998244353;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,x[201],y[201],o[201],cnt;
ll ans;
int main(void){
	register int i,j,k;
	n=read();
	o[0]=1;
	for(i=1;i<=n;++i)
		x[i]=read(),y[i]=read(),(o[i]=o[i-1]<<1)%=Mod;
	ans=((o[n]-1-n-(n*(n-1)>>1))%Mod+Mod)%Mod;
	for(i=1;i<=n;++i)
		for(j=i+1;j<=n;++j){
			cnt=0;
			for(k=j+1;k<=n;++k)
				if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))++cnt;
			ans=(ans-o[cnt]+1+Mod)%Mod;
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
def solve(H):
    dp = [0]*N
    dp[0] = 0
    dp[1] = abs(H[1]-H[0])
    for i in range(2,N):
        dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))
    ans = dp[-1]
    return ans
print(solve(H))

Measured memory_bytes: 13928
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,d;
	scanf("%d%d",&n,&d);
	d=d*2+1;
	int ans=n/d;
	if(n%d!=0)ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  ll k;
  cin >> s >> k;
  rep(i, s.size()) {
    if(s[i] == '1') {
      k--;
      if(k != 0) continue;
    }
    cout << s[i] << endl;
    return 0;
  }
}

Measured memory_bytes: 256
function main(lines) {
  const [sx, sy, tx, ty] = splitN(lines[0]);

  const dx = tx-sx, dy = ty-sy;
  let s = '';
  s += 'U'.repeat(dy) + 'R'.repeat(dx);
  s += 'D'.repeat(dy) + 'L'.repeat(dx);
  s += 'L' + 'U'.repeat(dy+1) + 'R'.repeat(dx+1) + 'D';
  s += 'R' + 'D'.repeat(dy+1) + 'L'.repeat(dx+1) + 'U';

  return s;
}


const ans = main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );
console.log( ans );

function splitN(s) {
  return s.split(' ').map(Number);
}

Measured memory_bytes: 29576
import sys
from io import StringIO
import unittest
import math

def resolve():
    r = int(input())
    ans = math.pi * r * 2
    print('{:.20f}'.format(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1"""
        output = """6.28318530717958623200"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """73"""
        output = """458.67252742410977361942"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 71108
#include<iostream>

const int MAX_N = 1 << 17, INF = 1 << 24;
class BIT{
public:
	BIT(int _n)
		:n(_n){
		std::fill(bit, bit+n, 0);
	}
	int sum(int i){
		int s = 0;
		while(i > 0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	int add(int i, int x){
		while(i <= n){
			bit[i] += x;
			i += i & -i;
		}
	}
private:
	int bit[MAX_N], n;
};

int main(){
	int n, k;
	while(std::cin >> n >> k, n){
		BIT b(n+1);
		for(int i=1;i<=n;i++){
			int a_i;
			std::cin >> a_i;
			b.add(i, a_i);
		}

		int res = -INF;
		for(int i=1;i+k-1<=n;i++){
			res = std::max(res, b.sum(i+k-1) - b.sum(i-1));
		}

		std::cout << res << std::endl;
	}
}

Measured memory_bytes: 1556
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <map>
using namespace std;
#define lli long long int
#define MAX 1000000007
#define MAX_N 100

bool is_ans = true;
int N;
vector<int> b;
vector<int> ans;

void read()
{
    int tmp;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        b.push_back(tmp);
    }
    return;
};
void solve()
{
    while (true)
    {
        is_ans = false;
        for (int i = b.size() - 1; i >= 0; i--)
        {
            if (b[i] == i + 1)
            {
                ans.push_back(i + 1);
                b.erase(b.begin() + i);
                is_ans = true;
                break;
            }
        }
        if (b.empty() == true)
        {
            is_ans = true;
            return;
        }
        if (b.empty() == false && is_ans == false)
        {
            return;
        }
    }
};
void print_ans()
{
    if (is_ans == true)
    {
        for (auto i = ans.rbegin(); i != ans.rend(); i++)
        {
            cout << *i << endl;
        }
    }
    else
    {
        cout << -1 << endl;
    }
}
int main()
{
    read();
    solve();
    print_ans();
    return 0;
}

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

int main()
{
	map<string,int> mp;
	int n;
	cin>>n;
	for( int i=0; i<n; i++ )
	{
		string s;
		cin>>s;
		mp[s] = 1;
	}
	cout << mp.size() << endl;
}


Measured memory_bytes: 19176
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
const int N = 2e2 + 1;
const int inf = 1e9;
bool b[N][N], can[N][N][2];
string s;
int d[N];


void solve() {
    int i, j, k, l, n;
    cin >> n;
    for (i = 0; i < n; ++i) {
        cin >> s;
        for (j = 0; j < n; ++j) {
            can[i][j][1] = b[i][j] = s[j] == '1';
        }
    }
    for (i = 0; i < n; ++i)
        can[i][i][0] = 1;
    for (k = 0; k < n; ++k)
    for (i = 0; i < n; ++i)
    for (j = 0; j < n; ++j) {
        can[i][j][0] |= (can[i][k][0] && can[k][j][0]) || (can[i][k][1] && can[k][j][1]);
        can[i][j][1] |= (can[i][k][0] && can[k][j][1]) || (can[i][k][1] && can[k][j][0]);
    }
    for (i = 0; i < n; ++i)
    if (can[i][i][1]) {
        cout << -1;
        return;
    }
    int ans = 0;
    for (i = 0; i < n; ++i) {
        vector <int> v;
        for (j = 0; j < n; ++j)
            d[j] = inf;
        v.push_back(i);
        d[i] = 0;
        for (j = 0; j < v.size(); ++j) {
            for (int l = 0; l < n; ++l)
            if (b[v[j]][l] && d[l] == inf) {
                v.push_back(l);
                d[l] = d[v[j]] + 1;
            }
        }
        ans = max(ans, d[v[v.size() - 1]]);
    }
    cout << ans + 1;
}

signed main() {
    #ifdef local
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 512
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b;
    cin>>a>>b;
    ll gcd=__gcd(a,b);
    ll ans= a*b;
    ans/=gcd;
    cout<<ans<<endl;
    
}

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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 3005;

ll A[N];
ll dp[N][N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    rep(i,0,n)  cin>>A[i];
    repb(i,n-1,0)   rep(j,i,n){
        if(i==j)    dp[i][j] = A[i];
        else{
            dp[i][j] = max(A[i] - dp[i+1][j], A[j] - dp[i][j-1]);
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 70016
#include <stdio.h>
#include <string.h>

int main(void){
 
    char sa[150];
    char sb[150];
    char sc[150];
    int salen, sblen, sclen;
    int apos, bpos, cpos;
    int turn;

    apos = 0;
    bpos = 0;
    cpos = 0;
    turn = 1;

    scanf("%s", sa);
    scanf("%s", sb);
    scanf("%s", sc);
    salen = strlen(sa);
    sblen = strlen(sb);
    sclen = strlen(sc);
    
    while(1){
        if(turn == 1){
            if(apos == salen) break;
            if(sa[apos] == 'b') turn = 2;
            else if(sa[apos] == 'c') turn = 3;
            apos++;
        }else if(turn == 2){
            if(bpos == sblen) break;
            if(sb[bpos] == 'a') turn = 1;
            else if(sb[bpos] == 'c') turn = 3;
            bpos++;
        }else {
            if(cpos == sclen) break;
            if(sc[cpos] == 'a') turn = 1;
            else if(sc[cpos] == 'b') turn = 2;
            cpos++;
        }
    }

    if(turn == 1) printf("A\n");
    else if(turn == 2) printf("B\n");
    else printf("C\n");

    return 0;

}

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

class Main{
  public static void main(String args[]){
    Scanner in = new Scanner(System.in);
    int mod = 1000000000+7;
    int n = in.nextInt();
    int m = in.nextInt();

    int a[][] = new int[n+1][m+1];
    for(int i=0;i<n;i++){
      String s = in.next();
      for(int j=0;j<s.length();j++)
        a[i+1][j+1] = s.charAt(j)=='#' ? -1 : 0;
    }
    for(int i=1;i<a.length;i++)
      for(int j=1;j<a[i].length;j++)
        a[i][j] = getVal(a,i,j,mod);

    System.out.println(a[n][m]%mod);
  }

  public static int getVal(int a[][], int i, int j, int m){
    if(i==1 && j==1) return 1;
    if(a[i][j]==-1) return 0;

    return (a[i-1][j]+a[i][j-1])%m;
  }

}


Measured memory_bytes: 34908
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int sum = 0;
  rep(i, N.size()){
    sum += N[i] - '0';
  }

  if (std::stoi(N) % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define N_MAX 100000
long long S[N_MAX + 1];

long long power(long long a, int p) {
    if(p == 1) return a;
    else {
        long long ret = power(a, p / 2);
        ret = ret * ret % mod;
        if(p & 1) ret = ret * a % mod;
        return ret;
    }
}

void init() {
    S[0] = 0;
    for(int i=1; i<=N_MAX; ++i) {
        S[i] = (S[i - 1] + power(i, mod - 2)) % mod;
    }
}

int main() {
    init();
    long long N;
    cin >> N;
    long long res = 0;
    for(int j=1; j<=N; ++j) {
        long long A;
        cin >> A;
        res += A * ((1 + S[j] - S[1] + S[N - j + 1] - S[1]) % mod) % mod;
        res %= mod;
    }

    long long fac = 1;
    for(int i=2; i<=N; ++i) {
        fac *= i;
        fac %= mod;
    }

    cout << (res * fac) % mod << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <bitset>

using bitset = std::bitset<40>;

bitset solv(long n) {
  if (n == 0) {
    return bitset(0);
  } else {
    size_t i;
    long long a;
    bitset ret;
    if (n < 0) {
      i = 1;
      a = -2;
      while (n < a) {
        i += 2;
        a += -(1LL<<i);
      }
      ret = solv(n + (1LL<<i));
    } else {
      i = 0;
      a = 1;
      while (n > a) {
        i += 2;
        a += (1LL<<i);
      }
      ret = solv(n - (1LL<<i));
    }

    ret.set(i);
    return ret;
  }
}

int main() {
  long n;
  std::cin >> n;

  auto ret = solv(n);

  bool put_flag = false;

  for (ssize_t i=35; i>=0; i--) {
    if (ret[i]) {
      std::cout << '1';
      put_flag = true;
    } else if (put_flag) {
      std::cout << '0';
    }
  }

  if (! put_flag) {
    std::cout << '0';
  }

  std::cout << std::endl;

  return 0;
}


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

int main()
{
    int n; cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    
    bool flag = true;
    if (n > 1) {
        for (int i = n - 2; i >= 0; i--) {
            if (h[i] > h[i+1] + 1) flag = false;
            else if (h[i] > h[i+1]) h[i]--;
        }
    }
    cout << ((flag) ? "Yes" : "No") << endl;
    return 0;
}

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

int main()
{
	  int a;
	  cin >> a;
	  int b;
	  cin >> b;
	  
	  cout << a * b << " " << (a + b) * 2 << endl;
	  
	 
	
	
	}

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<vector>
#include <type_traits>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
typedef pair<double, double> dop;
//------------------変数-----------------------//
ll n, k, maxa = 0;;
P p[100001];
//-------------------関数----------------------//
int main() {
	cin >> n >> k;
	REP(i, n) { cin >> p[i].first >> p[i].second; }
	REP(i, 32) {
		if (((k >> i) & 1) == 0) { continue; }
		ll iz=0;
		REP(j, n) {
			ll izryt = p[j].first;
			bool tourist = false;
			FOR(z, i+1 , 31) {
				if (((izryt >> z) & 1) == 1&&((k>>z)&1)==0) {
					tourist = true; break;
				}
				if (((izryt >> i) & 1) == 1) { tourist = true; break; }
			}
			if (!tourist) { iz += p[j].second; }
		}
	//	cout << iz << " " << i << endl;
		maxa = max(iz, maxa);
	}	
	ll iz = 0;
	REP(j, n) {
		ll izryt = p[j].first;
		bool tourist = false;
		FOR(z, 0, 31) {
			if (((izryt >> z) & 1) == 1 && ((k >> z) & 1) == 0) {
				tourist = true; break;
			}
		}
		if (!tourist) { iz += p[j].second; }
	}
		maxa = max(maxa, iz);
	cout << maxa << endl;
	return 0;
}

Measured memory_bytes: 2424
K, X = map(int, input().split())

# K, X = 100程度なので、端点を考慮しなくてよい
# X−K+1,X−K+2,...,X+K−1 の2K−1個を出力すればよい
print(' '.join(map(str, range(X-K+1, X+K))))

Measured memory_bytes: 9116
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
int matrix[100][100];
pair<int,int> edges[10010];
int cost[10010];
int src[10010];
int dst[10010];
int p[10010];
void init(int n)
{
    for(int i=0;i<=n;i++)
        p[i]=i;
};
int root(int a)
{
    if(p[a]==a)
        return a;
    return (p[a]=root(p[a]));
};
bool is_same_set(int a,int b)
{
    return root(a)==root(b);
};
void unite(int a,int b)
{
    p[root(a)]=root(b);
};

int main()
{
    int n,amount=0,sum=0;
    
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>matrix[i][j];
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(matrix[i][j]!=-1)
            {
                cost[amount]=matrix[i][j];
                src[amount]=i;
                dst[amount]=j;
                amount++;
            }
        }
    }
    for(int i=0;i<amount;i++)
    {
        edges[i]=make_pair(cost[i],i);
    }

	init(n);
    
    sort(edges,edges+amount);
    
    for(int i=0;i<amount;i++)
    {
        if(is_same_set(src[edges[i].second],dst[edges[i].second]))
			continue;
		unite(src[edges[i].second],dst[edges[i].second]);
		sum+=edges[i].first;
    }
	cout<<sum<<endl;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#include <inttypes.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   std::vector<std::pair<long, long>> compress(const LI &xs) {
      std::vector<std::pair<long, long>> res;
      long n = xs.size();
      for(long i = 0; i < n; ++i) {
         if( i == 0 or xs[i-1] != xs[i] ) {
            res.push_back(std::make_pair(xs[i], 1));
         }
         else {
            res.back().second += 1;
         }
      }
      return res;
   }
   void solve() {
      Int n; scan(n);
      LI xs(n); scan(xs);
      std::sort(xs.begin(), xs.end());
      auto ys = compress(xs);
      Int res = 0;
      for(auto y : ys) {
         res += y.second % 2;
      }
      printf("%ld\n", res);
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}
 
 

Measured memory_bytes: 4212
while 1:
  n,p=map(int,input().split())
  if not n and not p:break
  l=[0 for _ in range(n)]
  np=p
  s=0
  while 1:
    if np>0:
      l[s]+=1
      np-=1
      if l[s]==p:
        print(s)
        break
    elif np==0:
      np+=l[s]
      l[s]=0
    s+=1
    if s>n-1:s=0


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

int main()
{
    int N, M, X, sum1 = 0, sum2 = 0;
    cin >> N >> M >> X;
    vector<int> A(N + 1);
    rep(i, M)
    {
        int a;
        cin >> a;
        A[a] = 1;
    }
    for (int i = 0; i <= X; i++)
    {
        sum1 += A[i];
    }
    for (int i = X; i <= N; i++)
    {
        sum2 += A[i];
    }
    cout << min(sum1, sum2) << endl;
}

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

int main()
{
 	int k,x;
 	cin >> k >> x;
  	int min = x-k+1;
  	int max = x+k-1;
  	if(min < -1000000)
    {
     	min = -1000000;
    }
  	if(max > 1000000)
    {
     max = 1000000; 
    }
  	for(int i=min;i<=max;i++)
    {
     cout << i << " "; 
    }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
ll n,s;
inline ll calc(ll n,ll b)
{
	if(!n)return 0;
	return calc(n/b,b)+n%b;
}
int main()
{
	cin>>n>>s;
	if(n<=s){
		cout<<((n<s)?-1:n+1)<<endl;
		return 0;
	}
	int lim1=1;
	for(ll i=2;i*i<=n;++i){
		if(calc(n,i)==s){cout<<i<<endl;return 0;}
		lim1=i;
	}
	for(ll i=lim1;i>0;--i){
		if((n-s)%i==0){
			ll b=(n-s)/i+1;
			if(calc(n,b)==s){cout<<b<<endl;return 0;}
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    _  <- getLine
    xs <- fmap read . words <$> getLine
    answer $ solve xs

type Answer = Int
answer :: Answer -> IO ()
answer = print

solve :: [Int] -> Answer
solve = snd . inner 0 0 minBound maxBound
  where
    inner b s d p (x : xs)
      | x  <  p   = inner 1  0  d  x xs `add` (d, min b s)
      | x  == p   = inner b' s  d  p xs
      | d' == d   = inner b  s' d  p xs
      | d' >  d   = inner b  1  d' p xs
      | otherwise = inner b  s  d  p xs
      where
        d' = x - p
        b' = succ b
        s' = succ s
    inner b s d _ _ = (d, min b s)
    add (d, n) (c, m)
      | d > c     = (d, n)
      | otherwise = (d, n + m)


Measured memory_bytes: 36220
A=[]
F=[]
for i in range(0,10):
    B1=raw_input()
    B=int(B1)
    A.append(B)
for i in range(0,10):
    F.append(1)

for num in range(0,3):
    M=0
    m=0
    for i in range(0,10):    
        if(M<A[i]):
            if(F[i]==1):
                M=A[i]
                m=i
    print(M)
    F[m]=0
        

Measured memory_bytes: 6432