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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll>mp;

int main(){
  COMinit();

  ll n,m;
  cin>>n>>m;

  for(int i=2;i*i<=m;i++){
    while(m%i==0){
      mp[i]++;
      m/=i;
    }
  }
  if(m!=1)mp[m]=1;

  ll ans=1;
  for(auto i=mp.begin();i!=mp.end();i++){
    ll t=i->second;
    ans*=COM(n+t-1,t);
    ans%=mod;
  }

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


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

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

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

  for (int i = 1; i <= 2000; ++i) {
    int c = i * 0.08;
    int d = i * 0.1;

    if (c == a && d == b) {
      cout << i << '\n';
      return (0);
    }
  }

  cout << -1 << '\n';

  return (0);
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    cout<<15-x1-x2-x3-x4-x5<<endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  
  int n = 0;
  if(N[0] != N[1] && N[1] != N[2] && N[2]!=N[3]){
    cout << "Good" <<endl;
  }
  else{
    cout << "Bad" << endl;
  }
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
ll f(ll a,ll b,ll c){
    return a-(a/b+a/c-a/lcm(b,c));
}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<f(b,c,d)-f(a-1,c,d)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
using namespace std;

int main(){
	int n;
	while(~scanf("%d",&n)){
		int k4=0,k2=0;
		for(int i=0;i<n;i++){
			int a;
			scanf("%d",&a);
			if(a%4==0)k4++;
			else if(a%2==0)k2++;
		}
		if(k4>=n/2)cout<<"Yes"<<endl;
		else if(k4*2+k2>=n)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;

}

	


		

	





		

	




Measured memory_bytes: 256
#include <stdio.h>
#define N 250
int it = 1, tree[N + 1];
int main() {
	int n, i;
	
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &tree[i]);
		it++;
	}

	for (i = 1; i <= n; i++) {
		printf("node %d: key = %d, ", i, tree[i]);
		if (i / 2 > 0)
			printf("parent key = %d, ", tree[i / 2]);
		if (i * 2 < it)
			printf("left key = %d, ", tree[2 * i]);
		if (i * 2 + 1 < it)
			printf("right key = %d, ", tree[2 * i + 1]);
		printf("\n");
	}
	return 0;
}

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

const int MAX = 100;
const int INFINITY = 2 << 21;
int n;
int G[MAX][MAX];
int distances[MAX];
int parents[MAX];
int states[MAX];

int prim() {
  int id = 0;
  distances[id] = 0;

  while (1) {
    int min = INFINITY;

    for (int i = 0; i < n; i++) {
      if (states[i] == 0 && distances[i] < min) {
        min = distances[i];
        id = i;
      }
    }

    if (min == INFINITY) break;

    for (int i = 0; i < n; i++) {
      if (states[i] != 0 || G[id][i] == -1) continue;
      if (G[id][i] < distances[i]) {
        distances[i] = G[id][i];
        parents[i] = id;
      }
    }

    states[id] = 1;
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (parents[i] != -1) sum += distances[i];
  }
  return sum;
}

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

  cin >> n;

  for (int i = 0; i < n; i++) {
    distances[i] = INFINITY;
    parents[i] = -1;
    states[i] = 0;
    for (int j = 0; j < n; j++) {
      cin >> G[i][j];
    }
  }

  cout << prim() << endl;
  return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nmax=100005;
struct edge{ll to;ll cost;};
vector<edge> tree[nmax];
ll d[nmax];
ll n;
void dijkstra(ll s){
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
  fill(d,d+n,1e18);
  d[s]=0;
  pq.push(make_pair(0,s));
  while(!pq.empty()){
    pair<ll,ll> p=pq.top();
    pq.pop();
    ll v=p.second;
    if(d[v]<p.first){
      continue;
    }
    for(auto x:tree[v]){
      edge e=x;
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        pq.push(make_pair(d[e.to],e.to));
      }
    }
  }
}
int main(){
  ll m;cin >> n >> m;
  for(int i=1;i<n;i++){
    tree[i].push_back(edge{i-1,0});
  }
  for(int i=0;i<m;i++){
    ll l,r,c;cin >> l >> r >> c;
    l--,r--;
    tree[l].push_back(edge{r,c});
  }
  dijkstra(0);
  if(d[n-1]==1e18){
    cout << -1 << endl;
  }
  else{
    cout << d[n-1] << endl;
  }
}

Measured memory_bytes: 10104
#include "iostream"
#include "algorithm"
#include "string"
#include "map"
#include "vector"
#include "stack"
#include "queue"
using namespace std;
typedef long long ll;
int main()
{
    int N,X,T,time=0;
    
    cin>>N>>X>>T;
    
    while(N>0)
    {
        N = N-X;
        time=time+T;
    }
    cout<<time;

}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(void){
  int RPS[5],R,P,S;
  while(1){
    R = P = S = 0;
    for(int i=0;i<5;i++){cin>>RPS[i];if(RPS[0]==0)break;if(RPS[i]==1)R++;else if(RPS[i]==2)S++;else P++;}
    if(RPS[0]==0)break;
    if(R>0&&S>0&&P>0||R==5||S==5||P==5){for(int i=0;i<5;i++)cout<<"3"<<endl;}
    else if(R==0){for(int i=0;i<5;i++){if(RPS[i]==2)cout<<"1"<<endl;else cout<<"2"<<endl;}}
    else if(S==0){for(int i=0;i<5;i++){if(RPS[i]==3)cout<<"1"<<endl;else cout<<"2"<<endl;}}
    else if(P==0){for(int i=0;i<5;i++){if(RPS[i]==1)cout<<"1"<<endl;else cout<<"2"<<endl;}}
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
 
using vd=vector<double>;
using vvd=vector<vd>;
 
 
int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,(2650+2670)/2){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3192
import Control.Monad.State

main :: IO ()
main = do
  (`evalStateT` 1) $ fix $ \loop -> do
      i <- lift $ getLine
      n <- get
      unless (i == "0") $ do 
        lift $ putStrLn $ "Case " ++ show n ++ ": " ++ i
        modify (+1)
        loop
  return ()


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

int dig_sum(int x) {
	int sum = 0;
	int y = 10000;
	while (y > 0) {
		int z = x / y;
		sum += z;
		x -= z * y;
		y /= 10;
	}
	return sum;
}

int main(void) {
	int N, A, B;
	cin >> N >> A >> B;

	int ans = 0;
	for (int x = 1; x <= N; ++x) {
		int y = dig_sum(x);
		if (y >= A && y <= B)
			ans += x;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, k1, k2, k4;

	scanf("%d", &n);
	k1 = k2 = k4 = 0;
	while (n--) {
		int a;

		scanf("%d", &a);
		if (a % 4 == 0)
			k4++;
		else if (a % 2 == 0)
			k2++;
		else
			k1++;
	}
	printf((k2 == 0 && k1 <= k4 + 1) || (k2 > 0 && k1 <= k4) ? "Yes\n" : "No\n");
	return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
const int MAX = 100;
string S,T;

deque<int> sum_str(string s,string t)
{
	deque<int> res;
	bool carry = false;
	for(int i = 0;i < max(s.size(),t.size()) || carry;i++){
		res.push_front(carry);
		carry = false;
		if(i < s.size()){
			res.front() += s [s.size() - i - 1] - '0';
		}
		if(i < t.size()){
			res.front() += t [t.size() - i - 1] - '0';
		}
		if(res.front() >= 10){
			res.front() %= 10;
			carry = true;
		}
	}
	
	return res;
}

int main()
{
	cin >> N;
	FOR(i,0,N){
		cin >> S >> T;
		deque<int> ans = sum_str(S,T);
		if(ans.size() <= 80){
			FOR(i,0,ans.size()){
				cout << ans [i] << (i == ans.size() - 1 ? "\n" : "");
			}
		}
		else{
			cout << "overflow" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2992
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, m] <- getIntList
  d <- VM.new n
  VM.set d False
  VM.write d 0 True

  vn <- VM.new n
  VM.set vn (1::Int)

  replicateM_ m $ do
    [x, y] <- getIntList
    tx <- VM.read d (x-1)
    ty <- VM.read d (y-1)
    VM.write d (y-1) (tx || ty)
    nx <- VM.read vn (x-1)
    ny <- VM.read vn (y-1)
    VM.write vn (x-1) (nx-1)
    VM.write vn (y-1) (ny+1)
    when (nx == 1) $ VM.write d (x-1) False

  d' <- V.freeze d
  let ans = V.length $ V.filter id d'

  print ans

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int l;
    cin >> l;
    long long a = l*l*l;
    cout << fixed << setprecision(12) << (double) a/27;
    return 0;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

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

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


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

    ll x, y; cin >> x >> y;
    if (x * y > 0) {            // 符号が同じ
        if (x > y) {
            cout << x - y + 2 << "\n";
        } else {
            cout << y - x << "\n";
        }
    } else if (x * y == 0) {    // 少なくとも1つは0
        if (x > y) {
            cout << x - y + 1 << "\n";
        } else {
            cout << y - x << "\n";
        }
    } else {                    // 符号が逆
        cout << abs(abs(x) - abs(y)) + 1 << "\n";
    }
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

alias Point = Tuple!(long, "x", long, "y");

Point[50] PS;
int[51][51] SS;
long[50] XS, YS;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];

    auto ps = PS[0..N];

    foreach (i; 0..N) {
        auto xy = readln.split.to!(long[]);
        PS[i] = Point(xy[0], xy[1]);
        XS[i] = xy[0];
        YS[i] = xy[1];
    }

    sort(XS[0..N]);
    sort(YS[0..N]);
    foreach (i; 0..N) {
        foreach (j; 0..N) {
            int cnt;
            foreach (p; ps) if (p.x <= XS[i] && p.y <= YS[j]) ++cnt;
            SS[j+1][i+1] = cnt;
        }
    }

    auto min_size = long.max;
    foreach (ix; 0..N) {
        foreach (jx; ix..N) {
            foreach (iy; 0..N) {
                foreach (jy; iy..N) {
                    if (SS[jy+1][jx+1] - SS[iy][jx+1] - SS[jy+1][ix] + SS[iy][ix] >= K) {
                        auto size = (XS[jx] - XS[ix]) * (YS[jy] - YS[iy]);
                        min_size = min(min_size, size);
                    }
                }
            }
        }
    }
    writeln(min_size);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
#define ll long long
#define fn(i,n) for(ll i=0;i<n;i++)
#define rn(i,n) for(ll i=1;i<n;i++)
#define wh while
#define pb push_back
#define sc(n) scanf("%lld",&n)
#include <vector>
#define N 100100

using namespace std; 

int main() {
  string s;cin>>s;
    ll n=s.size();
    ll ans=n;
    rn(i,n)
    {
        if(s[i]!=s[i-1])
            ans=min(ans,max(i,n-i));
    }
    cout<<ans<<endl;
        
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) //aからbまで繰り替えす
#define vec vector<int>a(n)
#define soot(a) sort(a.begin(),a.end())
/*int n;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];*/
using namespace std;
int main() {
int n;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];
int high = 0;
rep0(i, n - 1) {
	if (high > a[i]) {
		cout << "No" << endl;
		return 0;
	}
	else if (high == a[i]) {
		high = a[i];
	}
	else {
		a[i] -= 1;
		high = a[i];
	}
}

cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
<?php

function parsenums($str) {
    return array_map(function ($a) {
        return intval($a);
    }, preg_split("/ /", $str));
}

$str1 = fgets(STDIN);
$str2 = fgets(STDIN);
$str3 = fgets(STDIN);

$r1 = parsenums($str1);
$r2 = parsenums($str2);
$r3 = parsenums($str3);

function ck($c1, $c2, $a1, $a2) {
    return $c1 - $c2 == $a1 - $a2;
}

function a() {
    global $r1, $r2, $r3;
    foreach(range(0, 100) as $i) { 
        foreach(range(0, 100) as $j) { 
            foreach(range(0, 100) as $k) { 
                if(
                    ck($r1[0], $r2[0], $i, $j)&&
                    ck($r2[0], $r3[0], $j, $k)&&
                    ck($r3[0], $r1[0], $k, $i)&&
                    ck($r1[1], $r2[1], $i, $j)&&
                    ck($r2[1], $r3[1], $j, $k)&&
                    ck($r3[1], $r1[1], $k, $i)&&
                    ck($r1[2], $r2[2], $i, $j)&&
                    ck($r2[2], $r3[2], $j, $k)&&
                    ck($r3[2], $r1[2], $k, $i)
                ){
                    return true;
                }
            }
        }
    }
    return false;
}

function b() {
    global $r1, $r2, $r3;
    foreach(range(0, 100) as $i) { 
        foreach(range(0, 100) as $j) { 
            foreach(range(0, 100) as $k) { 
                if(
                    ck($r1[0], $r1[1], $i, $j)&&
                    ck($r1[1], $r1[2], $j, $k)&&
                    ck($r1[2], $r1[0], $k, $i)&&
                    ck($r2[0], $r2[1], $i, $j)&&
                    ck($r2[1], $r2[2], $j, $k)&&
                    ck($r2[2], $r2[0], $k, $i)&&
                    ck($r3[0], $r3[1], $i, $j)&&
                    ck($r3[1], $r3[2], $j, $k)&&
                    ck($r3[2], $r3[0], $k, $i)
                ){
                    return true;
                }
            }
        }
    }
    return false;
}

if(a() && b()) {
    echo "Yes\n";
} else {
    echo "No\n";
}


Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	vector<int> count(n,0);
	int cnt=0;
	for(int i = 1; i < n; i++){
		if(s[i]=='C'&&s[i-1]=='A'){
			cnt++;
		}
		count[i]=cnt;
	}
	for(int i = 0; i < q; i++){
		int l,r;
		cin>>l>>r;
		l--;r--;
		cout<<count[r]-count[l]<<endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n;
const lli mod = 998244353;
struct Robot
{
  lli x, d; int reaches;
  void read() { scanf("%lld %lld", &x, &d); }
  void print() { DEBUG printf("\t"); printf("%lld %lld %d\n", x, d, reaches); }
  bool operator<(const Robot &other) const { return x < other.x; }
};
Robot robots[maxN];

int segtree[4*maxN];
int query(int qlo, int qhi, int i = 1, int lo = 0, int hi = n - 1)
{
  if (hi < qlo || lo > qhi) return 0;
  if (lo >= qlo && hi <= qhi) return segtree[i];
  int mid = (lo + hi) >> 1;
  return max(query(qlo, qhi, 2*i, lo, mid), query(qlo, qhi, 2*i + 1, mid + 1, hi));
}
void update(int pos, int value, int i = 1, int lo = 0, int hi = n - 1)
{
  if (lo == hi)
  {
    segtree[i] = value;
    return;
  }
  int mid = (lo + hi) >> 1;
  if (pos <= mid) update(pos, value, 2*i, lo, mid);
  else update(pos, value, 2*i + 1, mid + 1, hi);
  segtree[i] = max(segtree[2*i], segtree[2*i + 1]);
}

lli memo[maxN + 1];

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    memset(memo, 0, sizeof(memo)), memset(segtree, 0, sizeof(segtree));

    for (int i = 0; i < n; i++)
      robots[i].read();
    sort(robots, robots+n);

    robots[n - 1].reaches = n;
    for (int i = n - 2; i >= 0; i--)
    {
      Robot limit = Robot{robots[i].x + robots[i].d - 1, 0, 0};
      int pos = upper_bound(robots, robots+n, limit) - robots;
      if (pos < n) pos -= 1;
      if (pos == n) robots[i].reaches = n;
      else if (pos <= i) robots[i].reaches = i + 1;
      else robots[i].reaches = query(i + 1, pos);
      update(i, robots[i].reaches);
      DEBUG { printf("\t%d %d ||||", i, pos); robots[i].print(); }
    }

    memo[n] = 1;
    for (int i = n - 1; i >= 0; i --)
      memo[i] = (memo[i + 1] + memo[robots[i].reaches]) % mod;

    printf("%lld\n", memo[0]);
  }
  return 0;
}

Measured memory_bytes: 9600
# https://atcoder.jp/contests/abc079/tasks/abc079_d

from collections import Counter
from functools import reduce

def warshall(d, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][k] + d[k][j] < d[i][j]:
                    d[i][j] = d[i][k] + d[k][j]

h,w = map(int,input().split())
magic = []
for i in range(10):
    magic.append(list(map(int,input().split())))

counter = {i:0 for i in range(10)}
for _ in range(h):
    for a in map(int, input().split()):
        if a > -1:
            counter[a] += 1
    # counter.update(Counter(map(int, input().split())))
warshall(magic, 10)

ans = 0
for k,v in counter.items():
    ans += magic[k][1] * v
print(ans)
# print(reduce(lambda x,y:x+y, [magic[k][1] * v for k,v in counter.items() if k > -1]))


Measured memory_bytes: 3564
#include <iostream>

using namespace std;
 
int main(){
    int n,m = 100000;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
	m *= 1.05;
	if(m % 1000 != 0){
	    m += 1000 - m%1000;
	}
    }
    cout << m << endl;
    return 0;
}

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

long long gcd(long long A,long long B){
  if(B==0){
    return A;
  }
  return gcd(B,A%B);
}

vector<pair<long long,long long>> prime_factorize(long long A){
  vector<pair<long long,long long>> res;
  for(long long i=2;i*i<=A;i++){
    if(A%i!=0){
      continue;
    }
    long long ex=0;
    while(A%i==0){
      ex++;
      A/=i;
    }
    res.push_back(make_pair(i,ex));
  }
  if(A!=1){
    res.push_back(make_pair(A,1));
  }
  return res;
}
    
int main(){
  long long A,B;
  cin >> A >> B;
  long long C=gcd(A,B);
  vector<pair<long long,long long>> D=prime_factorize(C);
  cout << D.size()+1 << endl;
} 

Measured memory_bytes: 3604
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=300005;
int cnt[M],tmp,abr_cnt[M];
int fx[M];
int pcnt[M],pabr_cnt[M];
int ses[M];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>tmp;
        cnt[tmp]++;
    }
    f(i,1,n)
    {
        abr_cnt[cnt[i]]++;
    }
    int sum=0;
    f(i,1,n)
    {
        sum+=(abr_cnt[i]*i);
        pcnt[i]=sum;
    }
    sum=0;
    f(i,1,n)
    {
        sum+=abr_cnt[i];
        pabr_cnt[i]=sum;
    }
    f(x,1,n)
    {
       int lft=pcnt[x];
       int rgt=(pabr_cnt[n]-pabr_cnt[x])*x;
       fx[x]=(lft+rgt)/x;
       ses[fx[x]]=max(ses[fx[x]],x);
    }
    rf(i,n,1)
    {
        ses[i]=max(ses[i],ses[i+1]);
    }
    f(i,1,n)
    {
        cout<<ses[i]<<" ";
    }
    cout<<endl;
    return 0;

}



































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

using namespace std;


#define int long long

const int N = 1e6 + 10;

int a[N];

signed main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = k + 1; i <= n; i++)
	{
		if (a[i] > a[i - k])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 5112
def d_decayed_bridges(N, M, Bridges):
    class UnionFind(object):
        def __init__(self, n):
            self.p = list(range(n))  # i番の頂点の親(parent)はi番とする
            self.rank = [0] * n  # 全頂点はランク0(繋がりなし)とする
            self.size = [1] * n  # 全頂点の連結成分の大きさ1とする

        def union(self, x, y):  # x,yを同じ連結成分に属させる
            u = self.find(x)
            v = self.find(y)
            if u == v:  # x,yは既に同じ連結成分に属していた
                return
            if self.rank[u] < self.rank[v]:
                self.p[u] = v  # ランクの大きな方につなげる
                self.size[v] += self.size[u]  # つながっている要素数だけ足す
                self.size[u] = 0  # ランクが小さかった連結成分は「解散」
            else:
                # 上と同様にやる
                self.p[v] = u
                self.size[u] += self.size[v]
                self.size[v] = 0
                if self.rank[u] == self.rank[v]:
                    # 根の分だけ1個「ずれる」
                    self.rank[u] += 1
            # 経路圧縮を行い、連結成分の代表を更新
            self.find(x)
            self.find(y)

        def find(self, x):  # 頂点xが属する連結成分の代表(根の番号)を求める
            if self.p[x] != x:  # 頂点xの代表は他の頂点だった
                self.p[x] = self.find(self.p[x])  # 経路圧縮(xを代表につなぐ)
            return self.p[x]

        def is_same(self, x, y):  # 頂点x,yは同じ連結成分に属するか？
            return self.find(x) == self.find(y)

        def get_size(self, x):  # 頂点xが属する連結成分の大きさ
            return self.size[self.find(x)]

    uf = UnionFind(N + 1)  # 頂点番号は1-basedとする
    ans_tmp = [N * (N - 1) // 2]  # 橋がすべて崩壊したあと、不便さの値
    for a, b in reversed(Bridges):
        if uf.is_same(a, b):
            # 頂点a, bはすでに連結なので、不便さは変わらない
            ans_tmp.append(ans_tmp[-1])
        else:
            # 頂点a, bが連結することで不便さが減る
            ans_tmp.append(ans_tmp[-1] - (uf.get_size(a) * uf.get_size(b)))
        uf.union(a, b)
    ans_tmp.pop()  # すべての橋が繋がっているときの不便さは必要ない
    ans = '\n'.join(map(str, ans_tmp[::-1]))
    return ans

N, M = [int(i) for i in input().split()]
Bridges = [[int(i) for i in input().split()] for j in range(M)]
print(d_decayed_bridges(N, M, Bridges))

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

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));
    
    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < t.size(); j++) {
            if(s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j + 1]);
        }
    }

    // 復元
    string res = "";
    int i = s.size(), j = t.size();
    while(i > 0 && j > 0) {
        if(dp[i][j] == dp[i-1][j]) {
            --i;
        }
        else if(dp[i][j] == dp[i][j-1]) {
            --j;
        }
        else {
            res = s[i-1] + res;
            --i, --j;
        }
    }

    cout << res << endl;

    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<LL> v(n);
  LL a,b;
  LL ans=0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    v[i]=a+b;
    ans-=b;
  }
  sort(all(v),greater<LL>());
  for(int i=0;i<n;i+=2){
    ans+=v[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
struct point{
    int x,y;
};
double dist(point a){
    long long ret = (long long)a.x*a.x + (long long)a.y*a.y;
    return sqrt(ret);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, D;
    cin >> N >> D;
    int ans = 0;
    for(int i = 0; i < N; ++i){
        point a;
        cin >> a.x >> a.y;
        if(dist(a) <= D) ans++;
    }   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;

int main() {
  cin >>N;
  int a,b; cin >>a >>b;
  bool ok = false;
  for (int i=a; i<=b; i++){
    if (i%N == 0) ok = true;
  }
  cout <<(ok ? "OK" : "NG") <<endl;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =2e4+5;
    
     int mod= 1e9+7,INF=1e17;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
     
     int f[N];
     int inv[N];
     
     int pcal(int x,int y){
		 
		 int res=1;
		 x=x%mod;
		 
		 while(y>0){
			 
			 if(y&1)
			  res=(res*x)%mod;
			 
			 y=y>>1;
			 x=(x*x)%mod;
			  
		 }
		 
		 return res;	 
	 }
     
     void pre(){
		 f[0]=1;
		 rep(i,1,N-1)
		   f[i]=(f[i-1]*i)%mod;
		   
		 inv[N-2]=pcal(f[N-2],mod-2);
		 
		 for(int i=N-3;i>=0;i--){
			  inv[i]=((i+1)*inv[i+1])%mod;
		 }
	 }
    
    
     int comb(int n,int r){
		 
		 if(n<r)
		   return 0;
		   
		   return  (((f[n]*inv[n-r])%mod)*inv[r])%mod;
		   
	 }
     
     void solve(){
	      int n,k;
	       cin>>n>>k;
	       
	       pre();
	       
	       rep(i,1,k+1){
			   int nax1=comb(k-1,i-1);
			   int nax2=comb(n-k+1,i);
			   int wyn=(nax1*nax2)%mod;
			   
			   cout<<wyn<<endl;			   
		   }     
	 }
	
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
using namespace std;

const int MAX_N = 1<<17;

int n;
int64_t dat[2*MAX_N-1];

void init(int n_){
    n = 1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++) dat[i]=LLONG_MAX;
}

//0-indexed, k-th to a
void update(int k, int64_t a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}

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

using P = pair<int,int>;

int main(){
    int N;
    cin>>N;
    vector<P> V;
    vector<int> X;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        V.emplace_back(x,i);
        X.push_back(x);
    }
    sort(V.begin(), V.end());
    vector<int> nth(N);
    for(int i=0;i<N;i++){
        nth[V[i].second]=i;
    }
    init(N);
    for(int i=0;i<N;i++){
        update(i,0);
    }
    for(int i=0;i<N;i++){
        int64_t sum = -X[i];
        if(nth[i]){
            sum+=query(0,nth[i]);
        }
        update(nth[i],sum);
    }
    int64_t ans = 0;
    for(auto x:X) ans+=x;
    ans+=query(0,N);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6664
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn int() -> usize {
    read()
}

fn main() {
    let n = int() as usize;
    let mut bs: Vec<usize> = Vec::new();
    for _ in 0..n {
        bs.push(int());
    }

    let mut index = 1;
    let mut counter = 0;
    loop {
        counter = counter + 1;
        let next_index = bs[index - 1];
        bs[index - 1] = 0;
        if next_index == 0 {
            counter = -1;
            break;
        } else if next_index == 2 {
            break;
        }
        index = next_index;
    }
    println!("{}", counter);
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

    int B[N + 1];
    for (int i = 1; i < N; i++) {
        cin >> B[i];
    }

    int ans = 0;
    B[0] = B[N] = 100001;

    for (int i = 0; i < N; i++) {
        ans += min(B[i], B[i + 1]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long; using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

signed main() {
    int n,k;
    cin>>n>>k;
    vi count(n);
    rep(i,k) {
        int d;
        cin>>d;
        rep(j,d) {
            int a;
            cin>>a;
            count[a-1]++;
        }
    }
    int ans = 0;
    for(int a: count) {
        if(a==0)ans++;
    }
    cout<<ans;
    return 0;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if (S[1] >= S[0] * S[2])
            {
                Console.WriteLine(S[2]);
            }
            else
                Console.WriteLine(S[1] / S[0]);


        }
    }
}


Measured memory_bytes: 11092
def resolve():
    N, M = map(int, input().split())
    A = []
    for _ in range(N):
        a = list(map(int, input().split()))
        A.append(a)
    ans = 0
    for i, j in sorted(A, key=lambda x: x[0]):
        if j >= M:
            ans += M * i
            print(ans)
            exit()
        ans += i * j
        M -= j
resolve()

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

int main()
{
  int x, i;
  cin >> x;
  int ans = 1;
  for (i = 2; i*i <= x; i++) {
    int sum = 1;
    while (i*sum <= x)
      sum *= i;
    if (sum > ans)
      ans = sum;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=205,p=998244353;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n;
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read();
	printf("%d\n",360/__gcd(360,n));
	return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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 namespace std;

////////// 最大公約数 ///////////

int gcd(int a,int b){
  if(a%b==0) return(b);
  else return(gcd(b,a%b));
}

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

int main(){
  int N,ans=0;
  cin>>N;
  
  for(int i=1; i<=N; ++i){
    for(int j=1; j<=N; ++j){
      for(int k=1; k<=N; ++k){
        ans+=gcd(i,gcd(j,k));
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    string s;
    int one=0;
    cin >> s;

    for(int i;i<s.size();i++){
        if(s.at(i) == '1') one++;
    }
    cout << min(one, (int)s.size() - one) * 2 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+7) 
#define hmod 1286031825167LL
using namespace std;

string s,t;
int len,pt;
int main(){	
    ios::sync_with_stdio(false);
    cin >> s; len=s.length(); pt=len-1;
    while (pt > 0){
    	if (pt-4 < 0)
    	break;
    	t.clear();
    	for (int i=pt-4;i<=pt;i++){
    		t+=s[i];
		}
		if (t == "dream"){
			pt-=5;
			goto out;
		}
		if (t == "erase"){
			pt-=5;
			goto out;
		}
		if (pt-5 < 0)
		break;
		t.clear();
    	for (int i=pt-5;i<=pt;i++){
    		t+=s[i];
		}
		if (t == "eraser"){
			pt-=6;
			goto out;
		}
		
		if (pt-6 < 0)
		break;
		t.clear();
    	for (int i=pt-6;i<=pt;i++){
    		t+=s[i];
		}
		if (t == "dreamer"){
			pt-=7;
			goto out;
		}
		break;
		out:;
	}
	if (pt == -1)
	cout << "YES\n";
	else
	cout << "NO\n";
    return 0;
}	

Measured memory_bytes: 3736
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int s,w;
	scanf("%d %d",&s,&w);
	if(w>=s) printf("unsafe\n");
	else printf("safe\n");
	return 0;
}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-

def main():
    down_positions = []
    ponds = []
    for index, value in enumerate(raw_input()):
        if value == '\\':
            down_positions.append(index)
        elif value == '/' and down_positions:
            right = index
            left = down_positions.pop()
            area = right - left
            candidate_pond = []
            while ponds and left < ponds[-1][0]:
               candidate_pond.append(ponds.pop(-1))

            new_pond = (left, area + sum([x[1] for x in candidate_pond]))
            ponds.append(new_pond)
    
    print sum(x[1] for x in ponds)
    print len(ponds), 
    for pond in ponds:
        print pond[1], 

if __name__ == '__main__':
    main()

Measured memory_bytes: 6964
//-------------
//include
//-------------
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  set<int> SI;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int N,ANS;
	cin >> N;
	if (N >= 64)
	{
		ANS = 64;
	}
	else if (N >= 32)
	{
		ANS = 32;
	}
	else if (N >= 16)
	{
		ANS = 16;
	}
	else if (N >= 8)
	{
		ANS = 8;
	}
	else if (N >= 4)
	{
		ANS = 4;
	}
	else if (N >= 2)
	{
		ANS = 2;
	}
	else if (N == 1)
	{
		ANS = 1;
	}
	COUT(ANS);
#ifdef _DEBUG
	while (1);
#endif // _DEBUG

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i,d,S;
	while (scanf("%d",&d)!=EOF){
		S=0;
		for (i=0;i<600;i+=d){
			S+=d*pow(i,2);
		}
		printf("%d\n",S);
	}
	return 0;
}

Measured memory_bytes: 596