akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
h = list(map(int,input().split()))
low = list()

for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] < h[b-1]:
        low.append(a-1)
    elif h[a-1] > h[b-1]:
        low.append(b-1)
    else:
        low.append(a-1)
        low.append(b-1)

print(n-len(set(low)))

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

bool prime[mx6];
vector<int> P;

void sv()
{
    for(int i = 2; i * i <= 1e6; i++){
        if(!prime[i])
            for(int j = i * i; j <= 1e6; j += i)
                prime[j] = false;
    }

    for(int i = 2; i <= 1e6; i++)
        if(!prime[i])
            P.Pb(i);
}

int main()
{
    LL n, p;
    cin >> n >> p;

    if(n == 1)
        return cout << p << '\n', 0;

    sv();

    map<LL, int> mp;
    for(auto i: P){
        int cnt = 0;
        while(p % i == 0)
            cnt++, p /= i;

        if(cnt)
            mp[i] = cnt;
    }

    LL ans = 1;
    for(auto i: mp){
        int x = i.Y / n;
        while(x)
            ans *= i.X, x--;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 8372
def solve(n, ls):
    cnt = 0
    for i in range(n):
        if ls[i] != i + 1:
            cnt += 1
        if cnt > 2:
            return False
    return True


n = int(input())
ls = list(map(int, input().split()))
if solve(n,ls):
    print("YES")
else:
    print('NO')


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

int n;
int a[51];
int cnt=0;

int main(){
    cin>>n;
    for (int i=0; i<n; i++){
        cin>>a[i];
    }
    for (int i=0; i<n-1; i++){
        if (a[i]>a[i+1]){
            break;
        }
        if(i==n-2){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    for (int i=0; i<n-1; i++){
        for (int j=i+1; j<n; j++){
            swap(a[i],a[j]);
            for (int k=0; k<n-1; k++){
                if (a[k]>a[k+1]){
                    cnt++;
                    break;
                }
            }
            swap(a[i],a[j]);
        }
    }
    if (cnt==n*(n-1)/2){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
    //cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define MOD 1000000007

bool Y[1000001], X[1000001];

int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> A(N), B(M);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<M; i++) cin >> B[i];

    for(int i=0; i<N; i++)
        Y[A[i]] = true;
    for(int i=0; i<M; i++)
        X[B[i]] = true;

    long long cnt0 = 0;
    long long cnt1 = 0;
    long long ans = 1;

    for(int i=N*M; i>=1; i--){
        if(Y[i] && X[i]){
            cnt0++;
            cnt1++;
        }else if(Y[i]){
            ans = (ans*cnt1)%MOD;
            cnt0++;
        }else if(X[i]){
            ans = (ans*cnt0)%MOD;
            cnt1++;
        }else{
            long long tmp0 = (cnt0*cnt1)%MOD;
            long long tmp1 = (N*M-i)%MOD;
            long long tmp2 = tmp0+(MOD-tmp1)%MOD;
            ans = (ans*tmp2)%MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)

int32_t main(){
  
  fast;
  double n,d; cin >> n >> d;
  cout << ceil(n/(d*2+1));

 
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,D,x;
    cin>>r>>D>>x;
    ll sub;
    sub=x;
    for(int i=0;i<10;i++){
        sub=r*sub-D;
        cout<<sub<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  int a;
  cin>>a;
  vector<P>p(a);
  for(int i=0;i<a;i++){
    cin>>p[i].second>>p[i].first;
  }
  sort(p.begin(),p.end());
  ll t=0;
  for(int i=0;i<a;i++){
    t+=p[i].second;
    if(t>p[i].first){
      cout<<"No"<<endl;
    return 0;
    }
  }
  cout<<"Yes"<<endl;
}
    
  

Measured memory_bytes: 1792
n = int(input())
ans = 0
a = 0
b = 0
ba = 0
for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[-1] == "A":
        if s[0] == "B":
            ba += 1
        a += 1
    if s[0] == "B":
        b += 1
if a > b:
    ans += b
elif b > a:
    ans += a
else:
    ans += a
    if a == ba and a > 0:
        ans -= 1
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	long long a,b,x,d,sum=0;
	cin>>a>>b>>x;
	if(a%x==0) d=a;
	else d=(a/x+1)*x;
//	cout<<d<<endl;
	sum=(b-d)/x;
	if(a<=d&&b>=d) sum++;
	cout<<sum<<endl;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.size();
    int k=l/2;
    int p=k;
    int cnt=0;
    for(int i=0;i<k;i++)
    {
        if(s[i]==s[p+1])
        {
            cnt++;
            p++;
        }
    }
    if(cnt==k)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        if(sc.nextInt() == 1){
            System.out.println("Hello World");
        }else{
            System.out.println(sc.nextInt() + sc.nextInt());
        }
    }
}


Measured memory_bytes: 23244
#sig49san
N = int(input())
alpha_list = "abcdefghijklmnopqrstuvwxyz"
ans = ""
moji_list = []
while(N != 0):
    tmp = N % 26
    if(tmp == 0):
        tmp = 26
    moji_list.append(alpha_list[tmp-1])
    N = (N - tmp) // 26
for hoge in reversed(moji_list):
    ans += hoge
print(ans)


Measured memory_bytes: 9152
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.size() == 2){
        print(s);
    }else{
        reverse(s.begin(), s.end());
        print(s);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

const ll large_P = 1e9 + 7;


int main(){
  int N, M;
  cin >> N >> M;
  
  if(N == M){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int n=s.nextInt(),count=0;
		BitSet b=new BitSet(n+1);

		int buf;
		for(int i=0;i<n;i++) {
			buf=s.nextInt();
			if(b.get(buf)) count++;
			b.set(buf);
		}

		//System.out.println(count+count%2);
		System.out.println(n-(count+count%2));
	}
}


Measured memory_bytes: 31188
#include<iostream>
#include<algorithm>
using namespace std;
long long a[250000];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%lld", &a[i]);
	/*if (n == 2)
	{
		printf("%lld", abs(a[0] - a[1]));
		return 0;
	}*/
	for (int i = 1; i < n; i++)a[i] += a[i - 1];
	long long sum = a[n - 1];
	long long MIN = 1e18;
	for (int i = 0; i < n - 1; i++)
	{
		MIN = min(MIN, abs(sum - a[i] * (long long)2));
	}
	printf("%lld\n", MIN);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10=1024,X11=2048,X12=4096,X13=8196,X14=16392,X15=32786,X16=65536,X17=131072,X18=262144,X19=524288,X20=1048576;


int A[263];
void _(){
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    sort(A,A+n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        sum +=(A[n-i-1]*(-2*(i%2)+1));

    }

    cout << sum;
}






int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void){
	vector<int> p;
	bool isPrime[10000];

	fill(isPrime, isPrime+10000, true);

	for(int i=2;i<10000;i++){
		if(isPrime[i]){
			p.push_back(i);
			for(int j=2;i*j<10000;j++){
				isPrime[i*j] = false;
			}
		}
	}
	int n;
	while(cin >> n && n){
		vector<int>::iterator upper = upper_bound(p.begin(),p.end(),n), lower;
		--upper;
		lower = upper;
		--lower;
		while(true){
			if(*upper - *lower == 2) break;
			--upper;
			--lower;
		}

		cout << *lower << " " << *upper << endl;

	}
}

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

int main(){
   std::string s;
   std::cin >> s;
   std::vector<char> st;
   for (int i=0; i<s.size(); i++){
      if (s.at(i) != 'B'){
         st.push_back(s.at(i));
      } else{
         if (!st.empty()){
            st.pop_back();
         }
      }
   }
   for (int i=0; i<st.size(); i++){
      std::cout << st.at(i);
   }
   std::cout << std::endl;
}



Measured memory_bytes: 3508
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    vector<vector<int>> ans(H, vector<int>(W));
    int h = 0, w = 0;
    bool to_right = true;
    rep(i, 0, N) {
        rep(j, 0, A[i]) {
            ans[h][w] = i + 1;
            if (to_right) {
                if (w == W - 1) {
                    to_right = false;
                    ++h;
                } else {
                    ++w;
                }
            } else {
                if (w == 0) {
                    to_right = true;
                    ++h;
                } else {
                    --w;
                }
            }
        }
    }
    rep(i, 0, H) {
        rep(j, 0, W) {
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#define max 1000010
using namespace std;

bool isp[max];
vector<int> P;

void sieve(){
	for(int i=0;i<max;i++)isp[i]=true;
	for(int i=2;i<max;i++){
		if(isp[i]){
			P.push_back(i);
			for(int j=2*i;j<max;j+=i)isp[j]=false;
		}
	}
	return;
}

int main()
{
	int n;

	sieve();
	while(cin>>n){
		int c=0;
		for(int i=0;i<P.size();i++)if(P[i]<=n)c++;
		cout<<c<<endl;
	}

	return 0;
}

Measured memory_bytes: 2568
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N;
    cin >> N;
    vector<vector<int>> A(10, vector<int>(10, 0));
    FOR(i, 1, N + 1) {
        stringstream ss;
        ss << i;
        string S = ss.str();
        A[S.front() - '0'][S.back() - '0']++;
    }

    ll ans = 0;
    REP(i, 10) {
        REP(j, 10) {
            ans += A[i][j] * A[j][i];
        }
    }

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


Measured memory_bytes: 384
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
string Yes[2] = {"Yes", "No"};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;

/*------------------------------------------------------------------*/

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

    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << endl;
}


Measured memory_bytes: 3648
n = input()
s = n[-1]
if s == '2' or s == '4' or s == '5' or s == '7' or s == '9':
    print('hon')
    exit()
if s == '0' or s == '1' or s == '6' or s == '8':
    print('pon')
    exit()
if s == '3':
    print('bon')
    exit()




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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 200100;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int a[N];
int b[N];

void solve()
{
        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
                b[i] = a[i];
        }
        sort(b + 1, b + n + 1);
        for(int i = 1; i <= n; i++){
                if(a[i] <= b[n / 2]){
                        cout << b[n / 2 + 1] << "\n";
                }
                else{
                        cout << b[n / 2] << "\n";
                }
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    multiset<int> s;
    rep(i, n){
        auto itr = s.lower_bound(v[i]);
        if(itr != s.begin()){
            itr--;
            s.erase(itr);
        }
        s.insert(v[i]);
    }
    cout << s.size() << endl;
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int n, X, Y ;
    lli ans=0 ;
    pii temp ;
    cin>> n ;
    vector<pair<int, int>> x, y ;
    vector<vpii> adj(n+1) ;
    for(int i=1 ; i<=n ; i++)
      {
        cin>> X >> Y ;
        x.pb(mp(X, i)) ;
        y.pb(mp(Y, i)) ;
      }
    sort(all(x)) ;
    sort(all(y)) ;
    for(int i=1 ; i<n ; i++)
      {
        adj[x[i].se].pb(mp(x[i-1].se, abs(x[i-1].fi-x[i].fi))) ;
        adj[x[i-1].se].pb(mp(x[i].se, abs(x[i-1].fi-x[i].fi))) ;
        adj[y[i].se].pb(mp(y[i-1].se, abs(y[i-1].fi-y[i].fi))) ;
        adj[y[i-1].se].pb(mp(y[i].se, abs(y[i-1].fi-y[i].fi))) ;
      }
    priority_queue<pii> pq ;
    vb taken(n+1, false) ;
    taken[1]=true ;
    for(int i=0 ; i<adj[1].size() ; i++)
      {
        temp=adj[1][i] ;
        if(!taken[temp.fi])
          pq.push(mp(-temp.se, temp.fi)) ;
      }
    while(!pq.empty())
      {
        temp=pq.top() ; pq.pop() ;
        int u=temp.se ; lli w=-temp.fi ;
        if(!taken[u])
          {
            ans+=w ;
            taken[u]=true ;
            for(int i=0 ; i<adj[u].size() ; i++)
              {
                temp=adj[u][i] ;
                if(!taken[temp.fi])
                  pq.push(mp(-temp.se, temp.fi)) ;
              }
          }
      }
    cout<< ans ;
  }


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> trick(n, false);
  
  for(int i = 0; i < k; i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int A;
      cin >> A;
      trick[A] = true;
    }
  }
  int treat = 0;
   for(int i = 1; i < n+1; i++){
     if(trick[i] == false) treat++;
   }
  cout << treat << endl;
}

Measured memory_bytes: 3624
import functools

N = int(input())
a = list(map(int, input().split()))

bucket=[0] * (N+1)
parent=[[] for _ in range(N+1)]

for i in range(1, N+1):
    for j in range(i, N+1, i):
        if j != i:
            parent[i].append(j)
#print(parent)

for i in range(N//2+1, N+1):
    bucket[i]=a[i-1]
#print(bucket)

for i in range(N//2, 0, -1):
    bucket[i] = a[i-1] ^ functools.reduce(lambda x, y:x^y, [bucket[val] for val in parent[i]])
#print(bucket)

ans = [str(i) for i, v in enumerate(bucket) if v == 1]
print(len(ans))
print(' '.join(ans))



Measured memory_bytes: 123664
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 30;
const ll LINF = 1LL << 60;
const double eps = 1e-9;
const ll MOD = 1000000007LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    ll s = 0;
    ll ans = LINF;
    for(int i = 0; i < n - 1; i++) {
        s += a[i];
        chmin(ans, abs(s - (sum - s)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << max(0, A - B * 2) << endl;

    return 0;
}


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

a = list(int(i) for i in input().split() )

a.sort() #リストaを昇順にソート

i = Alice = Bob = 0

while len(a) >= 1:
	if i % 2 == 0:
		Alice += a.pop(len(a)-1) #リストaの末尾の値を加えて、リストから削除
	elif i % 2 != 0:
		Bob += a.pop(len(a)-1) #リストaの末尾の値を加えて、リストから削除

	i += 1


print(Alice - Bob)

Measured memory_bytes: 3060
#include<iostream>                                         
using namespace std;
bool check_3(int x){
    while(x){    
        if(x%10==3) return true;
        x/=10;
    }
    return false;

}
int main(){
    int n;
    int i=3;
    cin>>n;
    while(i<=n){
        if(i%3==0)cout<<" "<<i;
        else if(check_3(i))cout<<" "<<i;
        i++;

    }

    cout<<"\n";

}



Measured memory_bytes: 3100
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())
inline void Fail(){
	printf("0");
	exit(0);
}

int n;

int gcd(int a,int b){
	return a%b==0?b:gcd(b,a%b);
}

int main(){
	scanf("%d",&n);
	REP(a,3500)REP(b,3500){
		ll Big=n/(gcd(a,n))*a;
		Big=Big/(gcd(Big,b))*b;
		ll N=Big/n*4LL,A=Big/a,B=Big/b;
		N-=A+B;
		if(N<=0)continue;
		if(Big%N==0){
			printf("%d %d %lld",a,b,Big/N);
			return 0;
		}
	}
}

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

int main()
{
    int r,g,b,a=0;
    cin >> r >> g >> b;
    
    a=100*r+10*g+b;
    if(a%4==0){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int size = sc.nextInt();
    String[] array = new String[size];
    for (int i = 0; i < size; i++) {
      array[i] = sc.next();
    }

    checkStable(bubble(array), insert(array));
  }

  public static String[] bubble(String[] realArray) {
    String[] strArray = cpStrArray(realArray);
    int[] array = strToInt(strArray);
    int size = strArray.length;

    for (int i = 0; i < size; i++) {
      for (int j = size - 1; j > i; j--) {
        if (array[j] < array[j-1]) {
          swap(strArray, j - 1, j);
          swap(array, j - 1, j);
        }
      }
    }
    print(strArray);
    System.out.println("Stable");

    return strArray;
  }

  public static String[] insert(String[] realArray) {
    String[] strArray = cpStrArray(realArray);
    int[] array = strToInt(strArray);
    int size = strArray.length;

    for (int i = 0; i < size - 1; i++) {
      int min = i;
      for (int j = i + 1; j < size; j++) {
        if (array[j] < array[min]) {
          min = j;
        }
      }
      if (min != i) {
        swap(strArray, min, i);
        swap(array, min, i);
      }
    }
    print(strArray);

    return strArray;
  }

  public static String[] cpStrArray(String[] realArray) {
    String[] strArray = new String[realArray.length];
    for (int i = 0; i < realArray.length; i++) {
      strArray[i] = realArray[i];
    }

    return strArray;
  }

  public static int[] strToInt(String[] strArray) {
    int[] intArray = new int[strArray.length];
    for (int i = 0; i < strArray.length; i++) {
      intArray[i] = Integer.parseInt(strArray[i].replaceAll("[^0-9]", ""));
    }

    return intArray;
  }

  public static void swap(String[] array, int min, int i) {
    String tmp = array[i];
    array[i] = array[min];
    array[min] = tmp;
  }

  public static void swap(int[] array, int min, int i) {
    int tmp = array[i];
    array[i] = array[min];
    array[min] = tmp;
  }

  public static void print(String[] array) {
    int size = array.length;
    for (int i = 0; i < size - 1; i++) {
      System.out.print(array[i] + " ");
    }
    System.out.println(array[size - 1]);
  }

  public static boolean checkStable(String[] stableAns, String[] checkArr) {
    for (int i = 0; i < stableAns.length; i++) {
      if (!stableAns[i].equals(checkArr[i])) {
        System.out.println("Not stable");
        return false;
      }
    }
    System.out.println("Stable");
    return true;
  }
}



Measured memory_bytes: 26448
# include <cmath>
# include <iostream>
# include <vector>


using namespace std;


int n, m;

vector<int> q;
vector<int> p;
vector<vector<int>> ss;


bool valid(int query) {
    fill(q.begin(), q.end(), 0);

    for (int i=0; i<n; i++) {
        // whether i'th switch is pushed
        if (!(query>>i & 1)) continue;

        // i'th switch is pushed.
        // then which lights are incremented?
        for (int j=0; j<m; j++) {
            if (find(ss.at(i).begin(), ss[i].end(), j) != ss[i].end()) {
                q[j]++;
            }
        }
    }

    int cnt = 0;
    for (int i=0; i<m; i++) {
        if (q[i] % 2 == p[i]) cnt++;
    }
    return cnt == m;
}


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

    int k, v;
    ss.resize(n);
    for (int i=0; i<m; i++) {
        cin >> k;

        for (int j=0; j<k; j++) {
            cin >> v; v--;
            ss[v].push_back(i);
        }
    }

    q.resize(m);
    p.resize(m);
    for (int i=0; i<m; i++) cin >> p[i];

    int ans = 0;
    for (int i=0; i<(int)pow(2, n); i++) {
        if (valid(i)) ans++;
    }

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll d, t, s;
    cin >> d >> t >> s;
    if(s * t >= d)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3648
using System;

class Program
{
  static void Main(string[] args)
  {
    var input = new Input();
    if (input.C >= input.A && input.C <= input.B)
    {
      Console.WriteLine("Yes");
    }
    else
    {
      Console.WriteLine("No");
    }
  }
}

class Input
{
  public int A { get; set; }
  public int B { get; set; }
  public int C { get; set; }

  public Input()
  {
    var line = Console.ReadLine().Split(" ");
    this.A = int.Parse(line[0]);
    this.B = int.Parse(line[1]);
    this.C = int.Parse(line[2]);
  }
}


Measured memory_bytes: 27444
serch_table = []

for i in range(100):
    for j in range(1,1000):
        x = str(j) + '9'*i
        x = int(x)
        serch_table.append(x)
#print(serch_table)

L = []
for i in serch_table:
    l = [x for x in str(i)]
    x = sum(map(int,l))
    l = [i/x,i]
    L.append(l)
L= sorted(L)
M = []
tmp = -1
for i in L:
    if tmp < i[1]:
        M.append(i[1])
        tmp = i[1]
#print(M,len(serch_table ))
N = int(input())
for i in range(N):
    print(M[i])


Measured memory_bytes: 22268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
///////////////////////////////////////


int N;
vector<pii>g[100100];
int ans[100100];
bool seen[100100];
void dfs(int v,int p) {
	if (seen[v])return;
	ans[v] = p;
	seen[v] = true;
	for (auto x : g[v]) {
		if (x.second % 2 == 0) {
			dfs(x.first, p);
		}
		else {
			dfs(x.first, 1 - p);
		}
	}
}
int main() {
	cin >> N;
	REP(i, N-1) {
		int u, v, w;
		cin >> u >> v >> w;
		u--, v--;
		g[u].push_back({ v,w });
		g[v].push_back({ u,w });
		seen[i] = false;
	}
	dfs(0,0);
	REP(i, N) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 8448
N = gets.to_i
x = N.times.map{gets.split.map(&:to_i)}

hash = Hash.new

N.times do |i|
    N.times do |j|
        next if i==j
        new_x = x[i][0] - x[j][0]
        new_y = x[i][1] - x[j][1]
        hash["#{new_x},#{new_y}"]||=0
        hash["#{new_x},#{new_y}"]+=1
    end
end

puts N-(hash.values.max||0)

Measured memory_bytes: 2172
{-# LANGUAGE MultiWayIf, BangPatterns #-}
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  !al <- replicateM h $ map (== '#') <$> getLine
  let
    red = do
      i <- [1..h]
      return $ flip map [1..w] $ \j -> if
        | j == 1 -> True
        | j == w -> False
        | odd i  -> True
        | otherwise -> False
    blue = flip map red $ map not
    po c = zipWith (zipWith (||)) c al
    showColor = map (\b -> if b then '#' else '.')
  putStrLn $ unlines $ map showColor (po red)
  putStrLn $ unlines $ map showColor (po blue)


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B  > C + D) {
    cout << "Left" << endl;
  } else if (A + B == C + D) {
    cout << "Balanced" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
w=list(list(input()) for i in range(n))
f=True
c=0
for i in range(n):
    for j in range(n):
        if w[i]==w[j]:
            c+=1
    if (i!=n-1 and w[i+1][0]!=w[i][-1]) or c>n:
        f=False
if f:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W, K;
int X1, Y1, X2, Y2;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

int main(){
  scanf("%d%d%d", &H, &W, &K);
  scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
  X1--; Y1--; X2--; Y2--;

  char C[H][W]; int Dist[H][W];
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> C[i][j];
      Dist[i][j] = 1e9;
    }
  }

  queue <Pii> que; que.push({X1, Y1});
  Dist[X1][Y1] = 0;
  while (!que.empty()){
    Pii Q = que.front(); que.pop();
    for (int l = 0; l < 4; l++){
      for (int k = 1; k <= K; k++){
        int I = Q.fi + di[l] * k;
        int J = Q.se + dj[l] * k;
        if (I < 0 || H <= I || J < 0 || W <= J) break;
        if (C[I][J] == '@') break;
        if (Dist[Q.fi][Q.se] >= Dist[I][J]) break;
        
        if (Dist[I][J] > Dist[Q.fi][Q.se] + 1){
          Dist[I][J] = Dist[Q.fi][Q.se] + 1;
          que.push({I, J});
        }
      }
    }
  }

  if (Dist[X2][Y2] == 1e9) Dist[X2][Y2] = -1;
  cout << Dist[X2][Y2] << endl;

  return 0;
}


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, ans;
  cin >> s;
  for (char c : s) {
    if (c == '0') {
      ans += '0';
    } else if (c == '1') {
      ans += '1';
    } else if (ans != "") {
      ans.pop_back();
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S ;
    string str = S;
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    S[K-1] = str[K-1];
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define all(x) x.begin(), x.end()

int binpow(int a, int b)
{
    int ans = 1;
    if (b == 0)
        return 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n, x, t;
        cin >> n >> x >> t;
        int di = n / x;
        if (n % x != 0)
            di++;
        cout << di * t << "\n";
    }
}


Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  double n;
  cin>>n;
  vector<double>a(n);
  rep(i,n) cin>>a[i];
  vector<double>b(n);
  rep(i,n) b[i]=1/a[i];
  double sum=0;
  rep(i,n) sum+=b[i];
  double ans=1/sum;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int r;
	char s[105];
	bool ok=1;
	scanf("%d",&r);
	scanf("%s",s);
	if(r&1)ok=0;
	else
	{
		r/=2;
		for(int i=0;i<r&&ok;++i)
		if(s[i]!=s[i+r])ok=0;
	}
	puts(ok?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - y2 + y1
y3 = x2 + y2 - x1
x4 = x1 + y1 - y2
y4 = x2 - x1 + y1
print(x3, y3, x4, y4)

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long, long>;
using pdd = pair<ld, ld>;

template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<ll>;
V(size_t) -> V<ll>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll D, T, S;
    cin >> D >> T >> S;

    cout << (T*S>=D ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll X,ans,tmp;
	std::cin >> X;

	ans = (X / 500 )*1000;
	X %= 500;
	ans += (X / 5) * 5;
	std::cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        cnt = 0
        for k in a[i:i+m]:
            if not k[j:j+m]==b[cnt]:
                break
            cnt += 1
        else:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    class Logger
    {
    private:
        bool isEnable;

    public:
        Logger(bool isEnable = true) : isEnable(isEnable) {}

        template<class T>
        Logger& operator<<(const T& val)
        {
            if(isEnable)
            {
                std::cout << val;
            }
            return *this;
        }

        void set_enable()
        {
            isEnable = true;
        }

        void set_disable()
        {
            isEnable = false;
        }

        void endl()
        {
            if(isEnable)
            {
                std::cout << std::endl;
            }
        }
    };

    Logger logger;

    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

int n;
vector<string> domino(2);
const int MOD = 1000000007;

int solve(int x)
{
    if(x == n) return 1;

    int res;
    if(domino[0][x] == domino[1][x])
    {
        if(domino[0][x - 1] == domino[1][x - 1])
        {
            res = solve(x + 1) * 2;
        }
        else
        {
            res = solve(x + 1);
        }
    }
    else
    {
        if(domino[0][x - 1] == domino[1][x - 1])
        {
            res = solve(x + 2) * 2;
        }
        else
        {
            res = solve(x + 2) * 3;
        }
    }

    return res % MOD;
}

signed main()
{
    cin >> n;

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

    int res;
    if(domino[0][0] == domino[1][0])
    {
        res = solve(1) * 3;
    }
    else
    {
        res = solve(2) * 6;
    }

    cout << res % MOD << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int N=100000+10;
char s[N];
int n;
int main() {
    scanf("%s",s+1);
    n=strlen(s+1);
    int ans=n;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i+1]){
            ans=min(ans,max(i,n-i));
        }
    }
    cout<<ans<<endl;
}

/*
 x x+1
*/

Measured memory_bytes: 384
N,K=map(int,input().split())
b=[] #[[種類,美味しさ],...]
 
for _ in range(N):
    t,d=map(int,input().split())
    b.append([t,d])
b.sort(key=lambda x:-x[1])
 
f=[0]*(N+1)
x=0
point=0
 
for [t,d] in b[:K]:
    if f[t]==0: x+=1
    f[t]+=1
    point+=d
maxpoint=point+x*x
 
h=K-1
for [t,d] in b[K:]:
    if f[t]==0:
        f[t]=1
        x+=1
        point+=d
        for i in range(h,-2,-1):
            if i==-1:
                print(maxpoint)
                exit()
            t=b[i][0]
            d=b[i][1]
            if f[t]>1:
                f[t]-=1
                point-=d
                h = i-1
                break
        maxpoint=max(maxpoint,point+x*x)
print(maxpoint)

Measured memory_bytes: 24556