akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define inf 1e9+1
using namespace std;

int N,W;
int maxVal = 0;

int knapsack(vector<int> w, vector<int> v){
    vector<vector<long long> > dp(N+1, vector<long long>(maxVal+1,inf));
    for(int i=0;i<=N;i++)
        dp[i][0] = 0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=maxVal;j++){
            dp[i][j] = dp[i-1][j];
            if(j-v[i]>=0)
                if(w[i]+dp[i-1][j-v[i]]<=W)
                    dp[i][j] = min(dp[i][j], w[i]+dp[i-1][j-v[i]]);
        }
    }
    int i;
    for(i=maxVal;i>=0;i--){
        if(dp[N][i]!=inf)
            break;
    }
    return i;
}

int main(){
    cin>>N>>W;
    vector<int> w(N+1,0), v(N+1,0);
    for(int i=1;i<=N;i++){
        cin>>w[i]>>v[i];
        maxVal += v[i];
    }
    cout<<knapsack(w,v)<<endl;
    return 0;
}


Measured memory_bytes: 83076
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, S: str):
    if len(S) != A + B + 1:
        print(NO)
        return
    an = S[0:A]
    h = S[A]
    bn = S[A+1:]
    if not an.isdecimal():
        print(NO)
        return
    if h != "-":
        print(NO)
        return
    if not bn.isdecimal():
        print(NO)
        return
    print(YES)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(A, B, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61980
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int main() {
    int N;
    cin >> N;
    cout << N << ":";
    for(int i = 2;i * i <= N;i++){
        while(N % i == 0){
            cout << " " << i;
            N /= i;
        }
    }
    if(N != 1){
        cout << " " << N;
    }
    cout << endl;
}



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

int main(){
    long long X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    priority_queue <long long, vector<long long>, greater<long long> > P,Q;
    priority_queue <long long> R;
    long long p,q,r;
    for(long long i=0; i<A; i++){
        cin >> p;
        P.push(p);
    }
    for(long long i=0; i<B; i++){
        cin >> q;
        Q.push(q);
    }
    for(long long i=0; i<C; i++){
        cin >> r;
        R.push(r);
    }

    for(long long i=1; i<=A-X; i++){
        P.pop();
    }
    for(long long i=1; i<=B-Y; i++){
        Q.pop();
    }

    for(long long i=0; i<C; i++){
        long long aplus = R.top()-P.top();
        long long bplus = R.top()-Q.top();
        if( aplus > bplus && aplus > 0 ){ // add r to p
            P.pop();
            P.push(R.top());
            R.pop();
        }else if( bplus > aplus && bplus > 0 ){ // add r to q
            Q.pop();
            Q.push(R.top());
            R.pop();
        }else if(aplus == bplus && aplus > 0){
            P.pop();
            P.push(R.top());
            R.pop();            
        }

        if(aplus <= 0 && bplus <= 0){
            break;
        }
    }

    long long ans=0;

    while( !P.empty() ){
        ans += P.top();
        P.pop();
        //cout << "P " << ans << endl;
    }

    while( !Q.empty() ){
        ans += Q.top();
        Q.pop();
        //cout << "Q " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?middle:'\n'));
}
void array_show(LL *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?middle:'\n'));
}

vector<int> v1;
int t[105];

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	bool s=true;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	for(i=0;i<n;i++){
		if(v1[i]>i+1)s=false;
	}
	if(!s){
		cout<<-1<<endl;
		return 0;
	}
	for(i=0;i<n;i++){
		for(j=v1.size()-1;j>=0;j--){
			if(v1[j]==j+1)break;
		}
		t[n-i-1]=j+1;
		v1.erase(v1.begin()+j);
	}
	array_show(t,n,'\n');
}


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

int main() {

int n;
cin >> n;
vector <int> h(n);
vector <int> dp(n,1e9);
rep(i,n)
{cin >> h.at(i);}

dp[0]=0;
dp[1]=abs(h[1]-h[0]);
for (size_t i = 2; i <n; i++)
{ 
  int prev, prev2;
  prev =abs( h[i]-h[i-1] ) + dp[i-1];
  prev2=abs( h[i]-h[i-2] ) + dp[i-2];
  dp[i]=min(prev,prev2);
  
}


cout << dp.at(n-1) << endl;


}


Measured memory_bytes: 1024
import sys
n=int(input())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
maxmatch=n*(n-1)
day=0
q=[i for i in range(n)]
nq=[]
match=[0]*(n+1)
check=[0]*(n+1)
while q:
  day+=1
  for i in q:
    if match[i]==n-1 or check[i]==day:
      continue
    else:
      vs=a[i][match[i]]-1
      if check[vs]!=day and a[vs][match[vs]]-1==i:
        match[i]+=1
        match[vs]+=1
        match[n]+=2
        check[i]=day
        check[vs]=day
        check[n]=day
        nq.append(i)
        nq.append(vs)
      
    if i==q[-1]:
      if check[n]!=day:
        print(-1)
        sys.exit()
  if match[n]==maxmatch:
    break
  q=nq[:]
  nq=[]
        
print(day)


Measured memory_bytes: 35064
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main(){
    string s;
    cin >> s;
    string dream,dreamer,erase,eraser;
    dream = "maerd";
    dreamer = "remaerd";
    erase = "esare";
    eraser = "resare";
    bool can = true;
    vector<string> divide{dream,dreamer,erase,eraser};
    reverse(s.begin(),s.end());
    for(int i = 0; i < s.size();){
        bool can2 = false;
        for(int j = 0; j < 4; j++){
            string d = divide.at(j);
            if(s.substr(i,d.size()) == d){
                can2 =true;
                i += d.size();
            } 
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3756
n,a,b,c = map(int,input().split())
l = []
for i in range(n):
  l.append(int(input()))

b4 = ["0"]*(4**n)
def B4(X):
  if X == "0":
    return "0"
  elif b4[X] != "0":
    return b4[X]
  if (int(X/4)):
    b4[X] = B4(int(X/4))+str(X%4)
    return B4(int(X/4))+str(X%4)
  else:
    b4[X] = str(X%4)
  return str(X%4)
def f(x):
  return [int(j) for j in ["0"]*(n-len(list(x)))+list(x)]

m = float('inf')
for i in range(4**n):
  t = f(B4(i))
  cost = 0
  for j in range(3):
    cost += 10*(max(t.count(j)-1,0))
  length = [0,0,0,0]
  for j in range(n):
    length[t[j]] += l[j]
  if min(length[0:3]) == 0:
    continue
  cost += abs(a-length[0])+abs(b-length[1])+abs(c-length[2])
  #print(t)
  #print(cost)
  m = min(m,cost)
print(m)

Measured memory_bytes: 7608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll N,T;
ll t[200005];
int main() {
  cin >> N >> T;
  for(ll i=0;i<N;i++) cin >> t[i];
  ll rt = T;
  for(ll i=1;i<N;i++) rt += min(T,t[i]-t[i-1]);
  cout << rt << endl;
  return 0;
}


Measured memory_bytes: 1792
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	k := getNextInt(scanner)

	fmt.Fprintln(writer, (k>>1)*(k>>1+k%2))

	writer.Flush()
}


Measured memory_bytes: 640
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  n <- readLn
  putStrLn $ solve n

solve n
  | n == 25 = "Christmas" 
  | n == 24 = "Christmas Eve"
  | n == 23 = "Christmas Eve Eve" 
  | n == 22 =  "Christmas Eve Eve Eve" 


Measured memory_bytes: 508
#include<stdio.h>
#include<string.h>
int main()
{
  char s[20];  
    gets(s);
if(strcmp(s,"ABC")==0)    
  printf("ARC\n"); 
  else if(strcmp(s,"ARC")==0)
 printf("ABC\n");  
   return 0; 
}

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

const int MAXN = 200005;

int a[MAXN], n;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (a[i] >= i) {
			puts("-1");
			return 0;
		}
		if (i > 1 && a[i]-a[i-1] > 1) {
			puts("-1");
			return 0;
		}
	}
	long long ans = 0;
	for (int i = n; i >= 1; i--) {
		ans += a[i];
		while (i > 1 && a[i] == a[i-1]+1) i--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;
 
template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    
 
    bool operator!() const{return !x;}
 
    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }
 
    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }
 
    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }
 
    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }
 
    modint operator-() const{ return modint(-x); }
 
    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }
 
 
    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }
 
    modint inv() const{
        ll a = x,b = MOD,u = 1,v = 0;
        while(b){
            ll t = a/b;
            a -= t*b; swap(a,b);
            u -= t*v; swap(u,v);
        }
        u %= MOD;
        if(u < 0) u += MOD;
        return modint(u);
    }
 
    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }
 
    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

 

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    mint ans = 2;
    mint comb_a = 1,comb_b = 1;


    rep(i,0,a){
        mint m = i+1;
        comb_a *= (n-i);
        comb_a *= m.inv();
    }

    rep(i,0,b){
        mint m = i+1;
        comb_b *= (n-i);
        comb_b *= m.inv();
    }
    

    ans = ans.pow(n) - 1;
    ans -= comb_a;
    ans -= comb_b;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N=int(input())
L=list(input().split())
R=deque()
for i in range(N):
  if i%2==0:
    R.appendleft(L[i])
  else:
    R.append(L[i])
if N%2==0:
  R=reversed(R)
R=list(R)
print(" ".join(R))

Measured memory_bytes: 26684
//https://atcoder.jp/contests/abc149/tasks/abc149_a
//A - Strings
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    string S,T; cin>>S>>T;
    cout<<T<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
using namespace std;

int div2count(int x){
	int coun = 0;
	while(!(x%2)){
		x /= 2;
		coun++;
	}
	return coun;
}

long long gcd(long long x, long long y){
	if (x < y){
		int temp = x;
		x = y;
		y = temp;
	}
	if (x % y){
		return gcd(y, x%y);
	}
	return y;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<int> div2(n);
	cin >> a[0];
	div2[0] = div2count(a[0]);
	a[0] /= 2;
	for (int i = 1; i < n; i++){
		cin >> a[i];
		div2[i] = div2count(a[i]);
		a[i] /= 2;
		if (div2[i-1] != div2[i]){
			cout << 0 << endl;
			return 0;
		}
	}


	long long lcm = a[0];
	for (int i = 1; i < n; i++){
		lcm = lcm*a[i]/gcd(lcm, a[i]);
		if (lcm > m){
			cout << 0 << endl;
			return 0;
		}
	}

	cout << (m/lcm+1)/2 << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
//bool used[500005];
bool flag,dame;
 
int main(){
	cin >> n;
	for(i=0;i<n;i++){
	   cin >> x[i];
	}
	ll ab;
	ans = 0;
	for(i=1;i<n;i++){
	   ab = i;
	   a = 0;
	   b = n-1;
	   num = 0;
	   while(1){
		  num += x[a] + x[b];
		  a += i;
		  b -= i;
		  ans = max(ans,num);
		  if(i >= b)break;
		  if(a >= b && (n-1)%i == 0)break;
		  if(a >= n)break;
	   }
	}
	p(ans);
		  

	return 0;
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int N = NM[0];
		long ans = 0;
		for(int i=1;i<=N;i++) {
			if(i%3==0||i%5==0) {
				
			}else {
				ans+=i;
			}
		}
		
		print(ans);
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 32824
n = int(input())
ds = {}
for _ in range(n):
    s = input()
    if s not in ds.keys():
        ds[s] = 1
    else:
        ds[s] += 1

m = int(input())
dt = {}
for _ in range(m):
    s = input()
    if s not in dt.keys():
        dt[s] = 1
    else:
        dt[s] += 1

ans = 0
for k in ds.keys():
    if k in dt.keys():
        tmp = ds[k] - dt[k]
    else:
        tmp = ds[k]

    if ans < tmp:
        ans = tmp

print (ans)


Measured memory_bytes: 3064
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let n = io.read::<usize>();
    let mut v = vec![0; 10000001];
    for i in 1..n + 1 {
        for j in 1..n * 2 {
            if i * j > n {
                break;
            }
            v[i * j] += 1;
        }
    }
    let mut ans = 0;
    for i in 1..n + 1 {
        ans += i * v[i];
    }
    io.writeln(ans);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 80136
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
const int INF = 1e9 + 5;
const int LINF = int(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int n;
vector<int> a;
vector<vector<int>> v;
vector<int> ans;
void dfs(int k, int prev, vector<int> &dp)
{
    //debug(dp);
    //cout<<k<<"\n";
    int temp;
    auto x = lower_bound(ALL(dp), a[k]);
    bool check = false;
    int j = x - dp.begin();
    if (x == dp.end())
    {
        dp.push_back(a[k]);
        check = true;
    }
    else
    {
        temp = *x;
        *x = a[k];
    }
    ans[k] = dp.size();
    //cout<<ans[k]<<"\n";
    /*
    debug(dp);
    cout<<k<<"\n";
    */
    rep(i, v[k].size())
    {
        if (v[k][i] == prev)
            continue;
        dfs(v[k][i], k, dp);
    }
    if (check)
        dp.pop_back();
    else
        dp[j]=temp;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    v.resize(n);
    ans.resize(n);
    rep(i, n) cin >> a[i];
    rep(i, n - 1)
    {
        int temp, temp1;
        cin >> temp >> temp1;
        temp--;
        temp1--;
        v[temp1].push_back(temp);
        v[temp].push_back(temp1);
    }
    vector<int> dp;
    dfs(0, -1, dp);
    //debug(ans);
    rep(i, n) cout << ans[i] << "\n";
}


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

#include <iostream>

using namespace std;

constexpr int MAX_N = 100;
constexpr int MAX_W = 10000;

int N, W;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];

int dfs(int i, int j) {
  if (i >= N)
    return 0;
  if (dp[i][j] >= 0)
    return dp[i][j];
  int res = dfs(i + 1, j);
  if (j >= w[i]) {
    res = max(res, dfs(i + 1, j - w[i]) + v[i]);
  }
  return dp[i][j] = res;
}

int solve_dfs() {
  fill(dp[0], dp[0] + (MAX_N + 1) * (MAX_W + 1), -1);
  return dfs(0, W);
}

int solve() {
  for (int i{}; i < N; ++i) {
    for (int j{}; j <= W; ++j) {
      if (j < w[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }
  return dp[N][W];
}

int solve_backward() {
  for (int i{N - 1}; i >= 0; --i) {
    for (int j{}; j <= W; ++j) {
      if (j < w[i]) {
        dp[i][j] = dp[i + 1][j];
      } else {
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }
  return dp[0][W];
}

int main() {
  cin >> N >> W;
  for (int i{}; i < N; ++i) {
    cin >> v[i] >> w[i];
  }

  int ret = solve();
//  int ret = solve_dfs();
//  int ret = solve_backward();

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 7048
import math
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
lis = [[0,0] for i in range(h * w)]
num = [[0] * math.ceil((h * w) // d + 1) for i in range(d)]

for i in range(h):
    for j in range(w):
        lis[a[i][j]-1] = [i,j]

for i in range(h * w-d):
    num[i%d][i//d+1] = num[i%d][i//d]+abs(lis[i][0]-lis[i+d][0])+abs(lis[i][1]-lis[i+d][1])

q = int(input())
for _ in range(q):
    now,goal = map(int,input().split())
    if now % d == 0:
        print(num[now%d-1][(goal-now%d)//d-1]-num[now%d-1][(now-now%d)//d-1])
    else:
        print(num[now%d-1][(goal-now%d)//d]-num[now%d-1][(now-now%d)//d])

Measured memory_bytes: 74716
#include <stdio.h>

int kansuu(long long int *x)
{
  if (*x % 2 == 0)
    return *x = *x / 2;
  else
    return *x = 3 * (*x) + 1;
}

int main()
{
  long long int s, a[1000001], i;
  scanf("%lld", &s);

  a[0] = s;

  for (i = 1;; i++)
  {
    a[i] = kansuu(&s);
    for (int j = 0; j < i; j++)
    {
      for (int k = 1; k < i - j + 1; k++)
      {
        if (a[j] == a[j + k])
        {
          printf("%lld\n", i + 1);
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], mem[100010];
int main(){
    int n, k;
    while(cin>>n>>k){
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
        }
        mem[n]=1e9;
        mem[n-1]=0;
        for(int i=n-2; i>=0; --i){
            mem[i]=1e9;
            for(int j=1; j<=k&&i+j<=n-1; ++j){
                mem[i]=min(mem[i], abs(a[i+j]-a[i])+mem[i+j]);
            }
        }
        cout<<mem[0]<<endl;
    }
  return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
    	bool ok = true;
    	string s;
      cin>>s;
      if(s=="ABC")
      {
        cout<<"ARC"<<'\n';
      }
      else
      {
        cout<<"ABC"<<'\n';
      }
      return 0;
    }

Measured memory_bytes: 3464
//Resting_Prince
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000009
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define all(v) v.begin(),v.end()
#define rep(i,a,b)    for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    ll n,w,i,j,l,k,a[105],b[105];
    vector<pair<ll,ll>> v;
    cin>>n>>w;
    rep(i,1,n)cin>>a[i]>>b[i],v.pb(mk(a[i],b[i]));
    sort(all(v));
    ll dp[n+2][w+2];
    rep(i,0,n)
    {
        rep(j,0,w)
        {
            if(i==0 || j==0)dp[i][j]=0;
            else if(v[i-1].fi<=j)
            dp[i][j]=max(v[i-1].se+dp[i-1][j-v[i-1].fi],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
        }
    }cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
char a[100000],b[100000];
main()
{
	int o,oo; 
	gets(a);
	gets(b);
	o=max(strlen(a),strlen(b));
	oo=min(strlen(a),strlen(b));
	for(register int i=0;i<oo;i++)
	{
		cout<<a[i]<<b[i];
	}
	if(o==oo) return 0;
	else
	{
		if(strlen(a)>strlen(b))
        for(register int i=oo;i<o;i++)
        cout<<a[i];
        else
		{
		    for(register int i=oo;i<o;i++)
            cout<<b[i];
        }
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

if(a == b and b == c and a % 2 == 0):
    print(-1)
else :
    cnt = 0
    while True:
        if(a % 2 != 0 or b % 2 != 0 or c % 2 != 0):
            break
        A = b//2 + c//2
        B = c//2 + a//2
        C = a//2 + b//2
        a = A
        b = B
        c = C
        cnt += 1
    print(cnt)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
    int i=0;
    int num[10];
     for(;i<10;i++)
        cin>>num[i];
     int temp=0,temp1=0,j=0,k=0;
      for(;j<3;j++) {
            for(i=0;i<10;i++)
            {
                temp1=temp;
      temp=temp<num[i]?num[i]:temp;
       if(temp>temp1)
            k=i;
       }
       cout<<num[k]<<endl;
       temp=0;
        num[k]=0;
         }
       return 0;
       }

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
string s;
int N,tmp=1,K,a[6];
int D[10];
int cnt=0;
int ans;
int main(){
  cin >> N >> K;
  for(int i=0;i<K;i++){
    cin >> D[i];
  }
  for(int i=0;i<6;i++){
    a[i]=10;
  }

  for(int i=N;i<=100000;i++){
    cnt=0;
    a[0]=i%10;
    tmp=i-a[0]/10;
    int t=1;
    while(tmp!=0){
      a[t]=tmp%10;
      tmp=(tmp-a[t])/10;
      t++;
    }
    for(int j=0;j<K;j++){
      for(int k=0;k<6;k++){
        if(D[j]!=a[k]){
          cnt++;
        }
      }
    }
    if(cnt==K*6){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int days,jp,mp,jpd,mpd;
  cin >> days >> jp >> mp >> jpd >> mpd;
  if(jp / jpd > mp / mpd){
    if(jp % jpd){
      days -= jp/jpd+1;
    }
    else days -= jp/jpd;
  }
  else {
    if(mp % mpd){
      days -= mp/mpd+1;
    }
    else days -= mp/mpd;
  }
  cout << days << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;


ll power(ll a,ll b)
{
 ll res=1;
    while(b)
    {
     if(b&1)res=res*a;
        a=a*a;
        b/=2;
    }
    return res;
}


const int N=1e6+6;
vector<int>prime(N);



void solve()
{
    
    int sq=sqrt(N);
 int n,i,j;
    cin>>n;
    for(i=1;i*i<N;i++)
    {
     for(j=i;j<N;j+=i)
     {
       prime[j]++;
         int div=j/i;
         if(div==i)continue;
         if(div>sq)prime[j]++;
     }
    }
    
    ll ans=0;
    for(i=1;i<n;i++)
    {
     ans+=prime[i];   
    }
    cout<<ans<<endl;
    
}


int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 7068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int A, B;

  cin >> A >> B;

  if (A == 1)
    {
    A = 14;
    }
  if (B == 1)
    {
    B = 14;
    }

  if (A > B)
    {
    cout << "Alice" << endl;
    }
  else if (A < B)
    {
    cout << "Bob" << endl;
    }
  else
     {
    cout << "Draw" << endl;
    }
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
Mod = 10**9+7
def COMinit():
  #N_C_kのN
  for i in range(2, n+10):
    fac.append(fac[-1]*i%Mod)
    inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
    finv.append(finv[-1] * inv[-1] % Mod)


def COM(n, k):
  if n < 0 or k < 0 or n < k:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod

def ncr(n, r, p):
  num = den = 1
  for i in range(r):
    num = (num * (n - i)) % p
    den = (den * (i + 1)) % p
  return (num * pow(den, p - 2, p)) % p
p=10**9+7


ans = pow(2, n, Mod)

ans -= ncr(n, a, p)
ans %= Mod
ans -= ncr(n, b, p)
ans %= Mod
print(ans-1)

Measured memory_bytes: 3064
program j01;
var a,sum:array[0..100086]of int64;
    n,i:longint;

procedure qsort(l,r:longint);
var i,j,x,y:int64;
begin
  i:=l;j:=r;x:=a[(i+j)div 2];
  repeat
    while a[i]<x do inc(i);
    while x<a[j] do dec(j);
    if i<=j then
    begin
      y:=a[i];a[i]:=a[j];a[j]:=y;
      inc(i);dec(j);
    end;
  until i>j;
  if i<r then qsort(i,r);
  if l<j then qsort(l,j);
end;

begin
  readln(n);
  for i:=1 to n do read(a[i]);
  qsort(1,n);
  for i:=1 to n do sum[i]:=a[i]+sum[i-1];
  for i:=n-1 downto 1 do
    if sum[i]*2<a[i+1] then break;
  if (i=1)and(sum[i]*2>=a[2]) then
    writeln(n)
    else writeln(n-i);
end.

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char s[MAXN];
vi deg;
vector<pii> ans;

void solve(){
	scanf("%s", &s[1]);
	int n = strlen(&s[1]);
	if (s[n] == '1' || s[1] == '0') {
		printf("-1\n");
		return;
	}
	REP(i, 1, n) {
		if (s[i] != s[n - i]) {
			printf("-1\n");
			return;
		}
	}
	/*int fl = 0;
	REP(i, 2, n - 1) {
		if (s[i]) {
			fl = 1;
		}
	}
	if (!fl) {
		REP(i, 1, n) {
			printf("%d %d\n", i, n);
		}
		return;
	}*/
	deg.pb(1);
	int last = 1;
	REP(i, 2, n) {
		if (s[i] == '1') {
			deg.pb(i - last);
			last = i;
		}
	}
	int top = 1;
	last = 1;
	REP(i, 1, SZ(deg)) {
		int cur = ++top;
		ans.pb(mp(last, cur));
		REP(j, 0, deg[i] - 1) {
			ans.pb(mp(cur, ++top));
		}
		if (i == SZ(deg) - 1) {
			ans.pb(mp(cur, n));
		}
		last = cur;
	}
	
	if (n == 2) {
		ans.pb(mp(1, 2));
	}
	
	REP(i, 0, SZ(ans)) {
		printf("%d %d\n", ans[i]._1, ans[i]._2);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2804
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=600010,mod=998244353;
int n,lmt=1;
long long sum=0ll;
long long p[N],f[N],a[N];
inline long long add(long long x,long long y)
{
    return x+y>=mod?x+y-mod:x+y;
}
inline long long sub(long long x,long long y)
{
    return x-y<0?x-y+mod:x-y;
}
inline long long po(long long x,long long y)
{
    long long u=1ll;
    while(y)
    {
        if(y&1) (u*=x)%=mod;
        (x*=x)%=mod;
        y>>=1;
    }
    return u;
}
inline void fwt(long long *x,long long op)
{
    for(int mid=1;mid<lmt;mid<<=1)
    {
        int len=mid<<1;
        for(int k=0;k<lmt;k+=len)
        {
            for(int i=0;i<mid;i++)
            {
                long long wx=x[k+i],wy=x[k+mid+i];
                x[k+i]=add(wx,wy);
                x[k+mid+i]=sub(wx,wy);
                if(op^1) (x[k+i]*=op)%=mod,(x[k+mid+i]*=op)%=mod;
            }
        }
    }
    return;
}
inline void out(long long x)
{
    for(int k=0;k<=1000;k++)
    {
        for(int i=0;i<=1000;i++)
        {
            if(k*po(i,mod-2)%mod==x)
            {
                cout<<k<<"/"<<i<<endl;
                return ;
            }
            if(mod-k*po(i,mod-2)%mod==x)
            {
                cout<<"-"<<k<<"/"<<i<<endl;
                return;
            }
        }
    }
}
int main()
{
    scanf("%d",&n);
    n=(1<<n)-1;
    for(int k=0;k<=n;k++)
        scanf("%lld",&p[k]),sum+=p[k];
    long long inv=po(sum,mod-2);
    for(int k=0;k<=n;k++)
        (p[k]*=inv)%=mod;
    for(int k=0;k<=n;k++)
        a[k]=p[k];
    a[0]=sub(a[0],1);
    for(int k=1;k<=n;k++)
        f[k]=mod-1;
    f[0]=n;
    while(lmt<=n) lmt<<=1;
    fwt(a,1);
    fwt(f,1);
    for(int k=0;k<lmt;k++)
        (f[k]*=po(a[k],mod-2))%=mod;
    fwt(f,po(2,mod-2));
    fwt(a,po(2,mod-2));
    for(int k=1;k<=n;k++)
        f[k]=sub(f[k],f[0]);
    f[0]=0ll;
    for(int k=0;k<=n;k++)
        printf("%lld\n",f[k]);
    return 0;
}


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

int a[60];

int main () {

int n,k;
cin>>n>>k;
for (int i=0; i<n; i++) {
	cin>>a[i];
}
sort(a,a+n);
long long int zbr=0;
for (int i=n-1; i>n-1-k; i--) {
	zbr+=a[i];
}
cout<<zbr;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <unordered_map>
#include <set>
#include <cassert> //assart
#include <numeric>
#include <iterator>
#include <list>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int MOD=1e9+7;
const int MOD2=998244353;

const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！
//inline ll  ceil(double a){return (ll)a+1;}


//Eと名のつくのはデバッグ用！
int EintN(int array[],const int num){
    for(int i=0;i<num;i++){cerr<<array[i]<<" ";}
    br;
    return 0;
}
int EintNN(const int heighth,const int width,int array[heighth][width]){
    FOR(i, 0, heighth){
        FOR(k, 0, width){
            {cerr<<array[i][k]<<" ";}
        }
        br;
    }
    br;
    return 0;
}
int Eint(string str,const ll num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}


int prob(){
    ll ans;ans=0;
    unordered_map<string, ll> mp;
    int N;
    cin>>N;
    
    string S;
    FOR(i, 0, N){
        cin>>S;
        sort(S.begin(),S.end());
        ans+=mp[S];
        mp[S]++;
    }
    OutputAndReturn0(ans);
    return 0;
}



signed main(){
    //test();
    prob();
    return 0;
}


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

int main() {
  int n, sum = 0;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    int x = r - l + 1;
    sum += x;
  }
  
  cout << sum << endl;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    int n, m;
    string s[105];
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    sort(s, s + n);
    for (int i = 0; i < n; ++i) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt(); int y = scan.nextInt();
        if((x + y) % 2 == 0) System.out.println((x + y) / 2);
        else System.out.println("IMPOSSIBLE");
        scan.close();
    }
}

Measured memory_bytes: 35676
#include<bits/stdc++.h>
using namespace std;
int delta=10139;
int mark[100000002];
int main() {
    int n;cin>>n;
    vector<int>a;
    int s1=0,s2=0;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        a.push_back(t);
        if(i>0){
            s2+=t;
        }
    }
    s1=a[0];
    int ans=max(s1,s2)-min(s1,s2);
    for(int i=1;i<n;i++){
        s1+=a[i];
        s2-=a[i];
        ans=min(ans,(max(s1,s2)-min(s1,s2)));
    }
    cout<<ans;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskE {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			Segment[] s = new Segment[n];
			for (int i = 0; i < n; i++) {
				int l = in.nextInt();
				int r = in.nextInt();
				s[i] = new Segment(l, r);
			}
			Arrays.sort(s);
			int p = 0;
			Tree tree = new Tree(m + 1);
			for (int d = 1; d <= m; d++) {
				int ans = 0;
				while (p < n && s[p].len < d) {
					tree.add(s[p].l, s[p].r, 1);
					++p;
				}
				ans += n - p; // long segments will always hit
				for (int i = 0; i <= m; i += d) {
					ans += tree.get(i);
				}
				out.println(ans);
			}
		}

		class Segment implements Comparable<Segment> {
			int l;
			int r;
			int len;

			Segment(int l, int r) {
				this.l = l;
				this.r = r;
				this.len = r - l + 1;
			}

			public int compareTo(Segment o) {
				return len - o.len;
			}

		}

		class Tree {
			int n;
			int[] add;

			Tree(int n) {
				this.n = n;
				add = new int[4 * n];
			}

			void add(int l, int r, int val) {
				add(0, l, r, 0, n - 1, val);
			}

			int get(int x) {
				return get(0, x, 0, n - 1);
			}

			private int get(int root, int x, int L, int R) {
				if (L == R) {
					return add[root];
				}
				push(root);
				int M = (L + R) / 2;
				if (x <= M) {
					return get(2 * root + 1, x, L, M);
				}
				return get(2 * root + 2, x, M + 1, R);
			}

			private void add(int root, int l, int r, int L, int R, int val) {
				if (l > r || l > R || L > r || L > R) {
					return;
				}
				if (l == L && r == R) {
					add[root] += val;
					return;
				}
				push(root);
				int M = (L + R) / 2;
				add(2 * root + 1, l, Math.min(M, r), L, M, val);
				add(2 * root + 2, Math.max(M + 1, l), r, M + 1, R, val);
			}

			void push(int root) {
				add[2 * root + 1] += add[root];
				add[2 * root + 2] += add[root];
				add[root] = 0;
			}

		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 55636
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;

int main(void) {
	int i, j, k, tmp;
	int A, B, C, D;
	int t1, t2;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	if (B < C) {
		printf("0\n");
		return 0;
	}
	else if(D < A){
		printf("0\n");
		return 0;
	}
	t1 = max({ A, C });
	t2 = min( {B, D});

	printf("%d\n", t2 - t1);
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;
int a[20], b[20], c[20];
int dp[2][1<<18][18];
inline int f(int j, int k) {
	return (j - k) & 1 ? b[k] : a[k];
}
inline void upd(int &v, int x) {
	if (x && (!v || v > x)) v = x;
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	int y = 0, z = 1;
	for (int i = 0; i < n; i++) {
		dp[y][1<<i][i] = i + 1;
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 1 << n; j++) {
			for (int k = 0; k < n; k++) {
				dp[z][j][k] = 0;
			}
		}
		for (int j = 0; j < 1 << n; j++) {
			int m = 0;
			for (int k = 0; k < n; k++) {
				if (!(j >> k & 1)) {
					c[m++] = k;
				}
			}
			for (int k = 0; k < n; k++) {
				if (!(j >> k & 1)) continue;
				if (!dp[y][j][k]) continue;
				int la = f(i - 1, k);
				for (int l = 0; l < m; l++) {
					int t = f(i, c[l]);
					if (la > t) continue;
					upd(dp[z][j|(1<<c[l])][c[l]], dp[y][j][k] + l);
				}
			}
		}
		y = 1 - y;
		z = 1 - z;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		upd(ans, dp[y][(1<<n)-1][i]);
	}
	printf("%d\n", ans - 1);
	return 0;
}


Measured memory_bytes: 37120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    int key_place;
    cin>>s>>key_place;
    vector<int>str_map('z'-'a'+1,0);
    map<string,int>duplication,search_str;
    for(int i=0;i<key_place;i++){
        for(int k=0;k<s.length()-i;k++){
            string key=s.substr(k,i+1);
            if(duplication[key]==0){
                str_map[key[0]-'a']++;//先頭文字によって場合分け
                duplication[key]++;
            }
        }
    }
    char ans;
    int key_num;
    for(key_num=0;key_num<'z'-'a'+1;key_num++){
        if(key_place>str_map[key_num]){
            key_place-=str_map[key_num];
        }
        else{
            ans='a'+key_num;
            break;
        }
    }
    vector<string>s_array;
    for(int i=0;i<key_place;i++){
        for(int k=0;k<s.length()-i;k++){
            string key=s.substr(k,i+1);
            if(key[0]==ans){
                if(search_str[key]==0){
                    s_array.push_back(key);
                    search_str[key]++;
                }
            }
        }
    }
    sort(s_array.begin(),s_array.end());
    cout<<s_array[key_place-1]<<endl;

}

Measured memory_bytes: 2048