akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc021_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string N;
  cin >> N;

  ll ans = N[0] - '0';
  bool ok = true;
  repi(i, 1, N.size()) {
    ok &= N[i] == '9';
    ans += 9;
  }

  cout << (ok ? ans : ans - 1) << endl;
}

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

int main() {

	int n;
	cin >> n;

	int A[100];
	for (int i = 0; i < n; i++) cin >> A[i];

	for (int i = 0; i < n/2; i++) {
		swap(A[i], A[n - i - 1]);
	}

	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << A[i];
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 3100
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

count = 0
0.upto(a) do |aa|
  a_sum = 500 * aa
  break if a_sum > x

  0.upto(b) do |bb|
    b_sum = 100 * bb
    break if b_sum > x

    0.upto(c) do |cc|
      c_sum = 50 * cc
      break if c_sum > x

      count += 1 if a_sum + b_sum + c_sum == x
    end
  end
end

puts count

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

int main() {
    long long H, W, Ans = 0;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        Ans = 1;
    } else if (H % 2 == 1 && W % 2 == 1) {
        Ans = ((long long)(H / 2) + 1) * ((long long)(W / 2) + 1) + (H / 2) * (W / 2);
    } else {
        Ans = H * W / 2;
    }

    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
m,i,j,k,c[];main(n){for(;scanf("%d%d",&n,&m)*n;printf("%d\n",j>m?i:j)){for(k=-3;j=k++;)for(scanf("%d",&i);i--;c[n-j]=k)scanf("%d",&j);for(i=n;i--;k-=c[i])j+=pow(3,i)*abs(k*2%4+c[i]);j=fmin(j,pow(3,n)+~j);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

int N;
ll A[100005];
ll freq[100005];
ll ans = 1;


ll powmod(ll a, ll p, ll mod) {
	ll res = 1;
	while (p > 0) {
		if (p & 1) {
			res *= a;
			res %= mod;
		}
		a *= a;
		a %= mod;
		p >>= 1;
	}
	return res;
}

void solve() {
	for (int i = 0; i < N; i++) {
		freq[A[i]]++;
	}
	if (N % 2 == 0) {
		for (int i = 1; i <= N - 1; i+=2) {
			if (freq[i] == 2) {
				continue;
			} else {
				ans = 0;
				break;
			}
		}
	} else {
		for (int i = 2; i <= N - 1; i += 2) {
			if (freq[i] == 2) {
				continue;
			} else {
				ans = 0;
				break;
			}
			if (freq[0] != 1) {
				ans = 0;
			}
		}
	}
	if (ans == 0) {
		cout << 0 << endl;
	} else {
		cout << powmod(2, N/2, (ll)(1e+9+7)) << endl;
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	solve();
	return 0;
}




Measured memory_bytes: 1792
def main():
    n = int(input())

    ms = []
    for _ in range(n):
        s, t = input().split()
        t = int(t)
        ms.append((s, t))

    x = input()
    ret = 0
    flg = False
    for s, t in ms:
        if s == x:
            flg = True
        else:
            if flg:
                ret += t
    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()

# int(input())
# map(int, input().split())


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

struct Point{double x,y;};//点
struct Segment{Point p1,p2;};//線
double dot(Point a,Point b){//内積
    return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b){//外積
    return a.x*b.y-a.y*b.x;
}

int main(void){
    int n;cin>>n;
    Segment a,b;
    Point p,q;
    for(int i=0;i<n;i++){
        cin>>a.p1.x>>a.p1.y>>a.p2.x>>a.p2.y;
        cin>>b.p1.x>>b.p1.y>>b.p2.x>>b.p2.y;
        p.x=a.p2.x-a.p1.x;
        p.y=a.p2.y-a.p1.y;
        q.x=b.p2.x-b.p1.x;
        q.y=b.p2.y-b.p1.y;
        if(dot(p,q)==0.0)cout<<1<<endl;
        else if(cross(p,q)==0.0)cout<<2<<endl;
        else cout<<0<<endl;
    }
    return 0;
}



Measured memory_bytes: 3232
#include <stdio.h>

double factorial(int n)
{
	double sum = 1;
	while(n > 0)
	{
		sum *= n;
		n--;
	}

	return sum;
}

int main()
{
	int n=0;
	while(scanf("%d",&n) != EOF)
	{
		if(n <= 20)
		{
			printf("%0.lf\n",factorial(n));
		}
	}

	return 0;
}

Measured memory_bytes: 632
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int N,count=0;
	vector<int> A;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int a;
		scanf("%d", &a);
		A.push_back(a);
	}
	int min;
	for (int i = 0; i < N - 1; i++) {
		min = i;
		bool flag = false;
		for (int j = i+1; j < N; j++) {
			if (A[j] < A[min]) {
				min = j;
				flag = true;
			}
		}
		swap(A[i], A[min]);
		count += flag;
	}
	for (int i = 0; i < N-1; i++) {
		printf("%d ", A[i]);
	}
	printf("%d\n%d\n", A[N - 1], count);
	return 0;
}

Measured memory_bytes: 2788
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    // input
    ll N;
    cin >> N;
    vector<ll> A(N), S(N+1, 0);
    
    for (ll i = 0; i < N; ++i) {
        cin >> A[i];
        S[i+1] = S[i] + A[i];  // 累積和
    }
    
    // calculation
    ll res = 0;
    map<ll, ll> mp;
    for (ll i = 0; i < N+1; ++i) {
        res += mp[S[i]];
        mp[S[i]]++;
    }
    
    cout << res << "\n";
    
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  for(int i; i < N; i++){
    
    string s;
    cin >> s;
    
    if ( s == "Y"){
      cout << "Four" << endl;
      break;
      }
    
    else if ( i == N - 1){
      cout << "Three" << endl;
    }
  }
}
    
  
      
    
  

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;

  string result;
  for (int i = 0; i < s.size(); i++) {
    result += 'x';
  }

  cout << result << endl;
  
  return 0;
}


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

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int ans = 0;
    for (int i = 0; i*r <= n; i++) {
        for (int j = 0; i*r + j*g <= n; j++) {
            if ((n-(i*r+j*g)) % b == 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
from collections import Counter
from operator import itemgetter

n = int(input())
v = [int(i) for i in input().split()]
a = sorted(Counter(v[::2]).items(), key=itemgetter(1))
b = sorted(Counter(v[1::2]).items(), key=itemgetter(1))
ka, va = a[-1]
kb, vb = b[-1]
if ka != kb:
    print(n - va - vb)
else:
    sa = a[-2][1] if len(a) > 1 else va
    sb = b[-2][1] if len(b) > 1 else vb
    if len(a) == len(b) == 1:
        sa, sb = 0, 0
    print(n - max(sa + vb, va + sb))

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

#define ll long long int
#define PII pair<ll,ll>
const ll sz=2010;
ll dp[sz][sz];
ll n;
PII val[sz];

ll cholo(ll l,ll r,ll id)
{
    if(id>=n){
         return 0;
    }
    ll &ret=dp[l][r];
    if(~ret) return ret;

    ll mx=cholo(l+1,r,id+1)+(val[id].first*abs(l-val[id].second));
    mx=max(mx, cholo(l,r-1,id+1)+(val[id].first*abs(r-val[id].second)));
    return (ret=mx);
}

int main()
{
    ll m,p,q;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>val[i].first;
        val[i].second=i;
    }
    sort(val,val+n,greater<PII>());
    memset(dp,-1,sizeof dp);
    ll ans=cholo(0,n-1,0);
    cout<<ans<<'\n';
}



Measured memory_bytes: 35228
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define sp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}



void solve()
{
	int n;
	cin >> n;
	ll sum = 0;
	ll a[n];
	ll p = 0, res = 1e18;
	rep(i, n) cin >> a[i], sum += a[i];
	rep(i, n - 1){
		p += a[i];
		sum -= a[i];
		res = min(res, abs(p - sum));
	}
	cout << res;
}

 
int main()
{
	// freopen("crosses.in", "r", stdin);
	// freopen("crosses.out", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 5180
#include <iostream>
using namespace std;
int main () {

string s;
cin>>s;
int n=s.size();
if (n%2==0) {n=n-2;} else {n--;}
while (0==0) {
	int da=0;
	for (int i=0; i<n/2; i++) {
		if (s[i]==s[i+n/2]) {da++;}
		else {da=0; break;}
	}
	if (da==n/2) {cout<<n; return 0;}
	n-=2;
}

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define de(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(int i=(a); i<(b); i++)
//-----
int a, b, c, d, ans;
int main() {
	scanf("%d%d%d%d", &a, &b, &c, &d);
	ans=max(0, min(min(b, d)-a, min(b, d)- c));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
from math import ceil
from decimal import Decimal as Deci
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

for k in range(n):
    if k:
        m0 = ceil(Deci(a[k-1][0])/Deci(a[k][0]))
        m1 = ceil(Deci(a[k-1][1])/Deci(a[k][1]))
        m = max(m0, m1)
        a[k] = [m*a[k][0], m*a[k][1]]
print(sum(a[n-1]))


Measured memory_bytes: 5332
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> a(N);
	vector<Int> b(N);
	vector<Int> c(N);

	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (Int i = 0; i < N; i++) {
		cin >> b[i];
	}
	for (Int i = 0; i < N; i++) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	vector<Int> ba(N);//b[i]以下の数
	vector<Int> bc(N);

	Int tempA = 0;
	for (Int i = 0; i < N; i++) {
		while (tempA < N && b[i] > a[tempA]) {
			tempA++;
		}
		ba[i] = tempA;
	}

	Int tempB = 0;
	for (Int i = 0; i < N; i++) {
		while (tempB < N && c[tempB] <= b[i]) {
			tempB++;
		}
		bc[i] = N-tempB;
	}

	Int ans = 0;
	for (Int i = 0; i < N; i++) {
		ans += ba[i] * bc[i];
	}

	cout << ans << "\n";
}

Measured memory_bytes: 4224
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin >> s;
	int accum = 0;
	for(int i=0; i<s.length(); ++i) accum += (s[i]=='1')? 1:-1;
	cout << s.length()-abs(accum) <<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int h,w; cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	int black = 0;
	rep(i,h){
		rep(j,w){
			black += (s[i][j] == '#');
		}
	}
	vector<vector<bool>> visited(h, vector<bool>(w,false));

	int offset[4][2] = {{-1,0},{1,0},{0,-1},{0,1}};
	queue<pair<int,int>> q;
	q.push(make_pair(0,0));
	int path = 1;
	while(!q.empty()){
		path++;
		int c = q.size();
		Rep(c){
			auto [x,y] = q.front();
			q.pop();
			if(!visited[x][y]){
				visited[x][y] = true;
				for(auto k: offset){
					int x2 = x + k[0];
					int y2 = y + k[1];
					if(x2 == h-1 && y2 == w-1){
						cout << h * w - black - path << endl;
						return 0;
					}
					if(0 <= x2 && x2 < h && 0 <= y2 && y2 < w){
						if(!visited[x2][y2] && s[x2][y2] == '.'){
							q.push(make_pair(x2,y2));
						}
					}
				}
			}
		}
	}
	cout << "-1\n";
}

Measured memory_bytes: 3640
def dfs(place,number,checkedList,path):
  checkedList[place] = 1
  if sum(checked) == number:
    return 1
  pathNumber = 0
  for i in path[place]:
    if checkedList[i] == 1:
      continue
    pathNumber += dfs(i,number,checkedList,path)
    checkedList[i] = 0
  return pathNumber  

n, m = map(int, input().split())

checked = [0] * 8
path = [ [] for _ in range(8)]
for i in range(m):
  a, b = map(int, input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
  #print(path)
  
print(dfs(0,n,checked,path))

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n, k;
        in >> n >> k;
        ll ans = 1;
        for (int i = 0; i < n; i++) {
            ans = min(2 * ans, ans + k);
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
const int INF = 1e9;
const int maxn = 1e5 + 7;
const int mod = 1046527;

int a[30];

int main() {
    int n;
    while(~scanf("%d",&n)) {
        for(int i = 1 ; i <= n ; i++) {
            scanf("%d",&a[i]);
        }
        int q;
        scanf("%d",&q);
        while(q--) {
            int m;
            scanf("%d",&m);
            bool flag = false;
            for(int i = 1 ; i < (1 << n) ; i++) {
                int x = i;
                int sum = 0;
                int cnt = n;
                while(x) {
                    if(x&1) sum += a[cnt];
                    x >>= 1;
                    cnt--;
                }
                if(sum == m) {
                    flag = true;
                    break;
                }
            }
            if(flag) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

int main() {
  string str;
  getline(cin, str);
  for (string::iterator it=str.begin(); it!=str.end(); it++){
    if (islower(*it)) *it = toupper(*it);
  }
  cout << str << endl;

  return 0;
}

Measured memory_bytes: 1176
N = int(input())

if N < 10:
    ret = N

elif N < 100:
    ret = 9

elif N < 1000:
    ret = N - 90

elif N < 10000:
    ret = 909

elif N < 100000:
    ret = N - 9090

elif N == 100000:
    ret = 90909

print(ret)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
ans = 0
count = 0
current_num = A[0]
for i in range(N):
    if A[i] == current_num:
        count += 1
    else:
        if count % 2 == 1:
            ans += 1
        count = 1
        current_num = A[i]
if count % 2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 7388
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2)) {
    cout << "Yes" << endl;
  }
  else if (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(1)) {
    cout << "Yes" << endl;
  }
  else if (S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
    vector<int> v(3);
    for(int i = 0; i < 3; i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end(),greater<int>());
    cout << v[0]*10 + v[1] + v[2] << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
n=int(input())  #数値入力
w = list(map(int, input().split()))  #リスト入力

s = sum(w)

_s=0
for i,x in enumerate(w):
    _s+=x
    if _s>=s/2:
        break
print(min(abs(_s-(s-_s)), abs(_s-w[i]-(s-_s+w[i]))))

Measured memory_bytes: 13312
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
   int a,b,c,n;
   int ans = 0;
   while(cin>>n){
      ans = 0;
      for(a=0;a<=9;a++){
         for(b=0;b<=9;b++){
            for(c=0;c<=9;c++){
               if(n-(a+b+c) <= 9 && n-(a+b+c)>=0)
                  ans++;
            }
         }
      }
      printf("%d\n",ans);
   }
   return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




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

    int N;
    ll A,B,C,D;
    cin>>N>>A>>B>>C>>D;

    for(int i=0;i<N;i++){
        int x=N-1-i;
        ll high=A+D*i-C*x;
        ll low=A+C*i-D*x;
        if(low<=B && B<=high){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

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

#define ll long long
#define ld long double

#define pii pair<int, int>
#define pci pair<char, int>
#define pcc pair<char, char>

#define vi vector <int>
#define vll vector<long long>
#define vld vector<long double>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

#define vvi vector<vi>
#define vvll vector<vll>
#define vvld vector<vld>
#define vvb vector<vb>
#define vvc vector<vc>
#define vvs vector<vs>

#define vpii vector<pii>
#define vpci vector<pci>
#define vpcc vector<pcc>

#define all(v) (v).begin(), (v).end()
#define allrev(v) (v).rbegin(), (v).rend()
#define allcomp(v) (v).begin(), (v).end(), comp
#define allrevcomp(v) (v).rbegin(), (v).rend(), comp

const int MOD = 1e9 + 7;
const ld pi = 3.1415926535897932384626433832;

#define line cout<<"\n";
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

void solve(int test_case){
   int n;
   cin >> n;

   ll h = 1ll* n/500 * 1000;
   n %= 500;
   n -= n%5;

   h  += n;
   cout << h;

}

int main(){
    fast
    int test = 1;
   // cin>>test;
    for(int i = 1; i <= test; i++){
        solve(i);
    }
    return 0;
}




Measured memory_bytes: 256
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split();
            a = int.Parse(str[0]);
            b= int.Parse(str[1]);
            if (a+b >= 10) Console.WriteLine("error");
            else Console.WriteLine(a+b);
        }

    }
}


Measured memory_bytes: 27288
#include <stdio.h>

main() {
	int ch1,ch2;
	int a = 0;
	scanf("%x %x", &ch1, &ch2);

	a = ch1 - ch2;

	if (a < 0)
	{
		printf("<");
	}
	else if (a == 0)
	{
		printf("=");
	}
	else
	{
		printf(">");
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;


int main() {

    ll N, M, X;
    cin >> N >> M >> X;

    vector<ll > A(M, 0);
    vector<ll > ruiseki(N+1, 0);
    for(ll i = 0; i < M; i++){
        cin >> A[i];
        ruiseki[A[i]]=1;
    }

    for(ll i = 1; i <= N; i++){
        ruiseki[i] += ruiseki[i-1];
        //cout << ruiseki[i] << endl;
    }

    cout << min(ruiseki[X], ruiseki[N] - ruiseki[X]);

}

Measured memory_bytes: 256
# frozen_string_literal: true

k = gets.to_i
a = [*1..9]
i = 0

k.times do
  i = a.shift
  mod = i % 10
  l = i * 10 + mod

  a << l - 1 if mod != 0
  a << l
  a << l + 1 if mod != 9
end

puts i

Measured memory_bytes: 4348
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
string solve (int x,int y,int z)
{
//	printf("%d %d %d\n",x,y,z);
	if (y==0&&z==0)
	{
		string ans;
		for (int u=1;u<=x;u++) ans+='a';
		return ans;
	}
	if (x==0)
	{
		string ans=solve(y,z,0);
		for (int u=0;u<ans.size();u++)	ans[u]++;
		return ans;
	}
	if (z==0)
	{
		string ans=solve(x,0,y);
		for (int u=0;u<ans.size();u++)	if (ans[u]=='c') ans[u]='b';
		return ans;
	}
	if (z>=x)
	{
		string str=solve(x,y,z-x),ans;
		for (int u=0;u<str.size();u++)
		{
			ans+=str[u];
			if (str[u]=='a') ans+='c';
		}
		return ans;
	}
	else
	{
		string str=solve(x-z,z,y),ans;
		for (int u=0;u<str.size();u++)
		{
			if (str[u]=='a') ans+='a';
			else if (str[u]=='b')	{ans+='a';ans+='c';}
			else ans+='b';
		}
		return ans;
	}
}
int main()
{
	int x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	cout<<solve(x,y,z);
	return 0;
}

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

int main(){
  vector<int> vec(3);
  for(int i=0; i<3; i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(vec.at(0)==vec.at(1)){
    cout<<vec.at(2)<<endl;
  }
  else if(vec.at(1)==vec.at(2)){
    cout<<vec.at(0)<<endl;
  }
}

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

int main()
{
    int n;
    cin >> n;
    int coin[12] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
    int dp[100010] = {};
    for(int i=0; i<=n; i++) dp[i] = 1e9;
    dp[0] = 0;
    
    for(int i=1; i<=n; i++){
        for(int j = 0; j< 12; j++){
            if(i-coin[j]>=0){
                dp[i] = min(dp[i], dp[i-coin[j]]+1);
            }
        }
    }
        
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    X = int(input())

    result = (X // 11) * 2
    X %= 11

    if X == 0:
        print(result)
    elif X <= 6:
        print(result + 1)
    else:
        print(result + 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
ll const mod = 998244353;
const ll MAX = 300000;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
int main() {
    int d, g;
    cin >> d >> g;
    vi p(d), c(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
    }
    int db = 0;
    int ans = INF;
    rep(i, 1 << d) {
        int sum = 0, res = 0;
        if (i >= 24) {
            int k = 65;
        }
        rep(j, d) {
            if (i >> j & 1) {
                sum += (p[j] * 100 * (j + 1) + c[j]);
                res += p[j];
            }
        }
        if (sum >= g) {
            ans = min(ans, res);
            if (ans == res)db = i;
        }
        else {
            int get = 0;
            rep(j, d) {
                if (!(i >> j & 1)) {
                    get = j;
                }
            }
            int cnt = 0;
            while (g - sum > 0) {
                sum += ((get + 1) * 100);
                cnt++;
                if (cnt >= p[get])break;
            }
            if (sum >= g) {
                ans = min(ans, res + cnt);
                if (res + cnt == ans)db = res + cnt;
            }
        }
    }
   
    //cout << db << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=100001;

int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  double res=-1.0;
  int resw=0,resn=0;
  for(int i=0;i*a*100<=f;i++){
    for(int j=0;j*b*100<=f;j++){
      int w=i*a*100+j*b*100;
      for(int k=0;(k*c)*100<=e*w and w+(k*c)<=f; k++){
        for(int l=0;(k*c+l*d)*100<=e*w and w+(k*c+l*d)<=f;l++){
          int nat=k*c+l*d;
          if(w+nat<=f and e*w>=nat*100 ){
            if(resn*(nat+w)<=nat*(resw+resn)){
              resw=w;
              resn=nat;
            }
          }
        }
      }
    }
  }

  cout<<resw+resn<<" "<<resn<<endl;
  return 0;
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b){
    swap(a, b);
  }
  if (a > c){
    swap(a, c);
  }
  if (b > c){
    swap(b, c);
  }
  cout << a << " " << b << " " << c << endl;
}



Measured memory_bytes: 3092
a, b, c, x, y = map(int, input().split())
p0 = a * x + b * y
p1 = 2 * c * max(x, y)
a0 = 2 * c * min(x, y) + a * (max(x, y) - min(x, y))
b0 = 2 * c * min(x, y) + b * (max(x, y) - min(x, y))

if x <= y:
    print(min(p0, p1, b0))
else:
    print(min(p0, p1, a0))

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

const int M = 1e9+7;

int h, w;
char s[1000][1000];
int dp[1005][1005];

int main()
{
  cin >> h >> w;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      cin >> s[i][j];
  
  dp[0][1] = 1;
  
  for (int i = 1; i <= h; ++i)
    for (int j = 1; j <= w; ++j)
      if (s[i-1][j-1] == '.')
        dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % M;
  
  cout << dp[h][w] << endl;
  return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    string s,t;
    cin>>s;
    cin>>t;
    bool f=false;
    f(i,0,s.size()){
        s=s[s.size()-1]+s;
        s.erase(s.size()-1);
        if(s==t){
            f=true;
        }
    }
    if(f){
         cout<<"Yes"<<endl;
     }
     else{
         cout<<"No"<<endl;
     }
    return 0;
}


Measured memory_bytes: 3576
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))

    asort = sorted(A, reverse=True)
    m1 = asort[0]
    m2 = asort[1]

    for i in range(N):
        if A[i] == m1:
            print(m2)
        else:
            print(m1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14112
i=61,f[9],c,m,s;main(y){for(;s?++f[y+*f*12+"=>?2J13IK <@V&"[--s]]:~scanf("%d,%d,%d",&y,f,&s)?s*=5:++i<180?i%12>1?(y=f[i])?y>m?m=y:1:++c:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;

	final int[] nf = {-1};
	void doIt() {
		int m = sc.nextInt();
		int k = sc.nextInt();
		int a[] = solve(m, k);
		for(int j = 0; j < a.length; j++) {
			System.out.print(a[j] + " ");
		}
		System.out.println();
	}


	int[] solve(int m, int k){
		if((1 << m) <= k) {
			return this.nf;
		}
		if(m == 1) {
			if(k == 1) return this.nf;
			else {
				int a[] = {0, 0, 1, 1};
				return a;
			}
		}
		return makeArray(m, k);
	}
	int[] makeArray(int m, int k){
		int d = 1;
		int a[] = new int[(1 << (m + 1))];
		a[0] = k;
		for(int i = 0; i < (1 << m) ; i++) {
			if(i == k) {
				d= 0;
				continue;
			}
			a[i + d] = i;
			a[a.length - (i + d)] = i;
		}
		a[1 << m] = k;

		return a;
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 49012
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

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

    int a, b;
    cin >> a >> b;
    print(a * b);

    return 0;
}

/*
  __ _   ___ _ __  _ __
 / _` | / __| '_ \| '_ \
| (_| || (__| |_) | |_) |
 \__,_(_)___| .__/| .__/
            |_|   |_|
*/


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int MAXN = 100100;

int N;
pair <int, int> A[MAXN], B[MAXN];

int par[MAXN];

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

void uni (int a, int b)
{
    a = cfind (a);
    b = cfind (b);
    if (a != b)
        par[a] = b;
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i].first;
        A[i].second = i;
    }
    for (int i = 0; i < N; i++)
    {
        cin >> B[i].first;
        B[i].second = i;
    }
    sort (A, A + N);
    sort (B, B + N);

    bool bad = false;
    for (int i = 0; i < N; i++)
    {
        if (A[i].first > B[i].first)
            bad = true;
    }
    if (bad)
    {
        //cout << "BAD\n";
        cout << "No\n";
        return 0;
    }

    for (int i = 0; i < N; i++)
        par[i] = i;

    bool okay = false;
    for (int i = 0; i < N; i++)
    {
        uni (A[i].second, B[i].second);
        if (i && A[i] <= B[i-1])
            okay = true;
    }

    bool nbad = true;
    for (int i = 0; i < N; i++)
        if (cfind (i) != cfind (0))
            nbad = false;

    if (nbad && !okay)
        cout << "No\n";
    else
        cout << "Yes\n";
}

Measured memory_bytes: 3712
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}

int main()
{
    string S;
    cin>>S;
    if(S[2]==S[3]&&S[4]==S[5])
        cout<<"Yes";
    else
        cout<<"No";



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,q,xl,xr,res;
int a[1000010],cnt[1000010],ans[1000010];
struct Node{
	int l,r,num;
}f[1000010];
inline int read(){
	int ans=0;
	char c=getchar();
	while(c<'0'||c>'9')
		c=getchar();
	while(c>='0'&&c<='9'){
		ans=ans*10+c-'0';
		c=getchar();
	}
	return ans;
}
inline bool cmp(Node a,Node b){
	if(a.l/1500!=b.l/1500)
		return a.l<b.l;
	if(a.l/1500%2)
		return a.r<b.r;
	else
		return a.r>b.r;
}
inline void Add(int x){
	if(cnt[x]==0)
		res++;
	cnt[x]++;
}
inline void Delete(int x){
	if(cnt[x]==1)
		res--;
	cnt[x]--;
}
int main(){
	n=read();
 	q=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=q;i++){
		f[i].l=read();
		f[i].r=read();
		f[i].num=i;
	}
	sort(f+1,f+q+1,cmp);
	xl=1,xr=1,res=1;
	cnt[a[1]]=1;
	for(int i=1;i<=q;i++){
		while(xl<f[i].l){
			Delete(a[xl]);
			xl++;
		}
		while(xl>f[i].l){
			xl--;
			Add(a[xl]);
		}
		while(xr<f[i].r){
			xr++;
			Add(a[xr]);
		}
		while(xr>f[i].r){
			Delete(a[xr]);
			xr--;
		}
		ans[f[i].num]=res;
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 15456
x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
y = 101
#ans = x
if n == 0:
  print(x)
else:
  for i in range(0,102):
    #if i != x:
      if p.count(i) == 0:
        #print('i=',i,abs(x-i))
        if abs(x-i) < y:
          ans = i
          y = abs(x-i)
          #print('i=',i,'abs=',abs(x-i),'ans=',ans)
  print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 10;
int a[NMAX];
vector<int>edge[NMAX];
int cal(int i)
{
	for(register int j = 0;j < edge[i].size();j++)
		if(a[i] <= a[edge[i][j]])
			return 0;
	return 1;
}
int main(int argc, char const *argv[])
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(register int i = 1;i <= n;i++)	scanf("%d",a+i);
	while(m--)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	int ans = 0;
	for(register int i = 1;i <= n;i++)
		ans += cal(i);
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 9316
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, M; std::cin >> N >> M;
  int left = 0, right = N + 1;
  for (int i = 0; i < M; ++i) {
    int L, R; std::cin >> L >> R;
    left = std::max(left, L);
    right = std::min(right, R);
  }
  std::cout << std::max((right - left) + 1, 0) << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,K; cin>>N>>K;
  ll H[N]; rep(i,N) cin>>H[i];
  sort(H,H+N);
  ll ans=0;
  rep(i,max(0,N-K)) ans+=H[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a[520],n,x;
int main()
{
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; x-=a[i];
	}
	sort(a+1,a+n+1);
	cout<<n+x/a[1];
	return 0; 
} 

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std; 
 
int main()
{
	int n,m;
	cin>>n>>m;
	int a[401]={0},an=0,e[101]={0},o[101]={0},p=0,q=0;
	int t;
	if(n>m)
	{
		t=n;
	}
	else
	{
		t=m;
	}
 	for(int i=1;i<=t*2;i++)
	{
		if(i%2==0)
		{
			p++;
	        e[p]=i;
		}
		else
		{
			 q++;
		     o[q]=i;
		}
    }
	for(int i=1;i<=n;i++)
	   for(int j=i+1;j<=n;j++)
	   {
	      if(((e[i]+e[j]) != 0)&&((e[i]+e[j])%2==0))
			{
				an++;
			}
	   }
	for(int i=1;i<=m;i++)
	   for(int j=i+1;j<=m;j++)
	   {
	      if(((o[i]+o[j]) != 0)&&((o[i]+o[j])%2==0))
			{
				an++;
			}
	   }


	cout<<an;
	return 0;
}   		 

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

int main() {
  char s[3]; cin >> s;
  set<char> S; for(int i = 0; i < 3; ++i) S.insert(s[i]);
  if(S.size() == 3) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define INF 999999999

#define MAX_V 101

int n,m,l,k,a,h;

bool cold[200];

struct edge{int to,cost;};
vector<edge> G[MAX_V];
int d[MAX_V][101];

void dijkstra(int s,int V){
    priority_queue< pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>> > que;
    rep(i,MAX_V)rep(j,101)d[i][j]=INF;
    d[s][m]=0;
    que.push(mp(0,pii(s,m)));
    
    while(que.size()){
        pair<int,pii> p=que.top();
        que.pop();
        
        int v=p.second.first;
        int b=p.second.second;
        if(d[v][b]<p.first)continue;
        
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(b-e.cost>=0 && d[e.to][b-e.cost]>d[v][b]+e.cost){
                d[e.to][b-e.cost]=d[v][b]+e.cost;
                que.push(  mp( d[e.to][b-e.cost] , pii(e.to,b-e.cost) )  );
            }
        }
        if(cold[v]){
            for(int i=m;i>=b;i--){
                if(d[v][i]>d[v][b]+i-b){
                    d[v][i] = d[v][b]+i-b;
                    que.push( mp(d[v][i],pii(v,i)) );
                }
            }
        }
    }
}


int main(){
    while(cin>>n>>m>>l>>k>>a>>h && (n||m||l||k||a||h)){
        rep(i,MAX_V)G[i].clear();
        rep(i,200)cold[i]=false;
        rep(i,l){
            int a;
            cin>>a;
            cold[a]=true;
        }
        rep(i,k){
            int x,y,t;
            cin>>x>>y>>t;
            G[x].pb(edge{y,t});
            G[y].pb(edge{x,t});
        }
        
        dijkstra(a,n);
        
        int mini = INF;
        rep(i,101)mini = min(mini,d[h][i]);
        if(mini==INF)cout<<"Help!"<<endl;
        else cout<<mini<<endl;
    }
}

Measured memory_bytes: 3304
#include <iostream>
#include <set>
#include <stack>
#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;


const int N = 1e5 + 5;
typedef long long ll;
vector<int> adj[N];
bool visited[N] = {};
int nodesNum;
int dp[N];
void dfs(int node) {
	if (visited[node])
		return;
	visited[node] = 1;
	for (int i = 0; i < adj[node].size(); i++) {
		int child = adj[node][i];
		if (!visited[child])
			dfs(child);
		dp[node] = max(1 + dp[child], dp[node]);
	}
}



int main()
{
	int edges;
	cin >> nodesNum >> edges;
	while (edges--)
	{
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
	}
	for (int i = 1; i <= nodesNum; i++) {
		if (!visited[i])
			dfs(i);
	}
	int ans = 0;
	for (int i = 1; i <= nodesNum; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8192
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int l;
    cin >> l;
    
    double a, b, c;
    double ans;
    
    a = l/3.0;
    b = l/3.0;
    c = l/3.0;
    
    //cout << a << " " << b << " " << c << endl;

    ans = a * b * c;
    
    cout << fixed << setprecision(12) << (double)l*l*l / 27 << endl;
    //cout << ans << endl;
    
    //printf("%.12f", (double)l*l*l / 27);
    
    //cout << (double)l * l * l / 27 << endl;


    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int a = 0;
  if (s[1] == s[2]) a = 1;
  if (s[2] == s[3]) a = 1;
  if (s[0] == s[1]) a = 1;
  if (a == 1){
    cout << "Bad";
  } else {
    cout << "Good";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    int n;
    cin >> n;
    if(n==3){
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
    if(n==4){
        cout << 2 << " " << 5 << " " << 20 << " " << 63 << endl;
        return 0;
    }
    if(n==5){
        cout << 2 << " " << 5 << " " << 20 << " " << 63 << " " << 60 << endl;
        return 0;
    }
    vector<int> v;
    v.push_back(2);
    v.push_back(5);
    v.push_back(63);
    v.push_back(20);
    long long int sum = 90;
    int i = 4;
    int num = 64;
    while(1){
        if(i>=n-2) break;
        if(num%2 == 0 || num%3 == 0 || num%5 == 0){
            v.push_back(num);
            sum += num;
            i++;
        }
        num++;
    }
    if(sum%2 == 1){
        sum += 3;
        v.push_back(3);
    }
    else{
        sum += 4;
        v.push_back(4);
    }
    int s = sum%30;
    if(s == 10){
        v.push_back(50);
        sum += 50;
    }
    else if(s == 0){
        v.push_back(30);
        sum += 30;
    }
    else if(s == 28){
        v.push_back(32);
        sum += 32;
    }
    else if(s == 26){
        v.push_back(34);
        sum += 34;
    }
    else{
        v.push_back(30-s);
        sum += 30-s;
    }
    for(int j = 0; j < n; j++){
        cout << v[j] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
N = int(input())


li = []

for _ in range(N):
    a, b = list(map(int,input().split(" ")))
    li.append([b,a,b])

flag = True
now = 0
li = sorted(li)

for a, b, c in li:
    now += b
    if now > c:
        print("No")
        flag = False
        break
        
if flag:
    print("Yes")
        


Measured memory_bytes: 38104
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	double ax, ay, bx, by;
	cin >> ax >> ay >> bx >> by;
	printf("%.6f\n",sqrt(pow(bx-ax,2)+pow(by-ay,2)));
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <list>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  std::vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i]>>b[i]>>c[i];
  }
  vector<std::vector<int>> dp(n,vector<int>(3));
  dp[0]={a[0],b[0],c[0]};
  for(int i=1;i<n;i++)
  {
    dp[i][0]=max({dp[i-1][1]+a[i],dp[i-1][2]+a[i]});
    dp[i][1]=max({dp[i-1][0]+b[i],dp[i-1][2]+b[i]});
    dp[i][2]=max({dp[i-1][0]+c[i],dp[i-1][1]+c[i]});
  }
  int res;
  res=*max_element(dp[n-1].begin(), dp[n-1].end());
  cout <<res<<endl;
  return 0;

}


Measured memory_bytes: 6912