akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  cin >> A >> B;
  if (A >= 1 && A <= 9 && B >= 1 && B <= 9)
    cout << A * B << endl;
  else
    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/twosat>
using namespace std;
using namespace atcoder;
int main(){
  int N, D;
  cin >> N >> D;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++){
    cin >> X[i] >> Y[i];
  }
  two_sat S(N);
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      if (abs(X[j] - X[i]) < D){
        S.add_clause(i, true, j, true);
      }
      if (abs(Y[j] - X[i]) < D){
        S.add_clause(i, true, j, false);
      }
      if (abs(X[j] - Y[i]) < D){
        S.add_clause(i, false, j, true);
      }
      if (abs(Y[j] - Y[i]) < D){
        S.add_clause(i, false, j, false);
      }
    }
  }
  if (!S.satisfiable()){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    vector<bool> ans = S.answer();
    for (int i = 0; i < N; i++){
      if (ans[i]){
        cout << Y[i] << endl;
      } else {
        cout << X[i] << endl;
      }
    }
  }
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
 
int N,M;
 
int p[100001];

int f(int i){
	if(i==p[i]){
		return i;
	}else{
		return p[i]=p[i]?f(p[i]):i;
	}
}
 
main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;++i){
		int K,L0;
		scanf("%d%d",&K,&L0);
		f(L0);
		for(int i=1;i<K;++i){
			int L;
			scanf("%d",&L);
			if(f(L0)!=f(L)){
				p[f(L)]=f(L0);
			}
		}
	}
	int a=0;
	for(int i=1;i<=M;++i){
		if(p[i]){
			if(a==0){
				a=f(i);
			}else{
				if(f(i)!=a){
					puts("NO");
					return 0;
				}
			}
		}
	}
	puts("YES");
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

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

const int N = 1010, M = 1e9+7;
int R, C, a[N][N];
ll dp[N][N];

ll add(ll a, ll b) {return (a+b)%M;}

ll rec(int r, int c) {
	if(r == 0 || c == 0 || a[r][c] == 0) return 0;
	if(dp[r][c] != -1) return dp[r][c];
	return dp[r][c] = add(rec(r-1, c), rec(r, c-1));
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    memset(dp, -1, sizeof(dp));
    dp[1][1] = 1;
    cin >> R >> C;
    FOR(i, 1, R) {
    	FOR(j, 1, C) {
    		char ch;
    		cin >> ch;
    		a[i][j] = (ch != '#');
    	}
    }
    cout << rec(R, C) << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,d,x[11][11],num=0;
	cin>>n>>d;
	for(int i=0;i<n;i++)
		for(int j=0;j<d;j++)
			cin>>x[i][j];
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++) {
			int ans=0;
			for(int k=0;k<d;k++)
				ans+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			int m=(int)sqrt(ans);
			if(m*m==ans) num++;
		}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
    ll N,A,B,C;
    vector<int> L;
 
int rec(int i, int a, int b, int c){
  if(i == N) {
    if(!a || !b || !c) return 1e9;
    return abs(a - A) + abs(b - B) + abs(c - C);
  }
  
  int res = rec(i+1, a, b, c);
  
  chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
  chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
  chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
  
  return res;
}
 
int main(){
    cin >> N >> A >> B >> C;
  	L.resize(N);
  	for(int i = 0; i < N; ++i) cin >> L[i];
    cout << rec(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
//#define BIG 1000000010
int main(){
	//freopen("_inluckylist.txt","r",stdin);
	int N;
	scanf("%d",&N);
	int i,tmp;
	//int nums[BIG];
	int count1 = 0,count2 = 0;
	for(i = 0;i<N;i++){
		scanf("%d",&tmp);
		if(tmp%4==0){
			count1 ++;
		}else if(tmp%2==0){
			count2++;
		}
	}
	if(count2 != 0){
		if((count1*2+count2-1)>=N-1){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else {
		if(count1*2 >= N-1){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 128
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	// 入力
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int ans = 0;
	for (int i = 0; i <= 100; i++) {
		if ((a <= i && i < b)&&(c <= i && i < d)) {
			ans++;
		}
	}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  vll dp(86);
  dp[0]=2;dp[1]=1;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-2]+dp[i-1];
  }
  cout(dp[n]);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        String s = stdin.next();
        char x = s.charAt(0);
        int y = s.length() - 2;
        char z = s.charAt(s.length() - 1);
        System.out.printf("%c%d%c%n", x, y, z);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();//人数
		int K = sc.nextInt();//身長
		int d[] = new int[N]; //配列数を決定
		
		for(int i = 0; i<N; i++) {
			d[i] = sc.nextInt(); //配列の中身を挿入
			//System.out.println(d[i]);//配列の中身を確認
		}
		int count = 0;
		for(int i = 0; i<N; i++) {
			if(d[i]>=K) {
				count += 1;
			}else {
				count += 0;
			}
		}
		System.out.println(count);
	}
	
}


Measured memory_bytes: 48988
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean chk = true;
        for(int i = 0; i < n; i++){
            int tmp = sc.nextInt();
            if(tmp % 2 == 0 && tmp % 3 != 0 && tmp % 5 != 0){
                chk = false;
                break;
            }
        }
        if(chk){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }
    }
}

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

double ave(int *data, int dx)
{
    int i;
    int sum = 0;

    for(i=0;i<dx;i++) {
        sum += data[i];
    }

    return 1.0 * sum / dx;
}

double st_div(int *data, int dx)
{
    int i;
    double m = ave(data, dx);
    double sum = 0;

    for(i=0;i<dx;i++) {
        double t = data[i] - m;
        sum += t*t;
    }

    return sqrt(sum / dx);
}

int read(void)
{
    int i;
    int n;
    int data[1000] = {};
    char str[10000] = {};

    scanf("%d%*c", &n);
    if(n == 0) return 0;

    fgets(str, 10000, stdin);
    data[0] = atoi(strtok(str, " \n"));
    for(i=1;i<n;i++) {
        data[i] = atoi(strtok(NULL, " \n"));
    }

    printf("%lf\n", st_div(data,n));

    return 1;
}

int main(void)
{
    while(read() != 0);

    return 0;
}

Measured memory_bytes: 660
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    llint n;
    cin >> n;
    
    llint ans = (n / 11)*2;
    n = n % 11;
    if(n > 0){
        ans++;
        n -= 6;
    }
    if(n > 0){
        ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int n;
double dis[32][32];
bool dfs(int unvisit, int cur, double time)
{
	if (unvisit == 0)
		return true;

	for (int i = 0; i < n; ++i)
		if (unvisit >> i & 1 && time + dis[cur][i] > dis[n + 1][i])
			return false;

	for (int i = 0; i < n; ++i)
		if (unvisit >> i & 1 && time + dis[cur][i] < dis[n + 1][i])
			if (dfs(unvisit ^ 1 << i, i, time + dis[cur][i]))
				return true;

	return false;
}
int main()
{
	int  hx, hy, dx, dy;
	while (scanf("%d%d%d%d%d", &n, &hx, &hy, &dx, &dy), n)
	{
		int  x[32], y[32];
		rep (i, n)
			scanf("%d%d", x + i, y + i);
		x[n] = hx, y[n] = hy;
		x[n + 1] = dx, y[n + 1] = dy;

		for (int i = 0; i <= n + 1; ++i)
			for (int j = 0; j <= n + 1; ++j)
				dis[i][j] = hypot(x[i] - x[j], y[i] - y[j]);

		puts(dfs((1 << n) - 1, n, 0) ? "YES" : "NO");
	}
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;int main(){
long long N;
   cin>>N;
long long Q;
   vector<long long>A(N);   
   vector<long long>hantei(100000);
   long long answer=0;
   for(long long i=0; i<N; i++){
       cin>>A.at(i);
       hantei.at(A.at(i)-1)++;
       answer+=A.at(i);
   }
  cin>>Q;
  vector<long long>B(Q);
   vector<long long>C(Q);
   for(long long i=0; i<Q; i++){
       cin>>B.at(i);
       cin>>C.at(i);
    answer+=hantei.at(B.at(i)-1)*(C.at(i)-B.at(i));
        cout<<answer<<endl;
        if(hantei.at(B.at(i)-1)!=0){
   hantei.at(C.at(i)-1)+=hantei.at(B.at(i)-1);
   hantei.at(B.at(i)-1)=0;
   }
   }
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;

Int n;
vector<Int> G[10001];
//Int c[10001];
Int d[10001];
bool visited[10001];
Int res;

void dfs(Int x) {
    //dump(1);
    if (visited[x]) return;
    visited[x] = true;
    for (Int i = 0; i < (Int)G[x].size(); i++) {
        Int to = G[x][i];
        if (visited[to]) continue;
        res += min(d[x], d[to]);
        dfs(to);
    }
}

int main() {
    cin >> n;
    for (Int i = 0; i < n - 1; i++) {
        Int a, b;
        cin >> a >> b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    priority_queue<Int> c;
    for (Int i = 1; i <= n; i++) {
        Int x;
        cin >> x;
        c.push(x);
    }
    for (Int i = 1; i <= n; i++) d[i] = -1;
    priority_queue<pair<Int, Int>> q;
    Int ma = -1;
    Int index = 0;
    for (Int i = 1; i <= n; i++) {
        if (ma < (Int)G[i].size()) {
            ma = (Int)G[i].size();
            index = i;
        }
    }
    q.push({ma, index});
    d[index] = c.top();
    c.pop();
    while (!q.empty()) {
        Int x = q.top().second;
        q.pop();
        for (Int i = 0; i < (Int)G[x].size(); i++) {
            Int to = G[x][i];
            if (d[to] == -1) {
                q.push({(Int)G[to].size() ,to});
                d[to] = c.top();
                c.pop();
            }
        }
    }
    dfs(index);
    dump(res);
    for (Int i = 1; i <= n; i++) cout << d[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
using namespace std;
int main(){
    string S;
    cin>>S;
    if(S[0] == 'R'){
        if(S[1] == 'R'){
            if(S[2] == 'R'){
                cout<<"3"<<endl;
            }else{
                cout<<"2"<<endl;
            }
        }else{
            cout<<"1"<<endl;
        }
    }else{
        if(S[1] == 'R'){
            if(S[2] == 'R'){
                cout<<"2"<<endl;
            }else{
               cout<<"1"<<endl;
            }
        }else{
            if(S[2] == 'R'){
                cout<<"1"<<endl;
            }else{
                cout<<"0"<<endl;
            }
        }
    }
    return 0;

}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

int main(){
	int n=read(),t=read()/2;
	vi a;
	int x=1000000000,y=0;
	int ans=0;
	REP(i,n){
		int p=read();
		a.PB(p);
		if(y<p-x){
			ans=0;
			y=p-x;
		}
		if(y==p-x)
			ans++;
		chmin(x,p);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>



using namespace std;


int main() {
	string S;
	cin >> S;
	long long int Y = 0;
	for (int i = 0; i < S.size()-1; i++) {
		if (S[i] == S[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			Y ++ ;
			break;
		}


		if (i+2<S.size()) {
			if (S[i] == S[i + 2]&&S[i+1]) {
				Y++;
				cout << i+1 << " " << i + 3 << endl;
				break;
			}
		}
	}

	if (Y == 0) {
		cout <<-1<<" "<<-1<< endl;
	}
	

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h> 
using namespace std; 
#define M 1e9+7
#define int long long
#define lli long long int
#define I 10e5
int32_t main() 
{ 
   ios_base::sync_with_stdio(false);cin.tie(NULL); 
   
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout); 
   #endif
   string s1, s2;
   cin>>s1>>s2;
   int n = s1.length(), m = s2.length();
   int dp[n+1][m+1];
   memset(dp, 0, sizeof(dp));
   for(int i=1;i<=n;i++)
   {
      for(int j=1;j<=m;j++)
      {
         if(s1[i-1]==s2[j-1])
         {
            dp[i][j] = 1 + dp[i-1][j-1];
         }
         else
         {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
         }
      }
   }
   string lcs = "";
   for(int i=n,j=m;i>0 && j>0;)
   {
      if(s1[i-1]==s2[j-1])
      {
         lcs+=(s1[i-1]);
         i--;j--;
      }
      else 
      {
         if(dp[i-1][j]>dp[i][j-1])
         {
            i--;
         }
         else
         {
            j--;
         }
      }
   }
   reverse(lcs.begin(),lcs.end());
   cout<<lcs<<endl;
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
}

Measured memory_bytes: 74152
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
 
 
public class Main{
	
	public static class Exec{
		int pos, val;

		public Exec(int pos, int val) {
			super();
			this.pos = pos;
			this.val = val;
		}
	}
	
    public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	
    	final int n = sc.nextInt();
    	
    	Map<String, Integer> map = new HashMap<String, Integer>();
    	
    	int[] next = new int[n];
    	for(int i = 0; i < n; i++){
    		next[i] = i + 1;
    	}
    	
    	String[][] input = new String[n][2];
    	
    	for(int i = 0; i < n; i++){
    		String ops = sc.next();
    		
    		input[i][0] = ops;
    		
    		if("goto".equals(ops)){
    			String jump = sc.next();
    			input[i][1] = jump.substring(0, jump.length() - 1);
    		}else{
    			map.put(ops.substring(0, ops.length() - 1), i);
    		}
    	}
    	
    	for(int i = 0; i < n; i++){
    		if("goto".equals(input[i][0])){
    			//System.out.println(input[i][1]);
    			next[i] = map.get(input[i][1]);
    		}
    	}
    	
    	boolean[][] visited = new boolean[n][n];
    	LinkedList<Exec> queue = new LinkedList<Exec>();
    	queue.add(new Exec(0, 0));
    	
    	while(!queue.isEmpty()){
    		Exec e = queue.poll();
    		
    		//System.out.println(e.pos + " " + e.val);
    		
    		if(e.pos == n){
    			System.out.println(e.val);
    			return;
    		}
    		
    		if(visited[e.pos][e.val]){
    			continue;
    		}else{
    			visited[e.pos][e.val] = true;
    		}
    		
    		
    		
    		queue.addFirst(new Exec(next[e.pos], e.val));
    		if(next[e.pos] != e.pos + 1){
    			queue.addLast(new Exec(e.pos + 1, e.val + 1));
    		}
    	}
    	
    	
    }
     
}

Measured memory_bytes: 21844
N, M = map(int, input().split())

bs = [True for i in range(N+1)]
for i in range(M):
    a = int(input())
    bs[a] = False

dp = [0 for i in range(N+1)]
dp[0] = 1
if bs[1] != False: dp[1] = 1

for i in range(2,N+1):
    if bs[i-1] != False:
        dp[i] += dp[i - 1]
    if bs[i - 2] != False:
        dp[i] += dp[i - 2]

print(dp[N] % 1000000007)

Measured memory_bytes: 463512
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    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 size(self, x):
        return -self.parents[self.find(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 main():
    N, M, K = map(int, readline().split())
    AB = [tuple(int(s) - 1 for s in readline().split()) for _ in range(M)]
    CD = [tuple(int(s) - 1 for s in readline().split()) for _ in range(K)]

    G = [[] for _ in range(N)]
    for a, b in AB:
        G[a].append(b)
        G[b].append(a)

    H = [[] for _ in range(N)]
    for c, d in CD:
        H[c].append(d)
        H[d].append(c)

    uf = UnionFind(N)
    for a, b in AB:
        uf.union(a, b)

    ans = [0] * N
    for i in range(N):
        ans[i] = uf.size(i) - len(G[i]) - 1
        for j in H[i]:
            if uf.same(i, j):
                ans[i] -= 1

    print(' '.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 133952
<?php
$ans = [];

fscanf(STDIN, "%d", $N);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
$tmp = array_sum($A);
$sum = array_count_values($A);

fscanf(STDIN, "%d", $Q);
for ($i = 0; $i < $Q; $i++) {
    fscanf(STDIN, "%d %d", $B, $C);
    $tmp += ($C - $B) * ($sum[$B] ?? 0);
    $sum[$C] = $sum[$C] ?? 0;
    $sum[$C] += ($sum[$B] ?? 0);
    $sum[$B] = 0;
    $ans[] = $tmp;
}
echo implode(PHP_EOL, $ans);


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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll POW(ll a, ll b){
	if(b==1) return a;
	if(b%2==0) return POW(a*a%INF, b/2);
	return a*POW(a, b-1)%INF;
}

int main(){
	int h, w, x;
	cin >> h >> w >> x;
	if(w == 1){
		cout << 1 << endl;
		return 0;
	}
	x--;
	int dp[1000][1000] = { };
	dp[0][0] = 1;
	REP(i, h){
		REP(j, 1LL << (w-1)){
			if((3*j) != (j ^ (j<<1))) continue;
			REP(k, w){
				if((j >> k) %2 == 1) (dp[i+1][k] += dp[i][k+1]) %= INF;
				else if(k != 0 && (j >> (k-1))%2==1) (dp[i+1][k] += dp[i][k-1]) %= INF;
				else (dp[i+1][k] += dp[i][k]) %= INF;
			}
		}
	}
	cout << dp[h][x] << endl;
	return 0;
} 


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int MAX = 10000000;

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

  LL N, M;
  while(cin>>M>>N,N){
	vector<bool> ok(MAX);

	--M;
	while(true){
	  ++M;
	  if(ok[M]) continue;
	  if(--N < 0) break;
	  for(int j=M;j<MAX;j+=M)
		ok[j] = true;
	}
	cout << M << endl;
  }

  return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL my_kai(LL x){
	LL a=1;
	FOR(i,1,x+1){
		a *= i;
		a %= MOD;
	}
	return a % MOD;
}

LL my_kai_tobashi(LL x, LL y){
	LL a=1;
	FOR(i,1,x+1){
		if(i != y){
			a *= i;
			a %= MOD;
		}
	}
	return a % MOD;
}

LL my_kai_tobashi2(LL kai, LL x){
	while(kai % x != 0){
		kai += MOD;
	}
	return kai / x;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void Main()
{
	int n; cin >> n;
	vector<LL> x(n);
	REP(i, n) cin >> x[i];

	vector<LL> dist(n-1);
	REP(i,n-1){
		dist[i] = x[i+1] - x[i];
	}

	LL kai = my_kai(n-1);
	kai %= MOD;

	vector<LL> kai2(n-1);
	kai2[0] = kai;
	FOR(i,1,n-1){
		kai2[i] = (kai2[i-1] + (kai)*modinv(i+1,MOD)) % MOD;
		//kai2[i] = (kai2[i-1] + my_kai_tobashi(n-1,i+1)) % MOD;
		//kai2[i] = (kai2[i-1] + my_kai_tobashi2(kai,i+1)) % MOD;
	}
	//dump(kai)

	LL result = 0;

	REP(i,n-1){
		result += (dist[i] * kai2[i]) % MOD;
		result %= MOD;
	}
	
	cout << result << endl;


	return;
}

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

Measured memory_bytes: 2560
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    S = input()
    length = len(S)
    for i in range(length):
        if i % 2 == 0:
            # 奇数番目
            if S[i] not in ["R", "U", "D"]:
                print("No")
                sys.exit()
        else:
            if S[i] not in ["L", "U", "D"]:
                print("No")
                sys.exit()
    print("Yes")


if __name__ == '__main__':
    main()

Measured memory_bytes: 12492
#include <stdio.h>

int main(){
  int n, a[101], m, c = 0, i, max, min, mid;

  while(scanf("%d", &n) && n){
    for(i = 0; i < n; ++i) scanf("%d", a + i);
    scanf("%d", &m);
    c = 0;
    min = 0, max = n - 1;
    while(min <= max){
      mid = (min + max) / 2;
      c++;
      if(a[mid] == m) break;
      if(a[mid] > m) max = mid - 1;
      else if(a[mid] < m) min = mid + 1;
    }
    printf("%d\n", c);
  }
  return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
ll dp[505][505];
int main(){
   ll n,m,q;
   cin>>n>>m>>q;
   for(int i=0;i<m;i++){
      int a,b;
      cin>>a>>b;
      dp[a][b]++;
   }
   for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j+1]+=dp[i][j];
   for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[j+1][i]+=dp[j][i];
   while(q--){
      int l,r;
      cin>>l>>r;
      cout<<dp[r][r]+dp[l-1][l-1]-dp[l-1][r]-dp[r][l-1]<<"\n";
   }
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n);
    vector<int> wa(n);
    int suma = 0, sump = 0;
    for (int i=0; i<m; i++) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (!ac[p]) {
            if (s == "WA") wa[p]++;
             else ac[p] = true;
        }
    }
    for (int i=0; i<n; i++) {
        if (ac[i]) {
            sump += wa[i]; suma++;
        }
    }
    cout << suma << " " << sump << endl;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if (a == b && a != c) ans = "Yes";
  if (b == c && b != a) ans = "Yes";
  if (c == a && c != b) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

min_a = int(a//0.08+1)
max_a = (a+1)//0.08
min_b = int(b//0.1+1)
max_b =  (b+1)//0.1

if min_a < min_b:
    if max_a >= min_b:
        print(min_b)
    else:
        print(-1)
else:
    if max_b >= min_a:
        print(min_a)
    else:
        print(-1)

Measured memory_bytes: 38428
// JOI - Prelim  0512
// シーザー暗号
#include <bits/stdc++.h>

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void sub()
{
    const unordered_map<char, char> map_from_to{
        {'D', 'A'},
        {'E', 'B'},
        {'F', 'C'},
        {'G', 'D'},
        {'H', 'E'},
        {'I', 'F'},
        {'J', 'G'},
        {'K', 'H'},
        {'L', 'I'},
        {'M', 'J'},
        {'N', 'K'},
        {'O', 'L'},
        {'P', 'M'},
        {'Q', 'N'},
        {'R', 'O'},
        {'S', 'P'},
        {'T', 'Q'},
        {'U', 'R'},
        {'V', 'S'},
        {'W', 'T'},
        {'X', 'U'},
        {'Y', 'V'},
        {'Z', 'W'},
        {'A', 'X'},
        {'B', 'Y'},
        {'C', 'Z'},
    };

    const auto S(cin2var<string>());
    for (const auto& c : S) {
        cout << map_from_to.at(c);
    }
    cout << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	int X[100] = { 0 };
	cin >> n >> a;
	if (n % a != 0) {
		cout << 1;
	}
	else {
		cout << 0;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    ll T;cin>>T;
    ll t[200010],ans=T;
    for(int i=0;i<N;i++)cin>>t[i];
    for(int i=0;i<N-1;i++){
        ans+=min(T,t[i+1]-t[i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];

	rep(i, h){
		rep(j, 2){
			cout << s[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//int frq[123];
int main(){
	Lancer();
	string str;
	cin >> str;
	ll c = 0,ch=0,l=str.size(),ind;
	for (int i = 0; i < l; i++){
		if (str[i] == 'C'){
			c++;
			ind = i;
		}
		else if (str[i] >= 'a' &&str[i] <= 'z')
			ch++;
	}
	if (str[0] == 'A'  && c==1 && ch==l-2 && ind>=2  && ind <=l-2) cout << "AC";
	else cout << "WA";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
    int N,G,A;
    A=1;
    scanf("%d\n",&N);
    scanf("%d\n",&G);
    int i;
    for (i=1;i<=N;i++){
        if (A*2<A+G) A*=2;
        else A+=G;
    }
    printf("%d",A);
    return 0;
}

Measured memory_bytes: 128
# 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 size(self, x):
#         return -self.parents[self.find(x)]

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

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

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

#     def group_count(self):
#         return len(self.roots())

#     def all_group_members(self):
#         return {r: self.members(r) for r in self.roots()}

#     def __str__(self):
#         return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
# uf = UnionFind(N)
dic = {}
ansl = []

for i in range(M):
    ab = list(map(int, input().split()))
    # ab[0] -= 1
    # ab[1] -= 1
    # uf.union(*ab)
    AB.extend(ab)
    # ansl.append(max([H[ab[0]-1],H[ab[0]-1]]))
    dic.setdefault(ab[0],[]).append(ab[1])
    dic.setdefault(ab[1],[]).append(ab[0])

# print(dic)
# print(uf.all_group_members())
# ans = len(set(ansl))
ans = N-len(set(AB))
for k,v in dic.items():
    if H[k-1] > max(list(map(lambda x: H[x-1], v))):
        ans += 1

print(ans)



Measured memory_bytes: 38692
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin >> n;
  if(n < 2)
    cout << 1 << endl;
  else if(n >= 2 && n < 4)
    cout << 2 << endl;
  else if(n >= 4 && n < 8)
    cout << 4 << endl;
  else if(n >= 8 && n < 16)
    cout << 8 << endl;
  else if(n >= 16 && n < 32)
    cout << 16 << endl;
  else if(n >= 32 && n < 64)
    cout << 32 << endl;
  else
    cout << 64 << endl;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, k;

	cin >> n >> k;

	vector<ll> v(n);

	REP(i, n) {
		cin >> v[i];
	}

	ll ans = INF;
	ll x, y;

	REP(i, n - k + 1) {
		x = abs(v[i]);
		y = abs(v[i + k - 1]);
		if (k == 1) {
			ans = min(ans, x);
		}else if (v[i + k - 1] < 0) {
			ans = min(ans, x);
		}
		else if (v[i] > 0) {
			ans = min(ans, y);
		}
		else {
			ans = min(ans, min(x * 2 + y, x + y * 2));
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1152
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  ll count = 0;
  map<int,int>m;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    m[a]++;
  }
  for(auto p:m){
    if(p.second%2!=0)count++;
  }
  cout << count << endl;
}

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

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

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

const int MAX = 1e5 + 5;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

class Dijkstra{
    struct edge {
        int to;
        long long cost;
        edge(int a, long long b) {
            to = a;
            cost = b;
        }
    };
    
    private:
        int V;
        vector<vector<edge>> G;
        vector<long long> d;

    public:
        Dijkstra(int v) {
            V = v;
            G = vector<vector<edge>>(V);
            d = vector<long long>(V);
        }

        void add_edge(int from, int to, long long cost) {
            G[from].emplace_back(edge(to, cost));
        }

        vector<long long>& shortest_path(int s) {
            priority_queue<
                pair<long long, int>,
                vector<pair<long long, int>>,
                greater<pair<long long, int>>
            > que;

            for (long long& i : d) i = INF;
            d[s] = 0;
            que.push(make_pair(0, s));

            while (!que.empty()) {
                auto p = que.top(); que.pop();
                int v = p.second;
                if (d[v] < p.first) continue;

                for (const edge& e : G[v]) {
                    if (d[e.to] > d[v] + e.cost) {
                        d[e.to] = d[v] + e.cost;
                        que.push(make_pair(d[e.to], e.to));
                    }
                }
            }

            return d;
        }
};

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

    Dijkstra dij = Dijkstra(N);

    rep(i, M) {
        int l, r, c;
        cin >> l >> r >> c;
        l--, r--;
        dij.add_edge(l, r, c);
    }

    for (int i = 1; i < N; ++i) {
        dij.add_edge(i, i - 1, 0);
    }

    auto d = dij.shortest_path(0);

    if (d[N - 1] != INF) {
        cout << d[N - 1] << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
//const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

ll MOD;

//x^nを求める
ll mpow(ll x, ll n){
    x %= MOD;
    ll res = 1, now = x;
    while(n > 0){
        if(n & 1) res *= now, res %= MOD;
        now *= now, now %= MOD;
        n >>= 1;
    }
    return res;
}

//1+x+x^2+....+x^(n-1)を求める
ll powsum1(ll x, ll n){
    x %= MOD;
    ll now = 1, res = 0, pos = 0;
    for(int i = 0; (1ll<<i) <= n; i++){
        if(n & (1ll<<i)){
            res += now * mpow(x, pos);
            res %= MOD;
            pos |= 1ll<<i;
        }
        now = now*(1+mpow(x, 1ll<<i)), now %= MOD;
    }
    return res;
}

//0+1*x+2*(x^2)+....+(n-1)*x^(n-1)を求める
ll powsum2(ll x, ll n){
    x %= MOD;
    ll now = 0, res = 0, pos = 0;
    for(int i = 0; (1ll<<i) <= n; i++){
        if(n & (1ll<<i)){
            ll tmp = now+(pos%MOD)*(powsum1(x, (1ll<<i)));
            tmp %= MOD;
            tmp *= mpow(x, pos), tmp %= MOD;
            res += tmp, res %= MOD;
            pos |= 1ll<<i;
        }
        ll sub = now+((1ll<<i)%MOD)*powsum1(x, (1ll<<i));
        sub %= MOD;
        sub *= mpow(x, (1ll<<i)), sub %= MOD;
        now += sub, now %= MOD;
    }
    return res;
}

int main(){
    ll N, A, B, pw[19];
    pw[0] = 1;
    rep2(i, 1, 18) pw[i] = pw[i-1]*10;
    cin >> N >> A >> B >> MOD;
    //step[i]:=A+j*B>=10^iとなるような最小のj
    ll step[19];
    rep2(i, 0, 18){
        if(A >= pw[i]) step[i] = 0;
        elif(A+(N-1)*B < pw[i]) step[i] = N;
        else step[i] = (pw[i]-A+B-1)/B;
    }
    ll ans = 0, sum = 1;
    //i桁の数の総和
    rep3(i, 18, 1){
        //[l,r)項目を調べる
        ll l = step[i-1], r = step[i], n = r-l;
        if(l == r) continue;
        ll a = A+(r-1)*B, b = B, x = mpow(10, i);
        a %= MOD, b %= MOD;
        ll res = 0;
        res += a*powsum1(x, n), res %= MOD;
        res += (MOD-b)*powsum2(x, n), res %= MOD;
        ans += sum*res, ans %= MOD;
        sum *= mpow(mpow(10, n), i), sum %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256