akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll inf = 1e9+7;
ll n,m;

int main(){
	cin>>n>>m;
	ll ans=0;
	if(n==2||m==2)ans=0;
	else if(n==1&&m==1)ans=1;
	else if(n==1||m==1)ans=max(m-2,n-2);
	else{
		ans=(n-2)*(m-2);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 50000
#define INF 100000000
using namespace std;
typedef long long ll;
int t[MAX+1],c[21];
struct bags{
	int value;
	int weight;
};
vector<bags> B;
int dp[102][10002];
int main()
{	
	int n,m; 
	struct bags tian;
	cin>>n>>m;
	B.push_back(tian);
	for(int i=1;i<=n;i++)
	{
		struct bags tmp;
		cin>>tmp.value>>tmp.weight;
		B.push_back(tmp);
	}
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=0;
		dp[0][i]=0;
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(j<B[i].weight)
				dp[i][j]=dp[i-1][j];
			else{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-B[i].weight]+B[i].value);
			}
		}
	cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 7052
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  ll A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;
  ll distance = abs(A - B);
  ll div = (V - W);
  if(distance<=div*T){
    puts("YES");
  }else{
    puts("NO");
  }
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
	int h;
	int a;
	int b;
	int d;
	scanf ("%d %d",&h,&a);
	
	if (h%a==0){
		b=h/a;
		printf("%d",b);
	}
	else {
		d=(h/a)+1;
		printf ("%d",d);
	}
	
	return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define MN 200000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,ans,f[MN+5],a[MN+5];
int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[i]=read(),f[a[i]]=max(f[a[i]],f[a[i]-1]+1),ans=max(ans,f[a[i]]);
	cout<<n-ans;
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

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

ll dijkstra(ll from, ll to, const vector<vector<pair<ll, ll>>> & nodes){
    ll N = nodes.size();
    vector<ll> costs(N, numeric_limits<ll>::max());
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<>> pq;
    pq.push(make_pair(0LL, from));
    costs.at(from) = 0LL;
    while(!pq.empty()){
        ll shortest_path, now;
        tie(shortest_path, now) = pq.top();
        pq.pop();
        for (auto &&p: nodes.at(now)){
            ll cost, next;
            tie(cost, next) = p;
            ll alt_shortest = shortest_path + cost;
            if (costs.at(next) > alt_shortest){
                costs.at(next) = alt_shortest;
                pq.push(make_pair(alt_shortest, next));
            }
        }
    }
    return costs.at(to);
};

int main() {
    ll  N, M, R;
    cin >> N >> M >> R;
    vector<ll> rs(R, 0);
    for (auto && i: boost::irange(0LL, R)){
        ll r;
        cin >> r;
        r--;
        rs.at(i) = r;
    }
    vector<ll> as(M, 0), bs(M, 0), cs(M, 0);
    for (auto && i: boost::irange(0LL, M)){
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        as.at(i) = a;
        bs.at(i) = b;
        cs.at(i) = c;
    }
    vector<vector<pair<ll, ll>>> nodes(N, vector<pair<ll, ll>>{});
    for (auto &&i: boost::irange(0LL, M)){
        ll from{as.at(i)}, to{bs.at(i)}, cost{cs.at(i)};
        nodes.at(from).emplace_back(make_pair(cost, to));
        swap(from, to);
        nodes.at(from).emplace_back(make_pair(cost, to));
    }
    vector<vector<ll>> costs(R, vector<ll>(R, numeric_limits<ll>::max()));
    for (auto &&i: boost::irange(0LL, R)){
        for (auto &&j: boost::irange(i, R)){
            costs.at(i).at(j) = i==j ? 0 : dijkstra(rs.at(i), rs.at(j), nodes);
        }
    }

    for (auto &&j: boost::irange(0LL, R)){
        for (auto &&i: boost::irange(0LL, R)){
            costs.at(i).at(j) = costs.at(j).at(i);
        }
    }
//    for (auto &&i: boost::irange(0LL, R)){
//        for (auto &&j: boost::irange(0LL, R)){
//            cout << costs.at(i).at(j) << " ";
//        }
//        cout << endl;
//    }
    vector<ll> permutation(R, 0);
    for (auto &&i: boost::irange(0LL, R)){
        permutation.at(i) = i;
    }
    ll min_cost{numeric_limits<ll>::max()};
    do {
        ll cost{0};
        for (auto &&i: boost::irange(0LL, R-1)){
            ll from, to;
            from = permutation.at(i);
            to = permutation.at(i+1);
            cost+=costs.at(from).at(to);
        }
        min_cost = min(min_cost, cost);
    } while (next_permutation(permutation.begin(), permutation.end()));
    cout << min_cost;
    return 0;
}

Measured memory_bytes: 1664
import math
A, B, H, M = map(int, input().split())

start = 30*H
start -= 5.5*M
if start >=180:
  start = 360-start

syahen = A**2 + B**2 - 2*A*B*math.cos(math.radians(start))
print(math.sqrt(syahen))


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

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

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

    int N; cin >> N;
    string S; cin >> S;

    if(N%2 == 1){
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0;i < N/2;i++){
        if(S[i] != S[i+N/2]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 256
#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 ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    string s;
    cin >> s;
    string ans = "";
    for(int i = 0; i < s.size(); i += 2)
        ans += s[i];
    cout << ans;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

int dfs(int n,int s,int i){
  if(n == 0){
    if(s == 0)return 1;
    else return 0;
  }
  if(s < 0)return 0;
  if(i > 9)return 0;

  return dfs(n,s,i + 1) + dfs(n - 1,s - i,i + 1);
}

int main(){
  int n,s;
  
  while(cin >> n >> s,n|s){
    cout << dfs(n,s,0) << endl;
  }
}

Measured memory_bytes: 2996
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))
import fractions

n=int(input())
a=[input_list() for _ in range(n)]
a.sort(key=lambda x:x[1])
cal=0
for each in a:
    v=each[0]
    cal+=v
    if cal>each[1]:
        print("No")
        exit()


print("Yes")

Measured memory_bytes: 63560
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS

    ll n;
    cin >> n;
    ll cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 1) {
            ++cnt;
        }
    }
    cout << double(cnt) / double(n);

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

/*******************************************************/

int main() {
  string s; cin >> s;
  int ans = INT_MAX;
  for (char c = 'a'; c <= 'z'; c++) {
    int cnt = 0;
    string t = s;
    while (1) {
      bool judge = true;
      Loop(i, t.length()) {
        if (t[i] != c) judge = false;
      }
      if (judge) break;
      string t2;
      Loop(i, t.length() - 1) {
        if (t[i] == c) t2.push_back(t[i]);
        else t2.push_back(t[i + 1]);
      }
      t = t2;
      cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=1e5+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
long long n,m,a[maxn];
long long sum[maxn],msum,ans;

bool check(int x)
{
    long long num=0;
    for(int i=1;i<=n;i++)
    {
        int pos=lower_bound(a+1,a+1+n,x-a[i])-a;
        num+=n-pos+1;
    }
    // cout<<x<<" "<<num<<endl;
    return num>=m;
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif

    scanf("%lld%lld",&n,&m);
    _rep(i,1,n)
        scanf("%lld",&a[i]);    
    sort(a+1,a+1+n);
    _rep(i,1,n)
        sum[i]=sum[i-1]+a[i];
    int l=1,r=2e5,mid;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(check(mid))
            msum=mid,l=mid+1;
        else
            r=mid-1;
    }
    long long k=0;
    for(int i=1;i<=n;i++)
    {
        int pos=lower_bound(a+1,a+1+n,msum-a[i])-a;
        ans+=a[i]*(n-pos+1)+sum[n]-sum[pos-1];
        k+=n-pos+1;
    }
    cout<<ans-msum*(k-m)<<endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	int a = 0;
	rep(i, S.size()) {
		if (S[i] == '+') a++;
		else a--;
	}
	cout << a << endl;
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353 
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;

	int n;
	cin>>n;
	int arr[n];

	for(int i=0;i<n;i++)
		cin>>arr[i];

	int max = 0;
	int start = 0;
	for(int i=0;i<n-1;i++){
		if(arr[i+1]>arr[i]){
			if(max<i-start)
				max = i-start;
			start = i+1;
		}
	}

	if(max<n-1-start)
		max = n-1-start;

	cout<<max;

	return 0;
}

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


def solve(S: str):

    good = True

    for i in range(len(S) - 1):
        if S[i] == S[i + 1]:
            good = False
        else:
            pass

    if good:
        print("Good")
    else:
        print("Bad")


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = str(next(tokens))  # type: str
    solve(S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> in(n);
    for(int i = 0; i < n; i++) cin >> in[i];
    vector<long long> ans(21,0);
    ans[in[0]] = 1;
    for(int i = 1; i < n-1; i++){
        vector<long long> tmp(21,0);
        for(int j = 0; j < 21; j++){
            if(j + in[i] <= 20)tmp[j+in[i]] += ans[j];
            if(j - in[i] >= 0) tmp[j-in[i]] += ans[j];
        }
        ans = tmp;
    }
    cout << ans[in[n-1]] << endl;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef int  ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define INF 1e8
bool sor(tuple<double,int,int>&x,tuple<double,int,int>&y)
{
    if(get<0>(x)>get<0>(y))
    {
        return 1;
    }
    else if(get<0>(x)<get<0>(y))
    {
        return 0;
    }
    else
    {
        if(get<1>(x)<get<1>(y))
        {
            return 1;
        }
        else if(get<1>(x)>get<1>(y))
        {
            return 0;
        }
        else
        {
            if(get<2>(x)>get<2>(y))
            {
                return 1;
            }
            else if(get<2>(x)>get<2>(y))
            {
                return 0;
            }
        }
    }
}

int main()
{
    int n,m,a,b;
    cin>>n>>m;
    map<int,vl>g;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        g[a].push_back(b);
    }
    priority_queue<int>q;
    ll ans=0,in=0;
    for(int i=1;i<=m;i++)
    {
        for(int j=0;j<g[i].size();j++)
        {
               q.push(g[i][j]);
        }
        if(!q.empty()){ll t=q.top();
        q.pop();
        ans+=t;}
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<55);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll N; cin>>N;
    ll ans=0;
    std::map<ll,ll> map;
    for(ll i=2;i*i<=N;i++){
        ll cnt=0,sum=1;
        while(N%i==0){
            N/=i;
            cnt++;
            if(cnt==sum){
                ans++;
                sum++;
                cnt=0;
            }
        }
        map[i]=sum-cnt-1;
    }
    if(N>1&&map[N]==0){
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 66156
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000007
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
// #define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	pii v[200002];
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int,int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int r = v[i].s;

		auto it = mp.lower_bound(v[i].f);


		if(r==w) {
			while(it!=mp.end() && it->f <= r) {
				auto it1 = it++;
				auto it2 = mini.find(it1->s);
				if(it2->s==1) mini.erase(it2);
				else it2->s --;
				mp.erase(it1);
			}
		}
		else {
			int mn = inf;

			while(it!=mp.end() && it->f <= r) {
				mn = min(mn, r+1-(it->f)+(it->s));
				auto it1 = it++;
				auto it2 = mini.find(it1->s);
				if(it2->s==1) mini.erase(it2);
				else it2->s --;
				mp.erase(it1);
			}

			if(mn<inf) {
				if(it!=mp.end() && it->f == r + 1) {
					if(it->s > mn) {
						auto it1 = mini.find(it->s);
						if(it1->s ==1) mini.erase(it1);
						else it1->s --;
						mini[mn]++;
						it->s = mn;
					}
				}
				else {
					mp.insert({r+1,mn});
					mini[mn]++;
				}
			}
		}

		if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
		else cout<<-1<<endl;

	}
}

Measured memory_bytes: 14476
//#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

char buffer[200003] = { 0 };
int count[26] = { 0 };
int f(char c)
{
	return (c < 'a' || 'z' < c) ? 0 : 1;
}
int main(void)
{
	int i, cnt;
	long long answer;
	fgets(buffer, sizeof(buffer), stdin);
	for (cnt = 0; f(buffer[cnt]); ++cnt){
		count[buffer[cnt] - 'a']++;
	}
	answer = cnt * ((long long)cnt - 1) / 2 + 1;
	for (i = 0; i < 26; ++i){
		answer += -count[i] * ((long long)count[i] - 1) / 2;
	}
	printf("%lld\n", answer);
	return 0;
}


Measured memory_bytes: 384
N=int(input())
A = list(map(int, input().split()))

B=sorted(A)

def histogram_sorted(data):
    table = []
    prev = data[0] 
    c = 1
    for i in range(1,len(data)):
        if prev == data[i]:
            c=c+1
        else:
            table.append([prev,c])
            prev = data[i]
            c = 1
    table.append([prev,c])
    return table

X = histogram_sorted(B)

X.append([0,0])

c=0
for i in range(1,N+1):
    if X[c][0] == i:
        print(X[c][1])
        c = c+1
    else:
        print(0)



Measured memory_bytes: 36140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> cnt(n + 2), acc(n + 2);
    for (int i = 0; i < n; i++) {
        int a; std::cin >> a;
        cnt[a]++;
    }
    std::sort(cnt.rbegin(), cnt.rend());
    for (int i = n - 1; i >= 0; i--) {
        acc[i] = cnt[i] + acc[i + 1];
    }
    auto check = [&](int w, int h) {
        int lo = -1, hi = n + 1;
        while (hi - lo > 1) {
            int mid = lo + (hi - lo) / 2;
            if (cnt[mid] <= w) hi = mid;
            else lo = mid;
        }
        return hi + acc[hi] / w >= h;
    };
    int pos = 0;
    for (int i = 1; i <= n; i++) {
        int lo = 0, hi = n/i + 1;
        while (hi - lo > 1) {
            int mid = lo + (hi - lo) / 2;
            if (check(mid, i)) lo = mid;
            else hi = mid;
        }
        std::cout << lo << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x--;
    p[x] = i;
  }
  int t = 1, ans = 1;
  for (int i = 1; i < n; i++) {
    if (p[i] > p[i - 1]) {
      t++;
    } else {
      t = 1;
    }
    ans = max(ans, t);
  }
  cout << n - ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
import sys
# A,B,C = [int(n) for n in input().split()]

# A = [0]*N
# for i in range(N):
#     A[i] = int(input())
S = str(input())
# T = str(input())
if "a" in S and "b" in S and "c" in S :
    print("Yes")
    sys.exit()
print("No")


Measured memory_bytes: 2940
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi s(n),t(n);
	rep(i,n)cin>>s[i];
	rep(i,n)cin>>t[i];

	int out=0;
	rep(i,29){
		vi a=s,b=t;
		ll q=1<<(i+1);
		rep(i,n)a[i]%=q,b[i]%=q;
		q>>=1;
		sort(all(b));
		int co=0;
		rep(j,n){
			co+=lower_bound(all(b),2*q-a[j])-lower_bound(all(b),q-a[j]);
			co+=lower_bound(all(b),4*q-a[j])-lower_bound(all(b),3*q-a[j]);
		}
		if(co%2)out|=q;
	}
	cout<<out<<endl;
}










Measured memory_bytes: 3428
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int n, a, b, c;
  scanf("%d%d%d", &n, &a, &b);
  a = b;
  while(--n) scanf("%d", &a);
  scanf("%d", &c);
  printf("%d\n", max(abs(b-c), abs(a-c)));
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
        int i,j,n;
        cin >> n;
        int h[n];
        int a, b;
        a=0;
        b=0;
        for (i=0;i<n;i++){
                cin >> h[i];
                if (i!=0 and h[i-1]>=h[i]){
                        a = a + 1;
                        if (b<a){
                                b = a;
                        }
                }else{
                        a=0;
                }
        }
        cout <<  b;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        long S;

        try (Scanner sc = new Scanner(System.in)) {
            S = sc.nextLong();
        }
        long tes = (long) Math.sqrt(S) + 1;
        long X1 = 0L;
        long Y1 = 1L;
        long X2 = 0L;
        long Y2 = 0L;

        if(tes*tes - S > 1000000000){
            X1 = tes -1;
            Y2 = tes -1;
            X2 = S -(X1 *Y2);
        }else{
            X1 = tes;
            Y2 = tes;
            X2 = (X1 *Y2) - S;
        }




        StringBuilder sb = new StringBuilder();
        sb.append("0 0 ").append(X1).append(" ").append(Y1).append(" ");
        sb.append(X2).append(" ").append(Y2);
        System.out.println(sb.toString());
        return;
    }



}


Measured memory_bytes: 21716
def len_LCS(X,Y):
    x_l = len(X)
    y_l = len(Y)
    lcs_row = [0 for _ in range(x_l+1)]
    for yc in Y:
        lcs_row_p = lcs_row[:]
        # lcs_row_p: [i] [i+1]
        # lcs_row  : [i] [i+1]
        for i in range(x_l):
            if X[i] == yc:
                lcs_row[i+1] = lcs_row_p[i] + 1
            elif lcs_row[i] > lcs_row_p[i+1]:
                lcs_row[i+1] = lcs_row[i]
    return lcs_row[-1]
        
if __name__=='__main__':
    n = int(input())
    for _ in range(n):
        X = input()
        Y = input()
        print(len_LCS(X,Y))

Measured memory_bytes: 7708
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, m, cnt[N], p[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++){
        cnt[i] = 1;
    }
    p[1] = 1;
    while(m--){
        int x, y;
        cin >> x >> y;
        p[y] |= p[x];
        cnt[y]++;
        cnt[x]--;
        if(cnt[x] == 0) p[x] = 0;
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++){
        ans += p[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

S = deque(readline().rstrip().decode())
Q = int(readline())
query = readlines()

rev = False
for q in query:
    if q[0] == ord('1'):
        rev = not rev
    else:
        _, f, c = q.decode().split()
        f = int(f)
        if rev ^ (f == 1):
            S.appendleft(c)
        else:
            S.append(c)

T = ''.join(S)
if rev:
    T = T[::-1]
print(T)

Measured memory_bytes: 18144
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        
        int ans = 0;
        for(int i=0; i<N; i++){
            int x = Integer.parseInt(sc.next());
            
            int A = 2 * x;
            int B = 2 * (K - x);
            
            if(A <= B){
                ans += A;
            }else{
                ans += B;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        int hyo;
        while (true)
        {

            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (x[0] == x[1] && x[1] == x[2] && x[0] == -1)
            { break; }
            else
            {
                hyo = x[1] + x[0] ;
                if ((x[1] == -1) || (x[0] == -1))
                {
                    Console.WriteLine("F");
                }
                else if (hyo >= 80) { Console.WriteLine("A"); }
                else if (hyo < 80 && hyo >= 65) { Console.WriteLine("B"); }
                else if (hyo < 65 && hyo >= 50) { Console.WriteLine("C"); }
                else if (hyo < 50 && hyo >= 30)
                {
                    if (x[2] < 50) { Console.WriteLine("D"); }
                    else { Console.WriteLine("C"); }
                }
                else if (hyo < 30)
                {
                    { Console.WriteLine("F"); }
                }

            }
        }    Console.ReadLine();
        
    }
}

Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  ll k;
  str s;
  cin >> s >> k;
  ll n = s.size(), count = 0;
  char ans;
  for (ll i = 0; i < n; i++) {
    if (s[i] == '1') count++;
    else {
      ans = s[i];
      break;
    }
  }
  
  if (count >= k) {
    ans = '1';
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N;
scanf("%d",&N);
int p[N];
for(int i=0;i<N;i++)
  scanf("%d",&p[i]);

int count=0;

for(int i=0;i<N;i++)
  if(i+1!=p[i]) 
  count=count+1;
if(count<3)
  printf("YES");
else
  printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

const ll INF = 1e18;
int N;
vector<int> a;
vector<ll> S;
vector<vector<ll>> memo;

// [l, r]
ll minCost(int l, int r) {
  assert(0 <= l && l <= N - 1);
  assert(0 <= r && r <= N - 1);
  assert(l <= r);

  if (l == r) return 0;
  if (memo[l][r] != -1) return memo[l][r];

  ll res = INF;
  for (int i = l; i < r; ++i) {
    res = min(res, minCost(l, i) + minCost(i + 1, r));
  }
  return memo[l][r] = res + S[r + 1] - S[l];
}

int main() {
  cin >> N;
  a.resize(N);
  S.resize(N + 1, 0);
  memo.resize(N, vector<ll>(N, -1));

  rep(i, N) cin >> a[i];
  rep(i, N) S[i + 1] = S[i] + a[i];

  cout << minCost(0, N - 1) << endl;

  return 0;
}


Measured memory_bytes: 1536
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var t = new List<int>();
            var x = new List<int>();
            var y = new List<int>();
            for (int i = 0; i < n; i++) {
                t.Add(cin.ReadInt);
                x.Add(cin.ReadInt);
                y.Add(cin.ReadInt);
            }

            var temp_t = 0;
            var temp_x = 0;
            var temp_y = 0;

            var diff_t = 0;
            var diff_x = 0;
            var diff_y = 0;

            for (var i = 0; i < n; i++) {
                diff_t = Math.Abs(temp_t - t[i]);
                diff_x = Math.Abs(temp_x - x[i]);
                diff_y = Math.Abs(temp_y - y[i]);

                var distance = diff_x + diff_y;
                if (distance > diff_t || diff_t%2 != distance%2) {
                    WriteLine("No");
                    return;
                }
                temp_t = t[i];
                temp_x = x[i];
                temp_y = y[i];
            }

            WriteLine("Yes");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 18256
using System;
using System.Linq;
 
namespace _0011
{
    class Program
    {
        private static void Main(string[] args)
        {
            surou();
        }
        private static void surou()
        {
        const int maxNumberOfLines = 30;
            var numberOfVerticalLines = maxNumberOfLines + 1;
            var numberOfHorizontalLines = maxNumberOfLines + 1;
            while (maxNumberOfLines < numberOfVerticalLines)
            {
                var numberOfLines = Console.ReadLine();
                if (numberOfLines == null) continue;
                numberOfVerticalLines = int.Parse(numberOfLines);
            }
            while (maxNumberOfLines < numberOfHorizontalLines)
            {
                var numberOfLines = Console.ReadLine();
                if (numberOfLines == null) continue;
                numberOfHorizontalLines = int.Parse(numberOfLines);
            }
 
            var verticalLineNumbers = new int[numberOfVerticalLines];
            for (var i = 0; i < numberOfVerticalLines; i++)
            {
                verticalLineNumbers[i] = i + 1;
            }
 
            for (var i = 0; i < numberOfHorizontalLines; i++)
            {
                var horizontalLine = Console.ReadLine();
                if (horizontalLine == null) continue;
                var horizontalLineNumbers = horizontalLine.Split(',');
                var firstIndex = int.Parse(horizontalLineNumbers.First()) - 1;
                var lastIndex = int.Parse(horizontalLineNumbers.Last()) - 1;
                var temp = verticalLineNumbers[firstIndex];
                verticalLineNumbers[firstIndex] = verticalLineNumbers[lastIndex];
                verticalLineNumbers[lastIndex] = temp;
            }
 
            for (var i = 0; i < numberOfVerticalLines; i++)
            {
                Console.WriteLine(verticalLineNumbers[i]);
            }
        }
    }
}

Measured memory_bytes: 5796
#include<bits/stdc++.h>
#define INF 1e9+5
using namespace std;

int main(){

int n;
cin>>n;

int arr[n];

for(int i=0; i<n; i++)
    cin>>arr[i];

vector<int>dp(n, INF);
dp[0]=0;
for(int i=0; i<n; i++){
    for(int j=i+1; j<=i+2; j++){
            if(j<n){
              dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]));
            }
    }
}
    cout<<dp[n-1]<<endl;






return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

ll n,x,y;

ll dist(ll a,ll b){
    if(x <= a && b <= y){
        return min(b-a,y-x+1-(b-a));
    }
    else if(x <= a && a<=y){
        return min(b-a,b-y+y-x+1-(y-a));
    }
    else if(x <= b && b <= y){
        return min(b-a,x-a+y-x+1-(b-x));
    }
    else{
        if(b < x) return b-a;
        if(a > y) return b-a;
        return b-a-(y-x)+1;
    }
}

int main(void) {
    cin>>n>>x>>y;
    vl dis(n-1,0);
    ll cnt = 0;
    for(ll i = 1;i<=n;i++){
        for(ll j = i+1;j<=n;j++){
            //cout<<i<<" "<<j<<" "<<"d:"<<dist(i,j)<<endl;
            dis[dist(i,j)-1]++;
            cnt++;
        }
    }
    rep(i,n-1){
        cout<<dis[i]<<endl;
    }
	return 0;
}


Measured memory_bytes: 3632
N, M = map(int, input().split())
AB = []

for _ in range(M):
    a, b = map(int, input().split())
    AB.append((a-1, b-1))

class UnionFind():
    def __init__(self, n):
        # negative if parent
        # if parent, absolute value represents the number of nodes in the union
        # if child, value represents the parent node to it
        self.parent = [-1 for _ in range(n)]
        
    def root(self, x):
        if self.parent[x] < 0:
            return x

        else:
            # recursively trace a parent node until it gets to a root while updating every node so that they are directly connected to their common parent
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def size(self, x):
        return -1 * self.parent[self.root(x)]
    
    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False

        else:
            size_x = - self.size(x) 
            size_y = - self.size(y)

            # make sure y is shorter so that always shorter tree(y) is atached to longer tree(x) 
            if size_x > size_y:
                x, y = y, x 

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

            return size_x, size_y


n_solo = N * (N - 1) // 2 
ans = [n_solo]
uf = UnionFind(N)

for a, b in reversed(AB):

    united = uf.union(uf.root(a), uf.root(b))

    if united:
        n_solo -= united[0] * united[1]

    ans.append(n_solo)
    
for a in reversed(ans[:-1]):
    print(a)


Measured memory_bytes: 23244
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[] and n!=1:
        arr.append([n, 1])

    return arr

arr = factorization(N)


candidate_arr = sorted([arr[i][0]**(j+1) for i in range(len(arr)) for j in range(arr[i][1])])

ans = 0
for c in candidate_arr:
    if N%c==0:
        ans+=1
        N /= c

print(ans)

Measured memory_bytes: 9396
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    pair<int, int> A[100010];
    rep(i, N) cin >> A[i].first;
    rep(i, N) A[i].second = i;
    sort(A, A + N);
    int ans[2] = {};
    rep(i, N){
        if(A[i].second % 2 != i % 2) ans[i % 2]++;
    }
    cout << ans[0] << endl;

    return 0;
}
// 2 1 4 3 5
//

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


int main(void)
{
	//変数の宣言
	
	//int n,k;
	
	int X,Y;
	int n;
	//データの読み込み
	//scanf("%d %d",&n,&k)
	
	scanf("%d %d",&X,&Y);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	n = X + Y/2;
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",n);
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,L;
  string s,ans;
  map<string,int> S;
  cin>>N>>L;
  for(int i=0;i<N;i++){
    cin>>s;
    S[s]++;
  }
  for(auto itr=S.begin();itr!=S.end();itr++){
    for(int i=0;i<itr->second;i++){
      ans+=itr->first;
    }
  }
  cout<<ans<<endl;
} 

Measured memory_bytes: 256
using System;

class ITP1
{
    static void Main()
    {
        while (true)
        {
            string str = Console.ReadLine();
            if (str == "-") { break; }

            int a = int.Parse(Console.ReadLine());
            for(int i=0;i<a;i++)
            {
                int b = int.Parse(Console.ReadLine());
                str = str.Substring(b) + str.Substring(0, b);
            }
            Console.WriteLine(str);
        }
    }
}

Measured memory_bytes: 11496
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

 
const int MAXN = 1e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	int n, m, k;
	cin >> n >> m >> k;
	string a[n];
	forn(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	for (int maskn = 0; maskn < (1 << n); maskn++) {
		for (int maskm = 0; maskm < (1 << m); maskm++) {
			int cnt = 0;
			forn(i, n) {
				forn(j, m) {
					if (!(((1 << i) & maskn) || ((1 << j) & maskm))) {
						if (a[i][j] == '#') {
							cnt++;
						}
					}
				}
			}
			if (cnt == k) {
				ans++;
			}
		}
	}
	cout << ans << "\n";
 	return 0;
}

Measured memory_bytes: 3656
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;


struct job{
    int a,b;
    bool operator <(const job& rhs)const{
        return a == rhs.a ? b > rhs.b: a < rhs.a;
    }
};


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m;
    cin >> n >> m;
    vector<job> jobs(n);
    for (int i = 0; i < n; i++){
        cin >> jobs[i].a >> jobs[i].b;
    }
    
    sort(jobs.begin(), jobs.end());
    
    priority_queue<int, vector<int>, less<int> > q;     // 大顶堆
    int ptr = 0;
    ll money = 0;
    for (int i = 1; i <= m; i++){
        while (ptr < n&&jobs[ptr].a<=i) {
            q.push(jobs[ptr].b);
            ptr++;
        }
        
        if(!q.empty()){
            money += q.top();
            q.pop();
        }
    }
    
    cout << money << "\n";
    
    return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", (double)v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };


template<typename T>
class BIT {
public:
	int N;
	vector<T> seg;
	BIT(int N) : N(N) {
		seg.resize(N + 1);
		for (int i = 0; i < N + 1; ++i) seg[i] = 0;
	}

	//i番目にxを加算
	void add(int i, T x) {
		++i;
		while (i <= N) {
			seg[i] += x;
			i += i & (-i);
		}
	}

	//[0,i)の和
	T cumulative(int i) {
		T s = 0;
		while (i > 0) {
			s += seg[i];
			i -= i & (-i);
		}
		return s;
	}

	//[a,b)の和
	T sum(int a, int b) {
		return cumulative(b) - cumulative(a);
	}

	//i番目の要素
	T elem(int i) {
		return sum(i, i + 1);
	}

	//i番目に代入
	void assign(int i, T x) {
		add(i, -elem(i));
		add(i, x);
	}
};


int main() {
	int N; cin >> N;
	vector<ll> A(N); REP(i, 0, N) cin >> A[i];
	vector<pair<ll, int>> P(N); REP(i, 0, N) P[i] = { A[i], i };
	sort(P.begin(), P.end(), [&](pair<ll,int> a, pair<ll,int> b) {
		if (a.first == b.first) {
			return a.second < b.second;
		}
		else return a.first < b.first; });
	vector<int>I(N); REP(i, 0, N) I[P[i].second] = i;
	BIT<ll> tree{ N };
	BIT<ll> tree_sum{ N };
	vector<ll> T(N);
	for (int i = N - 1; i >= 0; --i) {
		int rank = I[i];
		ll high_rank_n = tree.sum(rank, N);
		ll sum = tree_sum.sum(rank, N);
		T[i] = sum - A[i] * high_rank_n;
		tree.add(rank, 1);
		tree_sum.add(rank, A[i]);
	}
	ll sum = 0;
	REP(i, 0, N) sum += A[i];
	ll curmax = 0;
	REP(i, 0, N) {
		if (A[i] > curmax) {
			ll ans = sum - T[i];
			sum = T[i];
			PRI(ans);
			curmax = A[i];
		}
		else PRI(0);
	}
	return 0;
}

Measured memory_bytes: 8284
#include <iostream>
#include <stdio.h>
#include<math.h>
using namespace std;
struct Point {double x,y;};
void kock(int n,Point a,Point b){
    double th=M_PI*60.0/180.0;
    Point s,t,u;
    if (n==0){
        return;
    }
    //s t u
    s.x=(2.0*a.x+b.x)/3;
    s.y=(2.0*a.y+b.y)/3;
    t.x=(a.x+2.0*b.x)/3;
    t.y=(a.y+2.0*b.y)/3;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    kock(n-1,a,s);
    cout<< s.x<<" "<< s.y<<endl;
    kock(n-1,s,u);
    cout<< u.x<<" "<<u.y<<endl;
    kock(n-1,u,t);
    cout<< t.x<<" "<<t.y<<endl;
    kock(n-1,t,b);
    
}
int main(void){
    int a;scanf("%d", &a);
    Point c,b;
    c.x=0.0;
    c.y=0.0;
    b.x=100.0;
    b.y=0.0;
    cout<<c.x<<" "<<c.y<<endl;
    kock(a,c,b);
    cout<<b.x<<" "<<b.y<<endl;
    return 0;
    
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll t,n,q,m,x,y,a=0,b=0,c=0,d=0;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        if(s=="AC")
            a++;
        else if(s=="WA")
            b++;
        else if(s=="TLE")
            c++;
        else
            d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
    return 0;
}







Measured memory_bytes: 3620