akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define _CRT_DISABLE_PERFCRIT_LOCKS

#include <iostream>
#include <cstdio>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>	
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <thread>
#include <cassert>

using namespace std;

#define ll long long
#define ull unsigned long long
typedef int hv;
#define double long double
#define make(type, x) type x; cin>>x	
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
#define VI vector<int>
#define VVI vector<vector<int>>
#define PII pair<int, int>
#define PPII pair<PII, int>
#define M7 1000000007ll
#define M9 1000000009ll
#define MFFT 998244353ll 
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define outv(a) for(auto& x: a) cout << x << ' ';


void Solve() {
	make(string, s);
	VI a = { 1 };
	for (int i = 1; i < s.length(); ++i) {
		if (s[i] == s[i - 1]) a[a.size() - 1]++;
		else a.emplace_back(1);
	}
	for (int i = 0; i < a.size(); i += 2) {
		for (int j = 1; j < a[i]; ++j) cout << "0 ";
		int lval = (a[i] + a[i + 1]) / 2;
		int rval = (a[i] + a[i + 1]) - lval;
		if (a[i + 1] > a[i]) swap(lval, rval);
		if (max(a[i], a[i + 1]) & 1) swap(lval, rval);
		cout << lval << ' ' << rval << ' ';
		for (int j = 1; j < a[i + 1]; ++j) cout << "0 ";
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef _SUPER_DEFINE
	auto F1 = freopen("input.txt", "r", stdin);
	auto F2 = freopen("output.txt", "w", stdout);
	if (F1 == NULL || F2 == NULL) return 0;
	if (sizeof(int) != 8) cout << "NO LONG!!!\n";
	Solve();
	fflush(stdout);
	while (!cin.eof()) {
		string s = "_";
		do getline(cin, s);
		while (!cin.eof() && !s.empty());
		if (cin.eof()) break;
		FOR(2) cout << endl;
		Solve();
		fflush(stdout);
	}
	fclose(F1), fclose(F2);
#else
	Solve();
#endif
	return 0;
	}

Measured memory_bytes: 1096
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define N 205
using namespace std;
char op[4];
int cost[11][11], a[N][N];
int main() {
    int h, w, ans = 0;
    cin >> h >> w;
    for(int i = 0; i <= 9; i++)
        for(int j = 0; j <= 9; j++)
            cin >> cost[i][j];
    for(int k = 0; k <= 9; k++) 
        for(int i = 0; i <= 9; i++) 
            for(int j = 0; j <= 9; j++) 
                cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
    for(int i = 1; i <= h; i++) 
        for(int j = 1; j <= w; j++) {
            cin >> a[i][j]; 
            if(a[i][j] == -1 || a[i][j] == 1) continue;
            ans += cost[a[i][j]][1];
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

bool in(ll y, ll x, ll h, ll w){
    return 0 <= y && y < h && 0 <= x && x < w;
}

int main(){
    while(1){
        int w,h; scanf("%d%d",&w,&h);
        if(!h && !w) break;
        vector<vc> s(2*h-1, vc(w));
        rep(i,2*h-1){
            if(i&1) rep(j,w) cin >> s[i][j];
            else rep(j,w-1) cin >> s[i][j];
        }
        vvl d(h,vl(w,linf));
        d[0][0] = 0;
        queue<P> q;
        q.emplace(0,0);
        while(!q.empty()){
            P p = q.front(); q.pop();
            ll y = p.first, x = p.second;
            rep(i,4){
                ll ny = y + dy[i];
                ll nx = x + dx[i];
                if(in(ny,nx,h,w)&&d[ny][nx]==linf){
                    if(i<2 && s[2*y+dy[i]][x]=='1') continue;
                    if(i==2 && s[2*y][x]=='1') continue;
                    if(i==3 && s[2*y][x-1]=='1') continue;
                    d[ny][nx] = d[y][x] + 1;
                    q.emplace(ny,nx);
                }
            }
        }
        if(d[h-1][w-1]==linf) cout << 0 << endl;
        else cout << d[h-1][w-1] + 1 << endl;
    }
}


Measured memory_bytes: 3124
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long[] xs = [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];
  long K;
  scanln(K);
  writeln(xs[K-1]);
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int sumAC[100001]; // i文字目までにACはいくつあるか

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

	int N, Q;
	string S;
	cin >> N >> Q >> S;
	queue<int> ans;

	char befo = S[0];
	sumAC[0] = 0;
	for (int i = 1; i < S.size(); i++) {
		sumAC[i] = sumAC[i - 1];
		char nowc = S[i];
		if (befo == 'A' && nowc == 'C') sumAC[i]++;
		befo = nowc;
	}

	for (int i = 0; i < Q; i++) {
		int l, r; cin >> l >> r;
		l--; r--;
		if (l != 0) ans.push(sumAC[r] - sumAC[l]);
		else ans.push(sumAC[r]);
	}

	while (!ans.empty()) {
		cout << ans.front() << endl;
		ans.pop();
	}

	return 0;
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
#define fn(i,n) for(int i=0;i<n;i++)
#define rn(i,n )for(int i=1;i<n;i++)
#define ll  long long int
#define wh while
#define str string
#define pb push_back
#define N 2101
#define MOD 100000007
#define sc(n) scanf("%lld",&n)
#define mkp(a,b) make_pair(a,b)
#define INF 100000000000
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p; 
    while (y > 0)
    {
     
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;  
    }
    return res;
}
vector < pair <ll,ll> > v;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll x1,x2,x3,x4,y4,y1,y2,y3;
    cin>>x1>>y1>>x2>>y2;
    x3 = x2 - y2 + y1;
	y3 = y2 + x2 - x1;
	x4 = x1 - y2 + y1;
	y4 = y1 + x2 - x1;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
 
   return 0;
}

Measured memory_bytes: 256
from collections import deque

q = deque([1,2,3,4,5,6,7,8,9])

n = int(input())

for _ in range(n-1):
    a = q.popleft()
    if a%10 != 0:
        q.append(a*10 + a%10 - 1)
    q.append(a*10 + a%10)
    if a%10 != 9:
        q.append(a*10 + a%10 + 1)
print(q.popleft())

Measured memory_bytes: 11908
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int T=scanner.nextInt();
		int t[]=new int[n];
		for(int i=0;i<n;i++) {
			t[i]=scanner.nextInt();
		}
		long sum=T;
		long b=t[0]+T;
		for(int i=1;i<n;i++) {
			if(t[i]<b) {
				sum+=t[i]+T-b;
			}else {
				sum+=T;
			}
			b=t[i]+T;
		}
		System.out.println(sum);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22356
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[]) {
	int n, h, w, a, b, ans = 0;
	cin >> n >> h >> w;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		ans += a >= h && b >= w;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func sumOfDigits(n int) int {
	var sum int
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}

func main() {
	var n, a, b, ans int
	fmt.Scan(&n, &a, &b)

	for i := 1; i <= n; i++ {
		if sumOfDigits(i) >= a && sumOfDigits(i) <= b {
			ans += i
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#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 REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n, m;
int par[150010];
int rk[150010];

void init (int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rk[i] = 0;
  }
}

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

void unite (int x, int y) {
  x = fd(x);
  y = fd(y);
  if (x == y) return;

  if (rk[x] < rk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rk[x] == rk[y]) rk[x]++;
  }
}


int main(){
  cin >> n >> m;
  init(n);

  REP(i,m) {
    int a,b,c;
    cin >> a >> b >> c;
    unite(a,b);
  }

  set<int> st;
  for (int i = 1; i <= n; i++) {
    st.insert(fd(i));
  }
  cout << sz(st) << endl;
  return 0;
}


Measured memory_bytes: 5760
from itertools import combinations
import numpy as np

def li():
    return [int(x) for x in input().split()]

H, W, K = li()
c = [list(input()) for x in range(H)]

def checkCount(m):
    cnt = 0
    for l in m:
        cnt += l.count('#')
    return cnt

result = 0
for h in range(H+1):
    comh = list(combinations(range(H),h))
    sm = 0
    for x in comh:
        cr = [c[i] if i not in x else [0]*W for i in range(H)]
        crt = np.array(cr).T.tolist()
        for w in range(W+1):
            comw = list(combinations(range(W),w))
            for y in comw:
                z = [crt[j] for j in range(W) if j not in y]
                if checkCount(z) == K:
                    result += 1

print(result)




Measured memory_bytes: 27196
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int x, y;
    cin >> x >> y;
    for (int t = 0; t <= x; t++) {
        if (2 * t + 4 * (x - t) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> H(N);

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

    int ans = 0;

    for (int i = 0; i < N; i++)
    {
        bool flag = 1;

        for (int j = 0; j < i; j++)
        {
            if (H[i] < H[j])
            {
                flag = 0;
            }
            
        }
        
        if (flag)
        {
            ans++; 
        }
        
    }
    
    cout << ans << endl;
    }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			char[][] th = new char[N][];
			for (int i = 0; i < N; ++i) {
				th[i] = sc.next().toCharArray();
				if (i == 0) continue;
				int head = 0;
				for (; th[i][head] == '.'; ++head) {
					th[i][head] = ' ';
				}
				--head;
				th[i][head] = '+';
				int prev = -1;
				for (int j = i - 1; j >= 0; --j) {
					if (th[j][head] == '+') {
						prev = j;
						break;
					}
					if (th[j][head] != ' ') break;
				}
				if (prev != -1) {
					for (int j = prev + 1; j < i; ++j) {
						th[j][head] = '|';
					}
				}
			}
			for (int i = 0; i < N; ++i) {
				System.out.println(String.valueOf(th[i]));
			}
		}
	}

}

Measured memory_bytes: 71400
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        vec.push_back(num);
    }

    sort(vec.begin(), vec.end(), greater<int>());

    int ans = 1;
    int preNum = vec[0];
    for (int i = 1; i < n; i++)
    {
        if (vec[i] < preNum)
        {
            preNum = vec[i];
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np

H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

mtx = np.ones([H, W])
# print(mtx)
mtx[:h] = 0
mtx[:, 0:w] = 0
# print(mtx)
print(np.count_nonzero(mtx))


Measured memory_bytes: 12484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
int a,b;
cin>>a>>b;
if(b==1){
    cout<<0;
    return 0;
}
cout<<(b-2)/(a-1)+1;
}

Measured memory_bytes: 256
import heapq
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x) * (-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp = heapq.heappop(A)
        tmp *= -1
        tmp = tmp // 2
        heapq.heappush(A, tmp * (-1))
    print(sum(A) * (-1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14168
#include<stdio.h>
int main(){
  int n,m,d[100010],l=0,r=0,i,c=0,a=0;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%1d",&d[i]);
  if(d[0]==0)c=1;
  for(l=0;l<n;l++){
    while(c<m+1){
      if(d[r]==1&&d[r+1]==0)c++;
      if(r==n)goto END;
      r++;
    }//printf("%d %d\n",l,r);
    if(a<r-l)a=r-l;
    if(d[l]==0&&d[l+1]==1)c--;
  }//printf("%d %d\n",l,r);
 END:;//printf("%d %d\n",l,r);
  if(a<r-l)a=r-l;
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 512
lake_circumference, house_count = map(int, input().split())
locations = list(map(int, input().split()))
min_distance = 10e6
for i in range(house_count):
    if i == 0:
        distance = locations[house_count-1] - locations[0]
    else:
        distance = lake_circumference + locations[i-1] - locations[i]
    if distance < min_distance:
        min_distance = distance
print(min_distance)


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  ll n,m,x; cin >> n >> m >> x;
  vl c(n);
  vvl a(n,vl(m));
  rep(i,n){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }

  ll res = L_INF;
  for(int i=0;i<(1<<n);i++){
    
    ll sum = 0;
    vl r(m);
    rep(j,n){ //jばんめの参考書
      if(i & (1<<j)){
        sum+=c[j];
        rep(k,m){
          r[k] += a[j][k];
        }
      }
    }
    //rについてxを超えるかチェック
    bool is_res = true;
    rep(j,m){
      if(r[j] < x)is_res = false;
    }
    if(is_res)res=min(res,sum);
  }
  cout << ((res == L_INF)?-1:res) << endl;
}

Measured memory_bytes: 3664
stac_in = gets.split(" ")
stac = Array.new()
stac_in.each do |ele|
  
  if ele == "+" || ele =="-" || ele =="*"
    a = stac.pop
    b = stac.pop
    c = case ele
        when "*"
        a*b
        when "+"
        a+b
        when "-"
        b-a
        end
    stac.push(c)
  else
    stac.push(ele.to_i)  
  end  
end
printf("%d\n",stac.last)

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
char s[200005];
int n;
long sum[200005],ans;

int main()
{
    scanf("%s",s+1);
    n = strlen(s+1);
    for(int i = 1;i <= n-2;i++)
    {
        if(s[i] == 'A') sum[i] = sum[i-1]+1;
        if(s[i] == 'A'&&s[i+1] == 'B'&&s[i+2] == 'C')
        {
            s[i] = 'B';
            s[i+1] = 'C';
            s[i+2] = 'A';
            ans += sum[i];
            sum[i+1] = sum[i]-1;
            sum[i+2] = sum[i];
            i += 1;
        }
    }
    printf("%ld",ans);
}

Measured memory_bytes: 2048
def main():
    s = input()
    while len(s) > 0:
        if s[-7:] == "dreamer":
            s = s[:-7]
        elif s[-6:] == "eraser":
            s = s[:-6]
        elif s[-5:] == "dream":
            s = s[:-5]
        elif s[-5:] == "erase":
            s = s[:-5]
        else:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"549
817
715
603"# => "1152",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }

    let mut ans = 0;
    ans += if a > b { b } else { a };
    ans += if c > d { d } else { c };
    ans.to_string()
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int n,ans,i,j,cnt;
string s;
char c;
map<char,int> cnt1,cnt2;
int main(){
  cin>>n>>s;
  for(i=1;i<n-1;i++){
    cnt=0;
    cnt1.clear();
    cnt2.clear();
    for(j=0;j<i;j++)cnt1[s[j]]++;
    for(j=i;j<n;j++)cnt2[s[j]]++;
    for(c='a';c<='z';c++)if(cnt1[c]&&cnt2[c])cnt++;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  double p[n];
  for(int i=0;i<n;i++){cin>>p[i];p[i]=(p[i]+1)/2;}
  double pre[n+1];
  pre[0]=0;
  for(int i=1;i<=n;i++)pre[i]=pre[i-1]+p[i-1];
  double ans=-1;
  for(int i=0;i<=n-k;i++)
  {
    double x=pre[i+k]-pre[i];
    ans=max(ans,x);
    
  }
  cout<<fixed<<setprecision(9)<<ans;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const ll inf = 1e16 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
int a[2010], b[2010];
ll c[2010];

const int MAX_E = 2010, MAX_V = 1010;
typedef struct{
    int from, to;
    ll cost;
} edge;

edge es[MAX_E];

ll d[MAX_V];
int V, E;

void bellman_ford(int s, int k) {
    fill(d, d+V, inf);
    d[s] = 0;
    for (int j = 0; j < k; j++) {
        for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (d[e.from] != inf && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
}

string solve() {
    V = n;
    E = m;
    for (int i = 0; i < m; i++) {
        es[i] = edge{a[i], b[i], -c[i]};
    }

    bellman_ford(0, n-1);
    ll res = -d[n-1];
    bellman_ford(0, 2*n);
    if (res < -d[n-1]) return "inf";
    return to_string(res);
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }
}

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

    input();
    cout << solve() << endl;;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n;
ll res=0;
int main()
{
	cin >>n;
	if (n%2)
	{
		cout <<"0";
		return 0;
	}
	n/=2;
	while (n)
	{
		res+=n/5;
		n/=5;
	} 
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    if( a < c && c < b || b < c && c < a ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



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

int main() {
  int n, x; cin >> n >> x;
  vector<int> arr(n);
  for (auto &a : arr) cin >> a;
  x -= accumulate(arr.begin(), arr.end(), 0);
  int ans = n + x / *min_element(arr.begin(), arr.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
ac=[0]*(N+1)
wa=[0]*(N+1)
for i in range(M):
    p,s=input().split()
    if ac[int(p)]==1:
        continue
    if s=='AC':
        ac[int(p)]=1
    elif s=='WA':
        wa[int(p)]+=1

ac_ans,wa_ans=0,0
for a,w in zip(ac,wa):
    if a==0:
        continue
    ac_ans+=a
    wa_ans+=w

print(ac_ans,wa_ans)

Measured memory_bytes: 4596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    public class ABC_051_B
    {
        public static void Main()
        {
			var a = Array.ConvertAll(Console.ReadLine().Trim().Split(' '),int.Parse);
            var k = a[0];
            var s = a[1];
            var z = 0;
            
            var result = 0;

            for (int i = 0; i <= k; i++)
            {
                for (int j = 0; j <= k; j++)
                {
                    z = s - i  - j ;
                    if (z >= 0 && z <= k)
                    {
                        result++;
                    }
                }
            }
            Console.WriteLine(result);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int ma=0;
  ll sum=0;
  rep(i,n)
  {
    int a;
    cin>>a;
    sum+=a;
    chmax(ma,a);
  }
  cout<<sum-ma/2<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int n;
	cin >> n;
	if (n % 10 == 3)
		cout << "bon" << endl;
	else if (n % 10 == 0 ||
			n % 10 == 1 ||
			n % 10 == 6 ||
			n % 10 == 8)
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s == "abc") {
    cout << "Yes" << "\n";
  }
  else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, _ := sc.NextInt()
	ans := solve(n)
	fmt.Println(ans)
}

func solve(n int) (ans int) {
	for i := 2; i*i <= n; i++ {
		for z := i; n%z == 0; z *= i {
			ans++
			n /= z
		}
		for n%i == 0 {
			n /= i
		}
	}
	if n != 1 {
		ans++
	}
	return ans
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
int vis[100005];
int pos[100005];
int l[100005],r[100005],d[100005];
vector<pair<int,int> >vec[400005];
map<int,int>mp;
int dfs(int k)
{
    vis[k]=1;
    for(int i=0;i<vec[k].size();i++){
        pair<int,int>tmp=vec[k][i];
        int p=tmp.first;
        int dis=tmp.second;
        if(vis[p]==0){
            pos[p]=pos[k]+dis;
            dfs(p);
        }
        else{
            if(pos[p]!=pos[k]+dis) return -1;
        }
    }
    return 1;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int cnt=1;
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&l[i],&r[i],&d[i]);
        if(mp.find(r[i]) == mp.end()) mp[r[i]] = cnt ++;
        if(mp.find(l[i]) == mp.end()) mp[l[i]] = cnt ++;
        int ll = mp[l[i]];
        int rr = mp[r[i]];
        vec[ll].push_back(make_pair(rr, d[i]));
        vec[rr].push_back(make_pair(ll, -d[i]));
    }
    int flag=1;
    for(int i=1;i<cnt;i++){
        if(vis[i]==0) pos[i]=0;
        flag=dfs(i);
        if(flag==-1) break;
    }
    if(flag==1) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 25472
import sys
s=input()
n=len(s)
for i in range(1,n):
  if s[i]==s[i-1]:
    print(i)
    print(i+1)
    sys.exit()
  if i>1 and s[i]==s[i-2]:
    print(i-1)
    print(i+1)
    sys.exit()
print(-1)
print(-1)

Measured memory_bytes: 39280
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long

using namespace std;

int n,a[200002];
map<int,LL>comb,cnt;
LL sum=0ll;

int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(cnt.count(a[i])==0ll)cnt[a[i]]=0ll;
		comb[a[i]]+=cnt[a[i]];
		cnt[a[i]]++;
	}
	for(auto i=comb.begin();i!=comb.end();i++)sum+=i->second;
	for(int i=0;i<n;i++){
		int tmp=cnt[a[i]]-1;
		cout<<sum-tmp<<endl;
	}	
	
	return 0;
}



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

int main(){
  ll n, k;
  cin >> n >> k;
  vector<double> p(n), ac(n);
  for(ll i=0; i<n; i++) cin >> p[i];
  ac[0] = (p[0]+1)/2;
  for(ll i=1; i<n; i++){
  	ac[i] = ac[i-1] + (p[i]+1)/2;
    //cerr << ac[i] << endl;
  }
  double mx = ac[k-1];
  for(ll i=1; i<=n-k+1; i++){
    //cerr << i << " " << i+k-1 << endl;
    double tmp = ac[i+k-1] - ac[i-1];
  	if(mx < tmp) mx = tmp;
  }
  printf("%15.15lf\n", mx);
}


Measured memory_bytes: 3328
import sys
def input(): return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]
    omit = set([])
    for j in range(W):
        white = True
        for i in range(H):
            if A[i][j] == '#':
                white = False
                break
        if white: omit.add(j)
    for i in range(H):
        white = True
        for j in range(W):
            if A[i][j] == "#":
                white = False
                break
        if white: continue
        ans = ""
        for j in range(W):
            if j not in omit:
                ans += A[i][j]
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39920
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
bool pairComparesecond(const p& firstElof, const p& secondElof)
{
    return firstElof.second > secondElof.second;
}
	ll x[5];
int main(){
	ll a,b,c,d,e,f;
	cin>>a>>b;
	cin>>c>>d;
	cin>>e>>f;
	x[a]++;
	x[b]++;
	x[c]++;
	x[d]++;
	x[e]++;
	x[f]++;
	rep(i,0,5){
		if(x[i]==3){
			cout<<"NO"<<endl;
			return 0;
		}
		else continue;
	}
	cout<<"YES"<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
     #include <string>
     #include <vector>
     #include <algorithm>
     #include <utility>
     #include <map>
     using namespace std;
     typedef long long ll;
     #define rep(i, n) for (int i=0;i < (int)(n);i++)

     int main(){
          int a,b;
          char ope;
          string s;
          cin >> a >> ope >> b;
          if (ope =='+') cout << a+b << endl;
          else cout << a-b << endl;
          
          return 0;
     
     }


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = aryread();
    a.sort();
    long current = a[0], count, remove_sum;
    foreach (e; a)
    {
        if (current != e)
        {
            if (current <= count)
            {
                remove_sum += count - current;
            }
            else
            {
                remove_sum += count;
            }
            current = e;
            count = 0;
        }
        count++;
    }
    if (current <= count)
    {
        remove_sum += count - current;
    }
    else
    {
        remove_sum += count;
    }
    remove_sum.writeln();
}


Measured memory_bytes: 4396
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vi> DP(H);
	rep(i, H)
		DP[i].resize(W, 0);
	vector<string> S(H);
	rep(i, H)
		cin >> S[i];
	if (S[0][0] == '#')
		DP[0][0] = 1;
	rep(i, H) {
		rep(j, W) {
			if (i == 0 && j == 0)
				continue;
			int DP0 = InfL, DP1 = InfL;
			if (i > 0)
				DP0 = (S[i - 1][j] == S[i][j]) ? DP[i - 1][j] : DP[i - 1][j] + 1;
			if (j > 0)
				DP1 = (S[i][j - 1] == S[i][j]) ? DP[i][j - 1] : DP[i][j - 1] + 1;
			DP[i][j] = min(DP0, DP1);
		}
	}
	int ans = (DP[H - 1][W - 1] + 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    var [a,b] = input[0].split(" ").map(v=>v-0);
    var list = input[1].split(" ").map(v=>v-0);
    var sum = 0;
    list.forEach(v=>sum+=v);
    console.log(a>=sum?a-sum:-1);
}



Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

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

int main() {
  int N;cin >> N;
  ll S = 0;
  const ll mod = 1000000007;
  int n = N / 3;
  vector<vector<ll>> v(N,vector<ll>(N,0));
  rep(i, 0, N) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  rep(i, 1, N) {
    rep(j, 1, i) v[i][j] = ((v[i-1][j-1] + v[i-1][j]) % mod);
  }
  rep(i, 1, n+1) {
    S += v[N - 2 * i - 1][i-1];
    S %= mod;
  }
  cout << S % mod << endl;
}

Measured memory_bytes: 34604
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

X = I()

now = 100
count = 1
while True:
    now = math.floor(1.01*now)
    if now >= X:
        print(count)
        exit()
    count += 1

Measured memory_bytes: 68124
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using llv = vector<ll>;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD7 = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void init(vector<T>& v, T initVal = T()){
		for(auto& e : v){
			e = initVal;
		}
	}

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	void reverse(vector<T>& v){
		reverse(all(v));
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T1, typename T2>
	inline vector<T1>& operator+=(vector<T1>& v1, const vector<T2>& v2){
		for(const auto& e : v2) v1.push_back(e);
		return v1;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T1, typename T2>
	void in(vector<T1>& v1, vector<T2>& v2){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i];
	}
	template<typename T1, typename T2, typename T3>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i];
	}
	template<typename T1, typename T2, typename T3, typename T4>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3, vector<T4>& v4){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
	}

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

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	template<typename T>
	inline set<T>& operator+=(set<T>& v, const T& e){
		v.insert(e);
		return v;
	}

	template<typename T1, typename T2>
	inline set<T1>& operator+=(set<T1>& v1, const set<T2>& v2){
		for(const auto& e : v2) v1.insert(e);
		return v1;
	}

	constexpr ll modPow(ll x, ll n, ll m){ // O(logn)
		if(n == 0) return 1;
		else if(n % 2 == 0) return modPow((x * x) % m, n / 2, m);
		else return x * modPow(x, n - 1, m) % m;
	}
}
using namespace atcoder;
#endif



int main(){
	cout << fixed << setprecision(15);
	
	int N,M;
	cin>>N>>M;

	intv H(N);cin>>H;

	intv A(M),B(M);
	in(A,B);

	vector<set<int>> road(N);

	for(int i=0;i<M;i++){
		road[A[i]-1]+=B[i];
		road[B[i]-1]+=A[i];
	}
	
	int ans=0;
	for(int i=0;i<N;i++){
		bool good = true;
		for(auto e : road[i]){
			if(H[i]<=H[e-1]){
				good = false;
				break;
			}
		}
		if(good) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 18496
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
using  namespace std;
typedef long long ll;
#define pd(x) printf("%d\n",x)
const double eps=1e-6;
const double PI=acos(-1.0);
const int INF=1e9+10;
const int MOD=1e9+7;
const int N=2e5+15;
int n,a[N],b[N];
vector<int>g[N];
void dfs1(int u,int fa)
{
   for(int i=0;i<g[u].size();i++)
   {
       int v=g[u][i];
        if(v==fa) continue;
       a[v]=a[u]+1;
       dfs1(v,u);
   }
}
void dfs2(int u,int fa)
{
   for(int i=0;i<g[u].size();i++)
   {
       int v=g[u][i];
       if(v==fa) continue;
       b[v]=b[u]+1;
       dfs2(v,u);
   }
}
int main()
{
    while(~scanf("%d",&n))
    {
        int u,v;
        for(int i=1; i<=n; i++)
        {
            g[i].clear();
            a[i]=b[i]=INF;
        }
        for(int i=1; i<n; i++)
        {
            scanf("%d%d",&u,&v);
            g[u].push_back(v);
            g[v].push_back(u);
        }
       a[1]=b[n]=0;
       dfs1(1,1);
       dfs2(n,n);
       int num1=0,num2=0;
       for(int i=2;i<n;i++)
       {
//           printf("i=%d a=%d b=%d\n",i,a[i],b[i]);
           if(a[i]<=b[i]) num1++;
           else num2++;
       }
        if(num1>num2) puts("Fennec");
        else puts("Snuke");
    }
    return 0;
}


Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    rep(i,N) cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(N+5,vector<int>(3));

    dp[0][0] = a[0]; 
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < N; i++){
        dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
        dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
        dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
    }
    cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
}

Measured memory_bytes: 9772