akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
using lint=long long;
lint inf=1e18;
lint myPow(int x,int n,int m){
    lint res=1;
    lint cur=x;
    while(n>0){
        if(n&1){
            res*=cur;
        }
        cur*=cur;
        cur%=MOD;
        res%=MOD;
        n/=2;
    }
    return res;
}
signed main(){
    int n;cin>>n;
    vector<lint> c(n+1,inf);
    rep1(i,n)cin>>c[i];
    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());
    lint res=0;
    rep1(i,n){
        res+=c[i]*(i+1);
        res%=MOD;
    }
    res*=myPow(4,n-1,MOD);
    res%=MOD;
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main(){
  int H[10000], W[10000], i, j, k, end;
  for(k=0; k<10000; k++){
    cin>>H[k]>>W[k];
    if(H[k]==0 && W[k]==0){
      end = k;
      break;
    }
  }
  for(k=0; k<end; k++){
    for(i=0; i<H[k]; i++) {
      for(j=0; j<W[k]; j++) cout<<"#";
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
 
int main(){
    ll N, K;
    cin >> N >> K;
    bool flag = false;
    vector<vector<ll>> G(N,vector<ll>(N,1));
    ll MM = 0;
    REP(i,1,N-1){
        MM += i;
    }
    if(K > MM){
        cout << -1 << endl;
        return 0;
    }
    rep(i,N){
        G[i][i] = 0;
    }
    ll cnt = 0;
    REP(i,1,N){
        REP(j,i+1,N){
            if(cnt == K){
                flag = true;
                break;
            }
            G[i][j] = 0;
            G[j][i] = 0;
            cnt++;
        }
        if(flag) break;
    }
    cout << (N*(N-1))/2 - K << endl;
    rep(i,N){
        REP(j,i+1,N){
            if(G[i][j]==0)continue;
            cout << i+1 <<" "<< j+1 << endl;
        }
    }
    /*
    ll s,t;
    REP(i,1,N){
        if(2*K == i*(i-1) + (N-i)*(N-i-1)){
            flag = true;
            s = i;
            t = N - i;
            break;
        }
    }
    if(K < N-1){
        flag = true;
    }
    if(!flag){
        cout << -1 << endl;
        return 0;
    }
    if(K >= N-1){
        cout << s*t << endl;
        REP(i,1,s+1){
            REP(j,s+1,N+1){
                cout << i << " " << j << endl;
            }
        }
    }else{
        cout << N*(N-1)/2 - K << endl;
        REP(i,1,N+1){
            REP(j,i+1,N+1){
                if(i == 1 && i > K) continue;
                cout << i << " " << j << endl;
            }
        }
    }*/
}

Measured memory_bytes: 3648
n = int(input())
M = 1046527
table = [""]*M
def getKey(str):
    sum = 0
    p = 1
    for i in range(len(str)):
        if str[i] == "A":
            num = 4
        elif str[i] == "T":
            num = 3
        elif str[i] == "G":
            num = 2
        else:
            num = 1
        sum += p*num
        p *= 5
    return sum

for ni in range(n):
    instruction = input().split()
    if instruction[0][0] == "i":
        key = getKey(instruction[1])
        h = key%M
        i = 0
        while table[h] != "" and table[h] != instruction[1]:
             i += 1
             h = (key%M + i *(1 + key%(M-1)) )%M
        table[h] = instruction[1]
    elif instruction[0][0] == "f":
        key = getKey(instruction[1])
        h = key%M
        i = 0
        while table[h] != "" and table[h] != instruction[1]:
             i += 1
             h = (key%M + i *(1 + key%(M-1)) )%M
        if table[h] == instruction[1]:
            print("yes")
        else:
            print("no")



Measured memory_bytes: 30952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 55;
const int maxp = 20;

int A[maxn][maxp], dst[maxn];
vector<int> g[maxn];
int id[maxn][maxn], n;

void dfs(int u, int p){
	A[u][0] = p;
	for(auto &v : g[u]){
		if(v != p){
			dst[v] = dst[u] + 1;
			dfs(v, u);
		}
	}
}

void compute(){
	for(int k = 1; k < maxp; k++)
		for(int i = 1; i <= n; i++)
			if(A[i][k - 1] != -1)
				A[i][k] = A[A[i][k - 1]][k - 1];
}

int query(int u, int v){
    if(dst[u] < dst[v])
        swap(u, v);
    
    int d = dst[u] - dst[v];

    for(int i = 0; i <= 19; i++){
        if(d & (1 << i)){
            u = A[u][i];
            d ^= (1 << i);
        }
    }

    if(u == v)
        return u;
    
    for(int i = 19; i >= 0; i--){
        if(A[u][i] != A[v][i]){
            u = A[u][i];
            v = A[v][i];
        }
    }

    return A[u][0];
}

ll solve(int a, int b){
	int l = query(a, b);
	ll ans = 0;
	
	int cur = a;
	while(cur != l){
		int pp = id[cur][A[cur][0]];
		ans |= (1ll << pp);
		cur = A[cur][0];
	}
	
	cur = b;
	while(cur != l){
		int pp = id[cur][A[cur][0]];
		ans |= (1ll << pp);
		cur = A[cur][0];
	}
	
	return ans;
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n;
	for(int i = 0; i + 1 < n; i++){
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
		id[a][b] = id[b][a] = i;
	}
	
	memset(A, -1, sizeof(A));
	dfs(1, -1);
	compute();
	
	int m;
	cin >> m;
	
	vector<ll> mask(m);
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		mask[i] = solve(a, b);
	}
	
	ll ans = (1ll << (n - 1));
	
	for(int i = 1; i < (1 << m); i++){
		int b = __builtin_popcount(i);
		ll M = 0;
		
		for(int j = 0; j < m; j++)
			if(i & (1 << j))
				M |= mask[j];
				
		int cnt = __builtin_popcountll(M);
		ll val = (1ll << (n - 1 - cnt));
		
		if(b & 1)
			ans -= val;
		else
			ans += val;
	}
	
	cout << ans << endl;

	return 0;
}

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

int main() {
    int n, ret = 0;
    std::cin >> n;
    std::vector<int> p(n + 1, 0);
    for (int i = 1; i <= n; i++) std::cin >> p[i];

    int consecutive = 0;
    for (int i = 1; i <= n; i++) {
        if (p[i] == i) {
            consecutive++;
        } else {
            if (!consecutive) continue;
            else {
                ret += (consecutive / 2) + (consecutive % 2);
                consecutive = 0;
            }
        }
    }

    ret += (consecutive / 2) + (consecutive % 2);

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstdio>

#define X first
#define Y second

using namespace std;

typedef pair<int,int> P;

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string idx="ABCDEFGHI";

int main(void){
	
	map<char,P> mp;
	int cnt=0,b;
	
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)mp[idx[cnt++]]=P(i,j);
	
	P s,t,d;
	char S,T,D;
	while(cin >> b >> S >> T >> D){
		
		s.X=mp[S].X,s.Y=mp[S].Y;
		t.X=mp[T].X,t.Y=mp[T].Y;
		d.X=mp[D].X,d.Y=mp[D].Y;
		
		double dp[16][3][3];
		
		for(int i=0;i<16;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)dp[i][j][k]=0;
		
		dp[0][s.Y][s.X]=1;
		
		for(int k=0;k<b;k++){
			for(int x=0;x<3;x++){
				for(int y=0;y<3;y++){
					for(int i=0;i<4;i++){
						int nx=x+dx[i],ny=y+dy[i];
						if(nx<0 || ny<0 || 2<nx || 2<ny || (nx==d.X && ny==d.Y))nx=x,ny=y;
						dp[k+1][ny][nx]+=dp[k][y][x]/4;
					}
				}
			}
		}
		printf("%.8f\n",dp[b][t.Y][t.X]);
	}
	return 0;
}

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


ll N, D, A;
vector<pair<ll, ll>> XH;


void input() {
    cin >> N >> D >> A;
    XH = vector<pair<ll, ll>>(N);
    rep(i, N) cin >> XH[i].first >> XH[i].second;
}


int main() {
    input();
    sort(XH.begin(), XH.end());
    vector<ll> x, c;
    x.push_back(-1);
    c.push_back(0);
    ll ans = 0;
    rep(i, N) {
        auto itr = lower_bound(x.begin(), x.end(), XH[i].first);
        int d = distance(x.begin(), itr);
        XH[i].second -= c.back() - c[d-1];
        if (XH[i].second <= 0) continue;
        ll v = XH[i].second / A;
        if (XH[i].second % A != 0) v++;
        ans += v;
        ll j = XH[i].first + 2 * D;
        x.push_back(j);
        c.push_back(c.back() + v * A);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6756
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

ll gcd(ll a,ll b){
  if(a%b==0)return b;

  return gcd(b,a%b);
}

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

  ll a,b;
  std::cin>>a>>b;

  std::cout<<(a/gcd(a,b))*b<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int f[100010];
int n, k, x;

inline void work() {
    cin >> n >> k;
    f[0] = 1;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        sum = min(sum + x, k);
        // f[i][j] = f[i - 1][j] + f[i - 1][j - 1] + ... + f[i - 1][j - x]
        int prev = 0;
        for (int j = sum; j >= max(0, sum - x); --j) {
            prev += f[j];
            prev %= mod;
        }
        for (int j = sum; j >= 0; --j) {
            int last_fj = f[j];
            f[j] = prev;
            if (j - x - 1 >= 0) {
                prev += f[j - x - 1];
            }
            prev -= last_fj;
            prev = (prev % mod + mod) % mod;
        }
    }
    cout << f[k] << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (A, B, C) = listOfInt()
    if (A == B && A != C) println("Yes")
    else if (B == C && A != C) println("Yes")
    else if (A == C && A != B) println("Yes")
    else println("No")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)


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

int N;
vector<int> h;

int main() {
    cin >> N; h.resize(N);
    for (int i = 0; i < N; i++) scanf("%d", &h[i]);
    int maxi = h[0];
    int count = 1;
    for (int i = 1; i < N; i++) {
        maxi = max(maxi, h[i-1]);
        if (maxi <= h[i]) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

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

e = []

for i in range(q):
  e.append(list(map(int, input().split())))

a = itertools.combinations_with_replacement(list(range(1, m+1)),n)

max_total = 0

for i in a:
  total = 0
  
  for j in e:
    if i[j[1]-1] - i[j[0]-1] == j[2]:
      total += j[3]
  
  if max_total < total:
    max_total = total
      
print(max_total)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  unsigned long long int a[n],pre[n],s=0,ans=0;
  for(long long int i=0;i<n;i++)
  {
  cin>>a[i];
  s+=a[i];
  }
  for(long long int i=0;i<n;i++)
  {
    s=s-a[i];
    pre[i]=s%1000000007;
  }
  for(long long int i=0;i<n;i++)
  {
    ans+=(a[i]*(pre[i]))%1000000007;
  }
  cout<<ans%1000000007<<endl;
}

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

typedef struct _data_st
{
    int a, b;
    char op;
    struct _data_st *next;
} data_st;

int main(int argc, char *argv[])
{
    data_st *head = NULL, *tail = NULL;
    int a, b;
    char op;
    for (; scanf("%d %c %d", &a, &op, &b) == 3 && op != '?';)
    {
        data_st *data = (data_st *)malloc(sizeof(data_st));
        *data = (data_st){.a = a, .b = b, .op = op, .next = NULL};
        head = head ?: data;
        if (tail)
        {
            tail->next = data;
        }
        tail = data;
    }
    for (data_st *elm = head; elm; elm = elm->next)
    {
        const int answer = (elm->op == '+') ? (elm->a + elm->b) :
                           (elm->op == '-') ? (elm->a - elm->b) :
                           (elm->op == '*') ? (elm->a * elm->b) :
                           (elm->op == '/') ? (elm->a / elm->b) : 0;
        printf("%d\n", answer);
    }
    while (head)
    {
        data_st *discard = head;
        head = head->next;
        free(discard);
    }
    tail = NULL;
    return 0;
}



Measured memory_bytes: 2064
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    int i,sum;
    while(true){
        cin >> s;
        if(s == "0") break;
        sum = 0;
        for(i=0;i<s.length();i++){
            sum += s.at(i)-'0';
        }
        cout << sum << endl;
    }
    return 0;   
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long

int main()
{

	ll n, W;
	cin >> n >> W;
	//cout << "HELLO" << endl;
	ll wt[n];
	ll val[n];
	ll total_val = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> wt[i] >> val[i];
		total_val += val[i];
	}



	ll dp[n + 1][total_val + 1];

	for (ll i = 0; i <= total_val; i++)
		dp[0][i] = 0;


	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= total_val; j++)
			dp[i][j] = 1e9 + 5;


	for (ll i = 0; i <= n; i++)
		dp[i][0] = 0;

	//cout << "x" << endl;
	ll ans = 0;
	for (ll i = 1; i <= n; i++)
	{
		for (ll j = 1; j <= total_val; j++)
		{
			ll x = INT_MAX;
			if (j - val[i - 1] >= 0)
				x = dp[i - 1][j - val[i - 1]] + wt[i - 1];
			ll y = dp[i - 1][j];

			dp[i][j] = min(x, y);
			//cout << dp[i][j] << " ";
		}
	}





	for (ll i = 1; i <= n; i++)
	{
		for (ll j = 1; j <= total_val; j++)
		{
			//cout << dp[i][j] << " ";
			if (dp[i][j] <= W)
			{
				ans = max(ans, j);
			}
		}
	}

	cout << ans << endl;
	// for (int i = 1; i <= total_val; i++)
	// {	for (int j = 1; j <= n; j++)
	// 		cout << dp[i][j] << " ";
	// 	cout << endl;


	// }



}













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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int f(int exp){

    int tmp = 1;

    while(1){
        exp -= tmp;

        if(exp <= 0){
            if(exp < 0)tmp-=1;
            break;
        }
    
        ++tmp;
    }

    return tmp;
}


int main(){

    bool flag=false;
    ll ans=0,sum=0;

    ll n;
    cin>>n;

    map<ll,int> divs;
    ll p = n;
    
    rep1(i ,2, sqrt(n)+1){
        int cnt=0;
        while(p%i==0){p/=i;cnt++;}
        
        if(cnt>0){
            divs[i] = cnt;
        
        }
    }
    if(p>1)divs[n]=1;

    for(auto p:divs){
        int exp = p.second;
        int ad = f(exp);
        
        //db(ad);ln;
        ans += ad;
    }

    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3732
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] array = br.readLine().split(" ");
        int a = Integer.parseInt(array[0]);
        int b = Integer.parseInt(array[1]);
        if(a < b){
    		System.out.println("a < b");
        }else if(a > b){
        	System.out.println("a > b");
        }else{
        	System.out.println("a == b");
        }
	}
}

Measured memory_bytes: 17052
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,v,w;
    cin>>a>>v;
    cin>>b>>w;
    long long t;
    cin>>t;
    if((v<w&&a!=b)||abs(a-b)>abs(v-w)*t) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

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

int main() {
	float Max; cin >> Max;
	float Min = Max;
	float f;
	while (cin >> f) {
		Max = max(Max, f);
		Min = min(Min, f);
	}
	cout << Max - Min << endl;
	return 0;
}

Measured memory_bytes: 3212
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    string S, T; cin >> S >> T;
    ll ans = INF;
    rep(i, S.size() - T.size() + 1){
        ll cnt = 0;
        rep(j, T.size()){
            if(S[i + j] != T[j]) cnt++;
        }
        chmin(ans, cnt);
    }
    pt(ans);
    return 0;
}

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

signed main(){
  int N;
  cin>>N;
  if(400<=N&&N<600)cout<<8<<endl;
  if(600<=N&&N<800)cout<<7<<endl;
  if(800<=N&&N<1000)cout<<6<<endl;
  if(1000<=N&&N<1200)cout<<5<<endl;
  if(1200<=N&&N<1400)cout<<4<<endl;
  if(1400<=N&&N<1600)cout<<3<<endl;
  if(1600<=N&&N<1800)cout<<2<<endl;
  if(1800<=N&&N<2000)cout<<1<<endl;
  return 0;
}

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

 using namespace std;
  vector<int> G[101];
  bool V[101]={};
  bool Vis[101]={};
  int DP[101] = {};
   int N;
   int Ans = 0;
  void DFS(int n,int len){
      Ans = max(Ans,len);
      DP[n] = max(DP[n],len);
      int S = G[n].size();
      for(int i=0;i<S;i++){
    if(!V[G[n][i]]){
        Vis[G[n][i]]= true;
        V[G[n][i]] = true;
        DFS(G[n][i],len+1);
        V[G[n][i]] = false;
    }
   }
   return;
  }
  int main(){
      do{
   for(int i=0;i<101;i++){
    G[i].clear();
    V[i] = false;
   Vis[i] = false;
    DP[i] = 0;
   }
   Ans = 0;
   scanf("%d",&N);
   if(N==0)break;
   for(int i=0;i<N;i++){
    int A,B;
    scanf("%d%d",&A,&B);
    G[A].push_back(B);
    G[B].push_back(A);
   }

   for(int i=1;i<=100;i++){
    if(!Vis[i]){
    Vis[i] =true;
    V[i] = true;
    DFS(i,1);
    V[i] = false;
    }
   }
//   printf("|%d|\n",Ans);
   for(int i=1;i<=100;i++){
    if(DP[i]==Ans){
        V[i] = true;
        DFS(i,1);
        V[i] = false;
        break;
    }
   }
   printf("%d\n",Ans);
  }while(true);
  }

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int power(int a, int b){ int S = 1; while(b--)S *= a; return S;}

int32_t main(){
	int n;
	cin >> n;
	int A[n];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	int m = A[0], s = 0;
	for(int i = 0; i < n; i++){
		m = min(m, A[i]);
		if(A[i] <= m){
			s++;
		}
	}
	cout << s;
	return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N;
    vector<int> D(N);
    rep(i, N) cin >> D[i];
    cin >> M;
    vector<int> T(M);
    rep(i, M) cin >> T[i];
    map<int, int> problems;
    rep(i, N) { problems[D[i]]++; }
    rep(i, M) {
        if(problems[T[i]] == 0) {
            cout << "NO" << endl;
            return 0;
        }
        problems[T[i]]--;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <bitset>

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = 2 * 100005;
const int MAX = 1000005;
bool has[MAX];
int n;
int a[MAXN];
bool can[MAX];
set<int> s;

int main() {
  for (int i = 0; i < MAX; i++) {
    can[i] = 1;
  }
	scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s.insert(a[i]);
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    bool good = 1;
    for (int j = 1; j * j <= a[i]; j++) {
      if (a[i] % j != 0) continue;
      if (has[j] && a[i] % j == 0) {
        good = 0;
        break;
      }
      if (has[a[i] / j] && a[i] % (a[i] / j) == 0) {
        good = 0;
        break;
      }
    }
    can[a[i]] &= good;
    has[a[i]] = 1;
  }
  int ans = 0;
  for (set<int>::iterator itr = s.begin(); itr != s.end(); itr++) {
    ans += can[*itr];
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 15176
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

//C++17
template<typename Type>
Type GCD(Type a,Type b){ return b ? GCD(b,a%b) : a ;}
template<typename Type>
Type LCM(Type a,Type b){ return a*b / GCD(a,b) ;}

template<typename Type>//文字列の置換/Boost:replace_all()
Type replace_str(Type str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n,k;cin >> n >> k;
    vector<int> a(n);
    vector<int> dp(n,INF);
    rep(i,n)cin >> a[i];
   dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j>=n)continue;
            dp[i+j] = min(dp[i+j],dp[i] + abs(a[i] - a[i+j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define MOD 1000000007

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    // dp[i][j] = # of permutations of i numbers that end on j
    long long dp[n][n];
    for (int i = 0; i < n; i++) dp[0][i] = 0; dp[0][0] = 1;
    long long pfx[n + 1];
    for (int i = 1; i < n; i++) {
        pfx[0] = 0;
        for (int j = 0; j < i; j++) pfx[j + 1] = (pfx[j] + dp[i - 1][j]) % MOD;
        for (int j = 0; j < i + 1; j++) {
            if (s[i - 1] == '<') dp[i][j] = pfx[j];
            else dp[i][j] = ((pfx[i] - pfx[j]) % MOD + MOD) % MOD;
        }
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) ans = (ans + dp[n - 1][i]) % MOD;
    cout << ans;
    return 0;
}


Measured memory_bytes: 70400
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  string s;
  cin >> s;
  for (auto&&c: s) {
    if (c == ',') cout << ' ';
    else cout << c;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{ return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{ return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, n) for (int i = 0; i < n; i++)


int main(void) {
  char s[10];

  scanf("%s", s);

  if (s[0] == 'S') printf("Cloudy\n");
  else if (s[0] == 'C') printf("Rainy\n");
  else printf("Sunny\n");
  return 0;
}


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

using namespace std;

double to_rad(int ang)
{
    return ang * acos(-1) / 180.0;
}

int main()
{
    double a, b, x = 0, y = 0, ang = 0;
    char c;
    while (cin >> a >> c >> b, (a != 0 || b != 0)) {
        x += a * sin(to_rad(ang));
        y += a * cos(to_rad(ang));
        ang += b;
    }
    cout << (int)x << endl << (int)y << endl;
    return 0;
}

Measured memory_bytes: 3464
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long a, b, n,x,ans;
	cin >> a >> b >> n;
	x = min(b-1,n);
	ans = (a * x) / b - a * (x / b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3588
n =int(input())

s=[]
ans=0
count=1

for i in range(n):
    s.append("".join(sorted(input())))

s.sort()
for i in range(n-1):
    if s[i] == s[i+1]:
        count=count+1
    else:
        ans=ans+count*(count-1)/2
        count=1

ans=ans+count*(count-1)/2

print(int(ans))
    


Measured memory_bytes: 10764
# tenka1-2019-beginnerC - Stones
def main():
    N, S = open(0).read().split()
    ans, blk = 0, 0
    for i in S:
        if i == "#":
            blk += 1
        else:
            if blk:
                ans += 1
                blk -= 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3376
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        n: usize,
        xs: [usize; n],
    }

    let middle_is_second = |ys: &[usize]| {
        (ys[0] <= ys[1] && ys[1] <= ys[2]) || (ys[2] <= ys[1] && ys[1] <= ys[0])
    };
    let ans = xs.windows(3).map(middle_is_second).filter(|x| *x).count();
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = s1.replace("2017/01", "2018/01");
		System.out.println(s2);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 22100
#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;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 long long    
#define vi                 vector<ll >
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define int                long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define inf                3223372036854775807
#define endl               '\n' 
#define PI                  3.14159265
#define N                  200005
ll n, m, k, a[N];
int dp1[N], dp[N][2];

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
    	string s;
    	cin >> s;
        n = sz(s);
        rep(i, 0, n)if(s[i] == '?')s[i] = 'D';
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;
string s,t;
void input();

void solve(){
    int cnt =0;

    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
}

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

    input();
    solve();

}

void input(){
    cin>>s>>t;
}


Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	ll a;
	long double b;
	cin>>a>>b;
	a*=b;
	a=(ll)a;
	printf("%lld\n",(ll)a);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3812
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
long long n,a,b,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) 
    {
            cin>>a>>b;
            ans+=b-a+1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	//"math"
	//"strings"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)
	if a == b {
		fmt.Print(a+b)
	}else if a > b{
		//max(a+b)/2 - 1
		fmt.Print(a*2-1)
	}else{
		fmt.Print(b*2-1)
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int A[N];
  for (int i=0;i<N;i++) cin>>A[i];
  int times=0;
  while(N>0){
    N-=K;
    times++;
    if (N<=0) break;
    N++;
  }
  cout<<times;
  return 0;
}


Measured memory_bytes: 640
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=A1+A2+A3
N=int(input())
ans=[0]*9
a='No'
for i in range(N):
    b=int(input())
    if b in A:
        ans[A.index(b)]=1
cheack=[ans[0:3],ans[3:6],ans[6:9],ans[0::3],ans[1::3],ans[2::3],ans[0::4],ans[2:7:2]]
for C in cheack:
    if sum(C)==3:
        a='Yes'
        break
print(a)

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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()


using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;


void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}


const double EPS = 1e-8;
const long long mod = 1e9+7;

const int dx[] = {0, 0,1,-1,1,-1, 1,-1};
const int dy[] = {1,-1,0, 0,1,-1,-1, 1};

const int N = 3e5 + 5;


int n,arr[N],k;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    map<int,int>cnt;
    for(int i = 0; i < n; ++i)
            cin >> arr[i] ,cnt[arr[i]]++;
    if(cnt.size() <= k){
        cout << 0 << '\n';
        return 0;
    }
    int r = cnt.size() - k;
    vector<int>v;
    for(auto i : cnt)
        v.push_back(i.second);
    sort(all(v));
    int ans = 0;
    for(auto i : v){
        ans+=i;
        r--;
        if(!r)break;
    }
    cout << ans << '\n';
    return 0;
}


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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N=2e5+1, mod= 1e9+7;


int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n;
	cin>>n;
	int a[n],res=0;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++)res+=a[i]*a[j];
	}
	cout<<res;
    yogeshk972();
}


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

int main( int argc, char *argv[] )
{
int x;
int y;
int G[] = { - 1, 0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 2, 0 };

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> x;
	cin >> y;
	if( G[ x ] == G[ y ] )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}




Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const n: number = parseInt(tmp[0].split(" ")[0]);
    const s: string = tmp[1].split(" ")[0];
    const m = s.match(/ABC/g);
    return `${m == null ? 0 : m.length}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s, t; cin >> s >> t;
	const int n = s.size(), m = t.size();

	int ans = 1 << 30;
	for(int i = 0; i < n - m + 1; i++) {
		int tmp = 0;
		for(int j = 0; j < m; j++) tmp += (s[i + j] != t[j]);
		ans = std::min(ans, tmp);
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

struct restaurant {
	int id;
	string cityname;
	int point;
};

int main(void) {
	// in
	int n;
	cin >> n;
	vector<restaurant> r(n);
	for(int i = 0; i < n; ++i) {
		string s;
		int p;
		cin >> s >> p;
		r[i].id = i + 1;
		r[i].cityname = s;
		r[i].point = p;
	}

	// sort
	sort(r.begin(), r.end(), [](restaurant &lhs, restaurant &rhs) {
		if(lhs.cityname == rhs.cityname) return lhs.point > rhs.point;
		else return lhs.cityname < rhs.cityname;
	});
	
	// out
	for(int i = 0; i < n; ++i) {
		cout << r[i].id << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import numpy as np
lis = []
fragone = False
fraglast = False
row,num = list(map(int,input().split()))
for i in range(row):
  lis.append(list(input()))
arr = np.array(lis)
for nikai in range(2):
  arr = arr[np.any(arr == "#",axis=1), :]
  arr = arr.T
for item in arr:
  print("".join(item))

Measured memory_bytes: 12620
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
    long long N, M;
    cin >> N >> M;
    vector<long long> L(M), R(M);
    for (int i = 0; i < M; i++) {
        cin >> L.at(i) >> R.at(i);
    }
    long long LMax = 0, RMin = 100000;
    for (int i = 0; i < M; i++) {
        if (L.at(i) > LMax) LMax = L.at(i);
        if (R.at(i) < RMin) RMin = R.at(i);
    }
    if (LMax > RMin) {
        cout << '0' << endl;
        return 0;
    }
    cout << RMin - LMax + 1 << endl;
    return 0;
}

Measured memory_bytes: 1920
buildings = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
space = '#' * 20

N = int(input())
for n in range(N):
    b,f,r,v = map(int, input().split())
    buildings[b-1][f-1][r-1] += v

i = 0
while 1:
  for floor in buildings[i]:
    residents =""
    for room in floor:
      residents += " " + str(room)
    print(residents)
  i += 1
  if i == 4:
    break 
  else:
    print(space)


Measured memory_bytes: 5608
def main():
    _ = int(input())
    a = list(map(int, input().split()))
    total = 0
    for i in range(len(a)-1):
        for j in range(i+1, len(a)):
            total += a[i]*a[j]
    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <cmath>
using namespace std;
#define fio ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int L[200005], R[200005];
int tree[2][505];
void update(int t,int i, int v) {
	while (i <= 501) {
		tree[t][i] += v;
		i += i & -i;
	}
}
int find(int t,int i) {
	int ret = 0;
	while (i) {
		ret += tree[t][i];
		i -= i & -i;
	}
	return ret;
}
int dp[505][505];
int inp[505][505];
int main() {
	int N, M, Q; scanf("%d %d %d", &N, &M, &Q);
	for (int i = 1;i <= M;i++) {
		scanf("%d %d", L + i, R + i);
		inp[L[i]][R[i]]++;
	}
	for (int i = 1;i <= N;i++) {
		for (int j = 1;j <= N;j++) {
			dp[i][j] = inp[i][j]+dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
		}
	}
	while (Q--) {
		int a, b;
		scanf("%d %d", &a, &b);
		int ret = dp[b][b] - dp[a - 1][b] - dp[b][a - 1] + dp[a - 1][a - 1];
		printf("%d\n", ret);
	}
	
}



Measured memory_bytes: 4480
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

bool isprime(int n){
    bool prime = true;
    for(int i = 2; i*i <= n; i++){
        if(n % i == 0){
            prime = false;
            break;
        }
    }
    return prime;
}

int main(){
    int N;
    cin >> N;
    int x = 11;
    REP(i,N){
        printf("%d ", x);
        while(1){
            x += 5;
            if(isprime(x)) break;
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

struct drug { ll a, b, c; };
signed main()
{
	ll n = in(), ma = in(), mb = in();
	vector<vector<vector<ll>>>dp(n + 1, vector<vector<ll>>(401, vector<ll>(401, INFLL)));
	dp[0][0][0] = 0;
	vector<drug>dr(n);
	REP(i, n) {
		ll a = in(), b = in(), c = in();
		dr[i] = { a,b,c };
	}
	REP(i, n) {
		REP(j, 401) {
			REP(k, 401) {
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				if (j + dr[i].a < 401 && k + dr[i].b < 401) {
					dp[i + 1][j + dr[i].a][k + dr[i].b] = min(dp[i + 1][j + dr[i].a][k + dr[i].b], dp[i][j][k] + dr[i].c);
				}
			}
		}
	}
	ll ans = INFLL;
	for (ll i = ma, j = mb; i < 401 && j < 401; i += ma, j += mb) {
		ans = min(ans, dp[n][i][j]);
	}
	cout << (ans == INFLL ? -1 : ans) << endl;
}

Measured memory_bytes: 53504