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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M, S;
int U[110], V[110], A[110], B[110];
int C[55], D[55];
int dp[55][5500];
signed main() {
    cin >> N >> M >> S;
    reps(i, M) { cin >> U[i] >> V[i] >> A[i] >> B[i]; }
    reps(i, N) { cin >> C[i] >> D[i]; }
    rep(i, 55)rep(j, 5500) { dp[i][j] = LLONG_MAX; }
    dp[1][min(S, 5499LL)] = 0;
    reps(i, 2 * M) {
        reps(j, N)rep(k, 5500) { if (dp[j][k] < LLONG_MAX) { chmin(dp[j][min(k + C[j], 5499LL)], dp[j][k] + D[j]); }}
        reps(j, M) {
            for (int k = A[j]; k < 5500; k++) {
                if (dp[V[j]][k] < LLONG_MAX) { chmin(dp[U[j]][k - A[j]], dp[V[j]][k] + B[j]); }
                if (dp[U[j]][k] < LLONG_MAX) { chmin(dp[V[j]][k - A[j]], dp[U[j]][k] + B[j]); }
            }
        }
    }
    for (int i = 2; i <= N; i++) {
        int ans = LLONG_MAX;
        rep(j, 5500) { chmin(ans, dp[i][j]); }
        cout << ans << endl;
    }
}

Measured memory_bytes: 6012
A=[]
for i in range(3):
  a=list(map(int,input().split()))
  A+=a
n=int(input())
C=[0]*9
for i in range(n):
  b=int(input())
  for j in range(9):
    if b==A[j]:
         C[j]+=1
if min(C[0:3])>0:
  print('Yes')
elif min(C[3:6])>0:
  print('Yes')
elif min(C[6:9])>0:
  print('Yes')
elif min(C[0::3])>0:
  print('Yes')
elif min(C[1::3])>0:
  print('Yes')
elif min(C[2::3])>0:
  print('Yes')
elif min(C[::4])>0:
  print('Yes')
elif min(C[2],C[4],C[6])>0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
func pow(_ x: Int, _ n: Int, mod: Int) -> Int {
    precondition(n >= 0 && mod > 1)
    if n == 0 { return 1 }

    var u = pow(x, n/2, mod: mod)
    u = u*u % mod
    if n%2 == 1 { u = u*x % mod }
    return u
}

//=============================================================================

let MOD = Int(1e9+7)

let line = readLine()!.split(separator: " ").map { Int($0)! }
let (N, M) = (line[0], line[1])

var modFactorial = [1]
for i in 1...M {
    modFactorial.append(modFactorial[i-1] * i % MOD)
}

func modinv(_ x: Int) -> Int {
    pow(x, MOD-2, mod: MOD)
}
var modinvCache = [Int]()
for i in 0...M {
    modinvCache.append(modinv(modFactorial[i]))
}

func modperm(_ n: Int, _ k: Int) -> Int {
    modFactorial[n] * modinvCache[n-k] % MOD
}

func modcomb(_ n: Int, _ k: Int) -> Int {
    modperm(n, k) * modinvCache[k] % MOD
}

var sigma = 0
for i in 0...N {
    var x = 1
    x *= modcomb(N, i)
    x %= MOD
    x *= modperm(M, i)
    x %= MOD
    x *= modperm(M-i, N-i)
    x %= MOD
    x *= modperm(M-i, N-i)
    x %= MOD
    x *= i%2 == 0 ? 1 : -1
    sigma += x
}
sigma = sigma % MOD + (sigma < 0 ? MOD : 0)
print(sigma)


Measured memory_bytes: 17668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const double eps = 1E-9;

bool equal (double a, double b)
{
    return abs(a-b)<eps;
}

struct V {
    double x, y;
    V(double x=0, double y=0): x(x), y(y) {}
    V operator+(const V& p) const { return V(x+p.x, y+p.y); }
    V operator-(const V& p) const { return V(x-p.x, y-p.y); }
    V operator*(double a) const { return V(x*a, y*a); }
    double sqrNorm() const { return x*x+y*y; }
    double norm() const { return sqrt(sqrNorm()); }
    V rotate90() const { return V(-y, x); }
};

struct Circle {
    V o;
    double r;
    Circle(V o=V(), double r=0): o(o), r(r) {}
    vector<V> xp(const Circle& c) {
        V v = c.o-o;
        double l = v.norm();
        double sub = abs(r-c.r);
        double add = r+c.r;
        if (equal(l, sub)) {
            if (r>c.r) return {o+v*(r/l)};
            else return {o+v*(-r/l)};
        }
        if (equal(l, add)) {
            return {o+v*(r/l)};
        }
        if (l>add || l<sub) {
            return {};
        }
        double x = (r*r-c.r*c.r+l*l)/(2.0*l);
        V mid = o+v*(x/l);
        V dx = v.rotate90()*((sqrt(r*r-x*x))/l);
        return {mid+dx, mid-dx};
    }
    bool isInside(const V& p) {
        return (p-o).norm() < r+eps;
    }
};


int main(){
    int n;
    cin >> n;
    vector<Circle> c(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        c[i] = Circle(V(x, y), 1.0);
    }
    double l = 0.0;
    double r = 2000;
    rep(ti, 100) {
        double x = 0.5 * (l+r);
        vector<V> ps;
        rep(i, n) {
            ps.push_back(c[i].r);
        }
        rep(i, n) rep(j, i) {
            Circle a = c[i];
            Circle b = c[j];
            a.r = x;
            b.r = x;
            vector<V> tmp = a.xp(b);
            for (V v:tmp) {
                ps.push_back(v);
            }
        }
        bool ok = false;
        for (V v:ps) {
            int cnt = 0;
            rep(i, n) {
                Circle a = c[i];
                a.r = x;
                if (a.isInside(v)) cnt++;
            }
            if (cnt==n) ok = true;
        }
        if (ok) r = x;
        else l = x;
    }
    printf("%.10f", r);
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int[] ave = new int[100];
            int count = 0;
            while(true){
                int max = 0, min = 1000, sum = 0;
                int n = sc.nextInt();
                if(n==0) break;

                for(int i=0;i<n;i++){
                    int input = sc.nextInt();
                    sum += input;
                    if(input > max) max = input;
                    if(input < min) min = input;
                }
                ave[count] = (sum - max - min)/(n-2);
                count ++;
            }
            for(int i=0; i<count; i++){
                System.out.println(ave[i]);
            }
        }
    }
}



Measured memory_bytes: 28932
n, k= map(int, input().split())
l = list(map(int, input().split()))
dp = [float("inf")]*n
dp[0] = 0
for i in range(n-1):
    for j in range(1,min(k+1,(n-i))):
        dp[i+j]=min(dp[i]+(abs(l[i]-l[i+j])),dp[i+j])
print(dp[-1])

Measured memory_bytes: 55264
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,p;
    cin >> a >> p;
    PRINT((3*a+p)/2);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int cnt = 0;
    if( n % 2 == 0) {
        cnt = n /2;
    } else {
        cnt = n / 2 + 1;
    }
    cout << float(cnt)/ n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    int n;
    cin>>s;
    n=s.length();
    for(int i=0;i<8;i++){
        string t=s.substr(0,i)+s.substr(n-7+i,7-i);
        //cout<<t<<endl;
        if(t=="keyence"){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<string> b(a);
  rep(i,a)
    cin>>b[i];
  int c=0,d=0,e=0,f=0;
  rep(i,a){
  if(b[i]=="AC")
    c++;
    else if(b[i]=="WA")
      d++;
    else if(b[i]=="TLE")
      e++;
    else
      f++;
  }
  cout<<"AC x "<<c<<endl;
  cout<<"WA x "<<d<<endl;
  cout<<"TLE x "<<e<<endl;
  cout<<"RE x "<<f<<endl;
}

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

#define inf 9023372036854775807

using namespace std;

vector <long long> operator + (vector <long long> & a, vector <long long> & b) {
    vector <long long> c(64);
    for (long long i = 0; i < 64; ++i) {
        c[i] = a[i] + b[i];
    }

    return c;
}

vector <long long> operator - (vector <long long> & a, vector <long long> & b) {
    vector <long long> c(64);
    for (long long i = 0; i < 64; ++i) {
        c[i] = a[i] - b[i];
    }

    return c;
}

bool check (vector <long long> c) {
    for (auto i : c) {
        if (i > 1) {
            return false;
        }
    }

    return true;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    long long n;
    cin >> n;

    long long a[n];
    vector <long long> b[n];

    for (long long i = 0; i < n; ++i) {
        cin >> a[i];
        b[i].resize(64);
        for (long long j = 0; j < 63; ++j) {
            if ((a[i] >> j) & 1) {
                ++b[i][j];
            }
        }
    }



    long long l = 0, r = 0;

    vector <long long> c(64);

    long long ans = 0;

    vector <pair <long long, long long>> sl;

    long long sum = 0, xr = 0;
    while (l < n && r <= n) {
        while (r < n && ((sum + a[r]) == (xr ^ a[r]))) {
            c = c + b[r];
            sum += a[r];
            xr ^= a[r];
            ++r;
        }

//        ans += max(0ll, (r - l) * (r - l + 1) / 2);
        if (sum == xr) {
            sl.emplace_back(l, r - 1);
            ans += max(0ll, (r - l) * (r - l + 1) / 2);
        }

        sum -= a[l];
        xr ^= a[l];

        ++l;
    }

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

    long long f, bal = 0;
    for (long long j = 1; j < sl.size(); ++j) {
         l = max(sl[j - 1].first, sl[j].first);
         r = min(sl[j - 1].second, sl[j].second);
         ans -= max(0ll, (r - l + 1) * (r - l + 2) / 2);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 115956
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;
typedef long long ll;
ll n, a[30][30], dp[N], bul[N];
vector < ll > x, y;

ll f(ll bit);

void dfs(ll ind, ll top){
	if(ind >= (int)x.size()){
		// cout << top << endl;
		y.pb(top);
		return;
	}
	dfs(ind + 1, top);
	dfs(ind + 1, top + x[ind]);
}

ll f(ll bit){
	ll &r = dp[bit];
	if(r != -1)
		return r;
	r = 0;
	if(bit == 0)
		return r;
	x.clear();
	for(ll i = 0; i <= 17; i++)
		if(bit&(1<<i))
			x.pb((1<<i));
	y.clear();
	dfs(0, 0);
	vector < ll > amk = y;
	for(ll i = 0; i < amk.size(); i++)
		dp[bit] = max(dp[bit], bul[amk[i]] + f(bit - amk[i]));

	// cout << bit << " -> " << dp[bit] << bul[bit] << endl;
	return dp[bit];
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%lld",&n);
	for(ll i = 0; i < n; i++)
		for(ll j = 0; j < n; j++)
			scanf("%lld",&a[i][j]);
	for(ll i = 0; i < (1<<n); i++){
		for(ll x = 0; x < n; x++)
			for(ll y = x; y < n; y++)
				if((i&(1<<x)) and (i&(1<<y)))
					bul[i] += a[x][y];
	}
	printf("%lld\n", f((1<<n) - 1));
	return 0;
}

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

vector<int> to[200005];

int main()
{
    int n;
    cin >> n;
    vector<string> w(n);
    rep(i, 0, n) cin >> w[i];
    map<string, int> mp;
    rep(i, 0, n){
        if(mp[w[i]]){
            cout << "No" << endl;
            return 0;
        }
        if(i > 0){
            if(w[i-1][w[i-1].size()-1] != w[i][0]){
                cout << "No" << endl;
                return 0;
            }
        }
        mp[w[i]]++;
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    ans += min(K, A);
    K -= min(K, A);
    K -= min(K, B);
    ans -= min(K, C);
    cout << ans << endl;
}

Measured memory_bytes: 3628
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll n;
    ll k;
    ll s;
    cin >> n >> k >> s;
    if(s == 1000000000){
        REP(i,k){
            cout << 1000000000 << " " ;
        }
        for(ll i=0; i<n-k; i++){
            cout << 1 << " " ;
        }
        cout << endl;
    }else{
        REP(i,k){
            cout << s << " " ;
        }
        for(ll i=0; i<n-k; i++){
            cout << 1000000000 << " " ;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int k,x;
    cin>>k>>x;
    for(int w=max(-1000000LL,x-k+1);w<=min(1000000LL,x+k-1);w++){
        cout<<w<<" ";
    }

	
	








	
return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

#include "bits/stdc++.h"


struct RMQ {
	using t = long long;
	constexpr static t id() {
		return std::numeric_limits<t>::min();
	}
	static t op(const t &a, const t &b) {
		return std::max(a, b);
	}
};

struct RmQ {
	using t = int;
	constexpr static t id() {
		return std::numeric_limits<t>::max();
	}
	static t op(const t &a, const t &b) {
		return std::min(a, b);
	}
};

template <typename M>
struct SegmentTree {
	int n;
	using T = typename M::t;
	std::vector<T> nodes;

	SegmentTree(std::vector<T> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		nodes.resize(2 * n - 1, M::id());
		for (int i = 0; i < sz; i++) nodes[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) nodes[i] = M::op(nodes[i * 2 + 1], nodes[i * 2 + 2]);
	}
	SegmentTree(int _n) {
		n = 1;
		while (n < _n)n *= 2;
		nodes.resize(2 * n - 1, M::id());
	}
	void update(int k, T a) {
		k += n - 1;
		nodes[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			nodes[k] = M::op(nodes[2 * k + 1], nodes[2 * k + 2]);
		}
	}
	T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
private:
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return M::id();
		if (a <= l && r <= b)return nodes[k];
		else {
			T vl = query(a, b, 2 * k + 1, l, (r + l) / 2),
				vr = query(a, b, 2 * k + 2, (r + l) / 2, r);
			return M::op(vl, vr);
		}
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	SegmentTree<RmQ> st(n);
	REP(i, q) {
		int t, x, y;
		cin >> t >> x >> y;
		if (t == 0)st.update(x, y);
		else cout << st.query(x, y + 1) << endl;
	}
}


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

int n, cnt[40][2], k[40];
long long a[100005], dp[40][2], K;

long long f(int pos, bool flag){
    if (pos == -1) return 0;
    if (dp[pos][flag] != -1) return dp[pos][flag];
    int upper;
    if (flag) upper = 1;
    else if (k[pos]) upper = 1;
    else upper = 0;
    long long mx = 0;
    for (int i = 0; i <= upper; i++){
        mx = max(mx, f(pos-1, flag||i!=k[pos])+(1LL<<pos)*cnt[pos][i^1]);
    }
    return dp[pos][flag] = mx;
}

int main() {
    cin >> n >> K;
    for (int i = 0; i < 40; i++){
        if (K & (1LL << i)) k[i] = 1;
    }
    for (int i = 0; i < n; i++){
        cin >> a[i];
        for (int j = 0; j < 40; j++){
            if (a[i] & (1LL<<j)) cnt[j][1]++;
            else cnt[j][0]++;
        }
    }
    for (int i = 0; i < 40; i++){
        dp[i][0] = -1;
        dp[i][1] = -1;
    }
    cout << f(39, false) << "\n";
}


Measured memory_bytes: 1024
s=input()
t=input()

ans=10**9+7
for i in range(len(s)-len(t)+1):
    miss=0
    tmp=s[i:i+len(t)]
    for j in range(len(t)):
        if tmp[j]!=t[j]:
            miss+=1
    ans=min(ans, miss)

print(ans)



Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


int main() {
  int N;
  cin >> N;
  set<pair<ll,int>> m;
  rep(i,N) {
    ll a;
    cin >> a;
    m.insert({-a,i});
  }
  m.insert({0,-1});
  vec<ll> ans(N,0);
  int id = N-1;
  ll res = 0,M = 0,cnt = 0;
  for (auto &e: m) {
    if (e.second>id) {
      res -= e.first;
      cnt++;
      continue;
    }
    ans[id] += res + cnt*e.first;
    cnt++;
    M = -e.first;
    id = e.second;
    res = -e.first*cnt;
  }
  rep(i,N) {
    print(ans[i]);
  }
  return 0;
}

Measured memory_bytes: 10372
# 入力受け取り
N = int(input())
time_list = input().split()
# strからintに型変換
time_list = [int(i) for i in time_list]
M = int(input())

i = 0
while i < M:
    time_i = time_list
    P_i, X = map(int, input().split())
    P_i_original = time_list[P_i - 1]
    time_i[P_i - 1] = X
    result = sum(time_i)
    time_list[P_i - 1] = P_i_original
    print(result)
    i +=1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  int sum=0;
  cin >> A >> B >> C >> K;
  
  if (A>K)
   cout << K << endl;
  else if (A+B > K)
    cout << A << endl;
  else
    cout << 2*A+B-K << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int x[100];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>x[i];
        sum+=min(k-x[i],x[i]);
    }
    cout<<sum*2<<endl;
    return 0;
}

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

using namespace std;

int main(){
  int i;
  int count = 0;
  vector<int> ans;
  int a, b, c, d;
  
  while(cin >> i){
    count = 0;
    if(cin.eof()){
      break;
    }
    for(a = 0; a < 10; a++){
      for(b = 0; b < 10; b++){
	for(c = 0; c < 10; c++){
	  for(d = 0; d < 10; d++){
	    if(a + b + c + d == i){
	      count++;
	    }
	  }
	}
      }
    }
    ans.push_back(count);
  }
  for(int& d : ans){
    cout << d << endl;
  }
}

Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;

int n, m, x, y, dist[110000];
vector<int> edges[110000], invedges[110000];
map<int, int> cnt;
vector<int> toposorted;
queue<int> next_v;

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

  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    edges[x].push_back(y);
    invedges[y].push_back(x);
    cnt[y] += 1;
  }

  for (int v = 0; v < n; v++) {
    if (cnt[v] == 0) {
      next_v.push(v);
    }
  }

  while (!next_v.empty()) {
    int v = next_v.front();
    next_v.pop();
    toposorted.push_back(v);
    for (int v2 : edges[v]) {
      cnt[v2]--;
      if (cnt[v2] == 0) {
        next_v.push(v2);
      }
    }
  }

  reverse(toposorted.begin(), toposorted.end());
  int ans = 0;
  for (int v : toposorted) {
    for (int v2 : invedges[v]) {
      dist[v2] = max(dist[v2], dist[v] + 1);
      ans = max(dist[v2], ans);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 20284
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,res=0;
  cin>>n;
  vector<int> v(n),c(n);
  for(int i=0;i<n;++i)cin>>v[i];
  for(int i=0;i<n;++i)cin>>c[i];
  for(int i=0;i<n;++i){
    if(v[i]>c[i])res+=v[i]-c[i];
  }
  cout<<res;
  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	Scanner scan2 = new Scanner(System.in);
		
	char[] kari = new char[1000];
	String[] ord = new String[101];
	int x = 0;
	
	String Str = scan.nextLine();
		char[] str = Str.toCharArray();
	
	int q = scan.nextInt();
	
	while(scan.hasNext()){
		ord[x] = "";
		ord[x] = scan.nextLine();
		x++;
		if(x > q){
			break;}}
	
	for(int i=1; i<=q; i++){
		String[] tek = ord[i].split(" ");
		
		int a = Integer.parseInt(tek[1]);
		int b = Integer.parseInt(tek[2]);
		
		if(tek[0].equals("replace")){
			char[] p = tek[3].toCharArray();
			for(int j=0; j<=b-a; j++){
				str[a+j] = p[j];}}
		else if(tek[0].equals("reverse")){
			for(int j=a; j<=b; j++){
				kari[j] = str[j];}
			for(int j=0; j<=b-a; j++){
				str[a+j] = kari[b-j];}}
		else{
			for(int j=a; j<=b; j++){
				System.out.print(str[j]);}
			System.out.print("\n");}}
	}
}


Measured memory_bytes: 31432
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct UF{
	int par[100010],r[100010],m[100010];
	void init(){
		rep(i,100010){
			par[i] = i;
			r[i] = 0;
			m[i] = INF;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		if(r[x] < r[y]){
			par[x] = y;
			m[y] = min( m[y] , m[x] );
		}
		else {
			par[y] = x;
			m[x] = min( m[x] , m[y] );
			if(r[x] == r[y])r[x] ++;
		}
	}
}uf;

int main(){
	uf.init();
	static int N,M;
	static int a[100010];
	static int x[100010],y[100010];
	scanf("%d%d",&N,&M);
	for(int i = 0 ; i < N ; i ++){
		scanf("%d",&a[i]);
	}
	for(int i = 1 ; i <= M ; i ++){
		scanf("%d%d",&x[i],&y[i]);
	}
	
	for(int i = 0 ; i < N ; i ++){
		uf.m[i] = a[i];
	}
	for(int i = 1 ; i <= M ; i ++){
		uf.unit(x[i],y[i]);
	}
	
	multiset<ll> S;
	for(int i = 0 ; i < N ; i ++){
		S.insert(a[i]);
	}
	ll ret = 0;
	ll cnt = (N-1-M)*2;
	for(int i = 0 ; i < N && cnt > 0 ; i ++){
		if(uf.find(i) == i){
			ret += uf.m[i];
			S.erase(S.find(uf.m[i]));
			cnt --;
		}
	}
	if(cnt > S.size()){
		puts("Impossible");
		return 0;
	}
	multiset<ll>::iterator itr = S.begin();
	while(cnt > 0){
		ret += *itr;
		itr ++;
		cnt --;
	}
	cout << ret << endl;
}



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

#define fi first
#define se second
#define pb push_back
#define ll long long
const int N = 3e5 + 7;

using namespace std;

ll n , m;
ll ans = 1 , sum , cnt , mx;
string s , s1;
ll used[N];
int main()
{
        ios_base::sync_with_stdio(false);
   ll T;
   cin >> n >> s;
   if( s.size() < n )
    n = s.size();
   for( int i = 0;i < n;i ++ )
    cout << s[i];
   if( s.size() > n )
    cout << s1 << "...";

}



Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A1, A2, A3;
    cin>>A1>>A2>>A3;
    if(A1+A2+A3>=22){
        cout<<"bust"<<endl;
    }
    else if(A1+A2+A3<=21){
        cout<<"win"<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int a,b;
	scanf("%d %d",&a, &b);
	if((a+b)%2!=0)
	{
		printf("%d",((a+b)/2)+1);
	}
	else
	{
		printf("%d",(a+b)/2);
	}
}



Measured memory_bytes: 1680
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<"1";
  else if(b==0)
    cout<<"2";
  else if(c==0)
    cout<<"3";
  else if(d==0)
    cout<<"4";
  else
    cout<<"5";
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{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;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    if(x.first<y.second)
        return true;
    else if(x.first==y.second)
        return x.second<y.second;
    else
        return false;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}
vector<int> g[100005];
int vis[100005];
vector<int> ans(100005,1);
vector<ll> h(100005);

void dfs(int node)
{
    vis[node]=1;
    for(int to: g[node])
    {
        if(vis[to]){
            if(h[node]<=h[to])
                ans[node]=0;
        }
        else
        {
            if(h[node]<=h[to])
                ans[node]=0;
            dfs(to);
        }
    }
}

void solve()
{   
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i])
            dfs(i);
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(ans[i])
            cnt++;
    cout<<cnt;
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


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

public class Coder
{

    public static int[] ReadArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));
    }

    public static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    public static string ReadStr()
    {
        return Console.ReadLine();
    }

    public static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }

    public static long[] ReadLongArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m));

    }

    public static void Main()
    {

        int[] A = ReadArray();
        int[] B = ReadArray();

        int sum = B.Sum();

        var t = sum / (double)(4 * A[1]);

        Array.Sort(B);
        int cnt = 0;

        for(int i = A[0] - 1; i >= 0; i--)
        {
            if (B[i] >= t) cnt++;

            if(cnt == A[1])
            {
                Console.WriteLine("Yes");
                return;
            }
        }

        Console.WriteLine("No");

        
    

    }

}

Measured memory_bytes: 13268
n = int(input())
lst = list(map(int, input().split()))
rate = [400 * i for i in range(9)]
st = set()
rainbow = 0
for i in range(n):
  for j in range(8):
    if rate[j] <= lst[i] < rate[j + 1]:
      st.add(rate[j])
  if lst[i] >= 3200:
    rainbow += 1
if rainbow == n:
  print(1, n)
  exit()
print(len(st), len(st) + rainbow)

Measured memory_bytes: 9204
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int N;
    cin >> N;
    string s,t;
    cin >> s >> t;
    int i;
    for(i=N;i>0;i--){
        if(s.substr(N-i) == t.substr(0,i)) break;
    }
    cout << 2*N-i << endl; 
    return 0;
}


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

using namespace std;

int main()
{
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++)
    for (int j = 0; j < S.size() - i; j++)
      if (S.substr(0, i) + S.substr(i + j, S.size() - i - j) == "keyence")
      {
        cout << "YES" << endl;
        return 0;
      }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 入力を解釈
	// input = input.split("\n");
	tmp0 = input[0];
	tmp1Array = input[1].split(" ");
	tmp2Array = input[2].split(" ");
	
	var length = tmp1Array.length;
	var totalValue = 0;
	for(var i = 0 ; i <= length ; i++){
	    var temp = tmp1Array[i] -  tmp2Array[i];
	    
	    if(temp > 0){
	        totalValue += temp;
	    }
	}
	console.log(totalValue);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));


Measured memory_bytes: 7372
//ABC163 B

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n,m;
lint a[10000];


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

  lint sum_a = 0;
  rep(i,m){
    scanf("%lld",&a[i]);
    sum_a += a[i];
  }
  if(n >= sum_a){
    ans = n - sum_a;
  }
  else{
    ans = -1;
  }
  
  printf("%lld\n",ans);
}


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

int main(){
    int n;
    while(cin>>n,n){
        vector<int> V(n);
        for(auto &v:V){
            string s;
            cin>>s;
            v=s.size();
        }
        for(int i=0;i<n;i++){
            int cnt=0;
            int ans=i+1;
            int j=i;
            while(cnt<5) cnt+=V[j++];
            if(cnt!=5) continue;
            cnt=0;
            while(cnt<7) cnt+=V[j++];
            if(cnt!=7) continue;
            cnt=0;
            while(cnt<5) cnt+=V[j++];
            if(cnt!=5) continue;
            cnt=0;
            while(cnt<7) cnt+=V[j++];
            if(cnt!=7) continue;
            cnt=0;
            while(cnt<7) cnt+=V[j++];
            if(cnt==7){
                cout<<ans<<endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n;
  cin>>n;
  ll a[n],x[n];
  ll z=0;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    if(i%2==0){
      z+=a[i];
    }else{
      z-=a[i];
    }
  }
  z/=2;
  x[0]=z;
  rep1(i,n){
    x[i]=a[i-1]-x[i-1];
  }
  rep(i,n){
    cout<<2*x[i]<<" ";
  }
}

Measured memory_bytes: 2944
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

using P = std::pair<int, int>;

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

  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  vector<P> X(M);
  rep(i, M) cin >> X[i].first >> X[i].second;
  vector<char> is_good(N, 1);
  rep(i, M) {
    if (H[X[i].first - 1] < H[X[i].second-1]) {
      is_good[X[i].first-1] = 0;
    } else if (H[X[i].first-1] == H[X[i].second-1]){
      is_good[X[i].first-1] = 0;
      is_good[X[i].second-1] = 0;
    } else {
      is_good[X[i].second-1] = 0;
    }
  }

  int answer {};
  rep(i, N) {
    if (is_good[i] == 1) ++answer;
  }
  cout << answer << '\n';
}


Measured memory_bytes: 4708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder(sc.next());
		sc.close();

		sb.reverse();
		int n = sb.length();
		int[] dp0 = new int[n + 1];
		int[] dp1 = new int[n + 1];
		dp1[0] = 2;
		for (int i = 0; i < n; i++) {
			int d = sb.charAt(i) - '0';
			dp0[i + 1] = Math.min(dp0[i] + d, dp1[i] + d);
			dp1[i + 1] = Math.min(dp0[i] + 11 - d, dp1[i] + 9 - d);
		}
		System.out.println(Math.min(dp0[n], dp1[n]));
	}
}


Measured memory_bytes: 48600
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e9;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

char arr[N];
ll n;
bool valid(ll i) {
  return i >= 1 && i <= n - 2 &&
         (arr[i] == '.' && arr[i + 1] == '.' && arr[i + 2] == '.');
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a, b, c, d;
  cin >> n >> a >> b >> c >> d;

  string s;
  cin >> s;
  for (ll i = 1; i <= n; i++)
    arr[i] = s[i - 1];

  if (c < a or d < b) {
    cout << "No" << en;
    return 0;
  }
  if (a > b) {
    swap(a, b);
    swap(c, d);
  }

  if (c < d) {
    bool dp[n + 5];
    memset(dp, false, sizeof(dp));

    dp[a] = true;
    for (ll i = a + 1; i <= c; i++) {
      if (arr[i] == '#')
        continue;
      dp[i] = dp[i - 1] | dp[i - 2];
    }

    bool dp2[n + 5];
    memset(dp2, false, sizeof(dp2));

    dp2[b] = true;
    for (ll i = b + 1; i <= d; i++) {
      if (arr[i] == '#')
        continue;
      dp2[i] = dp2[i - 1] | dp2[i - 2];
    }

    if (dp[c] && dp2[d])
      cout << "Yes" << en;
    else
      cout << "No" << en;

  } else {
    ll flag = 0;

    for (ll i = b - 1; i <= d - 1; i++) {
      if (valid(i)) {
        flag = 1;
        break;
      }
    }

    if (flag == 0) {
      cout << "No" << en;
      return 0;
    }

    bool dp[n + 5];
    memset(dp, false, sizeof(dp));

    dp[a] = true;
    for (ll i = a + 1; i <= c; i++) {
      if (arr[i] == '#')
        continue;
      dp[i] = dp[i - 1] | dp[i - 2];
    }

    bool dp2[n + 5];
    memset(dp2, false, sizeof(dp2));

    dp2[b] = true;
    for (ll i = b + 1; i <= d; i++) {
      if (arr[i] == '#')
        continue;
      dp2[i] = dp2[i - 1] | dp2[i - 2];
    }

    if (dp[c] && dp2[d])
      cout << "Yes" << en;
    else
      cout << "No" << en;
  }

  return 0;
}

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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define rep0(i,n) for (int i=0; i<(n); i++)
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; }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%d "; return r + "\n"; }
#define debug(...) do{printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__);}while(0)
#define FAST_IOSTREAM() do{}while(0);
#else
#define debug(...) do{}while(0)
#define FAST_IOSTREAM() do{std::ios::sync_with_stdio(false); std::cin.tie(nullptr);}while(0)
#endif

int main() {
    FAST_IOSTREAM();

    ll n, k;
    cin >> n >> k;
 
    // n > k の場合は n = n-k を繰り返すことで必ず n <= k とできる。 
    // n <= k の場合のみ考える
    // k-n と k-(k-n) のどちらか小さいほうが答え
    ll ans = 0;
    //while (n>k) n-=k;
    n -= k * (ll)(n/k);

    cout << min(k-n, k-(k-n)) << endl;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<cmath>
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define min_(a,b) ((a)<(b)?(a):(b))
using namespace std;

#define DAY 1440
#define	WEEK 10080
#define HALF 720

int s, n, t, m;
double p;
char weekday[20], times[20];

int count_max(){
	int max_k = 0;
	int w;
	int f_s, f_e, s_s=100000, s_e=-1;
	if (strcmp(times, "All") == 0)f_s = 0, f_e =DAY;
	else if (strcmp(times, "Day") == 0)f_s = HALF / 2, f_e = HALF + f_s;
	else f_s = 0, f_e = HALF / 2, s_s = HALF+f_e, s_e =DAY;
	if (strcmp(weekday, "All")==0)w = 1; else w = 7;
	rep(i, 0, WEEK){
		int k = 0;
		rep(j, 0, m){
			int st = (i+j*t);
			int ed = (st + s);
			st %= WEEK;
			ed %= WEEK;
			//cout << st << times << ed << endl;
			if (w == 7||f_s==HALF/2){
			if ((st / DAY) % w == 0 && st / DAY == ed / DAY)
			if (((st%DAY >= f_s&&st%DAY < f_e) && (ed%DAY >= f_s&&ed%DAY < f_e)) || ((st%DAY >= s_s&&st%DAY < s_e) && (ed%DAY >= s_s&&ed%DAY < s_e)))k++;
				//cout << "C" << endl;
			}
			else if (st / DAY == ed / DAY){
				if (((st%DAY >= f_s&&st%DAY < f_e) && (ed%DAY >= f_s&&ed%DAY < f_e)) || ((st%DAY >= s_s&&st%DAY < s_e) && (ed%DAY >= s_s&&ed%DAY < s_e)))k++;
				//cout << "B" << endl;
			}
			else if (f_e == DAY || (st%DAY >= s_s&&st%DAY < s_e&&ed%DAY >= f_s&&ed%DAY < f_e)){
				k++; 
			//	cout << "A" << endl;
			}
		}
		if (k > max_k)max_k = k;
	
	}
	//cout << max_k << endl;

	return(max_k);

}

int main(void){
	while (true){
		cin >> s >> n >> t >> weekday >> times >> p >> m;
		if (s == 0)return(0);
		double q = (p-1)/p;
		int k = count_max();
		printf("%.10f\n", (double)1.0 - pow(q, k*n));

	}



}

Measured memory_bytes: 1248
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int n;
    while(cin >> n){
        if(n == 0) break;
        else{
            double m = 0;
            double s[n];
            double A = 0;
            for(int i = 0; i < n; i++){
                cin >> s[i];
                m += s[i]/n;
            }
            for(int i = 0; i < n; i++){
                A += pow(s[i]-m,2) / n;
            }
            cout << fixed << setprecision(8) << sqrt(A) <<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3268
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int a,b;
    cin >> a >> b;
    if(a==b) cout << a*2 << endl;
    else cout << max(a,b)*2-1 << endl;
}

Measured memory_bytes: 256
import math
a,b,x=list(map(int,input().split()))
maxv=a*a*b
sukima=maxv-x
teimenseki=sukima/a
y=teimenseki*2/a
 
if x > (maxv/2):
    print(math.degrees(math.atan(y/a)))
else:
    tei=x/a
    z=tei*2/b
    print(math.degrees(math.atan(b/z)))

Measured memory_bytes: 3060
while True :
    n, m = map(int, input().split())
    if n == 0 and m == 0 :
        break
    
    p = list(map(int, input().split()))
    p.sort(reverse=True)
    cst = 0
    for i in range(n) :
        if (i+1) % m != 0 :
            cst += p[i]
    print(cst)


Measured memory_bytes: 5712
#include <stdio.h>
int main(){
  int i,num,tmp,j,count=0;
  scanf("%d",&num);
  int a[num];
  for(i = 0 ; i<num ;i++){
    scanf("%d",&a[i]);
  }
  for(i = 0 ;i<num-1;i++){
    for(j = num-1 ;j>=i+1 ;j--){
      if(a[j]<a[j-1]){
	tmp = a[j-1];
      a[j-1] = a[j];
      a[j] = tmp;
      count++;
    }
  }
  }
    for(i=0;i<num;i++){
      if(i == num-1) {printf("%d\n",a[i]);
	printf("%d\n",count);
      }
    else printf("%d ",a[i]);
    }
  return 0;
}

      
  



Measured memory_bytes: 2080