akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	cin >> n;
	V<int> a(n);
	RBF(i, a) {
		cin >> i;
	}

	LL ans = 0, pre = 0;
	RBF(i, a) {
		if (i < pre) {
			ans += pre - i;
			i = pre;
		}
		pre = i;
	}

	col(ans);
	return 0;
}

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

int main() {
	// your code goes here
	int b,c;
	cin>>b>>c;
	if(abs(b-c)==2)
	cout<<2;
	else if((b==1||b==2)&&(c==1||c==2))
	cout<<3;
	else
	cout<<1;
}


Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N, T, L, B;
  while(cin>>N>>T>>L>>B && N){
    bool lose[105] = {};
    bool back[105] = {};
    REP(i, L) {
      int k; cin>>k;
      assert(k < 100);
      lose[k] = true;
    }
    REP(i, B) {
      int k; cin>>k;
      assert(k < 100);
      back[k] = true;
    }
    double dp[102][101] = {};
    dp[0][0] = 1;
    REP(t, T){
      REP(x, N)if(dp[t][x] > 0){
        for(int d = 1; d <= 6; d++){
          int next = x + d;
          if(next > N) next = N - (next - N);
          if(lose[next]){
            dp[t + 2][next] += dp[t][x] * 1.0 / 6.0;
          }else if(back[next]){
            dp[t + 1][0] += dp[t][x] * 1.0 / 6.0;
          }else{
            dp[t + 1][next] += dp[t][x] * 1.0 / 6.0;
          }
        }
      }
      //dp[t + 1][N] += dp[t][N];
    }
    double ans = 0;
    REP(t, T) ans += dp[t + 1][N];
    printf("%.10lf\n", ans);
    //cout<<dp[T][N]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1272
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // get value from StandardIn
    int prob = sc.nextInt();
    int post = sc.nextInt();
    int accept = 0;
    int wrong = 0;
    int wrongCount[] = new int[prob];
    boolean result[] = new boolean[prob];
    for(int i=0;i<prob;i++){
      result[i] = false;
      wrongCount[i] = 0;
    }

    int num;
    String res;
    for(int i=0;i<post;i++){
      num = sc.nextInt();
      res = sc.next();
      if(result[num-1] == false && res.equals("AC")){
        result[num-1] = true;
        accept++;
        wrong += wrongCount[num-1];
      }else if(result[num-1] == false && res.equals("WA")){
        wrongCount[num-1] ++;
      }
    }

    System.out.println(accept + " " + wrong);
  }
}


Measured memory_bytes: 63392
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	cout<<s1[0]<<s2[1]<<s3[2]<<endl;
	
	return 0;
}


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

using namespace std;

int main()
{
int n;
cin>>n;
if(n%2==0) cout<<0.5;
double x=n;
double ans=(n/2+1)/x;

if(n%2==1) cout<<setprecision(7)<<fixed<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int c[555][555];
int f[555][555][2];
int main()
{
	//freopen("rabbit.in","r",stdin);
	//freopen("rabbit.out","w",stdout);
	int n=io::F(),M=1000000007;
	for(register int i=0;i<=n;++i)c[i][0]=c[i][i]=1;
	for(register int i=2;i<=n;++i)
		for(register int j=1;j<i;++j)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%M;
	f[1][0][0]=c[n][1];
	f[1][1][0]=c[n][1];
	#define register 
	for(register int i=1;i<n;++i)
		for(register int j=0;j<=i;++j)
			for(register int k=0;k<=1;++k)
				if(f[i][j][k])
				{
					long long F=f[i][j][k];
					for(register int x=0;x+i<=n;++x)
					{
						register int y=x==0?1:0;
						if((x+y^j)&1)++y;
						for(;x+y+i<=n;y+=2)
						{
							int cnt=x+y;
							if(cnt<j)continue;
							int ck=j+(cnt-j)/2,ct=cnt-ck;
							if(abs(ck-x)+cnt+i>n)continue; 
							if(ck>x)
								f[i+cnt][ck-x][k]=(f[i+cnt][ck-x][k]+F*c[n-i][x]%M*c[n-i-x][y])%M;
								else if(ck<x)
									f[i+cnt][x-ck][!k]=(f[i+cnt][x-ck][!k]+F*c[n-i][x]%M*c[n-i-x][y])%M;
									else f[i+cnt][0][0]=(f[i+cnt][0][0]+F*c[n-i][x]%M*c[n-i-x][y])%M;
						}
					}
				}
	printf("%d\n",f[n][0][0]);
	return 0;
}



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


using namespace std;

int main() {

	int n;
	cin >> n;

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

	reverse(a.begin(),a.end());

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

}


Measured memory_bytes: 3104
n=int(input())
X=[]
U=[]
for i in range(n):
    x,u=input().split()
    X.append(float(x))
    U.append(u)
sum=0
for i in range(n):
  if U[i]=='BTC':
    sum+=X[i]*380000.0
  else:
    sum+=X[i]
print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n, a, b;
    cin >> n >> a >> b;
    if( ( b - a ) % 2 ) cout << "Borys";
    else cout << "Alice";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#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++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, m; cin >> n >> m;
    vector<pair<int, bool>> num(n);
    ll ac = 0, wa = 0;
    REP(i, m){
        int number; cin >> number; number--;
        string s; cin >> s;
        if(!num[number].second and s == "AC"){
            num[number].second = true;
            ac++;
            wa += num[number].first;
        }else if(s == "WA" and !num[number].second){
            num[number].first++;
        }
    }
    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
const int MAX = 500000;
const int SENTINEL = 2000000000;
int A[MAX/2 + 1],B[MAX/2 + 1];
int cnt;

void merge(int P[],int alpha,int gamma,int beta){
    int n1 = gamma - alpha;
    int n2 = beta - gamma;
    for (int i = 0; i < n1 ; ++i)A[i] = P[alpha + i];
    for (int i = 0; i < n2 ; ++i)B[i] = P[gamma + i];
    A[n1] = SENTINEL;
    B[n2] = SENTINEL;
    int i=0; int j=0;
    for (int k = alpha; k < beta ; ++k) {
        cnt ++;
        if(A[i] <= B[j]){
            P[k] = A[i];
            i++;
        }else{
            P[k] = B[j];
            j++;
        }
    }
}

void mergesort(int P[],int alpha,int beta){
    if(alpha + 1 < beta){
        int gamma = (alpha + beta)/2;
        mergesort(P,alpha,gamma);
        mergesort(P,gamma,beta);
        merge(P,alpha,gamma,beta);
    }
}

int main (){
    int P[MAX] ,n,i;
    cnt = 0;
    cin >> n;

    for (int i = 0; i < n; ++i)cin >> P[i];

    mergesort(P,0,n);

    for (int i = 0; i < n ; ++i) {
        if (i) cout << " ";
        cout << P[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5064
import copy 

N = int(input())
num = list(map(int, input().split() ))

true_num = copy.deepcopy(num)
true_num = sorted(true_num)

swap_org=[]
swap_true=[]

count=0
for x,y in zip(num,true_num):
    if x != y:
        count += 1
        swap_org.append(x)
        swap_true.append(y)


for i in range(len(swap_org)-1):
    if swap_org[i] == swap_true[i+1] and swap_org[i+1] == swap_true[i]:
            count-=2
if count>0:
    print("NO")
else:
    print("YES")

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> res(N, -1);
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (res[s] != -1 && res[s] != c) {
      cout << -1 << '\n';
      return 0;
    }
    res[s] = c;
  }
  if (res[0] == 0 && N != 1) {
    cout << -1 << '\n';
    return 0;
  }
  if (res[0] == -1) {
    res[0] = N == 1 ? 0 : 1;
  }
  for (int i = 0; i < N; i++) {
    if (res[i] == -1) res[i] = 0;
  }
  for (int r : res) {
    cout << r;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,k; cin >> n >> k;
    string s; cin >> s;
    vl num;
    ll sequence = 1;
    ll cnt = 0;
    rep(i,n){
        if(s[i] == '1'){
            if(sequence==0){
                num.push_back(cnt);
                cnt = 1;
                sequence = 1;
            }
            else cnt++;
        }else{
            if(sequence==1){
                num.push_back(cnt);
                cnt = 1;
                sequence = 0;
            }
            else cnt++;
        }
    }
    num.push_back(cnt);
    vl sum(num.size()+1);
    ll tmp = 0;
    rep(i,num.size()){
        sum[i+1] = tmp + num[i];
        tmp = sum[i+1];
    }
    ll mx = 0;
    ll siz = num.size();
    for(ll i=0; i<siz; i+=2){
        if(i+2*k+1 >= siz){
            mx = max(mx, sum[siz] - sum[i]);
            break;
        }
        mx = max(mx, sum[i+2*k+1] - sum[i]);
    }
    cout << mx << endl;
}

Measured memory_bytes: 2164
#include <iostream>

using namespace std;

int main(void){
	int n, h[101], after[100];
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0;i < n + 1;i++){
			cin >> h[i];
		}
		for(int i = 0;i < n + 1;i++){ // 一つ引き抜く
			int cnt = 0;
			for(int j = 0;j < n + 1;j++){
				if(i != j){
					after[cnt++] = h[j];
				}
			}
			int sub = after[1] - after[0];
			int j = 0;
			for(j = 1;j < n;j++){
				if(sub != after[j] - after[j - 1]){
					break;
				}
			}
			if(j == n){
				cout << h[i] << endl;
				break;
			}
		}


	}
	return 0;
}

Measured memory_bytes: 1160
N = input()

S = 'keyence'
if S == N[:len(S)]:
    ans = 'YES'
elif S == N[-len(S):]:
    ans = 'YES'
else:
    for index in range(len(S)):
        if S[:index] == N[:index] and S[-(len(S) - index):] == N[-(len(S) - index):]:
            ans = 'YES'
            break
    else:
        ans = 'NO'

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
///////////////////

int const N = 2e5 + 41;

int n;
vector<int> a, b, ha, hb;
map<int, int> h, bal;
int x, w[N];
vector<int> e[N];
int ans;

void print(int v){
	cout << v << endl;
	exit(0);
}

int getHash(int v){
	if(h.find(v) == h.end()){
		int val = sz(h);
		h[v] = val;
	}
	return h[v];
}

void read(){
	cin >> n;
	rep(i, 0, n){
		int v;
		cin >> v;
		a.pb(v);
	}
	rep(i, 0, n){
		int v;
		cin >> v;
		b.pb(v);
	}
}

void hashIt(){
	rep(i, 0, n) x ^= (a[i]);
	getHash(x);
	rep(i, 0, n) getHash(a[i]), getHash(b[i]);
}

void checkBad(){
	bal[getHash(x)] = 1;
	rep(i, 0, n){
		++bal[getHash(a[i])];
		--bal[getHash(b[i])];
	}
	rep(i, 0, n){
		if(a[i] == b[i]) continue;
		ha.pb(getHash(a[i]));
		hb.pb(getHash(b[i]));
	}
	int bad = -1;
	for(auto it : bal){
		if(it.second != 0){
			if(bad != -1) print(-1);
			bad = it.first;
		}
	}
	ha.pb(getHash(x));
	hb.pb(bad);
}

void pushEdges(){
	ans = sz(ha);
	rep(i, 0, sz(ha)){
		e[ha[i]].pb(hb[i]);
		e[hb[i]].pb(ha[i]);
	}
}

void dfs(int u){
	if(w[u]) return;
	w[u] = 1;
	for(int to : e[u]) dfs(to);
}

void solve(){
	read();
	hashIt();
	checkBad();
	pushEdges();
	rep(i, 0, sz(ha)){
		if(!w[ha[i]]){
			++ans;
			dfs(ha[i]);
		}
	}
	print(ans - 2);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 22648
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, s; cin >> n >> s;
  v1i v(n+1); rep(i, n) cin >> v[i];
  v2li dp(n+1, v1li(s+1, 0)); dp[0][0] = 1;
  rep(i, n){
    int tmp = v[i];
    rep(j, s+1){
      dp[i+1][j] += dp[i][j]*2;
      dp[i+1][j] %= mod2;
      if(tmp + j <= s){
        dp[i+1][j+tmp] += dp[i][j];
        dp[i+1][j+tmp] %= mod2;
      }
    }
  }
  cout << dp[n][s] << endl;
  return 0;
}

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

int main()
{
    int a,b,c = 0;
    cin >> a >> b >> c;
    int shu = 0;
    if((a==b) && (b==c) && (a==c)){
        shu = 1;
    }
    else if((a==b && b!=c)|| (a==c && c!=b )||(b==c && c!=a)){
        shu = 2;
}
    else{
        shu = 3;
    }
    cout << shu << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug1(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout << #x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pb push_back
#define mp make_pair
#define f first
#define s second

typedef long long ll;
using namespace std;

void readFile() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll binpow(ll a,ll b) {    // a^b
    if(b==0) return 1;
    long long res = binpow(a,b/2);
    if(b%2)
        return res*res*a;
    else
        return res*res;
}

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

    int n;ll d;
    cin >> n >> d;
    int ans{};
    for(int i=0;i<n;i++) {
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;



int main(){
    string S;
    int Q;
    cin>>S>>Q;
    deque<int> Str(S.begin(),S.end());
    int T;
    int FB=1;
    rep(i,Q){
        cin>>T;
        if(T==1) FB=(FB+1)%2;
        else{
            int F;
            char C;
            cin>>F>>C;
            if((FB+F)%2==0) Str.push_front(C);
            else Str.push_back(C);
        }
    }
    if(!FB) reverse(Str.begin(),Str.end());
    for(auto e:Str)cout<<(char)e;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1920
N, D = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(N)]
#print(data)
count = 0
for d in data:
    if d[0]*d[0] + d[1]*d[1] <= D*D:
        count += 1
print(count)
#print(N,D)

Measured memory_bytes: 102380
n=int(input())
h=[int(i) for i in input().split()]
p=-10**101
for i in range(n):
    if p>h[i]:
        if p!=h[i]+1:
            print("No")
            exit()
        else:
            p=h[i]+1
    else:
        p=h[i]
print("Yes")

Measured memory_bytes: 14252
#include <stdio.h>
int a,b,c;
int main(){
  scanf("%d %d %d",&a,&b,&c);
  if((a+b)==c) {
    printf("Yes\n");
  }
  else if((a+c)==b) {
    printf("Yes\n");
  }
  else if((b+c)==a) {
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  


  return 0;
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;

const long long INF = 1e15;

void Main() {
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (int i = 0 ; i < R; i++) {
    cin >> r[i];
  }

  long long d[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }

  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }

  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  sort(r.begin(), r.end());
  long long ans = 1e17;
  do {
    long long tmp = 0;
    for (int i = 1; i < R; i++) {
      tmp += d[r[i - 1] - 1][r[i] - 1];
    }

    ans = min(ans, tmp);
  } while (next_permutation(r.begin(), r.end()));
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
 
int main()
{
  int a,b;
  std::cin >> a >> b;
  int res = 0;
  if(a > b){
    res += a;
    a--;
  }else{
    res += b;
    b--;
  }
  std::cout << res + std::max(a,b) << std::endl;
}

Measured memory_bytes: 256
datalist = {}
Flag = True
for i in range(10000):
    if Flag:
        n = int(input())
        if n == 0:
            Flag = False
        else:
            datalist[i+1] = n
#print(datalist)
for i in range(1, len(datalist)+1):
    print("Case {}: {}".format(i, datalist[i]))



Measured memory_bytes: 6584
N = int(input())
A = sorted(list(map(int,input().split())))
from collections import Counter
c = Counter(A)
# 余剰を計算する

counts = [count-1 for k,count in c.items() if count>1]

if len(counts)>1:
  l,r = counts[0],counts[-1]
  mids = sum(counts[1:-1])
  ## 中間にあるもので打ち消せ無い場合
  if abs(l-r) > mids :
    print(len(set(A)) - (abs(l-r) - mids))
  else:
    print(len(set(A)) - (mids -abs(l-r)) %2 ) 
else:
  print(len(set(A)) - sum(counts)%2 ) 

Measured memory_bytes: 20940
# frozen_string_literal: true
 
# Fenwick Tree
class FenwickTree
  def initialize(arg)
    case arg
    when Array
      @size = arg.size
      @data = Array.new(@size + 1, 0)
      arg.each.with_index(1) { |e, i| add(i, e) }
    when Integer
      @size = arg
      @data = Array.new(@size + 1, 0)
    else
      raise ArgumentError
    end
  end
 
  def add(i, x)
    while i <= @size
      @data[i] += x
      i += (i & -i)
    end
  end
 
  def sum(l, r)
    _sum(r) - _sum(l)
  end
 
  def _sum(i)
    res = 0
    while i > 0
      res += @data[i]
      i &= i - 1
    end
    res
  end
end
 
FeTree            = FenwickTree
BinaryIndexedTree = FenwickTree
 
n, q = gets.split.map { |e| e.to_i }
a    = gets.split.map { |e| e.to_i }
 
ft = FeTree.new(a)
 
q.times do
  t, u, v = gets.split.map { |e| e.to_i }
 
  if t == 0
    ft.add(u + 1, v)
  else
    puts ft.sum(u, v)
  end
end

Measured memory_bytes: 57372
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  string past;
  past = s[0];

  int ans = 1;
  FOR(i, 1, s.size()){
    if(s[i] != s[i-1]) ans++;
    else{
      if(i+2 < s.size()){
        i += 2;
        ans += 2;
      }else if(i+1 < s.size()){
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    char s[101];
    int n,x=0,a=0,i;
    scanf("%d%s",&n,s);
    for(i=0;i<n;i++){
        if(s[i]=='I')x++;
        else x--;
        if(x>a)a=x;
    }
    printf("%d",a);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int Max_n = 200000;

int N;
typedef pair<string, int> P;
map<string, int> kuji;

int main(){
    cin >> N;
    REP(i,N){
        string s;
        cin >> s;
        
        kuji.insert(P(s,0));
    }
    cout << kuji.size() << endl;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = 0; cin >> n;
    ll ac = 0, wa = 0, tle = 0, re = 0;
    rep(i, n) {
        string s; cin >> s;
        if(s == "AC") ac++;
        else if(s == "WA") wa++;
        else if(s == "TLE") tle++;
        else re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

using namespace std;
int main()
{
    int i,j,arr[100001],n,dp[100001],temp1,temp2;
    cin>>n;
    for(i=1;i<=n;++i)
        cin>>arr[i];
    arr[0]=-1;
    dp[0]=-1;
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);

    for(i=3;i<=n;i++)
    {
        temp1=dp[i-1]+abs(arr[i]-arr[i-1]);
        temp2=dp[i-2]+abs(arr[i]-arr[i-2]);
        if(temp2<temp1)
            dp[i]=temp2;
        else
            dp[i]=temp1;

    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);


        int n = sc.nextInt();
        long k = sc.nextLong();
        long[] a = new long[200000];
        long[] aruiseki = new long[200000];
        for (int i = 0; i < n; i++) {
            int tmpa = sc.nextInt();
            int tmpb = sc.nextInt();
            a[tmpa] += tmpb;
        }
        for (int i = 0; i < aruiseki.length; i++) {
            if (i > 0) {
                aruiseki[i] = aruiseki[i-1] + a[i];
                if (aruiseki[i] >= k) {
                    System.out.println(i);
                    break;
                }
            }
        }
        sc.close();
    }


    public static long gcd(Long m, long n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }

    public static long[][] Combination_nCk(long n, long k) {
        n++; k++;
        long[][] ans = new long[(int)n][(int)k];
        for (int i = 0; i < n; i++) {
            ans[i][0] = 1;
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < k-1; j++) {
                if (i < j) {
                    ans[i][j] = 0;
                }else{
                    ans[i+1][j+1] = ans[i][j] + ans[i][j+1];
                }
            }
        }
        return ans;
    }

    public static double[][] Probability_nCk(int n, int k) {
        n++; k++;
        double[][] ans = new double[n][k];
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                ans[i][0] = 1;
            }else{
                ans[i][0] = ans[i-1][0]/2;
            }
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < k-1; j++) {
                if (i < j) {
                    ans[i][j] = 0;
                }else{
                    ans[i+1][j+1] = (ans[i][j] + ans[i][j+1])/2;
                }
            }
        }
        return ans;
    }
}

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

/*********************************/
template<class T> inline ostream& operator<<(ostream& os,vector<T> arr) {os << "["; for(ll i = 0; i < (ll)arr.size(); i++)os << arr[i] << (i == (ll)arr.size() - 1 ? "]" : ",");os << endl;return os;}
template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A,B>& p){os << "{" << p.first << "," << p.second << "}";return os; }
#define prvec(v) cerr<<#v<<": [";for(ll __i = 0;__i < (ll)(v).size(); __i++)cerr<<((v)[__i])<<(__i+1==(ll)(v).size()?"]\n":",");
#define print(x) cerr<<#x<<": "<<(x)<<endl
/*********************************/

int main()
{
	ll n, x, mod; cin >> n >> x >> mod;
	vector<ll> arr(mod, -1); //arr[i]の初出が何項目か
	vector<vector<pair<ll,ll>>> du(D + 1, vector<pair<ll,ll>>(mod));

	for(ll i = 0; i < mod; i++) {
		ll nxt = (i * i) % mod;
		du[0][i].first = nxt;
		du[0][i].second= nxt;
	}

	for(ll i = 0; i < D; i++) {
		for(ll j = 0; j < mod; j++) {
			du[i + 1][j].first = du[i][du[i][j].first].first;
			du[i + 1][j].second= du[i][du[i][j].first].second + du[i][j].second;
		}
	}


	ll sum = x;
	ll pos = x;
	n--;
	for(ll i = 0; i < D; i++) {
		if((1LL << i) & (ll)n) {
			sum += du[i][pos].second;
			pos = du[i][pos].first;
		}
	}
	cout << sum << endl;

}

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

using namespace std;

int main() {
    set<int> st;

    int q;
    cin >> q;
    while (q--) {
        int op, x;
        cin >> op >> x;

        switch (op) {
            case 0:
                st.insert(x);
                cout << st.size() << endl;
                break;
            case 1:
                cout << st.count(x) << endl;
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 12388
#include <iostream>

int main(){
  int a,b;
  while(std::cin >> a >> b, (a|b)){
    [&a,&b] () -> void { if(a > b){ std::swap(a,b); } } ();
    std::cout << a << " " << b << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
    int n, T;
    cin >> n >> T;
    vector<int> c(n), t(n);
    for( int i = 0; i < n; i++ ) cin >> c[i] >> t[i];
    int res = 1e9;
    int j = 1e9;
    for( int i = 0; i < n; i++ ) {
        if( t[i] <= T ) {
            res = min(res, c[i]);
        }
    }
    if( res == j ) {
        dump("TLE");
    }
    else {
        dump(res);
    }
    return 0;  
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cmath>
#include <utility>
#include <queue>

using namespace std;
using ll = long long;

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

    vector<int> s(N);
    vector<int> t(N);
    vector<int> c(N);

    int T = 0;

    for (int i = 0; i < N; ++i) {
        cin >> s[i] >> t[i] >> c[i];
        --c[i];

        T = max(T, t[i]+1);
    }

    vector<vector<int>> v(C, 
        vector<int>(T+1, 0)
    );

    for (int nc = 0; nc < C; ++nc) {
        for (int i = 0; i < N; ++i) {
            if (c[i] == nc) {
                for (int j = s[i]; j <= t[i]; ++j) {
                    v[nc][j] = 1;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < T; ++i) {
        int count = 0;
        for (int nc = 0; nc < C; ++nc) {
            count += v[nc][i];
        }
        ans = max(ans, count);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13568
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

				Scanner s=new Scanner(System.in);
				int n=s.nextInt();

				HashMap<String,Integer>m=new HashMap<>();

				for(int i=0;i<n;++i) {
					char[] c=s.next().toCharArray();
					Arrays.sort(c);
					m.merge(String.valueOf(c),1,Integer::sum);
				}
			System.out.println(m.values().stream().mapToLong(i->(long)(i-1)*i/2L).sum());
    }
}


Measured memory_bytes: 59024
from math import gcd
def eratosthenes(N):
    from collections import deque
    work = [True] * (N+1)
    work[0] = False
    work[1] = False
    ret = []
    for i in range(N+1):
        if work[i]:
            ret.append(i)
            for j in range(2* i, N+1, i):
                work[j] = False
    return ret

# def gcd(a, b):
#     while b != 0:
#         a, b = b, a % b
#     return a

def main():
    N = int( input())
    A = list( map( int, input().split()))
    g = A[0]
    for a in A:
        g = gcd(a, g)
    if g > 1:
        print("not coprime")
        return
    E = eratosthenes(10**3)
    EE = [0]*len(E)
    R = []
    for a in A:
        for i, e in enumerate(E):
            if a%e == 0:
                if EE[i] > 0:
                    print("setwise coprime")
                    return
                EE[i] = 1
            while a%e == 0:
                a //= e
        if a > 1:
            R.append(a)
    R.sort()
    for i in range(len(R)-1):
        if R[i] == R[i+1]:
            print("setwise coprime")
            return
    print("pairwise coprime")
    
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 179944
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
 
typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;
 
bool TEST=false;
ll MOD = 1000000007;
 
void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
 
ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}
 
ll N;
v_ll A;
int main(){
  cin >> N;
  A.assign(N+10,0);
  for (ll i=1;i<=N;i++){
      ll a;cin >> a;
    A[a]=i;
  }
  for (ll i=1;i<=N;i++){
      if (i>1) cout << " ";
      cout << A[i];
  }
  cout << endl;
}

Measured memory_bytes: 1664
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] V = new int[n];
		int[] C = new int[n];
		for(int i = 0; i < n; i++) {
			V[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			C[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(V[i] > C[i]) {
				ans += V[i] - C[i];
			}
		}
		System.out.println(ans);

		sc.close();
	}

}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> ans(N, 0);
  for(int i = 0; i < A.size(); ++i){
    cin >> A[i];
    ans[A[i] - 1] = i + 1;
  }
  for(int i = 0; i < ans.size(); ++i){
    cout << ans[i] << " ";
  }
  cout << endl;
}

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

int main(){
  string S;
  cin >> S;
  if(S == "ABC"){
    cout << "ARC" << endl;
  }
  else{
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3596
#python3

class Problem:
    def __init__(self, status):
        self.status = status
        self.penalties = 0

n,m = map(int, input().split())
data = []
for _ in range(m):
    x, y = map(str, input().split())
    data.append((x, y))

problems = {str(i+1): Problem('-') for i in range(n)}


for number, isAC  in data:
    if problems[number].status == 'AC':
        continue
    else: 
        if isAC == 'AC':
            problems[number].status = 'AC'
        elif isAC == 'WA':
            problems[number].penalties += 1 

cntACproblems = 0
cntPenalties = 0

for problem in problems.values():
    if problem.status == 'AC': 
        cntACproblems += 1
        cntPenalties += problem.penalties

print(str(cntACproblems) + ' ' + str(cntPenalties))
    


Measured memory_bytes: 51280
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#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 PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int a, b;

	cin >> a >> b;

	if ((a + b) % 2 == 0) {
		cout << (a+b)/2 << endl;
	}
	else {
		cout << (a+b)/2+1 << endl;
	}

	return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(ReadLine());
            long[] a = new long[5];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = long.Parse(ReadLine());
            }
            long min = a.Min();
            if (n % min == 0) WriteLine(5 + n / min - 1);
            else WriteLine(5 + n / min);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <math.h>
#include <algorithm>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
#include <iomanip>

int main(void){
    int N;
    double ans = 0.0, A;
    cin >> N;
    
    for(int i = 1; i <= N; ++i){
        cin >> A;
        ans += 1.0 / A;
    }
    ans = 1.0 / ans;
    cout << setprecision(16) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def examD():
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        A, B = LI()
        V[A-1].append(B-1)
        V[B-1].append(A-1)
    C = LI(); C.sort()
    e = 0
    low = 0; up = N-1
    ans = 0; W = [-1] * N
    # 各点の値
    W[e] = C[up]; up -=1
    que = deque()
    que.append(e)
    while que or low<up:
        now = que.popleft()
        if len(V[now])==1 and now!=0:
            W[now] = C[low]
            ans += W[now]
            low +=1
        elif now!=0:
            W[now] = C[up]
            up -= 1
            ans += W[now]
        for ne in V[now]:
            if W[ne] == -1:
                que.append(ne)
    print(ans)
    print(" ".join(map(str,W)))

from string import digits
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


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

int main() {
  int s;
  cin >> s;
  vector<long long> dp(2001,0);
  dp[0]=1;
  for(int i=3;i<2001;i++){
    for(int j=0;j<=i-3;j++){
      dp[i]=(dp[i]+dp[j])%1000000007;
    }
  }
  cout << dp[s] << endl;
  return 0;
}

Measured memory_bytes: 3600
//  RAKSHIT KADAM
// rax_coder
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 3
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning check the size of arrays!!!
// NUMERIC DEFINITIONS :
    #define INF 1000000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define mod 998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll ter; cin>> ter; while(ter--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}

int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
//ll fact[300009];
//ll modIN[100009];
//void facto()
//{
//    ll lim =300005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%mod;
//    }
//
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modInverse(fact[b],mod));
//
//    ret%=mod;
//    ret*=modInverse(fact[a-b],mod);
//    ret%=mod;
//
//    return ret;
//}
//  """""   1LL << x    """""

ll seg[maxn*4];
ll arr[maxn];

void update(ll ind,ll l,ll r,ll pos,ll val)
{
    if(l==r )
    {
        seg[ind]=val;
//        cout<<ind<<" -- "<<val<<endl;
        return ;
    }
    ll mid = l+r>>1;
    if(mid>=pos)
    {
        update(ind*2,l,mid,pos,val);
    }
    else
        update(ind*2+1,mid+1,r,pos,val);
    seg[ind]=max(seg[ind*2],seg[ind*2+1]);

}
ll cnt= 0;
ll query(ll l,ll r,ll ind,ll L,ll R)
{
    if(L>R)return 0;
    if(l>=L && r<=R){return seg[ind];}
    ll mid = l+r>>1;
    ll ret = 0 ;
    ret = max(query(l,mid,ind*2,L,min(R,mid)),query(mid+1,r,ind*2+1,max(L,mid+1),R));
    return ret;
}
void solve()
{
    ll n;cin>>n;ll x;
    ll k;cin>>k;
    ll ans =0;
    for(ll i=1;i<=n;i++)
    {
        cin>>x;
        ll p = query(1,300000,1,max(0LL,x-k),min(x+k,600000LL));
        update(1,1,300000,x,p+1);
        
    }
    cout<<seg[1]<<endl;
}

signed main(){
   Need_for_speed(activated);

//    satisfy
//    {
// solve();
//    }
   
    solve();
    return 0;
}


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


int main() {
	int N, A, B;
	cin >> N >> A >> B;

	int a = 0, b = 0, c = 0;
	for(int i=0;i<N;i++) {
		int p;
		cin >> p;
		if(p <= A) {
			a++;
		}else if(p <= B) {
			b++;
		}else {
			c++;
		}
	}
	cout << min({ a, b, c }) << endl;

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  ll n, m, k;
  cin >> n >> m >> k;
  combination C(n*m);
  mint ans = 0;
  for(ll d = 0; d < m; ++d) ans += d*(m-d)*n*n;
  for(ll d = 0; d < n; ++d) ans += d*(n-d)*m*m;
  ans *= C(n*m-2, k-2);
  cout << ans.x << endl;
}

Measured memory_bytes: 6372