akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 555555;
int l,n,a[N];ll res,qz[N];
ll getdis(int i, int j){
	if(i>j)swap(i,j);return max(a[j]-a[i],l-(a[j]-a[i]));
}
ll solve(int l, int r, bool op){
	ll res=0;int t=min(r-n,n-l),L=l+t,R=r-t;
	if(l==n&&!op||r==n&&op)return 0;
	//printf("solve %d %d %d:",l,r,op);
	if(L<n||L==n&&R==n&&op){
		if(op)res+=a[r]-a[l],r--,op^=1;
		t=min(r-n,n-l),L=l+t,R=r-t;
		res+=2*(qz[r]-qz[n-1])-2*(qz[L]-qz[l-1])-(a[n]-a[l]);
	}
	else{
		if(!op)res+=a[r]-a[l],l++,op^=1;
		t=min(r-n,n-l),L=l+t,R=r-t;
		res+=2*(qz[r]-qz[R-1])-2*(qz[n]-qz[l-1])-(a[r]-a[n]);
	}
	//printf("%lld\n",res);
	return res;
}
int main() {
	read(l);read(n);rep(i,0,n-1)read(a[i]);
	a[n]=l;rep(i,n+1,n+n)a[i]=l+a[i-n-1];
	rep(i,0,n+n)qz[i]=(i?qz[i-1]:0LL)+a[i];
	rep(c,0,n-1){
		int L=c+1,R=n+c;
		res=max(res,solve(L,R,0)+getdis(c,c+1));
		res=max(res,solve(L,R,1)+getdis(n+c,n+c+1));
	}
	
	cout<<res;
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans, ball;
    for (int i=0; i<n; i++) {
        cin >> ball;
        if (abs(k-ball) > ball) {
            ans += ball*2;
        } else {
            ans += abs(k-ball)*2;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int N;
    int A[100005];
    int cnt = 0;
    long long ans = 1;

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];

    sort(A, A + N, greater < int > ());

    for(int i = 0; i < N - 1 && cnt < 2; i++) {
        if(A[i] == A[i + 1]) {
            ans *= A[i];
            i++; cnt++;
        }
    }

    if(cnt < 2) cout << 0 << endl;
    else cout << ans << endl;

    return (0);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int Abs(int a) { return (a > 0 ? a : -a); }

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

    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = Abs(h[1] - h[0]);
    Rep(i, 2, n) dp[i] = min(dp[i - 1] + Abs(h[i] - h[i - 1]), dp[i - 2] + Abs(h[i] - h[i - 2]));
    cout << dp[n - 1] << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int H,W,K;
string fld[333];
int ans[333][333];
signed main(){
    cin>>H>>W>>K;
    rep(i,H)cin>>fld[i];


    int cnt=0;
    memset(ans,-1,sizeof(ans));
    rep(i,H){
        vint pos;
        rep(j,W)if(fld[i][j]=='#')pos.pb(j);
        if(pos.size()==0)continue;
        for(int j=0;j<pos.size();j++){
            cnt++;
            int l,r;
            if(j==0)l=0;
            else l=pos[j-1]+1;
            if(j+1==pos.size())r=W-1;
            else r=pos[j];

            for(int k=l;k<=r;k++)ans[i][k]=cnt;
        }
    }

    rep(i,H){
        if(ans[i][0]!=-1)continue;
        if(i==0||ans[i-1][0]==-1)continue;
        rep(j,W)ans[i][j]=ans[i-1][j];
    }

    for(int i=H-1;i>=0;i--){
        if(ans[i][0]!=-1)continue;
        if(i+1==H||ans[i+1][0]==-1)continue;
        rep(j,W)ans[i][j]=ans[i+1][j];
    }

    rep(i,H){
        rep(j,W){
            if(j)cout<<" ";
            cout<<ans[i][j];
        }
        cout<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> L(N);
    for(int i=0; i<N; ++i){
        cin>>L[i];
    }

    sort(L.begin(), L.end());
    long cnt = 0;
    for(int i=0; i<N; ++i){
        for(int j=i+1; j<N; ++j){
            auto itr = lower_bound(L.begin()+j+1, L.end(), L[i]+L[j]);
            //cout<<itr - (L.begin()+j+1)<<endl;
            cnt+=itr - (L.begin()+j+1);
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){

  ll n,a,b;
  cin>>n>>a>>b;
  vector<ll> h(n);
  cin>>h;
  ll d = a-b;

  auto ceil = [](auto a,auto b){return (a-1)/b+1;};

  auto kill = [&](ll bomb){
    auto v = h;
    rep(i,n)v[i] -= b*bomb;
    ll cnt = 0;
    rep(i,n){
      if(v[i]<=0)continue;
      cnt += ceil(v[i],d);
    }
    return cnt<=bomb;
  };

  ll low=0,high=1e10;
  while(high-low>1){
    ll bomb = (high+low)/2;
    if( kill(bomb) )high=bomb;
    else low=bomb;
  }
  cout<<high<<endl;

}

Measured memory_bytes: 1792
N=int(input())
S=[str(input()) for i in range(N)]
M=int(input())
T=[str(input()) for i in range(M)]
S.sort()
result=0

for i in range(N):
	if i<N-1 and S[i]!=S[i+1]:
		if S.count(S[i])-T.count(S[i])>result:
			result=S.count(S[i])-T.count(S[i])
	elif i==N-1 and S.count(S[i])-T.count(S[i])>result:
		result=S.count(S[i])-T.count(S[i])
print(result)


Measured memory_bytes: 3064
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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



signed main () {
    int n;cin >>n;
    vector<int> a(n);int ma=0;
    rep(i,n){
        cin >>a[i];
    }
    sort(all(a));reverse(all(a));
    int now=1; ma=a[0];
    rep(i,n-2){
        if(i/2+1>=n)break;
        ma+=a[i/2+1];
    }
cout <<ma<<endl;
}





Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n;
int x[maxn], y[maxn];
int pw[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	*pw = 1;
	cin >> n;
	rep(i, 1, n) {
		cin >> x[i] >> y[i];
		pw[i] = (pw[i - 1] << 1) % mod;
	}
	int ans = pw[n] - n - 1;
	ans += ans >> 31 & mod;
	rep(i, 1, n) {
		rep(j, i + 1, n) {
			int cnt = 0;
			rep(k, j + 1, n) {
				cnt += (ll) (x[j] - x[i]) * (y[k] - y[i]) == (ll) (x[k] - x[i]) * (y[j] - y[i]);
			}
			ans -= pw[cnt];
			ans += ans >> 31 & mod;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;


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

  ll N;

  cin >> N;

  double X;
  X = (double)N / 3;

  cout << setprecision(10) << X * X * X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n, r;
    cin >> n >> r;
    if(n < 10)
        cout << r + 100 * (10 - n);
    else
        cout << r;
    return 0;
}

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

using namespace std;

using ll = long long;

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat& A, mat& B, ll mod) {
    mat C(A.size(), vec(B[0].size(), 0));
    for (int i = 0; i < A.size(); i++) {
        for (int k = 0; k < B.size(); k++) {
            for (int j = 0; j < B[0].size(); j++) {
                (C[i][j] += A[i][k] * B[k][j] % mod) %= mod;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n, ll mod) {
    mat B(A.size(), vec(A.size(), 0));
    for (int i = 0; i < A.size(); i++) {
        B[i][i] = 1;
    }
    while (n > 0) {
        if (n & 1) B = mul(B, A, mod);
        A = mul(A, A, mod);
        n >>= 1;
    }
    return B;
}

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

map<ll, int> prime_factor(ll n) {
    map<ll, int> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

ll euler(ll n) {
    map<ll, int> pv = prime_factor(n);
    ll res = 1;
    for (auto& p : pv) {
        ll hoge = 1;
        for (int i = 0; i < p.second - 1; i++) {
            hoge *= p.first;
        }
        res *= (hoge * p.first - hoge);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, m;
    cin >> n >> a >> b >> m;

    ll lim_max = 1000000000000000000LL, lim_min = lim_max / 10;
    ll ans = 0;
    ll foobar = 1;

    for (int i = 18; i >= 1; i--) {
        if (foobar == 0) break;
        ll ok1 = n - 1, ng1 = -1;
        while (ok1 - ng1 > 1) {
            ll mid = (ok1 + ng1) / 2;
            ll val = a + mid * b;
            if (lim_min <= val) ok1 = mid;
            else ng1 = mid;
        }

        ll ok2 = 0, ng2 = n;
        while (ng2 - ok2 > 1) {
            ll mid = (ok2 + ng2) / 2;
            ll val = a + mid * b;
            if (val < lim_max) ok2 = mid;
            else ng2 = mid;
        }

        if (ok2 < ok1) {
            lim_min /= 10;
            lim_max /= 10;
            continue;
        }

        ll v1 = a + ok1 * b;
        ll v2 = a + ok2 * b;
        if (v1 < lim_min || v1 >= lim_max || v2 < lim_min || v2 >= lim_max) {
            lim_max /= 10;
            lim_min /= 10;
            continue;
        }

        // ok1 <= ok2
        ll first_val = v1;
        ll p = ok2 - ok1 + 1;
        mat A = {{1, 0, 0}, {1, 1, 0}, {0, 1, lim_max % m}};
        A = pow(A, p, m);
        mat B = {{b % m}, {first_val % m}, {0}};
        (ans += mul(A, B, m)[2][0] * foobar % m) %= m; 

        (foobar *= modpow(lim_max % m, p, m)) %= m;
        lim_min /= 10;
        lim_max /= 10;
    }
    cout << ans << endl;
    return 0;
}

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

int n,  ara[4][105];

int solve(int i, int j) {
    if(i > 2 || j > n)
        return 0;
    if(i == 2) {
        if(j == n) {
            return ara[i][j]; 
        }
        
        return ara[i][j] + solve(i, j + 1);
    }
    int k = max(solve(i, j + 1), solve(i + 1, j));
    return k + ara[i][j];
}

int main() {
    cin >> n;
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < n; j++)
            cin >> ara[i + 1][j + 1];
    }
    
    cout << solve(1, 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let n = read::<usize>();
    let line = read_chars();
    let mut ans = 0;
    for i in 0..n {
        if line[i] == 'R' {
            ans += 1;
        }
        if ans > n / 2 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();

    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }

    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}


Measured memory_bytes: 4352
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

n, m = map(int, input().split())
UF = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    UF.union(a, b)

ans = 0
for i in range(n):
    ans = max(ans, UF.size(i))
print(ans)

Measured memory_bytes: 14564
#美しい文字列　044_B

w=input()
count=0
ans='Yes'
t=''
for i in range(len(w)):
    count=0
    t=w[i]
    for e in range(len(w)):
        if t==w[e]:
            count=count+1
    if count%2==1:
        ans='No'
        break
    else:
        ans='Yes'

print(ans)

Measured memory_bytes: 3060
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	k, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())
	na := make([]int, n)
	var c int
	for i := 0; i < q; i++ {
		sc.Scan()
		c, _ = strconv.Atoi(sc.Text())
		na[c-1]++
	}
	for i := 0; i < n; i++ {
		if na[i]-q+k > 0 {
			fmt.Println("Yes")
			continue
		}
		fmt.Println("No")
	}
}


Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int K_MAX = 5000;

int k;
vector<ll> d(K_MAX);
ll d_sum = 0LL;

void solve() {
    ll n, x, m;
    cin >> n >> x >> m;
    x %= m;

    vector<ll> dd(d);
    for(int i=0;i<k;++i) {
        dd[i] %= m;
    }

    vector<ll> d_cnt(k, 0);
    ll x_sum = x, zero = 0;
    for(int i=0;i<k;++i) {
        d_cnt[i] = (n-1+k-1-i) / k;
        if(dd[i]) {
            x_sum += dd[i] * d_cnt[i];
        } else {
            zero += d_cnt[i];
        }
    }

    cout << n - 1 - x_sum/m - zero << endl;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int q;
    cin >> k >> q;
    for(int i=0;i<k;++i) cin >> d[i];
    while(q--) {
        solve();
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    int n,h,w;cin>>n>>h>>w;
    int ans=0;
    rep(i,n){
        int a,b;cin>>a>>b;
        if(a>=h and b>=w)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, mi = 0, ma = 0, tc = 0;
    cin >> n;
    vector<long> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    vector<int> c(8, 0);
    for(int i = 0; i < n; i++){
        if(1 <= l[i] && l[i] <= 399) c[0] = 1;
        else if(400 <= l[i] && l[i] <= 799) c[1] = 1;
        else if(800 <= l[i] && l[i] <= 1199) c[2] = 1;
        else if(1200 <= l[i] && l[i] <= 1599) c[3] = 1;
        else if(1600 <= l[i] && l[i] <= 1999) c[4] = 1;
        else if(2000 <= l[i] && l[i] <= 2399) c[5] = 1;
        else if(2400 <= l[i] && l[i] <= 2799) c[6] = 1;
        else if(2800 <= l[i] && l[i] <= 3199) c[7] = 1;
        else tc++;
    }
    long sum = accumulate(c.begin(), c.end(), 0);
    mi = ma = sum;
    if(mi == 0 && tc != 0) mi++;
    if(tc != 0) ma += tc;
    cout << mi << " " << ma << endl;
    return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a=0,b=0,c=0;
    string s;
    cin>>s;
    int n=s.size();
    rep(i,s.size()){
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else c++;
    }
    int ma=max({a,b,c});
    int mi=min({a,b,c});
    if(ma-mi>1){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
    
}

Measured memory_bytes: 5248
#include<stdio.h>
int main(void){
	int a,b,c;
	int count=0;
	int i;
	
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++){
		if(c%i==0) count++;
	}
	
	printf("%d\n",count);
	
	return 0;
}

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

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

  vector<int> num(N);
  for(int i=0; i<N; i++){
         cin >> num.at(i);
  }
  int M = 1 ;
  sort(num.begin(), num.end());
  for(int i = 1; i<N; i++){
        if( num.at(i) > num.at(i-1)){
              M++;
         }
   }

   cout << M << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,b,c,i,sum=0,ans;
cin>>a>>b>>c;
	for(i=a;i<=b;i++){
		ans=c/i*i;
	if(ans==c){
	sum++;
	}
	}
	cout<<sum<<endl;
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];


	lli data[100];
	REP(i,0,100)data[i]=0;

	lli sum=0;
	for(lli i=0;i<n;i++){
		if(DEBUG)cout<<endl<<"now="<<a[i]<<endl;
		if(i!=0){
			lli next = a[i];
			lli size = i;
			lli two=1;
			for(lli bit=0;bit<61;bit++){
				if(DEBUG)cout<<"sum="<<sum<<endl;
				if(next&(1LL<<bit)){
					if(DEBUG)cout<<"ON"<<" bit="<<bit<<" size-data[bit]="<<size-data[bit]<<endl;
					sum += two*(size-data[bit]);
				}
				else{
					if(DEBUG)cout<<" OFF"<<" bit="<<bit<<" data[bit]="<<data[bit]<<endl;;
					sum += two*data[bit];
				}
				sum%=MOD;
				two*=2;
				two%=MOD;
			}
		}
		lli now = a[i];
		for(lli bit=0;bit<61;bit++){
			if(now&(1LL<<bit)){
				if(DEBUG)cout<<"bit="<<bit<<"now="<<now<<endl;
				data[bit]++;
			}
		}
	}
	cout<<sum<<endl;


	return 0;
}

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

int main(void) {
	int N, M;
	char buf[64], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	M = atoi(ch);

	printf("%d\n", (N * (N - 1)) / 2 + (M * (M - 1)) / 2);

	return 0;
}


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

int main(){
  int k,s,ans=0;
  int z;
  cin >> k >> s;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      z = s - x - y;
      if(0<=z && z <= k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <math.h>
#include <set>
#include <map>
#include <stdio.h>
#include <queue>
#include <iomanip>
#include <cstring>
#include <stack>
#include <chrono>
#include <unordered_map>
#include <stdlib.h>
#include <ctime>
using namespace std;
typedef long long ll;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
//#define fi first
//#define se second
//#define pll pair<ll,ll>
//#define forn(i,e) for(ll i = 1; i<=e; i++)
//#define forsn(i,s,e) for(ll i = s; i<=e; i++)
//#define rforn(i,s) for(ll i = s; i >= 0; i--)
//#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
//#define dbg(x) cout<<#x<<" = "<<x<<endl
//#define mp make_pair
//#define pb push_back
//#define fi first
//#define se second
//#define all(x) (x).begin(), (x).end()
//#define sz(x) ((ll)(x).size())
// freopen("input.txt","r", stdin);
// freopen("out.txt","w", stdout);
// auto start = chrono::high_resolution_clock::now();
// auto end = chrono::high_resolution_clock::now();
// double time_taken =chrono::duration_cast<chrono::nanoseconds>(end - start).count();
// time_taken *= 1e-9;
// cout << "Time taken by program is : " << fixed << time_taken << setprecision(9);
// cout << " sec" << endl;
using iii = tuple<ll, ll, ll>;
using viii = vector<iii>;

int main() {
      fio;
      ll n, q, a, b;
      ll u;
      cin >> n >> q;
      vector<ll> x(n);
     map<ll,ll> m;
      for (int i = 0; i < n; i++) {
        cin >> u;
        if (m.count(u))
            x[i] = m[u];
        else{
            x[i] = m.size();
            m[u] = x[i];
        }
      }
      viii y(q);
      for (int i = 0; i < q; i++) {
        cin >> a >> b;
        y[i] = {a-1, b, i};
      }
      int k = sqrt(n);
      sort(y.begin(), y.end(), [&](iii x, iii y) -> bool {
        int a1, b1, i1, a2, b2, i2;
        tie(a1, b1, i1) = x;
        tie(a2, b2, i2) = y;
        int a1q = a1/k, a2q = a2/k;
        if (a1q < a2q)
            return true;
        if (a1q > a2q)
            return false;
        return b1 < b2;
      });
      vector<ll> res(q);
      vector<ll> count(m.size());
      int l = 0, r = 0, ans = 0;
      for (iii z : y) {
        int i;
        tie(a, b, i) = z;
        while (r < b)
            if (++count[x[r++]] == 1)
                ans++;
        while (r > b)
            if (--count[x[--r]] == 0)
                ans--;
        while (l < a)
            if (--count[x[l++]] == 0)
                ans--;
        while (l > a)
            if (++count[x[--l]] == 1)
                ans++;
        res[i] = ans;
      }
      for (ll u : res)
          cout << u << endl;
}


Measured memory_bytes: 58520
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var abc = Reads();
            var max = abc.Max();
            var min = abc.Min();
            var mid = abc.Sum() - max - min;
            long count = (max-min)/2+(max-mid)/2;
            mid += (max - mid) / 2 * 2;
            min += (max - min) / 2 * 2;
            if (max == mid && max == min) Console.WriteLine(count);
            else if (max != mid && max == min) Console.WriteLine(count + 2);
            else if (max == mid && max != min) Console.WriteLine(count + 2);
            else Console.WriteLine(count + 1);



            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
N, P = map(int, input().split())
S = input()

r_circ = []
v = 1
while True:
    r = v % P
    if r in r_circ:
        break
    r_circ.append(r)
    v *= 10

ans = 0
if P in (2, 5):
    for i, s in enumerate(S):
        if int(s) % P == 0:
            ans += i+1
else:
    pr = 0
    rcntmap = [0] * P
    rcntmap[0] = 1  # r - 0 patten
    for i in reversed(range(len(S))):
        d = int(S[i])
        r = (d * r_circ[(len(S)-1-i) % len(r_circ)] + pr) % P
        #r = int(S[i:]) % P
        ans += rcntmap[r]
    
        rcntmap[r] += 1
        pr = r

print(ans)


Measured memory_bytes: 42332
#include <iostream>

using namespace std;

#define M 1046527
#define L 14

string H[M];

int getChar(char ch) {
    switch (ch) {
        case 'A':
            return 1;
        case 'C':
            return 2;
        case 'G':
            return 3;
        case 'T':
            return 4;
        default:
            return 0;
    }
}

long long getKey(string str) {
    long long sum = 0, p = 1, i;

    for (i = 0; i < str.size(); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }

    return sum;
}

int h1(int key) {
    return key % M;
}

int h2(int key) {
    return 1 + (key % (M - 1));
}

bool find(string str) {
    long long key, i, h;
    key = getKey(str);

    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (H[h] == str) {
            return true;
        } else if (H[h].empty()) {
            return false;
        }
    }
}

bool insert(string str) {
    long long key, i, h;
    key = getKey(str);

    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (H[h] == str) {
            return false;
        } else if (H[h].empty()) {
            H[h] = str;
            return true;
        }
    }
}

int main() {
    int n, h;
    char cStr[L], com[9];
    string str;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s %s", com, cStr);
        str = cStr;

        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 25328
N, M = map(int, input().split())
wro = dict()
cor = set()

for _ in range(M):
    p, s = input().split()
    if s == 'AC':
        cor.add(p)
    elif s == 'WA' and p not in cor:
        wro[p] = wro.get(p, 0) + 1

wro_num = 0
for i in cor:
    wro_num += wro.get(i, 0)

print(len(cor), wro_num)

Measured memory_bytes: 19892
#include<iostream>

using namespace std;

int main() {
	int a, b, c,i,count = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	for (i = a; i <= b; i++) {
		if (c % i == 0) {
			count++;
		}
	}
		cout << count << endl;
	
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {

	int value = -1;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		Book book[] = new Book[N];
		Main main = new Main ();
		for (int i=0;i<N;i++) {
			Book b = main.new Book();
			b.c = sc.nextInt();
			b.a = new int[M];
			for (int j=0;j<M;j++) {
				b.a[j] = sc.nextInt();
			}
			book[i]= b;
		}
		main.dfs(book, new int[M], 0, 0, X);
		System.out.println(main.value);
	}

	public void dfs(Book[] b,int []value,int now,int price,int X) {
		if (now==b.length) {
			return ;
		}
		dfs(b,value,now+1,price,X);
		int a[] = new int[value.length];
		for (int i=0;i<value.length;i++) {
			a[i] = value[i];
		}
		for (int i=0;i<value.length;i++) {
			a[i] +=b[now].a[i];
		}
		price +=b[now].c;
		if (checkValue(a,X)==true) {
			if (this.value ==-1||price<this.value) {
				this.value = price;
			}
			return;
		}
		dfs(b,a,now+1,price,X);
	}

	public boolean checkValue (int [] value,int X) {
		for (int i=0;i<value.length;i++) {
			if (value[i]<X) {
				return false;
			}
		}
		return true;
	}

	public class Book {
		int c;
		int a[];
	}

}

Measured memory_bytes: 39340
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int a,b;cin>>a>>b;
  int sm=0;
  for(int i=1;i<=b;i++)
  {
    int x;cin>>x;sm+=x;
  }
  if(sm>=a)cout<<"Yes\n";
  else cout<<"No\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int N;
    cin>>N;
    if(N%1000==0){
        cout<<0<<endl;
    }else{
        cout<<1000-(N%1000)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
// C++ program to print all 
// permutations with duplicates allowed 
#include <bits/stdc++.h> 
using namespace std; 
double ans = 0;

// Function to print permutations of string 
// This function takes three parameters: 
// 1. String 
// 2. Starting index of the string 
// 3. Ending index of the string. 

int fact(int n)
{
    int ans = 1;
    for(int i=1;i<=n;i++)
    {
        ans *= i;
    }
    return ans;
}

double squareRoot(int number, int precision) 
{ 
    int start = 0, end = number; 
    int mid; 
  
    // variable to store the answer 
    double ans; 
  
    // for computing integral part 
    // of square root of number 
    while (start <= end) { 
        mid = (start + end) / 2; 
        if (mid * mid == number) { 
            ans = mid; 
            break; 
        } 
  
        // incrementing start if integral 
        // part lies on right side of the mid 
        if (mid * mid < number) { 
            start = mid + 1; 
            ans = mid; 
        } 
  
        // decrementing end if integral part 
        // lies on the left side of the mid 
        else { 
            end = mid - 1; 
        } 
    } 
  
    // For computing the fractional part 
    // of square root upto given precision 
    double increment = 0.1; 
    for (int i = 0; i < precision; i++) { 
        while (ans * ans <= number) { 
            ans += increment; 
        } 
  
        // loop terminates when ans * ans > number 
        ans = ans - increment; 
        increment = increment / 10; 
    } 
    return ans; 
} 

void permute(vector<pair<double, double> > a, int l, int r, int n) 
{ 
	// Base case 
	if (l == r) 
	{
        long double sum = 0.0;
        for(int i=0;i<n-1;i++)
        {
            //cout << a[i].first << '-' << a[i].second << ' ';
            long double temp = abs(a[i].first-a[i+1].first)*abs(a[i].first-a[i+1].first) + abs(a[i].second-a[i+1].second)*abs(a[i].second-a[i+1].second);
            sum = sum + sqrt(temp);
        }
        ans += sum;
    } 
	else
	{ 
		// Permutations made 
		for (int i = l; i <= r; i++) 
		{ 

			// Swapping done 
			swap(a[l], a[i]); 

			// Recursion called 
			permute(a, l+1, r, n); 

			//backtrack 
			swap(a[l], a[i]); 
		} 
	} 
} 

// Driver Code 
int main() 
{ 
    int n;
    cin >> n;
	vector<pair<double, double> > str;
    int x, y;
    for(int i=0;i<n;i++)
    {
        cin >> x >> y;
        str.push_back(make_pair(x, y));
    } 
	permute(str, 0, n-1, n); 
    int nfact = fact(n);
    cout << setprecision(13) << ans/(nfact*1.00000) << endl;
	return 0; 
} 

// This is code is contributed by rathbhupendra 


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct SegmentTree {
private:
    int n;
    vector<int> node;
public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1,0);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = max(node[2*i+1],node[2*i+2]);
    }
    void update(int x,int val) {
        x += (n-1);
        node[x] = val;
        while (x > 0) {
            x = (x-1)/2;
            node[x] = max(node[2*x+1],node[2*x+2]);
        }
    }

    int getmax(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return node[k];
        int vl = getmax(a,b,2*k+1,l,(l+r)/2);
        int vr = getmax(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> a(1<<n);
    for (int i = 0;i < (1<<n);++i) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    bool ans = true;
    multiset<int> st1,st2;
    st1.insert(a[0]);
    for (int i = 1;i < (1<<n);++i) st2.insert(-a[i]);
    for (int i = 0;i < n;++i) {
        auto it1 = st1.begin();
        int k = (1<<i);
        vector<int> temp;
        for (int j = 0;j < k;++j) {
            auto it2 = st2.upper_bound(-(*it1));
            if (it2 == st2.end()) {
                ans = false;
                break;
            }
            it1++;
            temp.push_back(-(*it2));
            st2.erase(it2);
        }
        for (int& j : temp) st1.insert(j);
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define rep(i,n) for (i=1;i<=(n);++i)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
ll mod = 1e9 + 7;
ll countr(vector<string> a)
{
	vector<ll> c;
	int n=1;
	ll ans = 0;
	for (int i = 0; i < a.size() - 1; i++)
	{
		if (a[i] != a[i + 1])
		{
			c.push_back(n);
			n = 1;
		}
		else n++;
	}
	c.push_back(n);
	for (int i = 0; i < c.size(); i++)
	{
		ans += c[i] * (c[i]-1) / 2;
	}
	return ans;
}
int main()
{
	int n, i, j;
	vector<string> s;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		string a;
		cin >> a;
		s.push_back(a);
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());
	for (i = 0; i < n; i++)
	{
		//cout << s[i] << endl;
	}
	vector<int> c{ 3,3,3,4,4,9,9,9,9,6,6 };
	cout << countr(s) << endl;
}


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


int main() {
    string s;
    cin>>s;
    if(s[0]=='A'){
        if(s[1]=='A'&&s[2]=='A'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(s[0]=='B'){
        if(s[1]=='B'&&s[2]=='B'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3624
import collections

n = int(input())
ss = [input() for _ in range(n)] 

ss_sorted = [''.join(sorted(s)) for s in ss]
cnts = collections.Counter(ss_sorted)

ans = 0
for key in cnts.keys():
    n = cnts[key]
    ans += n*(n-1)//2

print(ans)    

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1e5 + 55;

ll dist[maxN][3];
int n, m, s, t;
vector<int> g[maxN];

void bfs(){
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 3; j++){
			dist[i][j] = INF;
		}
	}
	queue<pair<int, int> > que;
	que.push(make_pair(s, 0));
	dist[s][0] = 0;

	while(!que.empty()){
		int u = que.front().first;
		int tp = que.front().second;
		que.pop();

		for(int i = 0, L = (int)g[u].size(); i < L; i++){
			int v = g[u][i];
			if(dist[v][(tp + 1) % 3] > dist[u][tp] + 1){
				dist[v][(tp + 1) % 3] = dist[u][tp] + 1;
				que.push(make_pair(v, (tp + 1) % 3));
			}
		}
	}

	ll ans = dist[t][0];
	if(ans >= INF){
		cout << "-1\n";
		return;
	}

	cout << (ans / 3) << '\n';
}

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

	cin >> n >> m;

	for(int i = 0; i < m; i++){
		int u, v;	cin >> u >> v;
		g[u].push_back(v);
	}
	
	cin >> s >> t;
	
	bfs();

	return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);

  int i, c;

  c = 0;
  for(i = 0; i < 4; i++){
    if(n%10 == 2) c++;
    n /= 10;
  }

  printf("%d\n", c);

  return 0;
}



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

int main() {
	int k , a , b;
  cin >> k >> a >> b;
  bool ok = false;
  for(int i = a; i <= b; i++) if(i % k == 0) ok = true;
  if(ok) cout << "OK\n";
  else cout << "NG\n";
} 	

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

int main() {
	//code
//	int t; cin>>t;
	//while(t--){
	    int n; cin>>n;
	   long  int wt[n], v[n];
	    int w; cin>>w;
	    for(int i=0;i<n;i++){
	        cin>>wt[i]; cin>>v[i];
	    }
	    
	    
	   long int dp[n+1][w+1];
	    for(int i=0;i<=n;i++){
	        for(int j=0;j<=w;j++){
	            if(i==0 || j==0){
	                dp[i][j]=0;
	            }
	           
	            else if(j>= wt[i-1]){
	                dp[i][j] = max(dp[i-1][j], dp[i-1][j-wt[i-1]]+v[i-1]);
	            }
	             else {
	                dp[i][j]= dp[i-1][j];
	            }
	        }
	    }
	    cout<<dp[n][w]<<endl;
	//}
	return 0;
}


Measured memory_bytes: 79104
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int t = 1;
    main:
    while (t-- > 0) {
      int n = sc.nextInt();
      TreeMap<Integer, Integer> map = new TreeMap<>();
      for (int i = 0; i < 1 << n; i++) {
        final int num = sc.nextInt();
        map.put(num, map.getOrDefault(num, 0) + 1);
      }
      List<Integer> slime = new ArrayList<>();
      slime.add(map.lastKey());
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < 1 << i; j++) {
          final Entry<Integer, Integer> integerIntegerEntry = map.lowerEntry(slime.get(j));
          if (integerIntegerEntry == null) {
            System.out.println("No");
            continue main;
          }
          final Integer value = integerIntegerEntry.getValue();
          final Integer key = integerIntegerEntry.getKey();
          if (value == 1) {
            map.remove(key);
          } else {
            map.replace(key, value - 1);
          }
          slime.add(key);
        }
      }
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 108800
#include<bits/stdc++.h>
using namespace std ;
int main(){
    long long x , y ;
    scanf( "%lld%lld" , &x , &y ) ;
    long long ans = x * y + x ;
    if ( ans % y ) cout << ans << endl ;
    else cout << -1 << endl ;
    return 0 ;
}

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

char o[3] = {'+','-','*'};
bool flag;

int calc(int a,int b,int op){
    if( op == 0 )
        return a + b;
    if( op == 1 )
        return a - b;
    return a * b;
}

void solve(vector<int> v, int op1, int op2, int op3){
    if( flag == false ) return ;
    int a = v[0];
    int b = v[1];
    int c = v[2];
    int d = v[3];
	
    if( calc( calc( calc(a,b,op1) , c , op2 ) , d , op3 ) == 10 ){
        cout << "(((" << a << " " << o[op1] << " " << b << ") " << o[op2] << " " << c << ") " << o[op3] << " " << d << ")" << endl;
        flag = false;
        return;
    }
    if( calc( calc(a,b,op1) , calc(c,d,op3) , op2 ) == 10 ){
        cout << "((" << a << " " << o[op1] << " " << b << ") " << o[op2] << " (" << c << " " << o[op3] << " " << d << "))" << endl;
        flag = false;
        return;
    }
    if( calc( calc( a , calc(b,c,op2) , op1 ) , d , op3 ) == 10 ){
        cout << "((" << a << " " << o[op1] << " (" << b << " " << o[op2] << " " << c << ") " << o[op3] << " " << d << "))" << endl;
        flag = false;
        return;
    }
}

int main(){
    int a,b,c,d;
	
    while( cin >> a >> b >> c >> d , a || b || c || d ){
        vector<int> v(4);
        flag = true;
        v[0] = a;
        v[1] = b;
        v[2] = c;
        v[3] = d;
		
        sort( v.begin() , v.end() );
        do{
            for(int i=0 ; i < 3 && flag ; i++ ){
                for(int j=0 ; j < 3 && flag ; j++ ){
                    for(int k=0 ; k < 3 && flag ; k++ ){
                        solve( v , i , j , k );
                    }
                }
             }
        }while( next_permutation(v.begin(),v.end()) && flag );
        if( flag ){
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 1212