akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String input_n = ""; // 入力された次元数nを受け取る変数
		String input_X = ""; // 入力されたxの要素を受け取る変数
		String input_Y = ""; // 入力されたyの要素を受け取る変数
		int n = 0; // 次元数nをint型に変換して格納するための半数
		String[] X_String;// xの要素を配列で受け取るための変数
		String[] Y_String;// yの要素を配列で受け取るための変数
		int[] X_int; // X_Stringの要素を整数に変換して格納するための配列
		int[] Y_int;// Y_Stringの要素を整数に変換して格納するための配列
		double[] XY;// xiyiの距離を格納した配列
		double max = 0.0; // チェビシェフ距離における一時的なXY[i]の最大値
		double[] P_out = new double[4];// p=1、2、3、∞ のときの値を格納するための配列

		area: {
			input_n = sc.nextLine();
			n = Integer.parseInt(input_n);
			if (n < 1 || n > 100) {
				break area;

			}

			input_X = sc.nextLine();
			X_String = input_X.split(" ");

			input_Y = sc.nextLine();
			Y_String = input_Y.split(" ");

			if (X_String.length != n || Y_String.length != n) { // 入力されたXの要素とYの要素の数がそれぞれではない場合
				break area;
			}

			X_int = new int[n];
			Y_int = new int[n];
			XY = new double[n];

			for (int i = 0; i < n; i++) {
				X_int[i] = Integer.parseInt(X_String[i]);
				Y_int[i] = Integer.parseInt(Y_String[i]);

				// xiの値のチェック
				if (X_int[i] < 0 || X_int[i] > 1000) {
					break area;
				}

				// yiの値のチェック
				if (Y_int[i] < 0 || Y_int[i] > 1000) {
					break area;
				}

				XY[i] = Math.abs((double) X_int[i] - (double) Y_int[i]);
				P_out[0] += XY[i];
				P_out[1] += XY[i] * XY[i];
				P_out[2] += XY[i] * XY[i] * XY[i];

				if (i == 0) {
					max = XY[i];
				} else {
					if (max < XY[i]) {
						max = XY[i];
					}
				}// elseここまで
			}// for文ここまで

			// 始: p=1、2、3、∞ のときの値を求める

			// p=1は各XYiを足すだけでよいので処理する必要がないのでp=2、3、∞ のみの値を求める

			P_out[1] = Math.sqrt(P_out[1]);
			P_out[2] = Math.cbrt(P_out[2]);
			P_out[3] = max;

			// 終: p=1、2、3、∞ のときの値を求める

			for (int j = 0; j < P_out.length; j++) {
				System.out.printf("%.5f", P_out[j]);
				System.out.println();
			}

		}// area: ここまで

	}
}


Measured memory_bytes: 26464
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {

	int N;
	int D[100000];
	int R=0;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>D[i];
	}

	int a1=1,a2=1,a3=1;
	for(int i=1;i<N;i++){
		if(D[i]==D[i-1]){
			R=max(R,a3);
			a3=a2+1;
			a2=a1+1;
			a1=1;

		}
		if(D[i]!=D[i-1]){
			a1+=1;
			a2+=1;
			a3+=1;
		}

	}
	R=max(R,a1);
	R=max(R,a2);
	R=max(R,a3);

	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 3472
n = int(input())
print(str(n)+":",end = " ")

while n >= 4 and n % 2 == 0:
    print("2",end = " ")
    n //= 2
d = 3
q = n//d
while q >= d:
    if(n % d == 0):
        print(str(d),end = " ")
        n = q
    else:
        d += 2
    q = n // d
print(str(n))

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
   int n,m;
   cin>>n>>m;
   int sum=0;
   for(int i=1;i<=m;i++)
   {
       int x;
       cin>>x;
       sum+=x;
   }
   int ans=-1;
   if(sum<=n)
        ans=n-sum;
   cout<<ans;    
}

Measured memory_bytes: 3624
s=list(map(int,input().split()))
if (s[2]-s[1])%2==0:
  print(int((s[2]-s[1])//2))
else:
  if s[2]-1>=s[0]-s[1]:
    if (s[2]-s[1]-1)//2+s[0]-s[2]+1>s[0]-s[1]:
      print(s[0]-s[1])
    else:
      print(int((s[2]-s[1]-1)//2+s[0]-s[2]+1))
  else:
    if (s[2]-s[1]-1)//2+s[1]>s[2]-1:
      print(s[2]-1)
    else:
      print(int((s[2]-s[1]-1)//2+s[1]))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll> 
#define mll map<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ing(m,ad) rep(i,m){ int u,v; cin>>u>>v; u--;v--; ad[u].pb(v); ad[v].pb(u);}
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod (ll)1000000007
const int MAXN=1000005;
int spf[MAXN];
ll fac1[MAXN],fac2[MAXN],inv[MAXN];
ll gcd(ll x, ll y){ return y?gcd(y,x%y):x; }

void sieve(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

void pre(){
    fac1[0]=fac2[0]=inv[1]=1;
    for(ll i=1;i<MAXN;i++){
        fac1[i]=(fac1[i-1]*i)%mod;
        if(i>1) inv[i]=( mod - ((ll)(mod/i)*inv[mod%i])%mod ) %mod;
    }
    for(int i=1;i<MAXN;i++) fac2[i]=(fac2[i-1]*inv[i])%mod;
}
ll C(int n,int k){
    if(n<k) return 0;
    return ((fac1[n]*fac2[n-k]%mod)*fac2[k]%mod);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    pre();
    while(t--){
        cin>>n;
        n-=3;
        ll ans=0,r=1;
        while(n>=0){
            ans=(ans+C(n+r-1,r-1))%mod;
            r++; n-=3;
        }
        cout<<ans<<nl;
    }
    return 0;
}

Measured memory_bytes: 26640
let S = readLine()!.characters.enumerate()
var ans = S.map{_ in 0}
var cnt = [0,0]
for (i,c) in S {
    if c == "R" {
        cnt[i%2]++
    } else {
        ans[i] += cnt[i%2]
        ans[i-1] += cnt[i%2^1]
        cnt = [0,0]
    }
}
for (i,c) in S.reverse() {
    if c == "L" {
        cnt[i%2]++
    } else {
        ans[i] += cnt[i%2]
        ans[i+1] += cnt[i%2^1]
        cnt = [0,0]
    }
}
ans.forEach{print($0,terminator:" ")}

Measured memory_bytes: 7008
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M;
  cin >> N >> M;
  vi H(N);
  cin >> H;

  v(bool) ans(N, true);
  i64 a, b;
  rep(i, M){
    cin >> a >> b;
    a--;
    b--;
    if(H[a]<=H[b]){
      ans[a] = false;
    }
    if(H[a]>=H[b]){
      ans[b] = false;
    }
  }

  cout << accumulate(rng(ans), 0LL) << "\n";

}

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

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int MAXN = 3e5 + 10;
const int MAXM = 1e6 + 10;
const ll mod = 1e9 + 7;

int n,ans = 0;

struct node {
    int x,y;
}a[110],b[110];
int g[110][110];
int link[110];
bool vis[110];

bool dfs(int num) {
    for(int i=0; i<n; i++) {
        if(g[num][i] && !vis[i]) {
            vis[i] = 1;
            if(link[i] == -1 || dfs(link[i])) {
                link[i] = num;
                return true;
            }
        }
    }
    return false;
}

int main()
{
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d%d",&a[i].x,&a[i].y);
    for(int i=0; i<n; i++) {
        scanf("%d%d",&b[i].x,&b[i].y);
        for(int j=0; j<n; j++) {
            if(a[j].x < b[i].x && a[j].y < b[i].y) g[j][i] = 1;
        }
    }
    mst(link,-1);
    for(int i=0; i<n; i++) {
        mst(vis,false);
        if(dfs(i)) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  int m = 100000000; //そこまでのmin
  for (int i = 0;i < N;i++) {
    int p;
    cin >> p;
    if (m >= p) {
      ans++;
      m = p;
    }
  }
  cout << ans << endl;
}



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

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

using namespace std;
typedef long long ll;

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    vector<int> p(3), need(2);
    cin >> p[0] >> p[1] >> p[2] >> need[0] >> need[1];
    p[2] = min(p[2] * 2, p[0] + p[1]);
    if (need[0] > need[1]){
        swap(need[0], need[1]);
        swap(p[0], p[1]);
    }
    int res = p[2] * need[0];
    res += (need[1] - need[0]) * min(p[1], p[2]);
    cout << res << '\n';
}


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

int main(){
  long long K;
  vector<long long> t;

  cin >> K;

  for (int i = 1; i < 10; i++){
    t.push_back(i);
  }

  for (int i = 0; i < K; i++){
    if ((t[i] % 10) - 1 != -1){
      t.push_back(t[i] * 10 + t[i] % 10 - 1);
    }
    t.push_back(t[i] * 10 + t[i] % 10);

    if ((t[i] % 10) + 1 != 10){
      t.push_back(t[i] * 10 + t[i]% 10 + 1);
    }
  }

  cout << t[K - 1] << endl;

  return 0;

}


Measured memory_bytes: 6512
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2) {
        puts("No");
        return 0;
    }
    rep(i,n/2) {
        if(s[i] != s[i+n/2]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");

    return 0;
}


Measured memory_bytes: 3600
N = int(input())
A = list(map(int,input().split(sep=" ")))
S = [0 for i in range(0,N+1,1)]
for i in range(0,N,1):
    S[A[i]] += 1
Sum = 0
for i in range(1,N+1,1):
    Sum += S[i]*(S[i]-1)//2
for k in range(0, N ,1):
    print(Sum - S[A[k]] +1)

Measured memory_bytes: 85212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 998244353;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
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;
}
int main() {
  ll n,k;
  cin>>n>>k;
  n=n%k;
  cout<<min(n,k-n)<<endl;
}

Measured memory_bytes: 256
use std::io::prelude::*;

const MOD : u64 = 1_000_000_007;
enum State { X(u64), Y1(u64), Y2(u64), }

fn main(){
  let mut buf = String::new();
  std::io::stdin().read_to_string(&mut buf).expect("fail to read");
  let mut lines = buf.lines();
  
  let n : usize = lines.next().unwrap().parse().unwrap();
  let S : Vec<_> = lines.map(|s| s.as_bytes()).collect();

  use State::*;
  let s0 = if S[0][0] == S[1][0] { X(3) } else { Y1(6) };
  
  let ans = (1 .. n).fold(s0, |s, i| {
    if S[0][i] == S[1][i] {
      match s {
        X(v) => X(v * 2 % MOD),
        Y2(v) => X(v),
        _ => unreachable!(),
      } 
    } else {
      match s {
        X(v) => Y1(v * 2 % MOD),
        Y2(v) => Y1(v * 3 % MOD),
        Y1(v) => Y2(v),
      }
    }
  });
  
  match ans {
    X(v) => println!("{}", v),
    Y2(v) => println!("{}", v),
    _ => unreachable!(),
  }
  
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, y;
  cin >> n >> y;

  for (int i = 0; i <= n; i++) {
    for (int j = 0; i + j <= n; j++) {
      int k = n - (i + j);
      if (y == i * 10000 + j * 5000 + k * 1000) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll mod = 1000000007;


void swap(ll &a, ll &b){
    ll c = a;
    a = b;
    b = c;
}

ll modadd(ll a, ll b){
    return (a+b)%mod;
}

ll modsub(ll a, ll b){
    ll c = (a-b)%mod;
    if(c < 0){
        c += mod;
    }
    return c;
}

ll modmul(ll a, ll b){
    return ((a%mod) * (b%mod)) % mod;
}

ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

ll moddiv(ll a, ll b) {
    return ((a%mod) * (modinv(b))) % mod;
}


ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = modmul(res, a);
        a = modmul(a,a);
        n >>= 1;
    }
    return res;
}

ll modcomb(ll a, ll b){
    ll x = 1;
    for(int i=0; i<b; i++){
        x = modmul(x, modsub(a,i));
    }
    ll y = 1;
    for(int i=0; i<b; i++){
        y = modmul(y, modsub(b,i));
    }
    return moddiv(x,y);
}


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

    ll s[2001];
    s[0] = 0;
    s[1] = 0;
    s[2] = 0;
    s[3] = 1;
    s[4] = 1;
    s[5] = 1;

    for(int i=6; i<=S; i++){
        s[i] = 1;
        for(int j=3; i-j>=3; j++){
            s[i] = modadd(s[j], s[i]);
        }
    }

    cout << s[S] << endl;

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define orta ((l+r)>>1)
#define sol (node+node)
#define sag (node+node+1)
#define inf 1000000009
#define infll 1000000000000000009
#define eps 1e-9
#define ppair(x)  "(" << x.first << ", " << x.second << ") "
#define bas(x) #x << ": " << x << " "
#define prarr(x, n); {cout << #x << ": "; for(ll qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << "\n";}
#define prarrv(x); {cout << #x << ": "; for(ll qsd: x) cout << qsd << " "; cout << "\n";}
#define ii pair<ll, ll>
#define mod 1000000007 // 998244353
using namespace std;
typedef long long ll;

vector<ll> arr;
ll n, a, b;

ll bul(ll x){
    ll ans = x;
    for (ll i = 0; i < n; i++){
        ll kes = arr[i] - b*x;
        kes = max(kes, 0LL);
        ans -= kes/a + (kes%a != 0);
    }
    if (ans < 0) return 0;
    return 1;
}

int main(){
//    freopen("/home/cahid/CLionProjects/main/in", "r", stdin);


    cin >> n >> a >> b;
    a = a-b;
    arr.resize(n);
    for (ll i = 0; i < n; i++) cin >> arr[i];

    ll l = 1;
    ll r = 1000000000;
    while (l < r){
        ll mid = (l+r)/2;
        if (bul(mid)) r = mid;
        else l = mid+1;
    }

    cout << l << endl;
}


Measured memory_bytes: 1024
N = int(input())
from collections import Counter
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ca = Counter(A)
cb = Counter(B)
for i in range(1,N+1):
  if ca[i]+cb[i]>N:
    print('No')
    exit()
print('Yes')
from collections import deque
lis = [deque() for _ in range(N+1)]
da = deque(list(range(1,N+1)))
db = deque(list(range(1,N+1)))
while len(da) and len(db):
  a = da.popleft()
  b = db.popleft()
  if a==b:
    if len(db):
      db.append(b)
      b = db.popleft()
    elif len(da):
      da.append(a)
      a = da.popleft()
    else:
      for i in range(1,N+1):
        for _ in range(len(lis[i])):
          c = lis[i].popleft()
          if c!=b:
            lis[b].append(c)
            lis[i].append(b)
            ca[a] -= 1
            cb[b] -= 1
            if ca[a]==0:
              break
          else:
            lis[i].append(c)
        else:
          continue
        break
  if ca[a]>cb[b]:
    for _ in range(cb[b]):
      lis[a].append(b)
    ca[a] -= cb[b]
    cb[b] = 0
    da.appendleft(a)
  else:
    for _ in range(ca[a]):
      lis[a].append(b)
    cb[b] -= ca[a]
    ca[a] = 0
    if cb[b]>0:
      db.appendleft(b)
ans = []
for i in range(1,N+1):
  for _ in range(len(lis[i])):
    b = lis[i].popleft()
    ans.append(b)
print(*ans)


Measured memory_bytes: 278836
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, Q] = nextIntArray()
    const s = next()
    let l = []
    let r = []
    let agg = new Array(N).fill(0)
    let sum = 0
    agg[0] = 0
    for(let i = 1; i<N; i++){
        if(s[i] == "C" && s[i-1] == "A"){
            sum++
        }
        agg[i] = sum
    }
    while(hasNext()){
        let tmp = nextIntArray()
        l.push(tmp[0]-1)
        r.push(tmp[1]-1)
    }
    for(let i = 0; i<l.length;i++){
        console.log(agg[r[i]] - agg[l[i]])
    }

}
Main()



Measured memory_bytes: 61436
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			String a = scan.next();
			
			String b = a.toUpperCase();
			String s = a.toLowerCase();
			
			
			if(a.equals(s)) {
				System.out.println('a');
			}else {
				System.out.println('A');
			}
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 35664
def sol():
    n,m=map(int,input().split())
    k=[]
    for i in range(m):
        l=[int(i) for i in input().split()]
        k.append([l[j]-1 for j in range(1,l[0]+1)])
    p=[int(i) for i in input().split()]
    ans=0
    #for i in range(2**10):
    for i in range(2**n):
        s=bin(i)[2:]
        s="0"*(n-len(s))+s
        s=s[::-1]
        for a,j in enumerate(k):
            chk=f=0
            for x in j:
                if s[x]=="1":
                    chk+=1
            if chk%2!=p[a]:
                f=1
                break
        if f==0:
            ans+=1
    print(ans)

if __name__=="__main__":
    sol()


Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const long long &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
int n, w[100], v[100];
long long dp[100][100001];
long long calc(int i, int w_cap) {
	if(i >= n) return 0;
	if(dp[i][w_cap] != -1) return dp[i][w_cap];
	long long res = calc(i + 1, w_cap);
	if(w[i] <= w_cap) res = max(res, calc(i + 1, w_cap - w[i]) + v[i]);
	return dp[i][w_cap] = res;
}
int main() {
	int w_cap;
	R(n, w_cap);
	for(int i = 0; i < n; i++) R(w[i], v[i]);
	memset(dp, -1, sizeof(dp));
	long long ans = calc(0, w_cap);
	W(ans);
	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  // 10^18 くらいまでいける

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

const ll INF = 1LL << 60;

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;

  int ans=1;
  char c=s[0];  // 現在の最新の文字
  for(int i=0; i<n; i++){
    if (s[i] != c){
      c = s[i];
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int primes(int x){
  for(int i=2;i<x;i++){
    if(x%i==0){
      return -1;
    }
  }
  return 1;
}

int main(void){
  int x;
  
  scanf("%d",&x);
  
  while(1){
    if(primes(x)>0){
      printf("%d",x);
      break;
    }else x++;
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#define MOD 1000000007
using namespace std;
int main(void){
    int n, a[2000];
    long long k, ans = 0;
    map<int, int> p;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
        p[a[i]]++;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if((i-j) * (a[i]-a[j]) < 0)ans++;
        }
    }
    ans *= k;
    ans %= MOD;
    
    int s = 0;
    for(auto x = p.begin(); x!=p.end(); x++){
        ans += ((((k*(k-1)/2)%MOD) * s)%MOD * (x->second))%MOD;
        ans %= MOD;
        s += (x->second);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define mp map<ll,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{ 
	fast 
	ll n,m;
	cin>>n>>m;
	ll ans=1;
	char a[n+5][m+5];
	ll i,j;
	for(i=0;i<=m;i++)
	{
		a[0][i]='#';
	}
	for(i=0;i<=n;i++)
	{
		a[i][0]='#';
	}
	for(i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		for(j=1;j<=m;j++)
		{
			a[i][j]=s[j-1];
		}
	}
	ll dp[n+5][m+5];
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			dp[i][j]=0;
			if(a[i-1][j]=='.')
			{
				dp[i][j]=dp[i-1][j]+dp[i][j];
			}
			if(a[i][j-1]=='.')
			{
				dp[i][j]=dp[i][j-1]+dp[i][j];
			}
			if(a[i-1][j]!='.' && a[i][j-1]!='.')
			{
				dp[i][j]=0;
			}
			if(dp[i][j]>=MOD)
			{
				dp[i][j]=dp[i][j]-MOD;
			}
			if(i==1 && j==1)
			{
				dp[i][j]=1;
			}

		}
	}
	cout<<dp[n][m];


}

Measured memory_bytes: 9088
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ADuplexPrinting {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        cout << (N + 1) / 2 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ADuplexPrinting solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    
    
    char ch;
    int str[26]={}, i=0;
    
    while((ch=getchar())!=EOF){
        if( 'A'<=ch && ch <='Z')str[ch-'A']++;
        if( 'a'<=ch && ch <='z')str[ch-'a']++;
        i++;
    }
    
    for(i=0; i<26; i++){
        printf("%c : %d\n", i+'a', str[i]);
    }
    
return 0;
        
}

Measured memory_bytes: 524
#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 {
#ifndef ONLINE_JUDGE
~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__) << "] "
using ll = long long;
typedef pair<int,int> pie;
#define pb push_back
const int nax = 2e5+100;
bool visited[nax];
vector<int> vertices[nax];
const int inf = 1e6;
int dfs(int u) {
	if(visited[u]) return -inf;
	visited[u] = 1;
	int ret = 1;
	for(auto it:vertices[u]) {
		if(!visited[it]) {
			ret+= dfs(it);
		}
	}
	return ret;
}
int main() {
	int n,m;
	cin >> n >> m;
	for(int i = 0;i<m;i++) {
		int u,v;
		cin >> u >> v;
		vertices[u].pb(v);
		vertices[v].pb(u);
	}
	int maxc = -1;
	for(int i = 1;i<=n;i++) {
		if(!visited[i]) {
			maxc = max(maxc, dfs(i));
		}
 	}
 	cout<<maxc;
}


Measured memory_bytes: 23912
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<stack>
using namespace std;
const int N=1e4+50;
const int INF=0x3f3f3f;
char s[N];
int vis[N];
long long num(int l,int r)
{
    long long sum=0;
    for(int i=l;i<=r;i++){
        sum=sum*10+s[i]-'0';
    }
    return sum;
}
int main()
{
    scanf("%s",s);
    int len=strlen(s);
    long long sum=0;
    int tep= (1<<(len-1))-1;
    for(int i=0;i<=tep;i++)
    {
        memset(vis,0,sizeof(vis));
        int k=0;
        int q=i;
        while(q)
        {
            vis[k++]=q%2;
            q/=2;
        }
        int l=-1,r=0;
        vis[len-1]=1;
       for(int i=0;i<len;i++)
        {
          if(vis[i]==0)
           r++;
          else
          {
            sum+=num(l+1,i);
            l=i;
          }
        }
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 256
def fact(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
        val %= 10**9 + 7
    return val

x, y = map(int,input().split())
ans = 1

if abs(x-y) > 1:
    print(0)

elif x == y:
    print((fact(x)**2 *2) % (10**9+7))

else:
    print((fact(x) * fact(y)) % (10**9+7))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll A,B;
    cin>>A>>B;
    if(A%3==0||B%3==0||(A+B)%3==0)cout<<"Possible";
    else cout<<"Impossible";
    return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> s;
  //.#に
  rep(i, n) {
    if (s[i] == '.') cnt++;
  }
  ans = cnt;
  sum = 0;
  rep(i, n) {
    // iまで.
    if (s[i] == '.')
      cnt--;
    else
      sum++;
    ans = min(ans, cnt + sum);
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 720
#include <stdio.h>
int main(){
  int a,b,k,s,i,c=0;
  scanf("%d%d%d",&a,&b,&k);
  for(i=a;1<=i;i--){
    if(a%i==0&&b%i==0)c++;
    if(k==c)break;
  }
  printf("%d",i);
  return 0;
}

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

int main(){
  int N; cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++)
    cin>>p[i];
  vector<int> sum(N);
  for(int i=0;i<N;i++)
    sum[p[i]-1] = 1e9 + i;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    a[i] = (i+1) * (N+1);
  for(int i=0;i<N;i++)
    cout<<a[i]<<" ";
  cout<<endl;
  for(int i=0;i<N;i++)
    cout<<sum[i] - a[i]<<" ";
  cout<<endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

struct Edge
{
    int to, id;
    Edge(int to, int id) : to(to), id(id) {}
};

vector<Edge> tree[55];

vector<int> path;
bool dfs(int v, int tv, int p = -1)
{
    if (v == tv)
    {
        return true;
    }

    for (Edge e : tree[v])
    {
        if (e.to == p)
            continue;
        if (dfs(e.to, tv, v))
        {
            path.push_back(e.id);
            return true;
        }
    }
    return false;
}

int main()
{
    int n, m;
    cin >> n;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].emplace_back(Edge(b, i));
        tree[b].emplace_back(Edge(a, i));
    }
    cin >> m;
    vector<ll> eset(m);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        path = vector<int>();
        dfs(a, b);
        for (int e : path)
        {
            eset[i] |= 1ll << e;
        }
    }

    ll ans = 0;
    rep(i, 1 << m)
    {
        ll mask = 0;
        rep(j, m)
        {
            if (i >> j & 1)
            {
                mask |= eset[j];
            }
        }
        int whites = __builtin_popcountll(mask);
        ll count = 1ll << (n - 1 - whites);
        if (__builtin_popcountll(i) % 2 == 0)
        {
            ans += count;
        }
        else
        {
            ans -= count;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
    int k;
    cin >> k;
    string result = "";
    for(int i = 0; i < k; i++){
        result += "ACL";
    }
    cout << result << endl;
    return 0;
}

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

int main()
{
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i < 3; i++)
  {
    if (s[i] == t[i])
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}
  

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

ans=True
for i in range(N-1,0,-1):
    if(H[i] < H[i-1]):
        H[i-1] = H[i-1]-1
        if(H[i] < H[i-1]):
            ans=False
            break

if(ans):
    print('Yes')
else:
    print('No')

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


int main() {
    long long g = 1;
    rep(i,18) g *= 10;
    int n;
    cin >> n;
    long long ans = 1;
    bool ng = false;
    rep(i,n) {
        long long a;
        cin >> a;
        if(a == 0) {
            cout << 0 << endl;
            return 0;
        }
        if(ng || a > g/ans) {
            ng = true;
        }
        ans *= a;
    }
    if(ng) cout << -1 << endl;
    else cout << ans << endl;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define PI pair<int,int>
#define PL pair<long int,long int>
#define PLL pair<ll,ll>
#define Tcase int t;cin>>t;while(t--)   
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=b){
  while(b){
  cout<<a;b--;
  }}
    else{
    while(a){
    cout<<b;a--;
    }
    }
  
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

double const INF = 1e18;
struct range { 
  double ma, mi;
  range(): ma(-INF), mi(INF) {}
  range(double hi, double lo): ma(hi), mi(lo) {}
  void update(double v) {
    ma = std::max(ma, v);
    mi = std::min(mi, v);
  }
void print() const { std::cout << "[" << mi << ", " << ma << "]\n"; }
};

void add_time(std::vector<double>& ts, range r[3]) {
  auto add_one = [&](std::vector<double>& t, double v)->void { if(v >= 0 && v <= 2e8) t.push_back(v); };
  //up to stop;
  add_one(ts, r[1].ma - r[2].ma);
  add_one(ts, r[1].ma - r[2].mi);
  add_one(ts, r[1].mi - r[2].ma);
  add_one(ts, r[1].mi - r[2].mi);
  //down to stop;
  add_one(ts, r[0].ma - r[1].ma);
  add_one(ts, r[0].ma - r[1].mi);
  add_one(ts, r[0].mi - r[1].ma);
  add_one(ts, r[0].mi - r[1].mi);
  // up to down
  add_one(ts, (r[0].ma - r[2].ma)*0.5);
  add_one(ts, (r[0].ma - r[2].mi)*0.5);
  add_one(ts, (r[0].mi - r[2].ma)*0.5);
  add_one(ts, (r[0].mi - r[2].mi)*0.5);
}

int main() {
  std::cout << std::setprecision(10) << std::fixed;
  int N; std::cin >> N;
  range x[3], y[3]; // 0:dec, 1:stop, 2:inc
  for(int i = 0; i < N; ++i) {
    double xx, yy; char d; std::cin >> xx >> yy >> d;
    switch(d) {
    case 'R': x[2].update(xx); y[1].update(yy); break;
    case 'L': x[0].update(xx); y[1].update(yy); break;
    case 'U': x[1].update(xx); y[2].update(yy); break;
    case 'D': x[1].update(xx); y[0].update(yy); break;
    }
  }
  std::vector<double> ts(1, 0);
  add_time(ts, x);
  add_time(ts, y);
  std::sort(ts.begin(), ts.end());
  ts.erase(std::unique(ts.begin(), ts.end()), ts.end());
  auto f = [&](double t) {
    auto calc = [](double t, range r[3]) {
      double ma = r[1].ma, mi = r[1].mi;
      ma = std::max(ma, r[0].ma - t);
      ma = std::max(ma, r[2].ma + t);
      mi = std::min(mi, r[0].mi - t);
      mi = std::min(mi, r[2].mi + t);
      return ma - mi;
    };
    return calc(t, x)*calc(t, y);
  };
  
  double ans = INF;
  for(double t: ts) ans = std::min(ans, f(t));
  fin(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    ll n;
    cin>>n;
    vector<string> s(n);
    for(int i=0; i<n; i++) cin>>s[i];
    map<vector<ll>,ll> m;
    for(int i=0; i<n; i++){
        vector<ll> c(26,0);
        for(int j=0; j<s[i].size(); j++){
            c[s[i][j]-'a']++;
        }
        m[c]++;
    }
    ll ans=0;
    for(auto i=m.begin(); i!=m.end(); i++){
        ans+=((i->second))*((i->second)-1)/2;
    }
    cout<<ans<<endl;
}


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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;



int main() {
	int N;cin>>N;
	string ins,outs;cin>>ins>>outs;
	vector<long long int>nums(26);
	nums[ins[0]-'a']=0;
	for (int i = 0; i < N-1; ++i) {
		nums[ins[i] - 'a']+=nums[outs[i] - 'a'];
		if(i==0)nums[ins[i]-'a']++;
		nums[ins[i] - 'a']%=int(1e9+7);
	}
	cout<<nums[outs[N-1] - 'a']<<endl;
	return 0;
}


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

const int N=50010;

unsigned int cost[N];

int main(){
	int n,m;	cin>>n>>m;
	vector<int> coin(m);	for(int i=0;i<m;i++)cin>>coin[i];

	memset(cost,-1,sizeof(cost));
	cost[0]=0;

	for(int i=0;i<m;i++){
		for(int j=coin[i]; j<=n; j++){
			cost[j]=min(cost[j], cost[j-coin[i]]+1);
		}
	}

	cout<<cost[n]<<endl;
	return 0;
}



Measured memory_bytes: 3308
N = int(input())
a = list(map(int, input().split()))
i = 0
odd = 0
while odd == 0:
    for n in range(len(a)):
        if a[n]%2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)

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

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

Measured memory_bytes: 1792
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;
            long ans = 1;

            long L = N;
            while(L >= K){
                L = L / K;
                ans++;
            }

            WriteLine(ans);
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

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

int main(){
  char cmap[8][8];
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++)cin >> cmap[i][j];
  }
  printf("90\n");
  for(int i=0;i<8;i++){
    for(int j=7;j>=0;j--){
      printf("%c",cmap[j][i]);
    }
    printf("\n");
  }
  printf("180\n");
  for(int i=7;i>=0;i--){
    for(int j=7;j>=0;j--){
      printf("%c",cmap[i][j]);
    }
    printf("\n");
  }
  printf("270\n");
  for(int i=7;i>=0;i--){
    for(int j=0;j<8;j++){
      printf("%c",cmap[j][i]);
    }
    printf("\n");
  }
 
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N;
    ll K;
    cin >> N >> K;
    int A[N];
    REP(i, N) cin >> A[i] ;

    int dest[N];
    bool visited[N + 1];
    REP(i, N + 1) visited[i] = false;
    dest[0] = 1;
    visited[1] = true;
    int nloop = 1;
    REP(i, N) {
        int n = A[dest[i] - 1];
        if (visited[n]) {
            dest[i + 1] = n;
            break;
        }
        else {
            dest[i + 1] = n;
            nloop++;
            visited[n] = true;
        }
    }

    int r = 0;
    REP(i, nloop) {
        if (dest[nloop] == dest[i]) {
            break;
        }
        else {
            r++;
        }
    }
    int l = nloop - r;

    if (K <= r) {
        cout << dest[K] << endl;
    }
    else {
        ll a = (K - r) % l;
        cout << dest[r + a] << endl;
    }

    return 0;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    s[k-1] = tolower(s[k-1]);

    cout << s << endl;

    return 0;

} /*atcoder*/




Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
using namespace std;

stack<int> mizu_whole;
stack<pair<int, int> > mizu;
vector<int> ans;
int sum;

void solve() {
  char c;
  for (int i = 0; cin >> c; ++i) {
    if (c == '\\') {
      mizu_whole.push(i);
    } else if (c == '/' && !mizu_whole.empty()) {
      int left = mizu_whole.top();
      mizu_whole.pop();
      int area = i - left;
      while (!mizu.empty() && left <= mizu.top().first) {
        area += mizu.top().second;
        mizu.pop();
      }
      mizu.push(make_pair(left, area));
    }
  }
  while (!mizu.empty()) {
    sum += mizu.top().second;
    ans.push_back(mizu.top().second);
    mizu.pop();
  }
  reverse(all(ans));
  cout << sum << endl << ans.size();
  for (int area : ans) {
    cout << " " << area;
  }
  cout << endl;
}
int main() {
  solve();
  return 0;
}



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


int main(){
ll n,d,x,y,co=0;
cin >> n>> d;
 
  rep(i,n){
    cin >> x >> y;
    
    if(sqrt(x*x+y*y)<=d)
      co++;
  }
  cout << co << endl;
}

Measured memory_bytes: 3660