akhauriyash/Code-Regression huggingface dataset:
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
  
  const [A, B, C, D, E, F] = input.trim().split(' ').map(Number)

  let W = {}
  let S = {}
  
  for (let i = 1; i < F; i ++) {
    for (let j = 0; j < F; j++) {
      const s = A * i * 100 + j * B * 100
      if (s > F) break
	  W[s] = 1
    }
  }
  
  const p = F * E / 100
  for (let i = 0; i < F; i ++) {
    for (let j = 0; j < F; j++) {
      const s = C * i + D * j
      if (s > p) break
	  S[s] = 1
    }
  }

  let ans = [A * 100, 0]
  let max = 0
  let r = E / 100
  for (let i in W) {
    for (let j in S) {
      const t = (i - 0) + (j - 0)
      const sw = j / i
      if (sw > r || t > F) continue
      if (sw > max) {
        max = sw
	    ans = [t, j]
      }
    }
  }
  
  console.log(ans[0], ans[1])
  
    
})(input)


Measured memory_bytes: 33464
#include <iostream>
#include <algorithm>
#include <math.h>

int main()
{
	unsigned long long N = 0;
	std::cin >> N;

	unsigned long long B = N;	// A < B
	unsigned long long ans = N;

	unsigned long long C = ceil(sqrt(N));
	for (unsigned long long A = 1; A <= C; A++){
		if (N % A == 0)
		{
			B = N / A;
		}
		ans = std::min(ans, A + B - 2);
	}
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll a[101010], b[101010], q[101010];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int A,B,Q; cin >> A >> B >> Q;
    for(int i=0; i < A; ++i) cin >> a[i];
    for(int i=0; i < B; ++i) cin >> b[i];
    for(int i=0; i < Q; ++i) cin >> q[i];
    a[A] = INF;
    b[B] = INF;

    for(int i=0; i < Q; ++i) {
        // a
        int aidx = lower_bound(a, a + A, q[i]) - a;
        ll aright = a[aidx  ] - q[i];
        ll aleft  = (aidx!=0 ? a[aidx-1] - q[i] : -INF);

        // b
        int bidx = lower_bound(b, b + B, q[i]) - b;
        ll bright = b[bidx  ] - q[i];
        ll bleft  = (bidx!=0 ? b[bidx-1] - q[i] : -INF);

        cout << min(aright*2 + abs(bleft), min(abs(aleft)*2 + bright, min(bright*2 + abs(aleft),min(abs(bleft)*2 + aright, min(max(aright, bright), max(-aleft, -bleft)))))) << '\n';
    }
    return 0;
}

Measured memory_bytes: 3712
/*
* @Author: Nguyen Quoc Cuong
* @Mail : 97quoccuong@gmail.com
* @Created at:   2018-10-24 14:39:59
* @Last Modified time: 2018-10-24 14:43:57
*/

#include <bits/stdc++.h>

#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) x.size()

#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 repd(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define repd1(i, n) for (int i = (int)(n);i; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)

#define debug(a) cout << #a << " : " << a << endl
#define debuga(a,l,r) fore(i,l,r) cout << a[i] << ' ';cout << endl;
#define put(x) cout << (x) << endl;exit(0);

using namespace std;

typedef double ld;
typedef long long i64;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> T min(T a, T b, T c) { return min(a,min(b,c)); }
template<class T> T max(T a, T b, T c) { return max(a,max(b,c)); }

const i64 linf = 2e17;
const int inf = 2e9;
void Fan_chipu();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  Fan_chipu();
}
/*====================================================== END ==============================================*/
const int maxn = 3e5 + 7;

/*------------------------------------- */ void Fan_chipu() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a + 3);
  cout << a[2] * 10 + a[1] + a[0];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 2005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
LL C[Max][Max];
void Compare_C(){//打表
    C[0][0]=1;
    for(int i=1;i<Max;i++){
        C[i][0]=C[i][i]=1;
        for(int j=1;j<=i;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
}
int main()
{
    Compare_C();
    int b,r,c;
    scanf("%d%d",&c,&b);
    r=c-b+1;
    for(int i=1;i<=b;i++){
        printf("%lld\n",(C[b-1][i-1]*C[r][i])%mod);
    }
    return 0;
}



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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  int res = 0;
  for(int i = 1; i < n; i++){
    int j = n - i;
    if(j > 0 && j != i)res++;
  }
  cout << res / 2 << endl;
  return 0;
}


Measured memory_bytes: 892
using System;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var a = double.Parse(input.Split(' ')[0]);
            var b = double.Parse(input.Split(' ')[1]);
            var x = double.Parse(input.Split(' ')[2]);
            var height = x/a/b/2;
            var rad = Math.Atan2(b, height);
            double degree = 0;
            if(x*2 > a*a*b)
            {
               x = a*a*b-x;
               degree =90- ( Math.Atan2(a, x*2/a/a)) * 180 / Math.PI;
            }
            else
            {
              degree = (Math.Atan2(b, x/a/b*2)) * 180 / Math.PI;
            }
            Console.WriteLine(degree);
        }
    }
}


Measured memory_bytes: 13140
N, A, B = map(int,input().split())
S = input()
AB = A + B
P = 0
F = 0
for i in range(N):
  if S[i] == "a":
    if P < AB:
      print("Yes")
      P += 1
    else:
      print("No")
  elif S[i] == "b":
    F += 1
    if P < AB and F <= B:
      print("Yes")
      P += 1
    else:
      print("No")
    
  else:
    print("No")

Measured memory_bytes: 4016
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.close();
    int ans = 0;
    for(int i=1;i<=n;i++) {
    	int dig = (int) (Math.log10(i)+1);
    	if(dig%2==1) {
    		ans++;
    	}
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
 int a,b,c;
scanf("%d %d %d",&a,&b,&c);
 if(a<b){
  if(b<c){
   printf("Yes\n");
   }else{
   printf("No\n");
   }
  }else{
  printf("No\n");
}
 return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    for (ll i = 0; i < s.size() - 1; i++)
    {
        if (i < s.size() - 2)
        {
            if (s[i] == s[i + 2])
            {
                cout << i + 1 << " " << i + 3 << endl;
                exit(0);
            }
        }
        if (s[i] == s[i + 1])
        {
            cout << i + 1 << " " << i + 2 << endl;
                exit(0);
        }
    }
            cout << -1 << " " << -1 << endl;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    multiset<int>ms;
    int mx=-1;
    int mn=1000;
    for(int i=0;i<n;i++){
        int tm;
        cin>>tm;
        ms.insert(tm);
        mx=max(mx,tm);
        mn=min(mn,tm);
    }
    int ans=2000000;
    for(int i=mn;i<=mx;i++){
        int ttl=0;
        for(multiset<int>::iterator it=ms.begin();it!=ms.end();it++){
            ttl+=pow((*it)-i,2)+0.5;
        }
        ans=min(ans,ttl);
    }
    cout << ans<< endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i ){
        cin >> A[i];
    }
    
    int res = 0;
    
    for (int i = 0; i < N; ++i){
        if ( A[i] % 2 == 0 ){
            if ( A[i] % 3 != 0 and A[i] % 5 != 0) {
                res = 1;
            }
        }
    }
    if ( res == 0 ){
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii> 
#define vvpii vector<vpii>
#define mii map<int, int>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, b) for(int i = a; i < b; i++)
#define repd2(i, a, b) for(int i = b - 1; i >= a; i--)
#define repd(i, n) for(int i = n-1; i >= 0; i--)
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(),v.end()
#define INF 1e9
#define EPS 1e-9
#define PI acosl(-1)

const int maxn = 1e6;

int work(int x){
    int left = 0;
    int right = x;
    int ans = 0;
    while(left <= right){
        int mid = (left + right)/2;
        if(mid * (mid + 1) / 2 <= x){
            ans = mid;
            left = mid + 1;
        }
        else{
            right = mid - 1;
        }
    }
    return ans;
}

void solve(){
    int n;
    cin >> n;
    vi powers;
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            int cnt = 0;
            while(n % i == 0){
                cnt ++;
                n /= i;
            }
            powers.pb(cnt);
        }
    }
    if(n > 1){
        powers.pb(1);
    }
    int ans = 0;
    for(auto x : powers){
        ans += work(x);
    }
    cout << ans << endl;
}

signed main(){
    fastio;
    cout << setprecision(20) << fixed;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
} 


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll k, q;
ll d[5010], S[5010], zS[5010];

int main() {
  std::cin >> k >> q;

  rep( i, k )
    std::cin >> d[i];

  rep( t, q ) {
    ll n, x, m;
    std::cin >> n >> x >> m;

    ll cnt = n-1;

    ll a = x;

    S[0] = 0;
    zS[0] = 0;

    rep( i, k ) {
      S[i+1] = S[i]+d[i]%m;
      zS[i+1] = zS[i]+(d[i]%m == 0);
    }

    a += S[k]*((n-1)/k)+S[(n-1)%k];
    cnt -= zS[k]*((n-1)/k)+zS[(n-1)%k];

    cnt -= a/m-x/m;

    std::cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 3712
#include<cstdio>
using namespace std;
int n, a[100005], ans;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++) {
        if(a[a[i]] == i) ans++;
    }
    printf("%d\n",ans/2);
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,xmax,ymax,x,y,p,p2,a;
  string str;
  while(1){
    cin >> xmax >> ymax;
    if(xmax == 0 && ymax == 0) break;

      x = y = 1;
      p = 0;
    while(1){
      cin >> str;
      if(p > 3) p -= 4;
      else if(p < 0) p += 4;
      p2 = p;
      if(str == "STOP") break;
      else if(str == "RIGHT") p++;
      else if(str == "LEFT") p--;
      else if(str == "FORWARD" || str == "BACKWARD"){
	cin >> a;
	if(str == "BACKWARD") p2 = (p2+2)%4;
	if(p2 == 0){
	  if(y+a >= ymax) y = ymax;
	  else y += a;
	}
	else if(p2 == 1){
	  if(x+a >= xmax) x = xmax;
	  else x += a;
	}
	else if(p2 == 2){
	  if(y-a <= 1) y = 1;
	  else y -= a;
	}
	else if(p2 == 3){
	  if(x-a <= 1) x = 1;
	  else x -= a;
	}
      }
    }

    cout << x << " " << y << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    if (a == 1) {
        if (b == 1) puts("Draw");
        else puts("Alice");
    } else if (b == 1) {
        puts("Bob");
    } else {
        if (a == b) puts("Draw");
        else cout << (a > b ? "Alice" : "Bob") << endl;
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 2147483647
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, q;
vector<int> dat, lazy;
void init(int n_) {
	int x = 1;
	while (x < n_)x *= 2;
	n = x;
	dat.resize(2 * n - 1, INF);
	lazy.resize(2 * n - 1, INF);
}

void eval(int k) {
	if (lazy[k] == INF)return;
	if (k < n - 1) {
		lazy[2 * k + 1] = lazy[k];
		lazy[2 * k + 2] = lazy[k];
	}
	dat[k] = lazy[k];
	lazy[k] = INF;
}

void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = n;
	eval(k);
	if (a <= l && r <= b) {
		lazy[k] = x;
		eval(k);
	}
	else if (a < r&&l < b) {
		update(a, b, x, 2 * k + 1, l, (l + r) / 2);
		update(a, b, x, 2 * k + 2, (l + r) / 2, r);
		dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
	}
}

int query(int a, int b, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = n;
	eval(k);
	if (r <= a || b <= l)return INF;
	if (a <= l && r <= b)return dat[k];
	int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
	int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
	return min(vl, vr);
}



signed main() {
	cin >> n >> q;
	init(n);
	for (int i = 0; i < q; i++) {
		int a;
		cin >> a;
		if (!a) {
			int b, c, d;
			cin >> b >> c >> d;
			update(b, c + 1, d);
		}
		else {
			int b, c;
			cin >> b >> c;
			cout << query(b, c + 1) << endl;
		}
	}
}


Measured memory_bytes: 7060
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;

int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	char *S = new char[N + 1];
	scanf("%s", S);
	int*cnt = new int[N];
	cnt[0] = 0;
	for (int i = 1; i < N; i++) {
		if (S[i - 1] == 'A'&&S[i] == 'C') {
			cnt[i] = cnt[i - 1] + 1;
		}
		else {
			cnt[i] = cnt[i - 1];
		}
	}
	int *ans = new int[Q];
	for (int i = 0; i < Q; i++) {
		int l, r;
		scanf("%d %d", &l, &r);
		ans[i] = cnt[r - 1] - cnt[l - 1];
	}
	for (int i = 0; i < Q; i++) {
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#define N 100000
int Partition(int * ,int ,int );
int A[N];
 int Partition(int *A, int p,int r){
  int x,i,h,j;
 
  x = A[r];
  i = p - 1;
  for(j = p ; j <= r - 1; j++){
    if(A[j] <= x){
      i = i + 1;
    h = A[i];
    A[i] = A[j];
    A[j] = h;
    }
  }
  h = A[i + 1];
  A[i + 1] = A[r];
  A[r] = h;
 
  return i + 1;
}
main(){
 
  int i,n,z;
 
  scanf("%d",&n);
 n=n-1;
  for(i = 0 ; i <=n ; i++ ){
    scanf("%d",&A[i]);
  }
 
   z = Partition(A,0,n);
 
  for(i = 0 ; i <=n ; i++ ){
    if(i != 0) printf(" ");
    if(i == z) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
 
  printf("\n");
 
  return 0;
   
}
 

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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(lli i=1;i<=n;i++)

#define DEBUG 0

int main(){
	
	lli n,q;
	string s;
	char d[4] = {'A','T','C','G'};
	cin>>n>>q;
	cin>>s;

	lli data[100010]={0};
	for(lli i=0;i<n-1;i++){
		if(s.at(i) == 'A' && s.at(i+1)=='C'){
			data[i]=1;
		}
	}
	for(lli i=n-1;i>=0;i--){
		data[i] += data[i+1];
	}
	REP(i,n)if(DEBUG)cout<<"i="<<i<<" data = "<<data[i]<<endl;
	REP(i,q){
		lli l,r;
		cin>>l>>r;
		l--;
		r--;
		cout<<data[l]-data[r]<<endl;
	}
	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000003
#define invp(a,p)pom(a,p-2,p)

//*
ll fact[1000010];
ll invfact[1000010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/



ll e[MOD+10];
int main(){
	ll crr=1;
	rep(i,0,MOD){
		e[crr]=i;
		crr=crr*2%MOD;
	}
	makefact(MOD-1,MOD);
	
	ll q;
	scanf("%lld",&q);
	while(q--){
		ll x,d,n;
		scanf("%lld%lld%lld",&x,&d,&n);
		if(d==0){
			printf("%lld\n",pom(x,n,MOD));
		}else if(n>=MOD){
			puts("0");
		}else{
			ll k=x*invp(d,MOD)%MOD;
			if(k+n-1>=MOD||k==0){
				puts("0");
			}else{
				//d^n * (k～(k+n-1)までの積)
				printf("%lld\n",pom(d,n,MOD)*fact[k+n-1]%MOD*invfact[k-1]%MOD);
			}
		}
	}
}

Measured memory_bytes: 24192
#include <stdio.h>          // printf(), scanf()
#define MAX_N 500000

typedef struct node_tbl
{
	int key;
	int parent;
	int left;
	int right;
} node;

const int nil = -1;
node t[MAX_N + 1];
int root;
int ix;

int
find(int u, int k)
{
	while (u != nil && k != t[u].key)
	{
		if (k < t[u].key)
			u = t[u].left;
		else
			u = t[u].right;
	}

	return u;
}

void
insert(int k)
{
	int y = nil;
	int x = root;
	int z = ix++;

	t[z].key = k;
	t[z].left = nil;
	t[z].right = nil;

	while (x != nil)
	{
		y = x;
		if (t[z].key < t[x].key)
			x = t[x].left;
		else
			x = t[x].right;
	}

	t[z].parent = y;
	if (y == nil)
		root = z;
	else
	{
		if (t[z].key < t[y].key)
			t[y].left = z;
		else
			t[y].right = z;
	}
}

void
inorder(int u)
{
	if (u == nil)
		return;

	inorder(t[u].left);
	printf(" %d", t[u].key);
	inorder(t[u].right);
}

void
preorder(int u)
{
	if (u == nil)
		return;

	printf(" %d", t[u].key);
	preorder(t[u].left);
	preorder(t[u].right);
}

int
main(int argc, char** argv)
{
	char command[8];
	int n;
	int x;
	int i;

	root = nil;
	ix = 0;
	scanf("%d", &n);
	for (i = 0; i < n; ++i)
	{
		scanf("%s", command);
		switch (command[0])
		{
		case 'f':
			scanf("%d", &x);
			printf("%s\n", find(root, x) != nil ? "yes" : "no");
			break;

		case 'i':
			scanf("%d", &x);
			insert(x);
			break;

		case 'p':
		default:
			inorder(root);
			printf("\n");

			preorder(root);
			printf("\n");
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 7952
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct P{
    int to;
    ll cost;
};

ll cost_k[100010];
vector<P> tree[100010];

void dfs(int v, int par, ll dist){
    cost_k[v] = dist;
    for(int i = 0; i < tree[v].size(); i++){
        if(tree[v][i].to==par) continue;
        dfs(tree[v][i].to, v, dist + tree[v][i].cost);
    }
}

int main() {
    int n; cin >> n;
    rep(i,n-1){
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        tree[a].push_back({b,c});
        tree[b].push_back({a,c});
    }
    int q, k; cin >> q >> k;
    k--;

    dfs(k,-1,0);

    rep(i,q){
        int x, y; cin >> x >> y;
        x--; y--;
        cout << cost_k[x] + cost_k[y] << endl;
    }




    return 0;
}

Measured memory_bytes: 15872
n,k = map(int,input().split())
A = list(map(int,input().split()))
D = dict.fromkeys(range(1,n+1),0)
ans = 0
for a in A:
  D[a] += 1
D = sorted(D.items(), key=lambda x:x[1])
for i in range(n-k):
  ans += D[i][1]
print(ans)

Measured memory_bytes: 49116
using System;
using System.Collections.Generic;
using System.Linq;

namespace Aizu {
    class OnlineJudge {
        static void Main() {
            var query = Console.ReadLine();
            var yaml = Parse();
            Console.WriteLine(yaml.ContainsKey(query) ? yaml[query] : "no such property");
        }
        static Dictionary<string, string> Parse() {
            var result = new Dictionary<string, string>();
            var indent = new Stack<int>(new[] { -1 });
            var header = new LinkedList<string>();
            foreach (var line in Input()) {
                var lastIndent = indent.Peek();
                var orig = line.Split(':');
                var com = new[] { orig[0].Trim(), orig[1] };
                var currentIndent = orig[0].Length - com[0].Length;
                if (currentIndent != lastIndent) {
                    if (currentIndent < lastIndent) {
                        while (currentIndent != lastIndent) {
                            header.RemoveLast();
                            lastIndent = indent.Pop();
                        }
                    }
                    header.AddLast("." + com[0]);
                    indent.Push(currentIndent);
                }
                else {
                    header.Last.Value = "." + com[0];
                }
                result.Add(string.Concat(header.ToArray()), com[1].Length != 0 ? "string \"" + com[1].Substring(1) + "\"" : "object");
            }
            return result;
        }
        static IEnumerable<string> Input() {
            for (string i; (i = Console.ReadLine()) != null;) {
                yield return i;
            }
        }
    }
}

Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    ll b[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    rep(i,n){
        if(i==0){
            b[i] = a[i];
        }else{
            b[i] = b[i-1] +a[i];
            //cout << b[i];
        }
    }
    ll ans = 1;
    while(ans<n){
        if(a[n-ans]<=b[n-ans-1]*2){
            ans++;
        }else{
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 1792
#include <stdio.h>

int N;

int main(){

    int sho=0,amari=0,ans=0;
    scanf("%d",&N);

    sho=N/1000;
    amari=N%1000;
    if(amari!=0)
    	sho++;
    ans=sho*1000-N;
    printf("%d\n",ans);

    return 0;
}



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

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

	vector<vector<char>> c(h + 2, vector<char>(w + 2, 'e'));

	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cin >> c[i][j];


	vector<vector<int>> left_c(h + 2, vector<int>(w + 2, -1));
	vector<vector<int>> right_c(h + 2, vector<int>(w + 2, -1));
	vector<vector<int>> up_c(h + 2, vector<int>(w + 2, -1));
	vector<vector<int>> down_c(h + 2, vector<int>(w + 2, -1));

	for (int i = 1; i <= h; i++) {
		int cur = 0;
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == '#') cur = 0;
			else cur++;
			left_c[i][j] = cur;
		}
	}

	for (int i = 1; i <= h; i++) {
		int cur = 0;
		for (int j = w; j >= 1; j--) {
			if (c[i][j] == '#') cur = 0;
			else cur++;
			right_c[i][j] = cur;
		}
	}

	for (int j = 1; j <= w; j++) {
		int cur = 0;
		for (int i = 1; i <= h; i++) {
			if (c[i][j] == '#') cur = 0;
			else cur++;
			down_c[i][j] = cur;
		}
	}

	for (int j = 1; j <= w; j++) {
		int cur = 0;
		for (int i = h; i >= 1; i--) {
			if (c[i][j] == '#') cur = 0;
			else cur++;
			up_c[i][j] = cur;
		}
	}

	int ans = 0;	
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			ans = max(ans, left_c[i][j] + right_c[i][j] + down_c[i][j] + up_c[i][j] - 3);		
		}
	}

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

Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int k;
  cin >> k;
  if (k <= 9) {
    cout << k << endl;
    return;
  }
  queue<ll> q;
  FOR(i, 1, 9) q.push(i);
  REP(i, k - 1) {
    ll x = q.front();
    //cout << x << endl;
    q.pop();
    if (x % 10 != 0) q.push(x * 10 + (x % 10) - 1);
    q.push(x * 10 + (x % 10));
    if (x % 10 != 9) q.push(x * 10 + (x % 10) + 1);
  }
  cout << q.front() << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int r =  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 == d){
          r +=1;
        }
      }
    }
  }
  
  cout << r <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=1e7+5;
int a[N];
int b[N];
char s[N];
char t[N];
ll f[N];
int cmp1(int a,int b)
{
    return b<a;
}
multiset<int> ss;
map<int,int>mp;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            f[j]++;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=i*f[i];
    }
    cout<<ans<<endl;
}


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

int main() {
	int N;
  	cin >> N;
    if (N<4||N==5||N==6||N==9||N==10||N==13||N==17){
      cout << "No"<< endl;
    }
  else {
    cout << "Yes" << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_atcoder_boal(void) {
	int n,k;
	cin >> n >> k;
	long long int pat = 0;
	for (int i = 1; i <= n; i++) {
		if (i == 1)pat += k;
		else       pat *= (k - 1);
	}
	cout << pat << endl;
}

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

Measured memory_bytes: 3572
Main(myin());
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  var sortedList = JSON.parse(JSON.stringify(list));
  sortedList.sort(function(a,b){
  	return a-b;
  });
  var output = new Array(N);
  if(sortedList[N/2-1] == sortedList[N/2]){
    output.fill(sortedList[N/2-1]);
  }else{
    for(var i = 0; i < N; i++){
      if(list[i] <= sortedList[N/2-1]){
         output[i] = sortedList[N/2];
      }else{
        output[i] = sortedList[N/2-1];
      }
    }
  }
  myout(myconv(output,9));
}

Measured memory_bytes: 55944
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N], b[N];
ll dp[100009][109];

void solve(){
	ll n, W;
	cin >> n >> W;
	for(int i = 1; i <= n; ++i){
		cin >> a[i] >> b[i];
	}
	for(int i = 1; i <= W; ++i){
		for(int j = 1; j <= n ; ++j){
			dp[i][j] = dp[i][j - 1];
			if(a[j] <= i)	dp[i][j] = max(dp[i - 1][j], max(b[j] + dp[i - a[j]][j - 1], dp[i][j]));	
		}
	}
	cout << dp[W][n];
}
 
int main(int argc, char const *argv[]){
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
    	solve();
    }
}
// nEro

Measured memory_bytes: 88320
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
   int n;
   cin >> n;
   string s;
   cin >> s;
   ll zenntai = 1;
   for(int i=0;i<3;i++){
      ll che = 0;
      for(int j=0;j<n;j++){
         if(i==0){
            if(s.at(j)=='R')che++;
         }
         else if(i==1){ 
            if(s.at(j)=='B')che++;
         }
         else {
            if(s.at(j)=='G')che++;
         }
      }
      zenntai*=che;
   }
   ll hosyu = 0;
   for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
         int k= j+j-i;
         if(k>=n)continue;
         string che = "";
         che+=s.at(i);
         che+=s.at(j);
         che+=s.at(k);
         sort(che.begin(),che.end());
         if(che=="BGR")hosyu++;
      }
   }
   ll ans = zenntai - hosyu;
   cout << ans << endl;
}
    



Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;

int cnt_digit(ll N)
{
	int digit = 0;

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

int n;
vll a;

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

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


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, T;
	cin >> N >> T;
	vector<int> data(N);

	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
	}
	int ans = 0;
	for (int i = 0; i < N-1; i++)
	{
		int t = T;
		if ((data[i + 1] - data[i]) >= T)
		{
			ans += T;
		}
		else if ((data[i + 1] - data[i]) < T)
		{
			ans += (data[i + 1] - data[i]);
		}

	}

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


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  ll money = 1000, stock = 0;
  rep(i,N) {
    if (i > 0) {
      // 売却
      if (A[i] >= A[i-1]) {
        money += stock * A[i];
        stock = 0;
      }
    }
    if (i < N-1) {
      // 購入
      if (A[i] <= A[i+1]) {
        stock += money / A[i];
        money %= A[i];
      }
    }
  }
  cout << money << endl;
  return 0;
}

Measured memory_bytes: 3192
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
 
public class Main {
  public static void main(String args[] ) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s="";
    while(s != null) {
      s = br.readLine();
      if (s == null ){break;}
      int a = Integer.parseInt(s.split(" ")[0]);
      int b = Integer.parseInt(s.split(" ")[1]);
      System.out.println(String.valueOf(a + b).length());
    }
  }
}

Measured memory_bytes: 23936
#include <iostream>

using namespace std;

typedef long long ll;

int main() {

    ll n, t;
    cin >> n >> t;

    ll nums[n];

    for (int i = 0; i < n; i++) cin >> nums[i];

    ll ans = 0;

    for (int i = 1; i < n; i++){

        ll current = nums[i] - nums[i-1];

        if (current >= t){
            ans += t;
        } else {
            ans += current;
        }
    }

    ans += t;

    cout << ans << endl;

    return 0;
}

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

int main() {
	double a; cin >> a;
	double ans = (a / 3) * (a / 3) * (a / 3);
	cout << setprecision(10) << fixed << ans << endl;
	return 0;
}

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

int main()
{
	int i, N, a[3001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	long long sum = 0;
	for (i = 1; i <= N; i++) sum += a[i];
	
	printf("%d\n", sum - N);
	fflush(stdout);
	return 0;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int>h(n);
	for (int i = 0;i < n;i++) {
		cin >> h[i];
	}

	sort(h.begin(), h.end());
	int ans = 1000000000;
	for (int i = 0;i < n - k + 1;i++) {
		ans = min(ans, h[i + k - 1] - h[i]);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 640
using System;
namespace pro
{




    class MainClass
    {
        public static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if (a + b > a - b && a + b > a * b)
            {
                Console.WriteLine(a + b);
            }
            else if (a - b > a + b && a - b > a * b)
            {
                Console.WriteLine(a - b);
            }
            else if (a * b > a + b && a * b > a - b)
            {
                Console.WriteLine(a * b);
            }
            else if (a + b == a - b&&a+b==a*b)
            {
                Console.WriteLine(a + b);
            }
            else if (a + b > a - b && a + b == a * b)
            {
                Console.WriteLine(a + b);
            }
            else if (a - b > a + b && a - b == a * b)
            {
                Console.WriteLine(a - b);
            }
            else if (a + b > a * b && a - b == a + b)
            {
                Console.WriteLine(a - b);
            }

        }
    }


}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t x, y;
	cin >> x >> y;
	int64_t ans = -1;

	int64_t a = 0;
	if (x % y == 0) {
		cout << -1 << endl;
		return 0;
	}
	while (true) {
		a += x;
		if (x % y != 0) {
			ans = x;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
while True:
    W, D = map(int, input().split())
    if not (W | D):
        break
    hw = [int(x) for x in input().split()]
    hd = [int(x) for x in input().split()]

    cnt_hw = Counter(hw)
    cnt_hd = Counter(hd)
    print(min(sum(hw) + sum(max(0, v - cnt_hw[k]) * k for k, v in cnt_hd.items()),
              sum(hd) + sum(max(0, v - cnt_hd[k]) * k for k, v in cnt_hw.items())))

Measured memory_bytes: 7956
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 2 == 1) {
                count++;
            }
        }
        System.out.println(String.format("%f", ((float)count) / n));
    }
}



Measured memory_bytes: 23124