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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll x = x2 - x1, y = y2 - y1;
    PS(x2-y); PS(y2+x); PS(x1-y); PS(y1+x);


    return 0;
}

/*

x,y -> 

*/

Measured memory_bytes: 3620
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
const int MOD=1e9+7;
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); <-- PUT IN main()/solve()!

using namespace std;

int n;
class B81 {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		f(i,1,10)
			f(j,1,10)
				if(i*j==n)
				{
					out << "Yes\n";
					return;
				}
		out << "No\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	B81 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main(){
	int h,w;
	cin>>h>>w;
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	int ans[h][w];
	
	int x=0;
	int k=0;
	
	for(int i=0;i<w;i++){
		if(i%2==0){
			for(int j=0;j<h;j++){
				ans[j][i]=k;
				x++;
				if(x>=a[k]){
					x=0;
					k++;
				}
				//cout<<i<<" "<<j<<" "<<k<<endl;
			}
		}else{
			for(int j=h-1;j>-1;j--){
				ans[j][i]=k;
				x++;
				if(x>=a[k]){
					x=0;
					k++;
				}
				//cout<<i<<" "<<j<<" "<<k<<endl;
			}
		}
	}
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			cout<<ans[i][j]+1<<" ";
		}
		cout<<ans[i][w-1]+1<<endl;
	}
	
	return 0;
}

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

int n;
vector<int> dp(200010);
vector<int> ans(200010);
vector<int> a(200010);
vector<vector<int>> tr(200010);

void dfs(int v, int p=-1)
{
  int i = lower_bound(dp.begin(), dp.end(), a[v]) - dp.begin();
  int old = dp[i];
  dp[i] = a[v];
  ans[v] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
  for (int u : tr[v]) {
    if (u == p) continue;
    dfs(u, v);
  }
  dp[i] = old;
}

int main()
{
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  for (int i=0; i<n-1; i++){
    int u, v; cin >> u >> v; u--; v--;
    tr[u].push_back(v);
    tr[v].push_back(u);
  }
  rep(i, 200010) dp[i] = INF;
  dfs(0);
  for (int i=0; i<n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 27992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		ll a, b;
		cin>>a>>b;
		ll ans = a*b / __gcd(a,b);
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static int
solve(int N, int K)
{
  int d = 1;
  while (K <= N)
  {
    d++;
    N /= K;
  }
  return d;
}

int
main()
{
  int N, K;
  cin >> N >> K;
  cout << solve(N, K) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int a,b,c,d; cin >> a>>b>>c>>d;
    
    if((abs(b-a) <= d && abs(b-c) <= d) || abs(c-a) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    } 
    return 0;
}



Measured memory_bytes: 256
import java.util.*;


public class Main{
	public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int sum = 0;

        int n = sc.nextInt();
        int[] array = new int[n];
        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        int k = 1;
        for(int i = 0; i < n-1; i++){
            for(int j = 0; j < n-k; j++){
                sum += array[i] * array[i + j + 1];
            }
            k++;
        }
        System.out.print(sum);
    }
}

Measured memory_bytes: 23764
/* ex7_3:
    Jun_JPN */

#include <stdio.h>
#include <stdlib.h>

int main(void){

    int row_num, col_num, i, j;
    int row_flag[100] = {0}, col_flag[100] = {0};
    char **board;

    scanf("%d %d", &row_num, &col_num); // 行数，列数の順で値を取得

    /* メモリの動的確保 */
    board = (char**)malloc(sizeof(char*)*row_num);  // まず行数分(row_num個)のchar*型ポインタ配列を動的確保
    if(board == NULL){          // 動的確保できなかったらエラー表示
        fprintf(stderr, "memory allocation error.\n");
        exit(1);
    }
    for(i=0; i<row_num; i++){   // col_num個のchar型配列を各ポインタに対して動的確保
        board[i] = (char*)malloc(sizeof(char)*col_num);
        if(board[i] == NULL){   // 動的確保できなかったらエラー表示
            fprintf(stderr, "memory allocation error.\n");
            exit(1);
        }
    }

    /* 行列boardを'.'か'#'で初期化 */
    for(i=0; i<row_num; i++){           //　まずi行を固定
        for(j=0; j<col_num; j++){       // j列を動かしていく
            scanf(" %c", &board[i][j]); // (i, j)成分を入力
        }
    }

    for(i=0; i<row_num; i++){       // まずi行を固定
        for(j=0; j<col_num; j++){   // j列を動かしていく
            if(board[i][j]=='#'){   // 少なくとも１つ'#'を含む行・列に旗を立てる（＝1を代入していく）
                row_flag[i] = 1;
                col_flag[j] = 1;
            }
        }
    }

    for(i=0; i<row_num; i++){   // まずi行を固定
        if(row_flag[i]){        // 少なくとも１つ'#'がi行に含まれているとき（＝row_flag[i]に旗が立っているとき）
            for(j=0; j<col_num; j++){   // j列を動かしていく
                if(col_flag[j]){        // col_flag[j]に旗が立っているとき
                    printf("%c", board[i][j]);
                }
                if(j==col_num-1){       // i行の最後まで調べ終えたとき
                    printf("\n");
                }
            }
        }
    }

    /* メモリの解放 */
    for(i=0; i<row_num; i++){   // メモリ確保時とは逆順で
        free(board[i]);
    }
    free(board);

    return 0;
}

Measured memory_bytes: 1612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  map<ll,ll> m;
  for(int i = 0;i < 3;i++){
    ll n = 0;
    cin >> n;
    m[n]++;
  }
  cout << m.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

int main() {
    ll R, C;
    cin>>R>>C>>K;
    vector<mat> dp(R, mat(C, vec(4, 0)));
    mat value(R, vec(C, 0));
    rep(i,K){
        ll r, c, v;
        cin>>r>>c>>v;
        value[r - 1][c - 1] = v;
    }
    dp[0][0][1] = value[0][0];
    rep(i,R){
        rep(j, C){
            rep(k, 4){
                if(k == 0){
                    if(i != 0) chmax(dp[i][j][k], dp[i-1][j][3]);
                    if(j != 0) chmax(dp[i][j][k], dp[i][j-1][k]);
                }else{
                    chmax(dp[i][j][k], dp[i][j][k-1]);
                    if(j != 0) {
                        chmax(dp[i][j][k], max(dp[i][j-1][k], dp[i][j-1][k-1] + value[i][j]));
                    }
                    if(i != 0) chmax(dp[i][j][k], dp[i-1][j][3] + value[i][j]);
                }
            }
        }
    }
    cout<<dp[R-1][C-1][3]<<endl;
}

Measured memory_bytes: 706064
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf  1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int iwa[505][505][35]={};
signed main(){
    int n,c;cin>>n>>c;
    int po[35][55];
    rep(i,0,c)rep(j,0,c)cin>>po[i][j];
    int gri[505][505];
    rep(i,0,n)rep(j,0,n)cin>>gri[i][j];
    int sum[3][33]={};
    rep(i,0,n){
        rep(j,0,n){
            rep(k,0,c){
                sum[(i+j)%3][k]+=po[gri[i][j]-1][k];
            }
        }
    }
    int ans=434234;
    rep(i,0,c){
        rep(j,0,c){
            rep(k,0,c){
                if(i==j||j==k||i==k)continue;
                if(ans==434234)ans=sum[0][i]+sum[1][j]+sum[2][k];
                else ans=min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>
 
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	int num[101] = {0};

	int n, max = -1;
	while(cin >> n){
		num[n]++;
		if(num[n] > max){
			max = num[n];
		}
	}

	for(int i = 1; i <= 100; i++){
		if(num[i] == max){
			cout << i << endl;
		}
	}


	return 0;
}

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



signed main() {
  int n,k;cin>>n>>k;

  if(k%2)
  {
    cout << (n/k)*(n/k)*(n/k) << endl;
  }
  else
  {
    int kbai = n/k;
    int k2bai = n/(k/2) - kbai;

    cout << kbai*kbai*kbai + k2bai*k2bai*k2bai << endl;
  }
}


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

int main(){

  ll N,K;
  cin>>N>>K;
	

  ll A[N+1];
  ll done[N+1];
  rep(i,N){
    cin>>A[i+1];
    done[i+1]=0;
  }
  

  vector<int> v;
	
  done[1]=1;

  ll j=1;
  v.push_back(1);
  while(1){

    j=A[j];
    if(done[j]==2){break;}
    done[j]++;
    v.push_back(j);

  }
  
  ll S=v.size(); 
  //cout<<K<<" "<<S<<endl;
  if(K<S){cout<<v[K]<<endl;return 0;}

  ll count=0;
  ll count2=0;
  rep(i,N){
    if(done[i+1]==1)count++;
    if(done[i+1]==2)count2++;
  	//cout<<i+1<<" "<<done[i+1]<<endl;
  }
  //cout<<count<<endl;
  
  K-=count;
  ll d=(K%count2);
  //cout<<K<<" "<<count2<<" "<<d<<endl;
  cout<<v[d+count]<<endl;
  
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC145B()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	if (N % 2 == 1)
	{
		cout << "No" << endl;
		return;
	}
	int M = N / 2;
	string S1 = S.substr(0, M);
	string S2 = S.substr(M, M);
	if (S1 == S2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    vi v(3);
    scanf("%d %d %d %d", &v[0], &v[1], &v[2], &k);
    sort(all(v));
    rep(i, 1, k+1){
        v[2]*=2;
    }
    printf("%d",v[0]+v[1]+v[2]);
    return 0;
}

Measured memory_bytes: 3816
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,a[26]={0},cnt=0;
    string s;
    cin >>s;
    for(i=0;i<s.length();i++){
        a[s[i]-'A']++;
    }
    for(i=0;i<26;i++){
        if(a[i]==2){
            cnt++;
        }
    }
    if(cnt==2){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

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

int main() {
  int n;cin>>n;
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  int cnt=0,ans=1e9;
  rep(i,n){
    ans=min(ans,p[i]);
    if(ans==p[i])cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 4052
package main

import "fmt"

func main() {
	var a, b int64
	var k int
	fmt.Scan(&a, &b, &k)
	cookie := []int64{a, b}
	for i := 0; i < k; i++ {
		if cookie[i % 2] % 2 != 0 {
			cookie[i % 2] -= 1
		}
		cookie[i % 2] /= 2
		cookie[(i % 2 + 1) % 2] += cookie[i % 2]
	}
	fmt.Println(cookie[0], cookie[1])
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int A;
	int B;
	int T;
	cin >> A;
	cin >> B;
	cin >> T;

	int ans = 0;
	int tval = A;

	while (double(tval) < (double(T) + 0.5)) {
		ans += B;
		tval += A;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    cout << n*(n-1)/2 + n << endl;
    return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

const int maxn=1e5+7;
int nxt[maxn];
bool vis[maxn];
PII a[maxn],b[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i].first;
		a[i].second=i;
	}
	for(int i=0;i<n;i++) 
	{
		cin>>b[i].first;
		b[i].second=i;
	}
	sort(a,a+n);
	sort(b,b+n);
	int ok=1;
	for(int i=0;i<n;i++)
	{
		if(b[i].first<a[i].first) 
		{
			ok=0;
			break;
		}
		if(i&&b[i-1].first>=a[i].first) ok=2;
	}
	if(ok)
	{
		int cc=0;
		int cur=0;
		for(int i=0;i<n;i++)
			nxt[a[i].second]=b[i].second;
		while(!vis[cur])
		{
			vis[cur]=1;
			cc++;
			cur=nxt[cur];
		}
		if(cc<=n-1) cout<<"Yes\n";
		else if(cc==n&&ok==2) cout<<"Yes\n";
		else cout<<"No\n";
	}
	else{
		cout<<"No\n";
	}
}


Measured memory_bytes: 2304
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int s = 0;
	int i, j;
	int res = 1;
	int flag = 0;
	int N[10000];

	cin >> s;
	N[1] = s;
	while (1) {
		++res;
		if (N[res-1]%2 == 0)//sが偶数
		{
			N[res] = N[res-1] / 2;
		}
		else {
			N[res] = N[res-1]*3 + 1;
		}
		for (i = 0; i < res; ++i) {
			if (N[i] == N[res]) {
				++flag;
			}
		}
		if (flag == 1) {
			break;
		}
	}

	cout << res << endl;
}



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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int i,j,k,tmp;
ll ans = 0;

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

	int N; cin >> N;
	char C[N], D[N];
	int R=0,W=0;
	for(i=0;i<N;i++){cin >> C[i]; if(C[i]=='R'){R++;}else{W++;}}
	for(i=0;i<N;i++){if(i<R){D[i]='R';}else{D[i]='W';}}
	tmp=0;
	for(i=0;i<N;i++){if(C[i]!=D[i]){tmp++;}}

	cout << tmp/2 << endl;

  return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k,a; cin>>n>>k;
	map<int,int> ct;
	priority_queue<int> pq;
	while(n--)
		cin>>a, ct[a]++;
	for (auto it : ct)
		pq.push(it.second);
	while(!pq.empty() && k--)
		pq.pop();
	int ret=0;
	while(!pq.empty())
		ret+=pq.top(), pq.pop();
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;

const int mod = 1000003;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<mint> prod(mod), prodinv(mod);
    prod[0]=1;
    //prodinv[mod-1]=-1;
    rep2(i,1,mod)prod[i]=prod[i-1]*i;
    rep2(i,1,mod)prodinv[mod-i-1]=mint(mod-i)*prodinv[mod-i];
    //rep2(i,0,mod)prodinv[i]=prod[i].inv();
    ll q;cin>>q;
    rep(i,q){
        ll x,d,n;cin>>x>>d>>n;
        mint mx=mint(x),md=mint(d);
        if(d==0){cout<<mx.pow(n).x<<endl;continue;}
        mint aa = md.inv();
        mint l = mx*aa;
        mint r = (mx+md*(n-1))*aa;
        if(n>=mod||r.x<l.x){cout<<0<<endl;continue;}
        cout<<(prod[r.x]/prod[l.x-1]*md.pow(n)).x<<endl;

    }
    return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>
#include <map>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define printvec(vec)        \
    for (auto &&item : vec)  \
        cout << item << " "; \
    cout << endl

using namespace std;
using i64 = long long;

// 仮定が矛盾しないか判定
bool ishonest(int person, vector<int> const &honest_list, vector<map<int, int>> const &evidence)
{
    if (honest_list[person] == 0)
        return true;
    bool judge = true;
    for (auto &&mp : evidence[person])
    {
        if (honest_list[mp.first] != mp.second)
            judge = false;
    }
    return judge;
}

int recurse(int person, vector<int> &honest_list, vector<map<int, int>> const &evidence)
{
    if (person == evidence.size() - 1)
    {
        bool judge = true;
        int counter = 0;
        for (int i = 1; i <= evidence.size() - 1; i++)
        {
            judge &= ishonest(i, honest_list, evidence);
            if (!judge)
                return 0;
            if (honest_list[i] == 1)
                counter++;
        }
        return counter;
    }

    honest_list[person + 1] = 1;
    int honest = recurse(person + 1, honest_list, evidence);
    honest_list[person + 1] = 0;
    int unkind = recurse(person + 1, honest_list, evidence);
    return max(honest, unkind);
}

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

    vector<map<int, int>> evidence(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        for (int j = 1; j <= a; j++) // a-times
        {
            int x, y;
            cin >> x >> y;
            evidence[i][x] = y;
        }
    }

    int ans;

    // 仮定
    vector<int> honest_list(n + 1, -1);

    honest_list[1] = 1;
    int honest = recurse(1, honest_list, evidence);
    honest_list[1] = 0;
    int unkind = recurse(1, honest_list, evidence);
    ans = max(honest, unkind);

    cout << ans << endl;

    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  for (int i; i<101; i++) {
    C-=B;
    if(C<=0) {
      cout << "Yes" << endl;
      break;
    }
    A-=D;
    if(A<=0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1145141919
#define LLINF 1145148101919
#define PI 3.14159265359
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

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

string S, T;
int ctoi_alpha(char c)
{
    if (c >= 'a' && c <= 'z')
    {
        return c - 'a';
    }
    return 0;
}

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

int main()
{
    string S, T;
    cin >> S >> T;
    int ans=0;

    REP(i,3){
        if(S[i]==T[i]) ans++;
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a==b || a==c || c==b){
		if(a==b && b==c){
			printf("1");
		}
		
		else{
			printf("2");
			
		}
	}
	else{
		printf("3")
	;}

	
}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long max_ = -1000000000000000001;
  max_ = max(a * c, max_);
  max_ = max(a * d, max_);
  max_ = max(b * c, max_);
  max_ = max(b * d, max_);
  cout << max_ << endl;
}

Measured memory_bytes: 3632
x1, y1, x2, y2 = map(int, input().split())

a = x2 - x1
b = y2 - y1

x3 = x2 - b
x4 = x1 - b
y3 = y2 + a
y4 = y1 + a

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
/**/
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compile and get accepted.
 *      ____________
 *     /         __ \
 *    /   __    |  | \
 *   /   |__|   |  |  \
 *  (           |__|   )
 *   \                /
 *    \      ___     /
 *     \____________/
 *
 *
 */
const long long mod = 1000000007;

int BIT[500010];

void upd(int ind,int val) {
	while(ind < 500010) {
		BIT[ind] += val;
		ind |= (ind+1);
	}
}

long long get(int ind) {
	long long res = 0;
	while(ind >= 0) {
		res += BIT[ind];
		ind = (ind & (ind+1)) - 1;
	}
	return res;
}

long long fact[500010],inv[500010];

long long pow_mod(long long base,long long power) {
	long long res = 1;
	while(power) {
		if(power&1)
			res = res * base % mod;
		base = base * base % mod;
		power >>= 1;
	}
	return res;
}

void init() {
	fact[0] = fact[1] = inv[0] = inv[1] = 1;
	for(int i = 2;i < 500010;i++) {
		fact[i] = fact[i-1] * i % mod,inv[i] = pow_mod(fact[i],mod-2);
	}
}

inline void suM(long long & res, long long summand) {
	res += summand;
	if(res >= mod)
		res -= mod;
}

bool vis[500010];

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

	init();

	int N;
	cin>>N;
	vector<long long> P(N);
	vector<long long> toAdd;
	long long res = 0;
	long long unknown = 0,totalUnknown = 0,bigger = 0,with = 0,sumUnknown = 0;
	for(int i = 0;i < N;i++)
		cin>>P[i],totalUnknown += P[i] == 0,vis[P[i]] = true;

	for(int i = 1;i <= N;i++) {
		if(!vis[i]) {
			if(totalUnknown > 1) {
				suM(with,fact[totalUnknown - 2] * toAdd.size() % mod);
			}
			if(totalUnknown) {
				suM(sumUnknown,(i-1) * fact[totalUnknown - 1] % mod);
			}
			toAdd.push_back(i);
		}
	}

	for(int i = 0;i < N;i++) {
		long long cur = 0;
		if(P[i] != 0) {
			suM(cur,fact[totalUnknown] * get(P[i]) % mod);
			if(totalUnknown) {
				cur = (cur + (unknown * fact[totalUnknown - 1] % mod) 
						* (lower_bound(toAdd.begin(),toAdd.end(),P[i]) - toAdd.begin())) % mod;
				suM(bigger,fact[totalUnknown - 1] * (toAdd.end() - upper_bound(toAdd.begin(),toAdd.end(),P[i])) % mod);
			}
			cur = (fact[totalUnknown] * (P[i] - 1ll) + mod - cur)%mod;
			upd(P[i],1);
		}else {
			suM(cur,bigger);
			suM(cur,with * unknown%mod);
			cur = (sumUnknown + mod - cur)%mod;
			unknown++;
		}
		cur = cur * fact[N-i-1] % mod;
//		cerr<<cur<<'\n';
		suM(res,cur);
	}

	suM(res,fact[totalUnknown]);
	cout<<res<<'\n';

	return 0;
}
/**/


Measured memory_bytes: 18028
#include <stdio.h>
#include <string.h>
 
#define Max 500000
 
void insert(int); 
void find(int, int);
int successor(int);
void delete(int);
void Preorder(int);    /* ??????????????? */
void Inorder(int);     /* ??????????????? */
 
 
typedef struct{    /* p = parent, l = child, s = brother */
  int key;
  int p;
  int l[2];
} Node;
 
Node T[Max];
 
int main(){
  int i, n, k;
  char s[7];
 
  scanf("%d", &n);
 
  T[0].key = -1;
 
  
  for(i = 0; i < n; i++){
    T[i].l[0] = -1;
    T[i].l[1] = -1;
 
    scanf("%s", s);
 
    if(strcmp(s, "insert") == 0){
      scanf("%d", &T[i].key);
      insert(i);
    }
    else if(strcmp(s, "print") == 0){
      Inorder(0);
      printf("\n");
      Preorder(0);
      printf("\n");
    }
    else if(strcmp(s, "find") == 0){
      scanf("%d", &k);
      find(0, k);
    }
    else if(strcmp(s, "delete") == 0){
      scanf("%d", &k);
      delete(k);
    }
  }
   
  return 0;
}
 
 
void insert(int z){
  int x, y;
 
  y = -1;
  x = 0;
 
  if(z != 0){
    while(x != -1){
      y = x;
      if(T[z].key < T[x].key) x = T[x].l[0];
      else x = T[x].l[1];
    }
  }
 
  T[z].p = y;
 
  if(y != -1){
    if(T[z].key < T[y].key) T[y].l[0] = z;
    else T[y].l[1] = z;
  }
}
 
void find(int x, int k){
 
  if(x == -1) printf("no\n");
  else if(T[x].key == k) printf("yes\n");
  else if(k < T[x].key) find(T[x].l[0], k);
  else find(T[x].l[1], k);
}
 
int successor(int x){
  int y;
 
  if(T[x].l[1] != -1){
    x = T[x].l[1];
    while(T[x].l[0] != -1) x = T[x].l[0];
    return x;
  }
   
  else {
    y = T[x].p;
    while(y != -1 && x == T[y].l[1]){
      x = y;
      y = T[y].p;
    }
    return y;
  }
}
 
void delete(k){
  int x, y, z = 0;
 
  while(1){
    if(T[z].key == k) break;
    else if(k < T[z].key) z = T[z].l[0];
    else z = T[z].l[1];
  }
 
  if(T[z].l[0] == -1 || T[z].l[1] == -1) y = z;
  else y = successor(z);
 
  if(T[y].l[0] != -1) x = T[y].l[0];
  else x = T[y].l[1];
 
  if(x != -1) T[x].p = T[y].p;
 
  if(T[y].p != -1){
    if(y == T[T[y].p].l[0]) T[T[y].p].l[0] = x;
    else T[T[y].p].l[1] = x;
  }
 
  if(y !=  z) T[z].key = T[y].key;
 
}
 
 
void Preorder(int a){
  printf(" %d", T[a].key);
 
  if(T[a].l[0] != -1) Preorder(T[a].l[0]);
  if(T[a].l[1] != -1) Preorder(T[a].l[1]);
}
 
 
void Inorder(int a){
  if(T[a].l[0] == -1){
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
  else{
    Inorder(T[a].l[0]);
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
}

Measured memory_bytes: 8428
#include <bits/stdc++.h>
#define sc(x) scanf("%lld", &x)
#define pr(x) printf("%d\n", x)
#define lowbit(x) (x & -x)
#define N 100010
#define memset(x) memset(x, 0, sizeof(x))
using namespace std;
const int mod = 1e9 + 7, maxx = 1e6;
long long n, m, q[N], p = 0;
long long ans = 1, f[maxx + 1], g[maxx + 1];
long long Pow(long long a, long long b)
{ 
	long long t = 1;
    while (b) 
	{
        if (b & 1) t = t * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return t;
}
void prework()
{
	f[0] = 1;
	for (int i = 1; i <= maxx; i++)
	f[i] = f[i - 1] * i % mod;
	g[0] = 1;
	g[maxx] = Pow(f[maxx], mod - 2);
	for (int i = maxx - 1; i >= 1; i--)
	g[i] = g[i + 1] * (i + 1) % mod;
}
long long C(long long a, long long b)
{
	long long t = ((f[a] * g[a - b]) % mod * g[b]) % mod;
	return t;
}
int main()
{
	sc(n);
	sc(m);
	prework();
	long long k = sqrt(m);
	for (int i = 2; i <= k; i++)
	{
		if (m % i == 0)
		{
			q[++p] = 0;
			while (m % i == 0)
			{
				q[p]++;
				m /= i;
			}
		}
	}
	for (int i = 1; i <= p; i++)
	ans = (ans * C(q[i] + n - 1, n - 1)) % mod;
	if (m != 1) ans = ans * n % mod;
	printf("%lld\n", ans);
	return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x,ll y,ll m) 
{
    ll res = 1; 
    x = x % m;                
    if (x == 0)
        return 0; 
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

ll gcd(ll a,ll b) 
{
    if(b==0) return a;
    return gcd(b,a%b);
}
vector<vector<int>> a(50,vector<int>(4));
int n, m, q,ans=0;
vector<int> b;
void fun(int size,int j) {
    
    if(size==n) {
        int val=0;
        for(int i=0;i<q;i++) {
            if(b[a[i][1]-1]-b[a[i][0]-1]==a[i][2]) {
                val+=a[i][3];
            }
        }
        ans=max(val,ans);
        return;
    }

    for(int i=j;i<=m;i++) {
        b.pb(i);
        fun(size+1,i);
        b.pop_back();
    }

}
void solve()
{
    
    cin>>n>>m>>q;
    for(int i=0;i<q;i++) {
        for(int j=0;j<4;j++) {
            cin>>a[i][j];
        }
    }
    fun(0,1);
    cout<<ans;

}

int main()
{
    fastio;
    int t;
    t=1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout<<newl;
    }

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <cmath>

int a()
{
    int a, b = 0;
    std::cin >> a >> b;

    struct Condition
    {
        int digit;
        int num;
    };
    
    std::vector<Condition> input;
    for(int i = 0; i < b; i++)
    {
        Condition temp;
        std::cin >> temp.digit >> temp.num;
        input.push_back(temp);
    }
    
    std::vector<int> ans(a, -1);
    bool noAns = false;
    for(int i = 0; i < b; i++)
    {
        auto myValue = input[i];
        if(a < myValue.digit)
        {
            noAns = true;
            break;
        }
        
        // 頭が0のやつは除くが、1桁の場合は0でもOK
        if(myValue.digit == 1 && myValue.num == 0 && 2 <= a)
        {
            noAns = true;
            break;
        }
        
        int index = myValue.digit -1;
        if(ans[index] == -1)
        {
            ans[index] = myValue.num;
        }
        else
        {
            if(ans[index] != myValue.num)
            {
                noAns = true;
                break;
            }
        }
    }
    
    int ansVal = -1;
    if(!noAns)
    {
        ansVal = 0;
        for (int i = 0; i < a; i++)
        {
            if(ans[i] == -1)
            {
                if(1 < a && i == 0)
                {
                    ans[i] = 1;
                }
                else
                {
                    continue;
                }
            }
            ansVal += ans[i] * std::pow(10, a-i-1);
        }
    }
    
    std::cout << ansVal;
    return 0;
}

int main(int argc, const char * argv[])
{
    // insert code here...
    a();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;


int main() {
    llong n = 0;
    char ch;

    while ((ch = getchar()) != '\n') {
        if (ch == '+') n++;
        else n--;
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

fun pow(a: Long, p: Int): Long = when {
    p == 0 -> 1L
    p % 2 == 1 -> a * pow(a, p - 1)
    else -> {
        val half = pow(a, p / 2)
        half * half
    }
}

object Problem {
    lateinit var dfs: (Int, Int) -> Unit

    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val X = sc.next().toLong()
        val Y = sc.next().toLong()

        for (i in 0..60) {
            if (X * pow(2, i) > Y) {
                pw.println(i)
                break
            }
        }
    }
}


Measured memory_bytes: 31272
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0: break
    for i in range(H):
        for j in range(W):
            if i == 0 or j == 0 or i == H - 1 or j == W - 1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7008
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;
inline int read(){
	int re = 0,ch = getchar();
	while(!isdigit(ch))ch = getchar();
	while(isdigit(ch))re = (re<<1)+(re<<3)+ch-'0',ch = getchar();
	return re;
}
const int maxn = 200010;
struct edge{
	int v,w,nxt;
}e[maxn];
int h[maxn],cnt;
inline void add(int u,int v,int w){
	e[++cnt].v = v;
	e[cnt].w = w;
	e[cnt].nxt = h[u];
	h[u] = cnt;
}
inline int color(int c){
	if(c >= 3)c -= 3;
	if(c < 0)c += 3;
	return c;
}
int col[maxn],cnum[3],nsz,esz;
bool flag = 1,vis[maxn];
void coloring(int u){
	cnum[col[u]]++;nsz++;vis[u] = 1;
	for(int i = h[u];i;i = e[i].nxt){
		int v = e[i].v;
		if(e[i].w == 1)esz++;
		if(!vis[v]) col[v] = color(col[u] + e[i].w),coloring(v);
		else if(col[v] != color(col[u] + e[i].w)) flag = 0;
	}
}
int n,m;
long long ans;
int main(){
	n = read(),m = read();
	int u,v;
	for(int i = 1;i <= m;i++){
		u = read(),v = read();
		add(u,v,1);
		add(v,u,-1);
	}
	for(int i = 1;i <= n;i++){
		if(vis[i])continue;
		memset(cnum,0,sizeof(cnum));
		nsz = 0,esz = 0,flag = 1;
		coloring(i);
		if(!flag) ans += (long long)nsz * nsz;
		else if(cnum[0] && cnum[1] && cnum[2]) 
			ans += (long long)cnum[0] * cnum[1]
			 + (long long)cnum[1] * cnum[2] + (long long)cnum[2] * cnum[0];
		else ans += esz;
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 6656
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace ProCon2
{
    class Program
    {
        static void Main(string[] args)
        {
            var val = int.Parse(Console.ReadLine());
            Console.WriteLine(val+val*val+val*val*val);

        }


    }

}


Measured memory_bytes: 27456
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;

    ll x=n/(a+b);
    ll y=n%(a+b);

    ll ans=x*a;

    if(y-a>0){
        ans+=a;
    }else{
        ans+=y;
    }
    cout<<ans<<endl;
}

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

int main() {
    ll N;
    cin >> N;
    vector<pair<ll,ll>> R;
    for(int i=0;i<N;i++){
        ll X,L;
        cin >> X >> L;
        R.emplace_back(X-L,X+L);
    }
    sort(R.begin(),R.end());
    set<ll> removed;
  
    for(int i=0;i<N;i++){
        if(removed.find(i) != removed.end()){
            continue;
        }
        ll t= i+1;
        while(t<N && R[t].first < R[i].second){
            if(removed.find(t) != removed.end()){
                t++;
                continue;
            }
            if(R[i].second < R[t].second){
                removed.insert(t);
                t++;
            }else{
                removed.insert(i);
                break;
            }
        }
    }
    cout <<N -removed.size() << endl;

    return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>

const char *p;
class ParseError {};

int expression();
int term();
int factor();
void consume(char);

int main() {
  using namespace std;

  int n;
  string str;
  int ans;

  cin >> n;
  cin.ignore();
  for(int i = 0; i < n; i++) {
    getline(cin, str);
    p = str.c_str();
    ans = expression();
    consume('=');
    cout << ans << endl;
  }
  
  return 0;
}

void consume(char expected) {
  if(*p == expected) {
    p++;
  } else {
    std::cerr << "Expected '" << expected << "' but got '" << *p << "'" << std::endl;
    std::cerr << "Rest string is '";
    while(*p) {
      std::cerr << *p++;
    }
    std::cerr << "'" << std::endl;
    throw ParseError();
  }
}

int factor() {
  int ret;
  char *e;
  
  if(*p == '(') {
    consume('(');
    ret = expression();
    consume(')');
  } else {
    ret = strtol(p, &e, 10);
    p = e;
  }
  
  return ret;
}

int term() {
  int ret = factor();
  
  for(;;) {
    if(*p == '*') {
      p++;
      ret *= factor();
    } else if (*p == '/') {
      p++;
      ret /= factor();
    } else {
      break;
    }
  }

  return ret;
}

int expression() {
  int ret = term();
  
  for(;;) {
    if(*p == '+') {
      p++;
      ret += term();
    } else if (*p == '-') {
      p++;
      ret -= term();
    } else {
      break;
    }
  }
  
  return ret;
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using namespace std;

void Main()
{
   int t;
   int ans = 0;
   int min = 10;
   for (int i = 0; i < 5; i++)
   {
      cin >> t;
      if (t % 10 == 0)
         ans += t;
      else
      {
         if (min > t % 10)
            min = t % 10;
         ans += (t / 10 + 1) * 10;
      }
   }
   cout << (ans - 10 + min) << endl;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INFTY 2000000000
int cnt;
void merge(int A[500000],int left,int mid,int right){
  int n1,n2,i,j,k,L[500000],R[500000];
  n1=mid-left;
  n2=right-mid;

  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
    }
  }
}
void mergeSort(int A[500000],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
int main(){
  int n,S[500000],i;
  cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",cnt);
  return 0;
}



Measured memory_bytes: 6476
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(void){
  int in=0,l=0;
  string s;
  vector<int>v[101];

  while(getline(cin,s)){
    for(int i=0;i<=s.size();i++){
      if(s[i]==',' || i==s.size())v[l].push_back(in),in=0;
      else if(s[i]!=',')in*=10,in+=s[i]-'0'; 
    }
    l++;
  }

  int dp[101][101];

  fill(dp[0],dp[101],0);
   dp[0][0]=v[0][0];

  for(int i=1;i<l;i++){
    for(int j=0;j<v[i].size();j++){
      dp[i][j]=dp[i-1][j]+v[i][j];
      if(i<=l/2 && j)dp[i][j]=max(dp[i][j],dp[i-1][j-1]+v[i][j]);
      if(i>l/2)dp[i][j]=max(dp[i][j],dp[i-1][j+1]+v[i][j]);
    }
  }
  cout << dp[l-1][0] << endl;

  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
using namespace std;
int main(){
int a,b;
while(true)
{
   cin>>a>>b;
   if(a==0 && b==0) break;
   else{
   if(a>b) cout<<b<<" "<<a<<endl;
   else cout<<a<<" "<<b<<endl;
}
}
return 0;
}

Measured memory_bytes: 3048
#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() {
	int a, b; scanf("%d%d", &a, &b);

	std::vector<int> ans = {1, 2, 3};
	for(auto v: ans) {
		if(v == a or v == b) continue;
		printf("%d\n", v);
		break;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n; cin >> n;
  string frag = "No";
  for(int i = 1; i<10; i++){
    if(n%i == 0 && n/i > 0 && n/i < 10){
      frag = "Yes";
    }
  }
  cout << frag << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int x, y, z, K;
    cin >> x >> y >> z >> K;
    VL a(x), b(y), c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];

    sort(rall(a));
    sort(rall(b));
    sort(rall(c));

    priority_queue<pair<ll, tuple<int, int, int>>> pq;
    VL ans;
    set<tuple<int, int, int>> st;
    st.insert(tuple(0, 0, 0));
    pq.push(pair(a[0] + b[0] + c[0], tuple(0, 0, 0)));
    while((int)ans.size() <= K){
        auto p = pq.top(); pq.pop();
        int i = get<0>(p.second);
        int j = get<1>(p.second);
        int k = get<2>(p.second);
        ans.push_back(p.first);

        if (i + 1 < x && st.find(tuple(i+1, j, k)) == st.end()){
            pq.push(pair(a[i+1] + b[j] + c[k], tuple(i+1, j, k)));
            st.insert(tuple(i+1, j, k));
        }
        if (j + 1 < y && st.find(tuple(i, j+1, k)) == st.end()){
            pq.push(pair(a[i] + b[j+1] + c[k], tuple(i, j+1, k)));
            st.insert(tuple(i, j+1, k));
        }
        if (k + 1 < z && st.find(tuple(i, j, k+1)) == st.end()){
            pq.push(pair(a[i] + b[j] + c[k+1], tuple(i, j, k+1)));
            st.insert(tuple(i, j, k+1));
        }
    }

    rep(i,K) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4160