akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{double x,y;};
int main(){
	P p[4];
	while(cin >> p[0].x >> p[0].y){
		bool flag = false;
		rep(i,3)cin >> p[i+1].x >> p[i+1].y;
		
		vector<P> data;
		rep(i,2){data.push_back(p[2+i]);}
		
		P t;
		t.x = p[2].x; t.y = p[3].y; data.push_back(t);
		t.x = p[3].x; t.y = p[2].y; data.push_back(t);
		t.x = p[0].x; t.y = p[1].y; data.push_back(t);
		t.x = p[1].x; t.y = p[0].y; data.push_back(t);

		t.x = p[0].x; t.y = p[3].y; data.push_back(t);
		t.x = p[3].x; t.y = p[0].y; data.push_back(t);
		t.x = p[1].x; t.y = p[3].y; data.push_back(t);
		t.x = p[3].x; t.y = p[1].y; data.push_back(t);

		t.x = p[0].x; t.y = p[4].y; data.push_back(t);
		t.x = p[4].x; t.y = p[0].y; data.push_back(t);
		t.x = p[1].x; t.y = p[4].y; data.push_back(t);
		t.x = p[4].x; t.y = p[1].y; data.push_back(t);
		
		rep(i,data.size()){
			P cur = data[i];
			if( min(p[0].x , p[1].x) <= cur.x && cur.x <= max(p[0].x , p[1].x) ){
				if( min(p[0].y , p[1].y) <= cur.y && cur.y <= max(p[0].y , p[1].y) ){
					if( min(p[2].x , p[3].x) <= cur.x && cur.x <= max(p[2].x , p[3].x) ){
						if( min(p[2].y , p[3].y) <= cur.y && cur.y <= max(p[2].y , p[3].y) ){
							flag = true;
						}
					}
				}
			}
		}
		
		cout << (flag?"YES":"NO") << endl;
		
	}
}
	

Measured memory_bytes: 0
n=int(input())
l=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(l[0]-l[1])
for i in range(2,n):
    dp[i]=min((dp[i-1]+abs(l[i]-l[i-1])),(dp[i-2]+abs(l[i]-l[i-2])))
print(dp[n-1])


Measured memory_bytes: 13980
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
S = list(input())
c = Counter(S)
news = ['N','E','W','S']
sa = set(S)
if sa == {'N','S'} or sa == {'E','W'}:
    print("Yes")
    exit()
for i in range(4):
    if c[news[i]] == 0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef double d;
const int mod=1e9+7;
const int N=2e5+5;
d arr[N];
int main(){
	int n,k;cin>>n>>k;
	d mx=0.0;
	d cur=0.0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		arr[i]=(arr[i]+1.0)/2.0;
	}
	for(int i=0;i<k;i++){
		mx+=arr[i];
	}
	cur=mx;
	for(int i=k;i<n;i++){
		cur-=arr[i-k];
		cur+=arr[i];
		mx=max(mx,cur);
	}
	cout<<setprecision(9)<<fixed<<mx;
	return 0;
}

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


int main(int argc, char const *argv[])
{
	ll n; cin >> n;
	if (n % 2) n *= 2;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int A, B, C, X, Y;
		int cost = 0;
		Scanner in = new Scanner(System.in);

		A = Integer.parseInt(in.next());
		B = Integer.parseInt(in.next());
		C = Integer.parseInt(in.next());
		X = Integer.parseInt(in.next());
		Y = Integer.parseInt(in.next());

		int sum = A + B;
		if (C * 2 < sum) {
			cost += C * 2 * Math.min(X, Y);
			if (X > Y) {
				if (A < 2 * C) {
					cost += A * (X - Y);
				} else {
					cost += C * 2 * (X - Y);
				}
			} else {
				if (B < 2 * C) {
					cost += B * (Y - X);
				} else {
					cost += C * 2 * (Y - X);
				}
			}
		} else {
			cost += A * X + B * Y;
		}

		System.out.println(cost);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    char tmp;
    string s,t;
    cin >> s >> t;
    for(int i = 0;i < s.size();i++)
    {
        if(s == t){cout << "Yes" << endl; return 0;}
        tmp = s[s.size() - 1];
        for(int j = s.size() - 1;j > 0;j--)
        {
            s[j] = s[j - 1];
        }
        s[0] = tmp;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2") 
#pragma GCC optimization ("unroll-loops")

using namespace std;
using ll = long long;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define Ceil(x, y) ((x+y-1)/y)
#define PI acos(-1)
const int mod = (int) 1000000007;



void solve()
{
    string str;
    cin>>str;
    ll ans = 0;
    for(auto i : str)
    {
        ans += (i-'0');
    }
    // cout<<ans;
    cout<<(ans%9 == 0? "Yes" : "No");
}
 

int main(int argc, char *argv[])
{
    clock_t clk_start = clock();
    fast;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    int cases = 1;
    // cin>>cases;
    while(cases--)
    {
        solve();
    }
    cerr<<"Execution Time: "<<fixed<<double(clock() - clk_start)/double(CLOCKS_PER_SEC)<<setprecision(6)<<" sec\n"; 
}


Measured memory_bytes: 3864
char = {"A" => true, "B" => false, "C" => false}
while (swap = gets)
  swap = swap.chomp.split(",")
  char[swap[0]], char[swap[1]] = char[swap[1]], char[swap[0]]
end
if char["A"]
  puts "A"
elsif char["B"]
  puts "B"
else
  puts "C"
end

Measured memory_bytes: 6096
from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
n = int(gcd**0.5) + 2
for i in range(2, n):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if gcd >= n:
    ans += 1
if ans == 1 and gcd != 1:
    ans = 2
    
print(ans)

Measured memory_bytes: 64076
N = int(input())
A = list(map(int, input().split()))
result = 1
d = 0
for i in range(1, N):
  if A[i - 1] == A[i]:
    continue
  if d == 0:
    if A[i - 1] > A[i]:
      d = -1
    else:
      d = 1
  elif d == 1 and A[i - 1] > A[i]:
    d = 0
    result += 1
  elif d == -1 and A[i - 1] < A[i]:
    d = 0
    result += 1
print(result)


Measured memory_bytes: 14252
#include <cstdio>
#include <cctype>
#include <algorithm>
#define MAXIN 1000000
#define gc() (SS==TT&&(TT=(SS=IN)+fread(IN,1,MAXIN,stdin),SS==TT)?EOF:*SS++)
typedef long long LL;
const int N=1e5+5;

int p[N];
LL f[N];
char IN[MAXIN],*SS=IN,*TT=IN;

inline int read()
{
	int now=0;register char c=gc();
	for(;!isdigit(c);c=gc());
	for(;isdigit(c);now=now*10+c-'0',c=gc());
	return now;
}

int main()
{
	int n=read(),E=read(),T=read();
	for(int i=1; i<=n; ++i) p[i]=read();
	LL mn=1e16;
	for(int i=1,j=0; i<=n; ++i)
	{
		while(T<=2*(p[i]-p[j+1])) mn=std::min(mn,f[j]-2*p[j+1]), ++j;
		if(j!=i) f[i]=std::min(f[j]+T,mn+2*p[i]);
		else f[i]=mn+2*p[i];
	}
	printf("%lld\n",f[n]+E);

	return 0;
}

Measured memory_bytes: 2304
def bfs(bug)
  secs = {bug => 0}
  q = [bug]

  while b = q.shift
    return secs[b] if b.split(//).uniq.size == 1

    0.upto(b.size - 2) do |i|
      next if b[i] == b[i + 1]

      bt = b.dup
      bt[i, 2] = 'rgb'.delete(b[i, 2]) * 2
      next if secs[bt]

      secs[bt] = secs[b] + 1
      q.push bt
    end
  end

  'NA'
end

until (bug = gets.chomp) == '0'
  puts bfs(bug)
end

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define maxch(x,y) x=max(x,y)
#define dbg(x) cout<<#x<<"="<<x<<endl

int N;
char cs[100010];
vector<P> rs[100010];
vector<int> idxs[26];
int dp[100010];

int main(){
  cin>>N;
  rep(i,N){
    string S;
    cin>>S;
    cs[i]=S[0];
    idxs[cs[i]-'a'].push_back(i);
  }
  rep(i,26){
    rep(j,idxs[i].size()-1){
      rs[idxs[i][j+1]].push_back(P(idxs[i][j],idxs[i][j+1]));
    }
  }
  rep(i,100001){
    maxch(dp[i+1],dp[i]);
    for(P r : rs[i+1]){
     // dbg(r.fi); dbg(r.se);
      maxch(dp[i+1],dp[r.fi]+(r.se-r.fi));
    }
  }

  cout<<N-dp[100000]<<endl;

  return 0;
}



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

int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a%2==1)
    cout << "No" << endl;
  if (a%2==0){
    for (int i=0;i<a/2;i++){
      if(s[i]!=s[i+a/2]){
          cout << "No" <<endl;
        return 0;
      }
    }
  cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
char button[] ={'w','a','k','s','t','n','h','m','y','r'};
int main(){
	string str;
	cin>>str;
	string ans ="";
	int idx = 0;
	while(idx < str.length()){
		int x = str[idx]-'0';
		// scout <<"x = "<<x<<endl;
		char t = button[x];
		idx++;
		if(x!=0&&x!=1){
			ans +=t;
			if(str[idx]=='T'){
				ans +='a';
			}else if(str[idx]=='U'){
				ans +='u';
			}else if(str[idx]=='L'){
				ans +='i';
			}else if(str[idx]=='R'){
				ans +='e';
			}else if(str[idx]=='D'){
				ans +='o';
			}
		}else if(x==0){
			if(str[idx]=='U'){
				ans +="nn";
			}else if(str[idx]=='D'){
				ans +="wo";
			}else if(str[idx]=='T'){
				ans +="wa";
			}
		}else if(x==1){
			// cout <<"hoge"<<endl;
			if(str[idx]=='T'){
				ans +='a';
			}else if(str[idx]=='U'){
				ans +='u';
			}else if(str[idx]=='L'){
				ans +='i';
			}else if(str[idx]=='R'){
				ans +='e';
			}else if(str[idx]=='D'){
				ans +='o';
			}
		}
		// cout <<"ans = "<<ans<<endl;
		idx++;
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 1196
package main

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

var sc = bufio.NewScanner(os.Stdin)

/*
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
*/
func nextInt() int {
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	return num
}

func main() {
	sc.Split(bufio.ScanWords)
	n, time := nextInt(), nextInt()
	c := make([]int, n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = nextInt()
		t[i] = nextInt()
	}
	ans := 1001

	for i := 0; i < n; i++ {
		if t[i] <= time && c[i] < ans {
			ans = c[i]
		}
	}

	if ans == 1001 {
		fmt.Println("TLE")
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long S = long.Parse(str[0]);
		long W = long.Parse(str[1]);
		string ans = "safe";
		if(W>=S){
			ans = "unsafe";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17912
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <map>


typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple
#define fi first
#define se second


using namespace std;
int const N = 2000;
ll const MOD = 1e9 + 7;
string a[N];
pair<int, int> row[N][N];
pair<int, int> col[N][N];

void rowEval(int h, int w) {
	for (int i = 0; i < h; i++) {
		int j = 0; int l = -1, r = w;
		while (j < w) {
			if (a[i][j] == '#')
				l = j;
			row[i][j].first = l;
			j++;
		}

		j = w - 1;
		while (j >= 0) {
			if (a[i][j] == '#')
				r = j;
			row[i][j].second = r;
			j--;
		}
	}
}

void colEval(int h, int w) {
	for (int i = 0; i < w; i++) {
		int j = 0; int t = -1, b = h;
		while (j < h) {
			if (a[j][i] == '#')
				t = j;
			col[j][i].first = t;
			j++;
		}

		j = h - 1;
		while (j >= 0) {
			if (a[j][i] == '#')
				b = j;
			col[j][i].second = b;
			j--;
		}
	}
}

int main()
{
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		cin >> a[i];
	rowEval(h, w);
	colEval(h, w);
	
	ll ans = -1;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (a[i][j] != '#') {
				ans = max(ans, (row[i][j].second - row[i][j].first - 1ll)
					+ (col[i][j].second - col[i][j].first - 1ll) - 1ll);
			}

	cout << ans;
}


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

using namespace std;

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

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

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

    for (int i = 0; i < n; i++) {
        cout << (i == 0 ? "" : " ") << (a_xor ^ a[i]);
    }
    cout << endl;
}


Measured memory_bytes: 3992
function Main (input) {
  const inputs = input.split(/\s/g).filter((value) => value).map((value) => parseInt(value));
  const types = inputs[0];
  var material = inputs[1];
  const needs = inputs.slice(2);
  var counter = 0;

  // 1種類ずつ作る
  needs.forEach((need) => material -= parseInt(need));
  if (needs < 0) return console.log('%s', counter);
  counter = needs.length;

  // 使えるとこまで使う
  needs.sort((a, b) => a - b);
  needs.forEach((value) => {
    const divid = Math.floor(material / value);
    if (divid < 1) return;
    material -= value * divid;
    counter += divid;
  });

  console.log('%s', counter);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9804
#include <string>
#include <iostream>
#include <vector>
 
int main(){
  std::string strN, strK;
  long long N, K;
  
  std::cin >> strN;
  std::cin >> strK;
  N = std::stol(strN);
  K = std::stol(strK);
  
  long long counter_3 = 0;
  // a > b > cを家庭
  
  // Kの倍数の数を調べる
  long long countK = 0;
  for (long long a=1; a<=N; a++){
      if (a % K == 0)
	      countK++;
  }
  
    	counter_3 += countK * countK * countK;
 
  
  countK = 0;
  if (K%2 == 0){
    for (long long a=1; a<=N; a++){
      if (a % K == K/2)
	      countK++;
    }
    
    	counter_3 += countK * countK * countK;
  }
 
  
  std::cout << counter_3 << std::flush;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int a,b;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> a >> b;
  a %= 2;
  b %= 2;
  cout << (a*b ? "Odd" : "Even") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "


ll dp[3002][3002];
ll a[3002];

ll fnd(ll i, ll j)
{
  if(dp[i][j])return dp[i][j];

  if(i == j)return a[i];
  dp[i][j] =  max(a[i]-fnd(i+1,j),a[j]-fnd(i,j-1));
  return dp[i][j];
}
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n,i;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  cout<<fnd(0,n-1)<<"\n";

  return 0;
}


Measured memory_bytes: 70144
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll a[N];
  REP(i, N) { cin >> a[i]; }
  map<ll, ll> mp;
  REP(i, N) {
    mp[a[i] - 1]++;
    mp[a[i]]++;
    mp[a[i] + 1]++;
  }
  ll ans = 0;
  for (auto x : mp) {
    ans = max(ans, x.second);
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 6912
public class Main{
	public static void main(String[] args){
		//
		String input = new java.util.Scanner(System.in).nextLine();
		String[] words = input.split("\\s");
                int[] data = new int[3];
		for( int i=0; i < words.length; i++ ){
			data[i]  = Integer.parseInt(words[i]);
		}
		for(int i=0; i < data.length -1 ; i++){
			for(int j=0; j < (data.length -1) - i; j++){
				if(data[j] > data[j+1]){
					int temp = data[j];
					data[j] = data[j+1];
					data[j+1] = temp;
				}
			}
		}
		for(int i=0; i < data.length ; i++){
			System.out.print(data[i]);
			if( i != (data.length -1)){
				System.out.print(" ");
			}
		}
		System.out.println();
		//
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n, 0);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x == i + 1) p[i] = 1;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(p[i] == 1){
            if(i + 1 < n) p[i + 1] = 0;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3772
a, b, c, d = input().split()
a = int( a )
b = int( b )
c = int( c )
d = int( d )

while a > 0 and c > 0:
    c = c - b
    if c <= 0:
        print("Yes")
        exit()
    a = a - d
    if a <= 0:
        print("No")
        exit()

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int mod=1000000007;
const int maxn=55;
int n,m,k,dfn[maxn],low[maxn],tot,cnt,c1[maxn],c2[maxn],vis[maxn],C[205][205],pk[55];
vector<int> G[maxn];
stack<pii> stk;
void tarjan(int u,int fa) {
    dfn[u]=low[u]=++tot;
    for (int i=0;i<(int)G[u].size();++i) {
        int v=G[u][i];
        if (v==fa) continue;
        if (!dfn[v]) {
            stk.push(pii(u,v));
            tarjan(v,u);
            low[u]=min(low[u],low[v]);
            if (low[v]>=dfn[u]) {
                ++cnt;
                while (!stk.empty()) {
                    int x=stk.top().first;
                    int y=stk.top().second;
                    stk.pop();
                    if (vis[x]!=cnt) {
                        vis[x]=cnt;
                        ++c1[cnt];
                    }
                    if (vis[y]!=cnt) {
                        vis[y]=cnt;
                        ++c1[cnt];
                    }
                    ++c2[cnt];
                    if (x==u&&y==v) break;
                }
            }
        } else if (dfn[v]<dfn[u]) {
            low[u]=min(low[u],dfn[v]); //
            stk.push(pii(u,v));
        }
    }
}
inline int ksm(int x,int n) {
    int ret=1;
    while (n) {
        if (n&1) ret=1ll*ret*x%mod;
        n>>=1;
        x=1ll*x*x%mod;
    }
    return ret;
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    C[0][0]=pk[0]=1;
    for (int i=1;i<=m+k;++i) {
        C[i][0]=1;
        for (int j=1;j<=i;++j)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    }
    for (int i=1;i<=n;++i) pk[i]=1ll*pk[i-1]*k%mod;
    for (int i=0;i<m;++i) {
        int u,v;scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for (int i=1;i<=n;++i) if (!dfn[i])
        tarjan(i,0);
    int res=1;
    for (int i=1;i<=cnt;++i)
        if (c1[i]>c2[i]) res=1ll*res*k%mod;
        else if (c2[i]==c1[i]) {
            int tmp=0;
            for (int j=1;j<=c1[i];++j)
                tmp=(tmp+pk[__gcd(j,c1[i])])%mod;
            res=1ll*res*tmp%mod*ksm(c1[i],mod-2)%mod;
        } else res=1ll*res*C[c2[i]+k-1][k-1]%mod;
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 3840
def solve():
    for i in range(2, n+1):
        prev1 = dp[i-1]
        prev2 = dp[i-2]
        if i in set:
            continue
        else:
            dp[i] = prev1 + prev2
    return dp[n]


n, m = map(int, input().split())
lst = []
for i in range(m):
    lst.append(int(input()))
set = set(lst)
dp = [0] * (n+1)
dp[0] = 1
if 1 not in set:
    dp[1] = 1
res = solve()
print(res%1000000007)

Measured memory_bytes: 465872
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>
lli t[101][100001];
lli dp(lli val[],int w[],int W,int n)
{
	if(n==0 || W==0)
	   return 0;
	if(t[n][W]!=-1) return t[n][W];
	if(w[n-1]<=W)
		return t[n][W]=max(val[n-1]+dp(val,w,W-w[n-1],n-1),dp(val,w,W,n-1));
	else
	    return t[n][W]=dp(val,w,W,n-1);
}

int main()
{
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);
  memset(t,-1,sizeof(t));
	int n,W;
	cin>>n>>W;
	int w[n];
	lli val[n];
	for(int i=0;i<n;i++)
	   cin>>w[i]>>val[i];
	cout<<dp(val,w,W,n);
	return 0;
}


Measured memory_bytes: 79104
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int n,now,ans = 0;
vector<pair<int,int>> v;

int main(){
 cin >> n;
 rep(i,n){
   ll x,l = 0; cin >> x >> l;
   v.push_back(make_pair(x+l,x-l));
 }

//  rep(i,n){
//   int a = v[i].first;
//   int b = v[i].second;
//   cout << a << b << endl;
// }
 sort(v.begin(),v.end());
 now = -2e9;
//  now = v[0].first;
 ans = 0;

// rep(i,n){
//   int a = v[i].first;
//   int b = v[i].second;
//   cout << a << b << endl;
// }
// rep(i,n-1){
//   if(now > v[i+1].second){
//     ans -= 1;
//   }
// }

	// cout<<ans;
  	for (int i=0;i<n;i++){
		if (v[i].second<now) continue;
		now=v[i].first,ans++;
	}
  cout << ans;


}

Measured memory_bytes: 1400
n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(n):
    b += a[i] * (1-i%2*2)
print(b, end="")
for i in range(n-1):
    b = (a[i] - b//2) * 2
    print(" {}".format(b), end="")
print("")

Measured memory_bytes: 14092
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 2000000;
 
 
int main(void)
{
   int n,rt[MAX];
 
   cin >> n;
   for(int i=0;i<n;i++) cin >> rt[i];
 
   int maxv = -2000000000;
   int minv = rt[0];
 
   for(int i=1;i<n;i++){
     maxv = max(maxv,rt[i] - minv);
     minv = min(minv,rt[i]);
   }
cout << maxv << endl;
return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    ll X, Y;
    cin>>N>>X>>Y;
    --X;
    --Y;
    vec num(N, 0);
    rep(i,N){
        rep(j,i){
            int d = i - j;
            int xi = abs(X - i), xj = abs(X - j), yi = abs(Y - i), yj = abs(Y - j);
            d = min(d, min(xi + yj, xj + yi) + 1);
            ++num[d];
        }
    }
    reps(i,1,N) cout<<num[i]<<endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char rbuf[2800014];
char wbuf[699997];
int rbufl, wbufl;

#define getchar_unlocked() rbuf[rbufl++]
#define putchar_unlocked(c) wbuf[wbufl++]=(c)

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
void printpint(int32_t x){ if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }

int edge[200000][2];

int qmem[400000];

int *e[100001];
int el[100001];

int prev[100001];

int s[100000];
int sl, sr;

int main(void){
	read(STDIN_FILENO, rbuf, sizeof(rbuf));
	int n=nextpint();
	int m=nextpint();
	for(int i=0; i<m; i++){
		int A=nextpint();
		int B=nextpint();
		edge[i][0]=A;
		edge[i][1]=B;
		el[A]++;
		el[B]++;
	}
	int ne=0;
	for(int i=1; i<=n; i++){
		e[i]=&qmem[ne];
		ne+=el[i];
		el[i]=0;
	}
	for(int i=0; i<m; i++){
		int A=edge[i][0];
		int B=edge[i][1];
		e[A][el[A]++]=B;
		e[B][el[B]++]=A;
	}
	int k=0;
	prev[1]=1;
	s[sr++]=1;
	while(sl<sr){
		k++;
		int from = s[sl++];
		for(int i=0; i<el[from]; i++){
			int to = e[from][i];
			if(prev[to]==0){
				prev[to]=from;
				s[sr++]=to;
			}
		}
	}
	if(k==n){
		putchar_unlocked('Y');
		putchar_unlocked('e');
		putchar_unlocked('s');
		putchar_unlocked('\n');
		for(int i=2; i<=n; i++){
			printpint(prev[i]);
		}
		write(STDOUT_FILENO, wbuf, wbufl);
	}else{
		puts("No");
	}
}


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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int M = nextInt();

		int[][] x = new int[M+1][2];
		ArrayList<Integer> from1 = new ArrayList<>();
		ArrayList<Integer> toN = new ArrayList<>();
		for(int i=1;i<x.length;i++){
			x[i][0]=nextInt();
			x[i][1]=nextInt();
			if(x[i][0]==1){
				from1.add(x[i][1]);
			}
			if(x[i][1]==N){
				toN.add(x[i][0]);
			}
		}
		String ans = "IMPOSSIBLE";
		Collections.sort(toN);
		for(int from:from1){
			if(Collections.binarySearch(toN, from)>=0){
				ans="POSSIBLE";
				break;
			}
		}
		System.out.println(ans);
	}



	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 69160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int main() {
  off;
  int t;
  //cin>>t;
  t=1;
  while(t--){  
    int n;
    cin>>n;
    int v[n],c[n];
    for(int i=0;i<n;i++)
      cin>>v[i];
    for(int i=0;i<n;i++)
      cin>>c[i];
    for(int i=0;i<n;i++)
       v[i]-=c[i];
    //sort(v,v+n);
    int sum=0;
    for(int i=n-1;i>=0;i--)
      {
          if(v[i]>=0)
            sum+=v[i];
      } 
     cout<<sum<<'\n';  
  }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 ll gcdExtended(ll a, ll b, ll *x, ll *y) ;
    ll modInverse(ll a, ll m) 
    { 
        ll x, y; 
        ll g = gcdExtended(a, m, &x, &y); 
        // if (g != 1) 
        //     cout << "Inverse doesn't exist"; 
        // else
        // { 
            // m is added to handle negative x 
            ll res = (x%m + m) % m; 
            return res; 
        // } 
    } 
      
    // // C function for extended Euclidean Algorithm 
    ll gcdExtended(ll a, ll b, ll *x, ll *y) 
    { 
        // Base Case 
        if (a == 0) 
        { 
            *x = 0, *y = 1; 
            return b; 
        } 
      
        ll x1, y1; // To store results of recursive call 
        ll gcd = gcdExtended(b%a, a, &x1, &y1); 
      
        // Update x and y using results of recursive 
        // call 
        *x = y1 - (b/a) * x1; 
        *y = x1; 
      
        return gcd; 
    }
ll modu(ll n)
{
    if(n < 0)
    n+=mod;
    else 
    n = n%mod;
    return n;
}
ll power(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
int main()
{
    boost;
    ll n;
    cin>>n;
    ll k = power(10,n,mod);
    ll ans = k;
    k = power(9,n,mod);
    ll z= power(8,n,mod);
    ans = modu(ans -modu(2*k) + z);
    cout<<ans<<"\n"; 
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 1e5 + 5;
LL A[N] , n , Ans;
int main()
{
	scanf("%lld",&n);
	for(int i = 1 ; i <= n ; ++i) scanf("%lld" , &A[i]);
	for(int i = 1 ; i <= n ; ++i)
	{
		if(i > 1 && A[i] && A[i - 1])
		{
			A[i]-- , Ans++;
		}
		Ans += A[i] / 2 , A[i] %= 2;
	}
	cout << Ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define endl "\n" 
#define ll long long 
#define sp " "
#define pi acos(-1)
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	ll q=1;//cin>>q;
	while(q--){
		long double a,b,h,m,big,small,angle,c;cin>>a>>b>>h>>m;
		big =(h+m/60)*(pi/6);
		small=(m)*(pi/30);
		angle=cos(big-small);
		c=sqrt(a*a+b*b-2*a*b*angle);
		cout<<fixed<<setprecision(20)<<c<<endl;
	}
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    string S;
    cin >> S;

    int K;
    cin >> K;

    for(int a = 0; a < K; a++){
        if(S[a] != '1'){
            cout << S[a];
            return 0;
        }
    }

    cout << '1';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

bool bomb[8][8];

void recur(int x, int y)
{
	bomb[y][x] = false;
	int dx[] = { 0, 1, 0, -1 };
	int dy[] = { 1, 0, -1, 0 };

	for (int i = 0; i < 4; ++i)
	{
		for (int j = 1; j <= 3; ++j)
		{
			int tx = x + j*dx[i];
			int ty = y + j*dy[i];
			if (tx >= 0 && ty >= 0 && tx < 8 && ty < 8
				&& bomb[ty][tx])
			{
				recur(tx, ty);
			}
		}
	}
}

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

	for (int l = 1; l <= n; ++l)
	{
		char buf[64];
		cin.getline(buf, sizeof(buf));
		cin.getline(buf, sizeof(buf));
		for (int i = 0; i < 8; ++i)
		{
			cin.getline(buf, sizeof(buf));
			for (int j = 0; j < 8; ++j)
				bomb[i][j] = buf[j] == '1';
		}
		int x, y;
		cin >> x >> y;
		recur(--x, --y);

		printf("Data %d:\n", l);
		for (int i = 0; i < 8; ++i)
		{
			for (int j = 0; j < 8; ++j)
			{
				if (bomb[i][j])
					putchar('1');
				else
					putchar('0');
			}
			printf("\n");
		}
	}

	return 0;
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n,m;
	cin>>n>>m;

	vector<int> d;

	int sum=0;
	for(int i=0; i<n; i++){
		int tmp; cin>>tmp;
		d.push_back(tmp);
		sum +=tmp;
	}

	sort(d.begin(),d.end(),greater<int>());

	for(int i=0; i<m; i++){
		if(d[i]*4*m<sum){
			writeln("No");
			return 0;
		}
	}

	writeln("Yes");
}


Measured memory_bytes: 256
def prime_decomposition(n):
    '''by cocodrips'''
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

n = int(raw_input())
print str(n) + ': '+ ' '.join(map(str,prime_decomposition(n)))

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

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

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

int main() {
    int x,a,ans=10;
    cin>>x>>a;
    if (x<a) ans=0;
    cout<<ans<<endl;
}   

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll a;
	cin>>a;
	cout<<a*a*a<<endl; 
	return 0;
}

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

int n, q, i;
int a[200010];
bool g[200010];
int main()
{
	scanf("%d %d", &n, &q);
	for (i = 1; i <= q; i++)
		scanf("%d", &a[i]);
	for (i = q; i; i--)
	if (!g[a[i]])
	{
		g[a[i]] = 1;
		printf("%d\n", a[i]);
	}
	for (i = 1; i <= n; i++)
		if (!g[i])
		{
			printf("%d\n", i);
		}
	return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    ll nowa,nowb;
    rep(i,n){
        ll t,a;
        cin >> t >> a;
        if(i == 0){
            nowa = t;
            nowb = a;
        }else{
            ll n1 = (t+nowa-1)/t, n2 = (a+nowb-1)/a;
            n1 = max(n1,n2);
            n2 = max(n1,n2);
            nowa = n1 * t;
            nowb = n2 * a;
        }
    }
    cout << nowa + nowb << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	//C問題

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a, b, c;
		String kawaiso = "No";

		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		if (a == b && b == c) {

		} else {
			if (a == b || b == c || a == c) {
				kawaiso = "Yes";
			}
		}

		System.out.println(kawaiso);

	}

}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=3e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int step[maxn];
int a[maxn];
int to_back[maxn];

int main()
{
    int n;
    cin>>n;
    if(n>=30) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3636
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[Max];
ll n;
void solve(){
	cin>>n;
	rep(i,0,n){
		cin>>a[i];
	}
	if(n==1){
		cout<<"Yes";
		return;
	}
	if(a[0]>a[1]){
		if(a[0]-a[1]>1){
			cout<<"No";
			return ; 
		}
		a[0]--; 
	}else{
		a[0]--;
	}
	rep(i,1,n){
		if(a[i]>a[i-1]){
			a[i]--;
		}else if(a[i]<a[i-1]){
			cout<<"No";
			return ;
		}
	}
	cout<<("Yes");
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 1024
// inputに入力データ全体が入る
    function Main(input) {
		var tmp = input.split("");
		var answer = tmp[2] === tmp[3] && tmp[4] === tmp[5] ? 'Yes' : 'No';
		//出力
		console.log(answer);
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

namespace AtCoder {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static long cln(long D = -1) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return long.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			var Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		static string read() { return Console.ReadLine(); }
		#endregion

		static void Main(string[] args) {
			var N = cin();
			var A = cin();
			print(N * N - A);
		}
	}
}


Measured memory_bytes: 13140
program ABC132B
    implicit none
    integer::n,i,ans=0
    integer,allocatable::P(:)
    read*,n
    allocate(P(n))
    read*,P
    do i=1,n-2
        if(P(i+1)/=maxval(P(i:i+2)).and.P(i+1)/=minval(P(i:i+2)))ans=ans+1
    end do
    print'(i0)',ans
end program ABC132B

Measured memory_bytes: 2904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	long long x;
	cin >> x;
	long long ans = 100;
	for (int i=0;;i++) {
		ans *= 1.01;
		if (ans >= x) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    string n;
    cin >> n;
    if(n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;

}

Measured memory_bytes: 3600
n = int(input())
a = list(map(int, input().split()))
a.sort()
now = a[0]
ans = 0
count = 0
for i in range(n):
    if(now != a[i]):
        if(count < now):
            ans += count
        now = a[i]
        count = 0
    count += 1
    if(count > now):
        ans += 1
    if(i == n - 1):
        if(count < now):
            ans += count
print(ans)


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

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var N = int.Parse(Console.ReadLine());
            var dp = Enumerable.Range(0, N + 1).ToArray();
            for (var i = 6; i < N; i *= 6) dp[i] = 1;
            for (var i = 9; i < N; i *= 9) dp[i] = 1;

            for (var i = 1; i <= N; i++) {
                for(var p = 1;p<= i;p *= 6) {
                    dp[i] = Math.Min(dp[i],dp[i - p] + 1);
                }
                for (var p = 1; p <= i; p *= 9) {
                    dp[i] = Math.Min(dp[i], dp[i - p] + 1);
                }
            }
            Console.Write(dp[N]);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, m, cnt = 0;
    cin>>n>>m;
    int a[n+10], b[n+10] = {0};
    f(i,n)cin>>a[i+1];
    f(i,m){
        int x, y;
        cin>>x>>y;
        if(a[x] > a[y])b[y] = 1;
        else if(a[x] < a[y])b[x] = 1;
        else b[x] = 1, b[y] = 1;
    }
    for(int i = 1; i <= n; i++)if(b[i] == 0)cnt++;
    cout<<cnt;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 5168
main=do
 [a,b,k]<-map read.words<$>getLine
 putStrLn$f a b 0 k
f a b i k
 |i==k=(show a)++" "++(show b)
 |even i=f(a`div`2)(b+a`div`2)(i+1)k
 |odd i=f(a+b`div`2)(b`div`2)(i+1)k

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

bool check_mm(int s) {
  if (0 < s && s < 13) return true;
  else return false;
}

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

  string fst = s.substr(0,2);
  string snd = s.substr(2,2);

  if (check_mm(stoi(fst)) && check_mm(stoi(snd))) {
    cout << "AMBIGUOUS" << endl;
  } else if (check_mm(stoi(fst))) {
    cout << "MMYY" << endl;
  } else if (check_mm(stoi(snd))) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

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

	int ans = 0;
	int sum = 0;
	for (int i = 0;i < N;i++) {
		if (s[i] == 'I') {
			sum++;
		}
		else {
			sum--;
		}

		ans = max(ans, sum);
	}

	

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int solve(Int N, Int X, Int D) {
    if (X == 0 && D == 0) return 1;
    if (X == 0 && D != 0) return N * (N - 1) / 2 + 1;
    if (X != 0 && D == 0) return N + 1;
    if (X < 0) X *= -1, D *= -1;
    Int ans = 0;
    Int L = abs(X) * abs(D) / __gcd(abs(X), abs(D));
    Int a = L / X;
    Int b = L / D; // aX == bD == L
    auto f = [&](Int n) { return n * (n - 1) / 2; };
    auto g = [&](Int n) { return n * (N - 1) - f(n); };
    for (int n = 0; n <= N; n++) {
        Int x = f(n);
        Int y = g(n);
        Int t = y - x + 1;
        if (n >= a) {
            // n,[x,y] <-> n-a,[z,w]
            Int z = max(x + b, f(n - a));
            Int w = min(y + b, g(n - a));
            t -= max(0LL, w - z + 1);
        }
        ans += t;
    }
    return ans;
}
int main() {
    Int N, X, D; cin >> N >> X >> D;
    cout << solve(N, X, D) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int cnt = input.nextInt();
        int[] x = new int[cnt];
        int[] y = new int[cnt];
        for(int i = 0; i < cnt; i ++)
            x[i] = input.nextInt();
        for(int j = 0; j < cnt; j ++)
            y[j] = input.nextInt();
        man(x, y);
        euc(x, y);
        min(x, y);
        che(x, y);
    }
    
    public static void man(int[] x, int[] y){
        double sum = 0;
        for(int i = 0; i < x.length; i ++)
            sum += Math.abs(x[i] - y[i]);
        System.out.println(sum);
    }
    
    public static void euc(int[] x, int[] y){
        double d = 0;
        for(int i = 0; i < x.length; i ++)
            d += (x[i] - y[i]) * (x[i] - y[i]);
        d = Math.sqrt(d);
        System.out.println(d);
    }
    
    public static void min(int[] x, int[] y){
        double d = 0;
        for(int i = 0; i < x.length; i ++){
            double dif = Math.abs(x[i] - y[i]);
            d += dif * dif * dif;
        }
        d = Math.pow(d, 1.0 / 3) ;
        System.out.println(d);
    }
    
    public static void che(int[] x, int[] y){
        double max = 0;
        for(int i = 0; i < x.length; i ++){
            double dif = Math.abs(x[i] - y[i]);
            if(dif > max)
                max = dif;
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 26460