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

using namespace std;

char a[111111];
struct node{
    char ss;
    int pos;
    int pre;
    int hou;
} b[111111];;
bool x[111111];

int main(){
    scanf("%s", a + 1);
    int cnt = 0;
    a[0] = 'z';
    a[strlen(a)] = 'z';
    int len = strlen(a);
    int temp = 0;
    for(int i = 0; i < len; i++){
        if(a[i] != 'x'){
            b[cnt].ss = a[i];
            b[cnt++].pos = i;
        }
        else{
            temp = i;
            while(a[temp] == 'x') temp++;
            b[cnt - 1].hou = temp - i;
            i = temp - 1;
        }
    }
    int flag = 1;
    for(int i = 0, j = cnt - 1; i < j; i++, j--){
        if(b[i].ss != b[j].ss){
            flag = 0;
            break;
        }
    }
    if(!flag){
        return printf("-1\n"),0;
    }
    int ans = 0;
    for(int i = 0, j = cnt - 2; i < j; i++, j--){
        ans += abs(b[i].hou - b[j].hou);
    }
    printf("%d\n", ans);
}

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

#define MAXN 800005

typedef long long lint;

using namespace std;

const int G = 5, mod = 924844033;
int n;
int size[MAXN], times[MAXN], head[MAXN], cnt;
lint fac[MAXN], inf[MAXN], a[MAXN], b[MAXN];
int r[MAXN];

struct data {
    int next, to;
    data(int next = 0, int to = 0):next(next), to(to) {}
}edge[MAXN << 1];

int read() {
    char c = getchar();
    int x = 0;
    while (!isdigit(c))
        c = getchar();
    while (isdigit(c)) {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x;
}

void connect(int u, int v) {
    edge[++cnt] = data(head[u], v);
    head[u] = cnt;
}

void DFS(int u, int pre) {
    size[u] = 1;
    for (int i = head[u]; i; i = edge[i].next) {
        int v = edge[i].to;
        if (v == pre)
            continue;
        DFS(v, u);
        size[u] += size[v];
        ++times[size[v]];
    }
    ++times[n - size[u]];
}

lint power(lint a, int b) {
    lint res = 1;
    while (b) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void NTT(lint* a, int n, int opt) {
    for (int i = 0; i < n; ++i)
        if (i < r[i])
            swap(a[i], a[r[i]]);
    for (int i = 1; i < n; i <<= 1) {
        lint gn = power(opt == 1 ? G : power(G, mod - 2), (mod - 1) / (i << 1));
        for (int j = 0; j < n; j += (i << 1)) {
            lint g = 1;
            for (int k = 0; k < i; ++k) {
                lint x = a[j + k], y = a[j + k + i] * g % mod;
                a[j + k] = (x + y) % mod;
                a[j + k + i] = (x - y + mod) % mod;
                g = g * gn % mod;
            }
        }
    }
    if (opt == -1) {
        lint inv = power(n, mod - 2);
        for (int i = 0; i < n; ++i)
            a[i] = inv * a[i] % mod;
    }
}

int getr(int n) {
    int limit = 1, size = 0;
    while (limit <= n) {
        limit <<= 1;
        ++size;
    }
    for (int i = 0; i < limit; ++i)
        r[i] = (r[i >> 1] >> 1) | ((i & 1) << (size - 1));
    return limit;
}

void init() {
    inf[0] = fac[0] = 1;
    for (int i = 1; i <= n; ++i)
        fac[i] = fac[i - 1] * i % mod;
    inf[n] = power(fac[n], mod - 2);
    for (int i = n - 1; i >= 1; --i)
        inf[i] = inf[i + 1] * (i + 1) % mod;
}

lint C(int n, int m) {
    return fac[n] * inf[n - m] % mod * inf[m] % mod;
}

int main() {
    n = read();
    for (int i = 1; i < n; ++i) {
        int u = read(), v = read();
        connect(u, v);
        connect(v, u);
    }
    DFS(1, 0);
    init();
    for (int i = 0; i <= n; ++i) {
        a[i] = fac[n - i] * times[n - i] % mod;
        b[i] = inf[i];
    }
    int limit = getr(n << 1);
    NTT(a, limit, 1);
    NTT(b, limit, 1);
    for (int i = 0; i < limit; ++i)
        a[i] = a[i] * b[i] % mod;
    NTT(a, limit, -1);
    for (int i = 0; i < n; ++i)
        printf("%lld\n", (C(n, i + 1) * n % mod - a[n - i - 1] * power(fac[i + 1], mod - 2) % mod + mod) % mod);
}


Measured memory_bytes: 55168
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int gcd(Int x, Int y){
	while(x % y != 0){
		Int r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int a, b; cin >> a >> b;
	cout << a * b / gcd(a, b) << "\n";
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;
int arr[N];
int dp[N][2];
int n;
int solve(int i,int flag)
{
	if( i == 1){
		if(flag == 0)dp[i][flag] = arr[0] + arr[1];
		else
		dp[i][flag] = -(arr[0] + arr[1]);
		return dp[i][flag];
	}
	if(dp[i][flag] != -1) return dp[i][flag];
	int a = arr[i] + max(solve(i-1,0),solve(i-1,1));		
	int b = -arr[i] + max(solve(i-1,0) - 2*arr[i-1] , solve(i-1,1) + 2*arr[i-1]);
	
	dp[i][0] = a;
	dp[i][1] = b;
	return max(a,b);
}


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        cin>>n;
       //int arr[n];
       memset(dp,-1,sizeof dp);
       for (int i = 0; i < n; i++)
	   {
		   cin>>arr[i];
	   }
	//   cout<<endl;
	   int ans = max(solve(n-1,0),solve(n-1,1));
	   cout<<ans;
	   //cout<<endl;
	   //for(int i = 0 ; i < n ; i++) cout<<dp[i][0]<<" ";
	   //cout<<endl;
	   //for(int i = 0 ; i < n ; i++) cout<<dp[i][1]<<" ";
	   
    }
    return 0;

}


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

typedef long long ll;

const ll mod = 1e9 + 7;

int n, k;
vector<ll> pos, neg;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    ll x; cin >> x;
    if (x < 0) neg.push_back(x);
    else pos.push_back(x);
  }
  sort(pos.begin(), pos.end());
  sort(neg.rbegin(), neg.rend());

  ll res = 1;
  if (n == k) {
    for (ll x : pos)
      res = res * x % mod;
    for (ll x : neg)
      res = res * x % mod;
  } else if (n == (int) neg.size()) {
    if (k & 1) {
      for (int i = 0; i < k; i++)
        res = res * neg[i] % mod;
    } else {
      for (int i = neg.size() - 1; i >= neg.size() - k; i--)
        res = res * neg[i] % mod;
    }
  } else {
    if (k & 1) {
      --k;
      res = pos.back();
      pos.pop_back();
    }
    while (k > 0) {
      ll pa = 0, pb = -1, na = 0, nb = -1;
      if (pos.size() < 2) {
        na = neg.back(); neg.pop_back();
        nb = neg.back(); neg.pop_back();
        res = res * na % mod * nb % mod;
      } else if (neg.size() < 2) {
        pa = pos.back(); pos.pop_back();
        pb = pos.back(); pos.pop_back();
        res = res * pa % mod * pb % mod;
      } else {
        pa = pos[pos.size() - 1];
        pb = pos[pos.size() - 2];
        na = neg[neg.size() - 1];
        nb = neg[neg.size() - 2];
        if (pa * pb > na * nb) {
          pos.pop_back();
          pos.pop_back();
          res = res * pa % mod * pb % mod;
        } else {
          neg.pop_back();
          neg.pop_back();
          res = res * na % mod * nb % mod;
        }
      }
      k -= 2;
    }
  }
  res = (res % mod + mod) % mod;
  cout << res << '\n';
  return 0;
}



Measured memory_bytes: 5528
from scipy.sparse import*
e=enumerate
h,*s=open(0)
h,w=map(int,h.split())
*g,=eval('[0]*500,'*500)
for i,t in e(s):
  for j,u in e(t):
    k=i*w+j
    g[k][k+1]=u>'#'<t[j+1]
    g[k][k+w]=(i<h-1)*u>'#'<s[i+1][j]  
a=csgraph.johnson(csr_matrix(g),0)
print(int(a[a<999].max()))

Measured memory_bytes: 19896
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod=1e9+7;
const int MAXN=510000;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


//k<=1e5
mint COM(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}

ll fac[MAXN],finv[MAXN],inv[MAXN];

void COMint()
{
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAXN;i++)
    {
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll COM(int n,int k)
{
    if(n<k)return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main()
{
    ll x,y;
    cin>>x>>y;
    ll av=2*x-y;
    ll bv=2*y-x;
    if(av%3!=0 || bv%3!=0 || av<0 || bv<0)
    {
        cout<<0;
        return 0;
    }
    ll ac=av/3;
    ll bc=bv/3;
    mint ans=1;
    rep(i,ac+bc)
    {
        ans*=i+1;
    }
    rep(i,ac)
    {
        ans/=(i+1);
    }
    rep(i,bc)
    {
        ans/=(i+1);
    }
    cout<<ans.x;

    
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    rep(i, N){
        cin >> A[i] >> B[i];
    }

    if(N % 2 == 1){
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        int x = N / 2;
        cout << B[x] - A[x] + 1 << endl;
    } else {
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        int x1 = N / 2 - 1;
        int x2 = N / 2;
        int mi = A[x1] + A[x2];
        int ma = B[x1] + B[x2];
        cout << ma - mi + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4808
#include <iostream>
using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPD(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=b; i++)
#define INF 100000000000000
#define all(x)
#define MAX(x) *max_element(ALL(x))



//変数定義
ll N;
ll A[200000+10]={};
ll B[200000+10]={}; //各大きさの整数の含まれている数
ll C[200000+10]={};
ll sum=0;
ll MAX=0; 
#define COM(a) a*(a-1)/2

int code(){
    REP(i, MAX+1){
        C[i] = COM(B[i]);
        sum += C[i];
    }
    return 0;
}

int main(){
    cin >> N;
    REP(i, N){
        cin >> A[i];
        B[A[i]]++;
        if(MAX< A[i]){
            MAX = A[i];
        }
    }
    
    code();

    REP(i, N){
        ll answer;
        ll ins= B[A[i]] -1;
        answer = sum - C[A[i]] + COM(ins);
        cout <<  answer << endl;
    }
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double ld;
#define int long long
#define double long double
//typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double eps = 1e-10;
const double PI = 3.141592653589793;
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;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

typedef complex<ld> P;
ld cross(const P &a, const P &b) { return a.real() * b.imag() - a.imag() * b.real(); }
////////////////////////////////////////////////////////////////////
template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

////////////////////////////////////////////////////////////////////

int n;vector<P> v;
signed main(){
  cin>>n;
  rep(i,n){
    ld x,y;cin>>x>>y;v.push_back(complex<ld>(x, y));
  }
  ld ans = min_ball(v.begin(), v.end()).second;
  cout << setprecision(15) << sqrt(ans) << endl;
}


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

int main() {
  string s, t, u;
  cin >> s;
  t = s;
  sort(t.begin(), t.end());

  for (char c = 'a'; c <= 'z'; ++c)
    u.push_back(c);

  string diff;
  std::set_difference(u.begin(), u.end(), t.begin(), t.end(), std::inserter(diff, diff.begin()));

  if (0 < diff.size())
    cout << s << diff.front() << endl;
  else
  {
    if (s == "zyxwvutsrqponmlkjihgfedcba")
      cout << -1 << endl;
    else
    {
      t = s;
      next_permutation(t.begin(), t.end());
      for (int i = 0; i < 26; ++i)
      {
        cout << t[i];
        if (t[i] != s[i])
        {
          cout << endl;
          break;
        }
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/math/special_functions/prime.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace boost::math;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

namespace mymod {ll add(ll a, ll b);ll sub(ll a, ll b);ll mul(ll a, ll b);ll power(ll a, ll b);ll div(ll a, ll b);static constexpr ll my_modulus = 1000000007LL;}

ll mymod::add(ll a, ll b){return (a + b) % my_modulus;}
ll mymod::sub(ll a, ll b){return (a + my_modulus - b) % my_modulus;}
ll mymod::mul(ll a, ll b){return ((a % my_modulus) * (b % my_modulus)) % my_modulus;}
ll mymod::power(ll a, ll b){
    if (b == 0) return 1;
    else if (b == 1) return a % my_modulus;
    else if (b % 2 == 0){ll p = power(a, b / 2); return p * p % my_modulus;}
    else return a * power(a, b-1) % my_modulus;
}
ll mymod::div(ll a, ll b){return mul(a, power(b, my_modulus-2));}


int main() {
    ll N;
    cin >> N;
    array<ll, 168> counter{};
    for (auto &&i: boost::irange(1LL, N+1)){ // 全整数列挙
        ll target = i;
        for (auto &&j: boost::irange(0LL, 168LL)){ // 全素数列挙
            ll p = prime(j);
            while (target >= p && target % p == 0){
                target/=p;
                counter.at(j)++;
            }
        }
    }
    ll count{1};
    for (auto &&i: boost::irange(0LL, 168LL)){
//        cout << "i: " << prime(i) << " count: " << counter.at(i) << endl;
        count = mymod::mul(count, counter.at(i)+1);
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define N 100001
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
 
typedef long long ll;

int main(){
    IOS;
    ll n;
    cin>>n;
    if(n%1000==0){
        cout<<"0";
    }
    else{
        ll ans=(n/1000)*1000+1000;
        ans=ans-n;
        cout<<ans;
    }
    return 0;
}

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

int main() {
  int health,num,sum,temp;
  cin >> health >> num;
  sum = 0;
  for (size_t i = 0; i < num; i++) {
    cin >> temp;
    sum += temp;
  }
  if (health > sum) {
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        x: u64,
    }
    println!("{}", if x < 1200 {"ABC"} else {"ARC"});
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  vector<vl> g(n, vl(n));
  rep(i,n) rep(j,n) cin >> g[i][j];

  ll ans = 0;
  rep(i,n) rep(j,i) {
    bool f = true;
    rep(k,n) {
      if (k==i or k==j) continue;
      if (g[i][k] + g[k][j] < g[i][j]) {
	cout << -1 << endl;
	return 0;
      } else if (g[i][k] + g[k][j] == g[i][j]) {
	f = false;
      }
    }
    if (f) ans += g[i][j];
  }
    
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char a[12];

ll mk() {
    scanf("%s", a);
    sort(a, a+10);
    ll r = 0;
    for (int i = 0; i < 10; i++) {
        ll f = (1LL << (i*5));
        ll c = a[i] - 'a';
        r += f*c;
    }

    return r;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    map<ll, ll> m;
    int n = gi();
    for (int i = 0; i < n; i++)
        m[mk()]++;

    ll res = 0;
    for (auto &it : m)
        res += it.second * (it.second - 1) / 2;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector <long> a(n+1), b(n);
    for (int i = 0; i < n + 1; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    long sum = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < b[i]) {
            sum += a[i];
            if (a[i + 1] < b[i] - a[i]) {
                sum += a[i + 1];
                a[i + 1] = 0;
            } else {
                sum += (b[i] - a[i]);
                a[i + 1] -= (b[i] - a[i]);
            }
        } else {
            sum += b[i];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int n;
int r[101],b[101];
int memo[101];
P h[101];
int ans;
int rec(int s)
{
	if(memo[s]>0)return memo[s];
	if(r[s]==0&&b[s]==0)
	{
		memo[s]=h[s].fi+h[s].sec;
		return memo[s];
	}
	else if(r[s]==0&&b[s]!=0)
	{
		memo[s]=rec(b[s])/__gcd(h[s].fi,rec(b[s]))*(h[s].fi+h[s].sec);
		return memo[s];
	}
	else if(r[s]!=0&&b[s]==0)
	{
		memo[s]=rec(r[s])/__gcd(h[s].sec,rec(r[s]))*(h[s].fi+h[s].sec);
		return memo[s];
	}
	else
	{
		int tp,tq;
		tp=h[s].fi;tq=h[s].sec;
		int k=rec(b[s])/__gcd(rec(b[s]),tp);
		tp*=k;tq*=k;
		k=rec(r[s])/__gcd(rec(r[s]),tq);
		tp*=k;
		tq*=k;
		memo[s]=tp+tq;
		return memo[s];
	}
}
int main()
{
	while(1)
	{
		memset(r,0,sizeof(r));
		memset(b,0,sizeof(b));
		memset(memo,0,sizeof(memo));
		ans=0;
		for(int i=0;i<101;i++)
		{
			h[i].fi=0;
			h[i].sec=0;
		}
		cin >> n;
		if(n==0)break;
		for(int i=1;i<=n;i++)
		{
			int p,q,re,bl;
			cin >> p >> q >> re >> bl;
			int k=__gcd(p,q);
			p/=k;
			q/=k;
			h[i]=mp(p,q);
			r[i]=re;
			b[i]=bl;
		}
		for(int i=1;i<=n;i++)
		{
			ans=max(ans,rec(i));
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int N, K, S;
    cin >> N >> K >> S;
    for (int i = 0; i < K; i++) {
        cout << S;
        if (i < N-1) cout << " ";
    }
    int dummy = S == 1000000000? 1: S+1;
    for (int i = K; i < N; i++) {
        cout << dummy;
        if (i < N-1) cout << " ";
    }
    cout << "\n";
}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}



long long calc(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}



int main(void){
    int n;
    int even = 0;
    int odd = 0;
    int a;
    int i;
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &a);
        if (a % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }

    even += odd/2;
    odd = odd % 2;
    while (even > 1){
        even = even/2 + even%2;
    }
    if (even + odd == 1){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}


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

#define N 10
#define INT(X) \
  ( *( (const int *)(X) ) )

int comparator (
  const void  * a,
  const void  * b
  )
{
  return ( INT( b ) - INT( a ) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int k_operafan = 0;
  int i;

  for ( ; ; )
  {
    int n;
    struct tagD
    {
      int   pt;
      char  name[ 32 ];
    } d[ N ];

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    if ( k_operafan ) puts ( "" );
    else
    {
      k_operafan = 1;
    }

    for ( i = 0; i < n; ++i )
    {
      int w, l, e;

      scanf ( "%s %d %d %d", d[ i ].name, &w, &l, &e );
      d[ i ].pt = w * 3 + e;
    }

    qsort ( d, n, sizeof ( struct tagD ), comparator );

    for ( i = 0; i < n; ++i )
    {
      printf ( "%s,%d\n", d[ i ].name, d[ i ].pt );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int fig[8];
	while(cin>>fig[0]){
		for(int i=1;i<8;i++) cin>>fig[i];
		for(int i=0;i<8;i++){
			if(fig[i]!=0){
				if(fig[i]==fig[i+1]&&fig[i]%11==0)
				printf("A\n");
				else if(fig[i]==fig[i+1]&&fig[i]==fig[i+2])
				printf("B\n");
				else if(fig[i]%1111==0)
				printf("C\n");
				else if(fig[i+1]==fig[i]*10+fig[i])
				printf("D\n");
				else if(fig[i+1]==fig[i]/10)
				printf("E\n");
				else if(fig[i+1]==fig[i]+fig[i]/10)
				printf("F\n");
				else if(fig[i+1]==fig[i]*10)
				printf("G\n");
				break;
			}
		}
	}
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct edge{int to,cap,rev;};

const int MAX_V = 2000;
const int F_INF = 19191919;
vector<edge> G[MAX_V];
int lv[MAX_V], it[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].pb({to,cap,(int)G[to].size()});
    G[to].pb({from,0,(int)G[from].size()-1});
}

void dinic_bfs(int s){
    fill(lv,lv+MAX_V,-1);
    queue<int> que;
    lv[s]=0;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap>0 && lv[e.to]<0){
                lv[e.to] = lv[v]+1;
                que.push(e.to);
            }
        }
    }
}

int dinic_dfs(int v, int t, int f){
    if(v==t) return f;
    for(int &i=it[v]; i<G[v].size(); ++i){
        edge &e = G[v][i];
        if(e.cap>0 && lv[v]<lv[e.to]){
            int d = dinic_dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(1){
        dinic_bfs(s);
        if(lv[t]<0) return flow;
        fill(it,it+MAX_V,0);
        int f;
        while((f=dinic_dfs(s,t,F_INF))>0) flow+=f;
    }
}

int main()
{
    int n;
    while(scanf(" %d", &n),n)
    {
        rep(i,MAX_V) G[i].clear();

        unordered_map<int,int> m;
        int M = 0;

        int ISSAC;
        scanf(" %d", &ISSAC);
        while(ISSAC--)
        {
            int day;
            scanf(" %d", &day);
            if(!m.count(day)) m[day] = M++;
        }

        vector<int> k(n);
        vector<vector<int>> s(n);

        rep(i,n)
        {
            scanf(" %d", &k[i]);
            rep(j,k[i])
            {
                int day;
                scanf(" %d", &day);
                if(m.count(day)) s[i].pb(m[day]);
            }
            k[i] = s[i].size();
        }

        int S = n+M, T = S+1;
        rep(i,n)
        {
            add_edge(S,i,1);
            rep(j,k[i]) add_edge(i,n+s[i][j],1);
        }
        rep(i,M) add_edge(n+i,T,1);

        printf("%d\n", max_flow(S,T));
    }
    return 0;
}

Measured memory_bytes: 3688
w = input()
dic = {}
for i in range(len(w)):
    if w[i] not in dic.keys():
        dic[w[i]] = 1
    else:
        dic[w[i]] += 1
flag = True
for i in dic.keys():
    if dic[i]%2 != 0:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

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

int main() {
	int n, m;
	cin >> n >> m;
	int k[m];
	int p[m];
	vector<int> s[m];
	for (int i = 0; i < m; i++) {
		cin >> k[i];
		s[i].resize(k[i]);
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}

	int ans = 0;
	bool on[n];
	for (int i = 0; i < n; i++) {
		on[i] = false;
	}
	int sum = 0;
	bool ok = true;

	for (int i = 0; i < pow(2, n); i++) {
		ok = true;
		for (int j = 0; j < m; j++) {
			for (int l = 0; l < k[j]; l++) {
				//cout << s[j][l]-1 << "-" << on[s[j][l]-1] << ".";
				if (on[s[j][l]-1]) sum++;
			}
			//cout << sum << ", ";
			if (sum % 2 != p[j]) ok = false;
			sum = 0;
		}

		if (ok) ans++;
		//for (int j = 0; j < n; j++) {
			//cout << on[j] << " ";
		//}

		for (int j = 0; j < n; j++) {
			if (on[j] == true) {
				on[j] = false;
				break;
			}
			on[j] = true;
		}
		//cout << ok << endl;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(){

	int m;
	cin >> m;
	for(int l = 0; l < m; l++){
		int initMoney;
		cin >> initMoney;
		int year;
		cin >> year;
		int n;
		cin >> n;

		int maxMoney = 0;
		for(int i = 0; i < n; i++){
			int kind;
			double per;
			int hand;
			cin >> kind >> per >> hand;
			if(kind==1){
				int leftMoney = initMoney;
				for(int j = 0; j < year; j++){
					leftMoney = leftMoney + leftMoney*per - hand;
				}
				maxMoney = max(maxMoney,leftMoney);
			}
			else{
				int leftMoney = initMoney;
				int sumRisi = 0;
				for(int j = 0; j < year; j++){
					sumRisi += leftMoney*per;
					leftMoney -= hand;
				}
				maxMoney = max(maxMoney,sumRisi+leftMoney);
			}
		}
		cout << maxMoney << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
//#include <tuple>

using namespace std;

//constexpr long long mod = static_cast<long long>(1e9 + 7);

struct Node {
    std::array<std::unique_ptr<Node>, 2> children;
};

void insert(Node& root, const std::string& str, int depth = 0) {
    if(str.size() <= depth) return;
    int i = str[depth] - '0';
    if(!root.children[i]) root.children[i] = std::make_unique<Node>();
    insert(*root.children[i], str, depth + 1);
}

long long grundy(unsigned long long i) {
    unsigned long long pow = 1;
    unsigned long long ans = 1;
    while(pow <= i) {
        if(i % pow == 0) ans = pow;
        pow *= 2;
    }
    return ans;
}

long long solve(const Node& root, long long L, long long depth = 0) {
    long long ans = 0;
    if(root.children[0]) {
        if(!root.children[1]) ans ^= grundy(L - depth - 1);
        else ans ^= solve(*root.children[1], L, depth + 1);
        ans ^= solve(*root.children[0], L, depth + 1);
    } else {
        if(root.children[1]) {
            ans ^= grundy(L - depth - 1);
            ans ^= solve(*root.children[1], L, depth + 1);
        }
    }
    return ans;
}

int main() {
    int N;
    long long L;
    std::cin >> N >> L;
    auto root = std::make_unique<Node>();
    while(N--) {
        std::string str;
        std::cin >> str;
        insert(*root, str);
    }

    auto ans = solve(*root, L + 1);

    std::cout << (ans != 0 ? "Alice" : "Bob") << std::endl;

    return 0;
}


Measured memory_bytes: 8192
// inputに入力データ全体が入る
function Main(input) {
	var ans 
	var money = 100
	var y = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	// input = input.trim().split("\n");
	// s1 = input[0].split(' ').map((n) => (parseInt(n)))
	var m = parseInt(input)
	while ( money < m) {
		money = Math.floor(money * 1.01)
		y++
	}

	//出力
	console.log(y)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 29728
#include <iostream>
#include <cstring>

using namespace std;

char s[100],t[100];
int len,l,point;

int check(int p)
{
    for (int i=0;i<len;i++)
        if (s[i+p]=='?'||s[i+p]==t[i]) continue;else return(0);
    return(1);
}

int main()
{
    memset(s,0,sizeof(s));memset(t,0,sizeof(t));
    scanf("%s",s);scanf("%s",t);
    len=strlen(t);l=strlen(s);point=l+1;
    for (int i=0;i<l;i++)
        if (check(i)) point=i;
    for (int i=0;i<len;i++)
        s[i+point]=t[i];
    if (point==l+1) printf("UNRESTORABLE");
    else for (int i=0;i<l;i++)
            if (s[i]=='?') printf("%c",'a');
            else printf("%c",s[i]);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/abc140/tasks/abc140_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();

		System.out.println(N*N*N);
	}

}


Measured memory_bytes: 21332
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
//map<int,int> m;
//int fr[maxn][205];
//map<int,int> m;

int main(){
//	ios::sync_with_stdio(false);
	double r;
	cin>>r;
	printf("%.20lf\n",2*r*pi); 
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }
  return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




int n, k;
int a[maxn];

bool test(int x) {
    int have=k;
    for (int i=0; i<n; i++) {
	int need=(a[i]-1)/x;
	have -= need;
	if (have<0) return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    
    cin>>n>>k;
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    int lo = 0;
    int hi = 1e9 + 10;
    while (hi-lo>1) {
	int mid=(lo+hi)/2;
	if (test(mid)) {
	    hi=mid;
	} else {
	    lo=mid;
	}
    }
    cout<<hi<<endl;    
    return 0;
}


Measured memory_bytes: 4408
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    bool ans = true;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (a%2 == 0 && a%3 && a%5)
            ans = false;
    }
    cout << (ans?"APPROVED":"DENIED") << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}

use std::cmp::{min, max};
use std::num;


fn main() {
    
    let a = read::<usize>();
    let b = read::<usize>();
    let c = read::<usize>();
    
    let ans = if (a - b) > c {0} else {c - (a - b)};
    
    println!("{}",ans); 
    
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>

using namespace std;

static const int MAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1<<29);

main(){
    int n, m;
    int C[MAX + 1];
    int T[NMAX + 1];

    cin >> n >> m;

    for(int i=1; i<=m; i++){
        cin >> C[i];
    }

    for(int i=0; i<=NMAX; i++) T[i] = INFTY;
    T[0] = 0;
    for(int i=1; i<=m; i++){
        for(int j=0; j+C[i]<=n; j++){
            T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
        }
    }

    cout << T[n] << endl;

    return 0;
}


Measured memory_bytes: 3316
def calc_factors(N):
    """
    約数をlistでreturn
    この問題はK>1なので、約数に1を含めてない
    """
    i=2
    factors={N}
    while i*i<=N:
        if N%i==0:
            factors.add(i)
            factors.add(N//i)
        i+=1
    return list(sorted(factors))


N = int(input())


if N==2:
    print(1)
    exit()
#割り算しない場合
ans = len(calc_factors(N-1))
#割り算する場合
for fac in calc_factors(N):
    tmp=N
    while tmp%fac==0:
        tmp//=fac
    if tmp%fac==1:
        ans+=1
print(ans)


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

const long long mm=1000050;

struct zqz{
    long long to,next;
    long long val;
}edge[mm];

long long d[mm];
long long first[mm];
long long size=0;


void dfs(long long u,long long fa)
{
    for(long long i=first[u];i;i=edge[i].next)
    {
        long long to=edge[i].to;
        if(to==fa)
		{
			continue;
		}
        d[to]=d[u]+edge[i].val;
        dfs(to,u);
    }
}

void add(long long u,long long v,long long w)
{
    edge[++size].to=v;
    edge[size].val=w;
    edge[size].next=first[u];
    first[u]=size;
}
int main()
{
    long long n;
    cin>>n;
    for(long long i=1;i<n;i++)
    {
        long long u,v;
        long long w;
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w); 
    }
    long long s,t;
    cin>>s>>t;
    dfs(t,0);
    for(long long i=1;i<=s;i++)
    {
        long long x,y;
        cin>>x>>y;
        cout<<d[x]+d[y]<<endl;
    }
    return 0;
}

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

const int mod = 1000000007;
const int maxn = 200005;

int n, l, r;
int a[maxn], pos[maxn];
long long ans;
long long fact[maxn];

long long add_mod (long long x, long long y) {
	if (x + y < mod)
		return x + y;
	return x + y - mod;
}

long long sub_mod (long long x, long long y) {
	if (x >= y)
		return x - y;
	return x + mod - y;
}

long long mul_mod (long long x, long long y) {
	return (x * y) % mod;
}

long long pow_mod (long long x, long long y) {
	long long res = 1, t = x;
	while (y) {
		if (y & 1)
			res = mul_mod(res, t);
		t = mul_mod(t, t);
		y >>= 1;
	}
	return res;
}

long long div_mod (long long x, long long y) {
	return mul_mod(x, pow_mod(y, mod - 2));
}

long long ncr_mod (long long x, long long y) {
	if (x < y || y < 0)
		return 0LL;
	return div_mod(fact[x], mul_mod(fact[y], fact[x - y]));
}

void precalc () {
	fact[1] = fact[0] = 1LL;
	for (long long i = 2; i < maxn; ++i) 
		fact[i] = mul_mod(i, fact[i - 1]);
}

signed main () {
	precalc();
	scanf("%d", &n);
	for (int i = 1; i <= n + 1; ++i) {
		scanf("%d", &a[i]);
		if (pos[a[i]])
			l = pos[a[i]], r = i;
		pos[a[i]] = i;
	}
	for (long long k = 1; k <= n + 1; ++k) {
		ans = ncr_mod(n + 1, k);
		ans = sub_mod(ans, ncr_mod(n + l - r, k - 1));
		printf("%lld\n", ans);
	}
}


Measured memory_bytes: 6068
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    # Nが偶数の場合、完全N//2-partiteグラフ
    # Nが奇数の場合、完全(N-1)//2-partiteグラフに全ての頂点と隣接している頂点Nを加えたもの
    ans = []

    def f(n):
        for i in range(1, n // 2 + 1):
            for j in range(1, n + 1):
                if j != i and j != n + 1 - i:
                    if j < i:
                        ans.append((j, i))
                    else:
                        ans.append((i, j))
                    if j < n + 1 - i:
                        ans.append((j, n + 1 - i))
                    else:
                        ans.append((n + 1 - i, j))

    if N % 2 == 0:
        f(N)
    else:
        if N >= 5:
            f(N - 1)
        for i in range(1, N):
            ans.append((i, N))

    ans = set(ans)
    print(len(ans))
    for i, j in ans:
        print(i, j)
        
if __name__ == '__main__':
    resolve()


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

int main(){
    string s;
    cin>>s;
    int l = s.size();
    if(s[l-1]=='s')cout<<s + "es"<<endl;
    else cout<<s + 's'<<endl;
}

Measured memory_bytes: 3604
c = []
c[0], c[1], c[2], n = gets.split.map(&:to_i)
c.sort!.reverse!
res = 0
for i in 0..(n / c[0]) do
  rn = c[0] * i
  for j in 0..((n - rn) / c[1]) do
    gn = c[1] * j
    if (n - rn -gn) % c[2] == 0
      res += 1
    end
  end
end
puts res


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

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

    std::vector<int> A(n);
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int k;
        std::cin >> k;
        std::cout << (int)std::binary_search(A.begin(), A.end(), k) << std::endl;
    }
}



Measured memory_bytes: 3100
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

type Coodinate struct {
  x int
  y int
  index int
}
type Coodinates []Coodinate
func (C Coodinates) Len() int { return len(C) }
func (C Coodinates) Less(i, j int) bool { return C[i].x < C[j].x }
func (C Coodinates) Swap (i, j int) { C[i], C[j] = C[j], C[i] }
type xAxis struct {
  Coodinates
}
func (A xAxis) Less(i, j int) bool { return A.Coodinates[i].x < A.Coodinates[j].x }
type yAxis struct {
  Coodinates
}
func (A yAxis) Less(i, j int) bool { return A.Coodinates[i].y < A.Coodinates[j].y }

func Find(R *[]int, i int) int {
  if (*R)[i] == i { return i }
  (*R)[i] = Find(R, (*R)[i])
  return (*R)[i]
}
func Union(R *[]int, i, j int) {
  Ri := Find(R, i)
  Rj := Find(R, j)
  if Ri < Rj {
    (*R)[Rj] = Ri
  } else {
    (*R)[Ri] = Rj
  }
}

func main() {
  N := NextInt()
  R := make([]int, N)
  A := make([]Coodinate, N)
  for i := range A {
    XY := NextIntVec()
    R[i] = i
    A[i] = Coodinate{XY[0], XY[1], i}
  }
  sort.Sort(xAxis{A})
  for i := 1; i < N; i++ {
    if A[i - 1].x == A[i].x {
      Union(&R, A[i - 1].index, A[i].index)
    }
  }
  sort.Sort(yAxis{A})
  for i := 1; i < N; i++ {
    if A[i - 1].y == A[i].y {
      Union(&R, A[i - 1].index, A[i].index)
    }
  }
  Lattice := make([][]Coodinate, N)
  for i := range Lattice {
    Lattice[i] = make([]Coodinate, 0)
  }
  for _, a := range A {
    r := Find(&R, a.index)
    Lattice[r] = append(Lattice[r], a)
  }
  cnt := 0
  for _, L := range Lattice {
    x := 0
    y := 0
    sort.Sort(xAxis{L})
    current := 0
    for _, l := range L {
      if current < l.x {
        x++
        current = l.x
      }
    }
    sort.Sort(yAxis{L})
    current = 0
    for _, l := range L {
      if current < l.y {
        y++
        current = l.y
      }
    }
    if x > 1 && y > 1 {
      cnt += x * y - len(L)
    }
  }
  Write(cnt)
  Output()
}

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

int main()
{
	int n, d, x, ans=0, p=0, s=1;
	cin >> n >> d >> x;
	int a[n+10];
	for(int i=0; i<n; i++){
		cin >> a[i];
		while(p<d){
			p=a[i]*s+1;
			s++;
			if(p<=d) ans++;
		}
		p=0;
		s=1;
	}
	ans+=n;
	ans+=x;
	cout << ans;
    return 0;
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  int N = S.length();
  int k = 0;
  vector<string> V;

  if (N == 1) {
    return 1;
  }

  int result = 0;
  while (k + 1 < N) {
    string current = "";
    current += S[k];
    if (V.empty() || current != V.back()) {
      V.push_back(current);
      k++;
      result++;
    } else {
      current += S[k + 1];
      V.push_back(current);
      k += 2;
    }
  }

  if (k < N) {
    string current = "";
    current += S[k];
    if (V.empty() || current != V.back()) {
      V.push_back(current);
    }
  }
  cout << V.size() << endl;
  return 0;
}


Measured memory_bytes: 10996