akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll l, r, d;
	cin >> l >> r >> d;
	cout << r / d - (l-1) / d << endl;

	return 0;
}

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

#define int long long

int a[310];
int memo[310][310][310];
int n;

int dp(int i, int k, int l){
    if(i == n){
        return 0;
    }

    if(memo[i][k][l] != -1){
        return memo[i][k][l];
    }

    int ans = LLONG_MAX;

    if(k > 0){
        ans = min(ans, dp(i+1, k-1, l+1));
    }


    if(i-l-1 < 0 || a[i-l-1] < a[i]){
        ans = min(ans, dp(i+1, k, 0) + a[i]-(i-l-1 >= 0 ? a[i-l-1] : 0));
    }else{
        ans = min(ans, dp(i+1, k, 0));
    }

    return memo[i][k][l] = ans;
}

signed main(){
    int k;
    cin >> n >> k;

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

    memset(memo, -1, sizeof(memo));

    cout << dp(0, k, 0) << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};

struct edge{
  int to,we;
};

int main(){

  int n;
  cin >> n;
  int dist[n];
  int color[n];
  vector<vector<edge>> v(n);
  REP(i,n-1){
    int fr,to,we;cin >> fr >> to >> we;
    fr--,to--;
    v[fr].push_back({to,we});
    v[to].push_back({fr,we});
  }
  queue<int> que;
  que.push(0);
  FILL(dist,n,-1);FILL(color,n,-1);
  dist[0] = 0;color[0] = 0;
  while(!que.empty()){
    int ov = que.front();que.pop();
    for(auto nv : v[ov]){
      if(dist[nv.to] != -1)continue;
      dist[nv.to] = dist[ov] + nv.we;
      if(nv.we & 1)color[nv.to] = 1 - color[ov];
      else color[nv.to] = color[ov];
      que.push(nv.to);
    }
  }
  REP(i,n)cout << color[i] << endl;

  return 0;
}


Measured memory_bytes: 9216
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        Date baseDate = sdf.parse("2019/05/01");
        Date inDate = sdf.parse(s);
        System.out.println(inDate.before(baseDate) ? "Heisei" : "TBD");
    }
}


Measured memory_bytes: 22224
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    size_t N, M; cin >> N >> M;

    set<size_t> city;
    vector<size_t> city_info[N + 1];
    vector<size_t> p(M), y(M);
    for (size_t i = 0; i < M; ++i) {
        cin >> p[i] >> y[i];
        city.insert(p[i]);
        city_info[p[i]].emplace_back(y[i]);
    }

    map<pair<size_t, size_t>, size_t> mp;
    for (auto &ci: city) {
        sort(city_info[ci].begin(), city_info[ci].end());
        for (size_t i = 0; i < city_info[ci].size(); ++i) {
            mp[make_pair(ci, city_info[ci][i])] = i + 1;
        }
    }

    for (size_t i = 0; i < M; ++i) {
        cout << setw(6) << setfill('0') << p[i];
        cout << setw(6) << setfill('0') << mp[make_pair(p[i], y[i])] << "\n";
    }

    return 0;
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int N;
vector<int> A, L;

int solve(){
  L[0] = A[0];
  int length = 1;
  for (int i = 1; i < N; i++) {
    if (L[length - 1] <= A[i]) {
      L[length] = A[i];
      length++;
    } else {
      auto iter = upper_bound(L.begin(), L.begin() + length, A[i]);
      //L[L.end() - iter] = A[i];
      L[iter - L.begin()] = A[i];
    }
    // for (int i = 0; i < length; i++) {
    //   cout << L[i] << " ";
    // }
    // cout << "\n";
  }

  return length;
}
int main() {
  cin >> N;
  A.resize(N);
  L.resize(N, INT_MAX);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] = - A[i];
  }
  cout << solve() << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
int h,w,i;
  cin >> h >> w;
vector<string> s(h);
  for(i=0;i<h;++i)
  {
  cin >> s.at(i);
  cout << s.at(i) << endl;
  cout << s.at(i) << endl;
  }
return 0;}

Measured memory_bytes: 3556
#!/usr/bin/python
import sys,heapq

INF=2000000000000
def shortestPath(g,dist,prev):
	n = len(g)-1
	h = [INF]*n+[0]
	for k in range(n+1):
		for i in range(n+1):
			for e in g[i]:
				if h[e[1]]<INF and e[0]<INF and h[e[2]] > h[e[1]] + e[0]:
					h[e[2]] = h[e[1]] + e[0]
					if k==n: return False # negative cycle
	for i in range(n):
		for e in g[i]:
			e[0]+=h[i]-h[e[2]]
	for s in range(n):
		Q=[]
		heapq.heappush(Q,[0,s,s])
		while Q:
			e = heapq.heappop(Q)
			if prev[s][e[2]]!=-2: continue
			prev[s][e[2]] = e[1]
			for f in g[e[2]]:
				if e[0]<INF and f[0]<INF and dist[s][f[2]] > e[0] + f[0]:
					dist[s][f[2]] = e[0] + f[0]
					heapq.heappush(Q,[(e[0] + f[0]),f[1],f[2]])
		for u in range(n):
			if dist[s][u]<INF: dist[s][u] += h[u] - h[s]
	return True

V,E=map(int,raw_input().split())
g=[[] for i in range(V+1)]
dist=[[INF]*V for i in range(V)]
prev=[[-2]*V for i in range(V)]
for i in range(V): g[i].append([0,i,i])
for i in range(V): g[V].append([0,V,i])
for i in range(E):
	s,t,e=map(int,raw_input().split())
	g[s].append([e,s,t])
if not shortestPath(g,dist,prev):
	print("NEGATIVE CYCLE")
else:
	for i in range(V):
		print(' '.join("INF" if dist[i][j]>=INF else str(dist[i][j]) for j in range(V)))

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct StarrySkyTree {
  vector<ll> seg, lazy;
  ll size;
  StarrySkyTree() {}
  StarrySkyTree(ll n) {
    init(n);
  }
  void init(ll n) {
    size = 1;
    while (size < n) size *= 2;
    seg.resize(size * 2);
    lazy.resize(size * 2);
    for(int i = 0; i < size*2; i++)seg[i]=INF;
  }
  void update(ll k,ll v){
    k += size-1;
    seg[k] = v;
    while(k > 0){
      k = (k - 1)/2;
      seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
    }
  }
  void push(ll k,ll l,ll r) {
    seg[k] += lazy[k];
    if (r - l > 1) {
      lazy[k * 2 + 1] += lazy[k];
      lazy[k * 2 + 2] += lazy[k];
    }
    lazy[k] = 0;
  }
  void add(ll a,ll b, ll v, ll k, ll l,ll r) {
    push(k, l, r);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      lazy[k] += v;
      push(k, l, r);
    } else {
      add(a, b, v, k * 2 + 1, l, (l + r) / 2);
      add(a, b, v, k * 2 + 2, (l + r) / 2, r);
      seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
    }
  }
  void add(ll a,ll b, ll v) {
    add(a, b, v, 0, 0, size);
  }
  ll query(ll a,ll b, ll k, ll l, ll r) {
    push(k, l, r);
    if (r <= a || b <= l) return INF*10;
    if (a <= l && r <= b) return seg[k];
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl,vr);
  }
  ll query(ll a, ll b) {
    return query(a, b, 0, 0, size);
  }
};

struct query{
  ll type,d,s,t;
  ll idx;
};
bool operator<(const query& a,const query& b){
  if(a.d==b.d)return a.type > b.type;
  else return a.d < b.d;
}

ll n,m,q;
string res[101010];
vector<query> qs;

int main(){
  cin>>n>>m>>q;
  rep(i,m){
    ll d,s,t;
    cin>>d>>s>>t;
    s--; t--;
    qs.push_back((query){0,d,s,t,-1});
  }
  rep(i,q){
    ll d,s,t;
    cin>>d>>s>>t;
    s--;t--;
    qs.push_back((query){1,d,s,t,i});
  }
  sort(all(qs));
  StarrySkyTree sgt;
  sgt.init(n-1);
  rep(i,n-1)sgt.update(i,0);
  rep(i,qs.size()){
    if(qs[i].type==0){ // add
      sgt.add(qs[i].s,qs[i].t,1);
    }else{
      ll minv=sgt.query(qs[i].s,qs[i].t);
      if(qs[i].s<=qs[i].t&&minv==0) res[qs[i].idx]="No";
      else res[qs[i].idx]="Yes";
    }
  }
  rep(i,q)cout<<res[i]<<endl;
  return 0;
}



Measured memory_bytes: 20488
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >>n;
	auto f = [&](int x,int y){
		int ret = 0;
		while(x){
			x /= 10;
			ret++;
		}
		int tmp = 0;
		while(y){
			y /= 10;
			tmp++;
		}
		return max(tmp,ret);
	};
	int ret = 1e18;
	for(int i = 1;i*i <= n;i++){
		if(n%i == 0){
			ret = min(ret,f(i,n/i));
		}
	}
	cout << ret << endl;

	return 0;
}

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

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

using namespace std;


struct Node{
    int pos;
    ll cost;
    bool operator< (const Node &r) const{
        return cost < r.cost;
    }
};

int main(){
    int k, t;
    cin >> k >> t;
    int a[t];
    rep(i, t)   cin >> a[i];
    priority_queue<Node> que;
    rep(i, t)   que.push({i, a[i]});
    int pos = -1;
    while(!que.empty()){
        Node n = que.top(); que.pop();
        if(n.pos == pos){
            if(que.empty()){
                que.push(n);
                break;
            }
            Node nn = que.top(); que.pop();
            if(nn.cost == 0){
                que.push(n);
                break;
            }
            else{
                que.push({nn.pos, nn.cost-1});
                que.push({n.pos, n.cost-1});
            }
        }
        else if(0 < n.cost){
            que.push({n.pos, n.cost-1});
        }
        pos = n.pos;
    }

    ll sum = 0;
    while(!que.empty()){
        Node n = que.top(); que.pop();
        sum += n.cost;
    }

    cout << sum << 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++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
typedef pair<int,PP> PPP;
struct edge { int to;  int cost; };

signed main() {
	char c;
	cin >> c;

	if(c == 'A'){
		cout << 'T' << endl;
	}
	else if(c == 'T'){
		cout << 'A' << endl;
	}
	else if(c == 'G'){
		cout << 'C' << endl;
	}
	else{
		cout << 'G' << endl;
	}
	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 FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  long long A;
  long double B;
  cin >> A >> B;
  //B *= 100;
  //ll Ans = A * (ll)(floor(B)+0.001);
  //cout << Ans / 100 << endl;
  cout << (ll)(A * B+0.001) << endl;
}

Measured memory_bytes: 3720
from bisect import bisect
from fractions import gcd


def solve(N, SP):
    _x = list(map(int, input().split()))
    diff = []
    _x.sort()
    sp_pos = bisect(_x, SP)

    x = _x[0:sp_pos] + [SP] + _x[sp_pos:]

    for i in range(N):
        diff.append(x[i+1]-x[i])

    if len(diff) == 1:
        ans = diff[0]
    else:
        ans = diff[1]-diff[0]
        for d in diff[1:]:
            if ans == 1:
                break
            else:
                ans = gcd(ans, d)
    return ans


if __name__ == '__main__':
    n, sp = map(int, input().split())
    print(solve(n, sp))


Measured memory_bytes: 16324
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int V,E;
    cin >> V >> E;
    vector<int> s(E);
    vector<int> t(E);
    vector<int> res;
    vector< vector<int> > v(V);
    vector< vector<int> > rv(V);
    vector<bool> used(V,false);
    int count = 0;

    REP(i,E) scanf("%d%d",&s[i],&t[i]);
    REP(i,E) v[s[i]].PB(t[i]);
    REP(i,E) rv[t[i]].PB(s[i]);
    REP(i,V){
	REP(j,V){
	    if(used[j]) continue;
	    if(rv[j].size() == 0){
		res.PB(j);
		used[j] = true;
		int size = v[j].size();
		REP(k,size) rv[v[j][k]].erase(rv[v[j][k]].begin());
		fill(ALL(v[j]),0);
		break;
	    }
	}
    }

    REP(i,V) cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 2852
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll 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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int n; cin >> n;
	vector<vector<int>>txy(n, vector<int>(3));
	rep(i, n)rep(j, 3)cin >> txy[i][j];
	pair<int, int> nxy = make_pair(0, 0);
	bool ans = true;
	int cnt = 0;
	rep(i, n) {
		int dt = abs(nxy.first - txy[i][1]) + abs(nxy.second - txy[i][2]);
		int t = txy[i][0] - cnt;
		if (dt > t) {
			ans = false;
			break;
		}
		int is = t - dt;
		if (is % 2 != 0) {
			ans = false;
			break;
		}
		nxy = make_pair(txy[i][1], txy[i][2]);
		cnt = txy[i][0];
	}
	cout << (ans ? "Yes" : "No") << "\n";

	return 0;
}

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

using namespace std;

int main(){
	string O, E;
	cin >> O >> E;
	for(int i = 0; i < E.size(); i++){
		cout << O[i] << E[i];
	}
	if(O.size() - E.size() == 1) cout << O[O.size() - 1];
	
	return 0;
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const N = lines[0] - 0
    const a = lines[1].split(' ').map(Number)

    a.sort((a, b) => a - b)

    const dp = Array(a[N - 1] + 2).fill(0)
    for (let i = 0; i < N; i++) {
        dp[a[i]]++
    }

    const sum = []
    sum[0] = dp[0] + dp[1]
    for (let i = 1; i < dp.length - 1; i++) {
        sum[i] = dp[i - 1] + dp[i] + dp[i + 1]
    }

    console.log(Math.max(...sum))

})(input)


Measured memory_bytes: 43928
x,y =  map(int,input().split())

wk1 = y - 2 * x
wk2 = 4 * x - y
res = 'Yes'
if wk1 < 0 :
   res = 'No'

if wk2 < 0 :
   res = 'No'

if wk1 % 2 > 0:
   res = 'No'

if wk2 % 2 > 0:
   res = 'No'

print(res)



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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> d(n, vector<int>(2));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> d.at(i).at(j);
    }
  }
  
  vector<bool> doublet(n, false);
  for (int i = 0; i < n; i++) {
    if (d.at(i).at(0) == d.at(i).at(1)) doublet.at(i) = true;
  }
  
  bool judg(false);
  for (int i = 0; i < n - 2; i++) {
    if (doublet.at(i)) {
      if (doublet.at(i + 1)) {
        if (doublet.at(i + 2)) judg = true;
      }
    }
  }
  
  if (judg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

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

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	for ( int i = 1; i < 4; i++ )
	{
		if ( S[i] == S[i - 1] )
		{
			cout << "Bad" << endl;
			return ( 0 );
		}
	}

	cout << "Good" << endl;

	return ( 0 );
}


Measured memory_bytes: 888
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

constexpr int D = 365;
constexpr int K = 26;
int c[400];
int s[400][26];
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int _;
  cin >> _;
  for(int i = 0; i < K; i++) cin >> c[i];
  for(int i = 0; i < D; i++)
    for(int j = 0; j < K; j++) {
      cin >> s[i][j];
    }
  int f[D] = {};
  for(int i = 0; i < D; i++) {
    for(int j = 0; j < K; j++) f[j] += c[j];
    using P = pair<int, int>;
    pair<int, int> best(-1, -1);
    for(int j = 0; j < K; j++) best = max(best, P(f[j] + s[i][j], j));
    cout << best.second + 1 << endl;
    f[best.second] = 0;
  }
  return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int cou = count(s.begin(), s.end(), '.');
    int min = cou;
    for (auto c : s) {
        if (c == '#')
            cou++;
        else
            cou--;
        if (cou < min)
            min = cou;
    }
    cout << min << endl;
}

Measured memory_bytes: 644
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.D
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			var n = cin.NextInt();
			var q = cin.NextInt();
			var connected = new List<List<int>>();
			var seen = new List<bool>();
			var ans = new List<int>();
			for (int i = 0; i < n; i++)
			{
				connected.Add(new List<int>());
				seen.Add(false);
				ans.Add(0);
			}
			for (int i = 0; i < n - 1; i++)
			{
				int a = cin.NextInt();
				int b = cin.NextInt();
				connected[a - 1].Add(b - 1);
				connected[b - 1].Add(a - 1);
			}

			for (int i = 0; i < q; i++)
			{
				int p = cin.NextInt();
				int x = cin.NextInt();
				ans[p - 1] += x;
			}

			var qu = new Queue<int>();
			qu.Enqueue(0);
            while (qu.Count > 0)
            {
				var item = qu.Dequeue();
				seen[item] = true;
				foreach (var e in connected[item])
                {
					if (seen[e]) continue;
					qu.Enqueue(e);
					ans[e] += ans[item];
                }
            }

			Console.WriteLine(string.Join(" ", ans.ToArray()));

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

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

int32_t main() {
  long long a, b, c;
  cin>>a>>b>>c;
  long long k; cin>>k;
  long long s = a + b + c;
  long long mx = max({a, b, c});
  s -= mx;
  long long ans = s + mx * (1LL << k);
  cout<<ans<<endl;
}

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

int s[200005];
int main(void){
	int N,A,B,C,D;
	cin >> N >> A >> B >> C >> D;
	A--,B--,C--,D--;
	string S;
	int As=A,Bs=B;
	cin >> S;
	int Slen = S.size();
	bool aok = true;
	while(A!=C){
		if(S[A+1]=='.')A++;
		else if(S[A+2]=='.')A+=2;
		else {
			aok = false;
			break;
		}
	}
	bool bok = true;
	while(B!=D){
		if(S[B+1]=='.')B++;
		else if(S[B+2]=='.')B+=2;
		else {
			bok = false;
			break;
		}
	}
	if(aok*bok ==0){
		cout <<"No"<<endl;
	}else if(C<D){
		cout <<"Yes"<<endl;
	}else if(C>D){
		bool swap = 0;
		for(int i=Bs;i<=D;i++){
			if(S[i-1]=='.'&&S[i]=='.'&&S[i+1]=='.'){
				swap =1;
				break;
			}
		}
		if(swap){
			cout <<"Yes"<<endl;
			return 0;
		}else{
			cout <<"No"<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin>>n;
  x=(n-n%4)/4;
  if(n%4==0||n%7==0||n%4==3&&x>=1||n%4==2&&x>=3||n%4==1&&x>=5)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b){
		d=a;a=b;b=d;
	}
	if(b>c){
		d=b;b=c;c=d;
	}
	if(a>b){
		d=a;a=b;b=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	if(a==b) cout << a+b << endl;
	else if(a>b) cout << a*2-1 << endl;
	else cout << b*2-1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	// Tree := (Tree Tree) | Leaf
	String t;
	int idx;
	int nidx;
	int ls[];
	int n;
	int ps[];
	Tree T;
	int cnt;

	Tree tree() {
		if (t.charAt(idx) >= '0' && t.charAt(idx) <= '9') {
			int v = t.charAt(idx) - '0';
			idx++;
			cnt++;
			return new Tree(v);
		}
		if (t.charAt(idx) == '(')
			idx++;
		Tree l = tree();
		idx++;
		Tree r = tree();
		if (t.charAt(idx) == ')')
			idx++;
		return new Tree(l, r);
	}

	void run() throws Exception {
		while (true) {
			t = sc.nextLine();
			if (t.equals("END"))
				break;
			idx = 0;
			cnt = 0;
			n = sc.nextInt();
			ls = new int[n];
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				int d = sc.nextInt();
				ls[i] = (a << 3) + (b << 2) + (c << 1) + d;
			}
			sc.nextLine();
			T = tree();
			ps = new int[cnt - 1];
			System.out.println(solve(0));
		}
	}

	int solve(int k) throws Exception {
		int res = 0;
		if (k == cnt - 1) {
			nidx = 0;
			int set = check(T);
			if (set == 15)
				return 1;
			else
				return 0;
		}
		for (int i = 0; i < 3; i++) {
			ps[k] = i;
			res += solve(k + 1);
		}
		return res;
	}

	int check(Tree tr) throws Exception {
		if (tr.v > 0) {
			return ls[tr.v - 1];
		}
		Tree l = tr.l;
		Tree r = tr.r;
		int res = 0;
		switch (ps[nidx++]) {
		case 0:
			res = check(l) & check(r);
			break;
		case 1:
			res = check(l) | check(r);
			break;
		case 2:
			res = check(l) ^ check(r);
			break;
		}
		return res;
	}

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

}

class Tree {
	Tree l;
	Tree r;
	int v;

	Tree(Tree l, Tree r) {
		this.l = l;
		this.r = r;
		v = -1;
	}

	Tree(int v) {
		this.v = v;
	}

	public String toString() {
		if (v < 0) {
			return "(" + l.toString() + " " + r.toString() + ")";
		}
		return v + "";
	}
}

Measured memory_bytes: 32184
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll mod=998244353;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }


int main()
{
	ll a,b,n;
	cin>>a>>b>>n;
	ll x=min(b-1,n);
	cout<<(a*x)/b;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<algorithm>
 */
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int N;
vector<pair<double, double> > v;
using pdd = pair<double, double>;
void koch(int n, pdd a, pdd b) {
    if (n == N) {
        v.eb(make_pair(a.F, a.S));
        return;
    }
    double sx = a.F + (b.F - a.F) / 3;
    double sy = a.S + (b.S - a.S) / 3;
    double tx = b.F - (b.F - a.F) / 3;
    double ty = b.S - (b.S - a.S) / 3;
    double theta = M_PI / 3;
    double s = tx - sx;
    double t = ty - sy;
    // https://www.buildinsider.net/small/bookkinectv2/0803
    double ux = sx + s * cos(theta) - t * sin(theta);
    double uy = sy + s * sin(theta) + t * cos(theta);
    koch(n + 1, {a.F, a.S}, {sx, sy});
    koch(n + 1, {sx, sy}, {ux, uy});
    koch(n + 1, {ux, uy}, {tx, ty});
    koch(n + 1, {tx, ty}, {b.F, b.S});
}
int main() {
    cin >> N;
    koch(0, {0, 0}, {100, 0});
    v.eb(make_pair(100, 0));
    rep(i, SZ(v)) cout << FIX(4) << v[i].F << " " << v[i].S << endl;
}



Measured memory_bytes: 3364
#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);
  char* str = new char[N + 1];
  scanf("%s", str);

  int* numE = new int[N];
  for(int i=0;i<N;i++) {
    numE[i] = 0;
  }

  int sumE = 0, sumW = 0;
  for(int i=0;i<N;i++) {
    if(str[i] == 'E') {
      sumE++;
    }
    if(str[i] == 'W') {
      sumW++;
    }
  }

  int tmp = 0;
  for(int i=0;i<N;i++) {
    if(str[i] == 'E') {
      numE[i] = tmp;
      tmp++;
    }
  }

  int min = N;
  for(int i = 1;i<N - 1;i++) {
    tmp = (i - 1 - numE[i]) + (sumE - numE[i+1]);
    if(min > tmp) {
      min = tmp;
    }
  }
  if(str[0] == 'E') {
    if(min > (sumE - 1)) {
      min = sumE - 1;
    }
  } else {
    if(min > sumE) {
      min = sumE;
    }
  }
  if(str[N-1] == 'W') {
    if(min > (sumW - 1)) {
      min = sumW - 1;
    }
  } else {
    if(min > sumW) {
      min = sumW;
    }
  }

  printf("%d\n", min);

  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

void Output_Chessboard(int H, int W)
{
	int i, j;

	for (i = 0; i < H; i++)
	{
		for (j = 0; j < W; j++)
		{
			if ((i % 2) == 0)
			{
				if ((j % 2) == 0)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			else
			{
				if ((j % 2) == 0)
				{
					printf(".");
				}
				else
				{
					printf("#");
				}
			}

		}

		printf("\n");
	}

	printf("\n");
}

int main(void)
{
	int H, W;
	
	for (;;)
	{
		scanf("%d %d", &H, &W);

		if ((H == 0) && (W == 0))
		{
			break;
		}

		Output_Chessboard(H, W);
	}

	return 0;
}


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

int main()
{
    int N;
    string S;
    int x = 0, ans = 0;
    cin >> N >> S;

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'I')
        {
            x++;
            ans = max(ans, x);
        }
        else
        {
            x--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int partition(int *,int,int);
void quicksort(int *,int,int);
int main(){
  int i,n,p=0,par;
  scanf("%d",&n);
  int r=n-1;
  int A[n];
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  par = partition(A,p,r);
  for(i=0;i<n;i++){
    if(i==n-1 && i != par) printf("%d\n",A[i]);
    else if(i==par) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }
  return 0;
}
int partition(int *A,int p,int r){
  int j,temp;
  int x = A[r];
  int i = p-1;
  for(j = p;j<=r-1;j++){
    if(A[j] <= x){
      i = i+1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  return i+1;
}


Measured memory_bytes: 2104
def dist(coords1,coords2):
    dx = coords1[0]-coords2[0]
    dy = coords1[1]-coords2[1]

    dx = dx**2
    dy = dy**2

    return (dx+dy)**0.5

def findDist(a, n,ans,coords):
    #print(a)
    for i in range(len(a)-1):
        ans[0] += dist(coords[a[i]-1],coords[a[i+1]-1])
    

def heapPermutation(a, size, n,coords,ans): 
    if (size == 1): 
        findDist(a, n,ans,coords) 
        return
  
    for i in range(size): 
        heapPermutation(a,size-1,n,coords,ans); 
        if size&1: 
            a[0], a[size-1] = a[size-1],a[0] 
        else: 
            a[i], a[size-1] = a[size-1],a[i]

def fact(n):
    count = 1
    for i in range(1,n+1):
        count *= i

    return count

def main():
    n = int(input())
    arr = []
    for i in range(1,n+1):
        arr.append(i)

    coords = []
    for i in range(n):
        x,y = map(int,input().split())
        coords.append((x,y))

    ans = [0]
    heapPermutation(arr,n,n,coords,ans)

    total = fact(n)

    #print(total)
    print(ans[0]/total)

main()


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class E
{
	public static readonly int FALSE = 0;
	public static readonly int TRUE = 1;

	public static void Main()
	{
		long mod = 1000000007;
		string L = GetString();
		long[,] dp = new long[L.Length + 1, 2]; 

		dp[1, FALSE] = 2;
		dp[1, TRUE] = 1;

		for(int i = 1; i < L.Length; i++)
		{
			if(L[i] == '0')
			{
				dp[i+1, FALSE] = dp[i, FALSE];
				dp[i+1, TRUE] = (dp[i, TRUE] * 3) % mod;
			}
			else
			{
				dp[i+1, FALSE] = (dp[i, FALSE] * 2) % mod;
				dp[i+1, TRUE] = (dp[i, TRUE] * 3 + dp[i, FALSE]) % mod;
			}
		}

		Console.WriteLine((dp[L.Length, FALSE] + dp[L.Length, TRUE]) % mod);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 15328
N, Q = map(int, input().split())
S = list(input())

count_list = [0]*N
count = 0
s_1 = S[0]
s_2 = ''
for i in range(1, N):
    s_2 = S[i]
    if s_1 == 'A' and s_2 == 'C':
        count += 1
    count_list[i] = count
    s_1 = s_2
# print(count_list)

for _ in range(Q):
    l, r = map(int, input().split())
    print(count_list[r-1]-count_list[l-1])


Measured memory_bytes: 6796
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;

string s;
string t;
int p[100005],q[100005];
void query(int a,int b,int c,int d){
    int k = b-a+1+(p[b]-p[a-1]);
    int t = d-c+1+(q[d]-q[c-1]);
    //cout << k << " " << p[b]-p[a-1] << endl;
    //cout << t << " " << q[d]-q[c-1] << endl;
    if(k%3==t%3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}
int main(){
    int qq;
    cin >> s >> t >> qq;
    
    rep(i,s.size()){
        p[i+1]=p[i];
        if(s[i]=='A')p[i+1]++;
    }
    rep(i,t.size()){
        q[i+1]=q[i];
        if(t[i]=='A')q[i+1]++;
    }
    rep(i,t.size()+1){
        //cout << i << " "  << q[i] << endl;
    }
    int a,b,c,d;
    rep(i,qq){
        cin >> a  >> b >> c >> d;
        query(a,b,c,d);
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = 5042 + 17;
const int mod = (int)1e9 + 7;

int n, l;
string s;

void read()
{
	cin >> n >> s;
	l = s.size();
}

int dp[MAXN][MAXN];

int pw(int x, int p)
{
	int ret = 1;
	while(p)
	{
		if(p & 1) ret = (ret * 1ll * x) % mod;
		x = (x * 1ll * x) % mod;
		p >>= 1;
	}

	return ret;
}

void solve()
{
	dp[0][0] = 1;
	for(int i = 0; i < n; i++)
		for(int c = 0; c < n; c++)
			if(dp[i][c])
			{
				dp[i + 1][max(c - 1, 0)] = (dp[i + 1][max(c - 1, 0)] + dp[i][c]) % mod;
				dp[i + 1][c + 1] = (dp[i + 1][c + 1] + 2ll * dp[i][c]) % mod;
			}

	int answer = (dp[n][l] * 1ll * pw(pw(2, l), mod - 2)) % mod;	
	cout << answer << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 97536
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 924844033;
const int MAXN=530010, LOG=19;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll A[MAXN], B[MAXN];
ll F[MAXN], I[MAXN];
int sz[MAXN], rev[MAXN];
vector<int> G[MAXN];

int dfs(int node, int par){
	for (int v:G[node]) if (v!=par) sz[node]+=dfs(v, node);
	return ++sz[node];
}

ll powmod(ll a, ll b){
	ll res=1;
	for (; b; b>>=1, a=a*a%mod) if (b&1) res=res*a%mod;
	return res;
}

ll C(ll n, ll r){
	if (r<0 || r>n) return 0;
	return F[n]*I[r]%mod*I[n-r]%mod;
}

void NTT(ll* A, bool inv){
	int n=(1<<LOG);
	for (int i=1; i<n; i++){
		rev[i]=(rev[i>>1]>>1)|((i&1)<<(LOG-1));
		if (rev[i]<i) swap(A[i], A[rev[i]]);
	}
	for (int len=1; len<n; len<<=1){
		ll wlen=powmod(5, mod/2/len);
		if (inv) wlen=powmod(wlen, mod-2);
		for (int i=0; i<n; i+=(len<<1)){
			ll w=1;
			for (int j=0; j<len; j++){
				ll x=A[i+j], y=A[i+len+j]*w;
				A[i+j]=(x+y)%mod;
				A[i+j+len]=(x-y)%mod;
				w=w*wlen%mod;
			}
		}
	}
	if (inv){
		ll invn=powmod(n, mod-2);
		for (int i=0; i<n; i++) A[i]=(A[i]*invn)%mod;
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	F[0]=1;
	for (int i=1; i<MAXN; i++) F[i]=F[i-1]*i%mod;
	I[MAXN-1]=powmod(F[MAXN-1], mod-2);
	for (int i=MAXN-1; i; i--) I[i-1]=I[i]*i%mod;
	
	cin>>n;
	for (int i=1; i<n; i++){
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(1, 1);
	for (int i=2; i<=n; i++){
		A[sz[i]]++;
		A[n-sz[i]]++;
	}
	for (int i=0; i<=n; i++) A[i]=A[i]*F[i]%mod;
	for (int i=0; i<=n; i++) B[i]=I[n-i];
	
	NTT(A, 0);
	NTT(B, 0);
	for (int i=0; i<MAXN; i++) A[i]=A[i]*B[i]%mod;
	NTT(A, 1);
	
	for (int k=1; k<=n; k++){
		ans=A[n+k]*I[k]%mod;
		ans=(n*C(n, k) - ans)%mod;
		if (ans<0) ans+=mod;
		cout<<ans<<'\n';
	}
	
	return 0;
}
/*
4
1 2
2 3
3 4

*/

Measured memory_bytes: 52224
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <stack>

using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
const int MaxN = 1e6;

int a,b,x;

int main()
{
	cin >> a >> b >> x;
	if(x-a>=0 && x-a <=b)
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
    return 0;
}


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

ll power(ll X,ll Y,ll P){
  vector<ll> digit2(1000),XX(1000);
  ll I,N,mod;
  I=0;
  
  while(Y!=0){
    digit2.at(I)=Y%2;
    Y=Y/2;
    I++;
  }
  N=I;
  
  XX.at(0)=X%P;
  for(I=1;I<N;I++){
    XX.at(I)=(XX.at(I-1)*XX.at(I-1))%P;
  }
  
  mod=1;
  for(I=0;I<N;I++){
    if(digit2.at(I)==1){
      mod=(mod*XX.at(I))%P;
    }
  }
  
  if(mod<0){
    mod=mod+P;
  }
  
  return mod;
}

int main(){
  ll n,k;
  cin >> n >> k;
  if(k==1){
    cout << n << endl;
  }else{
    ll i,s=n-k+1,p=1000000007;
    cout << s << endl;
    for(i=2;i<=k;i++){
      s=(s*(k-i+1)*(n-k-i+2))%p;
      s=(s*power(i*(i-1),p-2,p))%p;
      cout << s << endl;
    }
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10; //N
const ll MOD = 1e9 + 7;
int N, M, K, Q;
int P[MAX];
ll cnt[MAX], ans[MAX];
pair<int, int> A[MAX];

int _find(int x) { return P[x] == x ? x : P[x] = _find(P[x]); }
void _union(int x, int y) { 
	cnt[_find(x)] += cnt[_find(y)];
	P[_find(y)] = _find(x);
}

int main()
{
	int i, j, k;
	scanf("%d%d", &N, &M);
	for (i = 1; i <= N; ++i) {
		P[i] = i;
		cnt[i] = 1LL;
	}
	for (i = 1; i <= M; ++i) {
		scanf("%d %d", &A[i].first, &A[i].second);
	}
	ll cur = 0;
	for (i = 1; i <= N-1; ++i) {
		cur += (ll)i;
	}
	for (i = M; i >= 1; --i) {
		ans[i] = cur;
		int x = _find(A[i].first);
		int y = _find(A[i].second);
		if(x != y) {
			cur -= cnt[x] * cnt[y];
			_union(x, y);
		}
	}
	for (i = 1; i <= M; ++i) printf("%lld\n", ans[i]);
}

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

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

    string S;
    cin >> S;

    vector<set<char>> fmemo(N), bmemo(N);
    set<char> s;
    for(int i = 0; i < N; ++i){
        s.emplace(S[i]);
        fmemo[i] = s;
        
    }

    set<char> t;
    for(int i = N-1; i >= 0; --i){
        t.emplace(S[i]);
        bmemo[i] = t;
    }

    set<string> u;
    for(int i = 1; i < N-1; ++i){
        for(auto a : fmemo[i-1]){
            string sa = {a};
            for(auto b : bmemo[i+1]){
                string sb = {b};

                string c = sa+S[i]+sb;
                u.emplace(c);
            }
        }
    }

    cout << u.size() << endl;
}

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

int main(){
int d,t,s;cin>>d>>t>>s;
if(d<=s*t){
    cout<<"Yes";
}else{
    cout<<"No";
}

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	long int a[10005], b[10005];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	long int acnt = 0;
	long int bcnt = 0;
	for(int i=0;i<n;i++){
		if(a[i]-b[i]<0){
			acnt += b[i]-a[i];
			if((b[i]-a[i])%2==1){
				acnt++;
				bcnt++;
			}
		}
		if(a[i]-b[i]>0){
			bcnt += a[i]-b[i];
		}
	}
	long int c = acnt-bcnt;
	long int x = (c*2-acnt)/2;
	long int y = c-bcnt;
	if(acnt==0 && bcnt==0){
		cout << "Yes" << endl;
		return 0;
	}
	if(c>0 && bcnt<=c && 2*x==y){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	printf("%lld",max(a*c,max(b*d,max(a*d,b*c))));
	return 0;
}

Measured memory_bytes: 3812