akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	if (A + B < 10) {
		cout << A + B << endl;
	}
	else {
		cout << "error" << endl;
	}
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;

}

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

int num_divisor(int n){
    auto x = decompose(n);
    int ans=1;
    for(auto p:x) ans*=(1+p.second);
    return ans;
}

void solve(){
    input();
    int c=0;
    for(int i=1;i<=N;i++){
        if(i%2==0) continue;
        if(num_divisor(i)==8) c++;
    }
    cout << c << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1 << 28;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    int mi0 = INF, mi1 = INF;
    vector<int> a(N), w(N);
    for(int i=0; i<N; i++) cin >> a[i];
    for(int i=0; i<N; i++) {
        cin >> w[i];
        if(a[i] == 0) mi0 = min(mi0, w[i]);
        if(a[i] == 1) mi1 = min(mi1, w[i]);
    }

    if(mi0 == INF or mi1 == INF) cout << 0 << endl;
    else cout << mi0 + mi1 << endl;
    return 0;
}



Measured memory_bytes: 3116
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int dp[200][20000];
signed main(){
  int N,W;
  cin>>N>>W;
  vector<int> v(N),w(N);  
  rep(i,200)rep(j,20000)dp[i][j]=-1;
  rep(i,N){
    cin>>v[i]>>w[i];
  }
  dp[0][0]=0;
  rep(i,N)rep(j,W+1){
    if(dp[i][j]==-1)continue;
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
  }
  int ans=0;
  rep(i,W+1){
    if(ans<dp[N][i]){
      ans=dp[N][i];
    }
  }
  cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 34344
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int count = 0;
    int A, B;
    cin >> A >> B;
    FOR(i,A,B+1){
       if(i/10000 == i%10){
            if((i/1000)%10 == (i/10)%10){
                count++;
            }
        }
    }
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int X;
    cin >> X;
    if(X>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 3132
m,d = gets.split.map &:to_i
cnt = 0
(1..m).each do |mm|
  (1..d).each do |dd|
    dds= dd.to_s
    if (dds[0].to_i >= 2) && (dds[1].to_i >= 2)
      cnt += 1 if dds[0].to_i * dds[1].to_i == mm
    end
  end
end
puts cnt

Measured memory_bytes: 1788
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMaximumVolume solver = new CMaximumVolume();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMaximumVolume {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            double L = sc.nextDouble();
            BigDecimal a = BigDecimal.valueOf(L / 3);
            out.println(a.multiply(a).multiply(a).toPlainString());
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}



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

char* animals;
char* s;

int test(char first, char second, int N){
	// N : animalsの長さ
	int i;
	//はじめの２とうを仮定
	animals[0] = first; animals[1] = second;

	for(i=1; i< N+1; i++){
		if(animals[i] == 'S' && animals[i-1] == 'S'){	//羊、羊の場合
			if(s[i%N] == 'o')	//答えがoならば
				animals[i+1] = 'S';	//次も羊
			else
				animals[i+1] = 'W';
		}else if(animals[i] == 'S' && animals[i-1] == 'W'){ // 羊、狼の場合
			if(s[i%N] == 'o') //答えがoならば
				animals[i+1] = 'W'; //次は狼
			else
				animals[i+1] = 'S';
		}else if(animals[i] == 'W' && animals[i-1] == 'S'){	//狼、羊の場合
			if(s[i%N] == 'o')	//答えがoならば
				animals[i+1] = 'W';	//次は狼
			else
				animals[i+1] = 'S';	//次は羊
		}else if(animals[i] == 'W' && animals[i-1] == 'W'){
			if(s[i%N] == 'o')
				animals[i+1] = 'S';
			else
				animals[i+1] = 'W';
		}
	}

	//１周して整合性が取れていれば１
	if(animals[0] == animals[N] && animals[1] == animals[N+1]){
		return 1;
	}else{
		return 0;
	}

	return 0;
}

int main(){

	int N;
	int i;

	scanf("%d", &N);
	s = (char*)malloc(sizeof(char) * (N+2));
	animals = (char*)malloc(sizeof(char) * (N+3));
	
	scanf("%s", s);

	// 初期化
	for(i=0;i <N; i++){
		animals[i] = NULL;
	}

	if(test('S', 'S', N)){
		for(i=0; i<N; i++)
			printf("%c", animals[i]);
		printf("\n"); return 0;
	}else if(test('S', 'W', N)){
		for(i=0; i<N; i++)
			printf("%c", animals[i]);
		printf("\n"); return 0;
	}else if(test('W', 'S', N)){
		for(i=0; i<N; i++)
			printf("%c", animals[i]);
		printf("\n"); return 0;
	}else if(test('W', 'W', N)){
		for(i=0; i<N; i++)
			printf("%c", animals[i]);
		printf("\n"); return 0;
	}else{
		printf("-1\n");
	}

	return 0;

}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;
int main()
{
	int x;
	cin>>x;
	if(x>=30) cout<<"Yes"<<endl;
	  else cout<<"No"<<endl; 
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int d,g; cin>>d>>g;
	vector<int>p(d),c(d);
	for(int i=0;i<d;++i){
		cin>>p.at(i)>>c.at(i);
	}
	int ans=1e9;
	for(int i=0;i<(1<<d);++i){
		vector<bool>v(d,false);
		int sum=0,tans=0;
		for(int j=0;j<d;++j){
			if(i&(1<<j)){
				sum+=(j+1)*100*p.at(j)+c.at(j);
				tans+=p.at(j);
				v.at(j)=true;
			}
		}
		if(sum<g){
			int mx=d-1;
			while(mx>=0&&v.at(mx))--mx;
			int rem=0;
			if(mx>=0)rem=p.at(mx);
			while(rem&&sum<g)sum+=(mx+1)*100,--rem,++tans;
		}
		if(sum>=g)ans=min(ans,tans);
	}
	cout<<ans<<"\n"s;
}

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

int rev( int x ){

 int res = 0  ;

 while(x){

    int md = x%10 ;
    x /= 10 ;
    res = res * 10  + md ;

 }

 return res ;

}


int main(){
   //freopen("coloring.in", "r", stdin);

   cin >> a >> b ;
   int cnt = 0 ;
  for(int i =a ; i <=  b ; i++  ){

    if( rev(i) == i  )
        cnt++ ;

  }

  cout << cnt ;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    int ans = 0;
    string S; cin >> S;
    rep(l, N) {
        string s = S.substr(l, S.size());
        vector<int> Z(N - l);
        Z[0] = N - l;
        int i = 1, j = 0;
        while(i < s.size()) {
            while(i + j < N && j < s.size() && s[j] == s[i + j]) ++j;
            Z[i] = j;
            if(j == 0) {
                ++i;
                continue;
            }
            int k = 1;
            while(k < j && k + Z[k] < j) {
                Z[i + k] = Z[k];
                ++k;
            }
            i += k;
            j -= k;
        }
        rep(k, N - l) {
            if(Z[k] <= k) {
                ans = max(ans, Z[k]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

s = input()
if s == 'RRR':
    print(3)
    exit()
elif s == 'RRS' or s == 'SRR':
    print(2)
    exit()
elif s == 'RSR' or s == 'SRS' or s == 'RSS' or s == 'SSR':
    print(1)
    exit()
else:
    print(0)
    exit()



Measured memory_bytes: 8964
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int m,n;
    scanf("%d%d",&m,&n);
    int mx = 0;
    for(int i = 0; i < m; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            int a;
            scanf("%d",&a);
            sum += a;
        }
        mx = max(mx,sum);
    }
    printf("%d\n",mx);
    return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
  using namespace std;
  #define LL long long

  int main() {
  LL A,B,C,D,E;
  cin>>A>>B>>C>>D>>E;
  if(A==0){
    cout<<"1"<<endl;
  }
  if(B==0){
    cout<<"2"<<endl;
  }
  if(C==0){
    cout<<"3"<<endl;
  }
  if(D==0){
    cout<<"4"<<endl;
  }
  if(E==0){
    cout<<"5"<<endl;
  }
}
/*LL X,Y;
cin>>X>>Y;
if(X*4>=Y&&(Y+1)/2==Y/2&&X*2<=Y){
  cout<<"Yes"<<endl;
}
else{
  cout<<"NO"<<endl;
}
}*/


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

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

  vector<int> L(N);

  for (int i = 0; i < N; i++)
  {
    cin >> L.at(i);
  }

  int D = 0;
  int j = 0;
  do
  {
    D += L.at(j);
    j++;
  } while (D <= X && j < N);
  
  // 入力を使い果たしてもまだXより左にいる時、1回足す
  if (j >= N && D <= X) j++;

  cout << j << endl;
}


Measured memory_bytes: 256
import bisect

n, m = map(int, input().split())

ab=[]
for i in range(n):
    ab.append(list(map(int, input().split())))

ab = sorted(ab, key=lambda x: x[0])

def func():
    c=0
    ans=0

    for target in ab:
        for i in range(target[1]):
            ans+=target[0]
            c+=1

            if c == m:
                return ans
            

print(func())


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

const int MOD = 1e9+7;

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

	int s, w; cin >> s >> w;
	if(w >= s) cout << "unsafe\n";
	else cout << "safe\n";

 	return 0;
}

Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	ll n, k;
	ll *A,*B;
	ll count;
	ll answer;
	cin >> n >> k;
	A = new ll[n+1];
	B = new ll[200000];
	for (ll i =0; i <= n; i++) {
		B[i]=0;
	}

	for (ll i = 0; i < n; i++) {
		cin >> A[i];
		B[A[i]]++;
	}

	sort(B+1, B + n+1);
	count = 0;
	answer = 0;
	for (ll i = 1; i <= n; i++) {
		if (B[i]) count++;
	}
	ll pos = 1;
	while (count > k) {
		while (B[pos] == 0) {
			pos++;
		}
		answer += B[pos];
		pos++;
		count--;
	}
	cout << answer;

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
using namespace std;
 
constexpr int max_n = 1e5 + 5;
 
vector<pair<int, int> > graf[max_n];
long long wynik, zliczanie[5];
int odwiedzony[max_n];
 
void bfs(int x){
    bool crush = false, cykl = true;
    zliczanie[1] = 1;
    zliczanie[2] = 0;
    zliczanie[0] = 0;
    odwiedzony[x] = 1;
    vector<int> kolejka;
    kolejka.push_back(x);
    for (unsigned int i = 0; i < kolejka.size(); i++){
        if (graf[kolejka[i]].size() != 2)
            cykl = false;
        for (pair<int, int> j : graf[kolejka[i]]){
            int pom = odwiedzony[kolejka[i]] + j.second;
            if (pom <= 0)
                pom += 3;
            if (!odwiedzony[j.first]){
                odwiedzony[j.first] = pom;
                zliczanie[pom % 3]++;
                kolejka.push_back(j.first);
            }
            else if (odwiedzony[j.first] % 3 !=  pom %  3){
                crush = true;
            }
        }
    }
    if (crush){
        wynik += (zliczanie[0] + zliczanie[1] + zliczanie[2]) * (zliczanie[0] + zliczanie[1] + zliczanie[2]);
    }
    else{
        if (!zliczanie[0] || !zliczanie[1] || !zliczanie[2]){
            wynik += zliczanie[0] + zliczanie[1] + zliczanie[2] - 1;
            if (cykl)
                wynik++;
        }
        else
            wynik += zliczanie[0] * zliczanie[1] + zliczanie[1] * zliczanie[2] + zliczanie[2] * zliczanie[0];
    }
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, a, b;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> a >> b;
        graf[a].emplace_back(b, 1);
        graf[b].emplace_back(a, -1);
    }
    for (int i = 1; i <= n; i++){
        if (!odwiedzony[i])
            bfs(i);
    }
    cout << wynik << "\n";
    return 0;
}

Measured memory_bytes: 7796
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ll INF = ll(1e9)+10;

ll add(ll a, ll b)
{
	a+=b;
	if(a>INF) a=INF;
	return a;
}

ll mult(ll a, ll b)
{
	if(a==0||b==0) return 0;
	if(a>INF/b) return INF;
	return min(a*b,INF);
}

vector<ll> a[1011];
const int LG = 32;
const int N = 50111;
ll c[N+10][LG+2];

ll choose(ll a, ll b)
{
	if(b==0) return 1;
	if(b==1) return a;
	if(b==2) 
	{
		if(a%2==0) return mult(a/2,a-1);
		else return mult(a,(a-1)/2);
	}
	if(a<b) return 0;
	if(b>a-b) return choose(a,a-b);
	if(a<=N&&b<=LG) return c[a][b];
	return INF;
}

void f(vector<ll> &v)
{
	for(int i=1;i<v.size();i++)
	{
		v[i]=add(v[i],v[i-1]);
	}
}

ll fele(vector<ll> &v, ll t, int pos)
{
	ll ans = 0;
	for(int i=0;i<=pos;i++)
	{
		ans = add(ans, mult(choose(t+pos-1-i,pos-i),v[i]));
	}
	return ans;
}

bool lexilarge(vector<ll> &a, vector<ll> &b)
{
	for(int i=0;i<a.size();i++)
	{
		if(a[i]>b[i]) return true;
		if(a[i]<b[i]) return false;
	}
	return false;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			ll x; cin>>x; a[i].pb(x);
		}
	}
	for(int i=0;i<=N;i++) c[i][0]=1;
	for(int i=0;i<=N;i++)
	{
		for(int j=1;j<=LG;j++)
		{
			if(i<j) continue;
			c[i][j]=add(c[i-1][j],c[i-1][j-1]);
		}
	}
	ll ans = 0; ll las = 0;
	for(int i=1;i<n;i++)
	{
		vector<ll> pre = a[i-1];
		vector<ll> cur = a[i];
		if(pre[0]!=cur[0])
		{
			if(pre[0]>cur[0]){cout<<-1<<'\n'; return 0;}
			las=0; continue;
		}
		if(m==1)
		{
			cout<<-1<<'\n'; return 0;
		}
		ll A = pre[1]+las*pre[0];
		ll diff = (A-cur[1]>=0?(A-cur[1]+cur[0]-1)/cur[0]:0LL);
		//do it diff times or diff+1 times?
		bool pos=0;
		if(diff>=las)
		{
			ll k = diff-las;
			if(k<=LG)
			{
				for(int z=0;z<k;z++) f(cur);
				if(lexilarge(cur,pre)) pos=1;
			}
			else
			{
				int ex=0;
				for(int z=0;z<min(n,LG);z++)
				{
					ll tmp = fele(cur,k,z);
					if(tmp!=pre[z])
					{
						ex=1;
						if(tmp>pre[z]){pos=1;}
						break;
					}
				}
				if(!ex&&n>LG) pos=1;
			}
		}
		else
		{
			ll k = las-diff;
			if(k<=LG)
			{
				for(int z=0;z<k;z++) f(pre);
				if(lexilarge(cur,pre)) pos=1;
			}
			else
			{
				pos=1;
				int ex=0;
				for(int z=0;z<min(n,LG);z++)
				{
					ll tmp = fele(pre,k,z);
					if(tmp!=cur[z])
					{
						ex=1;
						if(cur[z]<tmp){pos=0;}
						break;
					}
				}
				if(!ex&&n>LG) pos=0;
			}
		}
		if(!pos) diff++;
		ans+=diff; las=diff;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 21632
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N;
string S;

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

    map<pair<string, string>, LL> left_mp;
    {
        REP(i, (1 << N)) {
            string red = "", blue = "";
            REP(j, N) {
                if (i & (1 << j)) {
                    red = red + S[j];
                } else {
                    blue = S[j] + blue;
                }
            }
            left_mp[MP(red, blue)]++;
        }
    }

    map<pair<string, string>, LL> right_mp;
    {
        REP(i, (1 << N)) {
            string red = "", blue = "";
            REP(j, N) {
                if (i & (1 << j)) {
                    red = red + S[N + j];
                } else {
                    blue = S[N + j] + blue;
                }
            }
            right_mp[MP(red, blue)]++;
        }
    }

    LL ans = 0;
    FORE(e, left_mp) {
        ans += e.second * right_mp[MP(e.first.second, e.first.first)];
    }
    cout << ans << endl;
}


Measured memory_bytes: 101376
import math
from decimal import *
mod = 10 ** 9 + 7


N = int(input())

sosuu = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
for i in range(2, N+1):
    if i % 2 == 0 or i % 3 == 0 or i == 5 or i % 7 == 0 or i % 11 == 0 or i%13 == 0 or i%17 == 0\
            or i%19 == 0 or i%23 == 0 or i%29 == 0 or i%31 == 0 or i%37 == 0:
        continue
    for j in range(2,i+1):
        if j == i:
            sosuu.append(i)
        if i % j == 0:
            break

soinsuu_num = [0 for i in range(len(sosuu))]

for i in range(1, N+1):
    if i == 1:
        continue
    temp = i
    for j in range(len(sosuu)):
        while temp % sosuu[j] == 0 and temp != 1:
            soinsuu_num[j] += 1
            temp = Decimal(temp) / Decimal(sosuu[j])
        if temp == 1:
            break

ans = 1
for i in soinsuu_num:
    if i != 0:
        ans = ans * (i + 1) % mod

print(ans)

Measured memory_bytes: 5076
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
ll X[1005], Y[1005], Z[1005], now[1005], ans[8];

int main(){
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++){
    scanf("%lld%lld%lld", X+i, Y+i, Z+i);
  }

  for (int i = 0; i < 8; i++){
    for (int j = 0; j < N; j++){
      now[j] = pow(-1, i) * X[j];
      now[j] += pow(-1, i/2) * Y[j];
      now[j] += pow(-1, i/4) * Z[j];
    }
    sort(now, now + N, greater<ll>());

    for (int j = 0; j < M; j++){
      ans[i] += now[j];
    }
  }
  sort(ans, ans + 8, greater<ll>());
  printf("%lld\n", ans[0]);

  return 0;
}


Measured memory_bytes: 4048
package main

import (
	"fmt"
	"math"
)

func main() {
	// // Problem A
	// // input
	// var tmp string
	// fmt.Scan(&tmp)

	// // configuration
	// count := 0
	// ans := 0

	// // check
	// for i := 0; i < len(tmp); i++ {
	// 	if string(tmp[i]) == "R" {
	// 		count++
	// 		ans = count
	// 	} else {
	// 		ans = max(ans, count)
	// 		count = 0
	// 	}
	// }

	// // output
	// fmt.Println(ans)

	// Problem B Making Triangle
	// input
	var n int
	var nums []int
	fmt.Scan(&n)
	nums = scanNums(n)

	// Process
	if n < 3 {
		fmt.Println(0)
	} else {
		var L1 int
		var L2 int
		var L3 int
		var count int
		for i := 0; i < (n - 2); i++ {
			for j := i + 1; j < (n - 1); j++ {
				for k := j + 1; k < n; k++ {
					L1 = nums[i]
					L2 = nums[j]
					L3 = nums[k]
					if isOk(L1, L2, L3) == true {
						count++
					}
				}
			}
		}
		fmt.Println(count)
	}
}

func isOk(n1 int, n2 int, n3 int) (ok bool) {
	return ((n1+n2 > n3 && n1+n3 > n2 && n2+n3 > n1) && (n1 != n2 && n2 != n3 && n3 != n1))
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int A,B,C,K; cin >> A >> B >> C >> K;
	int ans =0;
	for(int i=0;i<=K;i++){
		for(int j=0;i+j<=K;j++){
			int cnt = A*pow(2,i)+B*pow(2,j)+C*pow(2,K-i-j);
			ans=max(ans,cnt);
		}
	}
	cout << ans << endl;
}

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

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

    if(a>b){
        d = a;
        a = b;
        b = d;
    }
    if(a>c){
        d=a;
        a=c;
        c=d;
    }
    if(b>c){
        d=b;
        b=c;
        c=d;
    }

    cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    char o[60], e[60];
    cin >> o;
    cin >> e;
    imfor(i, strlen(o)) {
        cout << o[i];
        if (e[i] != 0) {
            cout << e[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
m = [0] * n
m[0] = h[0]
for i in range(n - 1):
    m[i + 1] = max(m[i], h[i + 1])
ans = 0
for hi, mi in zip(h, m):
    if hi == mi:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0;
  cin >> N;
  string X = "";
  string s[N];
  int hozon = 0;
  int cnt = 0;
  int t[N];
   for(int i = 0;i < N;i++){
    cin >> s[i] >> t[i];
  }
  cin >> X;
  for(int i = 0;i < N;i++){
    if(s[i] == X){
      hozon = i;
    }
  }
  for(int i = hozon + 1;i < N;i++){
    cnt = cnt + t[i];
  }
  cout << cnt << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<vector<int>> lr(2);
  for(int i=0;i<2*n;i++)lr[(s[i]=='W')^(i%2)].push_back(i);
  if(lr[0].size()!=lr[1].size()) cout << 0 << endl;
  else{
    ll ans=1;
    reverse(lr[0].begin(),lr[0].end());
    auto itr=lr[1].end();
    for(int i=0;i<n;i++){
      itr=lower_bound(lr[1].begin(),itr,lr[0][i]);
      ans*=(lr[1].end()-itr)-i;
      ans%=MOD;
      ans*=(i+1);
      ans%=MOD;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 4600
#include<iostream>
#include<cmath>
int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		double xa, ya, ra, xb, yb, rb;
		std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double d = hypot(xa - xb, ya - yb);
		if (d < std::abs(ra - rb))
		{
			std::cout << 2 * (ra < rb ? -1 : 1) << std::endl;
		}
		else if (d <= ra + rb)
		{
			std::cout << 1 << std::endl;
		}
		else
		{
			std::cout << 0 << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
using System;

class MainClass {
    static void Main() {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);

        int d = b - a;
        int hwest = 0;
        for (int i = 1; i < d; i++) {
            hwest += i;
        }
        Console.WriteLine(hwest - a);
    }
}

Measured memory_bytes: 11092
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]

N = int(input())
divsN = make_divisors(N)
divsN2 = make_divisors(N-1)
divsN.pop(0)

ans = len(divsN2)-1

for div in divsN:
    n = N
    while True:
        if n%div != 0 or n==1:
            break
        n //= div
    if n%div == 1:
        ans += 1

print(ans)


Measured memory_bytes: 9152
import sys
sys.setrecursionlimit(10**5)

N,M = map(int, input().split())
edges = [[] for i in range(N)]
while M:
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    M -= 1

dp = [-1] * N
def dist(vertex):
    if dp[vertex] != -1:
        return dp[vertex]
    
    res = 0
    for to in edges[vertex]:
        res = max(res, dist(to) + 1)
    
    dp[vertex] = res
    return  res

ans = 0
for i in range(N):
    ans = max(ans, dist(i))
print(ans)

Measured memory_bytes: 59032
#include <iostream>
using namespace std;
int main(void)
{
	double x[4],y[4];
	while(cin >> x[0] >> y[0]){
		for(int i=1; i<4; i++){
			cin >> x[i] >> y[i];
		}
		if( (x[1]-x[0])*(x[3]-x[2])+(y[3]-y[2])*(y[1]-y[0]) == 0 ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val n = new BufferedReader(new InputStreamReader(System.in)).readLine().toInt
    System.out.println(
      if (n % 2 == 0) {
        1.0 * n / 2 / n
      } else {
        1.0 * (n / 2 + 1) / n
      }
    )
  }
}


Measured memory_bytes: 27216
ans = 'Yes'
h,w = map (int,input().split())
pict = []
for i in range (h) :
      dot = input() + '.'
      
      pict.append(dot)
up = '.' * w
pict.append(up)
left = '.'
for i in range(h) :
      line = tuple (pict[i])
      for d in range(w) :
            if line[d] == '#' :
                  if left == '.' and up[d] == '.' and line[d+1] == '.' and pict[i+1][d] == '.' :
                        ans = 'No'
                        break
            left = line[d]
      up = pict[i]
print(ans)

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

using namespace std ;



int main(){
	priority_queue<int> q;
	string s;
	int n;
	while(cin>>s){
		if(s=="end") break;
		if(s =="insert"){
			cin>>n;
			q.push(n);
		}
		else{
			cout<<q.top()<<endl;
			q.pop();
		}
	}
}


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

const int maxn=1e5+10;
int n,a[maxn],ans;
char s[maxn];

int main(){
	cin>>s;
	n=strlen(s);
	a[0]=s[0]-'0';
	for(int i=0;s[i+1];++i)
		a[i+1]=s[i]!=s[i+1];
	a[n]=s[n-1]-'0';
	ans=n;
	for(int i=0;i<=n;++i)
		if(a[i])
			ans=min(ans,max(n-i,i));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	while (1) {
		string str[100], str2[100];
		long long int n, maxboin = 0,minboin=99999, mmm = 0;
		cin >> n;
		if (n == 0) { return 0; }
		for (int i = 0; i < n; i++) {
			cin >> str[i];
			long long int tmp = 1;
			str2[i].push_back(str[i][0]);
			for (int j = 1; j < str[i].length(); j++) {
				if (str[i][j - 1] == 'a' || str[i][j - 1] == 'i' || str[i][j - 1] == 'u' || str[i][j - 1] == 'e' || str[i][j - 1] == 'o') {
					tmp++;
					str2[i].push_back(str[i][j]);
				}
			}
			maxboin = max(tmp, maxboin);
		}


		string code_name[60];

		for (int k = 1; k <= maxboin; k++) {
			for (int i = 0; i < n; i++) {
				code_name[i]=str2[i].substr(0,min(k,(int)str2[i].length()));
			}
			for (int i = 0; i < n; i++) {
				for (int j = i+1; j < n; j++) {
					if (code_name[i] == code_name[j]) {
						goto next;
					}
				}
			}
			cout << k << endl;
			break;
		next:
			if (k == maxboin) { cout << -1 << endl; }
			mmm++;
		}
	}
}


Measured memory_bytes: 3228
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

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


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;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int mi = 0, ma = 0;
    int tot = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') {
            ++tot;
        }
    }
    int a = tot - 1;
    int b = tot + 1;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') {
            if (a > 0) {
                mi += powerm(2, n - 1 - i, a);
                mi %= a;
            }
            ma += powerm(2, n - 1 - i, b);
            ma %= b;
        }
    }
    //return 0;
    int maf = ma;
    int mif = mi;
    for (int i = 0; i < n; ++i) {
        int tot = 0;
        ma = maf;
        mi = mif;
        if (s[i] == '0') {
            ma += powerm(2, n - 1 - i, b);
            ma %= b;
            ++tot;
            int p = ma;
            while (p > 0) {
                int f = __builtin_popcount(p);
                p %= f;
                ++tot;
            }
            cout << tot << '\n';
        }
        else {
            if (a <= 0) {
                cout << 0 << '\n';
                continue;
            }
            mi -= powerm(2, n - 1 - i, a);
            mi += a;
            mi %= a;
            ++tot;
            int p = mi;
            while (p > 0) {
                int f = __builtin_popcount(p);
                p %= f;
                ++tot;
            }
            cout << tot << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    string str[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string S;
    cin >> S;
    for(int i = 0; i < 7; i++){
        if(str[i] == S){
            cout << 7 - i << endl;
        }
    }
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

//constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	vector<string> s(n);
	rep(i, n) cin >> s[i];

	ll cnt = 0;
	unordered_map<string, int> mapList;

	rep(i, n) {
		sort(ASC(s[i]));
		mapList[s[i]]++;
		cnt += mapList[s[i]] - 1;
	}


	ANS(cnt);
}

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

int main() {
	string s;
	cin >> s;
	
	sort(s.begin(), s.end());
	if (s.at(0) == s.at(1) && s.at(1) != s.at(2) && s.at(2) == s.at(3)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
d = list(map(int, input().split()))

sum = 0
for i in range(N) :
  for j in range(i+1, N) :
    sum += d[i] * d[j]

print (sum)

Measured memory_bytes: 38512
from collections import deque

H, W = [int(a) for a in input().split()]
Ch, Cw = [int(a)-1 for a in input().split()]
Dh, Dw = [int(a)-1 for a in input().split()]

S = []
dist = []

for _ in range(H):
    S.append([a for a in input()])
    dist.append([-1 for _ in range(len(S[-1]))])

dist[Ch][Cw] = 0
q = deque()
q.append((Ch, Cw))
cost = 0

def p_dist():
    print('---')
    for row in dist:
        print(row)

while q:
    jump_list = []
    while q:
        v = q.popleft()
        jump_list.append(v)
        # print('n', v)
        for i in [v[0]-1, v[0]+1]:
            j = v[1]
            if i >= 0 and j >= 0 and i < H and j < W and S[i][j]=='.' and dist[i][j] == -1:
                dist[i][j] = cost
                q.append((i, j))
        for j in [v[1]-1, v[1]+1]:
            i = v[0]
            if i >= 0 and j >= 0 and i < H and j < W and S[i][j]=='.' and dist[i][j] == -1:
                dist[i][j] = cost
                q.append((i, j))

    cost += 1
    for v in jump_list:
        # print('j', v)
        for i in range(v[0]-2, v[0]+3):
            for j in range(v[1]-2, v[1]+3):
                if ((i == v[0] + 1) or (i == v[0] -1)) and j == v[1]:
                    pass
                elif ((j == v[1] + 1) or (j == v[1] -1)) and i == v[0]:
                    pass
                elif i == v[0] and j == v[1]:
                    pass
                elif i >= 0 and j >= 0 and i < H and j < W and S[i][j]=='.' and dist[i][j] == -1:
                    # print(i, j, dist[i][j])
                    dist[i][j] = cost
                    q.append((i, j))

# p_dist()
print(dist[Dh][Dw])

Measured memory_bytes: 135496
n,m = map(int,input().split())
people = [list(map(int,input().split())) for _ in range(n)]

matrix = [[ False for _ in range(n)] for _ in range(m)]
#横が人，縦がしなもの


for person_id in range(n):
    person = people[person_id]
    for konomi_num in person[1:]:
        matrix[konomi_num-1][person_id] = True
ans = 0
for food in range(m):
    if all(matrix[food]):
        ans += 1
print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define f first
//#define s second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (ll)2e5+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
 
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){	
	fast;
	int n,w;
	cin >> n >> w;
	vector<vector<ll>> dp(n+1,vector<ll> (w+1,0));
	for(int i=1;i<=n;i++ ){
		ll weight,value;
		cin >> weight >> value;
		dp[i] = dp[i-1];
		for(int j = 0;j<w;j++){
			if(j+weight <= w){
				dp[i][j+weight] = max(dp[i-1][j+weight],dp[i-1][j]+value);
			}
		}
	}
	
	/*for(int i = 1 ;i<=n;i++){
		for(int j = 0; j<=w;j++){
			cout<<dp[i][j]<<" ";
		}
		newline;
	}*/
	
	cout<<*max_element(all(dp[n]));
	
	return 0;
}

	


Measured memory_bytes: 80256
#include <cstdio>

int main()
{
	long long n; scanf("%lld",&n);
	if(n%2==1) printf("0");
	else
	{
		long long sum=0;
		while(n>0)
		{
			sum+=(n/5)/2; n/=5;
		}
		printf("%lld",sum);
	}
	return 0;
}

Measured memory_bytes: 128
n, x, y = map(int, input().split())

edges = [[] for _ in range(n)]
for i in range(n-1):
    edges[i].append((i+1, 1))
    edges[i+1].append((i, 1))
edges[x-1].append((y-1, 1))
edges[y-1].append((x-1, 1))

import heapq

def dijkstra(start, edge, n):

    dist = [float('inf')] * n
    dist[start] = 0

    pq = [(dist[start], start)]

    while len(pq):
        d, frm = heapq.heappop(pq)
        if dist[frm] < d:
            continue
        for to, cost in edge[frm]:
            if dist[frm] + cost < dist[to]:
                dist[to] = dist[frm] + cost
                heapq.heappush(pq, (dist[to], to))

    return dist

cnt = [0] * n

for i in range(n):
    dist = dijkstra(i, edges, n)
    for d in dist:
        cnt[d] += 1

ans = []
for c in cnt:
    c //= 2
    ans.append(c)

for i in range(1, n):
    print(ans[i])


Measured memory_bytes: 91612
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int k, a, b; cin >> k >> a >> b;
	if (b-a <= 1)cout << k + 1 << endl;
	else {
		int ans = 1, z = k;
		if (ans < a) {
			z -= a - ans;
			ans = a;
		}
		if (z % 2) {
			z--; ans++;
		}
		z /= 2; ans += z * (b - a);
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
bi = [int(i) for i in input().split()]

ans = []

for i in range(n):
    for j in range(len(bi)):
        if bi[len(bi)-1-j] == len(bi)-1-j+1:
            ans.append(len(bi)-1-j+1)
            del bi[len(bi)-1-j]
            break

if len(ans) != n:
    print(-1)
else:
    for i in range(n):
        print(ans[n-1-i])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  if(a + b < 10)
    out(a + b);
  else
    out("error");
  memi;
}

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

int main(int argc, char const *argv[])
{
    int n,l;cin>>n>>l;
    int min_l =1000;
    int ret;
    int sum =0;
    for(int i=1;i<=n;i++){
        int aji = l+i-1;
        sum+=aji;
        if(abs(aji)<min_l){
            min_l = abs(aji);
            ret = aji;
        }
    }
    // cout << min_l << endl;
    cout << sum - ret << endl;
    return 0;
}


Measured memory_bytes: 256