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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n = inl();
        vl p(n);
        rep(i, n) cin >> p[i];

        ll ans = 0;
        rep(i, n - 2) {
            if (p[i] < p[i + 1] && p[i + 1] < p[i + 2] || p[i + 2] < p[i + 1] && p[i + 1] < p[i]) {
                ans++;
            }
        }
        cout << ans << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

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

    int uresisa = 0;

    uresisa += x / 500 * 1000;
    x %= 500;
    uresisa += x / 5 * 5;

    cout << uresisa << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

void solve(){

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

	int n,m,cont=0,aux;

	cin >> n >> m;

	while(m--){
		cin >> aux;
		cont+=aux;
	}

	cout << (cont >= n ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#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,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n) {
        int x;
        cin >> x;
        if (x & 1) {
            cnt ^= 1;
        }
    }

    cout << (cnt == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool operator==(const mint& a, const mint& b) { return a.x == b.x;}

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

    int n, m;
    cin >> n >> m;
    vector<int> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    mint sum_x = 0;
    mint sum_y = 0;
    rep(i, n) sum_x += 1LL * i * x[i] - 1LL * (n - 1 - i) * x[i];
    rep(i, m) sum_y += 1LL * i * y[i] - 1LL * (m - 1 - i) * y[i];

    mint ans = sum_x * sum_y;
    cout << ans << endl;
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    vector<tuple<int, int, int>> query;
    REP(i, N){
        scanInt(xi);
        scanInt(yi);
        scanInt(hi);
        query.emplace_back(xi, yi, hi);
    }
    REP(cx, 101){
        REP(cy, 101){
            int H;
            for (auto& e : query){
                auto& xi = get<0>(e);
                auto& yi = get<1>(e);
                auto& hi = get<2>(e);
                if (0 < hi){
                    H = hi + abs(xi - cx) + abs(yi - cy);
                    break;
                }
            }
            bool flag = true;
            for (auto& e : query){
                auto& xi = get<0>(e);
                auto& yi = get<1>(e);
                auto& hi = get<2>(e);
                if (max(H - abs(xi - cx) - abs(yi - cy), 0) != hi){
                    flag = false;
                    break;
                }
            }
            if (flag){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
}

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

int main ()
{
    char a1, b1, c1, a2, b2, c2;
    cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
    int ans = 0;
    if (a1 == a2)
        ans++;
    if (b1 == b2)
        ans++;
    if (c1 == c2)
        ans++;
    cout << ans;
}


Measured memory_bytes: 3636
/*
 * Code be weshen zyk :'(
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define F first
#define S second

using ll = long long;
using ii = pair<int, int>;
using db = long double;

#ifdef ONLINE_JUDGE
#define cerr if(0)cerr
#endif

template<class C> void amin(C &a4, C b4) {
	a4 = min(a4, b4);
}
template<class C> void amax(C &a4, C b4) {
	a4 = max(a4, b4);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
	os << "[";
	for (auto vv : V)
		os << vv << ",";
	return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.first << "," << P.second << ")";
}

const int N = 1e5 + 5;
int n, m;
int dp[N][3];
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 3; j++)
			cin >> dp[i][j];

	for(int i = 2; i <= n; i++){
		dp[i][0] += max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] += max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] += max(dp[i-1][1], dp[i-1][0]);
	}


	cout << *max_element(dp[n],dp[n]+3) << '\n';


	return 0;
}


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

#define ll long long

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int> p(n + 1), c(n + 1);
	for (int i = 1; i <= n; ++i) cin >> p[i];
	for (int i = 1; i <= n; ++i) cin >> c[i];
	
	ll res = LLONG_MIN;
	vector<ll> sc(n+1);
	for (int i = 1; i <= n; ++i) {
		int next = p[i], step = k, cnt = 0;
		bool cyc = false;
		while (step > 0) {
			sc[i] += c[next];
			res = max(res, sc[i]);
			++cnt;
			--step;
			if (i == next && !cyc) {
				cyc = true;
				step = min(step, k % cnt + cnt);
				sc[i] *= max(k / cnt - 1, 1) ;
				res = max(res, sc[i]);
			}
			next = p[next];
		}
	}
	cout << res;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> pairs(N);
    
    for (int i = 0; i < N; i++) {
        pairs.at(i).second = i + 1;
    }
    
    for (int i = 0; i < N; i++) {
        cin >> pairs.at(i).first;
    }

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

    for (int i = 0; i < N; i++) {
        if (i == N-1) cout << pairs.at(i).second << endl;
        else cout << pairs.at(i).second << " ";
    }

    return 0;
}

Measured memory_bytes: 1664
#解説参照
a = list(map(int, input().split( )))
a.sort(reverse = True)
ans = 0
ans += a[0]-a[1]
a[1]+=ans
a[2] += ans
ans += (a[0]-a[2])//2
ans += ((a[0]-a[2])%2)*2###これ
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	int size = s.size();
	string ans;
	for (int i = 0;i<size;i++)
	{
		if (i % 2 == 0)
		{
			ans.push_back(s[i]);
		}
	}

	cout << ans << endl;

	return 0;

}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main() {
    FAST;


            ll a;
    cin>>a;
    ll ans=a+(a*a)+(a*a*a);
    cout<<ans<<endl;





    return 0;
}



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

int main() {
	int A, B, K;
	
	cin >> A >> B >> K;
	for (int i = A; i < A + K; i++) {
		if (i > B) continue;
		cout << i << endl;
	}

	for (int i = B - K+1; i < B+1; i++) {
		if (i <= A + K - 1) continue;
		cout << i << endl;
	}
	return 0;

}


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

using namespace std;

int main() {
  long long A; string B;
  cin >> A >> B;
  long long B2 = stoll(B.erase(1,1));
  //cout << B2 << endl;
  long long result = (A * B2) / 100;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int n;
ll k, a[N], b[N];

bool valid(ll lim){
    ll cnt = 0;
    for(int i = 0 ; i < n ; ++i)
        cnt += max(0LL, a[i] - (lim / b[i]));
    return cnt <= k;
}

ll bs(){
    ll l = 0, r = 1e12, mid, ans = -1;
    while(l <= r){
        mid = (l + r) / 2LL;
        if(valid(mid)){
            ans = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    return ans;
}

int main(){
    scanf("%d%lld", &n, &k);
    for(int i = 0 ; i < n ; ++i)scanf("%lld", a + i);
    for(int i = 0 ; i < n ; ++i)scanf("%lld", b + i);
    sort(a, a + n);
    sort(b, b + n);
    reverse(b, b + n);
    printf("%lld\n", bs());
}

Measured memory_bytes: 3328
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, p;
    cin >> a >> p;
    p += a * 3;

    cout << p / 2 << "\n";

    return 0;
}

Measured memory_bytes: 256
t;main(a,b,c){
    
    long int k;
    scanf("%d%d%d%ld",&a,&b,&c,&k);
    
    if(k%2==0){
        t=a-b;
    }else{
        t=b-a;
    }
    
    if(abs(a-b)>1000000000000000000){
        printf("Unfair");
    }else{
        printf("%d",t);
    }
    
}

Measured memory_bytes: 1684
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int h, w;
    std::cin >> h >> w;

    int count = 0;
    for (int i = 0; i < h; i++) {
        std::string temp;
        std::cin >> temp;

        count += std::count(temp.begin(), temp.end(), '#');
    }

    if (count == h + w - 1) {
        std::cout << "Possible" << std::endl;
    } else {
        std::cout << "Impossible" << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int max = 0;
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            max += a[i];
        }
        sc.close();

        int count = 0;
        for (int i = 0; i < a.length; i++) {
            if (((double)max) / (4 * m) <= a[i]) {
                count++;
            }
        }

        if (count >= m) {
            System.out.println("Yes");

        } else {
            System.out.println("No");

        }
    }
}


Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		while (scan.hasNextLine()) {
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();

			if (op.equals("?"))
				break;

			switch (op) {
			case "+":
				System.out.println(a + b);
				break;
			case "-":
				System.out.println(a - b);
				break;
			case "*":
				System.out.println(a * b);
				break;
			case "/":
				System.out.println(a / b);
				break;
			}
		}

	}

}






Measured memory_bytes: 26372
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>
#include<string.h>
#include<vector>

#define mod 1000000007

int main(){
	int n;
	long long ans;
	char a[100],b[100];
	
	scanf("%d",&n);
	scanf("%s",a);
	scanf("%s",b);
	
	if(a[0] == b[0])ans=3;
	else ans=6;
	for(int i=1;i<n;i++){
		if(a[i-1]==b[i-1])ans=(ans*2)%mod;
		else if(!(a[i-1]==a[i]||b[i-1]==b[i]||a[i]==b[i])) ans=(ans*3)%mod;
	}
	
	printf("%I64d\n",ans);
		
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
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; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;

ll fac[1000010];

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

void modfac() {
	fac[0] = 1;
	for (ll i = 1; i < 1000010; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
	}
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return (fac[n] * modinv(fac[n - k])) % mod;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return ((fac[n] * modinv(fac[k])) % mod*modinv(fac[n - k])) % mod;
}

int main() {
	char c;
	cin >> c;
	c++;
	cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;


//最大公約数
ll gcd(ll a, ll b) {
	if (b != 0) {
		return gcd(b, a % b);
	}

	return a;
}

// ABC125C - Blackboard
// https://atcoder.jp/contests/abc125/tasks/abc125_c
void ABC125C() {
	int N;
	cin >> N;
	
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	//累積GCD
	vector<int> left(N + 1, 0), right(N + 1, 0);
	for (int i = 0; i < N; i++)
	{
		left [i+1]   = gcd(left[i]   , A[i]);
		//cout << "left" << endl;
	}
	for (int i = N-1; i >= 0; i--)
	{
		right[i] = gcd(right[i + 1], A[i]);
		//cout << "right" << endl;
	}


	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int l = left[i];
		int r = right[i+1];
		//printf("[%d, %d]\n", l, r);
		ans = max(ans, (int)gcd(l, r));
		
	}
	cout << ans << endl;

}




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


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

template<typename T>
struct fenwick
{
    int n;
    vector<T> f;
    fenwick(int n = 500005) : n(n), f(n + 1) {}

    T query(int p)
    {
        T ret = 0;
        for (++p; p > 0; p -= p & -p)
            ret += f[p];
        return ret;
    }

    void update(int p, T x)
    {
        for (++p; p <= n; p += p & -p)
            f[p] += x;
    }
};

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n; string s;
	cin >> n >> s;
	vector<fenwick<int>> f(26);
	for (int i = 0; i < n; ++i)
		f[s[i]-'a'].update(i, +1);

	int q;
	cin >> q;
	char x;
	for (int t, l, r; q--; )
	{
		cin >> t >> l;
		if (t == 1)
		{
			cin >> x;
			f[s[l-1]-'a'].update(l-1, -1);
			s[l-1] = x;
			f[s[l-1]-'a'].update(l-1, +1);
		}
		else
		{
			cin >> r;
			int ans = 0;
			for (int i = 0; i < 26; ++i)
				ans += f[i].query(r-1) - f[i].query(l-2) > 0;
			cout << ans << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 51868
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
    int r, g, b, n;
    int res = 0;
    cin >> r >> g >> b >> n;

    for(int i = 0; i < (n/r)+1; i++){
        for(int j = 0; j < (n/g)+1; j++){
            int x = n - ((i*r)+(j*g));
            if(x%b == 0 && x >= 0){
                res++;
            }
        }
    }
    cout << res << endl;
}

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

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

using namespace std;

int main() {
	int n; cin >> n;
  	vector <int> a(n);
  for(int i = 0; i < n; i+=1) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  double res = a[0];
  for(int i = 1; i < a.size(); i+= 1) {
  	res = (a[i] + res)/2;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int x, y;
    cin >> x >> y;
    // a + b = x
    // 2a + 4b = y
    // (y - 2x) = 2b
    if ((y-x*2) % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    int b = (y-x*2) / 2;
    int a = x - b;
    if (a >= 0 && b >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).rbegin(), (v).rend())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define DESC(v) sort((v).rbegin(), (v).rend())
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

ll mz[51][51];

void solve() {
    ll H, W;
    cin >> H >> W;
    REP(y, H) {
        REP(x, W) {
            char c;
            cin >> c;
            mz[y][x] = (c == '#' ? 1 : 0);
        }
    }
    ll dx[4] = {-1, 0, 1, 0};
    ll dy[4] = {0, -1, 0, 1};
    REP(y, H) {
        REP(x, W) {
            ll ctr = 0;
            if(mz[y][x] == 0) continue;
            REP(i, 4) {
                ll xx = x + dx[i];
                ll yy = y + dy[i];
                if(mz[yy][xx] == 1 && x >= 0 && y >= 0 && x < W && y < H) {
                    ctr++;
                }
            }
            if(ctr==0) {
                cout << "No" << endl;
                return;
            }
        }
    }
    cout << "Yes" << endl;
}

int main() {
    FIO;
    solve();
    return 0;
}


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

using namespace std;

#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 itn long long

typedef long long ll;
typedef pair<ll,ll> p;

vector<string> a;
vector<string> b;
int n, m;

bool check(int x, int y)
{
  for (int i = 0; i < m; i++)
  {
    if(b[i] != a[y+i].substr(x, m)) return false;
  }
  return true;
}

int main()
{
  cin >> n >> m;
  for (int i = 0; i < n; i++)
  {
    string tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  for (int i = 0; i < m; i++)
  {
    string tmp;
    cin >> tmp;
    b.push_back(tmp);
  }

  // for (int i = 0; i < n; i++)
  // {
  //   cout << a[i] << endl;
  // }
  // for (int i = 0; i < m; i++)
  // {
  //   cout << b[i] << endl;
  // }
  // cout << a.size() << endl;
  // cout << b.size() << endl;

  for (int i = 0; i <= n - m; i++)
  {
    for (int j = 0; j <= n - m; j++)
    {
      if(check(i, j)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
ll fang(ll a){
  return a > 1 ? fang(a - 1) + a : 1;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  if(n == 2){
    cout << abs(v[0] - v[1]) << endl;
    return 0;
  }
  vector<ll>sum(n + 1);
  rep(i,n)sum[i + 1] = sum[i] + v[i];
  ll ans = INF;
  REP(i,1,n){
    ll x = sum[i];
    ll y = sum[n] - sum[i];
    ans = min(ans,abs(x - y));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

    bool ans;
    if((m1+1)%12==m2%12 && d2==1) ans=1;
    else ans=0;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s = reader.readLine();
				
			int n = Integer.parseInt(s);
			
			int i = 1;
			while (++ i <= n) {
				int x = i;
				if (x % 3 == 0) {
					System.out.print(" ");
					System.out.print(i);
					continue;
				}
				do {
					if (x % 10 == 3) {
						System.out.print(" ");
				 		System.out.print(i);
						break;
					}
					x /= 10;
				} while (x != 0);
			}
			System.out.println();				
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 30652
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");

//     String nyu=sc.nextLine();
//int[] num=new int[6];
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu);
//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

System.out.println(A + (B/2)) ;

	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  
  vector<int> X(n+1),Y(m+1);
  
  X[0] = x; Y[0] = y;
  
  for (int i = 1; i < n+1;i++){
    int tmp;
    cin >> tmp;
    X[i] = tmp;
  }
  for (int i = 1; i < m+1;i++){
    int tmp;
    cin >> tmp;
    Y[i] = tmp;
  }
  
  sort(X.begin(),X.end(),greater<int>());
  sort(Y.begin(),Y.end());

  if (X[0] >= Y[0]) cout << "War";
  else cout << "No War";
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxm=2e5+5;
const int mod=1e9+7;
int a[maxm];
int b[maxm];
int n;
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<int>ans;
    for(int i=n;i>=1;i--){
        int cnt=0;
        for(int j=i;j<=n;j+=i){
            cnt+=b[j];
        }
        if(cnt%2==a[i]){
            continue;
        }else{
            b[i]=1;
            ans.push_back(i);
        }
    }
    cout<<ans.size()<<endl;
    for(auto i:ans){
        cout<<i<<' ';
    }
    return 0;
}
/*

*/


Measured memory_bytes: 7236
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

h,a = LI()
print(math.ceil(h/a))

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      int k = 0;
      while ((i >> k & 1) == (j >> k & 1)){
        k++;
      }
      cout << k + 1;
      if (j < N - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
int main()
{
  LL a,b;
  while(cin>>a>>b){
    map<LL,LL>dp;
    LL A[1005]={},B[1005]={};
    for(int i=0;i<a;i++){
        cin>>A[i]>>B[i];
    }
    dp[0]=0;
    for(int i=0;i<a;i++){
        map<LL,LL>tmp=dp;
        for(map<LL,LL>::iterator j=tmp.begin();j!=tmp.end();j++){
            dp[j->first+A[i]]=max(dp[j->first+A[i]],j->second+B[i] );
        }
    }
    LL ans=0;
    for(map<LL,LL>::iterator i=dp.begin();i!=dp.end();i++){
            if(i->first<=b)
        ans=max(ans,i->second);
    }
    cout<<ans<<endl;

  }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

// kmp をやるための前計算 0-iの接頭辞と接尾辞が何文字まであっているかをTableに保存
vector<int> makeTable(const string& s) {
  int n = s.size();
  vector<int> ret(n+1);
  ret[0] = -1;
  int j = -1;
  for (int i = 0; i < n; i++) {
    while (j >= 0 && s[i] != s[j]) j = ret[j];
    ret[i+1] = ++j;
  }
  return ret;
}
// str の中に word とマッチする場所のリストを返す
// ret のそれぞれの要素 el は, 「str[el] からの文字列が word と一致する」ことを示す
bool kmp(const string& str, const string& word) {
  vector<int> table = makeTable(word);
  int m = 0, i = 0, n = str.size();
  while ( m+i < n) {
    if (word[i] == str[m+i]) {
      if (++i == (int)(word.size())) {
        return true;
      }
    } else {
      m = m+i-table[i];
      if (i > 0) i = table[i];
    }
  }
  return false;
}


void Main(){

  int N;
  string S;
  cin>>N>>S;

  //S+='$';

  int left=0;
  int right=0;

  string hiword=S;
  string word;

  int ans=0;
  while(right<N){
    //cout<< left<<" "<<right<<"\n";
    //cout<< hiword<<"\n";
    //cout<< word<<"\n";
    if(left==right){
      if(right==N) break;
      char c=S[right];
      word+=c;
      ++right;
      // char c=S[right];
      hiword.erase(hiword.begin());
      continue;
    }

    if(kmp(hiword,word)){
      maxi(ans,right-left);
      if(right==N) break;
      char c=S[right];
      ++right;
      // char c=S[right];
      word+=c;
      hiword.erase(hiword.begin());
      continue;
    }
    else{
      ++left;
      word.erase(word.begin());
      continue;
    }
  }

  cout<< ans<<"\n";

}

  //-----------------------------------
  int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
  }
  //-----------------------------------


Measured memory_bytes: 384
import math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, h, m = sc.nextInt

  var d = (30 * h + (0.5 * m) - 6 * m).abs
  if (d > 180) {
    d = 360 - d
  }

  println(sqrt(a * a + b * b - 2 * a * b * cos(toRadians(d))))
}

Measured memory_bytes: 55344
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//以上テンプレ
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main(){
ll N;
cin>>N;
vl vec(N);
ll count=0;
rep(i,N) cin>>vec.at(i);
sort(all(vec));
rep(i,N-2){
    ll a=i;
    for(ll j=i+1;j<N-1;++j){
        while(a<N&&vec.at(a)<vec.at(i)+vec.at(j)){
            a++;
        }
        count+=a-j-1;
    }
}
cout<<count<<endl;
}

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

int main(int argc, char *argv[])
{
    std::vector<int> vec;
    for (int i = 0; i < 4; i++) {
        int t;
        std::cin >> t;
        vec.push_back(t);
    }
    std::sort(vec.begin(), vec.end());
    int ans[] = {1, 4, 7, 9};
    bool flag = true;
    for(int i = 0; i < 4; i++){
        flag &= (ans[i] == vec[i]);
    }
    if(flag){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	ll N;
	cin >> N;
	ll A, high;

	cin >> A;
	high = A;
	ll ans = 0;

	REP (i, N-1) {
		cin >> A;
		high = max(A, high);
		ans += high - A;
	}

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

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

int main(){
    string st1, st2;
    cin>>st1>>st2;
    int n1=st1.size();
    int n2=st2.size(), flag=0;
    st1+=st1;
    
    rep(i,n1){
        rep(j,n2){
            if(st2[j]!=st1[i+j]) break;
            if(j==n2-1) flag++;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
      
}


Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, m, a[123456];
pair<int, int>p[123456];
signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> a[i]; sort(a, a + n);
	for (int i = 0; i < m; i++)cin >> p[i].second >> p[i].first;
	sort(p, p + m);
	int am = 0;
	for (int i = m - 1; i >= 0; i--) {
		for (int j = 0; j < p[i].second&&am < n; j++) {
			a[am] = max(a[am], p[i].first);
			am++;
		}
	}
	am = 0; for (int i = 0; i < n; i++)am += a[i];
	cout << am << endl;
	cin >> n;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;
priority_queue <pair<int, pair<int, int>>> Q;
long n,m;

void solve(){
    long long sum=0;
    while(n!=0){
        long value=Q.top().first, num=Q.top().second.first;
        Q.pop();
        sum += value*min(n, num);
        n -= min(n, num);
    }
    cout << sum << endl;
}

int main(){
    cin >> n >> m;
    int tmpa;
    for(int i=0;i<n;i++){
        cin >>tmpa;
        Q.push(make_pair(tmpa, make_pair(1,i)));
    }
    int tmpb,tmpc;
    for(int i=0;i<m;i++){
        cin >> tmpb >> tmpc;
        Q.push(make_pair(tmpc, make_pair(tmpb,n+i)));
    }
    solve();
}

Measured memory_bytes: 4340
#include <stdio.h>

int main(){
	int N=0;
  	int tmp=1;
  	int i;
  	int ans=0;
    scanf("%d",&N);
  for(i=1;i<7;i++){
  	if(tmp>N){
    	break;
    }
    tmp=tmp*10;
  }
  i--;
  if(i==1){
    	ans=N;
  }else if(i==2){
  	ans=9;
  }else if(i==3){
  	ans=9+N-100+1;
  }else if(i==4){
  	ans=900+9;
  }else if(i==5){
  	ans=9+900+N-10000+1;
  }else if(i==6){
  	ans=9+900+90000;
  }
	printf("%d",ans);

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int MAXN = 1e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-8;
const double PI=3.1415926535897932;

LL x[500009];
LL a[500009];//AFTER each move.
LL b[500009];

int main(){
	DRII(n,d);
	REP(i,n){
		scanf("%lld",&x[i]);
	}
	a[0]=d;
	REP(i,n){
		a[i+1]=min(abs(a[i]-x[i]),a[i]);
	}
	b[n]=1;
	for(int i=n-1;i>=0;i--){
		if(b[i+1]<=x[i]/2)b[i]=b[i+1];
		else b[i]=b[i+1]+x[i];
	}
	//REP(i,n+1)printf("%d ",a[i]);puts("");
	//REP(i,n+1)printf("%d ",b[i]);
	DRI(qn);
	REP(i,qn){
		DRI(qi);qi--;
		if(a[qi]>=b[qi+1])puts("YES");
		else puts("NO");
	}
}


Measured memory_bytes: 13696
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
    string s;
    cin>>s;
    if(s[1]=='B') p("ARC");
    else if(s[1]=='R') p("ABC");
}

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

int main()
{
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

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

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  int r[n] = {}, l[n] = {}, ans[n] = {};
  r[0] = 0;
  l[n - 1] = n - 1;
  FOR(i , 1, n) {
    if (s[i] == 'R') r[i] = i;
    else r[i] = r[i - 1];
  }
  for(int i = n - 2; i > -1; i--) {
    if (s[i] == 'L') l[i] = i;
    else l[i] = l[i + 1];
  }
  REP(i, n) {
    if(s[i] == 'R') {
      int x = l[i];
      if ((l[i] - i) % 2 == 0) {
        ans[l[i]]++;
      } else {
        ans[l[i] - 1]++;
      }
    } else {
      int x = r[i];
      if ((i - r[i]) % 2 == 0) {
        ans[r[i]]++;
      } else {
        ans[r[i] + 1]++;
      }
    }
  }
  cout << ans[0];
  FOR(i, 1, n) cout << " " << ans[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;


int main(){
  string s,t;cin>>s;
  ll k;cin>>k;
  for(int i=0;i<s.size();i++){
      if(s[i]!='1'){cout<<s[i];return 0;}
      if(i+1==k){cout<<1;return 0;}
  }
  cout<<1;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
x = []
for _ in range(n):
    a, b = map(int, input().split())
    x.append([a, b])
x = sorted(x)
for i in range(n):
    k -= x[i][1]
    if k < 1:
        print(x[i][0])
        break


Measured memory_bytes: 20872
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    reps(i,n){
        int x;
        cin >> x;
        a[i] = a[i-1] + x;
    }
    int minv = LINF;
    reps(i,n-1){
        minv = min(minv,abs(a[n]-a[i]*2));
    }
    cout <<minv << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main() {
  int w,i,n;
  char s[1001];
  scanf("%s",s);
  scanf("%d",&w);
  n=strlen(s);
  for (i=0; i<n; i++) {
    if (i%w==0) {
      printf("%c",s[i]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int A,B,C;
    cin >> A >> B >> C;
    int x=A%B;
    string ans="NO";
    rep(i,C+100){
        if(x*(1+i)%B==C) ans="YES";
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#define MOD 998244353
using namespace std;
long long n, s, a[3000], dp[3001][3001][3];
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= s; j++) {
      dp[i + 1][j][0] += dp[i][j][0];
      dp[i + 1][j][0] %= MOD;
      dp[i + 1][j][1] += (dp[i][j][0] + dp[i][j][1]) % MOD;
      dp[i + 1][j][1] %= MOD;
      dp[i + 1][j][2] += (dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) % MOD;
      dp[i + 1][j][2] %= MOD;
      if (j + a[i] <= s) {
        dp[i + 1][j + a[i]][1] += (dp[i][j][0] + dp[i][j][1]) % MOD;
        dp[i + 1][j + a[i]][1] %= MOD;
        dp[i + 1][j + a[i]][2] += (dp[i][j][0] + dp[i][j][1]) % MOD;
        dp[i + 1][j + a[i]][2] %= MOD;
      }
    }
  }
  cout << dp[n][s][2] << endl;
}

Measured memory_bytes: 211328
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.depth = 0
        self.type = None
        self.children = children
          
    def show(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,self.parent,self.depth,self.type,self.children))
  
  
def set_node(node_data):
    L = list(map(int, node_data.split()))
    num = L[0]
    children = L[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n
  
def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'
  
n = int(input())
  
T = [None] * n
  
T.append(int(n * (n - 1) / 2))
  
for i in range(n):
    x = input()
    set_node(x)
  
set_pdt(T[-1], -1, 0)
  
T[T[-1]].type ='root'
  
for n in T[:-1]:
    n.show()

Measured memory_bytes: 50404
#include<cstdio>
#include<algorithm>
#define abs(a) ((a)>0?(a):(-(a)))
#define ll long long
using namespace std;
int a[200050];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+1+n);
	ll ans=0;
	for (int i=1;i<=n;i++)
	ans+=abs(a[i]-a[(n+1)/2]);
	printf("%lld\n",ans);
	return 0;
}

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

int main(void){
  int n;
  string str;
  cin>>n;
  getline(cin,str);
  while(n--){
    getline(cin,str);
    int ind = 0;  
    string res = str.substr(0,1);
    for(int i = 0 ; i < str.size() + 1 ; i ++){
      
      if(str[i] == '>'){
	ind++;
	//cout<<'>';
	if(ind >= res.size()){
	  res = res + str[i + 1];
	}
      }else if(str[i] == '<'){
	//cout<<'<';
	ind--;
	if(ind < 0){;
	  res = str[i + 2] + res;
	  ind = 0;
	}
      }
    }
    cout<<res<<endl;
  }
}

Measured memory_bytes: 1212