akhauriyash/Code-Regression huggingface dataset:
#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>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int s, t;
  cin >> s >> t;

  int cnt = 0;
  int a = 1;
  while(a < t) {
    cnt++;
    a+=s-1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 888
N, D = map(int, input().split())
X = []
for i in range(N):
    X.append([int(i) for i in input().split()])
ans = 0
def d(a, b):
    num = 0
    for x, y in zip(a, b):
        num += (x-y)**2
    return num**(1/2)

for i in range(N-1):
    for j in range(i+1, N):
        a = d(X[i], X[j])
        if a == int(a):
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <sstream>
#include <cassert>
#include <queue>
#include <bitset>
#include <ctime>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define sz(x) ((int)x.size())
#define fst first
#define snd second
typedef long long ll;
typedef pair<int, int> ii;
const int MAXN = -1;

int n, w, h;

int main(){
	while(scanf("%d %d %d", &n, &w, &h) >= 1){
		printf("%d\n", (n-w+1)*(n-h+1));
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

ll gettime64(ll y,ll m,ll d){
  struct tm poi;
  poi.tm_year = y-1900;
  poi.tm_mon = m-1;
  poi.tm_mday = d;
  poi.tm_hour = poi.tm_min = poi.tm_sec = 0;
  poi.tm_isdst = -1;
  return mktime(&poi);
}

int toint(string s){
  return atoi(s.c_str());
}

vi split(string base, char spl){
  vi result;
  string::size_type pos = 0;
  string::size_type bef = 0;
  base += spl;
  while( (pos = base.find_first_of(spl,bef)) != string::npos ){
    result.push_back(toint(base.substr(bef,pos-bef)));
    bef = pos+1;
  }
  return result;
}

#define AD 146097
#define MAYA 1872000

int main(){
  while(true){
    string s;
    cin>>s;
    if(s=="#")break;
    vi input = split(s,'.');
    if(input.size()==3){
      // yyyy.mm.dd
      ll y = input[0];
      ll m = input[1];
      ll d = input[2];
      ll year_down = (y - 2013)/400;
      y -= year_down*400;
      ll birth = gettime64(y,m,d);
      ll origin = gettime64(2012,12,21);
      ll sub = (birth-origin)/24/60/60;
      sub += year_down*AD%MAYA;
      sub %= MAYA;
      int ki = sub%20; sub/=20;
      int w = sub%18;  sub/=18;
      int t = sub%20;  sub/=20;
      int ka = sub%20;
      int b = sub/20;
      printf("%d.%d.%d.%d.%d\n",b,ka,t,w,ki);
    }else{
      // b.ka.t.w.ki
      ll val = 0;
      val += input[0];  val *= 20;
      val += input[1];  val *= 20;
      val += input[2];  val *= 18;
      val += input[3];  val *= 20;
      val += input[4];
      ll year_add = val/AD;
      val %= AD;
      val *= 24*60*60;
      val += gettime64(2012,12,22);
      struct tm *birth = gmtime((time_t*)&val);
      int year = birth->tm_year + 1900 + year_add*400;
      int month = birth->tm_mon + 1;
      int day = birth->tm_mday;
      printf("%d.%d.%d\n",year,month,day);
    }
  }
  return 0;
}

Measured memory_bytes: 1308
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int sort(const void *first,const void *second) {
	int *a = (int*)first;
	int *b = (int*)second;
	if (*a > *b) {
		return +1;
	}
	else if (*b > *a) {
		return -1;
	}
	else {
		return 0;
	}
}

int main() {
	int N = 0;
	int d[100000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &d[i]);
	qsort(d, N, sizeof(int), sort);
	//for (int i = 0; i < N; i++) printf("%d", d[i]);
	printf("%d\n", (d[(N / 2)] - d[(N / 2) - 1]));

	return 0;
}

Measured memory_bytes: 892
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
    return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
          x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def num_roots(self):
    return len([i for i, x in enumerate(self.parents) if x < 0])

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def num_members(self,x):
    return abs(self.parents[self.find(x)])

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
uf = UnionFind(N)
ans = []
for i in range(Q):
  t,u,v = map(int, input().split())
  if t==0:
    uf.union(u,v)
  else:
    if uf.same(u,v):
      ans.append(1)
    else:
      ans.append(0)
print(*ans, sep='\n')

Measured memory_bytes: 80984
max,cost = 0,0
N = int(input())
S = input()

def update(max,cost):
    a = max
    if cost > a:
        a = cost
    return a

for i in range(N):
    if S[i] == 'I':
        cost += 1
        max = update(max,cost)
    elif S[i] == 'D':
        cost -= 1

print(max)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char c = scan.next().charAt(0);
		
		if (c == 'a' | c == 'i' | c == 'u' | c == 'e' | c == 'o') {
			System.out.println("vowel");
		}else {
			System.out.println("consonant");
		}
	}
}

Measured memory_bytes: 35536
#include <bits/stdc++.h>
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
int main()
{
    int N, W;
    std::cin >> N >> W;
    std::vector<int> v(N), w(N);
    for (int i = 0; i < N; i++) { std::cin >> v[i] >> w[i]; }
    std::vector<int> dp(W + 1, 0);
    for (int i = 0; i < N; i++) {
        for (int j = w[i]; j <= W; j++) { dp[j] = std::max(dp[j], dp[j - w[i]] + v[i]); }
    }
    std::cout << *max_element(dp.begin(), dp.end()) << std::endl;
    return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> L(N);

    for(int i =0; i < N; i++){
        cin >> L[i];
    }

    sort(L.begin(), L.end());

    int lenSum = accumulate(L.begin(), L.end() - 1, 0);
    if(L[N - 1] < lenSum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
import math
while 1:
    r0,w0,c,r = map(int,input().split())
    if r0 == 0 and w0 == 0 and c == 0 and r == 0:
        break
    for i in range(100000):
        if c <= (r0+i*r) // w0:
            print(i)
            break


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#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++)

int main() {
  int n;
  int ans=0;
  cin >> n;
  vint d(n);
  rep(k,n){
      cin >> d.at(k);
  }
  rep(i,n){
    rep(j,n){
      if (i < j) ans+=d.at(i)*d.at(j);
    }
  }
  cout << ans << endl;
      
  return 0;
}


Measured memory_bytes: 256
#t = Time.now
#N, K, Q = 2000, 10, 10
#as = (0...N).to_a.shuffle
N, K, Q = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
as_sort = as.sort

ans = Float::INFINITY
rows = [as.dup]
N.times do |i|
    min = as_sort[i]
    avail = []
    rows.each do |row|
        avail.concat(row.sort[0, row.length-K+1]) if row.length >= K
    end
    avail.sort!
    if avail.length >= Q
        cand = avail[Q-1] - min
        ans = cand if ans > cand
    end
    rows.length.times do |i|
        index = rows[i].index(min)
        if index == rows[i].length - 1
            rows[i].pop
        elsif index == 0
            rows[i].shift
        elsif index
            rows.push(rows[i][index+1, N])
            rows[i].slice!(index, N)
        end
    end
end

puts ans
#p Time.now - t

Measured memory_bytes: 17016
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
typedef long long int ll;
typedef long double ld;
using namespace std;

//----------------------------------------------------------------
int MAX_V = 1000001;
vvi G = vv(MAX_V, 0, 0, int);
vvi rG = vv(MAX_V, 0, 0, int);
vector<bool> used(MAX_V);
vector<int> cmp(MAX_V);
vector<int> depth(1000001, -1);
vector<int> vs;
void add_edge(int from, int to){ G[from].push_back(to), rG[to].push_back(from);}
void dfs(int v){
  used[v] = true;
  for(int i=0;i<G[v].size();i++) if(!used[G[v][i]]) dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  for(int i=0;i<rG[v].size();i++) if(!used[rG[v][i]]) rdfs(rG[v][i], k);
}
int scc(int V){
  for(int i=0;i<MAX_V;i++) used[i] = false;
  vs.clear();
  for(int i=0;i<=V;i++) if(!used[i]) dfs(i);
  for(int i=0;i<MAX_V;i++) used[i] = false;
  int k = 0;
  for(int i=vs.size()-1;i>=0;i--) if(!used[vs[i]]) rdfs(vs[i], k++);
  return k;
}
//-------------------------------------------------------------------
void KMPMatch(string src, string pat){
    int ini[pat.size()], i=1, j=0;
    ini[0] = 0;
    while(i<pat.size()){
      if(pat[i] == pat[j]) j++, ini[i] = j, i++;
      else if(j == 0) ini[i] = 0, i++;
      else j = ini[j - 1];
    }
    i = j = 0;
    while(j<pat.size()&&i<src.size()/2+pat.size()-2){
      if(src[i] == pat[j]) i++, j++;
      else if(j == 0) i++;
      else j = ini[j - 1];
      if(j==pat.size()-1) add_edge(abs(i-j), i%(src.size()/2));
    }
}

int df(int now){
  if(G[now].size()==0) return depth[now] = 0;
  if(depth[now]>0) return depth[now];
  for(int i=0;i<G[now].size();i++) {
    if(now==G[now][i]){
      std::cout << -1 << '\n';
      exit(0);
    }
    depth[now] = max(depth[now], df(G[now][i])+1);
  }
  return depth[now];
}
//-------------------------------------------------------------------

int main(int argc, char const *argv[]) {
  string s, t;
  std::cin >> s >> t;
  string tmp = s;
  while(s.size()<t.size()) s+=tmp;
  KMPMatch(s+s, t+'#');
  scc(s.size());
  vector<int> table(s.size()*2, 0);
  for(int i=0;i<s.size();i++){
    if(table[cmp[i]]!=0){
      std::cout << -1 << '\n';
      return 0;
    }
    table[cmp[i]]++;
  }
  int ans = 0;
  for(int i=0;i<s.size();i++) ans = max(ans, df(i));
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 157028
while(True):
    h, w = map(int, input().split())
    if(h == 0 and w == 0):
        break
    for i in range(h):
        s = ''
        for j in range(w):
            if (i + j) % 2 == 0:
                s += '#'
            else:
                s += '.'
        print(s)
    print()



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1){
		cout<<"Hello World"<<endl;
		return 0;
	}
	else
	{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
		return 0;
	}
	return 0;
}


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

int main(void){
    int n,m;
    int ans = 0;
    cin >> n >> m;
    ans = pow(100,n)*m;
    if(m == 100)ans+=pow(100,n);
    cout << ans << endl;
    return 0;
}

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

int main() {
  int s; cin >> s;
  int fir,sec;
  fir = s / 100;
  sec = s - fir*100;
  
  bool YYMM = true, MMYY = true;
  if(fir > 12 || fir == 0){
    MMYY = false;
  }
  if(sec > 12 || sec == 0){
    YYMM = false;
  }
  
  if(YYMM && MMYY){
    cout << "AMBIGUOUS" << endl;
  }
  else if(YYMM){
    cout << "YYMM" << endl;
  }
  else if(MMYY){
    cout << "MMYY" << endl;
  }
  else{
    cout << "NA" << endl;
  }
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(Long.parseLong(sc.next()));
        }
        if (k >= n) {
            System.out.println(0);
            return;
        }
        Collections.sort(list);
        for (int i = 0; i < k; i++) {
            list.remove(list.size() - 1);
        }
        long sum = list.stream().mapToLong(l -> l.longValue()).sum();
        System.out.println(sum);
    }
}


Measured memory_bytes: 66432
A = [input().split() for _ in range(3)]
N = int(input())
c = [[False]*3 for _ in range(3)]
for _ in range(N):
    B = input()
    for i in range(3):
        if B in A[i]:
            c[i][A[i].index(B)] = True

def solve(c):
    y = "Yes"
    n = "No"
    for i in range(3):
        if c[i][0] and c[i][1] and c[i][2]:
            return y
        if c[0][i] and c[1][i] and c[2][i]:
            return y
    if c[0][0] and c[1][1] and c[2][2]:
        return y
    if c[0][2] and c[1][1] and c[2][0]:
        return y

    return n

print(solve(c))


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(_itr, array) { cin >> *(_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
//
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}

template <class T>
istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}

const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w;
	cin >>h>>w;
	Pi at, ter;
	int ans = 0;
	cin >> at >> ter;
	at.F--;
	at.S--;
	ter.F--;
	ter.S--;
	vector<string> data(h);
///	input(data);
	cin >> data;
	VVi dis(h, Vi(w, INF));
	deque<Pi> q;
	q.push_back(at);
	dis[at.F][at.S] = 0;
	while(!q.empty()){
		at = q.front();
		q.pop_front();
		for (int ni = max(0, at.F - 2); ni < min(h, at.F + 3);ni++){
			for (int nj = max(0, at.S - 2); nj < min(w, at.S + 3);nj++){
				if (data[ni][nj] == '#') continue;
				if(abs(at.F-ni)+abs(at.S-nj)==1){
					if(chmin(dis[ni][nj],dis[at.F][at.S])){
						q.push_front(mp(ni, nj));
					}
				}else{
					if (chmin(dis[ni][nj], dis[at.F][at.S]+1)) {
						q.push_back(mp(ni, nj));
					}
				}
		}
			 }
	}

	ans = dis[ter.F][ter.S];
	if(ans==INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	//	cout<<ans<<endl;
}

Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,x,t;
  cin >> n >> x >> t;
  int sum=0;
  int sum_t=0;
  while(n>sum){
    sum += x;
    sum_t += t;
  }
  cout << sum_t << endl;
}

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

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<int>> a(h + 1, vector<int>(w + 1));
    rep(i, h) rep(j, w) cin >> a[i][j];

    rep(i, h) rep(j, w) {
        a[i][w] += a[i][j];
        a[h][j] += a[i][j];
        a[h][w] += a[i][j];
    }

    rep(i, h + 1) {
        rep(j, w + 1) {
            if (j != 0)
                cout << " ";
            cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 550
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    vector<ll>s(n+1);
    s[0]=0;
    REP(i,n){
        s[i+1]=s[i]+a[i];
    }
    map<int,int>w;
    REP(i,n){
        w[s[i+1]%m]++;
    }
    w[0]++;
    ll ans=0;
    for(auto p:w){
        ans+=(ll)p.second*(p.second-1)/2;
    }
    OUT(ans);
    return 0;
}

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

using namespace std;

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

  int n, m; cin >> n >> m;
  int h[n];
  for(int i = 0; i<n; ++i) cin >> h[i];
  vector<vector<int> > adj(n);
  for(int i = 0; i<m; ++i) {
    int u, v; cin >> u >> v;
    u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  int ret = 0;
  for(int i = 0; i<n; ++i) {
    bool good = true;
    for(auto x : adj[i]) {
      if(h[x] >= h[i]) good = false;
    }
    if(good) ret++;
  }
  cout << ret << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int mask[101];
int P[101];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>x;
		FOR(j,x) cin>>y, mask[i]|=1<<(y-1);
	}
	FOR(i,M) cin>>P[i];
	
	int ret=0;
	FOR(x,1<<N) {
		int ok=0;
		FOR(y,M) {
			int r=x&mask[y];
			if(__builtin_popcount(r)%2==P[y]) ok++;
		}
		if(ok==M) ret++;
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val AB = Array(N) { listOfInt() }.sortedBy { it[1] }
    var ans = true
    var t = 0
    repeat(N) {
        t += AB[it][0]
        if (t > AB[it][1]) ans = false
    }
    println("${if (ans) "Yes" else "No"}")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

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


int main(){
int A, B, C;
cin >>A>>B>>C;
if(A<B)swap(A,B);
if(A<C)swap(A,C);
int dif = (A-B)+(A-C);
int ans= dif/2;
if(dif%2==1)ans+=2;

cout<<ans<<endl;

}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
Alice = 0
Bob = 0
i = 0
for i in range(0,N,2):
    Alice += a[i]
    if i+1 >= N:
        break
    Bob += a[i+1]
print(Alice - Bob)

Measured memory_bytes: 9020
#include<vector>
#include<climits>
#include<iostream>
using namespace std;

class RangeMaximumQueryTree{
public:
  vector<long long> data;
  int size;
  int height; // the number of edges between the root and leaves
  long long maximum_util(int bidx, int eidx, int data_idx, int dbi, int dei){
    if((bidx <= dbi) && (dei <= eidx)){
      return data[data_idx];
    }

    if((eidx <= dbi) || (dei <= bidx)){
      return LLONG_MIN;
    }

    int dmi = (dbi + dei) / 2;
    return max(
               maximum_util(bidx, eidx, 2 * data_idx + 1, dbi, dmi),
               maximum_util(bidx, eidx, 2 * data_idx + 2, dmi, dei)
               );
  }
public:
  RangeMaximumQueryTree(int size){
    this->size = size;
    for(height = 0; (1 << height) < size; height++){
    }
    data = vector<long long>((1 << (height + 1)) - 1, LLONG_MIN);
  }
  const long long DEFAULT_VALUE = LLONG_MIN;
  void set(int idx, long long val){
    int leaf_idx = (1 << height) - 1 + idx;
    data[leaf_idx] = val;

    for(int node_idx = (leaf_idx - 1) / 2; node_idx > 0; node_idx = (node_idx - 1) / 2){
      data[node_idx] = max(data[2 * node_idx + 1], data[2 * node_idx + 2]);
    }
    data[0] = max(data[1], data[2]);
  }
  long long maximum(int begin, int end){
    return maximum_util(begin, end, 0, 0, 1 << height);
  }
};

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

  vector<int> h(N);
  for(auto& hh: h){
    cin >> hh;
  }

  vector<long long> a(N);
  for(auto& aa: a){
    cin >> aa;
  }

  vector<long long> dp(N);
  auto tree = RangeMaximumQueryTree(N + 1);
  dp[0] = a[0];
  tree.set(h[0], dp[0]);
  /*
  for(auto t: tree.data){
    cout << t << ' ';
  }cout << endl;
  */
  for(int i = 1; i < N; i++){
    dp[i] = max(0LL, tree.maximum(0, h[i])) + a[i];
    tree.set(h[i], dp[i]);
    dp[i] = max(dp[i - 1], dp[i]);
  }
  /*
  for(auto x: dp){
    cout << x << ' ';
  }cout << endl;
  */
  cout << dp[N - 1] << endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 5e5+23;

pair<pair<int, int>, int> qs[N];
int c[N], f[N], last[N], ans[N], bit[N], n, q;

void add(int idx, int val) {
  for (; idx <= n; idx += idx & -idx)
    bit[idx] += val;
}

int sum(int r) {
  int ret = 0;
  for (; r > 0; r-=r&-r)
    ret += bit[r];
  return ret;
}

int sum(int l, int r) {
  return sum(r+1) - sum(l);
}

void solve() {
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; ++i) scanf("%d", c+i);
  for (int i = 0; i < q; ++i) {
    scanf("%d%d", &qs[i].first.first, &qs[i].first.second);
    --qs[i].first.first;
    --qs[i].first.second;
    qs[i].second = i;
  }
  sort(qs, qs+q, [](const auto &x, const auto &y){
    return x.first.second < y.first.second;
  });
  int qq = 0;
  memset(last, -1, sizeof(last));
  for (int i = 0; i < n; ++i) {
    if (last[c[i]] != -1)
      add(last[c[i]]+1, -1);
    last[c[i]] = i;
    add(i+1, 1);
    while (qq < q && qs[qq].first.second == i) {
      ans[qs[qq].second] = sum(qs[qq].first.first, qs[qq].first.second);
      ++qq;
    }
  }
  for (int i = 0; i < q; ++i) {
    printf("%d\n", ans[i]);
  }
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 17440
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

using Iterator = std::string::iterator;
std::string String(Iterator& it);
char Letter(Iterator& it);

std::string Cipher(Iterator& it) {
  if (*it == ']') {
    ++it;
    return "";
  }
  if (*it == '.') {
    return "";
  }
  else {
    auto str = String(it);
    return str + Cipher(it);
  }
}
std::string String(Iterator& it) {
  if (*it == '[') {
    auto str = Cipher(++it);
    reverse(str.begin(), str.end());
    return str;
  }
  else {
    return std::string({ Letter(it) });
  }
}
char Letter(Iterator& it) {
  if (*it == '+') {
    char tmp = Letter(++it);
    return tmp == 127 ? tmp : tmp + 1;
  }
  else if (*it == '-') {
    char tmp = Letter(++it);
    return tmp == 127 ? tmp : tmp - 1;
  }
  else {
    char tmp = *it;
    ++it;
    return tmp == '?' ? 127 : tmp - 'A';
  }
}

int main() {
  while (true) {
    string input;
    cin >> input;
    if (input == ".") {
      break;
    }
    input += ".";
    auto it = input.begin();
    auto str = Cipher(it);
    for (auto& v : str) {
      if (v == 127) {
        v = 'A';
        continue;
      }
      v %= 26;
      v += 26;
      v %= 26;
      v += 'A';
    }
    cout <<str << endl;
  }
  return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int l, r;
        cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod= 1e9+7;
const ll mod2=1271309838631957LL;
long double PI = acosl(-1);
const ll inf = 1e15;
const int nmax = 1e5+10;
const int MAXLG = log2(nmax)+1;


ll val[1<<17];
ll dp[1<<17];


int mat[17][17];

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

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

    for(int mask=1; mask<(1<<n); mask++){
        vector<int>tmp;
        for(int i=0; i<16; i++){
            if(mask&(1<<i)) tmp.push_back(i);
        }
        for(int i=0; i<tmp.size(); i++){
            for(int j=i+1; j<tmp.size(); j++){
                val[mask]+=(ll)mat[tmp[i]][tmp[j]];
            }
        }
    }

    for(int mask = 0; mask<(1<<n); mask++){
        dp[mask] = val[mask];
        for(int i = mask; i > 0; i = (i-1)&mask){
            dp[mask] = max(dp[mask^i]+dp[i], dp[mask]);
        }
    }

    cout<<dp[(1<<n)-1];

}





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

const int maxn = 1e6 + 1;
bitset<maxn> prime;
vector<int> sf(maxn);

void seive() {
 prime.set();
 prime[0] = prime[1] = false;
 for(int i = 2; i < maxn; i++) {
  if(prime[i]) {
   sf[i] = i;
   for(int j = 2 * i; j < maxn; j += i) {
    sf[j] = i;
    prime[j] = false;
   }
  }
 }
}

vector<int> c(maxn);

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 seive();
 int n;
 cin >> n;
 vector<int> a(n);
 int gd = 0;
 for(auto& i: a) {
  cin >> i, gd = __gcd(gd, i);
  int x = i;
  while(x != 1) {
   int ss = sf[x];
   c[ss]++;
   while(x % ss == 0) x /= ss;
  }
 }
 bool ok = true;
 for(int i = 2; i < maxn; i++) ok &= (c[i] <= 1);
 if(ok) {
  cout << "pairwise coprime\n";
 }
 else if(gd == 1) cout << "setwise coprime\n";
 else cout << "not coprime";
 return 0;
}


Measured memory_bytes: 15040
#include <stdio.h>
#include <string.h>

char is_sosuu[1000001];
char ok[1000001];

void make_sosuulist(void) {
	int i,j;
	for(i=0;i<=1000000;i++) {
		is_sosuu[i]=1;
	}
	is_sosuu[0]=is_sosuu[1]=0;
	for(i=2;i<=1000000;i++) {
		if(is_sosuu[i]) {
			for(j=i+i;j<=1000000;j+=i)is_sosuu[j]=0;
		}
	}
}

int main(void) {
	int yosan;
	int dish_num;
	int dishes[30];
	int i,j;
	make_sosuulist();
	while(1) {
		scanf("%d%d",&dish_num,&yosan);
		if(dish_num==0 && yosan==0)break;
		for(i=0;i<dish_num;i++)scanf("%d",&dishes[i]);
		memset(ok,0,sizeof(ok));
		ok[0]=1;
		for(i=0;i<=yosan;i++) {
			if(ok[i]) {
				for(j=0;j<dish_num;j++) {
					if(i+dishes[j]<=yosan)ok[i+dishes[j]]=1;
				}
			}
		}
		for(i=yosan;i>0;i--) {
			if(ok[i] && is_sosuu[i])break;
		}
		if(i<=0)puts("NA");
		else printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 2368
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main(){
    ll a,b,ans2;
    double ans1;
    cin>>a>>b;
    ans1=(double)(a+b)/2;
    ans2=(a+b)/2;
    
    if(ans1==ans2)
     cout<<ans2;
     else
     cout<<"IMPOSSIBLE"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
inline int roundup(int a, int b) { return (((a + (b -1)) / b)); }
using namespace std;

signed main(void) {
    int n;
    cin >> n;
    cout << ((n % 1000 == 0)? 0 : (1000-(n%1000))) << '\n';
    return 0;
}

Measured memory_bytes: 3660
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int n, k;
  cin >> n >> k;
  assert(n >= 2);
  vector<li> h(n);
  rep(i, n) cin >> h[i];
  vector<li> mem(n, -1);
  mem[n - 1] = 0;
  mem[n - 2] = abs(h[n - 2] - h[n - 1]);
  rrep(i, n - 2) {
    mem[i] = (1 << 30);
    forn(j, i + 1, 1 + i + min(k, n - 1 - i)) {
      mem[i] = min(mem[i], abs(h[i] - h[j]) + mem[j]);
    }
  }
  cout << mem[0] << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0);
  return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 1792
fn downval(c: &Vec<usize>, lastvals: &Vec<usize>, d: usize) -> usize {
    lastvals.iter()
        .enumerate()
        .map(|pair| c[pair.0] * (d + 1 - pair.1))
        .sum()
}

fn main() {
    let mut d = String::new();
    std::io::stdin().read_line(&mut d).ok();
    let d: usize = d.trim().parse().unwrap();
    let mut c = String::new();
    std::io::stdin().read_line(&mut c).ok();
    let c: Vec<usize> = c.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut satisfied: Vec<Vec<usize>> = vec![vec![]; d];
    let mut lastvals: Vec<usize> = vec![0; 26];
    for i in 0..d {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let s: Vec<usize> = s.trim().split_whitespace().map(|t| t.parse().unwrap()).collect();
        satisfied[i] = s;
    }
    let mut result: isize = 0;
    for i in 0..d {
        let mut t = String::new();
        std::io::stdin().read_line(&mut t).ok();
        let t: usize = t.trim().parse::<usize>().unwrap() - 1usize;
        lastvals[t] = i+1;
        result += satisfied[i][t] as isize;
        result -= downval(&c, &lastvals, i) as isize;
        println!("{}", result);
    }
}


Measured memory_bytes: 2232
using System;
using System.Linq;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int sum = line.Sum();
        int ans = int.MaxValue;
        int temp = 0;
        for (int i = 0; i < n; i++)
        {
            temp += line[i];
            sum -= line[i];
            ans = Math.Min(ans, Math.Abs(temp - sum));
        }
        Console.WriteLine(ans);
    }
}

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

#define pb push_back
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define int long long
const int N = 1e6 + 10;

signed main(){

	int n , k ;
	cin >> n >> k;

	double ans = 0;

	for(int i = 1 ; i <= n ; ++i){
		
		int cur = i;
		double tmp = 1.0/n;
		while(cur < k){

			cur*=2;
			tmp/=2;
		}

		ans += tmp;
	}

	cout<<setprecision(15)<<fixed<<ans<<endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|i| i.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let n = input[0];
    let m = input[1];

    let mut count = 0;
    if n > 1 {
        count += n * (n - 1) / 2;
    }
    if m > 1 {
        count += m * (m - 1) / 2;
    }

    println!("{}", count);
}

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

#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
                                           	
const int N = 5e5 + 123, M = 2e3 + 123, inf = 1e9 + 123, mod = 1e9 + 7;
const ll INF = 1e18;

bool used[N];
int d[N];
vector < int > g[N];

void dfs(int v) {
	used[v] = 1;
	for (auto to : g[v]) {
		if (!used[to]) {
			dfs(to);
	 	}
		d[v] = max(d[v], d[to] + 1);
	}
}

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
	}
	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			dfs(i);
		}
	}
	cout << *max_element(d + 1, d + n + 1);
	return 0;   	
}                                                         

Measured memory_bytes: 17792
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


D = z()
C = zz()
S = defaultdict(list)
for i in range(D):
    S[i + 1] = zz()
for i in range(D):
    print(i % 26 + 1)


Measured memory_bytes: 27640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
   cin>>s;
   int maxcount=0,count=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')
            count++;
        else
            count=0;
        if(maxcount<count)
            maxcount=count;

    }
   cout<<maxcount;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin>>s;
	
	if(s.back() == 's')
	  s += "es";
	else
	  s += "s";
	  
	cout<<s<<"\n";  
	
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#pragma warning( disable:4996 )


int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if (b%a == 0) {
		printf("%d\n", a + b);
	}
	else {
		printf("%d\n", b - a);
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main(void) {
    int a, b, c; char ch;
    while (1){
        scanf("%d %c %d", &a, &ch, &b);
        if (ch == '?') break;
        if (ch == '+') c = a + b;
        else if (ch == '-') c = a - b;
        else if (ch == '*') c = a*b;
        else if (ch == '/') c = a / b;
        printf("%d\n", c);
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>

using namespace std;

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

node *root,*NIL;

void insert(int k)
{
    node *y=NIL;
    node *x=root;
    node *z;

    z=(node*)malloc(sizeof(node));
    z->key=k;
    z->left=NULL;
    z->right=NULL;

    while(x!=NULL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        }else{
            x=x->right;
        }
    }

    z->parent=y;

    if(y==NIL){
        root=z;
    }else{
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void inorder(node *u)
{
    if(u==NULL){
        return ;
    }
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(node *u)
{
    if(u==NULL){
        return ;
    }
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

node *find(node *u,int k)
{
    while(u!=NIL&&k!=u->key){
        if(k<u->key){
            u=u->left;
        }else{
            u=u->right;
        }
    }
    return u;
}

int main()
{
    int n,k;
    string com;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&k);
            insert(k);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }else{
            scanf("%d",&k);
            node *t=find(root,k);
            if(t!=NULL){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}
/*
10
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
find 16
print
*/



Measured memory_bytes: 22052
n=int(input())
l=list(map(int,input().split()))

ans=[0 for i in range(8)]
rate_3200=0

for i in l:
  if 1<=i<=399:
    ans[0]+=1
  elif 400<=i<=799:
    ans[1]+=1
  elif 800<=i<=1199:
    ans[2]+=1
  elif 1200<=i<=1599:
    ans[3]+=1
  elif 1600<=i<=1999:
    ans[4]+=1
  elif 2000<=i<=2399:
    ans[5]+=1
  elif 2400<=i<=2799:
    ans[6]+=1
  elif 2800<=i<=3199:
    ans[7]+=1
  elif 3200<=i:
    rate_3200+=1
    
if rate_3200==0:
  num=8-ans.count(0)
  print("{} {}".format(num,num))
else:
  count_0=ans.count(0)
  if count_0==8:
    min_num=1
    max_num=rate_3200
  else:
    min_num=8-count_0
    max_num=8-count_0+rate_3200
  print("{} {}".format(min_num,max_num))


Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i, lw[300003] = {}, re[300003] = {}, ans;
    string s;

    scanf("%d", &n);
    cin >> s;

    i = 1;
    while (i < n)
    {
        lw[i] = lw[i - 1];
        if (s[i - 1] == 'W')
            lw[i]++;
        i++;
    }
    i = n - 2;
    while (i >= 0)
    {
        re[i] = re[i + 1];
        if (s[i + 1] == 'E')
            re[i]++;
        i--;
    }

    ans = INF;
    i = 0;
    while (i < n)
    {
        ans = min(ans, lw[i] + re[i]);
        i++;
    }

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

    return 0;
}

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

using namespace std;

int main() {

	string n;
	cin >> n;
	for (int i = 0; i < n.size(); i++) {
		if (n[i] == '1') {
			cout << '9';
		}
		else {
			cout << '1';
		}
	}
	cout << endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

type Node struct {
	Id int
	Left *Node
	Right *Node
}

func main() {
	var n int
	fmt.Scan(&n)

	pre := make([]int, n)
	in := make([]int, n)

	for i := 0; i < n ; i++ {
		fmt.Scan(&pre[i])
	}
	for i := 0; i < n ; i++ {
		fmt.Scan(&in[i])
	}

	root := createTree(pre, in)
	queue := []int{}
	queuePostorder(&root, &queue)
	fmt.Print(queue[0])
	for i := 1; i < n; i++ {
		fmt.Printf(" %d", queue[i])
	}
	fmt.Println()
}

func createTree(pre []int, in []int) Node {
	root := Node{pre[0], nil, nil}
	
	i := 0
	leftPre := []int{}
	leftIn  := []int{}
	for ; i < len(in); i++ {
		if in[i] == root.Id {
			break
		}
		leftPre = append(leftPre, pre[i+1])
		leftIn = append(leftIn, in[i])
	}
	if len(leftPre) > 0 {
		left := createTree(leftPre, leftIn)
		root.Left = &left
	}

	i += 1
	rightPre := []int{}
	rightIn  := []int{}
	for ; i < len(in); i++ {
		rightPre = append(rightPre, pre[i])
		rightIn = append(rightIn, in[i])
	}
	if len(rightPre) > 0 {
		right := createTree(rightPre, rightIn)
		root.Right = &right
	}

	return root
}

func queuePostorder(node *Node, queue *[]int) {
	if node == nil {
		return
	}
	queuePostorder((*node).Left, queue)
	queuePostorder((*node).Right, queue)
	*queue = append(*queue, (*node).Id)
}



Measured memory_bytes: 1204
#!/usr/bin/env pypy3


def solve(r, g, b, n):
    res = 0
    for i in range(n // r + 1):
        rest = n - i * r
        for j in range(rest // g + 1):
            rest2 = n - (i * r + j * g)
            if rest2 >= 0 and rest2 % b == 0:
                res += 1
    return res


def main():
    r, g, b, n = (int(z) for z in input().split())
    res = solve(r, g, b, n)
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 40432
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<functional>
#include<iterator>
#include<math.h>

using namespace std;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	int nw[n] = {};
	for(int i=1;i<n;i++){
		nw[i] = nw[i-1];
		if(s[i-1] == 'W') nw[i]++;
	}
	int ne[n] = {};
	for(int i=n-2;i>=0;i--){
		ne[i] = ne[i+1];
		if(s[i+1] == 'E') ne[i]++;
	}

	int ans=n;
	for(int i=0;i<n;i++){
		ans = min(ans,ne[i]+nw[i]);
	}
	cout << ans << "\n";
		
	return 0;
}

Measured memory_bytes: 2964
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<vector<pair<ll,ll> > > nei(n);
    REP(i,n-1){
        ll a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        nei[a].pb(make_pair(b,c));
        nei[b].pb(make_pair(a,c));
    }
    priority_queue<pair<ll,ll>, vector<pair<ll,ll> >, greater<pair<ll,ll> > > pq;
    ll q,k;
    cin >> q >> k;
    k--;
    vll dis(n,LLINF);
    dis[k] = 0;
    pq.push(make_pair(0,k));
    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();
        for(auto i : nei[p.se]){
            if(dis[i.fi]>dis[p.se]+i.se){
                dis[i.fi]=dis[p.se]+i.se;
                pq.push(make_pair(dis[i.fi], i.fi));
            }
        }
    }
    REP(i,q){
        ll x,y;
        cin >> x >> y;
        x--; y--;
        cout << dis[x]+dis[y] << "\n";
    }
    return 0;
}

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


int tripulGCD(int a, int b, int c)
{
	return std::gcd<int, int>( std::gcd<int, int>(a, b) ,c );
}

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

	long long sum = 0;

	for (int a=1; a<k+1;a++)
	{
		for (int b=1; b<k+1; b++)
		{
			for (int c=1; c<k+1; c++)
			{
				sum += tripulGCD(a, b, c);
			}
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, K);
  int ans = K;
  rep(i, 1, N) {
    ans *= K - 1;
  }
  print(ans);
}


Measured memory_bytes: 256