akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


int main() {
    Int N,M;
    cin >> N >> M;
    map<Int,int> a;
    vi dp = vi(N+1);
    Int tmp;
    rep(i,M){
        cin >> tmp;
        a[tmp] = 1;
    }

    dp[0]=1;

    rep(i,N+1){
        for(int next = i+1; next <= min(N,i+2); next++){
            if(a[next] != 1){
                dp[next]+=dp[i];
                dp[next]%=1000000007;
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in(),M=in();
	ConnectNodeInfo connect(N);
	vector<int> input(N,0);
	REP(i,N-1+M){
		int u=in()-1,v=in()-1;
		connect.AddDirectionalConnection(u,v,1);
		input[v]++;
	}
	
	stack<int> vertex;
	vector<int> sorted;
	REP(i,N){
		if(input[i]==0){
			vertex.push(i);
			break;
		}
	}
	while(!vertex.empty()){
		auto v=vertex.top();
		vertex.pop();
		sorted.push_back(v);
		for(auto& x:connect[v]){
			input[x.first]--;
			if(!input[x.first]) vertex.push(x.first);
		}
	}
	vector<int> parent(N,-1);
	REP(i,N){
		for(auto& x:connect[sorted[i]]){
			parent[x.first] = sorted[i];
		}
	}

	for(auto& x:parent){
		out(x+1);
	}
	return 0;
}


Measured memory_bytes: 7672
#include <stdio.h>
#include <limits.h>

int cnt = 0;

void merge(int *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    for (int i=0; i<n1; i++)
        L[i] = A[left+i];
    for (int i=0; i<n2; i++)
        R[i] = A[mid+i];
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    int i = 0, j = 0;
    for (int k=left; k<right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int *A, int left, int right) {
    if (left+1 < right) {
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int n, a[500001];
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", a+i);
    mergeSort(a, 0, n);
    for(int i=0; i<n; i++) {
        printf("%d", a[i]);
        if (i<n-1) putchar(' ');
    }
    puts("");
    printf("%d\n", cnt);
}


Measured memory_bytes: 5632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputDataList = new LinkedList<String>();
        String input = null;

        try {
            while ((input = in.readLine()) != null) {
                inputDataList.add(input);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        for (String inputDataStr : inputDataList) {
            System.out.println(findPrimeNumber(inputDataStr));
        }
    }

    private static int findPrimeNumber(String inputDataStr) {

        int inputData = Integer.parseInt(inputDataStr);
        int count = 0;

        //エラー回避のため、1以下の値は一律0を返す。
        if(inputData < 2) {
            return 0;
        }

        //2〜入力値までの素数判定用フラグ格納配列 true : 素数である。 false : 素数でない。
        boolean[] isPrimeNumber = new boolean[inputData + 1];

        //1は素数でないので、2から探索
        for(int i = 2; i <= inputData; i++) {

            //素数ならば次の数へ
            if(isPrimeNumber[i]) {
                continue;
            }

            count++;

            //iの倍数のフラグをtrueに変更
            for(int j = i * 2; j <= inputData; j = j + i) {
                isPrimeNumber[j] = true;
            }
        }
        return count;
    }
}

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

int main(){
    int s=672*671,t;
    long long L,R;
    scanf("%lld %lld",&L,&R);
    if(R-L>672){
        printf("0\n");
        exit(0);
    }
    for(long long i=L;i<R;i++){
        for(long long j=i+1;j<=R;j++){
            t=(i*j)%2019;
            if(t<s){
                s=t;
            }
        }
    }
    printf("%d\n",s);
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
//#include<windows.h>


using namespace std;



#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9 + 7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;




int main() {
	int h, w;
	cin >> h >> w;
	char a[110][110];
	for (int i = 0; i < h ; i++) {
		for (int i2 = 0; i2 < w; i2++) {
			cin >> a[i][i2];
		}
	}
	cout << string(w+2, '#') << endl;
	for (int i = 0; i < h; i++) {
		cout << "#";
		for (int i2 = 0; i2 < w; i2++) {
			cout << a[i][i2];
		}
		cout << "#" << endl;
	}
	cout << string(w+2, '#') << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int a,b,c; cin >> a >> b >>c;
    int ans = 0;
    
    if(a < (b+c)) ans = c - (a-b);

    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i], --a[i];

    int idx = 0;
    int cnt = 0;
    rep(i, n) {
        idx = a[idx];
        ++cnt;
        if (idx == 1) {
            cout << cnt << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#define MAX 200000

int max(int a, int b) {
  return (a > b) ? a : b;
}

int min(int a, int b) {
  return (a < b) ? a : b;
}

int main() {
  int i, n, R[MAX], maxv, minv;

  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &R[i]);

  maxv = -1e+9;
  minv = R[0];
  for (i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

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

  return 0;
}


Measured memory_bytes: 2560
//Name : Rupa Dey
  //Date : 24 August 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gap " ";
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string str;
    int cnt=0,i;
    cin>>str;
     if(str[0]=='R' && str[1]=='R' && str[2]=='R') cnt=3;
     else if((str[0]=='R' && str[1]=='R') ||(str[1]=='R' && str[2]=='R')) cnt=2;
     else if((str[0]=='R' && str[1]=='S')||(str[1]=='S' && str[2]=='R')) cnt=1;
     else if((str[0]=='S' && str[1]=='R')||(str[1]=='R' && str[2]=='S')) cnt=1;

    cout<<cnt<<endl;

}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


Measured memory_bytes: 3636
data = [
    "{0} {1}".format(s, r)
    for s in ('S', 'H', 'C', 'D')
    for r in range(1, 13 + 1)
    ]

count = int(input())
for c in range(count):
    card = input()
    data.remove(card)

for c in data:
    print(c)

Measured memory_bytes: 7668
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(x);
        cout << (x>=30 ? "Yes" : "No") << endl;

//        cout << "Case #" << t << ": " << endl;
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3572
n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,x):
  if n==0:
    return 0 if x<=0 else 1
  elif x<=a[n-1]+1:
    return f(n-1,x-1)
  else:
    return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(n,x))

Measured memory_bytes: 3064
package main
import (
    "fmt"
)

func main() {
    var (
        n     int
        count int
    )
    fmt.Scan(&n)
    nums := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&nums[i])
    }

    flag := true
    for flag {
        for i := 0; i < n; i++ {
            if nums[i]%2 == 0 {
                nums[i] /= 2
            } else {
                flag = false
            }
        }
        if flag {
            count++
        }
    }
    fmt.Println(count)
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 2000000;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    ll K;
    cin >> K;

    int m = 0;
    for (int i = 1; i <= MAX; ++i) {
        m = m * 10 + 7;
        if (m % K == 0) {
            cout << i << endl;
            return 0;
        }
        m %= K;
    }

    cout << -1 << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 110;
int dp[maxn][maxn];
int main()
{
    int n;
    cin>>n;
    for (int k = 0; k <=9 ; ++k) {
        dp[1][k]=1;
    }
    for (int i = 2; i <=10 ; ++i) {
        for (int j = 0; j <=9 ; ++j) {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
        }
    }
    queue<int> que;
    int l=0, r = 0, flag=0;
    for (int j = 1; j <=10 ; ++j) {
        for (int i = 1; i <=9 ; ++i) {
            if(n<=dp[j][i]){
                l=j;
                r=i;
                flag=1;
                break;
            }
            n-=dp[j][i];
        }
        if(flag==1)break;
    }
    l--;
    que.push(r);
    while(l!=0){
        if(n<=dp[l][r-1]){
            r--;
            que.push(r);
        }else{
            n-=dp[l][r-1];
            if(n<=dp[l][r]){
                que.push(r);
            }else{
                n-=dp[l][r];
                r++;
                que.push(r);
            }
        }
        l--;
    }
    while(!que.empty()){
        int now=que.front();
        cout<<now;
        que.pop();
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
  long long N, A, B;
  cin >> N >> A >> B;
  long long  t = N / (A + B);
  long long  mod = N % (A + B);
  long long ans = t * A;
  ans += (A > mod) ? mod : A;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [''] * N
for i in range(N):
  s[i] = input()
M = int(input())
t = [''] * M
for i in range(M):
  t[i] = input()
  
p = {si: s.count(si) for si in set(s)}
for ti in t:
  if ti in p:
    p[ti] -= 1
print(max(max(p.values()), 0))


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <map>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    map<int, int> m;

    for (int i = 0; i < N; i++)
    {
        int A;
        if (scanf("%d", &A) < 1) return 0;
        m[A]++;
    }

    printf("%u\n", m.size() % 2 ? m.size() : m.size() - 1);
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>

using namespace std;

int main()
{
    int i,n,p=0;
    cin>>n;
    for(i=1; i<=n/i; i++)
        if(n%i==0&&i<=9&&n/i<=9)
        {
            p=1;
            cout<<"Yes"<<endl;
            break;
        }
    if(p==0)
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc008/tasks/agc008_a



x, y = gets.split.map(&:to_i)

button_a = (x.abs - y.abs).abs

button_b = if x < y
             if x * y >= 0
               0
             else
               1
             end
           else
             if x * y == 0
               1
             elsif x * y > 0
               2
             else
               1
             end
           end

puts button_a + button_b


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

int main(){

// cout
int a,b,c,d;
// string s;
cin >> a >> b >> c;
d = a*b*c;


if(1<=a && a <=10){
if(1<=b && b <=10){
if(1<=c && c <=10){


	if(d == 25*7){
		cout << "YES";
	}else{
		cout << "NO";
	}
	// cin >> b >> c;
	// cin >>s;


	// cout << (a+b+c) <<" "<< s<<endl;
}
}
}

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;

int main(){
	stack<int> s;
	int a;
	while	( scanf(" %d", &a) != EOF ){
		if(a==0) {
			cout << s.top() << endl;
			s.pop();
		}
		else s.push(a);
	}
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,K; cin >> N >> K;
    VI V(N); REP(i,N) cin >> V[i];

    int ans = 0;
    REP(z,K+1){
        REP(i,z+1){
            REP(j,z-i+1){
                priority_queue<int,VI,greater<int>> q;
                int tmp = 0;
                REP(k,min(j,N)){q.push(V[k]); tmp += V[k];}
                int right = N-min(j,N);
                REP(k,min(z-i-j,right)){q.push(V[N-1-k]); tmp += V[N-1-k];}
                REP(k,i) if(q.size()){tmp -= q.top(); q.pop();}
                chmax(ans, tmp);
            }
        }
    }

    cout << ans << en;
    return 0;
}

Measured memory_bytes: 256
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	string s,t;
	cin>>s>>t;
	int res=0;
	rep(i,3) if(s[i]==t[i]) res++;
	cout<<res<<endl;
	return 0;
}

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

int par[100010];
int rnk[100010];

void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return (par[x] = find(par[x]));
    }
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (rnk[x] < rnk[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if (rnk[x] == rnk[y])
            rnk[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

signed main()
{
    int n, m;
    int x[100000], y[100000], z[100000];
    cin >> n >> m;
    for (int i = 0; i < m; i++)
        cin >> x[i] >> y[i] >> z[i];

    init(n + 1);
    for (int i = 0; i < m; i++)
    {
        unite(x[i], y[i]);
    }

    int cnt = 0;
    /*
    for (int i = 1; i <= n; i++)
    {
        if (par[i] == i)
        {
            cnt++;
        }
        else
        {
            par[i] = par[par[i]];
        }
    }
    */
    int arr[100001] = {};
    set<int> s;
    for (int i = 1; i <= n; i++)
    {
        arr[i] = find(i);
        s.insert(arr[i]);
    }
    cout << s.size() << endl;
    // cout << cnt << endl;
}

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

using namespace std;
typedef long long ll;

#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))
#define all(v) v.begin(), v.end()
#define mp make_pair
#define ff first
#define ss second

const int mod = 1e9 + 7;

bool is_p(int x) {
    string s;
    stringstream ss;
    ss << x;
    ss >> s;
    string t(s.rbegin(), s.rend());
    return t == s;
}

int main() {
    // Code here:

    int a, b;
    cin >> a >> b;

    int ans = 0;
    forrn(i, a, b + 1) {
        ans += is_p(i);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
from heapq import heappop as pop
from heapq import heappush as push

INF = 10 ** 18

class edge:
  def __init__(self, to, cost):
    self.to = to
    self.cost = cost

V, E, r = map(int,input().split())

G = [[] for i in range(V)]
#G[i]...頂点iからの辺、(行き先、コスト)
d = [0 for i in range(V)]
#d[i]...スタートからみた頂点iまでの最短距離

def dijkstra(s, V):
  que = []
  global d
  global G
  d = [INF for i in range(V)]
  d[s] = 0
  push(que, (0,s))

  while len(que):
    p = pop(que)
    v = p[1]
    if (d[v] < p[0]):
      continue
#    print(p)
    for i in range(len(G[v])):
      e = G[v][i]
      if d[e.to] > d[v] + e.cost:
        d[e.to] = d[v] + e.cost
        push(que, (d[e.to], e.to))

for i in range(E):
  s, t, c = map(int,input().split())
  G[s].append(edge(t,c))
dijkstra(r, V)

for i in range(V):
  if d[i] != INF:
    print(d[i])
  else:
    print("INF")


Measured memory_bytes: 140088
w = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
s = gets.chomp
a, b = s[0..1].to_i, s[2..3].to_i
puts w[((a > 0 && a < 13) ? 2 : 0) + ((b > 0 && b < 13) ? 1 : 0)]


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k,l; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	cin >> n;
	vector<int>v(n); vector<int>c(n); vector<int>k(n);
	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		cin >> c[i];
	}
	rep(i, n) {
		k[i] = v[i] - c[i];
	}
	sort(k.begin(),k.end(),greater<int>());
	int res = 0;
	rep(i, n) {
		int hoge = res + k[i];
		chmax(res, hoge);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S=  sc.next();

        List<Integer> list = new ArrayList<>();
        List<Character> list01 = new ArrayList<>();
        char prev = S.charAt(0);
        int count =1;
        for (int i = 1; i < S.length(); i++) {
            char c = S.charAt(i);
            if(prev==c){
                count++;
            }else{
                list.add(count);
                list01.add(prev);
                count=1;
            }
            prev=c;
        }
        list.add(count);
        list01.add(prev);

        if(list01.get(0)=='0'){
            list.add(0,0);
        }
        if(list01.get(list01.size()-1)=='0'){
            list.add(0);
        }
        int ans=0;
        int width = 2*K+1;

        //TLE  n^2
//        for (int i = 0; i < list.size() ; i=i+2) {
//            int len = 0;
//            for (int j = i; j <= Math.min( width+i-1,list.size()-1) ; j++) {
//                len += list.get(j);
//            }
//            ans = Math.max(ans,len);
//        }

        //尺取り
        int left =0;
        int right =0;
        int temp = 0;
        for (int i = 0; i < list.size() ; i=i+2) {
            int nextleft = i;
            int nextright = Math.min(i+width-1,list.size()-1) ;
            while(left<nextleft){
                temp -= list.get(left);
                left++;
            }
            while(right<=nextright){
                temp += list.get(right);
                right++;
            }
            ans = Math.max(ans,temp);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 26684
main :: IO ()
main = do
  n <- readLn
  s <- getLine
  putStrLn $ if solve n s then "Yes" else "No"

solve :: Int -> String -> Bool
solve n s
  | odd n     = False
  | s1 == s2  = True
  | otherwise = False
  where
    (s1, s2) = splitAt (n `div` 2) s

Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;

ll sqr (ll x) {return x * x;}

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (c - a - b <= 0)
		cout << "No" << endl;
	else if (4 * a * b < sqr (c - a - b))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N,C,K = map(int,input().split())
A = []
for i in range(N):
  temp = int(input())
  A.append(temp)
A.sort()
ans = 1
nxt = A[0]+K
cus = 0
for i in range(N):
  if A[i] <= nxt and cus < C:
    cus +=1
    continue
  else:
    nxt = A[i]+K
    cus = 1
    ans += 1
print(ans)

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

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  bool cleared[110000];
  int wa[110000];
  for(int i=0;i<n;++i){cleared[i]=false;wa[i]=0;}
  int p[110000];string s[110000];
  for(int i=0;i<m;++i){cin>>p[i]>>s[i];--p[i];}
  
  int ac=0,pe=0;
  for(int i=0;i<m;++i){
    if(s[i]=="AC"){
      if(cleared[p[i]])
        continue;
      ++ac;
      cleared[p[i]]=true;
    }else{
      if(!cleared[p[i]]){
        ++wa[p[i]];
      }
    }
  }
  pe=0;
  for(int i=0;i<n;++i){
    if(cleared[i])
      pe+=wa[i];
  }
  
  cout<<ac<<" "<<pe;
  
  return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;



void solve(){

    double l;
    cin >> l;
    cout << setprecision(12) << pow(l/3.0, 3) << endl;

}

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
int x[120];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>x[i];
	int res=1e9;
	int cand;
	for(int i=0;i<=100;i++){
		cand=0;
		for(int j=1;j<=n;j++)
			cand+=(x[j]-i)*(x[j]-i);
		res=min(res,cand);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder {
    class Program {
        static void Main() {
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = input[0], m = input[1], x = input[2];
            var a = new int[n][];
            for(int i = 0; i < n; i++) {
                a[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }
            int min = int.MaxValue;
            for(int bit = 1; bit < 1 << n; bit++) {
                int cost = 0;
                var point = new int[m];
                for(int i = 0; i < n; i++) {
                    if((bit & 1 << i) != 0) {
                        cost += a[i][0];
                        for(int j = 0; j < m; j++) {
                            point[j] += a[i][j + 1];
                        }
                    }
                }
                if(point.All(p => p >= x)) {
                    min = Math.Min(min, cost);
                }
            }
            Console.WriteLine(min == int.MaxValue ? -1 : min);
        }
    }
}

Measured memory_bytes: 28584
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define pop(v) (v).back(); (v).pop_back()
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    lint n, ans=0;
    cin>>n;
    vector<lint> v(n);
    rep(i, n) cin>>v[i];
    tsort(v);
    while(siz(v)){
        ans += pop(v);
        if(!siz(v))break;
        ans -= pop(v);
    }
    co(ans);
}

Measured memory_bytes: 256
def main():
    N = input()
    str_num = input()
    num_list = str_num.split()
    
    if '0' in num_list:
        print(0)
        return
    
    answer = 1
    for num in num_list:
        answer *=int(num)
        if answer > 10**18:
            answer = -1
            break

    print(answer)

main()

Measured memory_bytes: 19288
//boom diggy diggy boom boom
/*
freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      */
#include<bits/stdc++.h>
#define ull unsigned long long int 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define ll long long 
#define ld long double 

int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n,int r){int res=1;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}int max(int a,int b){int ans=a>b?a:b;return ans;}

using namespace std;

int main()
{
 int n,k;
 cin>>n>>k;
 ll a[n+1],b[n+1]={};
 for (int i = 1; i <= n; ++i)
    {
      cin>>a[i];
    }   
  for (int i = 2; i <= n; ++i)
  {
    b[i]=100000000000000000;
    ll t=k;
    for (int j = i-1; j >=1 ; --j)
    {
      if(!t)break;
      ll x=abs(a[i]-a[j])+b[j];
      b[i]=min(b[i],x);
      t--;
    }
  }
  
  cout<<b[n];
  
return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#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 MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int N,K;
    cin>>N>>K;
    VI x(N),y(N);
    REP(i,N)cin>>x[i]>>y[i];
    V<pair<double,double>> ch;
    REP(i,N){
        FOR(j,i+1,N){
            if(x[i]!=x[j]){
                int a=y[i]-y[j];
                int b=x[i]-x[j];

                int c=x[i]*y[j]-x[j]*y[i];
                int d=x[i]-x[j];

                double aa=1.0*a/b;
                double bb=1.0*c/d;
                ch.push_back({aa,bb});
            }
        }
    }
    sort(All(ch));

    int c_max=0;
    REP(i,ch.size()){
        int ff=0;
        FOR(j,i+1,ch.size()){
            if(ch[i]!=ch[j]){
                c_max=max(c_max,j-i);
                i=j-1;
                ff=1;
            }
        }
        if(!ff){
            c_max=max(c_max,(int)ch.size()-i);
            break;
        }
    }

    int k=K*(K-1)/2;
    if(k<=c_max){
        cout<<1<<endl;
        return 0;
    }

    map<int,int> cnt2;
    REP(i,N)cnt2[x[i]]++;
    for(auto p:cnt2)if(K<=p.S){
        cout<<1<<endl;
        return 0;       
    }

    cout<<0<<endl;



}





Measured memory_bytes: 134056
import math

def is_prime(x):
  if(x <= 1):
    return False
 
  for i in range(2, int(math.sqrt(x))):
    if(x % i == 0):
      return False

  return True

x = int(input())
while is_prime(x) is False:
  x += 1

print(x)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	vi p(n);
	rep(i,n)cin>>p[i];
	int ans=0;
	for(int i=1;i<n-1;i++){
		if(p[i-1]<p[i]&&p[i]<p[i+1]) ans++;
		else if(p[i+1]<p[i]&&p[i]<p[i-1]) ans++;
	}
	cout<<ans<<endl;


	return 0;
}



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

ll mylcm(ll a, ll b){
  ll tmp, r;
  ll x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  return (x/b);
}


int main(void){
    ll a, b;
    //string s, t;
    cin >> a >> b;
    
    ll x = mylcm(a, b);

    std::cout << x << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long

const int NMAX = 1000005;
bool sieve[NMAX];
map <int, int> factors;

void factorize(int x){
	while(x>1){
		for(int i=2; i<NMAX; i++){
			if(!sieve[i] and x % i == 0){
				x /= i;
				factors[i]++;
				break;
			}
		}
	}
}

signed main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	
	for(int i=2; i<NMAX; i++){
		if(!sieve[i]){
			for(int j=2*i; j<NMAX; j+=i)
				sieve[j] = 1;
		}
	}

	for(int i=2; i<=n; i++){
		factorize(i);
	}

	int no_of_4, no_of_2, no_of_24, no_of_74, no_of_14;
	no_of_2 = no_of_4 = no_of_24 = no_of_74 = no_of_14 = 0;
	for(auto it=factors.begin(); it!=factors.end(); it++){
		if(it->second >= 2 and it->second < 4)
			no_of_2++;
		else if(it->second >= 4 and it->second < 14){
			no_of_2++;
			no_of_4++;
		}else if(it->second >= 14 and it->second < 24){
			no_of_2++;
			no_of_4++;
			no_of_14++;
		}else if(it->second >= 24 and it->second < 74){
			no_of_2++;
			no_of_4++;
			no_of_14++;
			no_of_24++;
		}else if(it->second >= 74){
			no_of_2++;
			no_of_4++;
			no_of_14++;
			no_of_24++;
			no_of_74++;
		}

	}

	lli ans = no_of_74;
	ans += no_of_24 * (no_of_2 - 1);
	ans += no_of_14 * (no_of_4 - 1);
	ans += no_of_4 * (no_of_4 - 1) / 2 * (no_of_2 - 2);

	cout << fixed << ans;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
vvl v;
vl vis,d;

int main() {
    IOS;
    cin>>x>>y>>z;
    cout<<min(x*y,z);
    return 0;
}


Measured memory_bytes: 764
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
signed main(void)
{
	int n;cin>>n;
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9)
		puts("hon");
	else if(n==0||n==1||n==6||n==8)
		puts("pon");
	else
		puts("bon");
	return 0;
}




Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
const int NUM=15;
int num[NUM];
bool vis[NUM];
void dfs(int i);
int main()
{
    int test;
    scanf("%d",&test);
    while(test--)
    {
        int ans=0;
        memset(vis,0,sizeof vis);
        for (int i=0; i<10; i++)
            scanf("%d",&num[i]);
        /*for (int i=0; i<10; i++)
        {
            if (!vis[i])
            {
                vis[i]=1;
                ans++;
                dfs(i);
            }
        }
        if (ans==1||ans==2)
            printf("YES\n");
        else
            printf("NO\n");*/
        int l=0,r=0,flag=1;
        for(int j=0; j<10; j++)
        {
            if(l<num[j])l=num[j];
            else if(r<num[j])r=num[j];
            else flag=0;
            if(flag==0)break;
        }
        if(flag)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}
/*void dfs(int i)
{
    for (int j=i+1; j<10; j++)
    {
        if (!vis[j]&&num[j]>=num[i])
        {
            vis[j]=1;
            dfs(j);
        }
    }
}*/



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

int main(void){
	int a;
	cin >> a;
	int result;
	result = a + a*a + a*a*a;
	cout << result << endl;

return 0;
}


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


#define pb push_back
#define ff first 
#define ss second
#define endl "\n"
#define all(v) v.begin(),v.end();
#define rall(v) v.rbegin(),v.rend();


// make it python 

#define gcd __gcd
#define append push_back
#define str to_string
#define upper(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define lower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define sum(arr) {auto ans=0, for auto i: arr  ans+=i ; return ans}
#define minA(arr) {auto ans=arr[0] for auto i:arr ans= min(ans,i); return ans }
#define maxA(arr) {auto ans= arr[0] for auto i:arr ans= max(ans,i); return ans}
#define print(arr) for(auto el: arr) cout<<el<<" ";cout<<endl


// utility functions shortcuts

#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)


// declaration shortcuts

#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>> 
#define pp pair<ll,ll>
#define ppp pair<ll,pp>
#define ull unsigned long long
#define ll long long




// constants 

#define PI  3.1415926358
const int MAX= int(1e9)+1;
const int MOD =int(1e9)+7;
const ll INF = 1999999999999999997; 
const int inf= INT_MAX;
const int MAXSIZE = int( 1e6)+5;


// debugging

#define trace(arr) for(auto i: arr) cerr<<i<<" "
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


// Helpful functions

ll pow(ll a,ll b,int MOD){
	ll ans=1; 
	while(b){
			if(b&1) ans=((ans)%MOD *a)%MOD;
			b=b>>1; a=((a%MOD) * (a%MOD))%MOD;
	}
	return ans%MOD;

}

int randInt(int s, int e){
	// return random value in range [s,e]
	return s + (rand()%(e-s+1));
}



// comparators
bool comp(int a,int b){
	return true;
}

class Comp{
	public:
	bool operator()(int b ,int a){
		return true;
	}
};


int arr[100005];
int dp[100005];

int fun(int n){
	if(n==1){
		return 0;
	}
	if(n<=0){
		return inf;
	}
	if(dp[n]!=-1){
		return dp[n];
	}
	int ans1=inf;
	int ans2=inf;


	ans1=abs(arr[n]-arr[n-1])+ fun(n-1);
	 if(n>2)
		ans2=abs(arr[n]-arr[n-2])+fun(n-2);
	dp[n]= min(ans1,ans2);
	return dp[n];
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	


	int n; cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<fun(n);


	return 0;
}


Measured memory_bytes: 4224
#include <array>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <iostream>
#include <vector>
using namespace std;

enum {NG, HF, OK};
enum {TO, BACK};

const string message[] = {
	"He cannot bring tea to his master.",
	"He cannot return to the kitchen.",
	"He can accomplish his mission."
};

struct state {
	int x, y, d;
	state(int x_, int y_, int d_):x(x_), y(y_), d(d_) {}
};

constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};
constexpr int MAX_H = 16;
constexpr int MAX_W = 64;
constexpr int D = sizeof(dx) / sizeof(int);
constexpr int HF_X = 1;
constexpr int HF_Y = MAX_H + 1;

int h, w;
string field[MAX_H + 3];

int sx, sy, sd;
int gd;
bool visited[MAX_W][MAX_H][D][MAX_W][MAX_H + 3][D];

vector<state> move_back(state s, int turn) {
	const int dir = (s.d + 2) % D;
	s.d = (s.d + turn + D) % D;

	vector<state> res;
	do {
		if(field[s.y + dy[s.d]][s.x + dx[s.d]] == '#') {
			res.emplace_back(s);
		}

		s.x += dx[dir];
		s.y += dy[dir];

	} while(field[s.y][s.x] != '#');

	res.emplace_back(state(HF_X, HF_Y, s.d));
	return res;
}

int bfs() {
	memset(visited, false, sizeof(visited));
	queue<array<state, 2>> que;

	for(int bd = 0; bd < 4; ++bd) {
		visited[sx][sy][sd][sx][sy][bd] = true;
		que.push({{state(sx, sy, sd), state(sx, sy, bd)}});
	}

	int res = NG;
	while(!que.empty()) {
		auto ss = que.front();
		que.pop();

		const state tmp_back = ss[BACK];

		int sign = 1;
		for(auto &s : ss) {
			while(field[s.y + dy[s.d] * sign][s.x + dx[s.d] * sign] != '#') {
				s.x += dx[s.d] * sign;
				s.y += dy[s.d] * sign;
			}
			sign = -sign;
		}

		if(field[ss[TO].y][ss[TO].x] == 'M') {
			if(field[ss[BACK].y][ss[BACK].x] == 'M' && ss[BACK].d == gd) return OK;
			res = HF;
		}

		for(int turn = -1; turn <= 1; turn += 2) {
			state sa(ss[TO]);
			sa.d = (sa.d + turn + D) % D;

			for(const auto &sb : move_back(tmp_back, turn)) {
				if(!visited[sa.x][sa.y][sa.d][sb.x][sb.y][sb.d]) {
					que.push({{sa, sb}});
					visited[sa.x][sa.y][sa.d][sb.x][sb.y][sb.d] = true;
				}
			}
		}
	}

	return res;
}

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

	field[MAX_H]     = "###";
	field[MAX_H + 1] = "#.#";
	field[MAX_H + 2] = "###";

	while(cin >> w >> h && w) {
		for(int i = 0; i < h; ++i) {
			cin >> field[i];
		}

		for(int i = 1; i < h - 1; ++i) {
			for(int j = 1; j < w - 1; ++j) {
				if(field[i][j] == 'K') {
					sx = j;
					sy = i;

					for(int d = 0; d < D; ++d) {
						if(field[i + dy[d]][j + dx[d]] != '#') {
							sd = d;
							break;
						}
					}
				}
				else if(field[i][j] == 'M') {
					for(int d = 0; d < D; ++d) {
						if(field[i + dy[d]][j + dx[d]] != '#') {
							gd = d;
							break;
						}
					}
				}
			}
		}

		cout << message[bfs()] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 21024