akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	string sa;
	getline(cin, sa);
	int z = sa.size();
	for (int i = 0; i < z - 4; i++) {
		string sb = sa.substr(i, 5);
		if (sb == "apple") {
			sa.replace(i, 5, "peach");
		}
		if (sb == "peach") {
			sa.replace(i,5, "apple");
		}
	}
	cout << sa << endl;
	return 0;
}

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


ll N, K;
vector<ll> A;
vector<ll> ml, pl;


void input() {
    cin >> N >> K;
    A = vector<ll>(N);
    rep(i, N) cin >> A[i];
}


ll solve1() {
    ll l = -1e18, r = 0;
    l--;
    while (r - l > 1) {
        ll c = (l + r) / 2;
        ll n = 0;
        for (ll x : ml) {
            ll y = c / x;
            if (c % x != 0) y++;
            auto itr = lower_bound(pl.begin(), pl.end(), y);
            n += pl.size() - distance(pl.begin(), itr);
        }
        if (K <= n) r = c;
        else l = c;
    }
    return r;
}


ll solve2() {
    ll l = 0, r = 1e18;
    while (r - l > 1) {
        ll c = (l + r) / 2;
        ll n = 0;
        for (ll x : ml) {
            ll y = c / x;
            auto itr = lower_bound(ml.begin(), ml.end(), y);
            n += ml.size() - distance(ml.begin(), itr);
            if (y <= x) n--;
        }
        for (ll x : pl) {
            ll y = c / x;
            auto itr = upper_bound(pl.begin(), pl.end(), y);
            n += distance(pl.begin(), itr);
            if (x <= y) n--;
        }
        n /= 2;
        if (K <= n) r = c;
        else l = c;
    }
    return r;
}


int main() {
    input();
    int z = 0;
    rep(i, N) {
        if (A[i] < 0) ml.push_back(A[i]);
        else if (0 < A[i]) pl.push_back(A[i]);
        else z++;
    }
    sort(ml.begin(), ml.end());
    sort(pl.begin(), pl.end());
    ll mn = ml.size() * pl.size();
    ll zn = 0;
    for (int i = 1; i <= z; i++) zn += N - i;
    ll ans;
    if (K <= mn) ans = solve1();
    else if (K <= mn + zn) ans = 0;
    else {
        K -= mn + zn;
        ans = solve2();
    }
    cout << ans << endl;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;


int32_t main(){
    ll n,x;
    cin >> n >> x;
    ll ans=1;
    ll p=0;
    for (int i=0;i<n;i++){
        ll d;
        cin >> d;
        p+=d;
        if (p<=x){
            ans++;
        }
    }
    cout << ans;
}


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

typedef long long ll;

typedef pair<int, int> p;


long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll n; 
    cin >> n;

    ll mod = pow(10, 9) + 7;

    ll posf, posb;

    vector<int> a(n + 1, -1);

    for(ll i = 0; i < n + 1; i++) {
        int b;
        cin >> b;
        if(a[b] != -1) {
            posf = a[b];
            posb = i;
        } else
            a[b] = i;
    }

    ll l = n - posb + posf;

    cerr << l << endl;

    vector<ll> ans(n + 1);

    ll base = n + 1;

    for(ll i = 0; i < n + 1; i++) {
        ans[i] = base;
        base *= n - i;
        base %= mod;
        base *= modpow(i + 2, mod - 2, mod);
        base %= mod;
    }

    vector<ll> m(l + 1);

    base = 1LL;

    for(ll i = 0; i <= l; i++) {
        m[i] = base;
        base *= l - i;
        base %= mod;
        base *= modpow(i + 1, mod - 2, mod);
        base %= mod;
    }

    for(ll i = 0; i <= l; i++) {
        ans[i] -= m[i];
        ans[i] += mod;
        ans[i] %= mod;
    }

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

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	int n;
	cin >> n;
	map<string, int> cnt;
	string s;
	loop(n) {
		cin >> s;
		cnt[s]++;
	}
	vector<string> ord = {"AC", "WA", "TLE", "RE"};
	each(s, ord) {
		cout << s << " x " << cnt[s] << endl;
	}
	return 0;
}



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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll L[2010];
ll ans;
vector<ll> v;
int main(){
	cin >> N;
	REP(i,0,N) cin >> L[i];
	sort(L, L+N);
	REP(a,0,N){
		REP(b,a+1,N){
//			p2(L[a], L[b]);
//			p(lower_bound(L, L+N, L[a] + L[b]) - upper_bound(L, L+N, L[b]));
			ll n = lower_bound(L, L+N, L[a] + L[b]) - L - max<ll>(b+1, lower_bound(L, L+N, L[b]) - L);
			ans += max(0LL, n);
		}
	}
	p(ans);
	return 0;
}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}
int s[100005];
int t;
int n;
int q;

int my_bsearch(int key){
    int left, right, mid;
    left = 0;
    right = n;
    while (left < right){
        mid = (left+right)/2;
        if (s[mid] == key){
            return mid;
        }else if(s[mid] < key){
            left = mid + 1;
        }else if(s[mid] > key){
            right = mid;
        }
    }
    return -1;
}

int main(void){
    int cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &s[i]);
    }
    qsort(s, n, sizeof(int), ascending_compare);
    scanf("%d", &q);
    for (int i = 0; i < q; i++){
        scanf("%d", &t);
        if (my_bsearch(t) != -1){
            cnt++;
        }
    }

    printf("%d\n", cnt);
    return 0;
    
    

}


Measured memory_bytes: 2196
n = input()

l = list( map(int, input().split()))

odd = [ c for c in l if (c % 2 == 0 ) and (( c % 3 != 0) and ( c % 5 !=0 ))]
if len( odd ) == 0: 
  print( "APPROVED" )
else:
  print( "DENIED" )

Measured memory_bytes: 9072
#include <cstdio>
#include <climits>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long LL;

int dp[101][303] = {0};
int w[101];
int v[101];

int main()
{
    int N, W;
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
        cin >> w[i] >> v[i];
    int dvd = W / w[0];
    int rmd = W % w[0];
    for (int i = 0; i < N; ++i)
    {
        int rest = w[i] - w[0];
        for (int k = dvd; k >= 1; --k)
        {
            for (int b = 300; b >= rest; --b)
            {
                dp[k][b] = max(dp[k][b], dp[k - 1][b - rest] + v[i]);
            }
        }
    }
    int res = 0;
    for (int i = 0; i <= dvd; ++i)
        for (int j = 0; j <= 300; ++j)
            if (i * w[0] + j <= W)
                res = max(res, dp[i][j]);
    cout << res << endl;
    
    return 0;
};

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define MP make_pair
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double PI = acos(-1);
const double EPS = 1e-9;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

///////////////////////////////////////////////////////

int n,m;
bool flag[15];

bool check(int x){
	while(x > 0){
		if(flag[x % 10]) return false;
		x /= 10;
	}
	return true;
}

int solve(){
	while(!check(n)) n++;
	return n;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	int x;
	FOR(i,m){
		cin >> x;
		flag[x] = true;
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

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

int main() {
  char b;
  cin >> b;
  if (b == 'A') {
    cout << 'T' << endl;
  }
  else if (b == 'T') {
    cout << 'A' << endl;
  }
  else if (b == 'C') {
    cout << 'G' << endl;
  }
  else {
    cout << 'C' << endl;
  }
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


int main()
{
	int n, d, ans;

	cin >> n >> d;
	
	if(n % (d * 2 + 1) == 0)
		cout << n / (d * 2 + 1) << endl;
	else
		cout << n / (d * 2 + 1) + 1 << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int main() {
	llong x;
	cin >> x;

	llong x500 = x / 500;
	x = x % 500;
	llong ans = x500 * 1000 + x / 5 * 5;
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

int main(){
  int A, B, C, D;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  int takahashi_win_count = (C+B-1)/B;
  int aoki_win_count = (A+D-1)/D;
  if (takahashi_win_count<=aoki_win_count){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    //  Fast_IO();
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll turn = 1;
    string ans;
    while(1) {
    	if(turn) {
    		c -= b;
    		if(c <= 0) {
    			ans = "Yes";
    			break;
    		}
    	}
    	else {
    		a -= d;
    		if(a <= 0) {
    			ans = "No";
    			break;
    		}
    	}
    	turn ^= 1;
    }
    cout << ans;
    return 0;
}

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

typedef long long ll;

ll mod=1000000000+7;


int main(void){
    int M1, M2, D1, D2;

    scanf("%d %d",&M1, &D1);
    scanf("%d %d",&M2, &D2);
    printf("%d", M1!=M2 ? 1:0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n, r;
	while (std::cin >> n >> r) {
		std::queue<int> a, b, c;
		for (auto i = 0; i < n; ++i) {
			c.push(i);
		}
		for (auto _i = 0; _i < r; ++_i) {
			int count; std::cin >> count;
			for (auto i = 0; i < n / 2; ++i) {
				b.push(c.front());
				c.pop();
			}
			for (auto i = n / 2; i < n; ++i) {
				a.push(c.front());
				c.pop();
			}
			while (!a.empty() || !b.empty()) {
				for (auto i = 0; i < count && !a.empty(); ++i) {
					c.push(a.front());
					a.pop();
				}
				for (auto i = 0; i < count && !b.empty(); ++i) {
					c.push(b.front());
					b.pop();
				}
			}
		}
		std::cout << c.back() << '\n';
	}
}


Measured memory_bytes: 3120
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        BigDecimal A = new BigDecimal(scanner.next());
        BigDecimal B = new BigDecimal(scanner.next());

        System.out.println(A.multiply(B).longValue());
    }

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


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int n, m, k;
	cin >> n >> m >> k;

	bool flag = false;
	rep(i, m + 1) {
		rep(j, n + 1) {
			if (n * i + m * j - i * j * 2 == k) {
				flag = true;
			}
		}
	}

	cout << (flag ? "Yes" : "No") << endl;
}



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

	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ string s;
long long d,sum=0,num;
cin>>s;
long long n=s.size();
for(int i=0 ; i<n ; i++){
     d = s[i] - '0';
    num = num * 10 + d;
sum+=d;
}
if(num%(sum)==0) cout<< "Yes"<<  endl;
if(num%(sum)!=0) cout<< "No"<<  endl;

return 0;

}


Measured memory_bytes: 3608
#include <stdio.h>
int main() {
int i,N,v,k,j;
int A[100];
scanf("%d",&N);
for(i=0;i<N;i++) {
scanf("%d",&A[i]);
}
 for(i=0;i<N-1;i++){
   printf("%d ",A[i]);
 }
 printf("%d\n",A[N-1]);
for(i=1;i<=N-1;i++){
v=A[i];
j=i-1;
while(j>=0&&A[j]>v){
A[j+1]=A[j];
j--;
A[j+1]=v;
}
for(k=0;k<N-1;k++){
printf("%d ",A[k]);
}
 printf("%d\n",A[N-1]);
}
return 0;
}




Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
long long num[10][10];
int main() {
    int N;
    cin >> N;
    for (int i=1; i<=N; i++){
        int first = i;
        for ( ; first > 9; first /= 10);
        num[first][i%10]++;
    }
    long long ans = 0;
    for (int i=1; i<=9; i++){
        for (int j=0; j<=9; j++){
            ans += num[i][j] * num[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc173/tasks/abc173_a
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n;
	cin>>n;
	long long ans = n%1000;
	if (0==ans) {
		ans=0;
	} else {
		ans = 1000-ans;
	}
	cout<<ans<<endl;
	
	return 0;
}


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


// type {{{

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;

// }}}


// macro {{{

#define rep(i,n) for (ll i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i,n) for (ll i=1, i##_len=(n); i<=i##_len; ++i)

#define SZ(x) ((ll)(x).size())

#define all(x) begin(x),end(x)

// }}}


// debug {{{

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    rep (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "(" << p.first << " " << p.second << ")";
}

// }}}


// chmax, chmin {{{

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

// }}}



// constants {{{

#define inf(T) numeric_limits<T>::max()

const ll MOD = 1e9+7;
const ld EPS = 1e-9;

// }}}


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

    ll n; cin >> n;
    int ans = 0;
    while (n > 1) {
        n = (n-1) / 3 + 1;
        ++ans;
    }
    cout << ans << endl;

    return 0;
}



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

int main(void){
	int D;
	cin >> D;
	int c[26];
	int s[D][26];
	rep(i,26) cin >> c[i];
	rep(i,D) rep(j,26) cin >> s[i][j];

	int t[D];
	rep(i,D){
		int max_s = s[i][0];
		int jmax = 0;
		rep(j,26){
			if (s[i][j]>=max_s){
				max_s = s[i][j];
				jmax =j;
			}
		}
		t[i] = 1;
	}
	rep(i,D) cout << t[i] << endl;
	


return 0;
}


Measured memory_bytes: 3684
while True:
    a, b, c = input().split()
    a = int(a)
    c = int(c)
    if b == "?":
        break
    elif b == "-":
        d = a - c
    elif b == "+":
        d = a + c
    elif b == "*":
        d = a * c
    elif b == "/":
        d = a // c
    print(d)

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

void solve()
{
    int n;
    cin>>n;
    int a,b,c;
    cin>>a>>b>>c;
    int dp[n+5][4];
    dp[0][0]=a;
    dp[0][1]=b;
    dp[0][2]=c;
    for(int i=1;i<n;i++)
    {
        cin>>a>>b>>c;
        dp[i][0] = a + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c + max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll n,i,j;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll ans=0;
    for(i=1;i<n-1;i++)
    {
        if(  (arr[i]>arr[i-1] && arr[i]<arr[i+1] ) || (arr[i]<arr[i-1] && arr[i]>arr[i+1]) )
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d;
        if (a > b) {
            // a(=X) と b(=Y)　を交換
            d = a;
            a = b;
            b = d;
        }
        if (b > c) {
            // b と c　を交換
            d = b;
            b = c;
            c = d;
        }
        if (a > b) {
            // a と b　を交換
            d = a;
            a = b;
            b = d;
        }
        System.out.println(a + " " + b + " " + c);
    }
}



Measured memory_bytes: 26248
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

#define INF 9e18
#define MAX_E 5000
#define MAX_V 2500

struct edge
{
  int from;
  int to;
  int cost;
};

vector<ll> bellmanford(vector<edge> &edges, int V, int s, set<int> &path)
{
  vector<ll> dist(V, INF);
  dist[s] = 0;
  
  REP(i,V){
    for(auto e: edges){
      if(dist[e.from]==INF) continue;
      if(dist[e.to]>dist[e.from]+e.cost){
        dist[e.to] = dist[e.from]+e.cost;
      }
    }
  }
  
  for(auto e: edges){
    if(dist[e.from]==INF) continue;
    if(path.count(e.from)==0 || path.count(e.to)==0) continue;
    if(dist[e.from]+e.cost<dist[e.to]) return vector<ll>();
  }
  return dist;
}

set<int> bfs(vector<vector<int>> &G, int V, int s)
{
  set<int> seen;
  seen.insert(s);
  queue<int> que;
  que.push(s);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(auto nv: G[v]){
      if(seen.count(nv)) continue;
      seen.insert(nv);
      que.push(nv);
    }
  }
  return seen;
}     

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int V,E,P;
  cin >> V >> E >> P;
  vector<edge> edges(E);
  vector<vector<int>> G(V), Grev(V);
  REP(i,E){
    int a,b,c;
    cin >> a >> b >> c;
    a--, b--, c-=P;
    edges[i] = edge{a,b,-c};
    if(a!=b){
      G[a].push_back(b);
      Grev[b].push_back(a);
    }
  }
  
  auto path1 = bfs(G, V, 0);
  auto path2 = bfs(Grev, V, V-1);
  set<int> path;
  for(auto p: path2){
    if(path1.count(p)){ 
      path.insert(p);
    }
  }
  
  auto dists = bellmanford(edges, V, 0, path);
  if(dists.empty() || dists[V-1]==INF) cout << "-1\n"; 
  else cout << max(-dists[V-1], 0LL) << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

#define MODN 1000000007

#define modadd(lhs,rhs) (((lhs)+(rhs)) % MODN)

#define modml(lhs,rhs) ((long)((long long)(lhs)*(rhs)%MODN))

static inline long modpow(long num,long ind){
    unsigned long cnt = ind;
    long res = 1;
    while(cnt){
        if(cnt & 1ul)res = modml(res,num);
        num = modml(num,num);
        cnt >>= 1;
    }
    return res;
}

long fact[5050];
long fact_inv[5050];

static inline long modncr(long n,long r){
    return modml(modml(fact[n],fact_inv[n-r]),fact_inv[r]);
}

int s;

static inline long seqs_num(int len){
    if(s < 3*len)return 0;
    return modncr((s-3*len)+len-1,len-1);
}

int main(void){
    register int i;
    long ans = 0;
    fact[0] = 1;
    for(i = 1;i < 5050;i++)fact[i] = modml(fact[i-1],i);
    for(i = 0;i < 5050;i++)fact_inv[i] = modpow(fact[i],MODN-2);
    scanf("%d",&s);
    for(i = 1;i < s;i++)ans = modadd(ans,seqs_num(i));
    printf("%ld",ans);
}

Measured memory_bytes: 1784
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())


res = n//k

ans = min(abs(n-(res*k)),abs(n-((res+1)*k)))

print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 3005, mod = 1e9+7;

ll n, m, o[N], b[N], dt[N][N];
char a[N];

int main()
{
	scanf("%lld%lld%s",&n,&m,a+1);
	for(ll i=1;i<=n;i++) {
		o[i] = o[i-1] + (a[i] == '1');
	}
	iota(b, b+n+1, 0);
	for(ll i=1;i<=m;i++) {
		ll S, E;
		scanf("%lld%lld",&S,&E);
		for(ll i=S;i<=E;i++) b[i] = max(b[i], E);
	}
	dt[0][0] = 1;
	for(ll i=1;i<=n;i++) for(ll j=0;j<=i;j++) {
		if(j > o[b[i]] || i-j > b[i]-o[b[i]]) continue;
		dt[i][j] = dt[i-1][j];
		if(j) dt[i][j] = (dt[i][j] + dt[i-1][j-1]) % mod;
	}
	printf("%lld\n",dt[n][o[n]]);
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    ll cnt = 0, ans = INF;
    REP(i, LEN(s)-LEN(t)+1){
        cnt = 0;
        REP(j, LEN(t)){
            if(s[i+j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans;
    return 0;
}

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

int main() {
    char X, Y;
    cin >> X >> Y;
    if (X < Y) {
        cout << "<" << endl;
    } else if (X > Y) {
        cout << ">" << endl;
    } else {
        cout << "=" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    string S; cin >> S;
    if(S == "KIHBR" || S == "AKIHBR" || S == "KIHABR" || S == "KIHBAR" || S == "KIHBRA" || S == "AKIHABR" || S == "AKIHBAR" || S == "AKIHBRA" || S == "KIHABAR" || S == "KIHABRA" || S == "KIHBARA" || S == "AKIHABAR" || S == "AKIHABRA" || S == "AKIHBARA" || S == "KIHABARA" || S == "AKIHABARA"){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
   
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

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

    void solve() {
        Scanner scanner = new Scanner(System.in);
        final int N = scanner.nextInt();
        HashSet<Integer> m = new HashSet<>();
        for (int i = 0; i < N; i++) {
            int d = scanner.nextInt();
            m.add(d);
        }
        System.out.println(m.size());
    }
}

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

int main(){
  string s; cin >> s;
  string g; g = s;
  reverse(g.begin(), g.end());
  int b, e;
  rep(i,s.size()) 
    if(s[i] == 'A'){
      b = i;
      break;
    }
  rep(i,g.size()) 
    if(g[i] == 'Z'){
      e = g.size()-i;
      break;
    }
  cout << e-b;
  return 0;
}

Measured memory_bytes: 772
#include<iostream>
#include<algorithm>
#include<vector>
#include <string.h>
#include <stdio.h>
#include <map>
using namespace std;

struct P{ 
string s;
int x;
};

int main(){
    int N;
    cin>>N;
    string s;
    int a;
    long long ans=0;
    map<string, long long> m;
    for(int i=0;i<N;i++){
        cin>>s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    for(auto n : m){
        ans+=(n.second*(n.second-1))/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll cnt=0;
	REP(i,6) {
		if(s[i]=='1') ++cnt;
	}
	cout<<cnt<<endl;
}

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

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

    int a, b;
    cin >> a >> b;
    if (a == 1 && b == 2) {
        cout << '3';
    }
    if (a == 1 && b == 3) {
        cout << '2';
    }
    if (a == 2 && b == 1) {
        cout << '3';
    }
    if (a == 2 && b == 3) {
        cout << '1';
    }
    if (a == 3 && b == 1) {
        cout << '2';
    }
    if (a == 3 && b == 2) {
        cout << '1';
    }
}

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

int main(void){
    char clima[20];
    scanf("%s", clima);

    if(strcmp(clima, "Sunny") == 0){
        printf("Cloudy\n");
    } else if (strcmp(clima, "Cloudy") == 0) {
        printf("Rainy\n");
    } else {
        printf("Sunny\n");
    }

    return 0;
}

Measured memory_bytes: 128
/*

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

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    int n,m,k;
	cin>>n>>m>>k;
	int s1=0,s2=0;
	rep(i,n){
		(s1+=i*(i+1)/2%MOD*m%MOD)%=MOD;
		(s1+=(n-i)*(n-i-1)/2%MOD*m%MOD)%=MOD;
	}
	rep(i,m){
		(s2+=i*(i+1)/2%MOD*n%MOD)%=MOD;
		(s2+=(m-i)*(m-i-1)/2%MOD*n%MOD)%=MOD;
	}
	(s1*=powmod(n*(n*m-1)%MOD,MOD-2,MOD))%=MOD;
	(s2*=powmod(m*(n*m-1)%MOD,MOD-2,MOD))%=MOD;
	int out=(s1+s2)%MOD*k%MOD*(k-1)%MOD*nCr(n*m,k)%MOD*powmod(2,MOD-2,MOD)%MOD;
	cout<<out<<endl;
}


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

int main(){
  int n,key,num[1000]={0};
  while( cin >> n,n ){
    for(int i = 0 ; i < n ; i++ ){
      cin >> num[i];
    }
    cin >> key;
    sort(num,num+n);
    int r = n-1;
    int l = 0;
    int cnt = 0;
    while(l <= r){
      int c = (r + l)/2;
      cnt++; 
      if(num[c] == key){break;}
      else if(num[c] < key){l = c+1;}
      else {r = c-1;}
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007

template<int mod>
struct ModInt{
	int x;
	ModInt():x(0){}
	ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator-()const{return ModInt(-x);}
	ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
	ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
	ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
	ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
	bool operator==(const ModInt &p)const{return x==p.x;}
	bool operator!=(const ModInt &p)const{return x!=p.x;}
	explicit operator int() const { return x; }						   // added by QCFium
	ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
	ModInt inverse()const{
		int a=x,b=mod,u=1,v=0,t;
		while(b>0){
			t=a/b;
			a-=t*b;
			std::swap(a,b);
			u-=t*v;
			std::swap(u,v);
		}
		return ModInt(u);
	}
	friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
		return os<<p.x;
	}
	friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
		long long x;
		is>>x;
		a=ModInt<mod>(x);
		return (is);
	}
};
typedef ModInt<MOD> mint;

struct MComb {
	std::vector<mint> fact;
	std::vector<mint> inv;
	MComb (int n) { // O(n + log(mod))
		fact = std::vector<mint>(n + 1, 1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * mint(i);
		inv.resize(n + 1);
		inv[n] = fact[n] ^ (MOD - 2);
		for (int i = n; i--; ) inv[i] = inv[i + 1] * mint(i + 1);
	}
	mint ncr(int n, int r) {
		return fact[n] * inv[r] * inv[n - r];
	}
	mint npr(int n, int r) {
		return fact[n] * inv[n - r];
	}
	mint nhr(int n, int r) {
		assert(n + r - 1 < (int) fact.size());
		return ncr(n + r - 1, r);
	}
};


int main() {
	int n = ri();
	int m = ri();
	mint dp[n + 1][m + 1];
	// dp[n][m] : result
	for (int i = 0; i <= m; i++) dp[0][i] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = 1;
		mint cur = 0;
		for (int j = 1; j <= m; j++) {
			// 000...111
			dp[i][j] += dp[i - 1][j] * (j + 1);
			if (j >= 2) {
				cur *= 2;
				cur += dp[i - 1][j - 1] * (j - 1);
			}
			dp[i][j] += cur;
		}
	}
	std::cout << dp[n][m] << std::endl;
	return 0;
}


Measured memory_bytes: 101324
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
int main(void) {
  int a, b;
  cin>>a>>b;
  string s=(a%3==0 or b%3==0 or (a+b)%3==0)?"Possible":"Impossible";
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[3]:


import math
from functools import reduce


# In[9]:


N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))


# In[10]:


def lcm_base(x,y):
    return (x*y)//math.gcd(x,y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


# In[11]:


print(lcm_list(T))


# In[ ]:






Measured memory_bytes: 85576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    ll sum = 0;
    rep(i, 0, n){
        cin >> h[i];
        sum += h[i];
    }
    ll l = 0, r = 1e9;
    while(r - l > 1) {
        ll m = l + (r - l) / 2;
        ll cnt = 0;
        rep(i, 0, n){
            cnt += max(0LL, (h[i] - b*m + (a-b) - 1) / (a-b));
        }
        if(cnt <= m) r = m;
        else l = m;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4008
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
struct edge { int to, cost; };

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int 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;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

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

    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int main()
{
	int x;
	cin>>x;
	if(x==0)
	{
		cout<<1;
		return 0;
	}
	else if(x==1)
	{
		cout<<0;
		return 0;
	} 
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, int, int, int> T;
typedef tuple<int, int, int> T2;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int x, y, z, k; cin>>x>>y>>z>>k;
    vector<ll> a(x), b(y), c(z);
    for(int i=0; i<x; i++) cin>>a[i];
    for(int i=0; i<y; i++) cin>>b[i];
    for(int i=0; i<z; i++) cin>>c[i];

    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());

    priority_queue<T> que;
    que.push(T(a[0] + b[0] + c[0], 0, 0, 0));

    vector<ll> ans;
    map<T2, bool> visited;
    for(int i=0; i<k; i++){
        ll sum;
        int ai, bi, ci;
        tie(sum, ai, bi, ci) = que.top();
        que.pop();

        ans.eb(sum);

        if(ai + 1 < x && !visited[T2(ai+1, bi, ci)]){
            que.push(T(a[ai+1] + b[bi] + c[ci], ai+1, bi, ci));
            visited[T2(ai+1, bi, ci)] = true;
        }

        if(bi + 1 < y && !visited[T2(ai, bi+1, ci)]){
            que.push(T(a[ai] + b[bi+1] + c[ci], ai, bi+1, ci));
            visited[T2(ai, bi+1, ci)] = true;
        }
        
        if(ci + 1 < z && !visited[T2(ai, bi, ci+1)]){
            que.push(T(a[ai] + b[bi] + c[ci+1], ai, bi, ci+1));
            visited[T2(ai, bi, ci+1)] = true;
        }
    }

    for(auto i:ans){
        cout << i << endl;
    }
}

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

int main() {
    int A,B,H,M;
    cin>>A>>B>>H>>M;
    double h = H + M/60.0;
    double deg =abs((h/12.0*360 - (M%60)/60.0*360.0) * M_PI / 180.0);
    //cout <<fixed << setprecision(10)<<deg<<endl;
    double c = sqrt(A*A + B*B - 2*A*B*cos(deg));

    cout << fixed << setprecision(10) << c << endl;
}



Measured memory_bytes: 4164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif


template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

typedef long long int ll;

void solve(int n,int m,int c,int s,int g){
  --s;
  --g;
  ll inf=1L<<60;
  ll dist1[100][100][20];
  fill_n((ll*)dist1,100*100*20,inf);
  rep(i,0,n) rep(j,0,c) dist1[i][i][j]=0;
  vector<int> xs,ys,ds,cs;
  rep(i,0,m){
    int x,y,cc;
    ll d;
    cin >> x >> y >> d >> cc;
    --x;
    --y;
    --cc;
    dist1[x][y][cc]=dist1[y][x][cc]=min(dist1[x][y][cc],d);
  }
  rep(l,0,c) rep(k,0,n) rep(i,0,n) rep(j,0,n){
    dist1[i][j][l]=min(dist1[i][j][l],dist1[i][k][l]+dist1[k][j][l]);
  }

  vector<int> p(c);
  vector<vector<ll>> q(c),r(c);
  rep(i,0,c) cin >> p[i];
  rep(i,0,c){
    q[i].resize(p[i]+1);
    r[i].resize(p[i]+1);
    q[i].back()=inf;
    rep(j,1,p[i]) cin >> q[i][j];
    rep(j,1,p[i]+1) cin >> r[i][j];
  }

  ll dist2[100][100];
  fill_n((ll*)dist2,100*100,inf);
  rep(i,0,n) dist2[i][i]=0;

  auto f=[&](int j,ll z,int k){
    ll sum = 0;
    rep(i,1,k) sum += r[j][i] * (q[j][i]-q[j][i-1]);
    sum += r[j][k]*(z-q[j][k-1]);
    return sum;
  };
  rep(i,0,n) rep(j,0,n) rep(ii,0,c){
    ll z=dist1[i][j][ii],k;
    if(z==inf) continue;
    rep(l,1,p[ii]+1){
      if(q[ii][l]>=z){
        k=l;
        break;
      }
    }
    dist2[i][j]=min(dist2[i][j],f(ii,z,k));
  }

  rep(k,0,n) rep(i,0,n) rep(j,0,n){
    dist2[i][j]=min(dist2[i][j],dist2[i][k]+dist2[k][j]);
  }
  if(dist2[s][g]==inf) cout << -1 << endl;
  else cout << dist2[s][g] << endl;
}

int main(){
  while (true) {
    int n,m,c,s,g;
    cin >> n >> m >>c >> s >> g;
    if(!n and !m and !c and !s and !g) break;
    solve(n,m,c,s,g);
  }
}

Measured memory_bytes: 4772
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
d = [LS() + [str(i)] for i in range(1, n+1)]
d = sorted(d, key=lambda x: (x[0], int(x[1])*(-1)))
for elem in d:
    print(elem[2])


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long cnt=0, cnt2=0;
  for(int i=0; i<n; i++){
    int x;
    cin >> x;
    if(x % 4 == 0) cnt++;
    if(x % 2 == 0 && x % 4 != 0) cnt2++;
  }
  if(2 * cnt + 1 >= n){
    cout << "Yes" << endl;
  }else if(cnt2 - 1 >= n - cnt * 2 - 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数（ll）
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

//素因数分解
vector<pair<ll, int>>factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n % i == 0){
      n /= i;
      res.back().second++;
    }
  }
if(n != 1) res.emplace_back(n, 1);
return res;
}




int main() {
  string S;
  cin >> S;
  vector<string> inputs = {"dream", "dreamer", "erase", "eraser"};
  reverse(all(S));
  REP(i, 4) reverse(all(inputs.at(i)));
  int pos = 0;
  while(true){
    bool flag = false;
    REP(i, 4){
      if(S.substr(pos, inputs.at(i).size()) == inputs.at(i)){
        flag = true;
        pos += inputs.at(i).size();
        break;
      }

    }
      if(!flag) break;      

  }
    if(pos == S.size()) YES;
    else NO;
}

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

int main() {
  int n, a;
  cin >> n;
  ll ans = 0;
  rep(i, n) {
    cin >> a;
    if (i % 2 == 0 && a % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620