akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
vector<pair<int, int>> vp[N][N];
int deg[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int px = 0;
		int py = 0;
		for (int j = 1; j < n; j++)
		{
			int x = i, y;
			scanf("%d", &y);
			if (x > y) swap(x, y);
			if (j > 1)
			{
				vp[px][py].emplace_back(x, y);
				deg[x][y]++;
			}
			px = x, py = y;
		}
	}
	vector<pair<int, int>> v;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			if (deg[i][j] == 0)
				v.emplace_back(i, j);
		}
	}
	int ans = 0;
	int out = 0;
	while (!v.empty())
	{
		ans++;
		vector<pair<int, int>> tmp;
		for (auto& p : v)
		{
			out++;
			int x, y;
			tie(x, y) = p;
			for (auto& pp : vp[x][y])
			{
				int xx, yy;
				tie(xx, yy) = pp;
				if (deg[xx][yy]-- == 1)
				{
					tmp.emplace_back(xx, yy);
				}
			}
		}
		v = tmp;
	}
	if (out != n * (n - 1) / 2) puts("-1");
	else printf("%d\n", ans);
	return 0;
}

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

string ma(int mask, int n) {
	string ret;
	for(int i = 0; i < n; ++i) {
		if(mask >> i & 1) ret += '1';
		else ret += '0';
	}
	return ret;
}

int dp[1 << 18][55];
int main() {
	const int INF = 1e9;
	for(int i = 0; i < (1 << 18); ++i) {
		for(int j = 0; j < 55; ++j) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	int n; cin >> n;
	int a[n][2];
	for(int i = 0; i < n; ++i) cin >> a[i][0];
	for(int i = 0; i < n; ++i) cin >> a[i][1];
	for(int mask = 0; mask < (1 << n); ++mask) {
		int cnt = __builtin_popcount(mask);
		int r = 0;
		for(int i = n - 1; i >= 0; --i) {
			if(mask >> i & 1) {
				++r;
				continue;
			}
			int nxt = a[i][abs(cnt - i) % 2];
			for(int j = 0; j <= nxt; ++j) {
				dp[mask | (1 << i)][nxt] = min(dp[mask | (1 << i)][nxt], dp[mask][j] + abs(i + r - cnt));
			}
		}
	}
	int ans = INF;
	for(int i = 0; i < 55; ++i) {
		ans = min(ans, dp[(1 << n) - 1][i]);
	}
	// for(int mask = 0; mask < (1 << n); ++mask) {
	// 	for(int i = 0; i < 5; ++i) {
	// 		cout << "(" << ma(mask, n);
	// 		printf(", %d): %d\n", i, dp[mask][i]);
	// 	}
	// }
	cout << (ans == INF ? -1 : ans) << '\n';
	return 0;
}

Measured memory_bytes: 56576
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>=0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r){
  if(l<r){
    return gcd(r, l);
  }
  if(r == 0){
    return l;
  }
  return gcd(r, l % r);
}

template<class T>
vector<T> accum_sum(vector<T> a){
  vector<T> b(a.size() + 1);
  b[0] = a[0];
  rep(i, a.size()){
    b[i + 1] = b[i] + a[i];
  }
  return b;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(N);
  vector<ll> a(N);
  rep(i, N){
    cin >> a[i];
  }
  sort(all(a));
  while(a.size() >= 1){
    // dump(a);
    rep1(i, N){
      a[i] %= a[0];
    }
     sort(all(a));
     while(a[0] == 0){
       auto it = remove(all(a), 0);
       a.erase(it, a.end());
     }
     if(a.size() == 1){
       cout << a[0] << endl;
       return 0;
     }
  }
}
#endif


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int G = sc.nextInt();
        int[] problemCnt = new int[D];
        int[] perfectScr = new int[D];
        for(int i=0;i<D;i++){
            problemCnt[i] = sc.nextInt();
            perfectScr[i] = sc.nextInt() + ((i+1) * problemCnt[i] * 100);
        }
        sc.close();
        int minCnt = Integer.MAX_VALUE;
        for(int bit=0; bit < 1 << D; bit++){
            int score = 0;
            int count = 0;
            for(int i=0;i<D;i++){
                if((bit & (1 << i)) > 0) continue;
                score += perfectScr[i];
                count += problemCnt[i];
            }
            if(score<G){
                for(int i=D-1;i>=0;i--){
                    if((bit & (1 << i)) == 0) continue;
                    for(int j = 0; j < problemCnt[i]; j++){
                        if(score >= G)break;
                        score += (i+1) * 100;
                        count++;
                    }
                }
            }
            minCnt = Math.min(minCnt, count);
        }
        System.out.println(minCnt);

    }

}


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s, nice = "BC";
	int n;
	ll ans = 0;
	cin >> s;
	n = s.size(); s = '#' + s + '#';
	int cnta = 0;
	for (int i=1; i<=n; i++) {
		if (s[i] == 'A') {
			cnta ++;
		} else if (s.substr(i, 2) == nice) {
			ans += cnta;
		} else if (s.substr(i-1, 2) != nice) {
			cnta = 0;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 788
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;
typedef long long ll;
typedef vector<long> vl;
typedef vector<string> vs;

int main(){
  int a[5],b=10,c,d,e,f,g,h;
  rep(i,0,5){
    cin>>a[i];
    if(a[i]%10!=0){
      b=min(b,a[i]%10);
    }
  }
  int aa=0,bb=0;
  rep(i,0,5){
    if(a[i]%10==b && bb==0){
      aa+=a[i];
      bb++;
      continue;
    }
    if(a[i]%10!=0){
      a[i]/=10;
      a[i]++;
      a[i]*=10;
    }
    aa+=a[i];
  }
  co(aa);
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
using namespace std;

enum Type{
	None,
	GreaterEqual,
	SmallerEqual,
};

struct Data{
	Type type;
	int number;
};

struct Info{
	Data data[101];
	bool used;
};

int main(){

	int num_of_SC,num_of_skill,K;
	scanf("%d %d",&num_of_SC,&num_of_skill);
	Info info[num_of_SC];
	for(int i = 0; i < num_of_SC; i++){
		info[i].used = false;
		for(int a = 1; a <= num_of_skill;a++)info[i].data[a].type = None;
	}

	int skill_code,skill_level;

	char eq[4];
	bool FLG = true;

	for(int i = 0; i < num_of_SC; i++){
		scanf("%d",&K);
		for(int a = 0; a < K; a++){
			scanf("%d %s %d",&skill_code,eq,&skill_level);
			if(info[i].data[skill_code].type == None){
				info[i].data[skill_code].number = skill_level;
				if(eq[0] == '>'){
					info[i].data[skill_code].type = GreaterEqual;
				}else{
					info[i].data[skill_code].type = SmallerEqual;
				}
			}else{
				if(info[i].data[skill_code].type == GreaterEqual){
					if(eq[0] == '>'){
						//Do nothing
					}else{
						if(info[i].data[skill_code].number > skill_level){
							FLG = false;
						}
					}
				}else{
					if(eq[0] == '>'){
						if(info[i].data[skill_code].number < skill_level){
							FLG = false;
						}
					}
				}
			}
		}
	}

	if(!FLG){
		printf("No\n");
		return 0;
	}

	int count = 0;
	stack<int> S;

	while(true){

		for(int i = 0; i < num_of_SC; i++){
			if(info[i].used == true)continue;

			FLG = true;
			for(int a = 0; a < num_of_SC; a++){
				if(i == a || info[a].used == true)continue;

				for(int b = 1; b <= num_of_skill;b++){

					switch(info[a].data[b].type){
					case None:
						//Do nothing
						break;
					case GreaterEqual:
						//Do nothing
						break;
					case SmallerEqual:
						if(info[i].data[b].type == GreaterEqual && info[i].data[b].number > info[a].data[b].number){
							FLG = false;
						}
						break;
					}
				}
				if(!FLG)break;
			}
			if(FLG){
				S.push(i);
				break;
			}
		}

		if(S.empty())break;

		while(!S.empty()){
			info[S.top()].used = true;
			count++;
			S.pop();
		}
	}

	if(count == num_of_SC){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

    return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

signed main(){
    ll n;
    cin>>n;

    vector<pair<pair<string,int>,int>> v(n);

    for(int i=0;i < n;i++)
    {
        cin>>v.at(i).fi.fi>>v.at(i).fi.se;
        v.at(i).fi.se*=(-1);
        v.at(i).se=i+1;
    }
    sort(v.begin(),v.end());

    for(int i=0;i < n;i++)
    {
        cout << v.at(i).se << endl;
    }
}


Measured memory_bytes: 256
#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 INF = 1001001001;
const int MAX_V = 110000;
vector<int> edge[MAX_V];

int memo[110000];
bool check[110000];

int dp(int v) {
    if (check[v]) return memo[v];
    int ret = 0;
    for (int to : edge[v]) {
        ret = max(ret, dp(to) + 1);
    }
    check[v] = true;
    memo[v] = ret;
    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int x, y;
        cin >> x >> y;
        edge[x].push_back(y);
    }
    int ans = 0;
    for (int v = 1; v <= n; v++) {
        ans = max(ans, dp(v));
    }
    cout << ans << endl;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll>c(n);
    rep(0,i,n)c[i]=0;
    rep(1,i,n){
        ll a;
        cin>>a;
        --a;
        ++c[a];
    }
    rep(0,i,n)cout<<c[i]<<endl;
}


Measured memory_bytes: 4760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
string s,t;
cin>>s>>t;
int c=0;
for(int i=0;i<3;i++){
    if(s[i]==t[i]){
        c++;
    }
}
cout<<c;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cksharma
 */

#include <bits/stdc++.h>
using namespace std;

class BCollatzProblem {
public:
    void solve(istream& cin, ostream& cout) {
        ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
        cout.setf(ios::fixed); cout.precision(20);
        long long s; cin >> s;
        set<int> visited;
        int steps = 1;
        long long a = s;
        while (visited.find(a) == visited.end()) {
            visited.insert(a);
            if (a % 2 == 0) a /= 2;
            else a = 3 * a + 1;
            ++steps;
        }
        cout << steps << endl;
    }
};


int main() {
    BCollatzProblem solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main(void){
  int N,L,minno=0,min,sum;
  scanf("%d %d",&N,&L);
  sum = L*N + N*(N+1)/2 -N;
  min = abs(L);
  for(int i=0;i<N;i++){
  	 if(abs(L+i) < min){
       min = abs(L+i);
       minno = i;
     }
  }
    printf("%d",sum - (L+minno));
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,n,t,l,r,a,b,c,d;
    cin>>a>>b>>c>>d;
    x=b*d;
    y=b*c;
    l=a*d;
    r=a*c;
    cout<<max({x,y,l,r})<<'\n';
}









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

namespace{
	const int mod=998244353;
	int fix(int x){
		return x>=mod?x-mod:x;
	}
	template<class... T> int fix(int x,T... y){ 
		return (ll)x*fix(y...)%mod;
	}
	void add(int &x,int y){
		x=(x+y>=mod?x+y-mod:x+y);
	}
}

const int N=12;
int C[N][N],pw[N],f[2][N][N],r[N],c[N],n,m,ans;
char s[N];

void init(int n){
	C[0][0]=1,pw[0]=1;
	rep(i,1,n){
		C[i][0]=1,pw[i]=fix(pw[i-1],2);
		rep(j,1,i) C[i][j]=fix(C[i-1][j-1]+C[i-1][j]);
	}
	REP(t,2){
		rep(i,0,n) rep(j,0,n)
			if(!i||!j) f[t][i][j]=(t?pw[i+j]:1);
		rep(i,1,n) rep(j,1,n){
			rep(k,1,i) add(f[t][i][j],
				fix(k&1?1:mod-1,C[i][k],pw[k],f[t][i-k][j]));
			rep(k,1,j) add(f[t][i][j],
				fix(k&1?1:mod-1,C[j][k],pw[k],f[t][i][j-k]));
			rep(k,1,i) rep(l,1,j) add(f[t][i][j],
				fix((k+l)&1?2:mod-2,C[i][k],C[j][l],f[t][i-k][j-l]));
		}
	}
}

int main(){
	init(10),cin>>n>>m;
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m) if(s[j]=='#')
			r[i-1]|=1<<(j-1),c[j-1]|=1<<(i-1);
	}
	rep(s,1,(1<<n)-1)
		rep(t,1,(1<<m)-1){
			int flag=0,a=0,b=0;
			REP(i,n) if(s>>i&1) a++,
				flag|=(r[i]&t)==t||((~r[i])&t)==t;
			REP(i,m) if(t>>i&1) b++,
				flag|=(c[i]&s)==s||((~c[i])&s)==s;
			if(!flag) add(ans,f[1][n-a][m-b]);
		}
	cout<<fix(ans+f[0][n][m])<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import(
	"fmt"
)

func main(){
	var a, b, c, k, max int
	fmt.Scan(&a, &b, &c, &k)
	for i:=0; i < k; {
		for m:=0; i < k && m < a; m++{
			max += 1
			i++
		}
		for l:=0; i < k && l < b; l++{
			i++
		}
		for n:=0; i < k && n < c; n++{
			max -= 1
			i++
		}	
		fmt.Println(max)
	}
}

Measured memory_bytes: 1772
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    for(int i = 0; i < (int)s.length(); i++){
        if(s[i] == 'a'){
            continue;
        }
        int diff = 'z' - s[i] + 1;
        if(diff <= k){
            s[i] = 'a';
            k -= diff;
        }
    }

    int c = s[(int)s.size()-1];
    c = (c - 'a' + k) % 26 + 'a';
    s[(int)s.size()-1] = c;

    cout << s << endl;

    return 0;
}


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


int main() {
  string s;
  cin >> s;
  if (s <= "2019/04/30") cout << "Heisei";
  else cout << "TBD";
  cout << endl;
}
  



Measured memory_bytes: 256
k = input()
win_count = 0
lose_count = 0
for i in range (len(k)):
    if k[i] == "o":
        win_count += 1
    else:
        lose_count += 1
if win_count + (15-len(k))>= 8:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 8940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int start = max(A,C);
  int end = min(B,D);
  if(start >= end) cout << 0 << endl;
  else cout << end - start << endl;
}

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

#define ll long long

int main(){
  ll n,d,c=0;
  cin>>n>>d;;
  while(n--){
    ll x,y;
    cin>>x>>y;
    if((x*x)+(y*y)<=(d*d))
      c++;
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  int n;
  string s;

  cin >> n;
  cin >> s;

  char red = 'R';
  char white = 'W';
  int size = s.size();
  int l = 0;
  int h = size - 1;
  int ret = 0;
  while (l < h) {
    if (s[l] == red) {
      ++l;
      continue;
    }
    if (s[h] == white) {
      --h;
      continue;
    }
    s[l] = red;
    s[h] = white;
    ++l;
    --h;
    ++ret;
  }

  for (char c : s) {
    if (c == red) {
      break;
    }
    ++ret;
  }

  int numr = 0;

  for (char c : s) {
    if (c == red) ++numr;
  }

  ret = min(ret, numr);
  cout << ret << endl;
  return 0;
}


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

int main(){
  long long n;
  cin >> n;
  long long total = 0;
  
  for(int i=1;i<=n;++i){
    if(i%3 == 0 or i%5 == 0){
    }
    else total += i;
  }
  cout << total << endl;
  
  return 0;
}


Measured memory_bytes: 3624
N,M = map(int,input().split())
H = list(map(int,input().split()))

bridge = [[] for i in range(N+1)]

for i in range(M):
    A,B = map(int,input().split())
    bridge[A].append(B)
    bridge[B].append(A)

ans = 0
count = 0

for i in range(1,N+1):
    tmp = bridge[i]
    tmp = list(set(tmp))
    flag = True
    for j in range(len(tmp)):
        if H[i-1] <= H[tmp[j]-1]:
            flag = False
    if flag == False and len(bridge[i]) != 0:
        continue
    elif flag == True and len(bridge[i]) != 0:
        ans += 1
            
    if len(bridge[i]) == 0:
        ans +=1
        
print(ans)

Measured memory_bytes: 32016
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<pair<int,int>> v;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    v.push_back(make_pair(a.at(i),i+1));
  }
  sort(v.begin(),v.end());
  for(auto x:v)cout<<x.second<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2164
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	int N, M;
	cin >> N >> M;
	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



}




	
	


	


	


		






Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	long long N;
	int M, K, D, S;
	cin >> N >> M >> K >> D >> S;
	vector<int> A(M), B(M); vector<long long> PreC(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i] >> PreC[i];
	}
	vector<long long> SC = PreC;
	sort(SC.begin(), SC.end());
	SC.erase(unique(SC.begin(), SC.end()), SC.end());
	vector<int> C(M);
	for (int i = 0; i < M; ++i) {
		C[i] = lower_bound(SC.begin(), SC.end(), PreC[i]) - SC.begin();
	}
	N = min(N, (long long)(SC.size() + 1));
	vector<int> wait(N);
	priority_queue<pair<int, int> > que;
	for (int i = 0; i < N; ++i) {
		que.push(make_pair(0, i));
	}
	int firstS = S, lastS = -1;
	for (int i = 0; i < M; ++i) {
		while (S + D < A[i] && K > 0) {
			while (-que.top().first != wait[que.top().second]) que.pop();
			pair<int, int> u = que.top();
			S = max(S + D, -u.first);
			--K;
			if (K == 0) lastS = S;
		}
		wait[C[i]] = max(wait[C[i]], A[i]) + B[i];
		que.push(make_pair(-wait[C[i]], C[i]));
	}
	while (K > 0) {
		while (-que.top().first != wait[que.top().second]) que.pop();
		pair<int, int> u = que.top();
		S = max(S + D, -u.first);
		--K;
		if (K == 0) lastS = S;
	}
	cout << lastS - firstS << endl;
	return 0;
}


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

void solve() {
  int n, d;
  cin >> n >> d;
  int num = 1 + 2 * d;
  int ans = 0;
  while (n > 0) {
  	ans++;
    n -= num;
  }
  
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


// 広義、狭義をフラグで指定できる
template< typename T >
int LIS(const vector< T > &a, bool strict) {
  vector< T > lis;
  for(auto &p : a) {
    typename vector< T >::iterator it;
    if(strict) it = lower_bound(begin(lis), end(lis), p);
    else it = upper_bound(begin(lis), end(lis), p);
    if(end(lis) == it) lis.emplace_back(p);
    else *it = p;
  }
  return lis.size();
}

void solve() {
    int N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    reverse(all(a));

    cout << LIS(a, false) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 6264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int A = cin.nextInt();
		int[] x = new int[N];
		int sum = 0;

		for (int i = 0; i < N; i++)
		{
			x[i] = cin.nextInt();
			sum += x[i];
		}

		long[,,] dp = new long[N, N + 1, sum + 1];

		for (int i = 0; i < N; i++)
		{
			dp[i, 0, 0] = 1;
		}
		dp[0, 1, x[0]] = 1;
		for (int i = 1; i < N; i++)
		{
			for (int j = 0; j <= N; j++)
			{
				for (int k = 0; k <= sum; k++)
				{
					dp[i, j, k] = dp[i - 1, j, k];
					if (k - x[i] >= 0 && j > 0)
					{
						dp[i, j, k] += dp[i - 1, j - 1, k - x[i]];
					}
				}
			}
		}

		long ans = 0;

		for (int i = 1; i <= N; i++)
		{
			if (i * A > sum) continue;
			ans += dp[N - 1, i, i * A];
		}
		Console.WriteLine(ans);
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 51544
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll MOD = 1000000007LL;

ll dp[100][100001];

int main(){
  int N,K;
  cin >> N >> K;
  int a[N];
  for(int i=0;i<N;i++) cin >> a[i];


  //初期化
  for(int j=0;j<=K;j++){
    if(j >= K - a[0]) dp[0][j] = 1LL;
    else dp[0][j] = 0LL;
  }

  for(int i=1; i<N; i++){
    //累積和---------------
    ll sum[K+2];
    sum[0] = 0LL;
    for(int j=1; j<=K+1; j++){
      sum[j] = sum[j-1] + dp[i-1][j-1];
    }
    //---------------------

    for(int j=0; j<=K; j++){
      int r = j + a[i] + 1;
      r = min(r, K + 1);
      dp[i][j] = sum[r] - sum[j];
      dp[i][j] %= MOD;
    }
  }

  /*for(int i=0;i<N;i++){
    for(int j=0;j<=K;j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/

  cout << dp[N-1][0] << endl;
  return 0;
}

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

public class Main{
    public static void main(String[] args){
        ArrayList<Integer> intlist  = new ArrayList<Integer>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            intlist.add(sc.nextInt());
            if(intlist.get(intlist.size() - 1) == 0){
                break;
            }
            System.out.println("Case " + intlist.size() +": " + intlist.get(intlist.size() - 1));
        }
    }
}


Measured memory_bytes: 43620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  char mas[1001][1001];
  int tes[1001][1001];
  while(1){
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>mas[i][j];
      }
    }
    for(int i=0;i<n;i++){
      tes[0][i]=(mas[0][i]=='.');
      tes[i][0]=(mas[i][0]=='.');
    }
    int ans=0;
    for(int i=1;i<n;i++){
      for(int j=1;j<n;j++){
	if(mas[i][j]=='*'){
	  tes[i][j]=0;
	}else{
	  tes[i][j]=min(tes[i][j-1],min(tes[i-1][j],tes[i-1][j-1]))+1;
	}
	ans=max(ans,tes[i][j]);
      }
    }
    cout<<ans<<endl;
  }
}

      

Measured memory_bytes: 6048
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()    
C.sort()

alow = []
for i in range(n):
    key = B[i]
    ok = -1
    ng = n
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if A[mid] < key:
            ok = mid
        else:
            ng = mid
    alow.append(ok+1)
    
cup = []
for i in range(n):
    key = B[i]
    ok = n
    ng = -1
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if C[mid] > key:
            ok = mid
        else:
            ng = mid
    cup.append(n-ok)

ans = 0
for i in range(n):
    ans+=alow[i] * cup[i]
print(ans)

Measured memory_bytes: 108260
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int A;
    cin >> N >> A;
    ans = N * N - A;
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class Main {
  private static BufferedReader buf;
  public static void main(String[] args) throws IOException {
    buf = new BufferedReader(new InputStreamReader(System.in));
    String[] s;
    String str = buf.readLine();
    s = str.split(" ", 0);
    int[] inp = new int[3];
    for (int i = 0; i < 3; i++) inp[i] = Integer.parseInt(s[i]);
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        if (inp[j] > inp[j+1]) {
          int tmp = inp[j];
          inp[j] = inp[j+1];
          inp[j+1] = tmp;
        }
      }
    }
    System.out.println(inp[0]+" "+inp[1]+" "+inp[2]);
  }
}

Measured memory_bytes: 24120
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = ReadLine().Split();
      int n = int.Parse(input[0]);
      int m = int.Parse(input[1]);
      int x = int.Parse(input[2]);
      int ans1 = 0;
      int ans2 = 0;
      
      List<int> a = ReadLine().Split().ToList().ConvertAll(x=>int.Parse(x));
      var hashSet = new HashSet<int>(a);
      for (int i=x;i<=n;i++)
      {
        if (hashSet.Contains(i))
        {
          ans1+=1;
        }
      }
      for (int i=x;i>=0;i--)
      {
        if (hashSet.Contains(i))
        {
          ans2+=1;
        }
      }
      WriteLine(Math.Min(ans1,ans2));
    }
}

Measured memory_bytes: 28372
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int h, w;
    cin >> h >> w;

    vector<string> grid(h);

    fo(i, h) cin >> grid[i];

    vector<pii> dxy = {{-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {0, -1}, {1, 0}, {1, 1}, {1, -1}};

    fo(i, h) {
        fo(j, w) {
            if ( grid[i][j] == '.' ) {
                int cont = 0;
                for ( auto p : dxy ) {
                    int x = i + p.ff, y = j + p.ss;
                    if ( x < 0 or x >= h or y < 0 or y >= w ) continue;
                    if ( grid[x][y] == '#' ) cont++;
                }
                // cout << cont << endl;
                grid[i][j] = '0' + cont;
            }
        }
    }

    fo(i, h) cout << grid[i] << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<vector<int>> vvi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)

const int INF = INT_MAX;

int fact[9]; 

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);
  
	int n;cin>>n;
	int dp[3][2];
	dp[0][0]=0; dp[1][0]=0; dp[2][0]=0;
	int toggle=1,prev=0;

	//toggling b/w day, day-1
	rep(day,1,n){
		rep(i,0,2){
			int x;cin>>x;
			if(i==0) dp[0][toggle] = x+max(dp[1][prev],dp[2][prev]);
			else if(i==1) dp[1][toggle] = x+max(dp[0][prev],dp[2][prev]);
			else dp[2][toggle] = x+max(dp[0][prev],dp[1][prev]);
		}
		toggle=(toggle+1)%2; prev=(prev+1)%2;
	}	

	int ans = dp[0][prev];
	rep(i,1,2) ans=max(ans,dp[i][prev]);
	cout << ans;
	
	return 0;
	
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, c;
	ll k;
	//string s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> a >> b >> c;

	if (b - a  == c -b) s_ans = "YES";
	else s_ans = "NO";

	cout << s_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

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

int main () {
    int n, k;
    while (scanf("%d %d", &n, &k) == 2) {
        vector<int> p(n, 0);
        for (int i = 0; i < n; i++) scanf("%d", &p[i]);
        sort(p.begin(), p.end());
        long long s = 0;
        for (int i = 0; i < n && i < k; i++) s += p[i];
        printf("%lld\n", s);
    }
}



Measured memory_bytes: 3792
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=2e5+5;
const int mod=998244353;
const double pi=acos(-1.0);
ll n,a,b;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    sc(n);
    sc(a),sc(b);
    for(int i=a;i<=b;i++){
        if(i%n==0) {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}

Measured memory_bytes: 3784
L = [[[0] * 10 for i in range(3)] for j in range(4)]
n = int(input())
for i in range(n):
  b, f, r, v = list(map(int, input().split()))
  L[b - 1][f - 1][r - 1] += v
for i in range(4):
  for j in range(3):
    for k in range(10):
      print(" {}".format(L[i][j][k]), end = "")
    print()
  if i + 1 != 4:
    print("#" * 20)


Measured memory_bytes: 5628
import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// ReverseSort
// 2012/09/19
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;

	int n;
	int[] a;

	int base=50;

	void run(){
		n=sc.nextInt();
		a=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
		}
		solve();
	}

	void solve(){
		HashMap<Long, Integer> map1=hoge(a);
		int[] b=new int[n];
		for(int i=0; i<n; i++){
			b[i]=i+1;
		}
		HashMap<Long, Integer> map2=hoge(b);
		int min=INF;
		for(Entry<Long, Integer> entry : map1.entrySet()){
			long hash=entry.getKey();
			int num=entry.getValue();
			if(map2.containsKey(hash)){
				min=min(min, num+map2.get(hash));
			}
		}
		if(min<INF){
			println(min+"");
		}else{
			// answer > 4+4
			println("9");
		}
	}

	HashMap<Long, Integer> hoge(int[] a){
		HashMap<Long, Integer> map=new HashMap<Long, Integer>();
		LinkedList<Long> que=new LinkedList<Long>();

		long[] pow=new long[n];
		for(int i=0; i<n; i++){
			pow[i]=(long)pow(base, i);
		}

		long hash0=hash(a);
		map.put(hash0, 0);
		que.offer(hash0);

		for(; !que.isEmpty();){
			long hash=que.poll();
			if(map.get(hash)>=4){
				break;
			}
			for(int cent=0; cent<n; cent++){
				// odd length
				long hashO=hash;
				for(int w=1; cent-w>=0&&cent+w<n; w++){
					// [cent-w, cent+w]
					long i=hashO/pow[cent-w]%base;
					long j=hashO/pow[cent+w]%base;
					hashO=hashO+(-i+j)*pow[cent-w]+(-j+i)*pow[cent+w];
					if(!map.containsKey(hashO)){
						map.put(hashO, map.get(hash)+1);
						que.offer(hashO);
					}
				}
				// even length
				long hashE=hash;
				for(int w=0; cent-w>=0&&cent+1+w<n; w++){
					// [cent-w, cent+1+w]
					long i=hashE/pow[cent-w]%base;
					long j=hashE/pow[cent+1+w]%base;
					hashE=hashE+(-i+j)*pow[cent-w]+(-j+i)*pow[cent+1+w];
					if(!map.containsKey(hashE)){
						map.put(hashE, map.get(hash)+1);
						que.offer(hashE);
					}
				}
			}
		}
		return map;
	}

	long hash(int[] _){
		long hash=0;
		for(int i=0; i<n; i++){
			hash=hash*base+_[i];
		}
		return hash;
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 51000
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;


int main() {
    int N;
    cin >> N;
    vi a(N);
    rep(i, N) {
        cin >> a[i];
    }
    int anycolor = 0;
    set<int> color;
    rep(i, N) {
        rep(j, 8) {
            if (a[i] >=  400 * j && a[i] < 400 * (j + 1)) color.insert(j);
        }
        if (a[i] >=  3200) anycolor++;
    }
    int mini;
    int maxi;
    if(!color.empty()){ 
        mini = color.size(); 
        maxi = mini + anycolor;
    }
    else {
        mini = 1;
        maxi = anycolor;
    }
    cout << mini << " " << maxi << endl;
}

Measured memory_bytes: 256
function main(input) {
  const [x, y] = input[0].trim().split(" ").map(i => parseInt(i));
  let ans = false;

  for(let i=0;i<=x;i++){
    if((i*2+(x-i)*4)===y){
      ans = true;
      break;
    }
  }
  console.log(ans?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 29628
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m;
    cin>>n>>m;
    vl ps(n);
    cin>>ps;
    rep(i, n) ps[i]--;

    UnionFind ds(n);
    rep(i, m) {
        ll x, y;
        cin>>x>>y; x--; y--;
        ds.merge(x, y);
    }
    
    map<ll, set<ll>> mp;
    ll ans = 0;
    rep(i, n) {
        auto p = mp[ds.root(i)].insert(i);
        if (!p.se) ans++;
        p = mp[ds.root(i)].insert(ps[i]);
        if (!p.se) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 20608
///        Saniuzzaman Robin
///        CSE'08, Comilla University
///        LET THE FUN BEGIN

#include<bits/stdc++.h>
using namespace std;

typedef     long long int                ll;
typedef     unsigned long long int       ull;
typedef     vector< int >                vint;
typedef     vector< ll >                 vlong;
typedef     vector< vint >               vvint;
typedef     pair< int,int >              pint;
typedef     pair< ll, ll >               plong;
typedef     vector< pint >               vpi;
typedef     vector< plong >              vpli;

#define     dbl                 double
#define     pf                  printf
#define     sc                  scanf
#define     MAX                 1000007
#define     MOD                 1000000007
#define     PI                  2*acos(0.0)
#define     fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define     all(a)              (a).begin(),(a).end()
#define     sz(x)               (int)x.size()
#define     pb                  push_back
#define     mp                  make_pair
#define     mem(a,b)            memset(a, b, sizeof(a) )
#define     gcd(a,b)            __gcd(a,b)
#define     lcm(a,b)            (a*(b/gcd(a,b)))
#define     ifor(x,n)           for( int i=x ; i<n ;i++)
#define     lfor(x,n)           for( long long int i=x; i<n; i++)

int main()
{

    int a,b,c;
    cin>>a>>b>>c;
    if(a>=b)
    {
        if(c>=a-b)
            cout<<c-(a-b)<<endl;
        else
            cout<<0<<endl;
    }




    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vp = vector<pii>;
using vs = vector<string>;
using qi = queue<int>;
using qp = queue<pii>;
using pqi = priority_queue<int>;
using pqim = priority_queue<pii, vector<pii>, greater<pii> >;
using ppp = pair<int, pair<int, int>>;
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define pb push_back
const ll mod = 998244353;
const ll inf = 1e18;

int x, y;

void input() {
	cin >> x >> y;
}

void solve() {
	int b = y - 2 * x;
	int a = 2 * x - b;
	if (a % 2 || b % 2)
		cout << "No";
	else if (a < 0 || b < 0)
		cout << "No";
	else cout << "Yes";
	return;
}

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

	input();
	solve();
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
	//Enter your code here Tanmay:)
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=1250;i++)
	{
		int x=i*0.08;
		int y=i*0.10;
		if(x==a&&y==b)
			{
				cout<<i;
				return;
			}
	}
	cout<<"-1";
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
/*
int eulortotent(int n)
     {
    //Enter your code here Tanmay:)
    int total=n;
        for(int p=2;p*p<=n;p++)
        {
            if (n%p==0)
        {
            total /= p;
            total *= (p-1);
            while ( n % p == 0 ) 
                n /= p;
        }
    }

    if(n>1)
    {
        total/=n;
        total*=(n-1);
    }

  return total;
}
*/

Measured memory_bytes: 384
W, H, N = map(int, input().split())
p = [list(map(int, input().split())) for i in range(N)]

xl, xr, yl, yh = 0, W, 0, H

for xi, yi, ai in p:
  if ai == 1:
    if xl < xi:
      xl = xi
  if ai == 2:
    if xr > xi:
      xr = xi
  if ai == 3:
    if yl < yi:
      yl = yi
  if ai == 4:
    if yh > yi:
      yh = yi

if xr -xl < 0 or yh - yl < 0:
  ans = 0
else:
  ans = (xr - xl) * (yh - yl)
print(ans)

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

typedef struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
}node;

#define NIL NULL

node* ROOT;
void insert(int);
void inorder(node*);
void preorder(node*);

int N;

int main(){
  int i,x;
  char com[20];
  scanf("%d",&N);

  for ( i = 0; i < N; i++ ){
    scanf("%s", com);
      if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(ROOT);
      printf("\n");
      preorder(ROOT);
      printf("\n");
  }
}
  return 0;
}


void insert(int z){
  node* T;
  node* y;
  node* x;
  T = (node *)malloc(sizeof(node)*1);
  y = NIL;
  x = ROOT;
  T->key = z;
  T->left = NIL;
  T->right = NIL;
  while(x != NIL){
    y = x;
    if(T->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  T->parent = y;

  if(y == NIL){
    ROOT = T; // Tree is empty
  }
  else if(T->key < y->key){
    y->left = T;
  }

  else{
    y->right = T;
  }
}

void inorder(node* n){

  if(n != NIL){
    inorder(n->left);
      printf(" %d",n->key);
      inorder(n->right);
  }
}

void preorder(node* n){
  if(n != NIL){
    printf(" %d",n->key);
    preorder(n->left);
    preorder(n->right);
  }
}

Measured memory_bytes: 24040
from functools import reduce
from fractions import gcd

N = int(input())
*A, = map(int, input().split())

l_gcd = [0]*(N+2)
r_gcd = [0]*(N+2)

l_gcd[0] = A[0]
for i in range(1, N+1):
    l_gcd[i] = gcd(l_gcd[i-1], A[i-1])

r_gcd[N+1] = A[N-1]
for i in range(1, N+1)[::-1]:
    r_gcd[i] = gcd(r_gcd[i+1], A[i-1])

ans = 0
for i in range(1, N+1):
    if i==1:
        ans = max(ans, r_gcd[i+1])
    elif i==N:
        ans = max(ans, l_gcd[i-1])
    else:
        ans = max(ans, gcd(l_gcd[i-1], r_gcd[i+1]))

print(ans)

Measured memory_bytes: 90336