akhauriyash/Code-Regression huggingface dataset:
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    ll N, x;
    cin >> N >> x;

    VL a(N);
    VL mincost(N);
    REP(i, N) {
        cin >> a[i];
        mincost[i] = a[i];
    }

    ll ans = INF;
    REP(t, N) {
        ll cost = 0;
        FOR(i, N, 2 * N - 1) {
            ll subcost = a[i % N];
            subcost = min(mincost[i % N], a[(i - t) % N]);
            cost += subcost;
            mincost[i % N] = subcost;
        }
        ans = min(ans, cost + x * t);
    }

    cout << ans << 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)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

vector<vector<int>> v(1111);
int seica[1111];
int x[1111];
int p[1111];
int dp[2][5555];

bool check(int a,vector<pair<int,int>> now){
	REP(i,2)REP(j,5555)dp[i][j] = INF;
	dp[0][0] = 0;
	REP(i,now.size()){
		REP(j,5555)if(dp[0][j] != INF){
			int tmp = j + now[i].FI;
			if(tmp < 5555)dp[1][tmp] = min(dp[1][tmp],dp[0][j] + now[i].SE);
			tmp = j + now[i].SE;
			if(tmp < 5555)dp[1][tmp] = min(dp[1][tmp],dp[0][j] + now[i].FI);
		}
		REP(j,5555){
			dp[0][j] = dp[1][j];
			dp[1][j] = INF;
		}
	}
	int ans = INF;
	REP(i,x[a]+1)ans = min(ans,dp[0][i]);
	seica[a] = ans;
	return ans != INF;
}

bool dfs(int a){
	if(v[a].size() == 0)return true;
	vector<pair<int,int>> now;
	REP(i,v[a].size()){
		if(!dfs(v[a][i]))return false;
		now.EB(x[v[a][i]],seica[v[a][i]]);
	}
	return check(a,now);
}

int main(){
	
	int n;cin >> n;
	REP(i,n-1){
		cin >> p[i+1];p[i+1]--;
		v[p[i+1]].EB(i+1);
	}
	REP(i,n)cin >> x[i];
	
	if(dfs(0)){
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}


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

int main(void) {
  using namespace std;
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int min = 114514;
  for(auto& x: m) {
    cin >> x;
    X -= x;
    if(x < min)
      min = x;
  }

  cout << N + X / min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int D;
  D=100*A+10*B+C;
  if(D%4==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


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

int main() {
	multiset<int, greater<int>> ms; int temp;
	for (int i = 0; i < 5; i++) { cin >> temp; ms.insert(temp); }
	for (auto itr = ms.begin(); itr != ms.end(); itr++) {
		cout << *itr << (itr != --ms.end() ? " " : "");
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3060
# coding: utf-8

n_ani = int(input())
l_ans = list(input())


def get_next_animal(pre_ani, now_ani, ans):
    if pre_ani == "S":
        if now_ani == "S":
            if ans == "o":
                return "S"
            else:
                return "W"
        else:
            if ans == "o":
                return "W"
            else:
                return "S"

    else:
        if now_ani == "S":
            if ans == "o":
                return "W"
            else:
                return "S"
        else:
            if ans == "o":
                return "S"
            else:
                return "W"


def solve_question(first_ani, last_ani):
    global l_ani
    l_ani.append(first_ani)
    next_ani = get_next_animal(last_ani, first_ani, l_ans[0])
    l_ani.append(next_ani)
    for i in range(1, (n_ani - 1)):
        next_ani = get_next_animal(l_ani[i - 1], l_ani[i], l_ans[i])
        l_ani.append(next_ani)

    if l_ani[(n_ani - 1)] == last_ani and get_next_animal(l_ani[(n_ani - 2)], l_ani[(n_ani - 1)], l_ans[(n_ani - 1)]) == l_ani[0]:
        return "ok"
    else:
        return "ng"


ng_counter = 0

for i in range(4):
    l_ani = []
    if i == 0:
        fir_ani = "S"
        las_ani = "S"
        if solve_question(fir_ani, las_ani) == "ok":
            print ("".join([i for i in l_ani]))
            break
        else:
            ng_counter += 1

    elif i == 1:
        fir_ani = "S"
        las_ani = "W"
        if solve_question(fir_ani, las_ani) == "ok":
            print ("".join([i for i in l_ani]))
            break
        else:
            ng_counter += 1

    elif i == 2:
        fir_ani = "W"
        las_ani = "S"
        if solve_question(fir_ani, las_ani) == "ok":
            print ("".join([i for i in l_ani]))
            break
        else:
            ng_counter += 1

    elif i == 3:
        fir_ani = "W"
        las_ani = "W"
        if solve_question(fir_ani, las_ani) == "ok":
            print ("".join([i for i in l_ani]))
            break
        else:
            ng_counter += 1

if ng_counter == 4:
    print(-1)


Measured memory_bytes: 5656
/* You can't hack me! */
#pragma warning(disable : 4996)
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vch;
typedef set<ll> sll;
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(auto i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define sc scanf
#define pr printf
#define in(x) sc("%lld", &(x))
#define id(x) sc("%Lf", &(x))
#define os(x) cout<<(x)<<' '
#define on(x) cout<<(x)<<'\n'
#define nl cout<<"\n"
#define F first
#define S second
//const ll P = 998244353;
//const ll N = 200010;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t = 1;
    //cin>>(t);
    while (t--)
    {
        ll n, m, u, v, ans=0;
        cin>>(n)>>(m);
        //vector<pair<ll, ll> > p(n);
        vll h(n);
        vector< vector<ll> > graph(n);
        fo(i, n)
        {
            cin>>h[i];
            graph[i].pb(i+1);
        }
        
        fo(i, m)
        {
            cin>>(u)>>(v);
            //graph[i].pb(i+1);
            //if(graph[u-1].size()==0) graph[u-1].pb(u);
            graph[u-1].pb(v);
            graph[v-1].pb(u);
        }
        /*fo(i, n)
        {
            fo(j, graph[i].size())
            {
                os(graph[i][j]);
            }
            nl;
        }*/
        fo(i, n)
        {
            //on(p[i].se);
            ll m=0;
            fo(j, graph[i].size())
            {
                if(h[graph[i][j]-1]==m)
                {
                    m=0;
                    break;
                }
                m=max(m, h[graph[i][j]-1]);
                //os(h[graph[i][j]-1]);
            }
            if(h[i]==m) ans++;
            //ans=max(ans, m);
        }
        on(ans);
    }
    cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 11644
S=str(input())
n=len(S)
buf='R'
ans=[]
for i in range(1,n):
    if S[i-1]=='R' and S[i]=='R':
        buf += S[i]
    elif S[i-1]=='R' and S[i]=='L':
        buf += S[i]
    elif S[i-1]=='L' and S[i]=='L':
        buf += S[i]
    else:
        r=buf.count('R')
        l=buf.count('L')
        rc=lc=0
        rc += r//2
        lc += r//2
        rc += r%2
        rc += l//2
        lc += l//2
        lc += l%2

        for j in range(r-1):
            ans.append(0)
        ans.append(rc)
        ans.append(lc)
        for j in range(l-1):
            ans.append(0)        
        
        buf='R'



r=buf.count('R')
l=buf.count('L')
rc=lc=0
rc += r//2
lc += r//2
rc += r%2
rc += l//2
lc += l//2
lc += l%2
for j in range(r-1):
    ans.append(0)
ans.append(rc)
ans.append(lc)
for j in range(l-1):
    ans.append(0)   

print(*ans)


Measured memory_bytes: 6520
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();
	pakuri_sort(N, A);
	int kotae = 0;
	int mae = -1;
	int k = 0;
	rep(i, N) {
		if (mae != A[i]) {
			kotae += k;
			k = 1;
			mae = A[i];
		}
		else k ^= 1;
	}
	printf("%d", kotae + k);

	Would you please return 0;
}

Measured memory_bytes: 1024
import typing

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
# https://github.com/not522/ac-library-python/blob/master/atcoder/math.py
def crt(r: typing.List[int], m: typing.List[int]) -> typing.Tuple[int, int]:
    assert len(r) == len(m)

    n = len(r)

    # Contracts: 0 <= r0 < m0
    r0 = 0
    m0 = 1
    for i in range(n):
        assert 1 <= m[i]
        r1 = r[i] % m[i]
        m1 = m[i]
        if m0 < m1:
            r0, r1 = r1, r0
            m0, m1 = m1, m0
        if m0 % m1 == 0:
            if r0 % m1 != r1:
                return (0, 0)
            continue

        # assume: m0 > m1, lcm(m0, m1) >= 2 * max(m0, m1)

        '''
        (r0, m0), (r1, m1) -> (r2, m2 = lcm(m0, m1));
        r2 % m0 = r0
        r2 % m1 = r1
        -> (r0 + x*m0) % m1 = r1
        -> x*u0*g % (u1*g) = (r1 - r0) (u0*g = m0, u1*g = m1)
        -> x = (r1 - r0) / g * inv(u0) (mod u1)
        '''

        # im = inv(u0) (mod u1) (0 <= im < u1)
        g, im = _inv_gcd(m0, m1)

        u1 = m1 // g
        # |r1 - r0| < (m0 + m1) <= lcm(m0, m1)
        if (r1 - r0) % g:
            return (0, 0)

        # u1 * u1 <= m1 * m1 / g / g <= m0 * m1 / g = lcm(m0, m1)
        x = (r1 - r0) // g % u1 * im % u1

        '''
        |r0| + |m0 * x|
        < m0 + m0 * (u1 - 1)
        = m0 + m0 * m1 / g - m0
        = lcm(m0, m1)
        '''

        r0 += x * m0
        m0 *= u1  # -> lcm(m0, m1)
        if r0 < 0:
            r0 += m0

    return (r0, m0)

def _inv_gcd(a: int, b: int) -> typing.Tuple[int, int]:
    a %= b
    if a == 0:
        return (b, 0)

    # Contracts:
    # [1] s - m0 * a = 0 (mod b)
    # [2] t - m1 * a = 0 (mod b)
    # [3] s * |m1| + t * |m0| <= b
    s = b
    t = a
    m0 = 0
    m1 = 1

    while t:
        u = s // t
        s -= t * u
        m0 -= m1 * u  # |m1 * u| <= |m1| * s <= b

        # [3]:
        # (s - t * u) * |m1| + t * |m0 - m1 * u|
        # <= s * |m1| - t * u * |m1| + t * (|m0| + |m1| * u)
        # = s * |m1| + t * |m0| <= b

        s, t = t, s
        m0, m1 = m1, m0

    # by [3]: |m0| <= b/g
    # by g != b: |m0| < b/g
    if m0 < 0:
        m0 += b // s

    return (s, m0)
  
N=int(input())
F = make_divisors(2*N)

ans = 10**20
for x in F:
  y = 2*N//x
  res,_ = crt([0,-1],[x,y])
  if res != 0:
    ans = min(ans,res)
  
print(ans)

Measured memory_bytes: 71288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int a, b;
    cin >> a >> b;

    if (a < b) {
        REP(i, b) {
            std::cout << a;
        }
        std::cout << '\n';
    } else {
        REP(i, a) {
            std::cout << b;
        }
        std::cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, M, K;
    int ans=0;

    cin >> N >> M >> K;

    vector<int> A(N), B(M);

    rep(i,N) {
        cin >> A[i];
    }

    rep(i,M) {
        cin >> B[i];
    }

    vector<ll> a(N+1,0), b(M+1,0);

    for(int i=1; i<=N; i++) {
        a[i] = a[i-1] + A[i-1];
    }

    for(int i=1; i<=M; i++) {
        b[i] = b[i-1] + B[i-1];
    }

    int j=M;

    for(int i=0; i<=N; i++) {
        if(a[i]>K) break;
        while(b[j]>K-a[i]) {
            j--;
        }
        ans = max(ans, i+j);
    }

    cout << ans << endl;

    return 0;
    
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N-1);
    for(int i=0;i<N-1;i++){
        cin >> B.at(i);
    }
    int sum = 0;
    for(int i=0;i<N;i++){
        if(i==0){
            A.at(i)=B.at(i);
        }
        else if(i==N-1){
            A.at(i)=B.at(i-1);
        }
        else{
            A.at(i)=min(B.at(i-1),B.at(i));
        }
        sum += A.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int d[20002], e[20002], c = 0;

int main()
{	 
	int n, m, i, k, j;
	
	scanf("%d%d", &n, &m);
	for(i = 1, k = sqrt(m); i <= k; i++){
		if(m % i == 0){
			d[c] = i;
			e[c++] = m / i;
		}
	}
	for(i = c - 1; i >= 0; i--){
		d[c] = e[i], e[c] = d[i], c++;
	}
	for(i = c - 1; i >= 0 && e[i] < n; i--);
	printf("%d\n", d[i]);
		
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= t * s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef pair<D,int> pdi;

const D EPS = 1e-8;
const D PI = acos(-1);

inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

inline D seg_p_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}

inline D seg_seg_dis(L a,L b){
  D res = 1e10;
  res = min(res,seg_p_dis(a,b.fs));
  res = min(res,seg_p_dis(a,b.sc));
  res = min(res,seg_p_dis(b,a.fs));
  res = min(res,seg_p_dis(b,a.sc));
  return res;
}

int main(){
  int w,n;
  while(cin >> w >> n){
    if(w==0)return 0;

    vector< vector<L> > l(n);
    rep(i,n){
      int m;
      cin >> m;
      vector<P> p(m);
      rep(j,m){
	int x,y;
	cin >> x >> y;
	p[j] = P(x,y);
      }
      rep(j,m){
	l[i].push_back(L(p[j],p[(j+1)%m]));
      }
    }

    int v = n+2;
    vector< vector<pdi> > g(v);
    g[v-2].pb(pdi(w,v-1));
    L ls = L(P(0,0),P(0,1e4)), lt = L(P(w,0),P(w,1e4));
    rep(i,n){
      D dis = w;
      for(L a : l[i])dis = min(dis, seg_seg_dis(ls,a));
      g[v-2].pb(pdi(dis, i));
      dis = w;
      for(L a : l[i])dis = min(dis, seg_seg_dis(lt,a));
      g[i].pb(pdi(dis,v-1));
      rep(j,i){
	dis = w;
	for(L a : l[i])for(L b : l[j]){
	    dis = min(dis, seg_seg_dis(a,b));
	  }
	g[i].pb(pdi(dis,j)); g[j].pb(pdi(dis,i));
      }
    }

    vector<D> d(v,1e9);
    d[v-2] = 0;
    bool use[220];
    memset(use,0,sizeof(use));

    for(;;){
      int u = -1;
      rep(i,v){
	if(!use[i] && (u<0 || d[u] > d[i]+EPS) )u = i;
      }
      if(u<0 || u==v-1)break;
      use[u] = true;
      
      for(pdi nxt : g[u]){
	D ncost = d[u] + nxt.fs;
	if(!use[nxt.sc] && d[nxt.sc] > ncost +EPS){
	  d[nxt.sc] = ncost;
	}
      }
    }
    cout << fixed << setprecision(9) << d[v-1] << endl;
  }
}

Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string s;
  cin>>s;
  
  int yymm=0;
  int mmyy=0;
  
  if ((s.at(0)=='0'&&s.at(1)!='0')||
      (s.at(0)=='1'&&(s.at(1)=='1'||s.at(1)=='2'))){
    mmyy=1;}
  
   if ((s.at(2)=='0'&&s.at(3)!='0')||
      (s.at(2)=='1'&&(s.at(3)=='1'||s.at(3)=='2'))){
    yymm=1;}
  
  if(mmyy==1&&yymm==1){
    cout<<"AMBIGUOUS"<<endl;}
  
  else if (mmyy==1){
    cout<<"MMYY"<<endl;}
  
  else if (yymm==1){
    cout<<"YYMM"<<endl;}
  
  else{cout<<"NA"<<endl;}
  
}
    

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> bool chmax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int n;
ll a[1000001][4];

int main() {
    cin >> n;
    a[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        (a[i][0] += a[i - 1][0] * 8) %= MOD;
        (a[i][1] += a[i - 1][0]) %= MOD;
        (a[i][1] += a[i - 1][1] * 9) %= MOD;
        (a[i][2] += a[i - 1][0]) %= MOD;
        (a[i][2] += a[i - 1][2] * 9) %= MOD;
        (a[i][3] += a[i - 1][1] + a[i - 1][2]) %= MOD;
        (a[i][3] += a[i - 1][3] * 10) %= MOD;
    }
    cout << a[n][3] << endl;

    return 0;
}

Measured memory_bytes: 34796
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;
int main(){
    int N, M; cin >> N >> M;
    priority_queue<ll> que;
    ll sum = 0;
    for(int i=0;i<N;i++){
        int a; cin >> a;
        que.push(a);
    }
    for(int i=0;i<M;i++){
        int tmp = que.top();
        que.pop();
        que.push(tmp/2);
    }
    for(int i=0;i<N;i++){
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys, math, itertools, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0



a, b, c = map(int, input().split())
for i in itertools.permutations([a, b, c], 3):
    if i[0] == sum(i[1:]) or sum(i[:2]) == i[2]:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n,m;
vl g[10];
bool vis[10];
ll ans;
void dfs(ll now,ll last,set<ll> s){
    s.insert(now);
    if(sz(s)==n)ans++;
    for(auto next:g[now]){
        if(next==last)continue;
        if(s.count(next))continue;
        dfs(next,now,s);
    }
    return;
}
int main(){
    cin>>n>>m;
    ans=0;
    rep(i,m){
        ll u,v;cin>>u>>v;
        g[u].pb(v);g[v].pb(u);
    }
    set<ll> s;
    dfs(1,-1,s);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
 
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b+c || b == a+c || c == a+b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

/* ?????????????????¨????§??????? */
typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) { return a < b ? a : b; }	/* ????°????????????? */

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);
	
	/* ??¨??????????????????????????\??????????????????????????? */
	for ( i = 1; i <= n; i++ ) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1; tail = n + 1;
	
	/* ????????\??¬????????§??? */
	while (head != tail) {
		u = dequeue();
		c = min(q, u.t);	/* q ???????????????????????? u.t ????????????????????? */
		u.t -= c;	/* ?????????????????????????¨???? */
		elaps += c;	/* ????????????????????? */
		if ( u.t > 0 ) enqueue(u);	/* ???????????????????????????????????°?????\???????????? */
		else {
			printf("%s %d\n",u.name, elaps);
		}
	}
	
	return 0;
}

Measured memory_bytes: 10756
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();
        }

        public static long C(long n, long k)
        {
            long bunbo = 1;
            long bunsi = 1;
            for (long i = n - k+1; i <= n; i++)
                bunsi *= i;
            for (long i = 1; i <= k; i++)
                bunbo *= i;
            return bunsi / bunbo;
        }
        bool f = false;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var n = Read();
            char[][] s = new char[n][];
            string[] str = new string[n];

            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine().ToCharArray();
                Array.Sort(s[i]);
                str[i] = new string(s[i]);
            }

            var d = new Dictionary<string, long>();

            long ans = 0;
          
            for (int i = 0; i < n; i++)
            {

                if (!d.ContainsKey(str[i]))
                {
                    d.Add(str[i], 1);
                }
                else d[str[i]]++;
            }


            foreach (var x in d.Values)
                ans += C(x, 2);

            Console.WriteLine(ans);
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 32596
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
ll n,d;
cin>>n>>d;
int cnt=0;
while(n--)
{
	ll x,y;
	cin>>x>>y;
	if(x*x+y*y<=d*d)
	cnt++;
}
cout<<cnt;
}
int main()
{
//code

fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3648
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    val h = readLine()!!.split(" ").map { it.toInt() }
    val good = (0 until n).toHashSet()
    for (i in 0 until m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() - 1 }
        if (h[a] <= h[b]) {
            good.remove(a)
        }
        if (h[a] >= h[b]) {
            good.remove(b)
        }
    }
    println(good.size)
}

Measured memory_bytes: 69584
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, k;
    cin >> a >> b >> k;

    if (b-a+1 == 2*k) {
        for(int i = a; i <=b; i++)
            cout << i << endl;
    }
    else if (b-a+1 > 2*k) {
        for (int i = 0; i < k; i++)
            cout << a+i << endl;

        for (int i = k-1; i >= 0; i--)
            cout << b-i << endl;
    }
    else if (b - a + 1 < 2*k) {
        for(int i = a; i <=b; i++)
            cout << i << endl;

    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	vector<vector<ll>> c(3, vector<ll>(3));
	for (int i = 0;i < 3;i++)
		for (int j = 0;j < 3;j++)
			cin >> c[i][j];
	bool ok = false;
	for (int a1 = 0;a1 <= 100;a1++) {
		vector<ll> a(3);
		a[0] = a1;
		vector<ll> b(3);
		for (int j = 0;j < 3;j++)
			b[j] = c[0][j] - a[0];
		for (int i = 0;i < 3;i++)
			a[i] = c[i][0] - b[0];
		bool now = true;
		for (int i = 0;i < 3;i++)
			for (int j = 0;j < 3;j++)
				if (c[i][j] != a[i] + b[j])
					now = false;
		if (now)
			ok = true;
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
        	list.add(scanner.nextInt());
        }
        //listを降順にソート
        Collections.sort(list, Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
        	if (i % 2 == 0) {
        		Alice += list.get(i);
        	} else {
        		Bob += list.get(i);
        	}
        }
        //System.out.println("Alice：" + Alice);
        //System.out.println("Bob：" + Bob);

        int div = Alice - Bob;
        System.out.println(div);
	}

}

Measured memory_bytes: 21844
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = array[0], t = array[1];

            var roots = (from _ in Enumerable.Repeat(0, n)
                         let cols = Console.ReadLine().Split().Select(int.Parse).ToArray()
                         let root = new { Cost = cols[0], Time = cols[1] }
                         where root.Time <= t
                         orderby root.Cost
                         select root).ToArray();

            Console.WriteLine(roots.Any() ? roots.First().Cost.ToString() : "TLE");
        }
    }
}

Measured memory_bytes: 13652
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] s = scanner.next().toCharArray();
		if(s[2] == s[3] && s[4] == s[5]) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    long int a,b;
    char op;
    cin>>a>>op>>b;
    if(op=='+')
    cout<<a+b;
    else 
    cout<<a-b;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
hnums = [int(i) for i in input().split()]
count = 0
max_movement = 0
for i in range(N-1):
    if hnums[i] >= hnums[i+1]:
        count += 1
    else:
        max_movement = max(max_movement,count)
        count = 0
max_movement = max(max_movement,count)
print(max_movement)

Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll h, w, ans = -1;
	in(h);
	in(w);
	vector<string> a(h);
	queue<pair<ll, ll>> q, qd;
	rep(i, 0, h) {
		in(a[i]);
		rep(j, 0, w) {
			if (a[i][j] == '#') {
				q.push(make_pair(i, j));
			}
		}
	}

	while (q.size() > 0) {
		ans++;
		qd = q;
		queue<pair<ll, ll>>().swap(q);
		while (qd.size() > 0) {
			auto tmp = qd.front();
			ll x = tmp.first;
			ll y = tmp.second;
			if (x - 1 >= 0 && a[x - 1][y] == '.') {
				a[x - 1][y] = '#';
				q.push(make_pair(x - 1, y));
			}
			if (x + 1 < a.size() && a[x + 1][y] == '.') {
				a[x + 1][y] = '#';
				q.push(make_pair(x + 1, y));
			}
			if (y - 1 >= 0 && a[x][y - 1] == '.') {
				a[x][y - 1] = '#';
				q.push(make_pair(x, y - 1));
			}
			if (y + 1 < a[x].size() && a[x][y + 1] == '.') {
				a[x][y + 1] = '#';
				q.push(make_pair(x, y + 1));
			}
			qd.pop();
		}
	}
	outn(ans);
	return 0;

}


Measured memory_bytes: 34100
#include<stdio.h>
 
int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key)i++;
    return i != n;
}
 
int main() {
    int i, n, A[10000 + 1], q, key, sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(A, n, key))sum++;
    }
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  map<int, int> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(a,a+n);
  int dia=a[n-1]+1,tmp=a[n-1];
  while(dia>0){
    if(dia>2){
      if(mp[tmp]<2){
        cout << "Impossible\n";
        return 0;
      }else{
        dia-=2;
      }
    }else if(dia==2){
      if(mp[tmp]==2){
        dia-=2;
      }else{
        cout << "Impossible\n";
        return 0;
      }
    }else{
      if(mp[tmp]==1){
        dia--;
      }else{
        cout << "Impossible\n";
        return 0;
      }
    }
    tmp--;
  }
  cout << "Possible\n";
  return 0;
}


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

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<bool> can_use_card(n, true);
    for (int i = 0; i < m; i++) {
        int l, r;
        std::cin >> l >> r;

        l--;
        r--;

        std::fill(can_use_card.begin(), can_use_card.begin() + l, false);
        std::fill(can_use_card.begin() + r + 1, can_use_card.end(), false);
    }

    std::cout << std::count(can_use_card.begin(), can_use_card.end(), true) << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
using namespace std;
const int Max = 2e5;
 
long long n, a[Max + 5], l, r, ans;
map<int, int> cnt;
bool cmp(int m, int n){
	return m > n;
}
bool flag = 0;
 
int main()
{
	scanf ("%I64d", &n);
	for (int i = 1; i <= n; i++){
		scanf ("%I64d", &a[i]);
		cnt[a[i]]++;
	}
	l = 0;
	r = 0;
	sort(a + 1, a + n + 1, cmp);
	for (int i = 1; i <= n; i++){
		if (cnt[a[i]] >= 2){
			if (!l)	l = a[i], cnt[a[i]]-=2;
			else r = a[i];
			if (l && r)	break;
		}
	}
	ans = l * r;
	printf ("%lld\n", ans);
}

Measured memory_bytes: 5760
n=int(input())
A=list(map(int,input().split()))

ans=1

if 0 in A:
    print(0)
else :
    for i in range(n):
        ans*=A[i]
        if ans > 10**18:
            break

    if ans>10**18:
        print(-1)
    else :
        print(ans)


Measured memory_bytes: 21708
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string S;
  cin >> S;
  bool x = true;
  for(int i = 0; i < S.size(); i++){
    for(int j = 0; j < S.size(); j++){
      if(S.at(i) == S.at(j) && i != j){
        x = false;
        break;
      }
    }
  }
  if(x){
    cout << "yes";
  }else{
    cout << "no";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;

int main(void) {

	int x, y;
	cin >> x >> y;
	int ans;
	

	for (int i = 0; i <= x; i++) {
		ans = 2 * x + 2 * i;
		if (ans == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

ll x = 1, n;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    ll ans = 0;
    for(ll i = 0; i < n; ++i){
        ll y; cin >> y;
        if(y != x) ans++;
        else x++;
    }
    cout << (ans == n ? -1 : ans) << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long int a[200005];
	long long int n;
	cin>>n;
	for(int i=1;i<=n;i++) 

	cin>>a[i];
	long long int s=0;
	sort(a+1,a+n+1);
	if(n%2==0)
	{
		int d=n/2;
		for(int i=n-1;i>d;i--)
		s+=a[i];
		s*=2;
		s+=a[n];

	}
	else
	{
		int d=(n+1)/2;
		for(int i=n-1;i>d;i--)
		s+=a[i];
		s*=2;
		s+=a[n];
		s+=a[d]; 
	}
	 
	cout<<s<<endl;
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
long long res = 0, f[100001], n;
string s[100001];
int main () {
  //freopen(".inp", "r", stdin);
  //freopen(".out", "w", stdout);
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  cin >> n;
  for (int i = 1; i <= n; ++ i) {
    cin >> s[i];
    sort (s[i].begin (), s[i].end ());
  }
  sort (s + 1, s + n + 1);
  for (int i = 1; i <= n; ++ i) {
    f[i] = f[i - 1] + i;
  }
  int c = 1;
  for (int i = 2; i <= n; ++ i) {
    if (s[i] != s[i - 1]) {
      res += f[c - 1];
      c = 1;
    }
    else {
      ++ c;
    }
  }
  res += f[c - 1];
  cout << res;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, a;
    vector<lli> v;
    cin >> n;
    vector<vector<lli>> men;
    men.resize(n + 2);
    lli mod = 1e9 + 7;

    fr(i, 0, n) {
        fr(j, 0, n) {
            cin >> a;
            if (a == 1) {
                men[j].pb(i);
            }
        }
    }

    vector<vector<lli>> dp(1 << n, vector<lli>(n + 2, 0));

    fr(i, 0, men[0].size()) {
        a = men[0][i];
        dp[1 << a][0] = 1;
    }

    for (lli mask = 1; mask < (1 << n); mask++) {
        lli c = -1;
        lli temp = mask;
        while (temp > 0) {
            if (temp % 2 == 1) {
                c++;
            }
            temp /= 2;
        }
        if (c == 0) {
            continue;
        }
        for (lli j = 0; j < men[c].size(); j++) {
            a = men[c][j];
            if ((mask & (1 << a)) != 0) {
                lli p = 1 << n;
                --p;
                p = p ^ (1 << a);
                dp[mask][c] += dp[mask & ~(1 << a)][c - 1];
                dp[mask][c] %= mod;
            }
        }
    }

    lli ans = 0;
    for (lli mask = 1; mask < (1 << n); mask++) {
        ans += dp[mask][n - 1];
        ans %= mod;
    }

    cout << ans << endl;
    rt;
}


Measured memory_bytes: 442624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

void no() {
    output("NO");
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int H, W, N;
    cin >> H >> W >> N;
    int Y, X;
    cin >> Y >> X;
    string s, t;
    cin >> s >> t;
    int x = X;
    rep(i, N) {
        if(s[i] == 'L') x--;
        if(x < 1 || x > W) no();
        if(t[i] == 'R') x++;
        if(x < 1 || x > W) x--;
    }
    
    x = X;
    rep(i, N) {
        if(s[i] == 'R') x++;
        if(x < 1 || x > W) no();
        if(t[i] == 'L') x--;
        if(x < 1 || x > W) x++;
    }
    
    int y = Y;
    rep(i, N) {
        if(s[i] == 'U') y--;
        if(y < 1 || y > H) no();
        if(t[i] == 'D') y++;
        if(y < 1 || y > H) y--;
    }
    
    y = Y;
    rep(i, N) {
        if(s[i] == 'D') y++;
        if(y < 1 || y > H) no();
        if(t[i] == 'U') y--;
        if(y < 1 || y > H) y++;
    }
    
    output("YES");
   
    
    return 0;
}


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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0238

int main() {
	int d, n;
	while (cin >> d >> n) {
		if (n == 0) break;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int s, t;
			cin >> s >> t;
			sum += t - s;
		}
		if (d <= sum) cout << "OK";
		else cout << (d - sum);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}


void func() {
  LL A,B;
  cin >> A;
  cin >> B;
  cout << max((LL)0, A - 2 * B);



}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





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

using namespace std;

int main(){
  int N; cin >> N;
  if(N == 1){
	cout << "! 1" << endl;
	return 0;
  }

  int mx = 0, left = 0;
  for(int i=2;i<=N;++i){
	cout << "? 1 " << i << endl;
	int x; cin >> x;
	if(x > mx){
	  left = i;
	  mx = x;
	}
  }

  vector<int> ans(N);
  ans[0] = left;
  for(int i=1;i<=N;++i){
	if(i == left) continue;
	cout << "? " << left << " " << i << endl;
	int x; cin >> x;
	ans[x] = i;
  }

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

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

    if (A<6)   cout << 0 << endl;
    else if (A<=12) cout << B / 2 << endl;
    else    cout << B << endl;

    return 0;
}



Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

#define	MOD	1000000007

using namespace std;

int main(int argc, char* argv[]) {

	string s;
	long first, end;
	int flg = 1;

	cin >> s;

	for (long i = 0; i < s.length(); i++) {
		if (s[i] == 'A' && flg) {
			first = i;
			flg = 0;
		}

		if (s[i] == 'Z') {
			end = i;
		}
	}

	cout << end - first + 1 << endl;

	return 0;

}


Measured memory_bytes: 640