akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};
ll mod_pow(ll x, ll n) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % MOD, n / 2);
	if (n & 1) res = res * x % MOD;
	return res;
}
 
ll comb(ll a, ll b) {
	ll mul = 1;
	ll div = 1;
	rep(i, 0, b) {
		mul *= (a - (ll)i);
		mul %= MOD;
		div *= ((ll)i + 1);
		div %= MOD;
	}
 
	mul *= mod_pow(div, MOD - 2);
	return mul%MOD;
}
bool isPrime(int x) {
  if (x < 2)
    return false;
  else if (x == 2)
    return true;
  else if (x % 2 == 0)
    return false;

  double sq = sqrt(x);
  for (int i = 3; i <= sq; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
ll n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    ll ans = 1;
    for (ll i = 2; i * i <= m; i++) {
      ll a = 0;
      while (m % i == 0) m /= i, a++;
      ans = (ans * comb(n + a - 1, a)) % MOD;
    }
    if (m > 1) ans = ans * comb(n, 1) % MOD;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	q := getNextInt(scanner)
	cc := make([]int, n)
	ii := make([][]int, n)
	for i := 0; i < n; i++ {
		cc[i] = getNextInt(scanner) - 1
		ii[cc[i]] = append(ii[cc[i]], i)
	}
	nn := make([]int, n)
	for i := 0; i < n; i++ {
		nn[i] = n
	}
	for i := 0; i < n; i++ {
		for j := 0; j < len(ii[i])-1; j++ {
			nn[ii[i][j]] = ii[i][j+1]
		}
	}

	pp := make(pairs, q)
	for i := 0; i < q; i++ {
		l := getNextInt(scanner) - 1
		r := getNextInt(scanner)
		pp[i][0] = l
		pp[i][1] = r
		pp[i][2] = i
	}
	sort.SliceStable(pp, pp.less)
	seg := newSegment(n + 1)
	p := n
	ans := make([]int, q)
	for i := 0; i < q; i++ {
		l := pp[i][0]
		r := pp[i][1]
		qi := pp[i][2]
		for p-1 >= l {
			p--
			seg.update(nn[p], seg[0][nn[p]]+1, seg.add)
		}
		ans[qi] = r - l - seg.query(0, r, 0, seg.add)
	}
	for i := 0; i < q; i++ {
		fmt.Fprintln(writer, ans[i])
	}
}

type pairs [][3]int

func (p pairs) less(i, j int) bool {
	return p[i][0] > p[j][0]
}

type segment [][]int

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]int, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]int, 1))
	return seg
}
func (seg segment) update(i int, v int, f func(x, y int) int) {
	seg[0][i] = v
	for h := 1; h < len(seg); h++ {
		i >>= 1
		if i<<1+1 < len(seg[h-1]) {
			seg[h][i] = f(seg[h-1][i<<1], seg[h-1][i<<1+1])
		} else {
			seg[h][i] = seg[h-1][i<<1]
		}
	}
}
func (seg segment) query(l, r int, s int, f func(x, y int) int) int {
	for h := 0; h < len(seg) && l < r; h++ {
		if l&1 == 1 {
			s = f(s, seg[h][l])
			l++
		}
		l >>= 1
		if r&1 == 1 {
			s = f(s, seg[h][r-1])
		}
		r >>= 1
	}
	return s
}
func (seg segment) add(x, y int) int {
	return x + y
}


Measured memory_bytes: 49668
N,x=list(map(int,input().split()))
a=list(map(int,input().split()))

op=0

for i in range(N-1):
    s=a[i]+a[i+1]
    opc=max(0,s-x)
    a[i+1]=max(0,a[i+1]-opc)
    op+=opc

print(op)

Measured memory_bytes: 14060
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
struct node {
	int p = -1, sib = -1, c1 = -1, c2 = -1, d = -1, h = -1;
};
node tree[30]; int n;
void f(int t) {
	int k = -1;
	if (tree[t].c1 != -1) {
		tree[tree[t].c1].d = tree[t].d + 1;
		f(tree[t].c1);
		k = max(k, tree[tree[t].c1].h);
	}
	if (tree[t].c2 != -1) {
		tree[tree[t].c2].d = tree[t].d + 1;
		f(tree[t].c2);
		k = max(k, tree[tree[t].c2].h);
	}
	tree[t].h = k + 1;
	return;
}
signed main() {
	cin >> n;
	for0(i, n) {
		int a, b, c; cin >> a >> b >> c;
		tree[a].c1 = b;
		tree[a].c2 = c;
		tree[b].p = a;
		tree[b].sib = c;
		tree[c].p = a;
		tree[c].sib = b;
	}
	for0(i, n)if (tree[i].p == -1) {
		tree[i].d = 0; f(i);
	}
	for0(i, n) {
		cout << "node " << i << ": parent = " << tree[i].p << ", sibling = " << tree[i].sib << ", degree = ";
		if (tree[i].c1 < 0 && tree[i].c2 < 0)cout << 0;
		else if (tree[i].c1 * tree[i].c2 < 0 || tree[i].c1 + tree[i].c2 == -1)cout << 1;
		else cout << 2;
		cout << ", depth = " << tree[i].d << ", height = " << tree[i].h << ", ";
		if (tree[i].p == -1)cout << "root\n";
		else if (tree[i].c1 < 0 && tree[i].c2 < 0)cout << "leaf\n";
		else cout << "internal node\n";
	}
}


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

int main() {
  int n, i, ans = 0;
  double avr = 0, eps = 100000.0;
  cin >> n;
  vector<double> a(n);
  for (i = 0; i < n; ++i) {
    cin >> a[i];
    avr += a[i];
  }
  avr /= n;
  for (i = 0; i < n; i++) {
    if (eps > abs(avr - a[i])) {
      ans = i;
      eps = abs(avr - a[i]);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <climits>
using namespace std;
const int nmax=100005;
long long opt[nmax],sum[nmax],a[nmax];
long long S,mx;
int n,i,k;
int main()
{
    cin>>n>>k;mx=LLONG_MIN;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        sum[i]=1LL*sum[i-1]+a[i];
        opt[i]=1LL*opt[i-1]+max(a[i],0LL);
    }
    for(i=1;i<=n-k+1;i++)
    {
        S=1LL*sum[i+k-1]-sum[i-1];
        mx=1LL*max(opt[i-1]+opt[n]-opt[i+k-1]+max(S,0LL),mx);
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
using namespace std;

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    string s; cin >> s;

    // set<ll> ans;
    vector<ll> ans;
    REP(i, (1 << (s.size() - 1))) {
        int l = 0;
        ll  a = 0;
        REP(j, s.size() - 1) {
            if (i >> j & 1) {
                string ts = s.substr(l, j-l+1);
                // cout << l << " " << j-l+1 << " " << ts << endl;
                // cout << ts;
                a += atol(ts.c_str());
                l = j+1;
            }
        }
        string ts = s.substr(l, s.size() - l  + 1);
        a += atol(ts.c_str());
        // cout << ts << endl;
        // ans.insert(a);
        ans.push_back(a);
    }

    ll a = 0;
    // for(set<ll>::iterator it = ans.begin(); it != ans.end(); ++it) {
    for(vector<ll>::iterator it = ans.begin(); it != ans.end(); ++it) {
        // cout << *it << endl;
        a += *it;
    }
    // cout << ans[0] << endl; 
    // string ts = s.substr(0, s.size() + 1);
    // cout << ts << " " << atol(ts.c_str()) << endl;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

void go(ll &a, ll b) {
	if (a < b) a = b;
}

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

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

		vector<vector<ll> > dp(n + 1, vector<ll>(2, -1));
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 2; j++) {
				if (dp[i][j] == -1) continue;
				if (j == 0) {
					go(dp[i + 1][a[i] % 2], dp[i][j] + a[i] / 2);
				}
				else {
					if (a[i] == 0) go(dp[i + 1][0], dp[i][j]);
					else {
						int cc = a[i] + 1;
						go(dp[i + 1][cc % 2], dp[i][j] + cc / 2);
					}
				}
				//int cc = a[i] + j;
				//dp[i + 1][cc % 2] = max(dp[i + 1][cc % 2], dp[i][j] + cc / 2);
			}
		}
		cout << max(dp[n][0], dp[n][1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int min(int a,int b){

    if(a>=b){return b;}
    return a;
}


int main(void){
double a,b,h,m;
double hkaku,mkaku;
double dif;
double ans;
scanf("%lf %lf %lf %lf",&a,&b,&h,&m);

mkaku=(double)6.0*m;
hkaku=(double)30.0*h+0.5*m;
dif=fabs(mkaku-hkaku);
dif=dif*3.14159265358979/180.0;
ans=sqrt((double)(a*a)+(b*b)-(2.0*a*b*cos(dif)));
//printf("%lf %lf %lf %.100lf %.100lf",mkaku,hkaku,dif,ans,ans2);
printf("%.40lf",ans);
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2;
typedef pair<int, P2> P3; typedef long long ll; typedef long double ld;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<10> fact; constexpr Prime<10> prime;
constexpr int comb(int a, int b){long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

int main(){
	string s, w;
	cin >> s; w += s[0];
	cin >> s; w += s[1];
	cin >> s; w += s[2];
	
	cout << w << endl;
	return 0;
}


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

using namespace std;

const long long INF = 1LL << 60;
const long long P = 1000000007;

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  set<string> st;
  for(int i = 1; i <= k; i++) {
    for(int j = 0; j < s.size(); j++) {
      string t = s.substr(j,i);
      st.insert(t);
    }
  }
  auto itr = st.begin();
  itr = next(itr, k-1);
  cout << *itr << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
const int stack_max_zize = 1000000;
template<class T>
class Stack{
  private:
    int pos;
    T S[stack_max_zize];
  public:
    Stack(){
      pos = 0;
    }
    bool isEmpty(){
      return pos == 0;
    }
    bool isFull(){
      return pos >= stack_max_zize - 1;
    }
    void push(T x){
      if(isFull()){
        cout << "Full" <<endl;
        assert(!isFull());
      }
      pos++;
      S[pos] = x;
    }
    T top(){
        if(isEmpty()){
          cout << "Empty" <<endl;
          assert(!isEmpty());
        }
      return S[pos];
    }
    void pop(){
      if(isEmpty()){
        cout << "Empty" <<endl;
        assert(!isEmpty());
      }
      pos--;
    }
    int size(){
      return pos;
    }
};

//-----------------------------------------
int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  Stack<int> S;
  string c;
  while(cin>>c){
    if(c=="+"){
      int a = S.top();
      S.pop();
      int b = S.top();
      S.pop();
      S.push(a+b);
    }
    else if(c=="-"){
      int a = S.top();
      S.pop();
      int b = S.top();
      S.pop();
      S.push(b-a);
    }
    else if(c=="*"){
      int a = S.top();
      S.pop();
      int b = S.top();
      S.pop();
      S.push(a*b);
    }
    else{
      S.push(stoi(c));
    }
  }

  cout << S.top() <<endl;


  return 0;
}


Measured memory_bytes: 3260
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String param[] = input.split(" ");
        
        int a = Integer.parseInt(param[0]);
        int b = Integer.parseInt(param[1]);
        int c = Integer.parseInt(param[2]);
        if(a < b && b < c){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int a[100000];
    bool b[100000];
    int ans=1;
    int count=0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        b[i]=true;
    }
    while(true){
        if(ans==2){
            cout << count << endl;
            break;
        }
        if(b[ans]==false){
            cout << -1 << endl;
            break;
        }
        b[ans]=false;
        ans=a[ans];
        count++;
    }
}

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

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  int c = 1, l = 0;

    int v = 1;
    while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
 

  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}


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

#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for (int i=0; i<n; ++i)

const int N_MAX = 2*1e5;
int p[N_MAX];

int main() {
//  std::cout<<std::fixed<<std::setprecision(10);
  int n; cin>>n;
  rep(i, n){
    cin >> p[i];
  }
  // 4 2 5 1 3
  int tmp=N_MAX+1; int ans=0;
  rep(i, n){
    if(p[i] < tmp){
      ans++;
    }
    tmp = min(tmp, p[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}
 
int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    out( ceil(n, min({a, b, c, d, e})) + 4 );
    re0;
}

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A, B;
signed main() {
    cin >> A >> B;
    cout << max(0LL, A - B - B) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	//RockPaperScissors
  public static void main( String[] args ) {
	  Scanner scan = new Scanner(System.in);
	  String S = scan.next();
	  boolean condition = true;
	  if( !(S.substring(0,1).equals("A")) ) {
		  condition = false;
		  //System.out.println("先頭の文字がAではないです。");
	  }
	  int C_cnt = 0;
	  for( int i = 2; i < S.length() - 1; i++ ) {
		  if( S.substring(i,i + 1).equals("C") )C_cnt++;
	  }
	  if( C_cnt != 1 ) {
		  condition = false;
		  //System.out.println("大文字のCの数がちょうど1ではないです。");
	  }
	  for( int i = 1; i < S.length();i++ ) {
		  if( !S.substring(i,i + 1).equals(S.substring(i,i + 1).toLowerCase()) && !(S.substring(i,i + 1).equals("C")) ) {
			  condition = false;
			  //System.out.println("AとCを除く文字列に大文字が混ざっています。 -> " + S.substring(i,i + 1) );
		  }
	  }
	  if( condition ) {
		  System.out.println("AC");
	  }else {
		  System.out.println("WA");
	  }
  }
}



Measured memory_bytes: 21844
fun main(args:Array<String>) {
	val s= readLine()!!
	val t= readLine()!!
	val st = mutableMapOf<Char,Char>()
	val ts = mutableMapOf<Char,Char>()
	for(i in 0..s.lastIndex){
		st[s[i]]=t[i]
		ts[t[i]]=s[i]
	}
	
	val ans = (0..s.lastIndex).all{ i->
		st[s[i]]==t[i] && ts[t[i]]==s[i]
	}
	
	println(if(ans)"Yes" else "No")
}

Measured memory_bytes: 39384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    long h, n;
    cin >> h >> n;
    long sum = 0;
    int tmp;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        sum += tmp;
        if (sum >= h) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int num[2000]={},co=n;
        for(int i=0;i<n;i++)cin>>num[i];
        for(int i=0;;i++){
            bool kawa=1;
            if(i==10000){
                cout<<-1<<endl;
                break;
            }
            for(int j=co-1;j>=0&&kawa;j--)if(num[j]!=j+1)kawa=0;
            if(kawa){
                cout<<i<<endl;
                break;
            }
            num[co]=co+1;
            for(int j=0;j<=co;j++){
                if(num[j]==1){
                    for(int k=j+1;k<=co;k++){
                        if(num[k]!=1){
                            swap(num[j],num[k]);
                            break;
                        }
                    }
                }
                num[j]--;
            }
            for(int j=co+1;j>=0;j--){
                if(num[j]!=0){
                    co=j+1;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = sqrt(n); i > 0; i--) {
        if (n % i == 0) {
            ll j = n / i;
            ans = j + i - 2;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main() {
	int n, ans = 0;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 0; i < n; i++) {
		int cnt = 0;
		for (char c = 'a'; c <= 'z'; c++) {
			bool left = false, right = false;
			for (int j = 0; j < i; j++) {
				if (s.at(j) == c) left = true;
			}
			for (int j = i; j < n; j++) {
				if (s.at(j) == c) right = true;
			}
			if (left && right)
				cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(){
    char a[100],b[100];
    int i=0,end = 0;
    scanf("%s%s",a,b);
    while(1){
        if(a[i]=='\0'&&b[i]!='\0'){
            end = 2;
            break;
        }
        if(a[i]!='\0'&&b[i]=='\0'){
            end = 1;
            break;
        }
        if(a[i]=='\0'&&b[i]=='\0'){
            break;
        }
        i++;
    }
    i = 0;
    while(end ==0){
        if(a[i]>b[i]){
            end = 1;
        }
        else if(b[i]>a[i]){
            end = 2;
        }
        else if(a[i] == '\0' &&b[i]=='\0'){
            break;
        }
        i++;
    }
switch(end){
    case 1:
    printf("GREATER");
    break;
    case 2:
    printf("LESS");
    break;
    default:
    printf("EQUAL");
}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

const ll h = modpow(2, MOD - 2);

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct Tree	//create tree(directed) from graph(undirected)
{
    int n;
    int root;
    vector<vector<int>> t;
    vector<int> par;
    vector<int> dpt;
    vector<ll> sz;
    
    void init(Graph &g, int root_){
        n = g.n;
        root = root_;
        t.resize(n);
        par.resize(n);
        dpt.resize(n);
        sz.resize(n);
        fill(dpt.begin(), dpt.end(), -1);
        queue<int> que;
        par[root] = -1;
        dpt[root] = 0;
        que.push(root);
        while(que.size()){
            int pa = que.front();
            que.pop();
            for(int ch : g.g[pa]){
                if(dpt[ch] == -1){
                    t[pa].push_back(ch);
                    par[ch] = pa;
                    dpt[ch] = dpt[pa] + 1;
                    que.push(ch);
                }
            }
        }
    }

    Tree(){}
    
    Tree(Graph &g, int root_){
        init(g, root_);
    }
    
    ll size(int k){
        if(sz[k]) return sz[k];
        ll res = 1;
        for(int ch : t[k]) res += size(ch);
        return sz[k] = res;
    }
};

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }
    Tree t(g, 0);
    ll ans = 0;
    if((int)t.t[0].size() != 1){
        ll s = 1;
        for(int ch : t.t[0]){
            s = (s + MOD - modpow(h, n - t.size(ch) - 1)) % MOD;
        }
        s = (s + modpow(h, n - 1) * ((ll)t.t[0].size() - 1) % MOD) % MOD;
        ans = s * h % MOD;
    }
    for(int i = 1; i < n; i++){
        if((int)t.t[i].size() == 0) continue;
        ll s = 1;
        for(int ch : t.t[i]){
            s = (s + MOD - modpow(h, n - t.size(ch) - 1)) % MOD;
        }
        s = (s + modpow(h, n - 1) * (ll)t.t[i].size() % MOD) % MOD;
        s = (s + MOD - modpow(h, t.size(i) - 1)) % MOD;
        ans = (ans + s * h % MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 29696
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

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


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int a,b; cin >> a >> b;
  if(a+b==15) cout << "+" << endl;
  else if(a*b == 15) cout << "*" << endl;
  else cout << "x" << endl;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,m,a[N],b[N],c[N],p[N],rk[N];
vector<int> G[N],E[N];
bool cmp(int x,int y) { return c[x]<c[y]; }

int f[N];
int find(int x) { return x==f[x]?x:f[x]=find(f[x]); }

ll dp[N],sum[N];
void dfs(int u) {
	sum[u]=b[u],dp[u]=1e18;
	if (E[u].empty()) { dp[u]=max(a[u],b[u]); return; }
	for (int v:E[u]) dfs(v),sum[u]+=sum[v];
	for (int v:E[u])	
		dp[u]=min(dp[u],sum[u]-sum[v]+max(1ll*c[u],dp[v]));
}

int main() {
	n=read(),m=read();
	for (int i=1;i<=n;++i) a[i]=read(),b[i]=read();
	for (int i=1;i<=m;++i) {
		int u=read(),v=read();
		G[u].emplace_back(v),G[v].emplace_back(u);
	}
	for (int i=1;i<=n;++i) c[i]=max(0,a[i]-b[i]),p[i]=i;
	sort(p+1,p+n+1,cmp);
	for (int i=1;i<=n;++i) rk[p[i]]=f[i]=i;
	for (int i=1;i<=n;++i)
		for (int v:G[p[i]])
			if (find(v)!=p[i]&&rk[v]<i)
				E[p[i]].emplace_back(find(v)),f[find(v)]=p[i];
	dfs(p[n]); printf("%lld\n",dp[p[n]]);
	return 0;
}

Measured memory_bytes: 22960
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a;

    cin >> a;

    if (a%2) {
        cout << (a/2+1) * (a/2) << endl;
    }
    else {
        cout << (a/2) * (a/2) << endl;
    }
}


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

int g[200][200], c[200], dis[200][200], n, ans;

int dfs(int x) {
  for (int i = 0; i < n; i++) {
    if (g[x][i] == 1 && c[i] == 0) {
      c[i] = c[x] * -1;
      if (dfs(i) == 0) {
        return 0;
      }
    } else if (g[x][i] == 1 && c[x] == c[i]) {
      return 0;
    }
  }
  return 1;
}

int main() {
  string s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') {
        g[i][j] = 1;
      }
    }
  }
  c[0] = 1;
  if (dfs(0) == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      dis[i][j] = dis[j][i] = 1000;
      if (g[i][j] == 1) {
        dis[i][j] = dis[j][i] = 1;
      }
    }
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ans = max(ans, dis[i][j]);
    }
  }
  cout << ans + 1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

struct aggString {
    string str;
    map<char, int> char_count;

    void init() {
        for (int i = 0; i < str.length(); ++i) {
            ++char_count[str[i]];
        }
    }

    void putString(string s) {
        map<char, int> char_count_tmp;
        for (int i = 0; i < s.length(); ++i) {
            ++char_count_tmp[s[i]];
        }
        for (auto it = char_count.begin(); it != char_count.end(); ++it) {
            if (char_count_tmp[it->first] < it->second) {
                it->second = char_count_tmp[it->first];
            }
        }
    }

    void printCharCount() {
        for (auto it = char_count.begin(); it != char_count.end(); ++it) {
            for (int i = 0; i < it->second; ++i) {
                cout << it->first;
            }
        }
        cout << endl;
    }
};

int main(void){
    // input
    int N;
    string s;
    cin >> N;
    cin >> s;
    struct aggString str = {s};
    str.init();

    for (int i = 0; i < N-1; ++i) {
        cin >> s;
        str.putString(s);
    }

    str.printCharCount();

    return 0;
}

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

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

    int s = t.size();

    rep(i,s) {
        if (t[i] == '?') t[i] = 'D';
    }

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
#include<limits.h>
int main(void)
{

	int  S=700;
	char a, b, c;
	char d = 'o';


	scanf("%c%c%c" , &a, &b, &c);

	if (a == 'o') {
		S += 100;
	}

	if (b == 'o') {
		S += 100;
	}

	if (c == 'o') {
		S += 100;
	}

	printf("%d", S);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;


int main() {
	cin >> X >> A;
	cout << (X < A ? 0 : 10) << endl;
}


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

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while( true ){
			int n = Integer.parseInt(br.readLine());
			int i = 0;
			double m = 0;
			double a = 0;

			if( n==0 ) break;

			String[] s = br.readLine().split(" ");

			for( i=0 ; i<n ; i++ ){
				m = m+Double.parseDouble(s[i]);
			}

			m = m/n;

			for( i=0 ; i<n ; i++ ){
				a = a+Math.pow(Double.parseDouble(s[i])-m, 2);
			}

			a = Math.sqrt(a/n);
			sb.append(String.format("%.6f", a)).append("\n");
 		}

		System.out.print(sb);
	}
}

Measured memory_bytes: 26660
#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

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

	u64 x = (N < B - 1) ? N : B - 1;
	u64 ans = (A * x / B) - A * (x / B);
	
	cout << ans;

	return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

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

#define F first
#define S second

#define popcnt __builtin_popcountll

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

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

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }

template<typename Monoid, typename T = ll> struct SegTree {
	using Func = function<Monoid( Monoid, Monoid )>;
	const Func func;
	const Monoid UNITY;
	T SIZE_R;
	vector<Monoid> data;

	SegTree( T n, const Func f, const Monoid &unity ) :
		func( f ), UNITY( unity ) {
			init( n );
		}

	void init( T n ) {
		SIZE_R = 1;
		while ( SIZE_R < n ) SIZE_R *= 2;
		data.assign( SIZE_R * 2, UNITY );
	}

	void set( T idx, const Monoid &val ) { data[idx + SIZE_R] = val; }
	void build() {
		for ( T k = SIZE_R - 1; k > 0; --k )
			data[k] = func( data[k * 2], data[k * 2 + 1] );
	}

	void update( T idx, const Monoid &val ) {
		T k = idx + SIZE_R;
		data[k] = val;
		while ( k >>= 1 ) data[k] = func( data[k * 2], data[k * 2 + 1] );
	}

	Monoid get( T a, T b ) {
		Monoid vleft = UNITY, vright = UNITY;
		for ( T left = a + SIZE_R, right = b + SIZE_R;
			  left < right;
			  left >>= 1, right >>= 1 ) {
			if ( left & 1 ) vleft = func( vleft, data[left++] );
			if ( right & 1 ) vright = func( data[--right], vright );
		}

		return ( func( vleft, vright ) );
	}

	inline Monoid operator[]( ll idx ) { return ( data[idx + SIZE_R] ); }
};


int main()
{
	ll n, k; cin >> n >> k;
	constexpr ll zero = 0;
	SegTree<ll, ll> seg( 300010, []( ll a, ll b ) { return max( a, b ); }, zero );

	ll ans = 0;
	rep( i, n )
	{
		ll a; cin >> a;
		ll left = max( 0LL, a - k );
		ll right = min( 300000LL, a + k );
		ll tmp = seg.get( left, right + 1 ) + 1;
		chmax( ans, tmp );
		seg.update( a, tmp );
	}

	cout << ans << endl;

	return ( 0 );
}


Measured memory_bytes: 11028
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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




int main(void) {
	int n, q;
	string s;
	int l, r;
	int dp[100002] = {};

	cin >> n >> q;
	cin >> s;
	FOR(i, 0, s.size() - 2) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			dp[i + 1] = dp[i] + 1;
		}
		else {
			dp[i + 1] = dp[i];
		}
	}

	FOR(i, 1, q) {
		cin >> l >> r;

		cout << dp[r-1] - dp[l-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
input = readlines()
h, w, k = input.shift.chomp.split("\s").map{|x| x.to_i}

cells = {}

input.each_with_index do |l, ih|
  l.chomp.split('').each_with_index do |color, iw|
    cells[ih + 1] = {} if cells[ih + 1].nil?
    cells[ih + 1][iw + 1] = color == '.' ? 'white' : 'black'
  end
end

h_list = []
w_list = []

def addNext(tmp, lim)
  res = []
  if tmp.length == 0
    (1..lim).each do |n|
      res.push([n])
    end
  else
    tmp.each do |t|
      (1..lim).each do |n|
        n_tmp = t.clone
        n_tmp.push(n)
        res.push(n_tmp)
      end
    end
  end

  res
end

(1..h).each do |n|
  h_list = addNext(h_list, h)
end

h_uniq = ['0']
h_list.each do |l|
  targets = l.uniq.sort.join(',')
  h_uniq.push(targets) unless h_uniq.include?(targets)
end

(1..w).each do |n|
  w_list = addNext(w_list, w)
end

w_uniq = ['0']
w_list.each do |l|
  targets = l.uniq.sort.join(',')
  w_uniq.push(targets) unless w_uniq.include?(targets)
end

cnt = 0
h_uniq.each do |hl|
  h_targets = hl.split(',').map{|x| x.to_i}
  w_uniq.each do |wl|
    w_targets = wl.split(',').map{|x| x.to_i}
    bk_cnt = 0
    (1..h).each do |h_idx|
      (1..w).each do |w_idx|
        next if h_targets.include?(h_idx)
        next if w_targets.include?(w_idx)
        bk_cnt += 1 if cells[h_idx][w_idx] == 'black'
      end
    end
    cnt += 1 if bk_cnt == k
  end
end

puts cnt


Measured memory_bytes: 51200
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<long int, long int>


int main(){
    long int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    long int p[a], q[b], r[c];
    priority_queue<P, vector<P>, greater<P> > que;
    rep(i, a) {
        cin >> p[i];
        que.push(P(p[i], 0));
    }
    rep(i, b) {
        cin >> q[i];
        que.push(P(q[i], 1));
    }
    rep(i, c) {
        cin >> r[i];
        que.push(P(r[i], 2));
    }
    
    long int numa = a;
    long int numb = b;
    long int numc = c;
    long int ans = 0;
    while (numa + numb + numc  > x + y){
        P d = que.top();
        que.pop();
        if (d.second == 0){
            if (numa + numc > x){
                numa--;
            }else{
                ans += d.first;
            }
        }else if (d.second == 1){
            if (numb + numc > y){
                numb--;
            }else{
                ans += d.first;
            }
        }else{
            if (numb + numc > y && numa + numc > x){
                numc--;
            }else{
                ans += d.first;
            }   
        }
    }
    while(que.size() > 0){
        P d = que.top();
        que.pop();
        ans += d.first;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12396
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
    
int main() {
    ll x=0,y=0,z=0,k,n,m,q,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
    bool ok = true;
    string t;
    cin >> x >> y >> n;
    if(y > n){
        cout << floor(x*n/y) - x*floor(n/y) << endl;
    }
    else
    {
        cout << floor(x*(y-1)/y) - x*floor((y-1)/y) << endl;
    }

    return 0;
}


Measured memory_bytes: 3728
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;

int n,q;
vvi G;
vi p_;

vi cou;
void dfs(int i, int j, int xx) {
    xx += p_[i];
    cou[i] = xx;
    for(int ne:G[i]) {
        if(ne == j) continue;
        dfs(ne, i, xx);
    }
}

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

    p_.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        --p;
        p_[p] += x;
    }


    cou.resize(n);
    dfs(0, -1, 0);

    rep(i, n-1) {
        cout << cou[i] << ' ';
    }
    cout << cou[n-1] << endl;

}

Measured memory_bytes: 24320
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

int main(){
    ll n, p;
    cin >> n >> p;

    vector<P> bunkai;
    ll p2 = p;
    for(ll i = 2; i*i <= p; i++){
        if(p2 % i == 0){
            bunkai.push_back(make_pair(i, 0));
            while(p2 % i == 0){
                bunkai[bunkai.size()-1].second++;
                p2 /= i;
            }
        }
    }
    if(p2 > 1) bunkai.push_back(make_pair(p2, 1));

    ll ans = 1;
    for(auto data: bunkai){
        if(data.second / n >= 1){
            ll coans = data.first;
            for(ll i = 1; i < data.second/n; i++) coans *= data.first;
            ans *= coans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N,i,j,r=0,x;
    cin >> N;
    vector<int> L(N);

    for(i=0; i<N; i++)
        cin >> L.at(i);
    sort(L.begin(), L.end());

    for(i=N-2; i>=1; i--)
        for(j=i-1; j>=0; j--) {
            x = distance(lower_bound(L.begin(), L.end(), L.at(i)+L.at(j)), L.end());
            r += N-1-i-x;
        }
    
    cout << r << endl;
}

Measured memory_bytes: 256
AB = input().split(' ')
A = int(AB[0])
B = int(AB[1])
'''
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
                cf.append(i)
    return cf
 
def check_cf(x1,x2):
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            return False
    return True
candidate = cf(A,B)
'''
'''
decided_list = [candidate[0]]
 
for i in range(1,len(candidate)):
    flag = True
    for s in range(2,candidate[i]):
        if candidate[i]%s == 0:
            flag = False
            break
    if flag:
        decided_list.append(candidate[i])
'''
#print(candidate)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def gcd(num1: int, num2: int) -> int:
    if num2 == 0:
        return num1
    else:
        return gcd(num2,num1%num2)
max_gcd = gcd(A,B)
result = factorization(max_gcd)
#print(result)
if len(result) == 1 and result[0][0] == 1:
    print(1)
else:
    print(len(result)+1)

Measured memory_bytes: 3064