akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, k;
    double result = 0;
    double buf;
    int thresh;
    int count;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        count = 0;
        thresh = i + 1;
        while(thresh < k){
            thresh *= 2;
            count++;
        }
        buf = 1/(double)n * pow(0.5, count);
        result += buf;
    }
    cout << setprecision(12) << result << endl;
}

Measured memory_bytes: 384
from collections import defaultdict
from fractions import gcd
#from math import factorial
from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *

N=int(input())
B=defaultdict(int)
for i in range(N):
    s=input()
    B[s]+=1

M=int(input())
A=defaultdict(int)
for i in range(M):
    s=input()
    A[s]+=1
Max=0
for key in set(A) | set(B):
    Max=max(Max,B[key]-A[key])
print(Max)


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

int A[4], B[4], numberOfHit, numberOfBlow;

void compute(){
  numberOfHit = numberOfBlow = 0;
  bool hasA[10];
  for ( int i = 0; i <= 9; i++ ) hasA[i] = false;

  for ( int i = 0; i < 4; i++ ){
    if ( A[i] == B[i] ) numberOfHit++;
    hasA[ A[i] ] = true;
  }

  for ( int i = 0; i < 4; i++ ){
    if ( hasA[ B[i] ] && A[i] != B[i] ) numberOfBlow++;
  }

  cout << numberOfHit << " " << numberOfBlow << endl;
}

main(){
  while ( cin >> A[0] >> A[1] >> A[2] >> A[3] ){
    cin >> B[0] >> B[1] >> B[2] >> B[3];
    compute();
  }
}

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

using namespace std;

int main(){
    long n,i,x,c=0;
    cin>>n;
    x=n;
    while(1){
        for(i=2;i<=x;i++)
            if(x%i==0)
                c++;
                
        if(c==1){
            cout<<x;
            return 0;
        }
        c=0;
        x++;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const ll INF = 1e18;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll int n,m;
    cin>>n>>m;
    if(n==m)
    	cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(void){
    int A, B, m;
    cin >> A >> B >> m;
    vector<int> a(A), b(B);
    for (int i=0; i<A; i++) cin >> a[i];
    for (int i=0; i<B; i++) cin >> b[i];
    int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    int x, y, c;
    for (int i=0; i<m; i++){
        cin >> x >> y >> c;
        ans = min(ans, (int)(a[x-1] + b[y-1] - c));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, M; cin >> N >> M;
  vector<bool> dp(N,0);
  vector<int> ball(N,1);
  dp[0] = 1;

  int x, y;
  rep(i,M){
    cin >> x >> y;
    x--,y--;
    ball[x]--;
    ball[y]++;
    dp[y] = (dp[y] || dp[x]);
    if (ball[x]==0) dp[x] = false;
  }

  int cnt = 0;
  rep(i,N) if (dp[i]) cnt++;
  cout << cnt << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define INF 1e+9
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int a[200010];

int main(void){
    int N; cin >> N;
    deque<int> que;
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        if(i%2 == 0) que.push_back(a);
        else que.push_front(a);
    }

    if(N%2 == 1) reverse(begin(que), end(que));

    cout << que.front();
    que.pop_front();
    while(not que.empty()){
        cout << ' ' << que.front();
        que.pop_front();
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#define INF 100000000000
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
int n;
vector<vector<int>> tree;
vector<int> a(200000);
vector<int> b(200000);
map<ll, ll> mp;
ll g = 200000;

void dfs(int now,int col,int par) {
	for (auto i : tree[now]) {
		if (i != par) {
			col++;
			mp[now*g + i] += col;
			dfs(i, col, now);
		}
	}
}

int main() {
	cin >> n;
	tree.assign(n, vector<int>());
	for (int i = 0; i < n-1; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		tree[a[i]].push_back(b[i]);
		tree[b[i]].push_back(a[i]);
		mp.insert(P(a[i] * g + b[i],0));
	}
	int k = 0;
	for (int i = 0; i < n; i++) {
		int l = tree[i].size();
		k = max(k, l);
	}
	cout << k << endl;
	dfs(0, 0, -1);
	for (int i = 0; i < n - 1; i++) {
		cout << (mp[a[i] * g + b[i]]-1)%k+1 << endl;
	}
}

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

int main() {
    int n, m, k;
    scanf("%d/%d/%d", &n, &m, &k);
    if (n > 2019) { puts("TBD");
        return 0;
    }
    if (n < 2019) { puts("Heisei");
        return 0;}
    if (m > 4) {
        puts("TBD");
        return 0;
    }
    if (m < 4) {
        puts("Heisei");
        return 0;}
    if (k > 30) {
        puts("TBD");
    } else puts("Heisei");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
 
 
int main() {
	string s;
	int ans = 0;
	cin>>s;
	while(s.size()){
		s.pop_back();
		if(s.size()%2!=0) continue;
		string t;
		for(int i=0;i<s.size()/2;i++) t.pb(s[i]);
		if(t+t==s) ans = max(ans, (int)t.size()*2);
	}
	cout<<ans<<endl;
	return 0;
}

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

namespace CSharpSample01
{
    
    class Program
    {
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int r1 = int.Parse(input[0]);
            int r2 = int.Parse(input[1]);

            double r3 = (double)r1 * r2 / (r1 + r2);

            Console.WriteLine($"{r3:f10}");

        }
    }
}


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

using namespace std;

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

  int n;
  double d;
  cin >> n >> d;

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    long double x, y;
    cin >> x >> y;
    long double dist = sqrt(x * x + y * y);
    if (dist <= d) {
      ++cnt;
    }
  }

  cout << cnt << '\n';

  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

int N;
vi d;
void solve(){
    cin>>N;
    rep(i,N){
        int a; cin>>a; d.push_back(a);
    }
    int ans=0;
    rep(i,N-1) rrep(j,i+1,N) ans+=d[i]*d[j];
    cout<<ans<<endl;
    return;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, y: i64,
        a: [i64; n],
    }
    let s: i64 = a.iter().sum();
    let mut tot: i64 = 0;
    for i in 0..n {
        let mut rot = a[i..].to_vec();
        rot.extend_from_slice(&a[..i]);
        let mut acc = vec![0; n + 1];
        for i in 0..n {
            acc[i + 1] = rot[i] + acc[i];
        }
        let mut dp = vec![vec![0i64; 6]; n + 1];
        dp[0][0] = 1;
        for i in 1..n + 1 {
            for j in 0..i {
                if acc[i] - acc[j] >= s / 5 - y {
                    for k in 0..5 {
                        dp[i][k + 1] += dp[j][k];
                    }
                }
            }
        }
        tot += dp[n][5];
    }
    puts!("{}\n", tot / 5);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 1308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;

    Integer[] primesArr;
    LinkedList<Integer> primes = new LinkedList<Integer>();

    int MAX = 1000000;

    //とりあえず2で割れない数を追加。2も素数なので2も入れる。
    primes.add(2);
    for (int i = 3; i < MAX; i += 2) {
      primes.add(i);
    }

    int m = 3;
    double s = Math.sqrt(MAX);
    int c = 0;
    do {
      Iterator<Integer> it = primes.iterator();
      while (it.hasNext()) {
        int num = it.next();
        if (num % m == 0 && num != m)
          it.remove();
      }
      m = primes.get(c);
      c++;
    } while (m < s);

    primesArr = primes.toArray(new Integer[0]);

    while ((readStr = reader.readLine()) != null && !"".equals(readStr)) {
      int readInt = Integer.parseInt(readStr);
      int count = 0;
      for (Integer i : primes) {
        if (i > readInt)
          break;
        count++;
      }
      System.out.println(count);
    }
  }

}

Measured memory_bytes: 41996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);//N人の子供を宣言
  //どの子供がどれだけお菓子をもらったかを入力
  for (int i = 0; i < K ; i++){
    int di;//i番目のお菓子をもってる人数
    cin >> di;
    int Ai;//i番目のお菓子を持ってる人の番号
    for(int j = 0; j < di ; j++){
    cin >>Ai;//お菓子を持ってる人の番号を入力
    A.at(Ai-1) += 1; //お菓子をもらった人のお菓子の数を＋１
    }
  }
  //A(N)の値を順に調べていって値が0の人数をカウントする
  int count = 0;
  for( int x : A ){//Aの値xをすべて調べる
    if ( x == 0 ) count++;
  }
  cout << count << endl;
}
    

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#define ll long long
using namespace std;


int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	string s;
	cin>>s;
	if(s=="ABC")cout<<"ARC";
	else cout<<"ABC"; 
    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int x, y; cin >> x >> y;
    int sum = 2*x;
    for(int i=0; i <= x; i++){
        if(sum == y){
            cout << "Yes" << endl;
            return 0;
        }else{
            sum += 2;
        }
    }
    cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3104
n = int(input())
l = list(map(int,input().split()))
r = list(map(int,input().split()))
l1 = max(l)
r1 = max(r)
left = 1
if l[0] == l1:left = 0

right = n-2
if r[-1] == l1:right = n-1

res = 1
if l1 != r1:print(0)
else:
    while l[left] != l1:
        if l[left] == l[left-1]:
            res = (res*l[left])%1000000007
        left += 1
    while r[right] != r1:
        if r[right] == r[right+1]:
            res = (res*r[right])%1000000007
        right -=1

    if  left > right:print(0)
    else:
        if  left < right:
            for i in range(right-left-1):
                res = (res*l1)%1000000007

        print(res%1000000007)




Measured memory_bytes: 18884
import sys
input = sys.stdin.readline

import heapq

def main(): 

    N,Q = map(int,input().split())
    
    S = input().split()
    S = list(S[0])
    lr = [list(map(int, input().split())) for _ in range(Q)]

    length = []
    cnt = 0
    length.append(cnt)
    for i in range(1,N):
        if S[i] == "C" and S[i-1] == "A":
            cnt += 1
        length.append(cnt)
    
    for i in range(Q):
        print(length[lr[i][1]-1]-length[lr[i][0]-1])


        


        


if __name__ == "__main__":
    main()
    

Measured memory_bytes: 73096
#include<bits/stdc++.h>
using namespace std;
#define maxn 100100
int a[maxn],b[maxn];
int ta[maxn],tb[maxn];
int n;
map<int,int>mp;
int cnt;
vector<int>g[maxn];
bool ok[maxn],vis[maxn];
void dfs(int u)
{
    vis[u]=true;
    for(int i=0;i<(int)g[u].size();++i)
    {
        int v=g[u][i];
        if(!vis[v])
            dfs(v);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    for(int i=1;i<=n;++i) scanf("%d",&b[i]);
    for(int i=1;i<=n;++i)
    {
        a[0]^=a[i];
        b[0]^=b[i];
        ta[i]=a[i];
        tb[i]=b[i];
        if(i==n)
        {
            ta[0]=a[0];
            tb[0]=b[0];
        }
    }
    sort(ta,ta+n+1); sort(tb,tb+n+1);
    for(int i=0;i<=n;++i)
        if(ta[i]!=tb[i])
        {
            puts("-1");
            exit(0);
        }

    for(int i=0;i<=n;++i)
    {
        if(!mp[a[i]]) mp[a[i]]=++cnt;
        if(!mp[b[i]]) mp[b[i]]=++cnt;
        a[i]=mp[a[i]];
        b[i]=mp[b[i]];
    }
    int ans=0;
    for(int i=0;i<=n;++i)
    {
        if(i>0&&a[i]==b[i]) continue;
        if(i>0) ++ans;
        g[a[i]].push_back(b[i]);
        ok[a[i]]=true;
    }
    for(int i=1;i<=n;++i)
        if(ok[i]&&!vis[i])
        {
            dfs(i);
            ++ans;
        }
    if(ans>0) ans--;
    printf("%d\n",ans);
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    ll W, H, x, y;

    cin >> W >> H >> x >> y;
    
    cout << double(H*W)/2 << endl;

    if((W%2 == 0) && (H%2 == 0)){
        if((x == W/2) && (y == H/2)){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

int main(){
  int n,a;
  deque<int>sort;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    if(i % 2 == n % 2){
      sort.push_back(a);
    }else{
      sort.push_front(a);
    }
  }
  for(int x:sort){
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); ++i)
#define REP(i, d, n) for(long long i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {//---------------------------------------------------------

 int a,b; cin>>a>>b;
  cout<<a*b<<endl;
 
return 0; }


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

signed main() {
    string s;
    int K;
    cin >> s >> K;

    string ans = s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        int t = 'z' - s[i] + 1;
        if (cnt + t <= K) {
            ans[i] = 'a';
            cnt += t % 26;
        }
    }
    char& c = ans.back();
    c = 'a' + (c - 'a' + max(0LL, K - cnt)) % 26;
    cout << ans << endl;
}


Measured memory_bytes: 512
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
p=1
k=0
s=0
for i in range(h):
    c=""
    for j in range(w):
        if i%2==1:
            c=str(p)+" "+c
        else:
            c+=str(p)+" "
        k+=1
        if a[p-1]==k:
            p+=1
            k=0
    else:
        print(c[:-1])

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            var nx = ReadAndParseIntArr();
            int n = nx[0];
            int x = nx[1];
            var a = ReadAndParseIntArr();
            var list = new List<int>(a);
            list.Sort();
            int ans = 0;
            for(int i=0;i<list.Count;++i)
            {
                if( i != list.Count - 1)
                {
                    if( list[i] <= x)
                    {
                        x -= list[i];
                        ans++;

                    }
                }
                else
                {
                    if( list[i] == x)
                    {
                        x = 0;
                        ans++;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        int ab = 0;
        int startBEndA = 0;
        int startB = 0;
        int endA = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            for (int j = 0; j < s[i].length() - 1; j++) {
                if (s[i].charAt(j) == 'A' && s[i].charAt(j + 1) == 'B') {
                    ab++;
                }
            }
            if (s[i].startsWith("B") && s[i].endsWith("A")) {
                startBEndA++;
                continue;
            }
            if (s[i].startsWith("B")) {
                startB++;
            }
            if (s[i].endsWith("A")) {
                endA++;
            }
        }
        int ans = ab;
        if (startBEndA == 0) {
            ans += Math.min(startB, endA);
        } else {
            if (startB == 0 && endA == 0) {
                ans += startBEndA - 1;
            } else {
                ans += startBEndA + Math.min(startB, endA);
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 29924
using System;
using System.Collections.Generic;

namespace ALDS1_4
{
    class Program
    {
        static void Main()
        {
            var h = new HashSet<string>();
            var l = int.Parse(Console.ReadLine());

            for (var i = 0; i < l; i++)
            {
                var _t = Console.ReadLine();
                if (_t[0] == 'i')
                    h.Add(_t.Substring(7));
                else
                    Console.WriteLine(h.Contains(_t.Substring(5)) ? "yes" : "no");
            }
        }
    }
}

Measured memory_bytes: 36988
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


X, Y = list(map(int, sys.stdin.buffer.readline().split()))

ans = 0
if X == Y == 1:
    ans += 400000
if X<= 3:
    ans += [0, 100000, 200000, 300000][-X]
if Y<= 3:
    ans += [0, 100000, 200000, 300000][-Y]
print(ans)


Measured memory_bytes: 23240
#include<bits/stdc++.h>
#define MAIN 110
#define INF 0X3F3F3F3F
using namespace std;
int main()
{
    int n,a[110];
    cin>>n;
    int maxx=-INF,minn=INF;
    int maxnum,minnum;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(maxx<a[i])
        {
            maxx=a[i];
            maxnum=i;
        }
        if(minn>a[i])
        {
            minn=a[i];
            minnum=i;
        }
    }
    if(minn>=0)
    {
        cout<<n-1<<endl;
        for(int i=1; i<n; i++)
            cout<<i<<" "<<i+1<<endl;
        return 0;
    }
    if(abs(minn)<=abs(maxx))
    {
        cout<<n*2-1<<endl;
        for(int i=1; i<=n; i++)
            cout<<maxnum<<" "<<i<<endl;
        for(int i=1; i<n; i++)
            cout<<i<<" "<<i+1<<endl;
        return 0;
    }
    cout<<n*2-1<<endl;
    for(int i=1; i<=n; i++)
        cout<<minnum<<" "<<i<<endl;
    for(int i=n; i>1; i--)
        cout<<i<<" "<<i-1<<endl;
    return 0;
}


Measured memory_bytes: 256
s = int(input())

# number of arrays of 2 elements for every S is:
#   S - 2
i = 0
ans = 0
den = int(1e9 + 7)
s_map = [0, 0, 0, 1]
if s < 3:
    print(s_map[s])
else:
    for i in range(4, s + 1):
        s_map.append(s_map[-1] + s_map[-3])
    print(s_map[-1] % den)

Measured memory_bytes: 9128
n, m = map(int, input().split())
gl=[]
for i in range(m):
	gl.append(list(map(int, input().split())))

gl.sort()
s = 1
e = n
for g in gl:
	if s < g[0]:
		s = g[0]
	if e > g[1]:
		e = g[1]
	#print("{}->{}".format(s, e))

print(max(e - s + 1, 0))

Measured memory_bytes: 27784
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<int> findIDs;
  for (int i=0; i<s.size();i++){
    if(findIDs.size()==0 && s[i]=='A'){
      findIDs.push_back(i);
    }
    if(findIDs.size()>0 && findIDs[0]<i && s[i]=='Z'){
      findIDs.push_back(i);
    }
  }
  cout << findIDs[findIDs.size()-1] - findIDs[0] +1 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin>>n;
    vector<pair<int,int>> r(n),b(n);

    REP(i,n){
        cin>>r[i].second>>r[i].first;
    }

    REP(i,n){
        cin>>b[i].first>>b[i].second;
    }

    sort(r.begin(), r.end(),greater<pair<int,int>>());
    sort(b.begin(), b.end());
    int result = 0;
    REP(i,n){
        
        REP(j,(int)r.size()){
            if(b[i].first>r[j].second&&b[i].second>r[j].first){
                result++;
                /*cout << result << endl
                 << r[i].first << " " << r[i].second << " " << b[i].first << " " << b[i].second << endl;
                */
                r.erase(r.begin() +j);
                break;
            }

        }
        /*
        for(auto x:r){
            cout << x.first<<" " << x.second << endl;
        }
        cout << endl;*/
    }
    cout << result << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int>a(n);

    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]%2==1){
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 0;

    while(1){
        for(int i=0; i<n; i++){
            a[i] /= 2;
        }
        ans++;
        for(int i=0; i<n; i++){
            if(a[i]%2==1){
                cout << ans << endl;
                return 0;
            }
        }
    }
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  bool ans = true;
  
    for (int i = 0; i < N; i++){
    
    if(A.at(i) % 2 == 0 && A.at(i) % 3 != 0 && A.at(i) % 5 != 0){
        ans = false;
      break;
    }
    }

      if(ans){
        cout << "APPROVED" << endl;
      }
      else{
        cout << "DENIED" << endl;
      }
}

Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    s =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    _s = s[0]+str(len(s[1:-1]))+s[-1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(_s)


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

int main(){
  ll result = -1;
 
  ll k;
  cin >> k;
 
  ll val = 7;
  for(ll i=0; i<1000010; ++i){
    if(val % k == 0){
      result = i+1;
      break;
    }
    val %= k;
    val = val * 10 + 7;
  }
  
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3616
## abc070c: Multiple Clocks

def gcm(q,r): ## 最大公約数
    if q<r: q, r = r, q
    while(r>0): q, r = r, q%r,
    return q

def lcm(a,b): ## 最小公倍数
    return a*b//gcm(a,b)

n = int(input())
a = int(input())
for _ in range(n-1): a = lcm(a, int(input()))
print(a)

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

int64_t lucas(int64_t N);

int main(){
  int N;
  cin >> N;
  
  vector<int64_t> lucas = {2, 1};
  
  for(int i = 0; i < N - 1; i++){
    lucas.push_back(lucas[i] + lucas[i+1]);
  }
  
  cout << lucas[N] <<endl;
}

int64_t lucas(int64_t N){
  if(N == 0)
    return 2;
  if(N == 1)
    return 1;
  
  int64_t L;
  L = lucas(N-1) + lucas(N-2);
  return L;
}

Measured memory_bytes: 3624
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    tmp = 0
    a = list(map(int, input().split()))
    for j in range(m):
        tmp += a[j] * b[j]
    tmp += c
    if tmp > 0:
        ans += 1
print(ans)

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<P> v(N);
    vector<int> a(N);
    rep(i,N){
        a[i] = i;
        cin >> v[i].first >> v[i].second;
    }
    
    long double sum = 0;
    int count = 0;
    do{
        count++;
        rep(i,N-1){
            sum += sqrt(pow(v[a[i]].first - v[a[i+1]].first, 2) + pow(v[a[i]].second - v[a[i+1]].second, 2));
        }
    }while(next_permutation(a.begin(), a.end()));
    
    // cout << count << endl;
    printf("%.9Lf", sum / count);

    return 0;
}

Measured memory_bytes: 256
def solve():
    A,B,C = map(int, input().split())
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        print(0)
        return

    ans = 0
    a = A
    b = B
    c = C
    while(True):
        x = int((b + c)/ 2)
        y = int((a + c)/ 2)
        z = int((a + b)/2)

        a = x
        b = y
        c = z

        ans += 1

        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            print(ans)
            return
        elif a == A and b == B and c == C:
            print(-1)
            return

solve()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<list>
#include<stack>
#define ll  long long
#define lll __int128
#define fi first
#define ld long double
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<vector<int>>
using namespace std;
ld a,b,c,d;
ld eps = 1e-6;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
    cin >> a>> b >> c >> d;
    ld phi1  = (2*M_PI)/12*c+(2*M_PI)/12*(d/60);
    ld phi2 = (2*M_PI)/60*d;
    ld phi = abs(phi1 - phi2);
//    cout << phi <<"\n";
    if(phi > M_PI)
        phi= 2*M_PI - phi;
 //   cout << phi1 <<' '<< phi2 <<" "<<phi <<" "<<M_PI/3<<"\n";
    ld ans = sqrt(a*a + b *b-2*b*a *cos(phi));
//    cout << cos(phi)<<"\n";
 //   cout << a*a + b *b-2*b*a *cos(phi) <<"\n";
    if(phi < eps)
        ans = abs(a - b);
    cout << fixed << setprecision(10)<< ans ;
  return  0;    
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int N, M, Q, ans = 0;
vl a, b, c, d;

void dfs(vl array, int depth, int pre = 1) {
    if (depth == N) {
        int score = 0;
        rep(i,Q) if (array[b[i]] - array[a[i]] == c[i]) score += d[i];
        ans = max(ans, score);
        return;
    }
    rng(i,pre,M+1) {
        array[depth] = i;
        dfs(array, depth+1, i);
    }
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i,Q) cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;
    vl array(N);
    dfs(array, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// Boost
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>

#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;

constexpr int64_t MOD = 1000000007;

vector<int64_t> divisor(const int64_t &_n) {
  vector<int64_t> head, tail;
  for (int64_t i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n)
        tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}

int64_t kadanes(const vector<int64_t> &_ls) {
  int64_t highestMax = 0, currentMax = 0, length = _ls.size();
  for (int64_t i = 0; i < length; i++) {
    currentMax = max(_ls[i], currentMax + _ls[i]);
    highestMax = max(highestMax, currentMax);
  }
  return highestMax;
}

void execution();

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

  execution();
  return 0;
}

//--------------------------------------------------------------
void execution() {
  string s;
  cin>>s;
  if(s[s.size()-1]=='s'){
    s+="es";
  }else{
    s+="s";
  }
  cout<<s<<"\n";
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>
using namespace std;

namespace {

}

int main()
{
	int N, M;

	cin >> N >> M; // Mは行数らしい。

	vector<int> c(3, 0);
	vector<int> s(3, 0);
	vector<bool> setflg(3, false);
	for (int i = 0; i < M; ++i){
		int first, second;
		cin >> first >> second;
		if (setflg[first-1]){
			if (s[first-1] != second){
				cout << -1 << endl;
				return 0;
			}
		}
		setflg[first - 1] = true;
		s[first-1] = second;
	}

	if (N == 1){
		if (setflg[0]){
			cout << s[0] << endl;
			return 0;
		}
		else {
			cout << 0 << endl;
			return 0;
		}
	}
	else {
		if (setflg[0]){
			if (s[0] == 0){
				cout << -1 << endl;
				return 0;
			}
		}
		else {
			s[0] = 1;
		}
		cout << s[0];

		for (int i = 1; i < N; ++i){
			if (setflg[i] == false){
				s[i] = 0;
			}
			cout << s[i];
		}
		
		cout << endl;
		return 0;
	}
}


Measured memory_bytes: 3580
import java.util.*

private val readInt: ()->Int = { readLine()!!.toInt() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }

fun main(args: Array<String>) {
    val (N, K) = readListInt()

    var st = mutableSetOf<Int>()
    for (i in 0 until K) {
        val D = readInt()
        val A = readListInt()
        for (e in A) {
            st.add(e)
        }
    }

    val ans = N - st.size
    println(ans)
}


Measured memory_bytes: 38980
#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>;

const int MAX_VAL = 1e4;
int main() {
    int H, N; cin >> H >> N;
    vector<int> A(N), B(N);
    rep(i, N) {
        cin >> A[i] >> B[i];
    }

    int limit = max(H * 2, MAX_VAL) + 1;
    vector<int> dp(limit, 1e9);
    dp[0] = 0;
    
    rep(i, N) {
        for (int j = A[i]; j < limit; j++) {
            dp[min(j, H)] = min(dp[min(j, H)], dp[j - A[i]] + B[i]);
        }
    }

    cout << dp[H] << endl;
}


Measured memory_bytes: 384
K = int(input())

def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)

dp = [[0] * (K+1) for _ in range(K+1)]
for i in range(1,K+1):
	for j in range(1,K+1):
		dp[i][j] = gcd(i,j)

ans = 0
for a in range(1,K+1):
	for b in range(1,K+1):
		for c in range(1,K+1):
			tmp = dp[a][b]
			ans += dp[tmp][c]
print(ans)


Measured memory_bytes: 76360
#include <stdio.h>

int main(void)
{
        int a,b;

        scanf("%d %d", &a,&b);
        if(a == b)
        {
                printf("a == b\n");
        }
        else if (a > b)
        {
                printf("a > b\n");
        }
        else
        {
                printf("a < b\n");
        }


        return 0;
}

Measured memory_bytes: 580
def factoring(n)
  # 素因数分解O(√n)
  res = Hash.new(0)
  i = 2
  while i*i <= n
    while n % i == 0
      res[i] += 1
      n /= i
    end
    i += 1
  end
  res[n] = 1 if n != 1
  res
end

n, p = gets.split.map(&:to_i)
ans = 1
factoring(p).each do |k, v|
  ans *= (k**(v/n)) if v >= n
end
p ans

Measured memory_bytes: 1788
from collections import deque
n,q = map(int,input().split())
ki = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
ans = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    p -= 1
    ans[p] +=x
visited = [0]*n
stack = deque()
stack.append(0)
visited[0] = 1
while stack:
    now = stack.popleft()
    for next in ki[now]:
        if visited[next]:continue
        ans[next] += ans[now]
        stack.append(next)
        visited[next] = 1

print(*ans)
    


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

int main() {
    int N, m; cin >> N >> m;
    int beg = 0;
    int flag = 0;
    long long mod = 1000000007;
    long long F[200000];
    long long M[200000] = {-1, -1};
    for (int i = 0; i < m; i++) cin >> M[i];

    F[0] = F[1] = 1;
    if (M[0] == 0) F[0] = 0;
    if (M[0] == 1) F[1] = 0;
    if (M[1] == 1) F[1] = 0;


    for( int i = 2; i <= N; i++) {
        int a = 1;
        int b = 1;
        int flag = 1;

        for (int j = beg; j < m; j++) {

            if (i > M[j]) beg = j;            

            if (i-1 == M[j]) {
                a = 0;
            }
            if (i-2 == M[j]) {
                b = 0;
            }
            
            if (i == M[j]) {
                a = 0;
                b = 0;
                break;
            }

            if (i < M[j]) {
                break;
            }
            
        }

        F[i] = (a * F[i - 1] + b * F[i - 2]) % mod;
    } 

    cout << F[N] << endl;
    
}

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

int main() {
	int n, q;
	cin >> n;
	cin >> q;
	
	string names[n];
	int times[n];
	queue <int> index;
	
	for(int i = 0; i < n; ++i){
		cin >> names[i];
		cin >> times[i];
		index.push(i);
	}
	
	int t = 0;
	while(index.empty() == false){
		int i = index.front();
		index.pop();
		if(times[i] <= q){
			t += times[i];
			cout << names[i] << " " << t << endl;
		}else{
			t += q;
			times[i] -= q;
			index.push(i);
		}
	}
	
	return 0;
}

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

int main(){

  int N;
  string s[100];
  int p[100];
  int ans[100];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> s[i];
    cin >> p[i];
    ans[i] = i + 1;
  }

  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if (s[i] > s[j] || (s[i]==s[j] && p[i] < p[j])){
        string temp;
        temp = s[i];
        s[i] = s[j];
        s[j] = temp;
        int t = p[i];
        p[i] = p[j];
        p[j] = t;
        int temp_int = ans[i];
        ans[i] = ans[j];
        ans[j] = temp_int;
      }
    }
  }

  for(int i=0;i<N;i++){
    cout << ans[i] << " ";
  }
  cout <<"\n";
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll dai=0;
  ll sho=10000;
  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
    chmax(dai,p[i]);
    chmin(sho,p[i]);
  }

  ll ans=sho;
  for(ll i=dai;i>sho;i--){
    rep(j,n){
    if(p[j]==i&&j+1<n&&p[j+1]!=i) ans++;
    if(j==n-1&&p[j]==i) ans++;
    }
    rep(j,n){
      if(p[j]==i) p[j]--;
    }
  }

  cout << ans << endl;
}

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

int main() {
  int64_t N,Q;
  string S;
  cin>>N>>Q>>S;
  
  vector<int64_t> vecL(Q);
  vector<int64_t> vecR(Q);
  for(int i=0;i<Q;i++){
    cin>>vecL.at(i)>>vecR.at(i);
  }
  vector<int64_t> rui(N);
  int64_t kai=0;
  rui.at(0)=0;
  for(int i=1;i<N;i++){
    if(S.at(i)=='C'&&S.at(i-1)=='A') kai++;
    rui.at(i)=kai;
  }
  for(int i=0;i<Q;i++){
    cout<<rui.at(vecR.at(i)-1)-rui.at(vecL.at(i)-1)<<endl;
      
  }
  
  
}

Measured memory_bytes: 5880
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll N;
  cin>>N;
  ll ans=MOD;
  ll X=0;
  vector<ll> A(N);
  rep(i,N)cin>>A.at(i);
  rep(i,100){
    X=0;
    rep(j,N){
      X+=(i+1-A.at(j))*(i+1-A.at(j));
    }
    ans=min(ans,X);
  }
  cout<<ans<<endl;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (2006)
ll n, dp[MAXN][MAXN*2], blue[MAXN], ans, mod=998244353, f[MAXN], inv[MAXN];
string A;
int main(){
	FAST
	cin>>A;
	n=siz(A);
	FOR(i,1,n) blue[i] = A[i-1] == '0' ? 0 : (A[i-1] == '1' ? 1 : 2);
	dp[0][0] = 1;
	FOR(i,1,n){
		FOR(b,0,MAXN*2-1) {
			ll r = i * 2 - b - (i-1);
			dp[i][b]=(b >= blue[i] ? dp[i-1][b-blue[i]] : 0) * ll(r>0) + (b+1 >= blue[i] ? dp[i-1][b-blue[i]+1] : 0);
			dp[i][b] %= mod;
		}
	}
	auto qexp=[&](ll x,ll e){
		ll sum=1;
		for(;e; e>>=1, x*=x, x%=mod) if(e&1) sum*=x, sum%=mod;
		return sum;
	};
	f[0]=1, inv[0]=1; FOR(i,1,MAXN-1) f[i]=f[i-1]*i%mod, inv[i]=qexp(f[i],mod-2);
	auto arrange=[&](ll r,ll b){
		return f[r+b] * inv[r] % mod * inv[b] % mod;
	};
	FOR(b,0,n) {
		ll r = n - b;
		ans += dp[n][b] * arrange(r, b) % mod, ans %= mod;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 62976
#include <iostream>
#include <math.h>
#define ISTRUE(a) (a)?"T":"F"
using namespace std;

int count(int N, int d, int prime){
    if(N>d){
        return N/d + count(N, d*prime, prime);
    }else{
        return 0;
    }
    
}

int main(void){
    int N;
    cin >> N;
    
    int num[15];
    num[0] = count(N, 2, 2);
    num[1] = count(N, 3, 3);
    num[2] = count(N, 5, 5);
    num[3] = count(N, 7, 7);
    num[4] = count(N, 11, 11);
    num[5] = count(N, 13, 13);
    num[6] = count(N, 17, 17);
    num[7] = count(N, 19, 19);
    num[8] = count(N, 23, 23);
    num[9] = count(N, 29, 29);
    num[10] = count(N, 31, 31);
    num[11] = count(N, 37, 37);
    num[12] = count(N, 41, 41);
    num[13] = count(N, 43, 43);
    num[14] = count(N, 47, 47);
    
    
    int ret = 0;
    
    // for(int i=0;i<15;i++){
    //     cout << num[i] << endl;
    // }
    
    //75
    for(int i=0;i<15;i++){
        if(num[i] >= 74){
            ret++;
        }
    }
    
    //25 3
    for(int i=0;i<15;i++){
        for(int j=0;j<15;j++){
            if(num[i]>=24 && num[j]>=2 && i!=j){
                ret++;
            }
        }
    }
    
    //15 5
    for(int i=0;i<15;i++){
        for(int j=0;j<11;j++){
            if(num[i]>=14 && num[j]>=4 && i!=j){
                ret++;
            }
        }
    }
    
    //5 5 3
    int add = 0;
    for(int i=0;i<15;i++){
        for(int j=0;j<15;j++){
            for(int k=0;k<15;k++){
                if(num[i]>=4 && num[j]>=4 && num[k]>=2 && i!=j && j!=k && k!=i){
                    add++;
                }
            }
        }
    }
    ret += add/2;
    
    cout << ret << endl;
}

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

int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    ll a,b,c;
    cin >> a >> b >> c;
    double waktu = a / (double) c;
    if(waktu <= b) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3632