akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int a[3][MAXN];
int f[2][MAXN];
void add(int p, int index) {
    for (;p < MAXN; p += p&-p)
        ++f[index][p];
}
int find(int p, int index) {
    int res = 0;
    for (;p; p -= p&-p)
        res += f[index][p];
    return res;
}
int32_t main () {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
    vector <int> vctr;
    bool b[2] = {0, 0};
    for (int i = 0; i < n; ++i) {
        int mx = max(a[0][i], max(a[1][i], a[2][i]));
        int mn = min(a[0][i], min(a[1][i], a[2][i]));
        if (mx - mn > 2)
            return cout << "No", 0;
        if (mx % 3)
            return cout << "No", 0;
        if (2 * a[1][i] != a[0][i] + a[2][i])
            return cout << "No", 0;
        if ((mx - i) % 2 == 0)
            return cout << "No", 0;
        vctr.push_back(mx / 3);
        if (a[0][i] == mx)
            b[i & 1] = 1 - b[i & 1];
        // cout << (a[0][i] == mx) << ' ';
    }
    // cout << b[0] << ' ' << b[1];
    for (int i = n - 1; i >= 0; --i) {
        if (find(vctr[i], i & 1) & 1)
            b[(i + 1) & 1] = 1 - b[(i + 1) & 1];
        add(vctr[i], i & 1);
        // cout << vctr[i] << ' ';
    }
    if (b[0] || b[1])
        return cout << "No", 0;
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 13432
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String s1 = S.substring(0, 1);
		String s2 = "";
		boolean f1 = false;
		boolean f2 = false;
		boolean f = false;
		for(int i = 1; i < 4; i++) {
			if(S.substring(i, i + 1).equals(s1)) {
				if(f1) {
					System.out.println("No");
					return;
				} else {
					f1 = true;
				}
			} else {
				if(f) {
					if(S.substring(i, i + 1).equals(s2)) {
						if(f2) {
							System.out.println("No");
							return;
						} else {
							f2 = true;
						}
					} else {
						System.out.println("No");
						return;
					}
				} else {
					s2 = S.substring(i, i + 1);
					f = true;
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=10005;
int n;
vector<int> G[N];
int deg[N],C[N],ans=0;
int V[N];
void go( int u, int p, int &k ) {
    V[u]=C[--k];
    if ( p!=-1 ) {
        ans+=min(V[u],V[p]);
    }
    for ( int v:G[u] ) {
        if ( v==p ) continue;
        go(v,u,k);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    REP(i,n-1) {
        int a,b;
        cin >> a >> b;
        --a;--b;
        G[a].PB(b);
        G[b].PB(a);
        deg[a]++;
        deg[b]++;
    }    
    REP(i,n) cin >> C[i];
    sort(C,C+n);
    int root,mx=0;
    REP(i,n) {
        if ( chmax(mx,deg[i]) ) {
            root=i;
        }
    }
    int k=n;
    go(root,-1,k);
    cout << ans << '\n';
    REP(i,n) cout << V[i] << ' ';
    return 0;
}


Measured memory_bytes: 4552
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<complex>
#include<set>
#include<map>
#include<algorithm>

using namespace std;

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

const int N = 211;
int dpcost[N][N];
int dptime[N][N];

int main(){
	
	A:;
	int n,m;
	cin>>n>>m;
	if(n==0)return 0;
	
	const int INF = 1000000000;
	
	rep(i,N)rep(j,N)dpcost[i][j]=dptime[i][j]=INF;
	rep(i,N)dpcost[i][i]=dptime[i][i]=0;
	
	rep(i,n){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		dpcost[a][b]=c;
		dpcost[b][a]=c;
		dptime[a][b]=d;
		dptime[b][a]=d;
	}
	
	
	reps(k,1,m+1)reps(i,1,m+1)reps(j,1,m+1){
		dpcost[i][j] = min(dpcost[i][j], dpcost[i][k]+dpcost[k][j]);
		dptime[i][j] = min(dptime[i][j], dptime[i][k]+dptime[k][j]);
	}
	
	
	int r;
	cin>>r;
	
	rep(i,r){
		int a,b,c;
		cin>>a>>b>>c;
		if(c==0)printf("%d\n",dpcost[a][b]);
		if(c==1)printf("%d\n",dptime[a][b]);
	}
	
	goto A;
}

Measured memory_bytes: 1492
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	bool ok = true;
	string s;
	cin >> s;
	vector<int> news(4, 0);
	for (int i = 0; i < s.size(); ++i) {
		if      (s[i] == 'N') ++news[0];
		else if (s[i] == 'E') ++news[1];
		else if (s[i] == 'W') ++news[2];
		else if (s[i] == 'S') ++news[3];
	}
	if (news[0] > 0 && news[3] == 0) ok = false;
	if (news[3] > 0 && news[0] == 0) ok = false;
	if (news[1] > 0 && news[2] == 0) ok = false;
	if (news[2] > 0 && news[1] == 0) ok = false;
 
	cout << (ok ? "Yes" : "No") << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  map<string,int>mp;
  cin >> n;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >>m;
  rep(i,m){
    string t;
    cin >> t;
    mp[t]--;
  }
  int ans = 0;
  for(auto it : mp){
    maxs(ans,it.se);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint A(N + 1);
    vector<bool> ans(N + 1, false);
    vector<int> divi(N + 1, 0);
    rep(i, N) cin >> A[i + 1];
    int M = 0;
    for (int i = N; i > 0; i--) {

        if (A[i] == 0) {
            if((divi[i]%2) == 0)
                ans[i] = false;
            else {
                ans[i] = true;
                M++;
                for (int j = 1; j * j <= i; j++) {
                    if (i % j == 0) {
                        divi[j] += 1;
                        if (j * j != i)
                            divi[i / j] += 1;
                    }
                }
            }
        }
        else {
            if ((divi[i] % 2) == 0) {
                ans[i] = true;
                M++;
                for (int j = 1; j * j <= i; j++) {
                    if (i % j == 0) {
                        divi[j] += 1;
                        if (j * j != i)
                            divi[i / j] += 1;
                    }
                }
            }
            else {
                ans[i] = false;
            }
        }
    }
    
    cout << M << endl;
    if (M == 0) return 0;
    REP(i,1, N + 1) {
        if (ans[i] == true)
            cout << i << " " ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
using namespace std;
 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int turns_takahashi = ceil((c-1) / b);
  int turns_aoki = ceil((a-1) / d);
  if(turns_takahashi > turns_aoki){
	cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int varD = Integer.parseInt(sc.next());
        final int varT = Integer.parseInt(sc.next());
        final int varS = Integer.parseInt(sc.next());
        sc.close();

        String result = "Yes";
        if (varD > varT * varS) {
            result = "No";
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 35736
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>

using namespace std;

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

    long long b=0,c=0;
    for(int i=0;i<a.size();++i){
        if(a[i]=='W'){
            b += i-c;
            ++c;
        }
    }
    cout<<b;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
const int MOD = 1000000007;
const char nl = '\n';
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
clock_t startTime;
double getCurrentTime() {
	cout << "Execution Time: ";
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
//const int N = 200200;
//bool p[N];
vector<int> a;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int n;
    cin >> n;
    if(n >= 30) cout << "Yes"; else cout << "No";
	return 0;
}

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

int main(){
int h,w;
cin>>h>>w;
int d[10][10];
int n=10;
for(int i=0;i<10;i++)for(int j=0;j<10;j++)cin>>d[i][j];
for(int i=0;i<n;i++)for(int j=0;j<n;j++)for(int k=0;k<n;k++)d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
int res=0;
for(int i=0;i<h;i++)for(int j=0;j<w;j++) {int a;cin>>a;if(a!=-1)res+=d[a][1];}
cout<<res<<endl;
 return 0;
}


Measured memory_bytes: 256
w,h,n = map(int,input().split())
pic = [[0]*w]*h

for i in range(n):
    x,y,a = map(int,input().split())
    
    if a == 1:
        for j in range(h):
            pic[j][:x] = [1]*len(pic[j][:x])
            
    if a == 2:
        for j in range(h):
            pic[j][x:] = [1]*len(pic[j][x:])
            
    if a == 3:
         for j in range(1,h+1):
            if j < y+1:
                pic[-j] = [1] * w
                
    if a == 4:
        for j in range(1,h+1):
            if j > y:
                pic[-j] = [1] * w
                
ans = 0

for i in pic:
    ans += i.count(0)
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

bool dp[100003];
vector<int> a;
int n, k; 

void solution(){
	cin >> n >> k;
	a = vector<int>(n); for(auto& x : a) cin >> x;
	// Game Theory DP - 
	// here state only depends on number of stones left 
	// and whos turn it is to move
	memset(dp,0,sizeof(dp));
	for(int cur = 0; cur <= k; cur++){
		for(int x : a){
			if(cur >= x && !dp[cur-x]) dp[cur] = 1;

		}
	}
	if(dp[k]) cout << "First\n";
	else cout << "Second\n";
}	


int main(){ 

	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}


Measured memory_bytes: 3712
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    FOR(i, 0, n) {
        cin >> p[i];
        p[i]--;
    }
    vector<int> a(n), b(n);
    FOR(i, 0, n) {
        a[i] = 1 + i * n;
        b[i] = 1+(n-i)*n;

    }

    FOR(i, 0, n) {
        int idx = p[i];
        a[idx] += i;
    }
    FOR(i, 0, n) {
        cout << (i == 0 ? "" : " ") << a[i];
    }
    cout << endl;
    FOR(i, 0, n) {
        cout << (i == 0 ? "" : " ") << b[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}


 
 
  

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())

CSF = []
for i in range(N-1):
    CSF.append(list(map(int, input().split())))


for i in range(N-1):
    estime = 0
    for (c,s,f) in CSF[i:]:
        if estime < s:
            estime = c + s
        else:
            if estime%f == 0:
                estime += c
            else:
                estime += c + f - estime%f

    print(estime)

print(0)


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

int main() {
  string s,t="";
  cin>>s>>t;
  int count=0;
  rep(i,0,s.size()){
    if(s.at(i)!=t.at(i)){
      count++;
    }
  }
  cout<<count;
}

Measured memory_bytes: 3916
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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

long long int a[3][100001];

int main() {
	int n;
	cin >> n;
	int maxer = 0, a, cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (maxer <= a) cnt++;
		maxer = max(maxer, a);
	}
	cout << cnt << endl;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	C *= 2;
	int ans = 0;
	if (X > Y) {
		swap(X, Y);
		swap(A, B);
	}
	if (A > C || B > C || A+B > C) {
		ans += C * X;
		Y -= X;
	}
	else {
		ans += A * X;
	}
	if (B > C) {
		ans += C * Y;
	}
	else {
		ans += B * Y;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int ans[4] = {-1, -1, -1, -1};
	bool success = true;
	for (int i = 0; i < m; i++) {
		int s, c;
		cin >> s >> c;
		if (n != 1 && s == 1 && c == 0)
			success = false;
		if (ans[s] != -1 && ans[s] != c)
			success = false;
		ans[s] = c;
	}
	if (success) {
		for (int i = 1; i <= n; i++)
			if (ans[i] == -1)
				cout << ((i == 1 && 1 != n) ? 1 : 0);
			else
				cout << ans[i];
		cout << "\n";
	} else {
		cout << "-1\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int H, W, d;
int mat[505][505];
char col[] = {'R', 'B', 'Y', 'G'};

int main(void)
{
	cin >> H >> W >> d;
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if( ((i + j) / d) % 2 ) mat[i][j] |= 1;
		}
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
		if( ((i + j) / d) % 2 ) mat[(H-1)-i][j] |= 2;
		}
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cout << col[mat[i][j]];
		}
		cout << endl;
	}
	
	return 0;
}

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

int main () {
  int H, W;
  cin >> H >> W;
  
  vector<char> vec(W + 2, '#');
  for (int i = 0; i < W + 2; i++) cout << vec.at(i);
  
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> vec.at(j + 1);
    }
    for(int j = 0; j < W + 2; j++) {
      cout << vec.at(j);
    }
    cout << endl;
  }
  
  vec = vector<char> (W + 2, '#');
  for(int i = 0; i < W + 2; i++) cout << vec.at(i);
  
  cout << endl;
}


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

typedef long long ll;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

namespace std{
  bool operator<(const P& a,const P& b){
    return a.X==b.X?a.Y<b.Y:a.X<b.X;
  }
}
bool cmp_x(const P& a,const P& b){ return abs(a.X-b.X)<eps?a.Y<b.Y:a.X<b.X; }
bool cmp_y(const P& a,const P& b){ return abs(a.Y-b.Y)<eps?a.X<b.X:a.Y<b.Y; }
bool cmp_a(const P& a,const P& b){ return arg(a)==arg(b)?norm(a)<norm(b):arg(a)<arg(b); }
D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }
D toRag(D deg){ return deg*PI/180.0; }
P rot(P base,P a,D theta){ return base+polar(abs(a-base),arg(a-base)+theta); }

struct L : public vector<P> { // line and segment
  L(P a,P b){
    push_back(a);
    push_back(b);
  }
};

struct C{
  P p; D r;
  C(P p,D r):p(p),r(r){}
};

enum RELATION{SAME=1,CONTAINED=2,OVER=4,NO_CROSS=8,ONE_CROSS=16,ONE_CONTAINED_CROSS=32,ONE_OVER_CROSS=64,TWO_CROSS=128};
int cRel(C c1, C c2) {
  D d=abs(c1.p-c2.p);
  D dr1=c1.r-c2.r,dr2=c2.r-c1.r;
  D ar=c1.r+c2.r;
  if(d<eps&&c1.r==c2.r)return SAME;
  if(d<dr1)return OVER;
  if(d<dr2)return CONTAINED;
  if(d==dr1)return ONE_OVER_CROSS;
  if(d==dr2)return ONE_CONTAINED_CROSS;
  if(d==ar)return ONE_CROSS;
  if(d>ar)return NO_CROSS;
  return TWO_CROSS;
}

P projection(L l,P p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*(c/b).X;
}

vector<P> crosspointCL(C c,L l){
  vector<P> res;
  P q=projection(l,c.p);
  double d=sqrt(c.r*c.r-abs(c.p-q)*abs(c.p-q));
  P base=l[1]-l[0];
  res.push_back(q+base*(d/abs(base)));
  res.push_back(q-base*(d/abs(base)));
  return res;
}

int main(){
	cin.sync_with_stdio(false);
  D cx,cy,cr;
  cin>>cx>>cy>>cr;
  C c1=C(P(cx,cy),cr);

  int q;
  cin>>q;
  while(q--){
    D x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    vector<P> res=crosspointCL(c1,L(P(x1,y1),P(x2,y2)));
    sort(all(res),cmp_x);
    printf("%.10Lf %.10Lf %.10Lf %.10Lf\n", res[0].X,res[0].Y,res[1].X,res[1].Y);
  }
  return 0;
}

Measured memory_bytes: 3364
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;



int main() {
	int x, n,p,pp;
	vector<int> a;
	bool flag=true;
	cin >> x >> n;
	for (int i = 0; i < n; i++) {
		cin >> p;
		a.push_back(p);
	}
	p = x;
	pp = 0;
	do 
	{
		p = x - pp;
		flag = false;
		for (int i = 0; i < n; i++) {
			if (a.at(i) == p) {
				flag = true;
				break;
			}
		}
		if (flag) {
			flag = false;
			p = x+pp;
			for (int i = 0; i < n; i++) {
				if (a.at(i) == p) {
					flag = true;
					break;
				}
			}
		}
		if (flag) {
			pp++;

		}
		//cout << pp << endl;
	} while (flag);
	cout << p << endl;

}


Measured memory_bytes: 3636
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, K = map(int, input().split())
As = list(map(int, input().split()))

for k in range(K, N):
    if As[k] > As[k - K]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 33556
#include<stdio.h>

int main(void){
        int S, h, m, s;
        printf("");
        scanf("%d", &S);
        if(S>=0 && S<86400){
                h=S/3600;
                m=(S%3600)/60;
                s=(S%3600)%60;
                printf("%d:%d:%d\n", h, m, s);
        }
        return 0;
}


Measured memory_bytes: 2148
'use strict';

const main = (input) => {
    const lines = input.split('\n');
    const header = lines[0].split(' ');
    const N = parseInt(header[0], 10);
    const raw_K = parseInt(header[1], 10);
    const raw_x = lines[1].split(' ').map(v => parseInt(v, 10));
    const x = raw_x.filter(v => v != 0);
    const K = raw_K - (raw_x.indexOf(0) != -1 ? 1 : 0) 

    // 原点のみ
    if (x.length == 0) {
        console.log(0);
        return;
    }
    // x>=0のみ
    if (Math.min(...x) >= 0) {
        console.log(x[K - 1]);
        return;
    }
    // x<=0のみ
    if (Math.max(...x) <= 0) {
        console.log(-x[x.length - 1 - (K - 1)]);
        return;
    }

    // 左に移動した後、右に移動して、また左に移動するのは無駄なので、
    // 左に移動してから右に移動、もしくは右に移動してから左に移動することになる。
    const neg_count = x.filter(v => v < 0).length;
    const pos_count = x.filter(v => v > 0).length;

    const extra_count = x.length - K;

    // 巡回しないロウソクを割り振って全数探索
    let min_cost = Math.pow(10, 8) * 3;
    for (let i = 0; i <= extra_count; i++) {
        const neg_extra = i;
        const pos_extra = extra_count - i;
        if (neg_extra > neg_count || pos_extra > pos_count) {
            continue;
        }
        const cost_neg = neg_extra == neg_count ? 0 : -x[neg_extra];
        const cost_pos = pos_extra == pos_count ? 0 : x[x.length - 1 - pos_extra];
        const neg_first_cost = cost_neg + cost_neg + cost_pos;
        const pos_first_cost = cost_pos + cost_pos + cost_neg;
        min_cost = Math.min(min_cost, neg_first_cost);
        min_cost = Math.min(min_cost, pos_first_cost);
    }
    console.log(min_cost);
};

const isTest = false;

if (isTest) {
    main('5 3\n-30 -10 10 20 50');
    main('3 2\n10 20 30');
    main('1 1\n0');
    main('8 5\n-9 -7 -4 -3 1 2 3 4');
} else {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}

Measured memory_bytes: 31252
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int T = GetInt();

		string[] ans = new string[T];
		for(int i = 0; i < T; i++)
			ans[i] = isOK(GetLong(), GetLong(), GetLong(), GetLong()) ? "Yes" : "No";

		Console.WriteLine(string.Join("\n", ans));
	}

	private bool isOK(long A, long B, long C, long D)
	{
		if(B > A)
			return false;

		if(B > D)
			return false;

		if(C >= B)
			return true;

		long g = gcd(B, D);
		long max = B - g + (A % g);
		return (max <= C);
	}
	
	private long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
 int main(){
 	int S;
 	cin>>S;
 	int h = S/3600;
 	S=S-h*3600;
 	int m = S/60;
 	S=S-m*60;
 	int s = S;
 	cout<<h<<":"<<m<<":"<<s<<endl;
 }


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int S = in.nextInt();
        int h = S/(60*60);
        S -= h*60*60;
        int m = S/60;
        int s = S%60;
        System.out.println(h + ":" + m + ":" + s);
    }
}

Measured memory_bytes: 26248
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
bool check_same(ll n){
    bool same=true;
    ll num=n%10;
    n/=10;
    while(n>0){
        if(n%10 != num){
            same=false;
            break;
        }
        n/=10;
    }
    return same;
}
int main() {
    cin>>n;

    while(1){
        if(check_same(n)){
            cout<<n<<endl;
            break;
        }
        n++;
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int count = 0;

    for(int i=0; i<s.size(); i++) {
        count += (int)(s[i]-48);
        count %= 9;
    }
    if (count % 9 == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
    }
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  ll a;
  string result;
  cin >> a;
  a %= 7;
  if (a == 1) result = "fri";
  else if(a == 2) result = "sat";
  else if(a == 3) result = "sun";
  else if(a == 4) result = "mon";
  else if(a == 5) result = "tue";
  else if(a == 6) result = "wed";
  else if(a == 0) result = "thu";
  cout << result << endl;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; 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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll d, n;
  cin >> d >> n;
  if (n != 100)
    cout << ll(pow(100, d)) * n << endl;
  else
    cout << ll(pow(100, d)) * (n+1) << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define endl endl;cf
#define be begin()
#define sz size()
#define en end()
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define rngx mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define cf cout.flush()
int main()
{
    ios;
    ll n , m;
    cin >> n  >> m;
    ll cnt[32];
    memset(cnt , 0 , so cnt);
    for(ll i = 0 ; i < n ; ++i){
        ll k;
        cin >> k ;
        for( ll j = 0 ; j < k ; ++j){
            ll x;
            cin >> x;
            cnt[x]++;
        }
    }
    ll res = 0 ;
    for(ll i = 1;i<=30;++i){
        if(cnt[i] == n) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {

	int i, l = 100;
	long long int k;
	char c, s[100];

	cin >> s >> k;

	for (i = 0; s[i] != '\0'; i++) {
		if (s[i] != '1') {
			c = s[i];
			l = i;
			break;
		}
	}
	if (l + 1 <= k) {
		cout << c << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int n ,m;
    cin >> n  >> m;
    int a[m] ,b[m],c[n] ,d[n];
    for(int i = 0 ; i < m ; i++){
        cin >> a[i] >> b[i];
    }
    
    for(int v = 0; v < n ; v++){
        d[v] = 0;
    }
    for(int j = 0 ; j < n ; j++){
        for(int t = 0;t < m;t++){
            if(a[t] == j+1 || b[t] == j+1){
                d[j] += 1;
            }    
        }
    }
    
    for(int y = 0;y < n;y++){
        cout << d[y] << endl;
    }
    
    
    
}


Measured memory_bytes: 3628
#include<stdio.h>
#define N 100
#define INF 100000000
#define W 0
#define G 1
#define B 2

int color[N],M[N][N],d[N],p[N],n;

void dijkstra(){
  int i,u,v,min;
  for(i=0;i<n;i++){
      color[i]=W;
      d[i]=INF;
  }
  d[0]=0;
  color[0]=G;

  while(1){
    min=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(color[i]!=B && d[i]<min){
        u=i;
        min=d[i];
      }
    }

    if(u==-1) break;
    color[u]=B;

    for(v=0;v<n;v++){
      if(color[v]!=B && M[u][v]!=INF){
        if(d[u]+M[u][v]<d[v]){
          d[v]=d[u]+M[u][v];
          color[v]=G;
        }
      }
    }
  }
}

int main(){
  int k,u,v;

  scanf("%d",&n);

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++) M[i][j]=INF;

  for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&M[u][v]);
    }
  }

  /*for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      printf("%d ",M[i][j]);
    }
    printf("\n");
    }*/

  dijkstra();

  for(int i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int difx = tx - sx;
	int dify = ty - sy;

	for (int i = 0; i < difx; i++) cout << "R";
	for (int i = 0; i < dify; i++) cout << "U";
	for (int i = 0; i < difx; i++) cout << "L";
	for (int i = 0; i < dify; i++) cout << "D";

	cout << "D";
	for (int i = 0; i < difx+1; i++) cout << "R";
	for (int i = 0; i < dify+1; i++) cout << "U";
	cout << "LU";
	for (int i = 0; i < difx+1; i++) cout << "L";
	for (int i = 0; i < dify+1; i++) cout << "D";
	cout << "R";


	return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int a, b;

void init()
{
	cin >> a >> b;
}

void solve()
{
	if (a > 0) {
		cout << "Positive" << endl;
		return;
	}
	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
		return;
	}
	if ((b - a) % 2) {
		cout << "Positive" << endl;
	} else {
		cout << "Negative" << endl;
	}
}




Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

vector<vector<int>> path(100005);

struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<int> sizes;
    UnionFind(int n): par(n), rank(n), sizes(n){
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
            sizes[i] = 1;
        }
    }

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

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

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

    int size(int x){
        return sizes[root(x)];
    }
};
int main(){
    int N,M,K;
    cin >> N >> M >> K;
    int A[2][M];
    UnionFind uni(N+1);
    for(int i = 0; i < M; i++){
        cin >> A[0][i] >> A[1][i];
        uni.unite(A[0][i], A[1][i]);
        path[A[0][i]].push_back(A[1][i]);
        path[A[1][i]].push_back(A[0][i]);
    }
    int C[2][K];
    for(int i = 0; i < K; i++){
        cin >> C[0][i] >> C[1][i];
        path[C[0][i]].push_back(C[1][i]);
        path[C[1][i]].push_back(C[0][i]);
    }
    for(int i = 1; i <= N; i++){
        int ans = 0;
        ans += uni.size(i)-1;
        for(int j = 0; j < path[i].size(); j++){
            if(uni.same(i, path[i][j])) ans--;
        }
        cout << ans << " ";
    }
}

Measured memory_bytes: 10240
#include<stdio.h>
  char f[100],c[100],r[100];
int main()
{
  int i,j,k,l1,l2,l3;
  j=0;k=0;
  scanf("%s",f);
  scanf("%s",c);
  scanf("%s",r);
  l1=strlen(f);
  l2=strlen(c);
  if (f[l1-1]==c[0])j=1;
  if (c[l2-1]==r[0])k=1;
  if (j==1&&k==1)printf("YES\n");
  else if(j==1&&k!=1)printf("NO\n");
    else if(j!=1&&k==1)printf("NO\n");
  else printf("NO\n");
  return 0;
}


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

int main(){
  int n,x;
  cin >> n >> x;
  int a = n;
  vector<int> m(n);
  rep(i,n) cin >> m[i];
  int minimum = 1e9;
  int sum = 0;
  rep(i,n) sum += m[i];
  rep(i,n){
   minimum = min(minimum,m[i]); 
  }
  x -= sum;
  int counts = x/minimum;
  cout << counts + a << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define INF 10e9
static const int MAX_N=10e5,MAX_M=10e5;
int N,M,K,X,Y,Z;
int maxs=-1,mini=INF,ans,res;
int A[MAX_N],B[MAX_N],C[MAX_N];
//int a,b,c,d,e,f,g;
int x,y,z;
int i,j,k,l,m,n;
string a;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define put(n) cout << n << " ";
#define puts(n)cout << n << endl;

int main(void){
	cin >> a;
	
	for(int i=0;i<a.size();i++){
		if(i-2<0)
			continue;
		int c=(a[i]-'0')+(a[i-1]-'0')*10+(a[i-2]-'0')*100;
		mini=min(mini,abs(c-753));
	}
	puts(mini);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#l=deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え
#start 4:00
N = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]



A = list(map(int, input().split()))
edge = [[] for i in range(N)]
for i in range(N-1):
    x,y = map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)


#始点sから各頂点への最短距離
inf=10**10
dp = [inf]*N
visited=[False]*N
q=[]
q=deque(q)
ans=[0]*N

def dfs(e):
    visited[e]=True
    a=A[e]
    ci=bisect_left(dp,a)
    q.append((ci,dp[ci]))
    dp[ci]=a
    ans[e]=bisect_left(dp,inf)
    #print(edge[e])
    for ne in edge[e]:
        if not visited[ne]:
            dfs(ne)
            pi,px=q.pop()
            dp[pi]=px


dfs(0)
    #print(d)
    
for x in ans:
    print(x)
#print(d[4])



Measured memory_bytes: 239308
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
p = [int(x[0]) for x in ps]
s = [x[1] for x in ps]

ac = 0
wa = 0

wa_count = [0] * (n+1)
close = [False] * (n+1)

for i in range(m):
    if (close[p[i]]):
        continue

    if (s[i] == "AC"):
        wa += wa_count[p[i]]
        ac+= 1
        close[p[i]] = True
    else:
        wa_count[p[i]] += 1

print(ac,wa,sep=' ')


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

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	int ans = 0;
	rep(is,1<<h)rep(js,1<<w) {
		int cnt = 0;
		rep(i,h)rep(j,w) {
			if (is>>i&1) continue;
			if (js>>j&1) continue;
			if (s[i][j] == '#') cnt++;
		}
		if(cnt == k) ans++;

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

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define VALS(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pf push_front
#define LLINF ((long long)1e18)
#define INF 1234567890ll
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define ll long long int 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define f first
#define s second
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
const int MOD = 1e9 + 7;
multiset <ll> ms;
vector <ll> v;
int main()
{
	IAMSPEED
	ll n; cin >> n;
	FOR (i, 1, pow(2, n)) {
		ll x; cin >> x;
		ms.insert(x);
	}
	v.pb(*prev(ms.end()));
	ms.erase(prev(ms.end()));
	FOR (i, 1, n) {
		vector <ll> newv;
		for (auto it : v) { // find the largest one that is smaller than the current slime
			if (ms.lower_bound(it) != ms.begin()) {
				newv.push_back(*prev(ms.lower_bound(it)));
				ms.erase(prev(ms.lower_bound(it)));
				//VALS(it, *prev(newv.end()));
			}
		}
		for (auto it : newv) v.pb(it);
	}
	if (v.size() == pow(2, n)) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 15460
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 998244353;
void naive(const string &s){
	set<string> vis;
	queue<string> q; q.push(s);
	while(!q.empty()){
		string t = q.front(); q.pop();
		if(vis.count(t)) continue;
		vis.insert(t);
		rep(i, t.size() - 1) if(t[i] != t[i + 1]){
			string u = t;
			char c = 'a';
			for(; c == u[i] || c == u[i + 1]; c++);
			u[i] = u[i + 1] = c;
			if(!vis.count(u)) q.push(u);
		}
	}
	//dbg(vis);
	cout << vis.size() << endl;
	exit(0);
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int dp[2][3][3][2] = {}; //prev, sum, flag
	string s; cin >> s;
	
	int n = s.size(), cur = 0, next = 1, diff = 0;
	rep(i, n - 1) diff += s[i] != s[i + 1];
	if(diff == 0){
		cout << 1 << endl;
		return 0;
	}
	if(n <= 6) naive(s);
	
	rep(i, 3) dp[0][i][i][0] = 1;
	for(int i = 1; i < n; i++){
		rep(j, 3) rep(k, 3) rep(f, 2) if(dp[cur][j][k][f]) rep(l, 3){
			
			(dp[next][l][(k + l) % 3][f || j == l] += dp[cur][j][k][f]) %= mod;
		}
		swap(cur, next);
		memset(dp[next], 0, sizeof(dp[next]));
	}
	
	ll ans = 0;
	int md = 0;
	rep(i, n) md += s[i] - 'a';
	rep(i, 3) ans += dp[cur][i][md % 3][1];
	if(diff == n - 1) ans++;
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {

	ll K, N;
	cin >> N >> K;

	vector<ll> count(N + 1,0);

	repn(i, N) {
		ll a;
		cin >> a;
		count[a]++;
	}

	sort(++count.begin(), count.end(),greater<ll>());

	ll ans = N;

	repn(i, K) ans -= count[i];

	cout << ans;

	system("PAUSE");

	

}


Measured memory_bytes: 2040