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

using i64 = int64_t;

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

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

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

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

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;
    vector<i64> A(N);
    rep(i,0,N){
        cin >> A[i];
    }

    sort(rbegin(A),rend(A));

    i64 plus=1,minus=1;
    vector<i64> l={A[0]},r={A[N-1]};
    rep(i,1,N-1){
        if(A[i]>=0){
            ++plus;
            l.emplace_back(A[i]);
        }
        else{
            ++minus;
            r.emplace_back(A[i]);
        }
    }



    vector<i64> x,y;

    function<i64(i64)> dfs=[&](i64 sgn){
        if(sgn==0){
            --plus;
            --minus;
            i64 a=dfs(1),b=dfs(-1);
            x.emplace_back(a);
            y.emplace_back(b);
            return a-b;
        }
        if(sgn==1){
            if(minus>0){
                --minus;
                i64 a=dfs(1),b=dfs(-1);
                x.emplace_back(a);
                y.emplace_back(b);
                return a-b;
            }else {
                i64 res = l.back();
                l.pop_back();
                return res;
            }
        }else{
            if(plus>0){
                --plus;
                i64 a=dfs(-1),b=dfs(1);
                x.emplace_back(a);
                y.emplace_back(b);
                return a-b;
            }else {
                i64 res = r.back();
                r.pop_back();
                return res;
            }
        }
    };

    i64 M=dfs(0);
    cout << M << endl;
    rep(i,0,N-1){
        cout << x[i] << " " << y[i] << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main() {
    int n, W; cin >> n >> W;
    vector<vector<int>> vs(4, vector<int>(1, 0));
    long long w0;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            int v; cin >> w0 >> v;
            vs[0].emplace_back(v);
        } else {
            int w, v; cin >> w >> v;
            vs[w - w0].push_back(v);
        }
    }
    for (auto &v: vs) {
        sort(v.begin(), v.end());
        reverse(v.begin() + 1, v.end());
        for (int i = 0; i + 1 < v.size(); i++) v[i + 1] += v[i];
    }
    int ma = 0;
    #define vrep(i, v) for (int i = 0; i < v.size(); i++)
    vrep(i, vs[0]) vrep(j, vs[1]) vrep(k, vs[2]) vrep(l, vs[3]) {
        long long w = (w0 + 0) * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l;
        if (w > W) continue;
        int v = vs[0][i] + vs[1][j] + vs[2][k] + vs[3][l];
        ma = max(ma, v);
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
graph = [list(input()) for _ in range(H)]
flg = True
while flg:
    loop = False
    for i in range(len(graph)):
        if "#" not in graph[i]:
            graph.pop(i)
            loop = True
            break
    if loop:
        continue
    for j in range(len(graph[0])):
        tate = [line[j] for line in graph]
        if "#" not in tate:
            for i in range(len(graph)):
                graph[i].pop(j)
            break
    else:
        flg = False
for line in graph:
    print("".join(line))


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

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i,n) cin >> w.at(i);
    int ans = INF;
    rep(i,n){
        int s1=0,s2=0;
        rep(j,n){
            if(j <= i) s1 += w.at(j);
            else s2 += w.at(j);
        }
        ans =min(ans,abs(s1-s2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
using namespace std;
int N,A[200000];
int main() {
    cin >> N;
    for (int i=0; i<N; i++) cin >> A[i];
    sort(A, A+N);
    string ans="YES";
    for (int i=0; i<N-1; i++) {
        if (A[i] == A[i+1]) {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

inline int get(string s, int x, int y){
    int i = y*3+x;
    switch(s[i]){
    case 'o': return 1;
    case 'x': return 2;
    case 's': return 4;
    }
    return 0;
}

int check(string s){
    int c3 = 0, c4 = 0;
    REP(i,3){
        int c1 = 0, c2 = 0;
        REP(j,3){
            c1 |= get(s, j, i);
            c2 |= get(s, i, j);
        }
        if(c1 == 1 || c1 == 2) return c1;
        if(c2 == 1 || c2 == 2) return c2;
        c3 |= get(s, i, i);
        c4 |= get(s, i, 2-i);
    }
    if(c3 == 1 || c3 == 2) return c3;
    if(c4 == 1 || c4 == 2) return c4;
    return 0;
}

int main(){
    string s;
    while(getline(cin, s)){
        cout << "dox"[check(s)] << endl;
    }
    return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

typedef unsigned long long ll;
typedef long double ld;
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPR(i,a,b) for(int i = b; i >= a; i--)
#define all(a)              a.begin(), a.end()
#define alln(a, n)          (a, a+n)
#define sz(x) (int)(x).size()
#define MAX                 10000007
#define MIN                 -10000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mii             map<int,int>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf 1e18
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<vi> vvi; 
typedef vector<string> vs;
typedef set<int> si;
const int MOD=1e9+7;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b,ll MOD){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2,MOD) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2,MOD);}
ll fact[1],inv[1];
void factorial(ll n){
  fact[0]=1;
  for(ll i=1;i<=n;i++){
    fact[i]=fact[i-1]*i;
    if(fact[i]>=MOD)
      fact[i]%=MOD;
  }
}
ll ncr(ll n,ll r){
  if(n<r||n<0||r<0)
    return 0;
  ll b=inv[n-r];
  ll c=inv[r];
  ll a=fact[n]*b;
  if(a>=MOD)
    a%=MOD;
  a*=c;
  if(a>=MOD)
    a%=MOD;
  return a;
}
vector<char> is_prime(100001, true);
void sieve(ll n){
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                  is_prime[j] = false;
        }
  }    
}   
std::vector<int> adj[100005];
int ans=0,maxx;
int visited[100005]={0};  
void dfs(int s){
    visited[s]=1;
    for(auto x:adj[s]){
      if(visited[x]) continue;
      dfs(x);
    }
}    
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      
    int t;
    t=1;
    cout<<fixed<<setprecision(0);
     //  cin>>t;
    while(t--){
          int n,m;
            cin>>n>>m;
            REP(i,0,m-1){
              int a,b;
              cin>>a>>b;
              adj[a].push_back(b);
              adj[b].push_back(a);
            }
            REP(i,1,n){
              if(visited[i]==1) continue;
              ans++;
              dfs(i);
            } 
              
            cout<<ans-1;

       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}



Measured memory_bytes: 10264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        string s = sc.NextString();
        string t = sc.NextString();
        int a = sc.NextInt();
        int b = sc.NextInt();
        string u = sc.NextString();
        if (u == s) a -= 1;
        if (u == t) b -= 1;
        Console.WriteLine("{0} {1}", a, b);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    static long Lcm(long a, long b)
    {
        long d = Gcd(a, b);
        return a / d * b;
    }

    static long RepeatedSquare(long n, long p, long m)
    {
        if (p == 0) return 1;
        if (p % 2 != 0) return n * RepeatedSquare(n, p - 1, m);
        long t = RepeatedSquare(n, p / 2, m);
        return (t * t) % m;
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140
def culc(num_referee):
    data=[]
    for i in range(num_referee):
        data.append(int(input()))
    data.sort()
    sum_data=0
    data[0]=0
    data[len(data)-1]=0
    #print(data)
    for j in data:
        sum_data=sum_data+j
    avg=sum_data/(len(data)-2)
    print(int(avg))


num_referee=1
while(1):
    num_referee=input()
    #print(num_referee)
    if num_referee != "0":
        culc(int(num_referee))
    else:
        break



Measured memory_bytes: 5596
#include<stdio.h>
int main()
{
	int N;
	scanf("%d", &N);

	int	V[20] = { 0 };
	int C[20] = { 0 };
	for (int i = 0; i < N; i++) {
		scanf("%d", &V[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &C[i]);
	}

	// 価値-コストを求める.
	int gain;
	int output = 0;
	for (int i = 0; i < N; i++) {
		gain = V[i] - C[i];
		// 価値-コストが正なら手に入れる.
		if (gain > 0) {
			output += gain;
		}
	}
  
  printf("%d", output);

	return 0;
}

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

ll N, M, V, p;
vector<ll> a;

bool check(int x){
    ll cnt = (V-1)*M, A = a[x-1]+M;
    for(int i=0;i<N;i++){
        if(i == x-1) continue;
        if(i < p-1) cnt -= M;
        else {
            if(a[i] > A) return false;
            cnt -= min(A-a[i], M);
        }
    }
    return cnt <= 0;
}

int main(){
    cin >> N >> M >> V >> p;
    a.resize(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    int ok = p, ng = N+1;
    while(abs(ok-ng) > 1){
        int mid = (ok+ng)/2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define forinc(i,a,b) for (int i = a ; i <= b ; i ++)
#define fordec(i,a,b) for (int i = a ; i >= b ; i --)
#define forv(j,u) for (int j = 0 ; j < u.size() ; j++)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
#define ooll (long long) 1e15
#define ooit (int) 2e9
#define maxN 305

using namespace std ;

int n , m , a[maxN][maxN] ;

void enter() {
    cin >> n >> m ;
    forinc(i,1,n) forinc(j,1,m) cin >> a[i][j] ;
}

bool era[maxN] ;

int solve() {
    int cnt[maxN] ;
    forinc(i,1,m) cnt[i] = 0 ;
    forinc(i,1,n) {
        bool ok = false ;
        forinc(j,1,m) if (!era[a[i][j]]) {cnt[a[i][j]] ++ ; ok = true ; break ; }
        if (!ok) return ooit ;
    }
    int max_peo = 0 , sport = 0 ;
    forinc(i,1,m) if (max_peo < cnt[i]) sport = i , max_peo = cnt[i] ;
    era[sport] = true ;
    return max_peo ;
}

void process() {
    int res = ooit ;
    forinc(loop,1,m) res = min(res,solve()) ;
    cout << res << endl ;
}

int main() {
    //freopen("agc018_b.inp" , "r" , stdin) ;
    enter() ;
    process() ;
    return 0 ;
}


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

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

Measured memory_bytes: 1184
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	int n;
	cin>>n;
	REP(i,n){
		vi l(3);
		REP(i,3){
			cin>>l[i];
		}
		sort(ALL(l));
		cout<<(l[2]*l[2]==l[0]*l[0]+l[1]*l[1]?"YES":"NO")<<endl;
	}
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, k, a = 0, w = 0, x, y, t = 0, r = 0, h, tot = 0, ans = 0, i, j;
    cin >> h >> w >> k;
    char s[h][w];
    for (x = 0; x < h; x++)
        for (y = 0; y < w; y++)
            cin >> s[x][y];
    long long rx = (1 << h) - 1, cx = (1 << w) - 1;
    for (x = 0; x < rx; x++)
    {
        for (y = 0; y < cx; y++)
        {
            tot = 0;
            for (i = 0; i < h; i++)
            {
                for (j = 0; j < w; j++)
                {
                    if ((x & 1 << i) == 0 && (y & 1 << j) == 0 && s[i][j] == '#')
                        tot++;
                }
            }
            if (tot == k)
                ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

int N;
int n, qn;
char s[maxn + 5];

int dif[maxn + 5];

int fa[maxn + 5];

int get(int x) { return fa[x] == x ? x : fa[x] = get(fa[x]); }

int sum[maxn + 5];

int where[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	static char tmp[maxn + 5];
	scanf("%s", tmp);
	n = strlen(tmp);
	int cur = 0;
	s[cur++] = '#';
	REP(i, 0, n)
	{
		if ((i << 1) == n) s[cur++] = '#';
		where[i] = cur;
		s[cur++] = tmp[i];
	}
	s[cur++] = '#';
	n = cur;
	int mid = n >> 1;
	N = mid;
	REP(i, 0, N)
	{
		dif[i] = (s[n - (N - i) - 1] - s[n - (N - i)]) - (s[N - i] - s[N - i - 1]);
	}
	REP(i, 0, N) fa[i] = i;
	scanf("%d", &qn);
	REP(i, 0, qn)
	{
		int x, y;
		scanf("%d%d", &x, &y), --x, --y;
		x = where[x];
		y = where[y];
		if (y < mid)
		{
			x = mid - x;
			y = mid - y - 1;
		}
		else if (x > mid)
		{
			x = x - mid - 1;
			y = y - mid;
		}
		else
		{
			x = mid - x;
			y = y - mid;
		}
		fa[get(x)] = get(y);
	}
	REP(i, 0, N) (sum[get(i)] += dif[i]) %= 26;
	REP(i, 0, N) if (fa[i] == i && sum[i])
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if((c>=a&&c<=b)||(c<=a&&c>=b)){op("Yes");}
  else{ op("No");}
  return 0;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	private static class Operation {
		public int srcX, srcY, dstX, dstY;

		public Operation(int srcY, int srcX, int dstY, int dstX) {
			this.srcX = srcX;
			this.srcY = srcY;
			this.dstX = dstX;
			this.dstY = dstY;
		}
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int H = Integer.parseInt(tokens[0]);
		int W = Integer.parseInt(tokens[1]);
		int[][] a = new int[H][W];
		int oddNum = 0;
		for (int i = 0; i < H; ++i) {
			tokens = in.nextLine().split(" ");
			for (int j = 0; j < W; ++j) {
				a[i][j] = Integer.parseInt(tokens[j]);
				if (a[i][j] % 2 == 1) {
					oddNum++;
				}
			}
		}
		List<Operation> operations = new ArrayList<>();
		// 奇数の数が奇数個 -> 1つ残る，偶数個 -> 全部偶数になる
		// でも，全部片寄するのでもいい気がする
		for (int i = 0; i + 1 < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (a[i][j] % 2 != 0) {
					// 下に1つ移動する
					operations.add(new Operation(i, j, i + 1, j));
					a[i][j]--;
					a[i + 1][j]++;
				}
			}
		}
		for (int j = 0; j + 1 < W; ++j) {
			if (a[H - 1][j] % 2 != 0) {
				// 右に1つ移動する
				operations.add(new Operation(H - 1, j, H - 1, j + 1));
				a[H - 1][j]--;
				a[H - 1][j + 1]++;
			}
		}
		System.out.println(operations.size());
		for (int i = 0; i < operations.size(); ++i) {
			Operation op = operations.get(i);
			System.out.println((op.srcY + 1) + " " + (op.srcX + 1) + " " + (op.dstY + 1) + " " + (op.dstX + 1));
		}

		in.close();
	}
}

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

int main(){
  int h,w;
  cin >> h >> w;
  int cnt = 0;
  vector<vector<bool> > a(h+1, vector<bool>(w+1, false));
  char c;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> c;
      if(c == '#'){
        a[i][j] = true;
        cnt++;
      }
    }
  }

  int start[2] = {0, 0};
  int right[2] = {0, 1};
  int down[2] = {1, 0};
  int step = 1;
  while(true){
    if(start[0] == h-1 && start[1] == w-1){
      break;
    }
    if(a[right[0]][right[1]] == a[down[0]][down[1]]){
      cout << "Impossible" << endl;
      return 0;
    }
    if(a[right[0]][right[1]]){
      start[1] = right[1];
    }else if (a[down[0]][down[1]]){
      start[0] = down[0];
    }

    right[0] = start[0] ; right[1] = start[1] + 1;
    down[0] = start[0] + 1; down[1] = start[1];
    step++;
  }

  if(step == cnt){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            count = 0
            if i > 0:
                if j > 0 and S[i-1][j-1] == '#':
                    count += 1
                if S[i-1][j] == '#':
                    count += 1
                if j < W-1 and S[i-1][j+1] == '#':
                    count += 1

            if i < H-1:
                if j > 0 and S[i+1][j-1] == '#':
                    count += 1
                if S[i+1][j] == '#':
                    count += 1
                if j < W-1 and S[i+1][j+1] == '#':
                    count += 1

            if j > 0 and S[i][j-1] == '#':
                count += 1
            if j < W-1 and S[i][j+1] == '#':
                count += 1
            S[i][j] = str(count)
    print(''.join(S[i]))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;

    vector<long long> p(N);
    for(int i=0; i<N; ++i){
        long long n;
        cin >> n;
        p[i] = n;
    }
    sort(p.begin(), p.end());

    long long ans = 0;
    for(int i=0; i<K; ++i){
        ans += p[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define push_back pb
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

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

int main() {
	int N;
	cin>>N;
	vector<int> A(N);
	rep(i,N)cin>>A[i];
	vector<int> L(N);
	vector<int> R(N);
	L[0] = A[0];
	R[N-1] = A[N-1];
	rep(i,N-1){
		L[i+1] = gcd(L[i],A[i+1]);
	}
	for (int i = N-1; i > 0; i--){
		R[i-1] = gcd(R[i],A[i-1]);
	}
	int ans = 0;
	rep(i,N){
		if(i == 0){
			ans = max(ans, R[1]);
		}
		else if(i == N-1)ans = max(ans, L[N-2]);
		else{
			ans = max(ans, gcd(L[i-1],R[i+1]));
		}
	}
	print(A);
	print(L);
	print(R);
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  int res = 0;
  for (int i = 0; i < N.size(); i++) {
    if (N.at(i) == '2') res++;
  }
 
  cout << res << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# from typing import *
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def solve(A, B, H, M):
    a = math.pi * H / 6 + math.pi * M /360
    b = math.pi * M / 30
    print(abs(A*complex(math.cos(a),math.sin(a))-B*complex(math.cos(b),math.sin(b))))


def main():
    A, B, H, M = map(int, input().split())
    solve(A, B, H, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9460
K = gets.chomp.to_i

#0から10^5までの数を全てチェック？いやだめだどれくらい大きくなるかわからない → 一応3^dみたいなので予想はつく

# ルンルン数全列挙を考える K個までなら10^5でいける

queue = [1,2,3,4,5,6,7,8,9]

K.times do |i|
  $num = queue.shift

  queue.push($num*10 + $num % 10 - 1 ) unless $num % 10 == 0
  queue.push($num*10 + $num % 10)
  queue.push($num*10 + $num % 10 + 1 ) unless $num % 10 == 9
end

p $num


Measured memory_bytes: 6012
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main(){
    int n, i, res = 0;
    string s;
    char c = 0;
    cin >> n >> s;
    forN(i,n){
        if(c == s[i]) res++;
        c = s[i];
    }
    cout << n - res << endl; 
}

Measured memory_bytes: 512
#include<iostream>

int main(int argc, char const* argv[])
{
	using namespace std;
	
	int n;
	
	cin >> n;
	int* v;
	int* c;
	v = new int[n];
	c = new int[n];
	for( int i=0; i<n; ++i ){
		cin >> v[i];
	}
	
	for( int i=0; i<n; ++i ){
		cin >> c[i];
	}
		
	int total=0;	
	for( int i=0; i<n; ++i ){
		if( v[i]-c[i]>0 ){
			total += v[i]-c[i];
		}
	}
	
	cout << total << endl;
	
	delete [] v;
	delete [] c;
	
	return 0;
}

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

typedef long long ll;

using namespace std;

int main(){
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 0; i < n; i++){
        a[i] = a[i] - (i + 1);
    }

    sort(a, a + n);
    int best_b = a[n/2];

    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += abs(a[i] - best_b);
    }

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

Measured memory_bytes: 1024
n,m=map(int,input().split())
s=input()
ans=[]
p=n
while p>0:
	flag=False
	k=min(p,m)
	for i in range(min(m,p)):
		if s[p+i-k]=="0":
			flag=True
			ans.append(k-i)
			p=p+i-k
			break
	if flag==False:
		print(-1)
		exit()
print(*ans[::-1])

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

// ?????????????????§??±?????????
// ???????????¨??¢?´¢?????????
//for (int p1=1; p1<s; p1++) {
//  int p2 = s-p1;
//}

int main() {
  // p: ?¶?????¨??????´????????????
  // w: ?¶?????¨????100??????
  // n: ?¶?????¨??????´????????????
  int x, y, s;
  while (cin >> x >> y >> s, x && y && s) {
    int ans = 0;

    for (int o1=1; o1<s; o1++) {
      for (int o2=1; o2<s; o2++) {

        int p1 = o1 * (100+x) / 100.0;
        int p2 = o2 * (100+x) / 100.0;

        if (p1+p2 != s) continue;

        int n1 = o1 * (100+y) / 100;
        int n2 = o2 * (100+y) / 100;

        ans = max(ans, n1+n2);

      }
    }

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

Measured memory_bytes: 3080
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
inline int read() {
	int s = 0, w = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') w = -1;
	for (; isdigit(c); c = getchar()) s = (s << 1) + (s << 3) + (c ^ 48);
	return s * w;
}

int main(){
   string s;
   int q,k,u;
   char c;
   cin>>s>>q;
   int len=s.size();
   int flag=0;
   while(q--){
    cin>>u;
    if(u==1){
        flag++;
    }
    else{
        cin>>k>>c;
        if(flag%2==0){
            if(k==1) s.insert(s.begin(),c);
            else s.insert(s.end(),c);
        }
        else{
            if(k==1) s.insert(s.end(),c);
            else s.insert(s.begin(),c);
        }
        len++;
    }
   }
   if(flag%2==1) {
        for(int i=len-1;i>=0;i--)
        printf("%c",s[i]);
   }
   else{
     for(int i=0;i<len;i++)
        printf("%c",s[i]);
   }
    return 0;
}



Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
// vector<vector<int>> A(3, vector<int>(4));
int main() {
    int N,D;
    cin>>N>>D;
    vector<vector<int>> A(N, vector<int>(D));
    rep(i,N){
        rep(j,D){
            cin>>A[i][j];
        }
    }
    int ans=0;
    rep(i,N-1){
            for(int k=i; k<N; k++){
                    if(k==i){
                    }
              		else if(k<i){}
                    else{
                        ld Z=0;
                        ll X=0;
                        rep(j,D){
                            Z+=(A[i][j]-A[k][j])*(A[i][j]-A[k][j]);
                            X+=(A[i][j]-A[k][j])*(A[i][j]-A[k][j]);
                        }
                      	Z=ld(sqrt(Z));
                      	X=ll(sqrt(X));
                        if(ld(X)==ld(Z)){
                            ans++;
                        }
                    }
                }
            }
    cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc074_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, K;
  cin >> N >> K;
  
  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = 0;
  rep(i, N) { ans += min(c[i], K - c[i]) * 2; }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
using vi = vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0


bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}


int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    
    int n, k; cin >> n >> k;
    
    if (k > (n - 1) * (n - 2) / 2) {cout << -1 << endl; return 0;}
    
    //complete graph
    int m = n * (n - 1) / 2;
    int table[101][101] = {0};
    
    if (k == 0) {
        cout << m << endl;
        rep3(i, 1, n + 1) {
            rep3(j, i + 1, n + 1) {
                cout << i << " " << j << endl;
            }
        }
        return 0;
    }
    
    rep3(i, 1, n + 1) {
        rep3(j, i + 1, n + 1) {
            table[i][j] = 1;
        }
    }
    
    cout << m - k << endl;
    
    rep3(i, 1, n) {
        rep3(j, i + 1, n) {
            table[i][j] = 0;
            k--;
            if (k == 0) {
                rep3(i2, 1, n + 1) {
                    rep3(j2, i + 1, n + 1) {
                        if (table[i2][j2]) cout << i2 << " " << j2 << endl;
                    }
                }
                return 0;
            }
        }
    }
    
    
    
    
    
    
}
//cast caution

/*
 
 完全グラフから辺を消してくといけそうと、終わり際気づいた
 
 頂点数5で思いついた
 
 想定解の逆の作業
 
 最後、ウニになるのは気づかんかった
 つまり、どう消していっていいか
 
 最大が何かわかればよかったのか
 
 でも想像できるよな
 辺落としていっても最短距離2が担保されるには
 1つの頂点は全部と繋がってたらいい、と
 
 
 
 
 
 
 
 
 
 参考
 完全グラフから消してく場合の必要十分条件うんぬん
 https://twitter.com/Morojenium/status/1142445502895575040
 
 うに、完全グラフ、補グラフは考えた方がいいらしい
 https://twitter.com/tsuka308/status/1142602335144701952
 
 最近のagcに完全グラフでたらしい
 https://twitter.com/ha15p/status/1142430363433652225
 なんか、それっぽいの
 http://drken1215.hatenablog.com/entry/2019/03/24/110200
 
 消し方で、グラフが連結だけだと不十分
 https://twitter.com/Linus_MK/status/1142604218940846085
 
 
 やっぱ演習足りんな
 */



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

#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)

#define range(i, l, r) for (int i = l; i < (int)(r); ++i)

signed main(){
  int N, M;
  set<string> s;

  cin>>N;

  for(int i = 0; i < N; i++){
    string x;

    cin>>x;
    s.insert(x);
  }

  cin>>M;
  
  for(int i = 0, j = 0; i < M; i++){
    string y;

    cin>>y;
    
    if(s.count(y)) {
      if(j) {
        cout<<"Closed by "<<y<<endl;
      } else {
        cout<<"Opened by "<<y<<endl;
      }
      
      j = !j;
    } else {
      cout<<"Unknown "<<y<<endl;
    }
  }
  
  return 0;
}




Measured memory_bytes: 3232
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int a,b,c;std::cin>>a>>b>>c;
    int X;std::cin>>X;
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==X)ans++;
            }
        }
    }
    std::cout<<ans<<std::endl;
}

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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans;
    if(k<=a) ans = k;
    else if(k<=a+b) ans = a;
    else ans = a - (k-a-b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import math
l=input().split()
N, A, B=[ int(i) for i in l]
s=0
for i in range(N+1):
   q=i/10
   s2=i% 10
   while q >= 1:
       q=math.floor(q)
       s2 += q% 10
       q/=10
   if s2 >= A and s2 <=B:
       s+=i
       
print(s)
   

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

using ll = long long;
#define int long long

using namespace std;

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N, Q;
	string s;
	cin >> N >> Q >> s;
	vector<int> v(N+100, 0);
	rep(i, N) {
		v[i+2] = v[i+1];
		if (s[i] == 'A' && s[i+1] == 'C') v[i+2]++;
	}
	while (Q--) {
		int l, r;
		cin >> l >> r;
		l--;
		if (r - l <= 1) {
			cout << 0 << endl;
		} else {
			int x = v[r] - v[l];
			if (l > 0 && s[l] == 'C' && s[l-1] == 'A') x--;
			cout << x << endl;
		}
	}
}

void solve()
{
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, count = 0;
    cin >> N;
    
    for(int i = 1; i <= N; i++){
        if(i%2 == 1){
            count++;
        }
    }
    
    cout << (double)count / N << endl;
}


Measured memory_bytes: 256
ans = 0

for i in range(int(input())):
    t_i, a_i = list(map(lambda x: int(x), input().split()))

    if i == 0:
        t, a = t_i, a_i

    else:
        n = max((t + t_i - 1) // t_i, (a + a_i - 1) // a_i)
        t = n*t_i
        a = n*a_i

    ans = t + a

print(ans)


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long

signed keisan(int n,int x){
    if(n == 0) return 1;
    else if(n % 2 == 0){
        int t = keisan(n / 2,x);
        return t * t % 1000000007;
    }
    else return x * keisan(n - 1,x) % 1000000007;
}



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

    int n,a,b; cin >> n >> a >> b;

    int ans = keisan(n,2) - 1; 

    int nca = 1;
    int ncb = 1;

    int akaijo = 1,bkaijo = 1;
    for(int i = 0;i < a;i ++){
        akaijo *= i + 1;
        akaijo %= 1000000007;
    }
    for(int i = 0;i < b;i ++){
        bkaijo *= i + 1;
        bkaijo %= 1000000007;
    }

    for(int i = 0;i < a;i ++){
        nca *= n - i;
        nca %= 1000000007;
    }
    for(int i = 0;i < b;i ++){
        ncb *= n - i;
        ncb %= 1000000007;
    }

    nca *= keisan(1000000005,akaijo);
    nca %= 1000000007;
    ncb *= keisan(1000000005,bkaijo);
    ncb %= 1000000007;


    ans -= nca;
    ans = (ans + 1000000007) % 1000000007;
    ans -= ncb;
    ans = (ans + 1000000007) % 1000000007;

    cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    string a, b;
    cin >> a >> b;

    int count = 0;
    for (int i = atoi(a.c_str()); i <= atoi(b.c_str()); i++)
    {
        string numStr = to_string(i);
        string iStr = to_string(i);
        reverse(iStr.begin(), iStr.end());
        if (numStr == iStr)
        {
            count++;
        }
    }
    
    cout << count << endl;
}

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

struct edge
{
	int to;
	int index;
};

std::vector<edge> edges[50];
long long path[50][50];

long long dfs(int v, int last, long long p, const int src)
{
	path[src][v] = p;
	for (auto &e : edges[v])
	{
		if (e.to == last) continue;
		dfs(e.to, v, p | 1LL << e.index, src);
	}
}


template<typename T> T power(T a, T b)
{
	T r = 1;
	while (b > 0)
	{
		if ((b & 1) != 0) r = (r * a);
		a = (a * a);
		b >>= 1;
	}
	return r;
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		--a, --b;
		edges[a].emplace_back(edge{b, i});
		edges[b].emplace_back(edge{a, i});
	}
	int m;
	int bd[20][2];
	scanf("%d", &m);
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		bd[i][0] = u - 1;
		bd[i][1] = v - 1;
	}

	for (int i = 0; i < n; ++i)
	{
		dfs(i, -1, 0, i);
	}

	long long ng = 0;
	for (int i = 1; i < 1 << m; ++i)
	{
		long long white = 0;
		for (int j = 0; j < m; ++j)
		{
			if (((i >> j) & 1) == 0) continue;
			white |= path[bd[j][0]][bd[j][1]];
		}
		int fw = __builtin_popcountll(white);
		long long pat = power(2LL, (long long)(n - 1 - fw));
		if (__builtin_popcount(i) & 1) ng += pat;
		else ng -= pat;
	}
	printf("%lld\n", power(2LL, (long long)(n - 1)) - ng);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  int N,M; cin >> N >> M;
  priority_queue<pii,vector<pii>,greater<pii>> pque;
  priority_queue<int> que;
  for(int i=0;i<N;i++){
    int a,b; cin >> a >> b;
    pque.push(make_pair(a,b));
  }
  int ans = 0;
  for(int i=1;i<=M;i++){
    while(!pque.empty()){
      pii p = pque.top();
      if(p.first>i) break;
      pque.pop();
      que.push(p.second);
    }
    if(!que.empty()){
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4744
#include<bits/stdc++.h>
#define N 100009
#define P pair<int,int>
#define mm make_pair
using namespace std;
typedef long long ll;
int n,f[N];
inline ll rd(){
    ll x=0;char c=getchar();bool f=0;
    while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return f?-x:x;
}
int find(int x){return f[x]=f[x]==x?x:find(f[x]);}
set<int>s[N];
map<P,int>mp;
queue<P>q;
inline P cl(int x,int y){return mm(min(x,y),max(x,y));}
inline void add(int u,int v){
    s[u].insert(v);s[v].insert(u);
    P now=cl(u,v);
    if(mp.find(now)==mp.end())mp[now]=1;
    else q.push(now);
}
int main(){
    n=rd();
    int x,y;
    for(int i=1;i<=n*2-2;++i){
        x=rd();y=rd();
        add(x,y);
    }
    int ans=0;
    for(int i=1;i<=n;++i)f[i]=i;
    while(!q.empty()){
        P now=q.front();q.pop(); 
        int u=find(now.first),v=find(now.second);
        if(u==v)continue;
        ans++;
        if(s[u].size()>s[v].size())swap(u,v);
        f[u]=v;
        mp.erase(mm(u,v));s[v].erase(u);
        for(set<int>::iterator it=s[u].begin();it!=s[u].end();++it){
            int to=*it;
            int x=v,y=find(to);
            if(v==y)continue;
            mp.erase(cl(u,y));
            P now=cl(x,y);
            if(mp.find(now)==mp.end())mp[now]=1;
            else q.push(now);
            s[v].insert(y);
        }
        s[u].clear();
    }
    if(ans==n-1)puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 36608