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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define MP make_pair
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double PI = acos(-1);
const double EPS = 1e-9;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

///////////////////////////////////////////////////////

const int N = 100;

int A[N + 5], B[N + 5], C[N + 5];
int n;

int solve(){
	int ret = B[A[1]];
	REP(i,2,n){
		int num = A[i];
		ret += B[num];
		if(num-1 == A[i-1]) ret += C[num-1];
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	REP(i,1,n) cin >> A[i];
	REP(i,1,n) cin >> B[i];
	REP(i,1,n-1) cin >> C[i];
	cout << solve() << endl;
	return 0;
} 

Measured memory_bytes: 256
N = int(input())

balls = []
for i in range(N):
    x, y = map(int, input().split())
    balls.append((x, y))

if N == 1:
    print(1)
else:
    pq = {}
    for i in range(N-1):
        for j in range(i+1, N):
            p, q = balls[i][0] - balls[j][0], balls[i][1] - balls[j][1]
            if p < 0 or (p == 0 and q < 0):
                p, q = -p, -q
            if (p, q) in pq:
                pq[(p, q)] += 1
            else:
                pq[(p, q)] = 1

    ans = N - max(pq.values())
    print(ans)

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;


int sm[575][575];

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

  CIN(N, M, Q);
  REP(i, M) {
    CIN(L, R);
    // L--; R--;
    sm[1][R]++;
    sm[L + 1][R]--;
  }

  REP(i, N) {
    REP(j, N) {

      sm[i + 1][j + 1] += sm[i][j + 1];
      sm[i + 1][j + 1] += sm[i + 1][j];
      sm[i + 1][j + 1] -= sm[i][j];
      // debug(sm[i + 1][j + 1]);
    }
  }

  
  
  REP(i, Q) {
    CIN(p, q);
    // p--; q--;
    cout << sm[p][q] << endl;
  }
  
  return 0;
}



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

using namespace std;

int main() {
    map <string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    string x; cin >> x;
    cout << mp[x] << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10**9 + 7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



ans = 1
for i in range(1, min(n, k + 1)):
    ans += cmb(n, i, mod) * cmb(n - 1, i, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 127700
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<int> p(N);
  rep(i, N) cin >> p[i];

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

  int ans = p[0]/2;
  for(int i = 1; i < N; i++) ans += p[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import math

def read():
    a, b, x = list(map(float, input().strip().split()))
    return a, b, x

def search_rad_overhalf(a, b, s):
    l = 0.0
    r = math.pi / 4.0
    while r - l > 1e-12:
        m = (l + r) / 2.0
        if a * a * math.tan(m) > (a * b - s) * 2.0:
            r = m
        else:
            l = m
    return l

def search_rad_underhalf(a, b, s):
    l = 0.0
    r = math.pi / 4.0
    while r - l > 1e-12:
        m = (l + r) / 2.0
        if b * b * math.tan(m) > s * 2.0:
            r = m
        else:
            l = m
    return math.pi / 2.0 - l


def solve(a, b, x):
    s = x / a
    if x < a * a * b / 2.0:
        # 半分未満の時
        rad = math.atan2(b * b, 2.0 * s)
        #rad = search_rad_underhalf(a, b, s)
    else:
        # 半分以上の時
        rad = math.atan2(2.0 * (b - s / a), a)
        #rad = search_rad_overhalf(a, b, s)
    return math.degrees(rad)

if __name__ == '__main__':
    inputs = read()
    print("%.10f" % solve(*inputs))


Measured memory_bytes: 38256
N,M=map(int,input().split())
H=list(map(int,input().split()))
r=[1]*N
AB=[list(map(int,input().split())) for i in range(M)]
for a,b in AB:
    if H[a-1]<H[b-1]:
        r[a-1]=0
    elif H[a-1]>H[b-1]:
        r[b-1]=0
    else:
        r[a-1]=r[b-1]=0
print(sum(r))

Measured memory_bytes: 32000
s_lst = list(input())
p_lst = list(input())
l = len(s_lst)
not_found = True

for i in range(l):
    s = "".join(s_lst)
    p = "".join(p_lst)

    if p in s:
        print("Yes")
        not_found = False
        break
    else:
        t = s_lst[0]
        for j in range(l-1):
            s_lst[j] = s[j+1]
        s_lst[-1] = t

if not_found:
    print("No")


Measured memory_bytes: 5560
#include <cstdio>
#include <cstring>

const int maxn = 100000 + 5;
char s[maxn];

int main(){
	scanf("%s", s);
	int g=0, p=0, t1, t2;// g是石头，p是布
	int n = strlen(s);
	for (int i = 0; i < n; i++){
		if (s[i] == 'g') g++;
		else p++;
	}

	t1 = n / 2; // 布
	t2 = n - n / 2; // 石头

	int ans = t1 - p;

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


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    const long long int mod = 1000000007;
    int n;
    cin >> n;

    std::vector<long long int> v;
    std::vector<long long int> vv(n);
    for(int i=0; i<n; i++){
        long long int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }

    vv[n-1] = 0;
    //cout << vv[n-1] << endl;
    for(int i=n-2; i>=0; i--){
        vv[i] = (vv[i+1]%mod + v[i+1]);
        //cout << vv[i] << endl;
    }
    long long int sum = 0;
    for(int i=0; i<n-1; i++){
        sum += (v[i] * vv[i]%mod);
        //cout << v[i] << ":" << vv[i] << endl;
    }

    cout << sum%mod << endl;
    

    return 0;
}

Measured memory_bytes: 6896
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

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

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a, b := scanInt(), scanInt()
	fmt.Fprintln(wr, a*b)
}


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

#define MAX_N 50000

int p = 0;
int prime[MAX_N];
int is_prime[MAX_N + 1];

void eratosthenes() {
  int i, j;
  for (i = 0; i < MAX_N; i++) { is_prime[i] = 1; }
  is_prime[0] = is_prime[1] = 0;
  
  for (i = 2; i <= MAX_N; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (j = 2 * i; j <= MAX_N; j += i) { is_prime[j] = 0; }
    }
  }
}

int p_max(const int n) {
  int i;
  for (i = p - 1; i > 0 && prime[i] > n; i--);
  return i;
}

void solve(const int n) {
  int count = 0;
  int max = p_max(n/2+1);
  int i, j;
  
  /*
  for (i = 0; i <= max; i++) {
    for (j = i; j < p; j++) {
      if (prime[i] + prime[j] == n) {
        count++;
        // printf("%d + %d = %d\n", prime[i], prime[j], n);
      }
      if (prime[i] + prime[j] > n) break;
    }
  }
  */
  printf("%d\n", is_prime[n]);
}

void init() {
  int i, j, max = p_max(50000);
  for (i = 0; i < MAX_N; i++) is_prime[i] = 0;
  for (i = 0; i <= max; i++) {
    for (j = i; j < p; j++) {
      if (MAX_N >= prime[i] + prime[j]) is_prime[prime[i] + prime[j]]++;
    }
  }
}

int main(int argc, char argv) {
  int n;
  
  eratosthenes();
  init();
  while (scanf("%d", &n)) {
    if (0 == n) break;
    solve(n);
  }
  return 0;
}

Measured memory_bytes: 616
#include <iostream>
using namespace std;
int main() {
	int x = 1;
	int y = 1;
	while((x > 0) || (y > 0 )) {
		cin >> x;
		cin >> y;
		if  (( x > 0 ) || ( y > 0)) {
			if (x > y) {
				cout << y <<  " " << x << endl;
			}
			else {
				cout << x  << " " << y << endl;
			}
		}	
}
	return 0;
}


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

int main() {
	int n,k;cin >> n >> k;
	int out =0;
	for(int i=0;i<n;++i){
		int x;cin >> x;
		out += 2*min(x, abs(x-k));
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
hs = list(map(int, input().split()))

h_max = hs[0]
viewable = [hs[0]]
for i in range(1, n):
    h_height = hs[i]
    if h_height < h_max:
        continue
    h_max = h_height
    viewable.append(h_height)

print(len(viewable))

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

int main(){
  int H,W;
  while(1){
    cin >> H >> W;
    
     
    if(H==0 && W==0)
      break;
    
  for(int i=1; i <= H; i++){
    for(int j=1; j <= W; j++){
      cout << "#";
    }
    cout << endl;
    }
    cout << endl;
    
  }
}



Measured memory_bytes: 3092
#include<iostream>
#include<queue>
#include<cstdlib>
#include<set>
#include<functional>
#include<algorithm>

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

using namespace std;

enum triangle{DOWN=0,UP=1};

const int dx = 101;
const int dy = 101;
const int MAX_X = 2*dx;
const int MAX_Y = 2*dy;
const int offsets[2][3] = {{2,0,1},{1,2,0}};
const int cx[2][3] = { {1,-1,0}, {1,0,-1} };
const int cy[2][3] = { {0,0,1}, {0,-1,0} };

const int roll[20][3]={
  {1,4,5},{2,0,6},{3,1,7},{4,2,8},{0,3,9},
  {11,0,10},{12,1,11},{13,2,12},{14,3,13},{10,4,14},
  {5,9,15},{6,5,16},{7,6,17},{8,7,18},{9,8,19},
  {16,10,19},{17,11,15},{18,12,16},{19,13,17},{15,14,18},
};
const int infty = 200;

struct State{
  unsigned char x,y;
  char face,preface,from;
  char link[3];
  char cost;
  State (unsigned char x, unsigned char y, char face, char preface, char from):x(x),y(y),face(face),preface(preface),from(from){}
};

static bool vis[MAX_X][MAX_Y][20][20][3];

State nextState(const State &st, int moveType){
  int x = st.x;
  int y = st.y;
  int which = (abs(x)+abs(y)) % 2;
  int diff;
  State next(x+cx[which][moveType],y+cy[which][moveType],st.link[moveType],st.face,moveType);

  next.cost = st.cost + 1;
  rep(i,3) if( roll[next.face][i] == st.face ) diff = i;
  rep(i,3) next.link[(i+offsets[which][moveType])%3] = roll[next.face][ (diff+i) % 3 ];

  return next;
};

int solve(int gx, int gy, int gface)
{
  queue<State> Q;
  State init(dx,dy,0,0,0);
  
  rep(i,MAX_X)rep(j,MAX_Y)rep(k,20)rep(l,20)rep(m,3)vis[i][j][k][l][m]=false;
  rep(i,3)init.link[i]=roll[0][i];
  init.cost = 0;
  Q.push( init );

  while(!Q.empty()){
    State cur = Q.front(); Q.pop();
    if( cur.cost + abs(cur.x-gx) + abs(cur.y-gy) > 100 ) continue;
    if( cur.x == gx && cur.y == gy && cur.face == gface ){
      return cur.cost;
    }
    rep(i,3){
      State next = nextState( cur, i );
      if( vis[next.x][next.y][next.face][next.preface][next.from] ) continue;
      else vis[next.x][next.y][next.face][next.preface][next.from] = true;
      Q.push( next );
    }
  }
  return -1;
}

int main()
{
  int x,y,face;
  while(cin>>x>>y>>face){
    if( x == 0 && y == 0 && face == 0 ) break ;
    cout << solve(x+dx,y+dy,face) << endl;
  }
  return 0;
}

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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){
    
    ll N;
    cin >> N;
std::map<int, int> m;
    for(int i = 0; i < N-1;i++){
       int a;
        cin >>a;
        m[a]++;
    }
    for(int i = 1; i <= N; i++)
{
    cout << m[i] << endl;
}    return 0;
}



Measured memory_bytes: 12976
n = int(input())
x = list(map(int, input().split(" ")))

y = sorted(x, reverse=True)
mid = int(n / 2) - 1

for i in x:
    if(i >= y[mid]):
        if(mid + 1 != n):
            print(y[mid+1])
        else:
            print(y[mid])
    else:
        print(y[mid])

Measured memory_bytes: 25220
#include <bits/stdc++.h>
#define inf 2147483647
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
int n,m,ck,ans; char arr[103];
main()
{
	scanf("%d",&n);
	scanf("%s",arr);
	for(int i=0;i<n;i++)
	{
		if(arr[i]=='A') ck=1;
		else if(ck==1&&arr[i]=='B') ck=2;
		else if(ck==2&&arr[i]=='C') ck=3;
		else ck=0;
		if(ck==3) ans++;
	} printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	while (1) {
		int n, x;
		int count = 0;
		cin >> n >> x;
		
		if (n == 0 && x == 0) break;
		for (int i = 1; i <= n; i++) {
			for (int j = i+1; j <= n; j++) {
				for (int k = j+1; k <= n; k++) {
					if ((i + j + k) == x) count++;
				}
			}
		}
		cout << count << "\n";
	}

	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)5e5+5
#if !testing
	#define cerr if(0)cout
#endif

int32_t main() {
    IAMSPEED
    //set testing to 0 when submitting on judge
    char x; cin >> x;
 	cout << char(int(x)+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    #define ull unsigned long long
    #define rep(X,N) for(ll X = 0; X < (N); X++)
    #define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
    #define PI (acos(-1.0))
    #define sorta(V) sort(V.begin(), V.end())
    #define pback push_back
    #define mpair make_pair
    #define MODN 1000000007
    #define ALL(V) (V).begin(),(V).end() 


    using namespace std;


    int main(){

        int n,x;
        cin >> n >> x;

        int alldonut = 0;
        int mindonut = INT_MAX;
        int ans = 0;

        rep(i,n){
            int m;
            cin >> m;
            mindonut = min(mindonut, m);
            alldonut += m;
        }

        x = x - alldonut;
        ans = n;

        ans = ans + x / mindonut;

        cout << ans << endl;
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    
    reps(i, 1, n) {
        if (s[i - 1] != s[i]) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

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

    vector<int> vecc = vec;
    sort(vecc.begin(), vecc.end());
    int sakaime = vecc[N/2-1];

    for(int i=0; i<N; i++){
        if(vec[i]>sakaime){
            cout << vecc[N/2-1] << endl;
        }
        else{
            cout << vecc[N/2] << endl;
        }
    }
}

Measured memory_bytes: 4796
r, c = map(int, input().split())
last_list = [0] * (c + 1)
for _ in range(r):
    n = 0
    x = input()
    sum_list = list(map(int, x.split()))
    for i in range(c):
        last_list[i] += sum_list[i]
        n += sum_list[i]
    print(x, n)

last_list[-1] = sum(last_list)
print(*last_list)

Measured memory_bytes: 7608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
#define pi 3.1415926535897
int gcd(int a, int b) {
	if (b != 0) return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	double a, b, h, m; cin >> a >> b >> h >> m;
	double theta0, theta1;
	theta0 = h / 12 + m / 720;
	theta1 = m / 60;
	cout << fixed << setprecision(10) << sqrt(pow(a * sin(theta0 * pi * 2) - b * sin(theta1 * pi * 2), 2) + pow(a * cos(theta0 * pi * 2) - b * cos(theta1 * pi * 2), 2)) << endl;
}

Measured memory_bytes: 4092
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var m = cin.ReadInt;
            var ab = new List<dynamic>();
            for (var i = 0; i < n; i++) {
                var a = cin.ReadInt;
                var b = cin.ReadInt;
                ab.Add(new { a = a, b = b});
            }

            ab = ab.OrderBy(t => t.a).ToList();
            long total = 0;
            long left = m;
            for (var i = 0; i < n; i++) {
                long unit = ab[i].a;
                long num = ab[i].b;

                if (left < num) {
                    total += unit*left;
                    break;
                } else {
                    total += unit*num;
                    left -= num;
                }
            }
            WriteLine(total);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 38512
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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()
{
    int N;
    cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++) cin >> T[i];

    ll t = 1LL;
    for (int i = 0; i < N; i++) t = lcm(t, T[i]);

    cout << t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;

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

	map<ll, int>m;
	vector<pair<ll,int>>min_index;
	ll max_ = 0;
	for (int i = 0; i < n; i++) {
		if (m.find(a[i]) == m.end()) {
			if(max_ < a[i])min_index.push_back(make_pair(a[i], i));
			else min_index.push_back(make_pair(a[i], -1));
			max_ = max(max_,a[i]);
			m[a[i]]=1;
		}else{
			m[a[i]]++;
		}
	}
	sort(min_index.begin(), min_index.end(), greater<pair<ll, int>>());
	vector<pair<ll,ll>>sum;
	for (auto it = --m.end();; it--) {
		sum.push_back(make_pair(it->first,it->second));
		if (it == m.begin())break;
	}

	for (int i = 1; i < sum.size(); i++) {
		sum[i].second += sum[i - 1].second;
	}

	min_index.push_back(make_pair(0,-1));
	sum.push_back(make_pair(0, 0));
	vector<ll>ans(n);
	int j = 0;
	int now = -1;
	for (int i = 0; i < min_index.size()-1; i++) {
		ll tmp = 0;
		while (min_index[i].first != sum[j].first) {
			tmp += sum[j].second * (min_index[i].first - min_index[i + 1].first);
			j++;
		}
		tmp += sum[j].second * (min_index[i].first - min_index[i + 1].first);
		j++;
		if (min_index[i].second != -1) {
			ans[min_index[i].second] = tmp;
			now = min_index[i].second;
		}else{
			ans[now] += tmp;
		}
	}


	for (int i = 1; i <= n; i++) {
		cout << ans[i-1] << endl;
	}
	return 0;
}



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int H, W;
  cin >> H >> W;
  

  VL crt(W+1), nxt(W+1);
  crt[0] = 1;
  REP(y,H){
    fill(ALL(nxt), 0);
    string s;
    cin >> s;

    REP(x,W){
      if(s[x] == '#') continue;
      (nxt[x] += crt[x]) %= MOD;
      (crt[x+1] += crt[x]) %= MOD;
    }

    swap(crt, nxt);
  }

  cout << crt[W-1] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    //-------------------------------------------------------------//
    public static final void main(String[] args) {
        new Main().solve();
    }
    //-------------------------------------------------------------//
    private final Scanner sc = new Scanner(System.in);

    void solve() {
        int N = sc.nextInt();
        long A = sc.nextLong();
        long B = sc.nextLong();
        long[] h = new long[N];
        for (int i = 0; i < N; i++) h[i] = sc.nextLong();
        int low = 0;
        int high = (int)1e9;

        while (low < high - 1) {
            int mid = (low + high) >> 1;
            if (check(mid, h, A, B)) {
                high = mid;
            }
            else {
                low = mid;
            }
        }
        System.out.println(high);
    }

    boolean check(int T, long[] h, long A, long B) {
        long d = 0;
        for (long hh : h) {
            if (hh > B * T) {
                d += (hh - B * T + A - B - 1) / (A - B);
            }
        }
        return d <= T;
    }
}

Measured memory_bytes: 59996
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int x[214514];
double y[214514];
string z[214514];
signed main(){
	ic(n) ic(l)
	rep(0,i,n)cin>>z[i];
	sort(z,z+n);
	rep(0,i,n)cout<<z[i];
}	

Measured memory_bytes: 1920
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    val dice1 = new Dice(StdIn.readLine.split(" ").toList.map(_.toInt))
    val dice2 = new Dice(StdIn.readLine.split(" ").toList.map(_.toInt))

    println(if(dice1.isEqual(dice2)) "Yes" else "No")
  }
}

class Dice(sur: List[Int]){
  private val index: List[Int] = sur

  def findRight(list: List[Int]): Int={
    val dice = new Dice(index)
    val kindOfDices = List[Dice](dice, dice.rotN, dice.rotS, dice.rotW, dice.rotE, dice.rotN.rotN)
    val finddice = for{
      kindOfDice <- kindOfDices
    }yield kindOfDice match{
      case x if(x.getVal(0) == list(0) && x.getVal(1) == list(1)) => x.getVal(2)
      case x if(x.rotR.getVal(0) == list(0) && x.rotR.getVal(1) == list(1)) => x.rotR.getVal(2)
      case x if(x.rotR.rotR.getVal(0) == list(0) && x.rotR.rotR.getVal(1) == list(1)) => x.rotR.rotR.getVal(2)
      case x if(x.rotR.rotR.rotR.getVal(0) == list(0) && x.rotR.rotR.rotR.getVal(1) == list(1)) => x.rotR.rotR.rotR.getVal(2)
      case _ => 0
    }

    finddice.sum
  }

  def isEqual(dice2:Dice): Boolean={
    val dice = new Dice(index)
    val kindOfDices = List[Dice](dice, dice.rotN, dice.rotS, dice.rotW, dice.rotE, dice.rotN.rotN)

    val torf = for{
      kindOfDice <- kindOfDices
    } yield kindOfDice match{
      case x if(x.index == dice2.index) => true
      case x if(x.rotR.index == dice2.index) => true
      case x if(x.rotR.rotR.index == dice2.index) => true
      case x if(x.rotR.rotR.rotR.index == dice2.index) => true
      case _ => false
    }

    torf.foldLeft(false)((a,b) => a || b)
  }

  def getVal(i: Int): Int = index(i)

  def rotR(): Dice =
    new Dice(index).rotS.rotW.rotN

  def rotN(): Dice =
    new Dice(List[Int](index(1), index(5), index(2), index(3), index(0), index(4)))

  def rotS(): Dice =
    new Dice(List[Int](index(4), index(0), index(2), index(3), index(5), index(1)))

  def rotW(): Dice =
    new Dice(List[Int](index(2), index(1), index(5), index(0), index(4), index(3)))

  def rotE(): Dice =
    new Dice(List[Int](index(3), index(1), index(0), index(5), index(4), index(2)))
}

Measured memory_bytes: 43844
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,ans=0;
int main() {
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int z=0;z<=c;z++)
	if(i*500+j*100+z*50==x)ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    final Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int[] dis = new int[n];
    for(int i = 0; i<n; i++){
      dis[i] = sc.nextInt();
    }
    
    int ans = 0;
    int max = dis[0] + k - dis[n-1];
	for(int j = 0; j < n-1; j++){
      if(dis[j+1] - dis[j]>max){
        max = dis[j+1] - dis[j];
      }
    }
    System.out.println(k-max);
  }
}

Measured memory_bytes: 73856
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		var a=sc.Ia;
		var b=sc.Ia;
		var c=sc.Ia;
		long ans=b.Sum();
		for(int i = 0;i<n-1;i++) {
			if(a[i]==a[i+1]-1){ans+=c[a[i]-1];}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

int main() {
  int A, B, C, ans = 0;
  cin >> A >> B >> C;
  if (B >= C) {
    ans += B + C;
  } else {
    ans += 2 * B;
    C -= B;
    if (A >= C) {
      ans += C;
    } else {
      ans += A + 1;
    }
  }
  cout << ans << "\n";
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int array[n + 1];
	int count = 0;
	for (int i = 1; i <= n; ++i)
	{
		cin >> array[i];
	}

	int current = 1;
	bool found = false;
	while (current != 2)
	{
		count++;
		current = array[current];
		if (current == 2) found = true;

		if (count >= n + 5) break;
	}
	if (found) cout << count;
	else cout << -1;


	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>

const std::vector<int> dx{-1, 0, 1, 0}, dy{0, -1, 0, 1};

template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int INF = 1 << 30;

void solve() {
    int h, w;
    std::cin >> h >> w;

    auto xss = vec(h, vec(w, 0));
    for (auto& xs : xss) {
        for (auto& x : xs) {
            std::cin >> x;
        }
    }

    auto dp = vec(h, vec(w, vec(h * w, INF)));
    dp[0][0][0] = 0;

    MinHeap<std::tuple<int, int, int, int>> que;
    que.emplace(dp[0][0][0], 0, 0, 0);

    while (!que.empty()) {
        int d, i, j, l;
        std::tie(d, i, j, l) = que.top();
        que.pop();
        if (d > dp[i][j][l]) continue;

        for (int k = 0; k < 4; ++k) {
            int ni = i + dx[k],
                nj = j + dy[k],
                nl = l + 1;
            if (ni < 0 || h <= ni || nj < 0 || w <= nj || nl >= h * w) continue;

            int nd = d + xss[ni][nj] * (l * 2 + 1);
            if (nd >= dp[ni][nj][nl]) continue;

            dp[ni][nj][nl] = nd;
            que.emplace(nd, ni, nj, nl);
        }
    }

    int ans = *std::min_element(dp[h - 1][w - 1].begin(), dp[h - 1][w - 1].end());
    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}



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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool a = (n % 2 == 0), b = (s[0] == s[n-1]);
    if (a^b) cout << "Second" << endl;
    else cout << "First" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int v[100010];
struct data{
    int id;int num;
    friend bool operator <(const data &a,const data &b) {
        return a.num>b.num;
    }
}
j[100010],
o[100010];
bool cmp(const int &a,const int &b){
    return a>b;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&v[i]);
    for(int i=1;i<=1e5;i++)j[i].id=i,o[i].id=i;
    for(int i=1;i<=n;i++) {
        if(i&1) j[v[i]].num++;
        else o[v[i]].num++;
    }
    sort(j+1,j+100000+1);
    sort(o+1,o+100000+1);
    if(j[1].id==o[1].id) {
        if(j[1].num+o[2].num>j[2].num+o[1].num) printf("%d",max(0,n-j[1].num-o[2].num));
        else printf("%d",max(0,n-j[2].num-o[1].num));
    }
    else printf("%d",max(0,n-j[1].num-o[1].num));
    return 0;
}


Measured memory_bytes: 2176
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nd = readln.split.to!(int[]);
    auto N = nd[0];
    long D = nd[1];
    int c;
    foreach (_; 0..N) {
        auto xy = readln.split.to!(long[]);
        if (xy[0]^^2 + xy[1]^^2 <= D^^2) ++c;
    }
    writeln(c);
}

Measured memory_bytes: 3736
import itertools

n,m,r = map(int,input().split())
wa = [[float("INF")]*n for i in range(n)]
l = [i-1 for i in map(int,input().split())]
for i in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    wa[a][b] = c
    wa[b][a] = c
for i in range(n):
    wa[i][i] = 0

for k in range(n):
    for i in range(n):
        for j in range(n):
            wa[i][j] = min(wa[i][j],wa[i][k]+wa[k][j])

ans = float("INF")

for p in list(itertools.permutations(l)):
    count = 0
    for i in range(r-1):
        count += wa[p[i]][p[i+1]]
    ans = min(ans,count)
print(ans)



Measured memory_bytes: 78424
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){return (y==0)?x:igcd(y,x%y);}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}


//解説参考.
int main(){
	int n,k;
	cin>>n>>k;
	
	vi v(n);
	REP(i,n) cin>>v[i];
	
	int ans=0;
	for(int i=0;i<=min(n,k);++i)for(int j=0;j<=min(n,k);++j){
		if(i+j>n or i+j>k) break;//REP(j).
      
		priority_queue<int,vi,greater<int> > que;
		REP(l,i) que.push(v[l]);
		REP(l,j) que.push(v[n-1-l]);
      
		for(int l=1;l<=k-i-j;++l){
			if(que.empty()) break;//REP(l).
			//debug(que.top());
			if(que.top()<=0) que.pop();
			else break;
		}
      
		int sum=0;
		while(!que.empty()){
			//debug(que.top());
			sum+=que.top();
			que.pop();
		}
      
		//debug(sum);
		chmax(ans,sum);
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque
inf=10**9


def BFS(num):
    color=["white" for _ in range(n+1)]
    D=[inf for _ in range(n+1)]
    queue=deque([num])

    color[num]="gray"
    D[num]=0

    while len(queue)>0:
        u=queue.popleft()
        for i in M[u]:
            if color[i]=="white" and D[u]+1<D[i]:
                D[i]=D[u]+1
                color[i]="gray"
                queue.append(i)
        color[u]="black"

    return D


n,x,y=map(int,input().split())
M=[[] for _ in range(n+1)]
for i in range(1,n):
    M[i].append(i+1)
    M[i+1].append(i)
M[x].append(y)
M[y].append(x)

ans=[0 for _ in range(n-1)]
for i in range(1,n+1):
    for j in BFS(i)[i+1:]:
        ans[j-1] +=1

for i in ans:
    print(i)

Measured memory_bytes: 77236
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CBuildStairs {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = ReadInput.readIntArray(n, in);
            for (int i = 1; i < n; i++) {
                if (a[i] > a[i - 1])
                    a[i]--;
            }
            boolean check = true;
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1]) {
                    check = false;
                    break;
                }
            }
            out.println(check ? "Yes" : "No");
        }

    }

    static class ReadInput {
        public static int[] readIntArray(int size, Scanner in) {
            int a[] = new int[size];
            for (int i = 0; i < size; i++) {
                a[i] = in.nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 48336
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc093_a.cpp
 * time   : Thu Apr 30 18:18:12 2020
 * quest  : A - abc of ABC
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  cout << (s == "abc" ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i < n;i++) a[i] = sc.nextInt();

        Arrays.sort(a);
        for(int i = 0;i < a.length / 2;i++) {
            int tmp = a[i];
            a[i] = a[a.length - 1 - i];
            a[a.length - 1 - i] = tmp;
        }

        double diff = Double.MAX_VALUE;
        double half = (double)a[0] / 2;
        int idx = -1;
        for(int i = 0;i < a.length;i++) {
            double tmpDiff = Math.abs(half - a[i]);
            if(diff >= tmpDiff) {
                diff = tmpDiff;
                idx = i;
            }
        }

        System.out.println(a[0] + " " + a[idx]);
    }
}


Measured memory_bytes: 50656
#include <cstdio>
#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int> G[10010];
vector<int> c(10010, 0);
int num[10010];
bool used[10010];
int now_c = 0;

int dfs(int s) {
    if (used[s]) {
        return 0;
    } else {
        used[s] = true;
    }

    num[s] = c[now_c];
    now_c++;

    for (int i = 0; i < G[s].size(); i++) {
        dfs(G[s][i]);
    }
    return 0;
}

int main() {
    int N,M; cin >> N >> M;
    vector<P> s(N);

    priority_queue<P, vector<P>, greater<>> pq;
    priority_queue<lli> q;
    rep(i,N){
        int a,b;
        cin >> a >> b;
        pq.push(P{a,b});
    }

    lli ans=0LL;
    for(int i=M-1; i>=0; i--){
        P a;
        while(!pq.empty() && pq.top().first+i <= M){
            a=pq.top();
            q.push(a.second);
            pq.pop();
        }

        if(!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 18;

struct Carte
{
	int valeur , posInit;
	bool operator < (const Carte & autre) const
	{
		return valeur < autre.valeur || (valeur == autre.valeur && posInit < autre.posInit);
	}
};

int tab[MAXN][2];
bool estPareil[MAXN];
int N;
int rep = 1e9;
void faire()
{
	vector <Carte> pair;
	vector <Carte> impair;
	for (int i = 0 ; i < N ; i++)
	{
		if ((estPareil[i] + i) % 2 == 0)
		{
			pair.push_back({tab[i][estPareil[i]] , i});
		}
		else
		{
			impair.push_back({tab[i][estPareil[i]] , i});
		}
	}
	if (N % 2 == 0 && pair.size() != impair.size())
	{
		return;
	}
	if (N % 2 == 1 && impair.size() + 1 != pair.size())
	{
		return;
	}

	sort(impair.begin() , impair.end());
	sort(pair.begin() , pair.end());
	int der = -1;
	vector <int> actu;
	for (int i = 0 ; i < N ; i++)
	{
		if (i % 2 == 0)
		{
			if (pair[i / 2].valeur < der)
			{
				return;
			}
			der = pair[i/2].valeur;
			actu.push_back(pair[i/2].posInit);
		}
		else
		{
			if (impair[i/2].valeur < der) return;
			der = impair[i/2].valeur;
			actu.push_back(impair[i/2].posInit);


		}
	}
	int total = 0;
	for (int i = 0 ; i < N ; i++)
	{
		int posActu = 0;
		for (int j = 0 ; j < N ; j++)
		{
			if (actu[j] == i) posActu = j;
		}
		total += abs(i - posActu);
		if (i < posActu)
		{
			while (posActu > i)
			{
				int t = actu[posActu - 1];
				actu[posActu - 1] = actu[posActu];
				actu[posActu] = t;
				posActu--;
			}
		}
		else if (i > posActu)
		{
			while (posActu < i)
			{
				int t = actu[posActu + 1];
				actu[posActu + 1] = actu[posActu];
				actu[posActu] = t;
				posActu++;
			}
		}
	}
	rep = min(rep , total);
}

void recursion(int indice)
{
	if (indice == N)
	{
		faire();
		return;
	}
	estPareil[indice] = false;
	recursion(indice+ 1);
	estPareil[indice] = true;
	recursion(indice + 1);
}
int main()
{
	cin >> N;
	for (int j = 0 ; j < 2 ; j++)
	{
		for (int i = 0 ; i < N ; i++)
		{
			cin >> tab[i][j];
		}
	}

	recursion(0);
	if (rep != 1e9)
	{
		cout<<rep<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 256