akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int N;
    vector<int> d(101);
    int ans = 0;
    cin >> N;
    for (int a = 0; a < N;a++){
        cin >> d.at(a);
    }

    for (int b = 0;b<N;b++){
        for (int c = b+1; c < N;c++){
            ans += d.at(b) * d.at(c);
            }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream> 
#include <string>
#include <vector>

using namespace std;
int main() {
    int n, maxValue = 0, count = 0, h;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h;
        if (h >= maxValue) {
            maxValue = h;
            count++;
        }
    }

    cout << count << endl;
    // int n, maxValue = 0, count = 0;
    // cin >> n;
    // vector<int> h(n);
    // for (int i = 0; i < n; i++) {
    //     cin >> h[n];
    //     if (h[n] >= maxValue) {
    //         maxValue = h[n];
    //         count++;
    //     }
    // }

    // cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define int(x) int x; scanf("%d",&x)
#define input(x) scanf("%d",&x)
#define rep(x,n) for(int x = 0; x < n; x++)
#define _br printf("\n")
#define INF 2000000000

vector<pair<int,int> > PathList[10000];
int d[10000];
bool complete[10000];

void dijkstra(int n,vector<pair<int,int> > PathList[]){
    rep(i,n){
        d[i] = INF;
        complete[i] = false;
    }
    d[0] = 0;
    
    int count = 0;
    
    while (count != n) {
        int mind = INF;
        int mindi = 0;
        
        //select
        rep(i,n){
            if (!complete[i] && d[i] < mind) {
                mind = d[i];
                mindi = i;
            }
        }
        
        complete[mindi] = true;
        count++;
        
        //update
        rep(i,PathList[mindi].size()){
            if (PathList[mindi][i].second + d[mindi] < d[PathList[mindi][i].first]) {
                d[PathList[mindi][i].first] = PathList[mindi][i].second + d[mindi];
            }
        }
    }
}


int main(){
    int(n);
    rep(i,n){
        int(k);int(num);
        rep(j,num){
            int(s);int(t);
            PathList[i].push_back(make_pair(s,t));
        }
    }
    
    dijkstra(n,PathList);
    
    rep(i,n){
        printf("%d %d\n",i,d[i]);
    }
    
    return 0;
}

Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    long long s=0;
    cin >> n;
    vector<int> a(100005);
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        s += x;
        a[x]++;
    }
    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int x,y;
        cin >> x >> y;
        s += (y-x)*a[x];
        a[y] += a[x];
        a[x]=0;
        cout << s << endl;

    }
}

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<ll>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);


void solve()
{
    ll n, m;
    cin>>n;
    vector<char>res;
    while(n > 0)
    {
        ll r = n % 26;
        if(r == 0)
        {
            res.push_back('z');
            n = (n/26) - 1;
        }
        else
        {
            res.push_back(r - 1 + 'a');
            n /= 26;
        }
    }
    for(ll i=res.size()-1;i>=0;i--)
        cout<<res[i];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 3648
n, x, y = map(int, input().split())
a = [0] * (n - 1)
for i in range(n - 1):
    for j in range(i + 1, n):
        a[min(j - i - 1, abs(x - 1 - i) + abs(y - 1 - j))] += 1
print(*a, sep="\n")

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int a[3];
    rep(i,3)cin>>a[i];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

using namespace std;

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

    string s;
    int k;
    cin >> s >> k;

    int n = s.size();
    set<string> st;
    for(int i = 0; i < n; ++i){
        for(int j = 1; j < k+1; ++j){
            if(i+j <= n){
                string sub = s.substr(i, j);
//                cout << sub << endl;
                st.insert(sub);
            }
        }
    }
    
    auto itr = st.begin();
    for(int i = 0; i < k-1; ++i) ++itr;
    cout << *itr << endl;
}

Measured memory_bytes: 4836
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
#include<string>
using namespace std;
typedef long long int llint;
int main() {
	char s[200010];
	cin >> s;
	int x, y;
	for (int i = 0;;i++) {
		if (s[i] == 'A') {
			x = i;
			break;
		}
	}
	for (int i = strlen(s) - 1;;i--) {
		if (s[i] == 'Z') {
			y = i;
			break;
		}
	}
	cout << y + 1 - x << endl;
	return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().split())

w = []

for i in range(n):
    w.append(int(input()))
   
def carriable(P, n, k, w):
    j = 0
    for i in range(k):
        sum = 0
        while j < n and sum + w[j] <= P:
            sum += w[j]
            j += 1
    return j

def binary_search(p_left, p_right, n, k, w):
    if p_left == p_right:
        return p_left
    else:
        p_center = (p_left + p_right)//2
        # because we have to search for the smallest p which satisfies carriable(p, n, k, w) = n, 
        # be careful of the inequality condition
        if carriable(p_center, n, k, w) >= n:
            return binary_search(p_left, p_center, n, k, w)
        else:
            return binary_search(p_center + 1, p_right, n, k, w)

p_left = 0
p_right = sum(w)
print(binary_search(p_left, p_right, n, k, w))


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,W; cin >> n >> W;
  vector<int> v(n), w(n);
  for(int i = 0; i < n; ++i)cin >> w[i] >> v[i];
  vector<vector<ll>> dp(n, vector<ll>(W+1,0));
  for(int i = 0; i < n; ++i){
    for(int j = 0; j <= W; ++j){
      if(i == 0){
	dp[i][j] = (j >= w[i])*v[i];
      } else {
	dp[i][j] = dp[i-1][j];
	ChangeMax(dp[i][j],(j >= w[i] ? dp[i-1][j-w[i]] + v[i]: 0));
      }
    }
  }
  cout << dp[n-1][W] << endl;
  return 0;
}


Measured memory_bytes: 79360
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <string.h>
#include <queue>
using namespace std;
const int INF = 1e9;

struct edge {int to, cap, cost, rev;};
 
int V;
const int MAX_V = 202;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost){
  G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
  G[to].push_back((edge){from, 0, -cost, (int)G[from].size()-1});
}

int min_cost_flow(int s, int t, int f){
  int res = 0;
  fill(h, h+V, 0);
  while(f > 0){
    priority_queue< pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > que;
    fill(dist, dist+V, INF);
    dist[s] = 0;
    que.emplace(0, s);
    while(!que.empty()){
      pair<int,int> p = que.top();
      que.pop();
      int v = p.second;
      if(dist[v] < p.first) continue;
      for(int i = 0; i < G[v].size(); ++i){
        edge &e = G[v][i];
        if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          que.emplace(dist[e.to], e.to);
        }
      }
    }
    if(dist[t] == INF) return -1;
    for(int v = 0; v < V; ++v) h[v] += dist[v];
    int d = f;
    for(int v = t; v != s; v = prevv[v]){
      d = min(d, G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d*h[t];
    for(int v = t; v != s; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  int N, M, L;
  while(cin >> N, N){
    V = 2*N + 2;
    vector< vector<int> > M;
    long long int ans = 0;
    for(int i = 0; i < N; ++i){
      int x, y, z;
      cin >> x >> y >> z;
      int s = min({x, y, z}), l = max({x, y, z}), m = x + y + z - s - l;
      M.push_back({s, m, l});
      //ans += s*m*l;
    }
    sort(M.begin(), M.end());

    for(int i = 0; i < N; ++i){
      add_edge(i, 2*N+1, 1, M[i][0]*M[i][1]*M[i][2]);
      for(int j = 0; j < i; ++j){
        if(M[j][0] < M[i][0] && M[j][1] < M[i][1] && M[j][2] < M[i][2])
          add_edge(j, i+N, 1, 0);
      }
    }
    
    for(int i = 0; i < N; ++i){
      add_edge(2*N, i, 1, 0);
      add_edge(N+i, 2*N+1, 1, 0);
    }

    ans += min_cost_flow(2*N, 2*N+1, N);
    /*
    for(int i = 0; i < N; ++i){
      if(G[2*N][i].cap) ans += M[i][0]*M[i][1]*M[i][2];
    }
    */
    cout << ans << endl;
    for(int i = 0; i < V; ++i) G[i].clear();
  }
  return 0;
}



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

        using namespace std;

        typedef long long ll;
        const ll N = 1e6+5;
        const ll MOD = 1000000007;
        #define all(x) x.begin(),x.end()
        #define pii pair<ll,ll>
        #define pis pair<ll,string>
        #define F first
        #define S second
        #define LCM(a,b) ((a*b)/__gcd(a,b))
        #define inf 1e15
        #define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
        #define PI 3.14159265
        #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
        const double EPS = 1E-9;
        typedef vector< vector<double> > matrix;
        typedef vector<int> vi;


const int MAX = 1e5 + 5;
int id[MAX];
int sz[MAX];

multiset<int> sett;

void initialize(int n){
    for(int i = 1;i <=n;++i){
         id[i] = i;
         sz[i]=1; sett.insert(1);
     }
}

int findset(int x){
    while(id[x] != x){
        id[x] = id[id[x]];
        x = id[x];
    }
    return x;
}

void combine(int x, int y){
    int p = findset(x), q = findset(y);
    if(p==q) return;
    if(sz[q] > sz[p]) swap(p,q);

        sett.erase( sett.find(sz[p]));
        sett.erase( sett.find(sz[q]));
        id[q]=p; sz[p]+=sz[q];

        sz[q]=-1;
        sett.insert(sz[p]);
}
int main(){

    fast;
    int n, m;
    cin >> n >> m;

    initialize(n);
    int x, y;

    for(int i = 1; i <= m; i++){
        cin >> x >> y;
        combine(x, y);
    }

    cout << sett.size() - 1 << "\n";
    return 0;
}

Measured memory_bytes: 9128
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

struct TCoordinate
{
	double x;
	double y;
};

TCoordinate GetCenterPoint(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return {x, y};
}

double GetRadius(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		TCoordinate P1, P2, P3;
		cin >> P1.x >> P1.y >> P2.x >> P2.y >> P3.x >> P3.y;
		TCoordinate CenterPoint = GetCenterPoint(P1, P2, P3);
		double Radius = GetRadius(P1, P2, P3);
		cout << fixed << setprecision(3);
		cout << CenterPoint.x << ' ' << CenterPoint.y << ' ' << Radius << endl;
	}
	return 0;
}

Measured memory_bytes: 3248
use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;
// use std::collections::VecDeque;
// use std::collections::BTreeSet;


// const INF: i64 = 1_000_000_000;
// const MOD: i64 = 998244353;


fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());
    let n: i64 = sc.read();
    let a: i64 = sc.read();
    let b: i64 = sc.read();
    let ans: i64;
    if (a - b) % 2 == 0 {
        ans = ((a - b).abs()) / 2;
    } else {
        ans = cmp::min(
            ((a-1) + (b-1) + 1) / 2,
            ((n-a) + (n-b) + 1) / 2);
    }
    println!("{}", ans);
    //println!("{}", s);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N = int(input())
W = [int(x) for x in input().split()]

ans = 1e20
s = sum(W)

for i in range(N - 1):
    sum1 = 0
    for j in range(i + 1):
        sum1 += W[j]
    sum2 = s - sum1
    ans = min(ans, abs(sum1 - sum2))

print(ans)


Measured memory_bytes: 3444
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

const int N = 5e5+5;
int arr[N], cnt[N], vans[N];
int ans;
struct query {
	int i, l, r, b;
};
query que[N];

void add(int p) {
	cnt[arr[p]]++;
	if(cnt[arr[p]] == 1)
		ans++;
}
void rem(int p) {
	cnt[arr[p]]--;
	if(!cnt[arr[p]])
		ans--;
}

signed main() {
	EmiliaMyWife

	int n, q;
	cin >> n >> q;
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	int w = sqrt(n)+1;
	for(int i = 0; i < q; i++)
		cin >> que[i].l >> que[i].r, que[i].l--, que[i].i = i, que[i].b = que[i].l/w;
	sort(que, que+q, [](query a, query b) {
		return (a.b==b.b?(a.r<b.r)^(a.b&1):a.b<b.b);
	});
	for(int i = 0, l = 0, r = 0; i < q; i++) {
		while(r < que[i].r)
			add(r++);
		while(l > que[i].l)
			add(--l);
		while(r > que[i].r)
			rem(--r);
		while(l < que[i].l)
			rem(l++);
		vans[que[i].i] = ans;
	}
	for(int i = 0; i < q; i++)
		cout << vans[i] << '\n';

	return 0;
}


Measured memory_bytes: 17464
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n):
    ai = a[i]
    if ai in dic:
        dic[ai] += 1
    else:
        dic[ai] = 1
s = sum(a)
q = int(input())
ans = []
for i in range(q):
    bi, ci = map(int, input().split())
    if bi in dic:
        num = dic[bi]
        s += (ci-bi)*num
        ans.append(s)
        if ci in dic:
            dic[ci] += num
        else:
            dic[ci] = num
        dic.pop(bi)
    else:
        ans.append(s)

for i in ans:
    print(i)

Measured memory_bytes: 88312
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 




int N, M, C, l[101010], c[101010], w[101010];
vector<int> v[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> C;
    rep(i, 0, C) cin >> l[i];
    rep(i, 0, N) {
        cin >> c[i] >> w[i];
        c[i]--;
        v[c[i]].push_back(w[i]);
    }
    vector<int> w;
    rep(i, 0, C) {
        sort(all(v[i]), greater<int>());
        int n = min(l[i], (int)v[i].size());
        rep(j, 0, n) w.push_back(v[i][j]);
    }
    sort(all(w), greater<int>());

    int n = min(M, (int)w.size());
    ll ans = 0;
    rep(i, 0, n) ans += w[i];
    cout << ans << endl;
}


Measured memory_bytes: 8732
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
    ll a,b;cin>>a>>b;
    ll flag=0;
    for(ll i=1;i<=1000;i++)
    {
    	if(((i*8)/100)==a&&((i*10)/100)==b)
    	{
    		flag=1;
    		cout<<i;
    		return 0;
    	}
    }
    if(flag==0)cout<<-1;
}

Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 12.08.2020 23:51:46
*/

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


int main(){
    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()) cout << "GREATER" << endl;
    else if(a.size() < b.size()) cout << "LESS" << endl;
    else {
        for(int i=0; i<(int)a.size(); i++){
            if(a[i]>b[i]){
                cout << "GREATER" << endl;
                return 0;
            }
            else if(a[i]<b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}

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

int main() {
  string A,B,C; cin >> A >> B >> C;
  int a,b,c;
  a = A.size();
  b = B.size();
  c = C.size();
  char s,t,u,v;
  s = A.at(a-1);
  t = B.at(0);
  u = B.at(b-1);
  v = C.at(0);
  if (s == t && v == u){
    cout << "YES";
  }
  else cout << "NO";
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = a * b;
  
  if ( c % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

string A;
ll N, ans = 0;

ll dp[101][4][4][4];

int main(void) {
	FOR(i,0, 4) {
		FOR(j, 0, 4) {
			FOR(k, 0, 4)dp[3][i][j][k] = 1;
		}

	}

	dp[3][0][1][2] = 0; dp[3][0][2][1]=0; dp[3][1][0][2] = 0;


	
	cin >> N;
	
	FOR(i, 4, N + 1) {
		FOR(s,0, 4)FOR(j, 0, 4)FOR(p,0,4)dp[i][s][j][0] = (dp[i][s][j][0]+dp[i-1][p][s][j] )%MOD;//Aの追加
		FOR(s, 0, 4)FOR(j, 0, 4)FOR(p, 0, 4)if(!(s==0&&j==2))dp[i][s][j][1] =( dp[i][s][j][1]+ dp[i - 1][p][s][j])%MOD;//Gの追加
		FOR(s, 0, 4)FOR(j, 0, 4)FOR(p, 0, 4)if(!(s==0&&j==1)&&!(p==0&&s==1)&&!(s==1&&j==0)&&!(p==0&&j==1))dp[i][s][j][2] = (dp[i][s][j][2]+dp[i - 1][p][s][j])%MOD;//Cの追加
		FOR(s, 0, 4)FOR(j, 0, 4)FOR(p, 0, 4)if(!(p==0&&s==1&&j==2))dp[i][s][j][3] = (dp[i][s][j][3]+ dp[i - 1][p][s][j])%MOD;//Tの追加
	}
	FOR(i, 0, 4) {
		FOR(j, 0, 4) {
			FOR(k, 0, 4)ans=(ans+dp[N][i][j][k])%MOD;
		}

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int n = s.size();
   string t;
   cout << s[0] << n - 2 << s[n - 1] << endl;
   return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

template<typename A, typename B> inline void chmin(A &a, B b) { if(a > b) a = b; }
template<typename A, typename B> inline void chmax(A &a, B b) { if(a < b) a = b; }

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}

int64 query(int64 a, int64 b) {
    cout << "? " << a+1 << " " << b+1 << endl;
    int64 x;
    cin >> x;
    return x;
}

vector<int64> res;

void ans() {
    cout << "! ";
    REP(i, res.size())
        cout << res[i]+1 << " ";
    cout << endl;
}

int main(void){
    int64 N, s, t;
    cin >> N >> s >> t; s--; t--;
    int64 dist = query(s, t);
    vector<PLL> vs;
    REP(i, N) {
        int64 d1 = query(s, i), d2 = query(i, t);
        if (d1 + d2 == dist) {
            vs.push_back(PLL(d1, i));
        }
    }
    sort(all(vs));
    int64 now = 0, v = s;
    int64 p = 0;
    while (p < vs.size() && v != t) {
//        cout << v << " " << p << " " << now << " " << vs[p].fs << endl;
        if (query(v, vs[p].sc) == vs[p].fs-now) {
            res.push_back(vs[p].sc);
            v = vs[p].sc;
            now = vs[p].fs;
        }
        p++;
    }
    ans();
}


Measured memory_bytes: 4652
// 0067
#include <iostream>
#include <cstdio>
using namespace std;

char s[13][13];

void walk(int i,int j){
	if(!(0<=i&&i<12&&0<=j&&j<12))return;
	if(s[i][j]=='0')return;
	s[i][j]='0';
	walk(i+1,j);
	walk(i-1,j);
	walk(i,j+1);
	walk(i,j-1);
}

int main(void){
	while (scanf("%s",s[0])!=EOF) {
		for(int i=1;i<12;i++){ scanf("%s",s[i]); }
		int c=0;
		for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				if(s[i][j]=='1'){
					c++;
					walk(i,j);
				}
			}
		}
		cout<<c<<endl;
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[111111],B[111111];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i]>>B[i];

    int ans=0;
    for(int i=N-1;i>=0;i--){
        A[i]+=ans;
        A[i]%=B[i];
        ans+=(B[i]-A[i])%B[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

void trace(int A[], int count, int N) {
    for (int i=0; i<N; i++) {
        if (i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d", count);
    printf("\n");
}

void bubbleSort(int A[], int N) {
    int i, j, v;
    int count = 0;
    bool flag = true;

    while (flag) {
        flag = false;
        for (j=0; j<N; j++){
            for (i=N-2; i>=j; i--) {
                if (A[i]>A[i+1]) {
                    v = A[i];
                    A[i] = A[i+1];
                    A[i+1] = v;
                    flag = true;
                    count++;
                }
            }
        }
    }
    trace(A, count, N);
}

int main() {
    int A[100], N;

    scanf("%d", &N);
    for (int i=0; i<N; i++) scanf("%d", &A[i]);
    
    bubbleSort(A, N);

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;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--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif
ll MOD;

class mint {
public:
    long long x;

    mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const {
        return mint(-x);
    }

    mint &operator+=(const mint &rhs) {
        if ((x += rhs.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator-=(const mint &rhs) {
        if ((x += MOD - rhs.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator*=(const mint &rhs) {
        (x *= rhs.x) %= MOD;
        return *this;
    }

    mint operator+(const mint &rhs) const {
        mint res(*this);
        return res += rhs;
    }

    mint operator-(const mint &rhs) const {
        mint res(*this);
        return res -= rhs;
    }

    mint operator*(const mint &rhs) const {
        mint res(*this);
        return res *= rhs;
    }

    [[nodiscard]] mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    [[nodiscard]] mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator/=(mint rhs) {
        return *this *= rhs.inv();
    }

    mint operator/(const mint rhs) const {
        return mint(*this) /= rhs;
    }

    bool operator==(const mint &rhs) const noexcept {
        return this->x == rhs.x;
    }

     bool operator!=(const mint &rhs) const noexcept {
        return this->x != rhs.x;
    }

    bool operator<(const mint &rhs) const noexcept {
        return this->x < rhs.x;
    }

    bool operator>(const mint &rhs) const noexcept {
        return this->x > rhs.x;
    }

    bool operator<=(const mint &rhs) const noexcept {
        return this->x <= rhs.x;
    }

    bool operator>=(const mint &rhs) const noexcept {
        return this->x >= rhs.x;
    }

    friend istream &operator>>(istream &is, mint &a) {
        long long t;
        is >> t;
        a = mint(t);
        return is;
    }

    friend ostream &operator<<(ostream &os, const mint &a) {
        return os << a.x;
    }
};


void solve() {
    string S;
    cin >> S;
    MOD = 2019;
    reverse(S.begin(), S.end());
    map<ll, ll> cnt;
    ll ans = 0;
    mint a = 1;
    mint value = 0;
    cnt[0] = 1;
    rep(i, S.size()) {
        mint d = S[i] - '0';
        value += (d * a);
        ans += cnt[value.x];
        cnt[value.x]++;
        a *= 10;
    }
    cout << ans << '\n';
}

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


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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	int n, y;
	cin >> n >> y;
	y /= 1000;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (10*i + j*5 + (n-i-j) == y && 10*i + j*5 <= y) {cout << i << " " << j << " " << n-i-j; return 0;}
		}
	}
	cout << "-1 -1 -1";
	
	return 0;
}

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

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }

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

	for(int c, d, w, x; cin >> c >> d >> w >> x, c;) {
		vector<vector<int> > e(c, vector<int>(d));
		for(int i = 0; i < c; ++i)
			for(int j = 0; j < d; ++j)
				cin >> e[i][j];

		vector<vector<int> > f(c, vector<int>(d));
		for(int i = 0; i < c; ++i)
			for(int j = 0; j < d; ++j)
				cin >> f[i][j];

		vector<vector<int> > dp(w + 1, vector<int>(x + 1, -INT_MAX));
		dp[0][0] = 0;

		for(int i = 0; i < d; ++i) {
			vector<vector<int> > next(w + 1, vector<int>(x + 1, -INT_MAX));
			for(int j = 0; j < w + 1; ++j) {
				for(int k = 0; k < x + 1; ++k) {
					chmax(next[j][k], dp[j][k]);
					for(int l = 0; l < c; ++l) {
						int tmp_w = j;
						int tmp_e = dp[j][k];
						for(int m = l; m < c; ++m) {
							if(!e[m][i])
								break;

							tmp_w += f[m][i];
							tmp_e += e[m][i];
							if(tmp_w > w)
								break;

							int tmp_x = k + (l != m);
							if(tmp_x > x)
								break;

							chmax(next[tmp_w][tmp_x], tmp_e);
						}
					}
					
				}
			}

			dp.swap(next);
		}

		int ans = 0;
		for(int i = 0; i < w + 1; ++i)
			for(int j = 0; j < x + 1; ++j)
				chmax(ans, dp[i][j]);

		cout << ans << endl;
	}


	return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
n=int(input())
a= list(map(int, input().strip().split()))
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
ans = min(map(how_many_times_divisible, a))
print(ans)


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum=0;
vector<ll> sl;
ll dp[100000];
ll func(ll a[],ll n,ll size)
{
	if(dp[n]>=0)
	return dp[n];
	else
	{

		//cout<<"fghjrtghj";
	ll sum=dp[n-1]+abs(a[n]-a[n-1]);
	ll su=dp[n-2]+abs(a[n]-a[n-2]);
	dp[n]=min(sum,su);
	if(n+1==size)
	return dp[n];
	else
	return func(a,n+1,size);
}
}
main()
{
	ll n,a[100000],b[100000];
	cin>>n;
	memset (dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	if(n>2)
	cout<<func(a,2,n);
	else
	cout<<dp[n-1];
	
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

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

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

// array pointer = *a, num of element = n, key key
int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod;
        }
    }
}*/
long long mod = 1000000007;

//x ^ n
long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

int edge[301][301];
int del[301][301];

int main(void){
    int n;
    long long total = 0;
    long long minus = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            scanf("%d", &edge[i][j]);
            if (!edge[j][i]){
                total += edge[i][j];
                edge[j][i] = edge[i][j];
            }
            
        }
    }

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            for (int k = 1; k <= n; k++){
                if (edge[j][i] + edge[i][k] < edge[j][k]){
                    printf("-1\n");
                    return 0;
                }
            }
        }
    }

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            for (int k = 1; k <= n; k++){
                if (i != k && i != j && j != k && edge[j][i] + edge[i][k] == edge[j][k]){
                    if (!del[j][k]){
                        minus += edge[j][k];
                        del[j][k] = 1;
                    }
                }
            }
        }
    }

    printf("%lld\n", total-minus/2);
    return 0;



}


Measured memory_bytes: 896
#include <stdio.h>

int main() {
  unsigned long level_deposit, deposit = 100;
  short output_year = 0;

  scanf("%ld", &level_deposit);

  if (level_deposit < 101 || level_deposit > 1000000000000000000) {
    return 1;
  }

  while(deposit < level_deposit) {
    deposit = deposit + deposit / 100;
    output_year += 1;
  }

  printf("%hd", output_year);
  printf("%c", '\n');

  return 0;
}


Measured memory_bytes: 1732
#pragma GCC optimize ("O3,unroll-loops")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define spIO ios::sync_with_stdio(false);cin.tie(0)
int arr[2 * 100000 + 5], n;
void solve()
{
	set<int> se;
	se.insert(arr[0]);

	for (int i = 1; i < n; i++)
	{
		if (se.find(arr[i]) != se.end())
		{
			cout << "NO";
			return;
		}
		else
			se.insert(arr[i]);
	}
	cout << "YES";
}
int main()
{
	spIO;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];
	solve();
	
}

Measured memory_bytes: 10368
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	vll a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
	int k ; cin >> k ;
	cout << a.at(k-1) << endl ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n=kbd.nextInt();
   int m=kbd.nextInt();

   int[] A= new int[n+1];
   for(int i=1;i<=n;i++){
     A[i]=1;
   }
   int[] H= new int[n+1];
   for(int i=1;i<=n;i++){
     H[i]=kbd.nextInt();
   }
   for(int i=0;i<m;i++){
     int a=kbd.nextInt();
     int b=kbd.nextInt();
     if(H[a]>=H[b]){A[b]=0;}
     if(H[a]<=H[b]){A[a]=0;}
   }
   int c=0;
  for(int i=1;i<=n;i++){
   if(A[i]>0){
     c++;
   }
 }
   System.out.println(c);
 }
}


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

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

const int INF=1e9;
const ll MOD=998244353;

template<typename T>
struct lazysegtree{
    int n;
    T init_v;
    vector<T> dat;
    vector<T> lazy;
 
    lazysegtree(vector<T> a,T _init_v){
        n=1;
        init_v=_init_v;
        int sz=a.size();
        while(n<sz) n*=2;
 
        dat.resize(2*n,init_v);
        lazy.resize(2*n,init_v);
 
        for (int i=0;i<sz;i++) dat[i+n-1]=a[i];
        for (int i=n-2;i>=0;i--) dat[i]=dat[i*2+1]+dat[i*2+2];
    }
 
    void eval(int k,int l,int r) {
        if(lazy[k]!=0) {
            dat[k]+=lazy[k];
            if(r-l>1){
                lazy[k*2+1]+=lazy[k]/2;
                lazy[k*2+2]+=lazy[k]/2;
            }
            lazy[k]=0;
        }
    }
 
    void add_sub(int a,int b,T x,int k,int l,int r){
        eval(k,l,r);
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b){
            lazy[k]+=(r-l)*x;
            eval(k,l,r);
        }else{
            add_sub(a,b,x,k*2+1,l,(l+r)/2);
            add_sub(a,b,x,k*2+2,(l+r)/2,r);
            dat[k]=dat[k*2+1]+dat[k*2+2];
        }
    }
    void add(int a,int b,T x){
        return add_sub(a,b,x,0,0,n);
    }
 
    T getsum_sub(int a,int b,int k,int l,int r){
        eval(k,l,r);
        if(r<=a||b<=l) return 0;
        if(a<=l&&r<=b) return dat[k];
        T vl=getsum_sub(a,b,k*2+1,l,(l+r)/2);
        T vr=getsum_sub(a,b,k*2+2,(l+r)/2,r);
        return vl+vr;
    }
    T getsum(int a,int b){
        return getsum_sub(a,b,0,0,n);
    }
};

int main(){
    int N,K; cin >> N >> K;
    P d[N];
    for(int i=0;i<K;i++){
        int l,r; cin >> l >> r;
        d[i]={l,r};
    }
    vector<ll> a(N+1);
    lazysegtree<ll> dp(a,0);
    dp.add(1,2,1);
    for(int i=1;i<=N;i++){
        for(int j=0;j<K;j++){
            ll res=dp.getsum(i,i+1)%MOD;
            dp.add(i+d[j].first,i+d[j].second+1,res);
        }
    }
    cout << dp.getsum(N,N+1)%MOD << endl;
}

Measured memory_bytes: 16184
#include <stdio.h>
#include <math.h>

int main(){
  int n;
  scanf("%d",&n);
  int i,j,flag=0;
  int a,count=0;
  for(i=0;i<n;i++){
    scanf("%d",&a);
    flag = 0;
    for(j = 2 ;j*j<=a;j++){
      if(a%j==0){
	flag = 1;
	break;
      }
    }
    if(!flag) count++;
  }
  printf("%d\n",count);
   
}
   

Measured memory_bytes: 2680
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

string str[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int b=0,c=0;
		for(int j=0;j<s.size();j++){
			if(s[j]=='0'){
				if(b){
					cout<<str[b][c%str[b].size()];
				}
				b=0;
			}else{
				if(s[j]-'0'==b){
					c++;
				}else{
					b=s[j]-'0';
					c=0;
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

h, w, k = na()
s = nsn(h)

ans = inf
for bits in range(2 ** (h - 1)):
    binf = "{0:b}".format(bits)
    res = sum([int(b) for b in binf])
    divcnt = res + 1
    cnt = [0] * divcnt
    flag = True
    j = 0
    while j < w:
        cur = 0
        for i in range(h):
            if (s[i][j] == '1'):
                cnt[cur] += 1
            if bits >> i & 1:
                cur += 1
        if max(cnt) > k:
            if flag:
                res = inf
                break
            res += 1
            for i in range(divcnt):
                cnt[i] = 0
            flag = True
        else:
            flag = False
            j += 1
    ans = min(ans, res)

print(ans)

Measured memory_bytes: 45276
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
#include <limits>
using namespace std;
typedef long long ll;

typedef pair<ll, ll> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;


int main() {
	ll i,j, k, l, m, n, sum, flag, cc, M,N, K,A,B,C,D;
	cc = 0;
	flag = 0;
	char s[200001];
	cin >> s;
	N = strlen(s);
	ll cnt = 0;
	ll ans = 0;
	while (cc < N) {
		if (s[cc] == 'A') {
			cnt++;
			cc++;
		}
		else if (cc < N - 1 && s[cc] == 'B'&&s[cc + 1] == 'C') {
			ans+=cnt;
			cc += 2;
		}
		else {
			cnt = 0;
			cc++;
		}
		
	}
	output(ans);
	return 0;
}








Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

char num[] = {'I','V','X','L','C','D','M'};
int eqiv[] = {1,5,10,50,100,500,1000};

int id(char el){
	for(int x=0;x<7;++x)
		if(num[x] == el)return x;
	return -1;
}

int main(){	
	string line;
	while(cin>>line){
		int num = 0;
		for(int x=0;x<line.size();++x){
			int c = 1;
			while(x<line.size()+1 && line[x] == line[x+1]){
				c++;x++;
			}
			if(id(line[x])<id(line[x+1])){
				num -= c*eqiv[id(line[x])];
			}else{
				num += c*eqiv[id(line[x])];
			}
			if(line[x]==line[x+1])++x;
		}
		cout<<num<<endl;	
	}
	return 0;
}		

Measured memory_bytes: 1180
N, M = map(int, input().split())
#print('N : ' + str(N))
#print('M : ' + str(M))
H = list(map(int, input().split()))
#print('H : ' + str(H))
lists = [1 for i in range(N)]
for i in range(M):
  A, B = map(int, input().split())
 # print('A : ' + str(A) + ' / B : ' + str(B))
  A -= 1
  B -= 1
  if H[A] > H[B]:
    lists[B] = 0
  elif H[A] == H[B]:
    lists[A] = 0
    lists[B] = 0
  else :
    lists[A] = 0
  #print(lists)
  
#print('---')
#print(lists)
sum = 0
for i in range(N):
  if lists[i] == 1 :
    sum += 1
    
#print('<sum>')
print(sum)

Measured memory_bytes: 20136
#include <stdio.h>
#include <algorithm>

using namespace std;


int main(){
	int n,minimum,tmp;
	scanf("%d",&n);
	int table[n][n];
	int data[n][2];

	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++)table[i][k] = 0;
		scanf("%d %d",&data[i][0],&data[i][1]);
	}

	for(int i=n-2;i>=0;i--){
		for(int k=0;k<=i;k++){
			if(i==n-2){
				table[n-i-1][k] = data[k][0]*data[k][1]*data[k+1][1];
		}else{
				minimum = 2147483647;
				for(int p=0;p<=n-i-2;p++){
					tmp=(table[p][k]+table[n-i-p-2][k+p+1])+(data[k][0]*data[k+p][1]*data[k+n-i-1][1]);
					minimum = min(minimum,tmp);
				}
				table[n-i-1][k] = minimum;
			}
		}
	}

	printf("%d\n",table[n-1][0]);

    return 0;
}



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

int main() {
 	    long n,w,a,b;
        cin>>n>>w;
        vector<pair<long,long>>p;
        for(long i=0;i<n;i++){cin>>a>>b; p.push_back({b,a});}
        long dp[n+1][w+1];
        for(int i=0;i<=n;i++)dp[i][0]=0;       //dp[i][j] is best value upto weight j considering frst i elements
        for(int i=0;i<=w;i++)dp[0][i]=0;
        for(long i=1;i<=n;i++){
             for(long j=1;j<=w;j++){
                 long aa=LONG_MIN;
                 if(j>=p[i-1].second)aa=p[i-1].first+dp[i-1][j-p[i-1].second];
                 dp[i][j]=max(dp[i-1][j],aa);
                 //cout<<dp[i][j]<<endl;
             }
        }
        cout<<dp[n][w]<<endl;


	return 0;
}

Measured memory_bytes: 82332