akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;
const long long INF = 1e15;

int main(){
  long long N, M, X;
  cin >> N >> M >> X;
  vector<long long> H(N);
  for(int i = 0; i < N; ++i) cin >> H[i];
  vector<vector<pair<long long,int>>> G(N);
  for(int i = 0; i < M; ++i){
    int a, b;
    long long t;
    cin >> a >> b >> t;
    --a,--b;
    G[a].emplace_back(t,b);
    G[b].emplace_back(t,a);
  }
  vector<pair<long long,long long>> V(N,{INF,INF});
  V[0] = {0,-X};
  priority_queue<pair<int,pair<long long,long long>>> Q;
  Q.push({0,{0LL,-X}});
  while(Q.size()){
    int v;
    pair<long long,long long> p;
    tie(v,p) = Q.top();
    long long h = -p.second, c = p.first;
    Q.pop();
    if(V[v] < p) continue;
    for(auto e : G[v]){
      int v_;
      long long c_;
      tie(c_,v_) = e;
      if(c_ <= h and h - c_ > H[v_]){
        long long dh = (h - c_) - H[v_];
        if(h - dh < c_) continue;
        pair<long long, long long> p_(c+c_+dh,-(h-c_-dh));
        if(V[v_] <= p_) continue;
        V[v_] = p_;
        Q.emplace(v_,p_);
      }
      if(c_ <= h and h - c_ <= H[v_]){
        pair<long long, long long> p_(c+c_,-(h-c_));
        if(V[v_] <= p_) continue;
        V[v_] = p_;
        Q.emplace(v_,p_);
      }
      if(c_ > h and c_ <= H[v]){
        pair<long long, long long> p_(c+c_+c_-h,-(0));
        if(V[v_] <= p_) continue;
        V[v_] = p_;
        Q.emplace(v_,p_);
      }
    }
  }
  long long ans = V[N-1].first + H[N-1] + V[N-1].second;
  if(ans >= INF) ans = -1;
  cout << ans << endl;
}



Measured memory_bytes: 67676
a,b=map(int,input().split())
c=list(map(int,input().split()))[1:]
#print(c)
for _ in range(a-1):
  #print(range(a))
  d=list(map(int,input().split()))[1:]
  #print(d)
  c=set(c)&set(d)

#print(c)
print(len(c))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int dx[4]={1,-1,0,0};
    int dy[4]={0,0,1,-1};
    int n,m,ans=0; cin>>n>>m;
    queue <pair <int,int> > q ;
    vector <vector<char>> a( n,vector <char>(m ));
    vector <vector<int>> data( n,vector <int>(m,-1 ));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
        cin>>a[i][j];
        if(a[i][j]=='#') {q.push(make_pair(i,j)); //y,x
        data[i][j]=0;
        }
        }
    }
    while(q.size()){
        pair <int,int> pa=q.front();
        q.pop();
        for(int j=0;j<4;j++){
            int ny,nx;
             ny=pa.first+dy[j],nx=pa.second+dx[j];
            if(nx>=0&&nx<m&&ny>=0&&ny<n&&a[ny][nx]=='.'&&data[ny][nx]==-1){
            q.push(make_pair(ny,nx));
            data[ny][nx]=data[pa.first][pa.second]+1;
            ans=max(data[ny][nx],ans);
            }
    }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13456
import Control.Monad
import Text.Printf

main = do
  line <- fmap (fmap (read :: String -> Double) . words) getLine
  let aa = Point { x = line !! 0, y = line !! 1}
  let bb = Point { x = line !! 2, y = line !! 3}
  let l = Line aa bb
  q <- readLn
  input <- replicateM q getLine
  let xs = fmap (fmap (read :: String -> Double) . words) input
  let result = fmap (\e -> (x $ res l (e !! 0) (e !! 1), y $ res l (e !! 0) (e !! 1))) xs
  mapM_  (\r -> (printf "%.8f %.8f\n" (fst r) (snd r))) result
    where res l x1 y1 = l `project` Point{x=x1,y=y1}

eps :: (Floating a) => a
eps = 1e-7

add :: (Ord a, Floating a) => a -> a -> a
add a b
  | abs (a + b) < eps * (abs a + abs b ) = 0.0
  | otherwise = a + b

data Point a = Point { x :: a, y :: a } deriving (Eq)
data Line a = Line {a :: Point a, b :: Point a}

(^+) :: (Ord a, Floating a) => Point a -> Point a -> Point a
a ^+ b =  Point (add (x a) (x b)) (add (y a) (y b))

(^-) :: (Ord a, Floating a) => Point a -> Point a -> Point a
a ^- b = Point (add (x a) (-x b)) (add (y a) (-y b))

(^*) :: (Floating a) => Point a -> a -> Point a
a ^* d = Point (x a * d) (y a * d)

dot :: (Floating a) => Point a -> Point a -> a
a `dot` b = x a * x b + y a * y b

project :: (Ord a, Floating a) => Line a -> Point a -> Point a
l `project` p = a l ^+ (base ^* t)
  where base = b l ^- a l
        t = ((p ^- a l) `dot` base) / (base `dot` base)

reflect :: (Ord a, Floating a) => Line a -> Point a -> Point a
l `reflect` p = p ^+ ((l `project` p) ^- p) ^* 2

Measured memory_bytes: 5136
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#define FILE_NAME "a"


int H, W, h, w;

bool read() {
	if  (scanf("%d%d%d%d", &H, &W, &h, &w) < 4) {
		return 0;
	}
	return 1;
}

const int MAXN = 500 + 10;
const int MAX = int(1e9);

int a[MAXN][MAXN];

bool solve() {
	if  (H % h == 0 && W % w == 0) {
		return 0;
	}
	
	memset (a, 0, sizeof a);

	const int x = (MAX - 1) / (h * w - 1);
	const int y = x * (h * w - 1) + 1;
	assert(0 <= x && x <= MAX);
	assert(0 <= y && y <= MAX);

	forn(i, H) {
		forn(j, W) {
			if  ((i + 1) % h == 0 && (j + 1) % w == 0) {
				a[i][j] = -y;
			} else {
				a[i][j] = x;
			}
		}
	}

	ll sum = 0;
	forn(i, H) {
		forn(j, W) {
			sum += a[i][j];
		}
	}

	if  (sum <= 0) {
		return 0;
	}

	puts("Yes");
	forn(i, H) {
		forn(j, W) {
			printf("%d ", a[i][j]);
		}
		puts("");
	}
	puts("");
	return 1;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		if  (!solve()) {
			puts("No");
		}
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 3968
use std::io::{self, BufRead};

fn main() {
    let si = io::stdin();
    let mut lns = si.lock().lines();
    let mut s = lns.next().unwrap().unwrap().into_bytes();
    let mut t = lns.next().unwrap().unwrap().into_bytes();
    s.sort();
    t.sort_by(|c, d| c.cmp(d).reverse());
    println!("{}", if s < t { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<fstream>
#include<sstream>
#include<queue>
#include<iterator>
#include<stack>
using namespace std;
int n;
vector<int> a;
int main() {
	cin>>n;
	int mx=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	int x=0,y=0;

	for(int i=0;i<n-1;i++){
		if(a[i]!=a[i+1])continue;
		if(x==0){
			x=a[i];
			i++;
		}
		else if(y==0){
			y=a[i];
			i++;
		}
		if(x!=0&&y!=0)break;
	}

  cout<<(long long)x*y<<endl;




  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n;
int arr[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&arr[i]);
    int mx=0;
    for(int i=1;i<=n;i++){
        if(arr[i]-1>=mx){
            arr[i]--;
            mx=max(mx,arr[i]);
        }
        else if(arr[i]>=mx){
            mx=max(mx,arr[i]);
        }
        else {
            puts("No");return 0;
        }
    }
    puts("Yes");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;

	cout<<(n+110)/111*111<<endl;
}

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

int main() {
        int n, t, l, b;
        while (scanf("%d%d%d%d", &n, &t, &l, &b) && n) {
                vector<int> h(n + 1, 0);
                int a;
                for (int i = 0; i < l; i ++) {
                        scanf("%d", &a);
                        h[a] = 1;
                }
                for (int i = 0; i < b; i ++) {
                        scanf("%d", &a);
                        h[a] = 2;
                }
                vector<vector<double>> dp(t + 1, vector<double> (n + 1));
                dp[0][0] = 1;
                double ans = 0;
                for (int i = 0; i <= t; i ++) {
                        ans += dp[i][n];
                        dp[i][n] = 0;
                        for (int j = 0; j <= n; j ++) {
                                int ni = i + (h[j] == 1 ? 2 : 1);
                                if (ni > t) continue;
                                for (int dice = 1; dice <= 6; dice ++) {
                                        int nj = j + dice;
                                        if (nj > n) nj = n - (nj - n);
                                        if (h[nj] == 2) nj = 0;
                                        dp[ni][nj] += dp[i][j] / 6;
                                }
                        }
                }
                printf("%lf\n", ans);
        }
        return 0;
}

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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

const int N = 3010;

const long long mod = 998244353;

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int n, S;
int a[N], f[N];

long long ans;

int main() {
    
    n = read(), S = read();
    Rep(i, 1, n) a[i] = read();

    Rep(i, 1, n) {
        if (a[i] > S) continue;
        if (a[i] == S) ans = (ans + i * (n - i + 1)) % mod;
        else {
            ans = (ans + 1ll * f[S - a[i]] * (n - i + 1)) % mod;
            Dep(j, S, a[i] + 1) f[j] = (f[j] + f[j - a[i]]) % mod;
            f[a[i]] = (f[a[i]] + i) % mod;
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
const int maxn=1e5+7;
struct Edge{
	int to;
	int last;
}a[maxn<<1];
int n,m;
int tot;
int head[maxn];
bool vis[maxn];
std::vector<int>v;
inline void HA(int x,int y){
	a[++tot]=(Edge){y,head[x]};head[x]=tot;
	a[++tot]=(Edge){x,head[y]};head[y]=tot;
}
#define y a[i].to
inline void Dfs(int x){
	v.push_back(x),vis[x]=true;
	for(int i=head[x];i;i=a[i].last)
		if(!vis[y]){Dfs(y);break;}
}
#undef y
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;++i)
		scanf("%d%d",&x,&y),HA(x,y);
	v.push_back(1),vis[1]=true;
	for(int i=head[1],cnt=0;i;i=a[i].last)
		if(!vis[a[i].to]){
			if(cnt==1){
				std::reverse(v.begin(),v.end());
				Dfs(a[i].to);break;
			}else Dfs(a[i].to),++cnt;
		}
	std::cout<<v.size()<<"\n";
	for(auto x:v)printf("%d ",x);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[2020];
int main(){
	dp[0]=1; int n; cin>>n;
	for(int i=0;i<=n;++i){
		for(int j=3;i+j<=n;++j) (dp[i+j]+=dp[i])%=mod; 
	}
	printf("%d\n",dp[n]);
} 

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 1e5 + 5;
int a[maxn][3], dp[maxn][3];

int main() {
    int n;
    scanf("%d", &n);
    REP(i, n) REP(j, 3) {
        scanf("%d", &a[i][j]);
    }
    REPP(i, 1, n + 1) REP(j, 3) REP(k, 3) {
        if (k != j) dp[i][j] = max(dp[i - 1][k] + a[i - 1][j], dp[i][j]);
    }
    int ans = 0;
    REP(i, 3) ans = max(dp[n][i], ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
a,b,c=map(int,input().split())
if a==b:
  if a!=c:
    print("Yes")
  else:
    print("No")
elif a==c:
  if a!=b:
    print("Yes")
  else:
    print("No")
elif b==c:
  if a!=b:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
  long int k,a,b,sum;
  scanf("%ld %ld %ld",&k,&a,&b);

  if(a >= b - 1)
    printf("%ld\n",1+k);

  else{
    if((k-a+1)%2 == 0){
      sum = a  + (b - a) * (k - a + 1)/2;
      printf("%ld\n",sum);
    }
    else{
      sum = a + 1 +(b - a) * (k - a)/2;
      printf("%ld\n",sum);
    }

  }
  return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

int mod=1e9+7;
struct Mint {
    int val;
    Mint inv() const{
        int tmp,a=val,b=mod,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return Mint(x);
    }
public:
    Mint():val(0){}
    Mint(ll x){if((val=x%mod)<0)val+=mod;}
    Mint pow(ll t){Mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    Mint& operator+=(const Mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
    Mint& operator-=(const Mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
    Mint& operator*=(const Mint& x){val=(ll)val*x.val%mod; return *this;}
    Mint& operator/=(const Mint& x){return *this*=x.inv();}
    bool operator==(const Mint& x) const{return val==x.val;}
    bool operator!=(const Mint& x) const{return val!=x.val;}
    bool operator<(const Mint& x) const{return val<x.val;}
    bool operator<=(const Mint& x) const{return val<=x.val;}
    bool operator>(const Mint& x) const{return val>x.val;}
    bool operator>=(const Mint& x) const{return val>=x.val;}
    Mint operator+(const Mint& x) const{return Mint(*this)+=x;}
    Mint operator-(const Mint& x) const{return Mint(*this)-=x;}
    Mint operator*(const Mint& x) const{return Mint(*this)*=x;}
    Mint operator/(const Mint& x) const{return Mint(*this)/=x;}
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx){
        Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
    }
    Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
    Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
    Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};


factorial fact(200010); Mint dp[3010];
typedef pair<int,int> P;

int main(){
    int h,w,n; scanf("%d%d%d",&h,&w,&n);
    vector<P> rc(n);
    rep(i,0,n){
        scanf("%d%d",&rc[i].first,&rc[i].second);
        rc[i].first--,rc[i].second--;
    }
    rc.push_back({h-1,w-1}); n++;
    sort(ALL(rc),
    [&](P a,P b){return a.first+a.second<b.first+b.second;});
    vector<int> r(n),c(n);
    rep(i,0,n)r[i]=rc[i].first,c[i]=rc[i].second;
    rep(i,0,n){
        Mint base=fact.nCr(r[i]+c[i],r[i]);
        rep(j,0,i)base-=dp[j+1]*fact.nCr(r[i]+c[i]-r[j]-c[j],r[i]-r[j]);
        dp[i+1]=base;
    }
    printf("%d\n",dp[n].val);
    return 0;
}

Measured memory_bytes: 1920
a, b, c, d = map(int, input().split())
 
def gcd(x, y):
    if y > x:
      return gcd(y, x)
    if x % y == 0:
        return y
    return gcd(y, x%y)
 
cd = c // gcd(c,d) * d
 
a -= 1
a_ = a - a//c - a//d + a//cd
b_ = b - b//c - b//d + b//cd
 
print(b_ - a_)

Measured memory_bytes: 3060
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public string s { get; set; }
    public int nowb { get; set; }
    public bool use { get; set; }
}
public class hello
{
    public static void Main()
    {
        var p = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < p; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var ans = getAns(n, line[1]);
            Console.WriteLine(ans);
        }
    }
    static int getAns(int n, string s)
    {
        var bc = s.Length - s.Replace("B", "").Length;
        var bmax = 0;
        var st = new Stack<P>();
        st.Push(new P { s = s, nowb = bc });
        while (st.Count() > 0)
        {
            var w = st.Pop();
            var ngc = w.s.Length - w.s.Replace("G", "").Length;
            if (ngc == 0) { bmax = Max(bmax, w.s.Length); continue; }
            if (ngc == w.s.Length) continue;
            var a = getP(w.s.Length, n, 0);
            var nowb2 = w.s[a] == 'B' ? w.nowb - 1 : w.nowb;
            if (nowb2 < bmax) continue;
            string ns;
            if (a == w.s.Length - 1) ns = w.s.Substring(0, w.s.Length - 1);
            else if (a == 0) ns = w.s.Substring(1);
            else ns = w.s.Substring(a + 1) + w.s.Substring(0, a );
            st.Push(new P { s = ns, nowb = nowb2, use =w.use});
            if (!w.use)
            {
                a = getP(w.s.Length, n, 1);
                nowb2 = w.s[a] == 'B' ? w.nowb - 1 : w.nowb;
                if (nowb2 < bmax) continue;
                if (a == w.s.Length - 1) ns = w.s.Substring(0, w.s.Length - 1);
                else if (a == 0) ns = w.s.Substring(1);
                else ns = w.s.Substring(a + 1) + w.s.Substring(0, a);
                st.Push(new P { s = ns, nowb = nowb2, use = true });
            }
        }
        return bmax;
    }
    static int getP(int sL, int n, int f)
    {
        var ans = 0;
        ans = f == 0 ? n % sL - 1 : (n + 1) % sL - 1;
        if (ans < 0) ans += sL;
        return ans;
    }
}



Measured memory_bytes: 20648
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public static partial class Program
{
    public static void Main()
    {
        var nq = CRL().ArrayInts();
        var n = nq[0];
        var q = nq[1];
        var str = CRL();
        var memo = new int[n];
        for (int i = 1; i < n; i++)
        {
            memo[i] = memo[i - 1] + (str[i - 1] == 'A' && str[i] == 'C' ? 1 : 0);
        }

        for (int i = 0; i < q; i++)
        {
            var p = CRL().ArrayInts();
            CWL(memo[p[1] - 1] - memo[p[0] - 1]);
        }
    }
}

public static partial class Program
{
    //テンプレここから
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static string RL() => ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static void WL(object obj) => WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new [] {0, -1, 0, 1};
    public static int[] dy = new [] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);
    //テンプレここまで
}


Measured memory_bytes: 18608
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S = input()
T = input()

m = 0

def count(A, B):
    ans = 0
    for i in range(len(A)):
        if A[i] == B[i]:
            ans += 1
    return ans

for i in range(len(S)-len(T)+1):
    m = max(m, count(S[i:i+len(T)],T))

print(len(T)-m)

Measured memory_bytes: 72968
# main関数
if __name__ == '__main__':

    S = input()
    ans = 0



    for t in range(0, len(S) - 1) :
        if (t % 2 == 0) and S[0: int(t / 2)] == S[int(t / 2) : t] :
            ans = max(t , ans)
    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  int n,m;
  cin >>n >>m;
  char g[n][n],h[m][m];
  rep(i,n)rep(ii,n)cin >>g[i][ii];
  rep(i,m)rep(ii,m)cin >>h[i][ii];

  rep(i,n-m+1)rep(r,n-m+1){
    int ans=0;
    for(int ii=i;ii<m+i;ii++){
      for(int iii=r;iii<m+r;iii++){
        if(g[ii][iii]==h[ii-i][iii-r])ans++;
      }
    }
    if(ans==m*m){cout << "Yes" << endl; return 0;}
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>

typedef struct pair{
  int x,y,z;
}point;

int compare(const void *a,const void *b){
  return (*(point*)a).z > (*(point*)b).z;
}

int compare_int(const void *a,const void *b){
  if((*(point*)a).x == (*(point*)b).x){
    return (*(point*)a).y > (*(point*)b).y;
  }
  return (*(point*)a).x > (*(point*)b).x;
}

int main(void){
  int N,M;
  scanf("%d%d",&N,&M);

  point arr[M];
  for(int i = 0;i < M;i++){
    scanf("%d %d",&arr[i].x,&arr[i].y);
    arr[i].z = i;
  }

  qsort(arr,M,sizeof(point),compare_int);

  int p = arr[0].x;
  int cnt = 0;
  for(int i = 0;i < M;i++){
    if(arr[i].x != p){
      p = arr[i].x;
      cnt = 0;
    }
    arr[i].y = ++cnt;
  }

  qsort(arr,M,sizeof(point),compare);

  for(int i = 0;i < M;i++){
    printf("%06d%06d\n",arr[i].x,arr[i].y);
  }

  return 0;
}

Measured memory_bytes: 3820
// AOJ 2426: Treasure Hunt
// 2017.12.2 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { int x, y; } PP;
PP t[5002];
int x[5002], xs;
int y[5002], ys;
int sum[5002][5002];

char buf[60], *p;
int getint()
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		n = -n;
	} else while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }
int xycmp(PP *a, PP *b) { if (a->x - b->x) return a->x - b->x; return a->y - b->y; }

int uniq(int *a, int n)
{
	int i, j;
	
	for (i = 0, j = 1; j < n; j++) {
		while (j < n && a[j] == a[i]) j++;
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int bschLE(int *a, int x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l + r) >> 1;
		if (a[m] == x) return m;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

int bschGE(int *a, int x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l + r) >> 1;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int n, m, i, j, x1, y1, x2, y2, i1, j1, i2, j2;

	fgets(p=buf, 60, stdin);
	n = getint(), m = getint();
	for (i = 0; i < n; i++) {
		fgets(p=buf, 60, stdin);
		t[i].x = x[i] = getint(), t[i].y = y[i] = getint();
	}
	qsort(x, n, sizeof(int), cmp); xs = uniq(x, n);
	qsort(y, n, sizeof(int), cmp); ys = uniq(y, n);
	qsort(t, n, sizeof(PP), xycmp);

	for (j = 0, i = 0; i < n; i++) {
		if (t[i].x != x[j]) j++;
		y1 = bschLE(y, t[i].y, ys);
		sum[y1+1][j+1]++;
	}

	for (i = 0; i < ys; i++) for (j = 0; j < xs; j++) {
        sum[i+1][j+1] += sum[i+1][j] + sum[i][j+1] - sum[i][j];
	}

	while (m--) {
		fgets(p=buf, 60, stdin);
		x1 = getint(), y1 = getint(), x2 = getint(), y2 = getint();

		j2 = bschLE(x, x2, xs);
		if (x1 == x2) j1 = j2;
		else j1 = bschGE(x, x1, xs);

		i2 = bschLE(y, y2, ys);
		if (y1 == y2) i1 = i2;
		else i1 = bschGE(y, y1, ys);

		i2++, j2++;
        printf("%d\n", sum[i2][j2] - sum[i2][j1] - sum[i1][j2] + sum[i1][j1]);
	}
	return 0;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> pref(M, 0);
	for(int i=0; i<N; ++i){
		int K;
		cin >> K;
		for(int j=0; j<K; ++j){
			int A;
			cin >> A;
			++pref[A-1];
		}
	}
	int ans = 0;
	for(int i=0; i<M; ++i){
		if(pref[i]==N) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

int main()
{
    ll A, B;
    cin >> A >> B;

    cout << max({A + B, A - B, A * B}) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i){
    int l, r, largest;
    l=2*i;
    r=2*i+1;
    
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    
    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int main(){
    cin>>H;
    for(int i=1;i<=H;i++) cin>>A[i];
    
    for(int i=H/2;i>=1;i--) maxHeapify(i);
    
    for (int i=1;i<=H;i++){
        cout<<" "<<A[i];
    }
    
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 5052
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    
    public static void main(String[] args) {
        println((char)(next().toCharArray()[0]+1));
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;
int main(){
	ll n;
	cin >> n;
	vector<ll> a(5);
	rep(i,5) cin >> a[i];
	ll min_val = *min_element(a.begin(),a.end());
	cout << ll(ceil(double(n)/double(min_val))) +4;
}

Measured memory_bytes: 256
s = input()
sum = 0
for i in range(2**(len(s)-1)):
    term = 0
    for j in range(len(s)-1):
        term *= 10
        if (i//(2**j))%2 == 0:
            sum += term + int(s[j])
            term = 0
            if j == len(s)-2:
                sum += int(s[-1])
        else:
            term += int(s[j])
            if j == len(s)-2:
                sum += term*10 + int(s[-1])
if len(s) == 1:
    sum = int(s)

print(sum)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0, l = 0, r = n - 1;
        while (l < r) {
            while (l < n && s.charAt(l) == 'R') {
                l++;
            }
            if (l >= r) {
                break;
            }
            while (r >= 0 && s.charAt(r) == 'W') {
                r--;
            }
            if (l >= r) {
                break;
            }
            l++;
            r--;
            ans++;
        }
        pw.println(ans);
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int l=0;
    if(m1<m2){
        l+=(h2-h1)*60;
        l+=(m2-m1);
    }
    else{
        l+=(h2-h1-1)*60;
        l+=60-(m1-m2);
    }
    cout<<l-k<<endl;
}

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = a + b;
  ll ans = a * (n / c);
  ans += min(n % c, a);
  cout << ans << endl;
}


Measured memory_bytes: 256
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var A = parseInt(parts[0]);
var B = parseInt(parts[1]);
var C = parseInt(parts[2]);
console.log(A + B == C || B + C == A || C + A == B ? "Yes" : "No");

Measured memory_bytes: 11340
#include <iostream>

using namespace std;

int main() {
  int x, n;
  bool m[105];
  for (bool &i : m) i = true;
  cin >> x >> n;
  for (int i = 1; i <= n; ++i) {
    int p;
    cin >> p;
    m[p] = false;
  }
  for (int i = 0; i < n + 1; ++i) {
    if (m[x - i]) {
      cout << x - i << endl;
      return 0;
    }
    if (m[x + i]) {
      cout << x + i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3604
import sys
input = sys.stdin.readline
N = list(map(int, list(input().strip())))
if sum(N[:3])%3 == 0 or sum(N[1:])%3 == 0:
    if sum(N[:3])//3 == N[0] or sum(N[1:])//3 == N[-1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 38384
H,W=map(int,input().split())
a=[list(input()) for i in range(H)]
rmidx=[]

for i in range(W):
    cnt=0
    for j in range(1,H):
        if a[0][i]=="." and a[0][i]==a[j][i]:
            cnt+=1
            if cnt==H-1:
                rmidx.append(i)
        else:
            break


for i in range(H):
    for j in reversed(rmidx):
        a[i].pop(j)

rmidx=[]

for i in range(H):
    if a[i].count("#")==0:
        rmidx.append(i)

for i in range(H):
    if not i in rmidx:
        print("".join(a[i]))

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    map<P, ll> m;
    for(int i = 0; i < n; i++)
    {
        double x;
        cin >> x;
        ll a = llround(x * 1e9);
        int two = 0;
        int five = 0;
        while(a % 2 == 0)
        {
            two++;
            a /= 2;
        }
        while(a % 5 == 0)
        {
            five++;
            a /= 5;
        }
        m[P(two, five)]++;
    }
    ll ans = 0;
    for(auto itr = m.begin(); itr != m.end(); itr++)
    {
        auto itr2 = itr;
        for(; itr2 != m.end(); itr2++)
        {
            int two = itr->first.first + itr2->first.first;
            int five = itr->first.second + itr2->first.second;
            if(two >= 18 && five >= 18)
            {
                if(itr == itr2) ans += itr->second * (itr2->second - 1) / 2;
                else ans += itr->second * itr2->second;
            }
        }
    }
    cout << ans << endl;
}


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

#define ll long long

using namespace std;

const int MAXN = 1e7 + 10;
const int MAXM = 1e5 + 10;
const int INF = 0x3fffffff;
const int MOD = 1e9 + 7;

int n, m, k;
ll tot, cnt, ans;

int f[MAXN];

string s;

int main() {
	int T;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			++f[j];
		}
	}
	for (int i = 1; i <= n; i++) {
		ans += 1ll * i * f[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

vector<string> split(const string &str, char delim){
	vector<string> res;
	size_t current = 0, found;
	while((found = str.find_first_of(delim, current)) != string::npos){
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main(){
	int data[100+10][50+10];
	int memo[100+10][50+10];
	int h;
	vector<string> strings;
	string s;
	for (int i = 0; i < 110; i++) {
		for (int j = 0; j < 60; j++) {
			data[i][j] = -1;
			memo[i][j] = -1;
		}
	}
	for (h = 0; getline(cin, s); h++) {
		strings = split(s, ',');
		for (int i = 0; i < strings.size(); i++) {
			data[h][i+1] = atoi(strings[i].c_str());
		}
	}
	
	// solve
	memo[h-1][1] = data[h-1][1];
	for (int i = h-2; i >= 0; i--) {
		if (i >= h/2) {
			for (int j = 0+1; j < h-i+1; j++) {
				memo[i][j] = data[i][j] + max(memo[i+1][j-1],memo[i+1][j]);
				//cout << memo[i][j] << " ";
			}
		}else {
			for (int j = 0+1; j < i+1+1; j++) {
				memo[i][j] = data[i][j] + max(memo[i+1][j],memo[i+1][j+1]);
				//cout << memo[i][j] << " ";
			}
		}
		//cout << endl;
	}
	cout << memo[0][1] << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    bool nines=true;
    string s;
    cin >> s;
    FOR(i,1,s.length()){
        if(s[i]!='9'){
            nines=false;
            break;
        }
    }
    ll answer = 9*(s.length()-1);
    if(nines)answer+=s[0]-'0';
    else answer += s[0]-'0'-1;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete

signed main(){

    int N, M;
    cin>>N>>M;
    vint H;
    for(int i=0;i<N;i++){
        int h;
        cin>>h;
        H.pb(h);
    }

    bool bad[SIZE]={};
    for(int i=0;i<M;i++){
        int a, b;
        cin>>a>>b;
        a--, b--;
        if(H[a]<=H[b])
            bad[a]=1;
        if(H[b]<=H[a])
            bad[b]=1;
    }

    int ans=0;
    for(int i=0;i<N;i++)
        ans+=(!bad[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    int n,l;
    cin>>n>>l;
    vector<string>v(n);
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        v[i]=s;
    }
    sort(v.begin(),v.end());
    string ans="";
    for(auto x:v)ans+=x;
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans=0;
	ll N,M,K,G,A[500010],B[500010];
	ll sum;bool F=true;
	string S;
struct UnionFind {
    vector< int > data;
    UnionFind(int sz){
        data.assign(sz, -1);
    }
    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) std::swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k){
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int k){
        return(-data[find(k)]);
    }
};

int main(){
	ios_base::sync_with_stdio(false);
	cin>>N>>M;
	UnionFind U(2*N);
	REP(i,M){
		int a,b;
		cin>>a>>b;a--,b--;
		U.unite(a,b+N);
		U.unite(a+N,b);
	}
	REP(i,N){
		if(U.same(i,i+N)){
			cout<<N*(N-1)/2-M;
			return 0;
		}
	}
	ll cnt=0;
	REP(i,N){
		if(U.same(0,i))cnt++;
	}
	cout<<cnt*(N-cnt)-M;
}
//連結グラフにおいてはv_a,v_bが同じ集合に属していたらそいつは二部グラフじゃない
//http://noshi91.hatenablog.com/entry/2018/04/17/183132
//https://ei1333.github.io/algorithm/union-find.html

Measured memory_bytes: 1024
N=int(input())
D=list(map(int,input().split()))
MOD=998244353
if D[0]!=0:
    print(0)
    exit()
b=[0]*N
for d in D:
    b[d]+=1
if b[0]!=1:
    print(0)
    exit()

cnt=1
#print(b)
#print(b[1:])
for v1,v2 in zip(b,b[1:]):
    #print(v1)
    #print(v2)
    cnt *= v1**v2 % MOD
print(cnt%MOD)

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    vector<int> s(n+1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        p[i] = a + 1;
    }
    s[0] = 0;
    s[1] = p[0];
    for (int i = 1; i < n; i++)
    {
        s[i+1] = s[i] + p[i];
    }
    
    double expv = 0;
    for (int i = 0; i < n-k+1; i++)
    {
        int hoge = 0;
        hoge = s[i + k] - s[i];
        if (hoge > expv) expv = hoge;
    }
    cout << fixed << setprecision(12);
    cout << expv / 2 << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int ans = 0;
signed main() {
	string s; cin >> s;
	for0(i, s.size() / 2)ans += (s[i] != s[s.size() - i - 1]);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N;
    cin >> N;

    vector<int> a(N);

    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                if (tmp <= N) {
                    a[--tmp]++;
                }
            }
        }
    }

    rep(i, N)
    {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 3616