akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int l,n;
  cin>>l>>n;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];
  Int ans=0;
  for(Int uku=0;uku<2;uku++){
    vector<Int> sm1(n+1,0),sm2(n+1,0);    
    for(Int i=0;i<n;i++){
      sm1[i+1]=sm1[i]+x[i]*2;      
      sm2[i+1]=sm2[i]+(l-x[n-(i+1)])*2;
    }
    chmax(ans,x.back());
    for(Int i=0;i<n;i++){
      Int k=n-(i+1);
      Int a=k/2,b=k-a;
      if(a==b){
        chmax(ans,sm1[i+1+a]-sm1[i]+sm2[b]-x[i+a]);        
      }else{
        chmax(ans,sm1[i+1+a]-sm1[i]+sm2[b]-(l-x[n-b]));
      }      
    }
    reverse(x.begin(),x.end());
    for(Int &a:x) a=l-a;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
N = int(input())
string = [0] * N
ans = 0
for i in range(N):

    mozi = input()
    for k in range(10):
        string[i] += (ord(mozi[k])-96)**10

string_new = sorted(string)
ite = 0
index = 0
while ite < N-1:
    index = ite + 1
    while string_new[ite] == string_new[index]:
        #print(ite, index)
        ans += index-ite
        index += 1

        if index >= N:
            break
    ite = index
print(ans)


Measured memory_bytes: 9032
N = int(input())
P = list(map(int,input().split()))
Q = []
num = 2*10**5
for i in range(N):
    if num > P[i]:
        num = P[i]
    Q.append(num)
ans = 0
for i in range(N):
    if P[i]<=Q[i]:
        ans += 1
print(ans)

Measured memory_bytes: 85584
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(A * B - A - B + 1);
	}
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int x, n;
    cin >> x >> n;
    set<int> a;
    if(n == 0)
    {
        cout << x << endl;
        return 0;
    }
    for(int i = 0; i < n; i++)
    {
        int d;
        cin >> d;
        a.insert(d);
    }
    for(int i = 0; i <= 100; i++)
    {
        if(a.find(x-i) == a.end())
        {
            cout << x-i << endl;
            return 0;
        }
        if(a.find(x+i) == a.end())
        {
            cout << x+i << endl;
            return 0;
        }
    }
}




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

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

int A[3][3];
int N;
int b[110];
bool hole[3][3];
signed main() {
    rep(i, 3)rep(j, 3) { cin >> A[i][j]; }
    cin >> N;
    rep(k, N) {
        cin >> b[k];
        rep(i, 3)rep(j, 3) {
                if (b[k] == A[i][j]) { hole[i][j] = true; }
            }
    }
    if (hole[0][0] && hole[0][1] && hole[0][2]) { fin("Yes"); }
    if (hole[1][0] && hole[1][1] && hole[1][2]) { fin("Yes"); }
    if (hole[2][0] && hole[2][1] && hole[2][2]) { fin("Yes"); }
    if (hole[0][0] && hole[1][0] && hole[2][0]) { fin("Yes"); }
    if (hole[0][1] && hole[1][1] && hole[2][1]) { fin("Yes"); }
    if (hole[0][2] && hole[1][2] && hole[2][2]) { fin("Yes"); }
    if (hole[0][0] && hole[1][1] && hole[2][2]) { fin("Yes"); }
    if (hole[0][2] && hole[1][1] && hole[2][0]) { fin("Yes"); }
    fin("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int D;
    cin >> D;

    switch (D) {
        case 7:
        case 5:
        case 3:
            cout << "YES" << endl;
            break;
        default:
            cout << "NO" << endl;
            break;
    }

    return 0;
}


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

int main() {
  int x, a;
  cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;
}

Measured memory_bytes: 3600
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto M = RD!long;

	long[] a, b;
	foreach (i; 0..M)
	{
		a ~= RD!long;
		b ~= RD!long;
	}

	auto index = new size_t[](M);
	makeIndex(a, index);

	auto dp = new long[](N+1);
	fill(dp, long.max);
	long pos;
	foreach (i; 0..N)
	{
		if (dp[i] >= i + 1)
			dp[i+1] = dp[i];

		if (pos >= M) break;
		while (a[index[pos]] <= i + 1)
		{
			dp[i+1] = min(dp[i+1], b[index[pos]] - 1);
			++pos;
			if (pos >= M) break;
		}
	}

	long ans;
	long last;
	foreach (e; dp)
	{
		if (e == long.max)
		{
			last = 0;
			continue;
		}
		else if (e > last) ++ans;

		last = e;
	}

	//stderr.writeln(dp);
	writeln(ans);
	stdout.flush();
}

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

using namespace std;

using ll = long long;

int main() {
  ll ans = 0;
  int n;
  cin >> n;
  vector<vector<int>> v(3, vector<int>(n));
  for (auto &x : v) {
    for (auto &xx : x) {
      cin >> xx;
    }
    sort(x.begin(), x.end());
  }
  for (const auto &xx : v[1]) {
    int u = lower_bound(v[0].begin(), v[0].end(), xx) - v[0].begin();
    int d = v[2].end() - upper_bound(v[2].begin(), v[2].end(), xx);
    ans += (ll)u * d;
  }
  cout << ans << endl;
}

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

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

  for(int i = n; i <= 999; i++){
    if(i%10 == (i/10)%10 && i%10 == (i/100)%10){
      cout << i << endl;
      break;
    }
  }

  return 0;
}

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

int main(){
	int n;
	cin >> n;
	int temp=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++)
		if(i*j==n){temp=1;break;}
		
	}
   if(temp==1)cout <<"Yes";
   else cout <<"No";
	
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
    a:usize,
    b:usize,
    c:usize,
    }
    let mut d=0;
    let mut e=0;
    d+=c;
    while d+b+c<=a {
        d+=b+c;
        e+=1
    }
    println!("{}",e)
}

Measured memory_bytes: 2148
s = input()
a = [0] * (len(s) + 1)
cur = 0
for i in range(len(s)):
  a[i] = cur
  cur = 0 if s[i] == '>' else cur + 1 
a[-1] = cur
cur = 0
for i in reversed(range(len(s))):
  a[i + 1] = max(a[i + 1], cur)
  cur = 0 if s[i] == '<' else cur + 1
a[0] = max(a[0], cur)
print(sum(a))

Measured memory_bytes: 23324
#include<stdio.h>
int main()
{
	int i,j,n;
	int a,b,t;
	int sum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		t=0;
		for(j=1;j<=i;j++)
		{
			if(i%j==0&&i%2==1)t++;
		}
		if(t==8)sum++;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a[MAXN];

void solve(){
    double a;
    cin>>a;
    a/=3;
    cout<<fixed<<setprecision(7)<<a*a*a;
}



int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


Measured memory_bytes: 256
// 2011/06/23 Tazoe

#include <iostream>
using namespace std;

int main()
{
	double mnt;
	cin >> mnt;

	double max = mnt;
	double min = mnt;

	while(true){
		cin >> mnt;
		if(cin.eof())
			break;

		if(mnt>max)
			max = mnt;
		if(mnt<min)
			min = mnt;
	}

	cout << max-min << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
#include <stack>
#include <queue>

typedef long long ll;
#define ALL(obj) (obj).begin(),(obj).end()
#define MOD 1000000007


using namespace std;

long long GCD(long long x, long long y){
   long long r, tmp;
   if(x < y){
       tmp = x;
       x = y;
       y = tmp;
   }
   while(y!=0){
       r = x%y;
       x = y;
       y = r;
   }
   return x;
}
long long LCM(long long x, long long y){
   long long lcm = (x*y)/GCD(x, y);
   return lcm;
}

int bubblesort(int n){
    vector<int> data(n);
    int num=0;
    for(int end = n-1; end>0; end--){
        for(int j=0; j<end; j++){
            if(data[j+1] < data[j]){
                int temp = data[j];
                data[j] = data[j+1];
                data[j+1] = temp;
                num++;
            }
        }
    }
    return num;
}

int main(){
    long long n;
    cin >> n;
    long long x=1, y=1, z=1;
    for(ll i=0; i<n; i++){
        x*=10;
        y*=8;
        z*=9;
        x%=MOD;
        y%=MOD;
        z%=MOD;
    }
    long long ans = x-(2*z-y);
    ans%=MOD;
    if(ans<0){
        ans+=MOD;
    }
    cout << ans << endl;
}


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

// macros
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

// util functions
template<class T> inline T sqr(T x) {return x*x;}

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T>inline T max(vector<T> v){T max=v[0]; FOR(i, 1, v.size())max=MAX(v[i], max); return max;}
template <typename T>inline T min(vector<T> v){T min=v[0]; FOR(i, 1, v.size())min=MIN(v[i], min); return min;}
template <typename T>inline vector<T> concat(vector<T> a, vector<T> b){vector<T> ab; ab.reserve(a.size()+b.size());ab.insert(ab.end(),a.begin(),a.end());ab.insert(ab.end(),b.begin(),b.end());return ab;}

// types
typedef long long LL;

// consts
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//debug
#define dump(x)  #x << " = " << (x) << endl
#define debug(x) #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(){
    INT_IN(a);
    INT_IN(b);
    INT_IN(c);
    vector<int> col(100);
    col[a - 1]++;
    col[b - 1]++;
    col[c - 1]++;

    int dcol = 0;
    REP(i, 100){
        if(col[i])dcol++;
    }
    PRINTLN(dcol);
    return 0;
}



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

using namespace std;
using namespace atcoder;

int segop(int a,int b){
    return max(a,b);
}

int sege(){
    return -1;
}

int segfn;
bool segf(int v){
    return v < segfn;
}

int main(){
    int N,Q;
    cin>>N>>Q;
    segtree<int,segop,sege> seg(N+1);
    for(int i=0;i<N;i++){
        int A;
        cin>>A;
        seg.set(i+1,A);
    }

    for(int i=0;i<Q;i++){
        int t,x,v;
        cin>>t>>x>>v;
        if(t==1){
            seg.set(x,v);
        }
        if(t==2){
            cout<<seg.prod(x,v+1)<<endl;
        }
        if(t==3){
            segfn=v;
            cout<<seg.max_right<segf>(x)<<endl;
        }
    }
}


Measured memory_bytes: 6200
while True:
    
    m ,f ,r = map(int,input().split())
    G = str()

    if m == -1 and f == -1 and r == -1:
        break

    total = m + f
    
    if m == -1 or f == -1 :G ="F"
    else:
        if total >= 80: G ='A'
        elif total >= 65:G ='B'
        elif total >= 50:G ='C'
        elif total >= 30:
            if r >= 50:G ='C'
            else:   G ='D'
        elif total <= 30: G ="F"

    print(G)


Measured memory_bytes: 5596
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;

public class Main {
	static ContestScanner in;
	static Writer out;
	public static void main(String[] args) {
		Main main = new Main();
		try {
			in = new ContestScanner();
			out = new Writer();
			main.solve();
			out.close();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void solve() throws IOException {
		int n = in.nextInt();
		Deque<Integer> deq = new ArrayDeque<>();
		for(int i = 0; i < n; i++) {
			if(i % 2 == 0) deq.addLast(in.nextInt());
			else deq.addFirst(in.nextInt());
		}
		
		for(int i = 0; i < n; i++) {
			if(i != 0) out.print(" ");
			if(n % 2 == 1) {
				out.print(deq.pollLast());
			} else {
				out.print(deq.poll());
			}
		}
		out.println();
	}
}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Integer>{
	@Override public Integer get(Object key){return containsKey(key)?super.get(key):0;}
	public void add(T key,int v){put(key,get(key)+v);}
	public void add(T key){put(key,get(key)+1);}
	public void sub(T key){final int v=get(key);if(v==1)remove(key);else put(key,v-1);}
	public MultiSet<T> merge(MultiSet<T> set)
	{MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
	for(Entry<T,Integer>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
	private BufferedReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new BufferedReader(new InputStreamReader(System.in));}
	public ContestScanner(String filename)throws IOException
	{in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
	public void close() throws IOException {in.close();}
}

Measured memory_bytes: 48512
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

bool[long] kset;

void main(){
	int n, m;
	{
		int[] tmp = readln.chomp.split.map!(to!int).array;
		n = tmp[0], m = tmp[1];
		}
	
	for(int j = 0; j < m; j ++){
		int[] tmp = readln.chomp.split.map!(to!int)
				.map!(x => x - 1).array;
		kset[tmp[0] * 8 + tmp[1]] = 1;
		kset[tmp[1] * 8 + tmp[0]] = 1;
		}
	
	debug kset.writeln;
	
	int[][] routes = getRoutes([], 0, n, n);
	int count = 0;
	foreach(r; routes) if(r.isValid) count += 1;
	
	debug routes.writeln;
	
	count.writeln;
	}

int[][] getRoutes(int[] r, int m, int n, int k){ // 0からn-1まで、あとk個、使用済r、使用済マップm、
	int[][] res;
	if(k == 0) return [r];
	for(int i = 0; i < n; i ++){
		if(!((2 ^^ i) & m)){
			res ~= getRoutes(r ~ i, (2 ^^ i) | m, n, k - 1);
			}
		}
	return res;
	}

bool isValid(int[] r){
	if(!r.length) return 0;
	if(r[0] != 0) return 0;
	for(int i = 0; i < r.length - 1; i ++){
		if(r[i] * 8 + r[i + 1] !in kset) return 0;
		}
	debug r.writeln;
	return 1;
	}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n, m;
  cin >> n >> m;
  vi a(m), b(m);
  vii a2b(n);
  rep (i, m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    a2b[a[i]].push_back(b[i]);
  }
  int cnt = 0;
  set<int> st;
  rep (i, n) {
    rep (j, a2b[i].size()) {
      st.insert(a2b[i][j]);
    }
    if (st.count(i + 1)) {
      cnt++;
      st.clear();
    }
  }
  cout << cnt << endl;
}
 


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int flag=0;
    int n;
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
       for(int j=1;j<=n;j++)
       {
        for(int k=1;k<=n;k++)
            sum+=(ll)__gcd(__gcd(i,j),k);
       }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 3816
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long[] X = new long[N];
		long[] I = new long[N];
		for(int i = 0;i < N;i++) {
			X[i] = scn.nextLong();
			I[i] = X[i];
		}
		Arrays.sort(X);

		long under = X[N/2-1], upper = X[N/2];
		for(int i = 0;i < N;i++) {
			System.out.println((I[i] >= upper)?under:upper);
		}
	}

}


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

int main() {
	string S;
	int C = 0;
	cin >> S;
	bool check = true;
	if (S[0] != 'A') check = false;
	for (int i = 2; i < S.size() - 1; i++) {
		if (S[i] == 'C') C = i;
	}
	if (C == 0) check = false;
	for (int i = 1; i < S.size(); i++) {
		int x = S[i];
		if (i != C) {
			if (x < 97 || 122 < x) check = false;
		}
	}
	if (check) cout << "AC" << endl;
	else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define MAX(a, b) ((ll)(a) > (ll)(b)) ? (a) : (b)
#define MIN(a, b) ((ll)(a) > (ll)(b)) ? (b) : (a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};




ll X, Y, Z, K;
ll cindex[1000 * 1000];
vector<ll> A, B, C;
vector<ll> AB;
ll ans[3004];
int main() {
	ll x;
	cin >> X >> Y >> Z >> K;


	rep(i, X) {
		cin >> x;
		A.push_back(x);

	}

	rep(i, Y) {

		cin >> x;
		B.push_back(x);
	}

	rep(i, Z) {
		cin >> x;
		C.push_back(x);

	}


	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	for (int i = A.size() - 1; i >= 0; i--) {
		for (int j = B.size() - 1; j >= 0; j--) {
			AB.push_back(A[i] + B[j]);
		
		}


	}

	sort(AB.begin(), AB.end());

	

	
	ll m = 0;
	ll index = 0;
	for (int j = 0; j < K; j++) {
		

		for (int i = AB.size()-1; i >= 0; i--) {


			if (cindex[i] < C.size()) {
				if (m < AB[i] + C[C.size() - cindex[i] - 1]) {
					index = i;
					m = AB[i] + C[C.size() - cindex[i] - 1];
				}

			}


			if (cindex[i] == 0) {
				break;
			}

		}

		cindex[index] += 1;
		ans[j] = m;
		m = 0;

	}

	rep(i, K)
		cout << ans[i] << endl;


	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int K = S.size();
  bool check = true;
  if (K == 1) {
    cout << S << endl;
    return 0;
  }
  for (int i = 1; i < K; i++) {
    if (S[i] != '9') {
      check = false;
    }
  }
  if (check) { //  Nが、○999...999の形
    int top = (S[0] - '0');
    cout << top + 9*(K-1) << endl;
  }
  else {
    int top = (S[0] - '0');
    cout << top -1 + 9*(K-1) << endl;
  }
}

    
    
      

Measured memory_bytes: 256
c['   '],j,n;main(i){for(i=2;i*i<=5e4;i++)for(j=i;!c[i]&&j<=5e4;c[j+=i]=1);for(;scanf("%d",&j),j;n=!printf("%d\n",n))for(i=2;i<=j/2;i++)n+=!(c[i]+c[j-i]);exit(0);}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	set <int> s;
	int m;
	cin>>m;
	long long ans=0,l,r;
	while(m--)
	{
		cin>>l;
		if(s.find(l) == s.end())
			s.insert(l);
		else
			s.erase(l);
	}
	ans = s.size();
	cout<<ans;
	return 0;
}

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

double dsum(double n){
  double sum = 0;
  while(n > 0){
    sum += (long)n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int k; cin >> k;
  vector<double> s;
  for(int i=1; i<10; i++) s.push_back(i);
  for(int i=1; i<=15; i++)for(int j=1; j<140; j++) s.push_back(j*pow(10, i)-1);
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  double d[s.size()];
  rep(i, s.size()) d[i] = s[i] / dsum(s[i]);
  rep(i, s.size()){
    bool flag = true;
    for(int j=i+1; j<s.size(); j++){
      if(d[i] > d[j]){
        flag = false;
        break;
      }
    }
    if(flag){
      cout << (long)s[i] << endl;
      k--;
    }
    if(k == 0) break;
  }
}

Measured memory_bytes: 892
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    S=readline().strip()
    K=int(readline())

    count1=0
    for i in range(len(S)):
        if S[i]=="1": count1+=1
        else: break

    if K<=count1: print("1")
    else: print(S[count1])

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, K;
	cin >> N >> K;
	ll cnt = 0;
	if (K % 2 == 1) {
		for (int i = 1; i <= N; i++) {
			if (i % K == 0) {
				cnt++;
			}
		}
		cout << cnt * cnt * cnt << endl;
	}
	else {
		ll cnt2 = 0;
		for (int i = 1; i <= N; i++) {
			if (i % K == 0) {
				cnt++;
			}
			else if (i % K == K / 2) {
				cnt2++;
			}
		}
		cout << cnt * cnt * cnt + cnt2 * cnt2 * cnt2 << endl;
	}
}

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

ll binpow(ll a, ll n)
{
	if(n==0)
		return 1;
	if(n%2==0)
	{
		return ((binpow(a,n/2))*binpow(a,n/2));
	}
	else
	{
		return binpow(a,n/2)*binpow(a,n/2)*a;
	}
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    	ll n;
    	cin>>n;
    	ll i=0;
    	while(n>1)
    	{
    		long double temp=n/2.00;
    		n=floor(temp);
    		i++;
    	}

    	long ans=(1ll)<<(i+1);
    	ans--;
    	//ans--;
    	//cout<<i+1<<endl;
    	//long double temp1=log(1099511627776)/log(2);
    	//cout<<temp1<<endl;
    	cout<<ans<<endl;


    

}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[60][60], f[100200], g[100200], h[100200], counto = 1000000000, ans =1 , x[100] = {}, y, z;
int64_t ab[10000] = {}, abc = 0, abcd = 0;
pair<int, int>manji[101] = {};
char rikka, toka[150][150] = {};
vector<int> train, code;
vector<char>aka, ao;
string saya, homu, kyok, mami[108], mado[100];
bool gg = true ,ap=false;
bool exist[100200];
int main() {
	cin >> a>>b>>c>>d;
	cout << c-d + b << ' ' << d+c - a << ' ' << a - d + b << ' ' << b+c-a << endl;


	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
        let stdin = io::stdin();
        let mut buf = String::new();

        stdin.read_line(&mut buf).unwrap();

        let abc: Vec<i32> = buf.split_whitespace().map(|n| n.parse().unwrap()).collect();

        if abc[0] <= abc[2] && abc[2] <= abc[1] {
                println!("Yes");
        } else {
                println!("No");
        }
}

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

using namespace std;
using ll = long long;


int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    vector<int> v;
    v.push_back(c*max(x,y)*2);
    v.push_back(a*x+b*y);
    if(x<y){
        v.push_back(x*2*c+(y-x)*b);
    }else{
        v.push_back(y*2*c+(x-y)*a);
    }
    cout<<*min_element(v.begin(),v.end())<<endl;
    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                count += 1

print(count)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n = int(input())
    ans = [[0 for _ in range(n)] for _ in range(n)]
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    u = list(map(int, input().split()))
    v = list(map(int, input().split()))
    for i in range(n):
        if not s[i]:
            for j in range(n):
                ans[i][j] = ans[i][j]|u[i]
        if not t[i]:   
            for j in range(n):
                ans[j][i] = ans[j][i]|v[i]
    for i in range(n):
        for j in range(n):
            if (u[i] & v[j]):
                ans[i][j] = ans[i][j]|(u[i]&v[j])
    for x in range(n):
        if not s[x]:
            continue
        x_sum = ans[x][0]
        for y in range(n):
            x_sum = x_sum|ans[x][y]
        if x_sum == u[x]: 
            continue
        up = u[x] - x_sum
        for y in range(n):
            if t[y]:
                continue
            y_mul = ans[0][y]
            for i in range(n):
                if i == x:
                    continue
                y_mul = y_mul&ans[i][y]
            up_y = (~y_mul)&up
            ans[x][y] += up_y
            up -= up_y
            if not up:
                break
    for y in range(n):
        if not t[y]:
            continue
        y_sum = ans[0][y]
        for x in range(n):
            y_sum = y_sum|ans[x][y]
        if y_sum == v[y]: 
            continue
        up = v[y] - y_sum
        for x in range(n):
            if s[x]:
                continue
            x_mul = ans[x][0]
            for j in range(n):
                if y == j:
                    continue
                x_mul = x_mul&ans[x][j]
            up_x = (~x_mul)&up
            ans[x][y] += up_x
            up -= up_x
            if not up:
                break
    for i in range(n):
        check_xs = ans[i][0]
        check_ys = ans[0][i]
        check_xm = ans[i][0]
        check_ym = ans[0][i]
        for j in range(n):
            check_xs = check_xs|ans[i][j]
            check_ys = check_ys|ans[j][i]
            check_xm = check_xm&ans[i][j]
            check_ym = check_ym&ans[j][i]
        if s[i] and u[i] != check_xs:
            print(-1)
            return       
        if t[i] and v[i] != check_ys:
            print(-1)
            return       
        if not s[i] and u[i] != check_xm:
            print(-1)
            return       
        if not t[i] and v[i] != check_ym:
            print(-1)
            return
    for i in range(n):
        print(*ans[i])

if __name__ == "__main__":
    main()

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1e6 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

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

int main () {
	int a, b, c;
    ll k;
    cin >> a >> b >> c >> k;
 
    cout << (b - a) * ((k & 1) ? 1 : -1) << endl;
}

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

namespace io {
    template <typename T> inline void read(T & _x) {
        int f = 0, ch; _x = 0;
        while(!isdigit(ch = getchar())) f |= ch == '-';
        while(isdigit(ch)) _x = _x * 10 + ch - '0', ch = getchar();
        if(f) _x = -_x;
    }
    template <typename T, typename ... Args> inline void read(T &_f, Args& ... args) {
        read(_f), read(args ...);
    }
    inline void _deal(char ch) { putchar(ch); }
    template <typename T> inline void _deal(T _x) {
        if (_x < 0) putchar('-'), _x = -_x;
        if (_x > 9) _deal(_x / 10);
        putchar(_x % 10 + '0');
    }
    inline void write() {}
    template <typename T, typename ... Args> inline void write(T _f, Args ... args) {
        _deal(_f), write(args...);
    }
}

int32_t main() {
	int n, k, p[1010], sum = 0;
	io::read(n, k);
	for(int i = 1; i <= n; ++i)
		io::read(p[i]);
	std::sort(p + 1, p + n + 1);
	for(int i = 1; i <= k; ++i)
		sum += p[i];
	printf("%d", sum);
    return 0;
}



Measured memory_bytes: 3764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%s",s);
  n=strlen(s);
  rep(i,n){
    if(s[i]=='+') result++;
    else result--;
  }
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 128
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int N;
int a[200000];
map<int, int> mp;

bool f(int n){
  mp.clear();
  mp[a[0]] = 0;
  rep(i, 1, N){
    if(a[i] <= a[i - 1]){
      int pos = a[i];
      {
        auto it = mp.find(pos);
        if(it == mp.end()){
          mp[pos] = 0;
        }
      }
      {
        auto it = mp.find(pos);
        auto itt = mp.end();
        for(itt--; itt != it; itt--){
          mp.erase(itt);
        }
      }
      {
        while(mp[pos] == n - 1){
          mp[pos] = 0;
          pos--;
        }
        if(pos == 0){
          return false;
        }
        mp[pos]++;
      }
    }
  }
  return true;
}

int main(){
  cin >> N;
  rep(i, N) scanf("%d", &a[i]);
  {
    bool flag = true;
    rep(i, 1, N){
      if(a[i] <= a[i - 1]){
        flag = false;
        break;
      }
    }
    if(flag){
      cout << 1 << endl;
      return 0;
    }
  }

  int hi = N;
  int lo = 1;
  while(hi - lo > 1){
    int mi = (hi + lo) / 2;
    if(f(mi)){
      hi = mi;
    }else{
      lo = mi;
    }
  }
  cout << hi << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
vector<int> S;
int root(int dest){
	if(S[dest]==dest) return dest;
	else return S[dest]=root(S[dest]);
}
int same(int chk1,int chk2){
	if(root(chk1)==root(chk2)) return 1;
	else return 0;
}

int main(){
	int n,q;
	cin >> n >> q;
	S.resize(n);
	for(int loop=0;loop<n;loop++){
		S[loop] = loop;
	}
	int com,x,y;
	int rootx,rooty;	//根はできるだけ小さくしたいので、小さくした
	for(int loop=0;loop<q;loop++){
		cin >> com >> x >> y;
		if(x>y) swap(x,y);
		if(com==0){
			rootx=root(x);
			rooty=root(y);
			if(rootx<rooty){
				S[rooty]=rootx;
			}else{
				S[rooty]=rootx;
			}
		}else cout << same(x,y) << endl;
	}
	return 0;
}



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

int main() { /* ここに書く */
  
  int A , B , N , i ; 
  cin >> A >> B ;
  i = 0 ;
  N = 0 ;
 
  if( A <= B ){
    
    while( i < B ){
      N = N * 10 ;
      N = N + A ;
      i++;
    }
    
    cout << N << endl;
    
  }
  else{
    while( i < A ){
  	  N = N * 10 ;
      N = N + B ;
      i++;
    }
    
    cout << N << endl;
    
  }
}

Measured memory_bytes: 256
import itertools
n = list(map(int,input().split()))
l = [int(input()) for i in range(n[0])]
ans = 10**9

la = [0,1,2,3]


for i in itertools.product(la,repeat=n[0]):
    count = 0
    
    if (1 not in i) or (2 not in i) or (3 not in i):
        continue
    
    lis = [0]*4
    for j in range(n[0]):
        if i[j] > 0 and lis[i[j]] > 0:
            count += 10
        lis[i[j]] += l[j]

    for j in range(1,4):
        count += abs(lis[j]-n[j])
    ans = min(count,ans)
print(ans)

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

int main() {

  string s;
  cin >> s;

  string result = "";
  for (int i = 0; i < s.length(); i++) {
    
    if (s[i] == '0') {
      result += "0";
    } else if (s[i] == '1') {
      result += "1";
    } else {
      if (!result.empty()) {
        result.erase(result.length() - 1);
      }
    }

  }
  
  cout << result << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
bool checkpal(int n )
{
    int x[5] ;
    for(int i = 0 ; i<5 ; i++)
    {
        x[i]=n%10 ;
        n/=10 ;
    }
    if(x[0]==x[4]&&x[1]==x[3])
        return 1;
    return 0 ;
}
int main()
{
    int a , b ,mx , mn , counter = 0;
    cin>>a>>b ;
    mn=min(a,b);
    mx=max(a,b);
    for(int i =mn ; i<=mx ; i++)
    {
        if(checkpal(i))counter++ ;
    }
    cout<<counter<<endl ;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,q,l,r;
    string s;
    vector<lli> ans,boo,rui;
    lli i,j;
    cin>>n>>q>>s;
    rep(i,1,n){
        if((s[i-1]=='A')&&(s[i]=='C')){
            boo.push_back(1);
        }
        else{
            boo.push_back(0);
        }
    }
    rui.push_back(0);
    rep(i,1,n){
        rui.push_back(boo[i-1]+rui[i-1]);
    }
//    rep(i,0,boo.size()){
//        cout<<boo[i];
//    }
//    cout<<endl;
//    rep(i,0,rui.size()){
//        cout<<rui[i];
//    }
//    cout<<endl;
    rep(i,0,q){
        cin>>l>>r;
        ans.push_back(rui[r-1]-rui[l-1]);
    }
    rep(i,0,ans.size()){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 3572
n = int(input())
a = list(map(int,input().split()))
c1 = 0
c2 = 0
c3 = 0
for i in a:
    if i%4==0:
        c1 += 1
    elif i%2==0:
        c2 += 1
    else:
        c3 += 1
if c2==0:
    if c1+1>=c3:
        print("Yes")
    else:
        print("No")
else:
    if c1>=c3:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14352
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    s_arr = [s for s in S]
    s_arr = list(set(s_arr))
    if len(s_arr) == 26:
        s = 'None'
    else:
        s_arr.sort()
        for i in range(26):
            if len(s_arr) <= i:
                s = chr(i+97)
                break
            elif s_arr[i] != chr(i+97):
                s = chr(i+97)
                break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(s)


Measured memory_bytes: 45168
#include <cstdio>
#include <set>

using namespace std;

int main() {
    int N, d;
    scanf("%d", &N);
    set<int> s;
    for (int i=0; i<N; i++) {
        scanf("%d", &d);
        s.insert(d);
    }
    printf("%ld\n", s.size());
    return 0;
}

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

using namespace std;

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

	int n;
	cin >> n;

	set<string> s;

	for(int i = 0; i < n; ++i) {
		string S;
		cin >> S;
		s.emplace(S);
	}

	cout << s.size() << '\n';

	return 0;
}


Measured memory_bytes: 19244
#include<stdio.h>

int main(void) {
    int j, q, k = 0;
    int w, h, x, y, r;
    
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    
    if (x + r <= w && x - r >= 0)
        k = k + 1;
    if (y + r <= h && y - r >= 0)
        k = k + 1;
    if (k == 2)
        printf("Yes\n");
    else
        printf("No\n");
    
        return 0;
    }




Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

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

int main(void)
{
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    bool f = false;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i]==K) f = true;
    }
    if(f){
        pr("POSSIBLE");
        return 0;
    }

    SORT(A);
    if(A.back() < K){
        pr("IMPOSSIBLE");
        return 0;
    }
    
    ll g = gcd(A[0], A[1]);
    Rep(i, 2, N){
        g = gcd(g, A[i]);
    }

    if((K%g) == 0)pr("POSSIBLE");
    else pr("IMPOSSIBLE");
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const string MINUSINF = "-";
int match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

void chmax(string& a, string b){
  if(a.size() < b.size()) a = b;
  else if(a.size() == b.size()){
    if(a<b) a = b;
  }
}

int main(){
  int a,b; cin >> a >> b;
  if(b%a==0){
    cout << a+b << endl;
  }else cout << b-a << endl;
  
  return 0;
}

Measured memory_bytes: 384
fun main() = Thread(null, ::abc168d, "", 128 * 1024 * 1024).start()

@OptIn(ExperimentalStdlibApi::class)
fun abc168d() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val abList = List(m) {
        readLine()!!.split(' ').map { it.toInt() - 1 }.let { it[0] to it[1] }
    }

    val graph = Array(n) { Vertex(it) }
    abList.forEach { (a, b) ->
        graph[a].neighbor.add(b)
        graph[b].neighbor.add(a)
    }

    val queue = ArrayDeque(listOf(-1 to 0))
    val indices = IntArray(n) { -1 }
    val visited = mutableSetOf(0)

    while (queue.isNotEmpty()) {
        val (from, to) = queue.removeFirst()
        if (from != -1) indices[to] = from
        graph[to].neighbor.filter { visited.add(it) }.map { to to it }.let { queue.addAll(it) }
    }

    if (indices.drop(1).any { it == -1 }) return println("No")

    val answer = buildString {
        appendln("Yes")
        appendln(indices.drop(1).map { it + 1 }.joinToString(System.lineSeparator()))
    }

    print(answer)
}

private data class Vertex(val index: Int, val neighbor: MutableSet<Int> = mutableSetOf())


Measured memory_bytes: 134736