akhauriyash/Code-Regression huggingface dataset:
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
-- returns n! % m
local function modfactorial(n, m)
    local a = 1
    for i=1, n do
        a = a * i % m
    end
    return a
end
----
local MOD = math.floor(10^9) + 7
local N = read.nl()
local S = read.l():totable()

local lcount = 0
local ans = 1

for i=1,2*N do
    local ev = i % 2 == 0 and 1 or 0
    local c = S[i] == 'W' and 0 or 1
    --[[                
        ev  c   example     flip    L           R           use
        0   0   i=3,W       Do not  flip        not flip    R
        0   1   i=3,B       Do      flip        not flip    L
        1   0   i=2,W       Do not  not flip    flip        L
        1   1   i=2,B       Do      not flip    flip        R
    ]]
    if ev ~ c == 0 then
        -- R
        if lcount <= 0 then
            print(0)
            return
        end
        ans = ans * lcount % MOD
        lcount = lcount - 1
    else
        -- L
        lcount = lcount + 1
    end
end
if lcount > 0 then
    print(0)
    return
end

ans = ans * modfactorial(N, MOD) % MOD
print(ans)

Measured memory_bytes: 4836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std {
    bool operator<(const Point &lhs, const Point &rhs) {
        if (lhs.real() < rhs.real() - eps) return true;
        if (lhs.real() > rhs.real() + eps) return false;
        return lhs.imag() < rhs.imag();
    }
}
Point input_point() {ld x, y; cin >> x >> y; return Point(x, y);} // ????????\???
bool eq(ld a, ld b) {return (abs(a - b) < eps);} // ????????????????????????
ld dot(Point a, Point b) {return real(conj(a) * b);} // ??????
ld cross(Point a, Point b) {return imag(conj(a) * b);} // ??????

// ??´????????????
class Line {
public:
    Point a, b;
    Line() : a(Point(0, 0)), b(Point(0, 0)) {}
    Line(Point a, Point b) : a(a), b(b) {}
    Point operator[](const int _num) {
        if (_num == 0)return a;
        else if (_num == 1)return b;
        else assert(false);
    }
};

// ????????????
class Circle {
public:
    Point p;
    ld r;
    Circle() : p(Point(0, 0)), r(0) {}
    Circle(Point p, ld r) : p(p), r(r) {}
};

// CCW
int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if (cross(b, c) > eps) return 1;   // a,b,c??????????¨???¨?????????????????¶
    if (cross(b, c) < -eps) return -1; // a,b,c???????¨???¨?????????????????¶
    if (dot(b, c) < 0) return 2;       // c,a,b???????????´???????????¶
    if (norm(b) < norm(c)) return -2;  // a,b,c???????????´???????????¶
    return 0;                          // a,c,b???????????´???????????¶
}

/* ???????????? */
// ??´?????¨??´??????????????????
bool isis_ll(Line l, Line m) {
    return !eq(cross(l.b - l.a, m.b - m.a), 0);
}

// ??´?????¨?????????????????????
bool isis_ls(Line l, Line s) {
    return isis_ll(l, s) &&
    (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

// ????????¨?????????????????????
bool isis_ss(Line s, Line t) {
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
    ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int q; cin >> q;
    for(int i = 0;i<q;i++){
        Line s1(input_point(),input_point()), s2(input_point(),input_point());
        if(isis_ss(s1,s2)){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3360
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
int h, w, n, m, s, ans = 0, a,b,c,f[100000], num = 0, sum = 0;
int flag = 0;
string str,stt;
int main() {
	cin >> n >> m >> s;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'a') {
			if (c < m + s) {
				c++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
			a++;
		}

		if (str[i] == 'b') {
			if (c < m + s&&b < s) {
				c++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
			b++;
		}
		if (str[i] == 'c')
			cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll x[55], y[55];
    rep(i,0,N) cin >> x[i] >> y[i];
    map<lpair, ll> mp;
    rep(i,0,N){
        rep(j,0,N){
            if(i == j) continue;
            mp[make_pair(x[i] - x[j], y[i] - y[j])]++;
        }
    }
    ll mv = 0;
    for(auto &e: mp){
        mv = max(mv, e.second);
    }
    print(N - mv);


    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  if(x>=400&&x<600){
    cout << 8 << endl;
  }else if(x>=600&&x<800){
    cout << 7 << endl;
  }else if(x>=800&&x<1000){
    cout << 6 << endl;
  }else if(x>=1000&&x<1200){
    cout << 5 << endl;
  }else if(x>=1200&&x<1400){
    cout << 4 << endl;
  }else if(x>=1400&&x<1600){
    cout << 3 << endl;
  }else if(x>=1600&&x<1800){
    cout << 2 << endl;
  }else if(x>=1800&&x<2000){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3612
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
charenger = [k - q] * n
for i in range(q):
    charenger[a[i] - 1] += 1

for out in charenger:
    if out > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 15560
#include <stdio.h>
int main(void){
    int ans=0,i;
    char S[4];
    scanf("%s",S);
    
    for(i=0;i<4;i++){
        if(S[i]=='+')   ans++;
        if(S[i]=='-')   ans--;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7


class ModInt:
    def __init__(self, num, mod):
        self.num = num
        self.mod = mod

    def __str__(self):
        return str(self.num)

    def __repr__(self):
        return "ModInt(num: {}, mod: {}".format(self.num, self.mod)

    def __add__(self, other):
        ret = self.num + other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __sub__(self, other):
        ret = self.num - other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __mul__(self, other):
        ret = self.num * other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def pow(self, times):
        pw = pow(self.num, times, self.mod)
        return ModInt(pw, self.mod)

    def inverse(self):
        return self.pow(self.mod - 2)

    def __truediv__(self, other):
        num = self * other.inverse()
        return ModInt(num, self.mod)


class CombinationSmall:
    def __init__(self, n, k, mod):
        self.n = n
        self.k = k
        self.mod = mod
        self.fact = [ModInt(1, mod)]
        self.inverse = [ModInt(1, mod)]
        for i in range(1, k + 1):
            self.fact.append(self.fact[-1] * ModInt(n - i + 1, mod))
            self.inverse.append(self.inverse[-1] * ModInt(i, mod).inverse())

    def comb(self, k):
        if k > self.k:
            return ModInt(0, self.mod)

        return self.fact[k] * self.inverse[k]


comb = CombinationSmall(n, min(n, 2 * 10 ** 5), mod)

ans = ModInt(2, mod).pow(n) - ModInt(1, mod)
ans -= comb.comb(a)
ans -= comb.comb(b)

print(ans)


Measured memory_bytes: 85232
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())
nsl = lambda: list(nsm())

mod = 1000000007

n, m = nm()
dp = [0] * (n + 2)
for i in range(m):
    tmp = ni()
    dp[tmp] = -1
dp[0] = 1
for i in range(n):
    if i + 1 <= n:
        if dp[i + 1] != -1 and dp[i] != -1:
            dp[i + 1] += dp[i] % mod
            dp[i + 1] %= mod
    if i + 2 <= n:
        if dp[i + 2] != -1 and dp[i] != -1:
            dp[i + 2] += dp[i] % mod
            dp[i + 2] %= mod
if dp[n] == -1:
    print(0)
else:
    print(dp[n] % mod)


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> X, std::vector<long long> Y, std::vector<int> U){
    const int MAX_LEN = 2e5;
    const int OFFSET = 2e5;
    int answer = INT_MAX;
    rep(u,0,4) {
        vector<set<int>> lineL(MAX_LEN+1);  // lineL[y when x is 0] = all x whose direction is u+2
        vector<set<int>> lineD(2*MAX_LEN+1); // lineD[y when x is 0] = all x whose direction is u+1
        rep(i,0,N) {
            if (U[i] == (u+2) % 4) {
                lineL[Y[i]].insert(X[i]);
            } else if (U[i] == (u+1) % 4) {
                lineD[OFFSET + Y[i]-X[i]].insert(X[i]);
            }
        }
        rep(i,0,N) {
            if (U[i] != u) continue;
            // lineL
            auto itr = lineL[Y[i]].lower_bound(X[i]);
            if (itr != lineL[Y[i]].end()) {
                answer = min<int>(answer, (*itr - X[i]) * 5);
            }
            // lineD
            itr = lineD[OFFSET + Y[i]-X[i]].lower_bound(X[i]);
            if (itr != lineD[OFFSET + Y[i]-X[i]].end()) {
                answer = min<int>(answer, (*itr - X[i]) * 10);
            }
        }
        // rotate to left
        rep(i,0,N) {
            ll x = MAX_LEN - Y[i], y = X[i];
            X[i] = x;
            Y[i] = y;
        }
    }
    cout << (answer == INT_MAX ? "SAFE" : to_string(answer)) << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    std::vector<int> U(N);
    unordered_map<char, int> direction = {{'R', 0}, {'D', 1}, {'L', 2}, {'U', 3}};
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        char c;
        std::cin >> c;
        U[i] = direction[c];
    }
    solve(N, std::move(X), std::move(Y), std::move(U));
    return 0;
}


Measured memory_bytes: 44608
#include <stdio.h>
#define MAX 500000
#define INF 1073741823
int L[MAX],R[MAX];

void merge(int A[],int left,int mid,int right){
  int n1 = mid - left, n2 = right - mid;
  int i,j,k;
  for(i=0; i<n1; ++i) L[i] = A[left+i];
  for(i=0; i<n2; ++i) R[i] = A[mid+i];
  L[n1] = INF; R[n2] = INF;
  //L[n1] = -INF; R[n2] = -INF;
  i=0; j=0;
  for(k=left; k<right; ++k){
    if(L[i]<=R[j])
    //if(L[i]>=R[j])
    {
      A[k] = L[i++];
    }
    else
    {
      A[k] = R[j++];
    }
  }
}
void mergeSort(int A[],int left,int right){
  /*ソートの順番を変えたいときは、
  コメントアウトしているところを入れ替える*/
  int i,mid;
  if(left+1<right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}


int main(void) {
  int i,j,n,k,ans,a;
  int l[1000000];
  ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&l[i]);
  }
  mergeSort(l,0,n);
  for(i=0;i<n;i++)
  {
    for(j=0;j<i;j++)
    {
      for(k=0;k<j;k++)
      {
        if(l[k]!=l[j] && l[k]!=l[i] && l[i]!=l[j] && l[k]+l[j]>l[i])
        {
          ans++;
        }
      }
    }   
  }
  printf("%d",ans);
  return 0;
}



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

#define DB	double
#define lf	else if
#define	I64	long long
#define Rd()	(rand() << 15 | rand())
#define For(i,a,b)	for(int i=a;i<=b;i++)
#define Rep(i,a,b)	for(int i=a;i>=b;i--)
	
#define fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

#define CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for (; CH < '0' || ch > '9';)	f= (ch == '-');
		for (; ch >= '0' && ch <= '9'; CH)	(x*= 10)+= ch - '0';
		return	f ? -x : x;
}

#define n	200005

int		N, K, M, B[n];

map<int, int>	A;

bool	Cmp(int a, int b)	{
		return	A[a] < A[b];
}

int		main()	{
		N= IN();
		For(i, 1, N)	{
			int x= IN();
			A[x]++;
			
			if	(A[x] == 1)	B[++ M]= x;
		}
		
		int ans= 0;
		For(i, 1, M)	if	(A[B[i]] >= B[i])	ans+= A[B[i]] - B[i];
			else	ans+= A[B[i]];
		
		cout << ans;
}

Measured memory_bytes: 5120
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b


def lcm(a, b):
    y = a*b / gcd(a, b)
    return int(y)

N = INT()
A = LIST()
c = 1
ans = 0
for i in range(N) :
  if A[i] == c:
    c += 1
    ans += 1

if ans == 0:
  print(-1)
else:
  print(N-ans)

Measured memory_bytes: 27196
N,C,K = [int(x) for x in input().split()]
T = [int(input()) for _ in range(N)]
T.sort()
cnt = 0
first = -float('inf')
peop = 0
for i in T:
    if(i-first>K or peop>=C):
        cnt += 1
        first = i
        peop = 1
    else:
        peop += 1
print(cnt)


Measured memory_bytes: 7384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.size()) ans += s[i]!=t[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL A,B;
  cin>>A>>B;
  LL k = (A+B)/2;
  if(2*k!=A+B){
    cout<<"IMPOSSIBLE"<<endl;
  }
  else if((A>k && B>k ) || (A<k && B<k)){
    cout<<"IMPOSSIBLE"<<endl;
  }else {
  cout<<k<<endl;

  }


  return 0;
}


Measured memory_bytes: 256
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
ll dp[105][N];
void solve()
{
   ll n,w;
   cin>>n>>w;
   for(int i=0;i<=n;i++)
   {
   	  for(int j=0;j<=100000;j++)
   	  {
   	  	  dp[i][j]=1e18;
   	  }
   }
   ll we[n+3],val[n+3];
   for(int i=1;i<=n;i++)
   {
   	  cin>>we[i]>>val[i];
   }
   for(int i=0;i<=n;i++)
   {
   	  dp[i][0]=0;
   }   
   for(int i=1;i<=n;i++)
   {
   	  for(int j=0;j<=100000;j++)
   	  	dp[i][j]=dp[i-1][j];
   	  for(int j=0;j+val[i]<=100000;j++)
   	  {
   	  	  dp[i][j+val[i]]=min(dp[i-1][j]+we[i],dp[i][j+val[i]]);
   	  	  //cout<<dp[i][j+val[i]]<<endl;
   	  }
   }
   ll ans=0;
   for(int i=1;i<=100000;i++)
   {
   	  if(dp[n][i]<=w)
   	  {
   	  	  ans=i;
   	  }
   }
   cout<<ans<<endl;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

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

int main() {
    int r, c;
    cin >> r >> c;

    int value[101][101] = {};
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> value[i][j];
            value[i][c] += value[i][j];
        }
    }

    for (int j = 0; j <= c; j++) {
        for (int i = 0; i < r; i++) {
            value[r][j] += value[i][j];
        }
    }

    for (int i = 0; i <= r; i++) {
        for (int j = 0; j < c; j++) {
            cout << value[i][j] << " ";
        }
        cout << value[i][c] << endl;
    }

    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];

  sort(ALL(A));
  sort(ALL(B));

  if(N%2 == 0){
    cout << B[N/2]+B[N/2-1]-A[N/2]-A[N/2-1]+1 << "\n";
  }else{
    cout << B[N/2]-A[N/2]+1 << "\n";
  }

  return 0;
}

Measured memory_bytes: 6312
//d.c D-Patisserie ABC
#include<stdio.h>
#define lld long long int

lld max4(lld a,lld b,lld c,lld d){
    lld max = a;
    if(b>max){
        max = b;
    }
    if(c>max){
        max = c;
    }
    if(d>max){
        max = d;
    }
    return max;
}

lld max2(lld a,lld b){
    lld max = a;
    if(b>max){
        max = b;
    }
    return max;
}

void iswap(lld *a,int i,int j){
    lld x = a[i];
    a[i] = a[j];
    a[j] = x;
}

void qs(lld *a,int i,int j){
    if(j<=i){
        return ;
    }
    int s = i;
    lld pivot = a[j];
    for(int k=i;k<j;++k){
        if(a[k]<pivot){
            iswap(a,s++,k);
        }
    }
    iswap(a,j,s);
    qs(a,i,s-1);
    qs(a,s+1,j);
}

void quicksort(lld *a,int n){
    qs(a,0,n-1);
}

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    lld  x[n],y[n],z[n];
    for(int i=0;i<n;++i){
        scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
    }

    lld ver1[n],ver2[n],ver3[n],ver4[n],ver5[n],ver6[n],ver7[n],ver8[n];

    for(int i=0;i<n;++i){
        ver1[i] = x[i]+y[i]+z[i];
        ver2[i] = (-1)*x[i]+y[i]+z[i];
        ver3[i] = x[i]+(-1)*y[i]+z[i];
        ver4[i] = x[i]+y[i]+(-1)*z[i];
        ver5[i] = (-1)*x[i]+(-1)*y[i]+z[i];
        ver6[i] = x[i]+(-1)*y[i]+(-1)*z[i];
        ver7[i] = (-1)*x[i]+y[i]+(-1)*z[i];
        ver8[i] = (-1)*x[i]+(-1)*y[i]+(-1)*z[i];
    }

    quicksort(ver1,n);
    quicksort(ver2,n);
    quicksort(ver3,n);
    quicksort(ver4,n);
    quicksort(ver5,n);
    quicksort(ver6,n);
    quicksort(ver7,n);
    quicksort(ver8,n);

    lld sum1=0,sum2=0,sum3=0,sum4=0,sum5=0,sum6=0,sum7=0,sum8=0;

    for(int i=0;i<m;++i){
        sum1 += ver1[n-1-i];
        sum2 += ver2[n-1-i];
        sum3 += ver3[n-1-i];
        sum4 += ver4[n-1-i];
        sum5 += ver5[n-1-i];
        sum6 += ver6[n-1-i];
        sum7 += ver7[n-1-i];
        sum8 += ver8[n-1-i];
    }

    lld ans = max2(max4(sum1,sum2,sum3,sum4),max4(sum5,sum6,sum7,sum8));

    printf("%lld\n",ans);
    return 0;
}

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

typedef long long ll;
const int MaxN = 212345;
const ll mod = 1000000007;


void solve_case() {
	int n;
	cin >> n;
	
	double p[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	
	double dp[n + 1][n + 1];
	dp[1][1] = p[1], dp[1][0] = 1 - p[1];
	for (int i = 2; i <= n; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (j == 0) {
				dp[i][j] = dp[i - 1][j] * (1 - p[i]);
			}
			else if (j == i) {
				dp[i][j] = dp[i - 1][j - 1] * p[i];
			}
			else {
				dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
			}
		}
	}
	
	
	double ans = 0;
	int i = n / 2 + 1;
	while(i <= n) {
		ans += dp[n][i];
		i++;
	}
	cout << setprecision(10) << fixed;
	cout << ans << "\n";
}

signed main() {
    /*ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    
    ll t=1;
    //cin >> t;
    while(t--) solve_case();
}


Measured memory_bytes: 49880
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt() % 2 == 0 ? 2 : 1;
        }
        long sum = (long)Math.pow(3, n);
        long minus = 1;
        for (Integer v: array
             ) {
            minus *= v;
        }
        System.out.println(sum - minus);
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, k = mi()
    maximum_pair = (n - 1) * (n - 2) // 2
    if k > maximum_pair:
        print(-1)
    else:
        m = (n - 1) + (maximum_pair - k)
        print(m)
        for i in range(2, n + 1):
            print("1 {}".format(i))
        cnt = maximum_pair - k
        for u in range(2, n + 1):
            for v in range(u + 1, n + 1):
                if cnt > 0:
                    print("{} {}".format(u, v))
                    cnt -= 1
                else:
                    exit()


if __name__ == "__main__":
    main()

Measured memory_bytes: 42216
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;

int main()
{
	priority_queue<int> PQ;
	int x;
	string com;
	
	while(1)
	{
		cin >> com;
		if(com=="insert")
		{
			cin >> x;
			PQ.push(x);
		}
		else if(com=="extract")
		{
			cout << PQ.top() << endl;
			PQ.pop();
		}
		else if(com=="end") break;
	}
	return 0;
}

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

#define TITLE_NUM 100
#define MUSIC_NUM 50

typedef struct playlist{
  char music_title[TITLE_NUM];
  int music_time;
} PlayList;

int total_music;
char x_music[TITLE_NUM];
PlayList playlist[MUSIC_NUM];

void input(){
  int i;

  scanf("%d", &total_music);
  for(i=0; i<=total_music-1; i++){
    scanf("%s%d", playlist[i].music_title, &playlist[i].music_time);
  }
  scanf("%s", x_music);

}

int main(){
  int i;
  int x_number;
  int sleep_time=0;

  input();

  for(i=0; i<=total_music; i++){
    if(strcmp(playlist[i].music_title,x_music) == 0) {
      x_number = i;
    }
  }

  for(i=x_number+1; i<=total_music; i++){
    sleep_time += playlist[i].music_time;
  }

  printf("%d\n", sleep_time);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll MOD = 1000000007;

const ll MAXN = 2001;
ll dp[MAXN][MAXN];

int main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> S(n);
    vector<ll> T(m);

    for (auto& s : S) { cin >> s; }
    for (auto& t : T) { cin >> t; }

    rep (i, MAXN) { dp[0][i] = dp[i][0] = 1; }

    rep (i, n)
    rep (j, m)
    {
        const auto& s = S[i];
        const auto& t = T[j];

        auto& dst = dp[i + 1][j + 1];

        dst += dp[i + 1][j];
        dst += dp[i][j + 1];
        dst += (s == t ? 0 : MOD - dp[i][j]);
        dst %= MOD;
    }

    cout << dp[n][m] << endl;

    return 0;
}


Measured memory_bytes: 31616
N = int(input())
charA = input().split()

A = []
for i in range(N):
    A.append(int(charA[i]))

count = -1
finalA = [0]*N
         
even = True
while(even):
    for i in range(N):
        if (A[i]%2 == 1):
            even = False
    for i in range(N):
        A[i] = A[i]/2
    count = count +1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct initon
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
string s;
int n;
cin >> n >>s;
REP(i,s.size()){
s[i]+=n;
if(s[i]>90)
s[i]-=26;
}
cout <<s;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long A = long.Parse(input[0]);
            long B = long.Parse(input[1]);
            long C = long.Parse(input[2]);
            long D = long.Parse(input[3]);
            
            Console.WriteLine((get_count(B, C, D) - get_count(A-1, C, D)).ToString());
        }
        public static long get_count(long X, long C, long D)
        {
            return X - X / C - X / D + X / Lcm(C, D);
        }
        // Gratest Common Divider by Euclid 
        public static long Gcd(long a, long b)
        {
            if (a < b)
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
        // Least Common Multiplier
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

const int V=100005;

vector<int> to[V*3];

int d[V*3];

typedef pair<int,int> P;

const int INF=1e+9;

void dij(int s)
{
	priority_queue<P,vector<P>,greater<P> > que;
	fill (d,d+V*3,INF);
	d[s]=0;
	que.push(P(0,s));

	while(!que.empty())
	{

		P p=que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(int i=0;i<to[v].size();i++)
		{
			int nx=to[v][i];
			if(d[nx]>d[v]+1)
			{
				d[nx]=d[v]+1;
				que.push(P(d[nx],nx));
			}

		}
	}
}

int main()
{
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin >> u >> v;
		u--;v--;
		to[u].push_back(v+V*1);
		to[u+V*1].push_back(v+V*2);
		to[u+V*2].push_back(v);
	}
	int s,t;
	cin >> s >> t;
	s--;t--;
	

	dij(s);
	

	cout << (d[t]==INF ? -1:d[t]/3) << endl;


}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, son[MAXN];
vector<int> e[MAXN];

int DFS(int u, int fa) {
	for (auto v : e[u]) {
		if (v == fa) continue;
		son[u] += DFS(v, u);
	}
	if (son[u] >= 2) {
		puts("First");
		exit(0);
	}
	return son[u] ^ 1;
}

int main() {
	read(n);
	for (int i = 1, u, v; i < n; ++i) {
		read(u); read(v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	puts(DFS(1, 0)? "First" : "Second");
	return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int h,w,n,A[12345],map[123][123],i,j,k;
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	k=1;
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
	    if(A[k])map[i][j]=k,A[k]--;
	    else map[i][j]=++k,A[k]--;
	    i++;if(i>h)break;
	    for(j=w;j>=1;j--)
	    if(A[k])map[i][j]=k,A[k]--;
	    else map[i][j]=++k,A[k]--;
	}
	for(i=1;i<=h;i++,printf("\n"))
	for(j=1;j<=w;j++)printf("%d ",map[i][j]);
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> a >> b;
    ll diff = b - a;
    MSG((diff * (diff + 1) / 2) - b)
}


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

int main(void)
{
    int K;
    char S[101];
    char copyS[101];

    scanf("%d", &K);
    scanf("%s", S);

    int len = strlen(S);

    if (len <= K) {
        printf("%s\n", S);
        return 0;
    } else {
        strncpy(copyS, S, K);
        copyS[K] = '\0';
        printf("%s...\n", copyS);
        return 0;
    }
}

Measured memory_bytes: 2128
#include<stdio.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(i=0; i<n; i++)

int main(void)
{
	int i, n=7;
	char a[4];
	char b[7][4]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	scanf("%s", a);
	rep(i,7){
		if(strcmp(a,b[i]) == 0){
			printf("%d", n);
			return 0;
		}
		n--;
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int from = 0;
        int to = n - 1;
        String fromState = execQuery(from);
        if (fromState.equals("Vacant")) {
            return;
        }
        String toState = execQuery(to);
        if (toState.equals("Vacant")) {
            return;
        }

        while (true) {
            int mid = (from + to) / 2;
            
            String midState = execQuery(mid);
            if (midState.equals("Vacant"))
                return;
            
            boolean isSameState = midState.equals(fromState);
            boolean isDiffEven = (mid - from) % 2 == 0;
            if (isSameState && !isDiffEven ||
                    !isSameState && isDiffEven) {
                to = mid;
                toState = midState;
            } else {
                from = mid;
                fromState = midState;
            }
        }
    }
    
    static String execQuery(int qu) {
        System.out.println(qu);
        System.out.flush();
        return sc.next();
    }
}

Measured memory_bytes: 23840
a, b, c = gets.split.map(&:to_i)
K = gets.to_i

if  c > b && b > a
    puts 'Yes'
    exit
end

K.times do
    if b <= a
        b *= 2
    elsif c <= b
        c *= 2
    end
    if  c > b && b > a
        puts 'Yes'
        exit
    end
end

puts 'No'

Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  int flag=0;
  cin >> s;
  vector<int> dp(27);
  for(int i=0; i<s.size(); i++){
    int a = s.at(i);
    a -= 97;
    dp.at(a)++;
  }
  for(int i=0; i<27; i++){
    if(dp.at(i)%2 == 1){
      flag=1;
      break;
    }
  }
  
  if(flag==1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

int main() {
 string s;
 cin >> s;
 
 int count = 0;
 int maxcount = 0;
 
 
  for(int j = 0; j < s.size(); j++) {
   if(s.at(j) != 'A' && s.at(j) !='T' && s.at(j) !='G'&& s.at(j) !='C') {
    maxcount = max(maxcount,count);
    count = 0;
    continue;
    }
    else {
    count++;
    }
  }
  maxcount = max(maxcount,count);
cout << maxcount;
}

Measured memory_bytes: 3600
n, m = map(int, input().split())
N = [0]*n
ac = [0]*n
wa = [0]*n
wa2 = [0]*n
for i in range(m):
  p, s = map(str, input().split())
  p = int(p)
  if N[p-1]==0:
    if s=='WA':
      wa[p-1]+=1
    elif s=='AC':
      ac[p-1]+=1
      N[p-1]=1
      wa2[p-1]=wa[p-1]
print(sum(ac), sum(wa2))

Measured memory_bytes: 6132
import sys
readline = sys.stdin.buffer.readline
 
def main():
    N = int(readline())
    A = [0] *(10**5+1)
    total = 0
    for a in map(int, readline().split()):
        total += a
        A[a] += 1
 
 
    Q = int(readline())
    for _ in range(Q):
        b, c = map(int, readline().split())
        total += A[b]*(c-b)
        print(total)
        A[c] += A[b]
        A[b] = 0
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 15788
#include<bits/stdc++.h>
using namespace std;
long long time(long long n)
{
	if(n==1)
	{
		return 1;
	}
	else
	{
		return time(n/2)*2+1;
	}
}
int main()
{
	long long n;
	cin>>n;
	cout<<time(n);
	return 0;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    set<string> s;
    string S;
    rep(i, N) {
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << "\n";
}


Measured memory_bytes: 19228
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
 
#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
 
#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)
 
typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)
 
#define S_RTN(S)  s_cout(S);return 0
 
 
#define _itoa(A,N) sprintf(A, "%d", N);
 
int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);
 
int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);
 
 
int s_asorts(const void* a, const void* b);
 
//昇順
int s_asorts(const void* a, const void* b) {
    return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
    return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
    return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
    int i;
    rept(i, 0, n) {
        l_cin2(*(a + i), *(b + i));
    }
    return 0;
}
int i_cins(int n, int* a) {
    int i;
    for (i = 0; i < n; i++) {
        i_cin(*(a + i));
    }
 
    return 0;
}
int _gcd(int a, int b) {
    int r, tmp;
    if (a < b) { tmp = a; a = b; b = tmp; }
    r = a % b;
    while (r) {
        if (!r) break;
        a = b; b = r;
        r = a % b;
    }
    return(b);
}
 
long _max(long a, long b) {
    return a > b ? a : b;
}
long _min(long a, long b) {
    return a < b ? a : b;
}
int _swp(int* a, int* b)
{
    int tmp;
    tmp = *b; *b = *a; *a = tmp;
    return 0;
}


int main(){
    int n,k;
    int cnt=0;
    scanf("%d%d",&n,&k);
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
        b[i]=0;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int j=0;j<k;j++){
        int me1,me2,me3,me4;
        scanf("%d%d",&me3,&me4);
        
        me1=me3-1;
        me2=me4-1;
        if(a[me1]==a[me2]){
            b[me1]=1;
            b[me2]=1;
        }else if(a[me1]<a[me2]){
            b[me1]=1;
        }else{
            b[me2]=1;
        }
    }
        
    
    for(int i=0;i<n;i++){
        if(b[i]==0)
            cnt++;
    }
    printf("%d",cnt);
}

Measured memory_bytes: 2504
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

void a()
{
    string s;
    cin >> s;
    int count = 0;
    for(auto e : s)
    {
        if(e == '1')
        {
            count++;
        }
    }
    cout << count << endl;
}

void b()
{
    int n;
    cin >> n;
    int maxa = 0;
    int b;
    for(int i = 0; i < n; i++)
    {
        int tempa, tempb;
        cin >> tempa >> tempb;
        if(tempa > maxa)
        {
            maxa = tempa;
            b = tempb;
        }
    }
    maxa += b;
    cout << maxa << endl;
}

void c()
{

}

void d()
{

}

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


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

int w, h, n, l, r, u, d, x, y, a;

int main() {
    scanf("%d%d%d", &w, &h, &n);
    r = w, u = h;
    while (n--) {
        scanf("%d%d%d", &x, &y, &a);
        if (a == 1) l = max(l, x);
        if (a == 2) r = min(r, x);
        if (a == 3) d = max(d, y);
        if (a == 4) u = min(u, y);
    }
    printf("%d\n", max(r-l,0)*max(u-d,0));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    for (int h = 1;;) {
        if (h > n) {
            break;
        }
        G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) {
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }

    return 0;
}

Measured memory_bytes: 7112
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    boolean ans = true;
    int tmp = 0;
    for(int i = 0;i < n;i++){
      h[i] = sc.nextInt();
    }
    for(int j = 0;j < n;j++){
      if(tmp < h[j]){
        h[j]--;
        tmp = h[j];
      }else if(tmp > h[j]){
        ans = false;
        break;
      }
    }
    if(ans){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

int main(void){
    int a,b,c,e;
        e = 0;
        cin >> a;
        cin >> b;
        cin >> c;
     if(a <= b){
        for (int x = a; x <= b; x++) {
            if(c % x == 0) {
                e += 1;
            }
        }
        cout << e << endl;
     }else{
         return 0;
     }
    return 0;
}


Measured memory_bytes: 3120
using System;

namespace Csharp_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string[] temp= Console.ReadLine().Split(' ');
            int A = int.Parse(temp[0]);
            int B = int.Parse(temp[1]);

            string ans = "Yay!";

            if (A > 8 || B > 8)
            {
                ans = ":(";
            }

            Console.WriteLine(ans);
        }
    }
}


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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)

int main() {
    int ans = 0;
    int a;
    string s;
    cin >> a >> s;
    if(a<3200){
        cout << "red" << endl;
    }
    else cout << s << endl;
}

Measured memory_bytes: 256