akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<cstdio>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>>a(H, vector<int>(W, 0));
	int odd = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> a[i][j];
			if (a[i][j] & 1)odd++;
		}
	}
	vector<piii>res;
	int num = 0;
	int x = 0, y = 0;
	for (int iter = 0; iter < W*H; ++iter) {
		if (a[x][y] & 1) ++num;

		int nx = x, ny = y;
		if (x % 2 == 0) {
			if (ny == W - 1)++nx;
			else ++ny;
		}
		else {
			if (ny == 0)++nx;
			else --ny;
		}
		if (num & 1)if (num < odd)res.push_back(piii(pii(x, y), pii(nx, ny)));
		x = nx, y = ny;
	}
	cout << res.size() << endl;
	for (auto p : res) {
		cout << p.first.first + 1 << " " << p.first.second + 1 << " " << p.second.first + 1 <<
			" " << p.second.second + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5232
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	map<string, bool> m;
	int n; cin >> n;
	int ans = 0;
	rep(i, n) {
		string s; cin >> s;
		if (m.find(s) == m.end()) {
			m[s] = 0;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 19200
H,W,K=map(int,input().split())
C=[input() for _ in range(H)]
ans=0
for i in range(2**H):
  for j in range(2**W):
    c=0
    for ii in range(H):
      for jj in range(W):
        if (i>>ii)&(j>>jj)&1:
          if C[ii][jj]=='#':
            c+=1
    if c==K:
      ans+=1
print(ans)

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

const int mxN = 1e5 + 5;
int a[mxN];

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	int best = -1, cnt = 0;
	for(int i = n; i; --i) {
		if(a[i] >= a[i + 1])
			++cnt;
		else
			cnt = 1;
		best = max(best, cnt);
	}
	cout << best - 1;
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  char f='a';
  cin >> a >> b >> c;
  while(1){
    if(f == 'a'){
      f = a[0];
      if(a == ""){
        cout << 'A';
        break;
      }
      a.erase(a.begin());
    }
    if(f == 'b'){
      f = b[0];
      if(b == ""){
        cout << 'B';
        break;
      }
      b.erase(b.begin());
    }
    if(f == 'c'){
      f = c[0];
      if(c == ""){
        cout << 'C';
        break;
      }
      c.erase(c.begin());
    }
  }
}


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

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

    map<string, ll> count;
    for(int i = 0; i < N; i ++){
        string s; cin >> s;
        sort(s.begin(), s.end());
        count[s]++;
    }

    ll sum = 0;
    for(auto e:count){
        ll tmp = e.second * (e.second - 1) / 2;
        sum += tmp;
    }

    cout << sum << endl;

}

Measured memory_bytes: 11136
#include <iostream>
#include <string>

int main()
{
	int n;
	int ans = 0;
	std::string s;
	std::cin >> n;
	std::cin >> s;
	for (int i = 0; i < 1000; i++)
	{
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int find = 0;
		for (int x = 0; x < n; x++)
		{
			if (s[x] == (c[find] + '0'))
				find++;
			if (find == 3)
				break;
		}
		if (find == 3)
			++ans;
	}
	std::cout << ans << '\n';
	return 0;
}


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

a_s = input().split()
for i in range(n):
    a_s[i] = int(a_s[i])

cnt = 0
flag = True
while flag:
    for i in range(n):
        a_s[i] = a_s[i]/2
        if a_s[i]%1 == 0.5:
            print(cnt)
            flag = False
            break
        
    cnt += 1


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

	public static long ans = 0;

	public static void main(String[] args) {

//		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		long a = sc.nextLong();
		long b = sc.nextLong();

//		int n = sc.nextInt();


		//-------------------------------------------------------------------------------------

		ans = -1;
		for(int i = 0; i < 20000; i++) {
			double tmpa = Math.floor(i * 0.08);
			double tmpb = Math.floor(i * 0.1);
			if(tmpa == a && tmpb == b) {
				ans = i;
				break;
			}
		}

		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 35544
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r, g, b, n; cin >> r >> g >> b >> n;
  ll ans = 0;
  for(int i=0; i<=n/r; i++) {
    for(int j=0; j<=(n-i*r)/g; j++) {
      if((n-i*r-j*g)%b==0) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e6;

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

    cout<<a*b/2<<endl;
}

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

using namespace std;

pair<int,int>a[1000000];
int main(){
	long long n,q;
	int dig=0;
	scanf("%lld",&n);
	for(int i=sqrt(double(n));i>0;i--){
		if(n%i==0){
			q=n/i;
			break;
		}
	}
	while(q!=0){
		q/=10;
		dig++;
	}
	printf("%d",dig);
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
ll a[345678], x[3456][3456], y[3456][3456];
signed main() {
	ll n, ans = 0; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a[h];
		for (int i = 0; i < a[h]; i++) {
			cin >> x[h][i] >> y[h][i];
			x[h][i]--;
		}
	}
	for (int i = 0; i <= (1 << n); i++) {
		vector<ll> sep = { }; ll ng = 0; vector <ll> ok(20);
		for (int j = 0; j <= n - 1; j++) {
			if ((i & (1 << j)) > 0) {
				sep.push_back(j); ok[j] = 1;
			}
		}
		if (sep.size() == 0) { continue; }
		for (int h = 0; h < sep.size(); h++) {
			for (int j = 0; j < a[sep[h]]; j++) {
				if (y[sep[h]][j] == 1) {
					if (ok[x[sep[h]][j]] == 0) { ng++; }
				}
				if (y[sep[h]][j] == 0) {
					if (ok[x[sep[h]][j]] == 1) { ng++; }
				}
			}
		}
		if (ng == 0) { ans = max(ans, (ll)sep.size()); }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4352
N, A = gets.split.map(&:to_i)
X = gets.split.map(&:to_i).sort

dp = Array.new(60) { Array.new(3000, 0) }
dp[0][0] = 1

X.each_with_index do |x, i|
  i.downto(0) do |j|
    0.upto((N + 1) * A + 1) do |v|
      dp[j + 1][v + x] += dp[j][v]
    end
  end
end

ans = 0

(1..N).each do |i|
  ans += dp[i][A * i]
end

puts ans


Measured memory_bytes: 3196
d={'A': 'X', 'C': 'Z', 'B': 'Y', 'E': 'B', 'D': 'A', 'G': 'D', 'F': 'C', 'I': '\
F', 'H': 'E', 'K': 'H', 'J': 'G', 'M': 'J', 'L': 'I', 'O': 'L', 'N': 'K', 'Q': \
'N', 'P': 'M', 'S': 'P', 'R': 'O', 'U': 'R', 'T': 'Q', 'W': 'T', 'V': 'S', 'Y':\
 'V', 'X': 'U', 'Z': 'W'}
s=raw_input()
t=""
for c in s:
    t+=d[c]
print t

Measured memory_bytes: 4248
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>

using namespace std;

int main()
{
  double a;
  while (scanf("%lf ", &a) == 1) {
    double cur = a;
    double sum = a;
    for (int i = 0; i < 9; i++) {
      if (i % 2 == 0) {
	sum += cur * 2;
	cur *= 2;
      } else {
	sum += cur / 3;
	cur /= 3;
      }
    }
    printf("%lf\n", sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MAX = 3000000;
const ll MOD = 1000000007;
//string s;
ll n,x,y;

int main() {
    cin >> n >> x >> y;
    ll count[n];
    for(ll i=0;i<n;i++){
        count[i] = 0;
    }
    for(ll i=1;i<n;i++){
        for(ll j=i+1;j<=n;j++){
            ll dist1 = j-i;
            ll routex = (i<=x)?x-i:i-x;
            ll routey = (j<=y)?y-j:j-y;
            ll dist2 = routex+1+routey;
            ll dist = (dist1<dist2)?dist1:dist2;
            //cout << i << ' ' << j << ' ' << dist << endl;
            count[dist]++;
        }
    }
    for(ll i=1;i<n;i++){
        cout << count[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define N 400
using namespace std;
int n,ma,mb,mn=1e9,a,b,c,x[415][415];
int main() {
	int i,j;
	cin>>n>>ma>>mb;
	for(i=0; i<=N; i++) for(j=0; j<=N; j++) x[i][j] = 1e9;
	x[0][0] = 0;
	while(n--) {
		cin>>a>>b>>c;
		for(i=N; i>=0; i--) for(j=N; j>=0; j--) {
			if(x[i][j]<1e9) {
				x[i+a][j+b] = min(x[i+a][j+b], x[i][j]+c);
			}
		}
	}
	for(i=0; i<N; i++) for(j=0; j<N; j++) {
		if(i==0 && j==0) continue;
		if(i%ma==0 && j%mb==0 && i*mb==j*ma)
			mn = min(mn, x[i][j]);
	}
	if(mn == 1e9) cout<<-1;
	else cout<<mn;
	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<string> vec(n);  
  for (int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for (int i = 0; i < n; i++){
    cout << vec.at(i);
  }
  cout << endl;
}

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

int main() {
  string s;
  while(cin >> s && s!="0") {
    int a=0, b=0;
    for(int i=1; i<s.size(); i++) {
      if(s[i]=='A') a++;
      else b++;
    }
    if(a>b) a++;
    else b++;
    cout << a << " " << b << endl;
  }
  return 0;
}


Measured memory_bytes: 1184
res = 7
cnt = 1
k = int(input().rstrip())
res_list = [0 for _ in range(k)]
flg = 0
while True:
  res %= k
  if res == 0:
    flg = 1
    break
  if res_list[res] == 1:
    break
  res_list[res] = 1
  cnt += 1
  res = res * 10 + 7
if flg == 1:
  print(cnt)
else:
  print(-1)
  

Measured memory_bytes: 16892
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int power(int n, int k) {
    if(k == 0) {
        return 1;
    }
    if(k & 1) {
        return power(n, k - 1) * n;
    } else {
        int t = power(n, k / 2);
        return t * t;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> X(N), Y(N), P(N);
    for(int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i] >> P[i];
    }
    // 前計算
    vector pre1((1 << N), vector(N, LLINF));
    vector pre2((1 << N), vector(N, LLINF));
    {
        for(int bit = 0; bit < (1 << N); bit++) {
            for(int i = 0; i < N; i++) {
                ll tmp1, tmp2;
                tmp1 = tmp2 = min(llabs(X[i]), llabs(Y[i]));
                for(int j = 0; j < N; j++) {
                    if(bit & (1 << j)) {
                        chmin(tmp1, llabs(Y[i] - Y[j]));
                        chmin(tmp2, llabs(X[i] - X[j]));
                    }
                }
                chmin(pre1[bit][i], tmp1);
                chmin(pre2[bit][i], tmp2);
            }
        }
    }
    vector<ll> ans(N + 1, LLINF);
    int limit = power(3, N);
    vector<int> v(N);
    for(int bit = 0; bit < limit; bit++) {
        int tmp = bit;
        for(int i = 0; i < N; i++) {
            v[i] = tmp % 3;
            tmp /= 3;
        }
        // 0:線はひかれていない
        // 1:X軸に平行な線が引かれている
        // 2:Y軸に平行な線が引かれている
        int cnt = 0;
        int bit1 = 0, bit2 = 0;
        for(int i = 0; i < N; i++) {
            if(v[i] == 1) {
                cnt++;
                bit1 |= (1 << i);
            } else if(v[i] == 2) {
                cnt++;
                bit2 |= (1 << i);
            }
        }
        ll res = 0;
        for(int i = 0; i < N; i++) {
            res += P[i] * min(pre1[bit1][i], pre2[bit2][i]);
        }
        chmin(ans[cnt], res);
    }
    for(auto i : ans) {
        cout << i << "\n";
    }
}

Measured memory_bytes: 12924
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));

  int k = 0;
  int kd = 2000000000;
  rep(i,N-1){
    int x = abs(v[N-1] - v[i]*2);
    if(kd > x){
      k = v[i];
      kd = x;
    }
  }
  
  cout << v[N-1] << " " << k << endl;
  
  
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,H,W;
    cin>>N>>H>>W;
    int count =0;
    for(int i=1;i<=N;i++){
        int A,B;
        cin>>A>>B;
        if(H<=A&&W<=B){
            count++;
        }
    }
    cout<<count<<endl;
 
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  auto * const h = &H[0];
  for (int i = 0; i < N; ++i)
    cin >> h[i];
  int max = 0;
  int count = 0;
  for (int i = 0; i < N - 1; ++i)
  {
    if (h[i] < h[i + 1])
    {
      if (max < count)
        max = count;
      count = 0;
    }
    else
      ++count;
  }
  if (max < count)
    max = count;
  cout << max;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
#define ld long double
 
using namespace std;
 
const int N = 5e5 + 123;
const ll mod = 1e9 + 7;

string s;
ll d, sum;
ll dp[110][10010], res;
ll steps[10010];

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

	cin >> s >> d;
	
	steps[0] = 1;
	for(int i = 1;i <= 10000;i++)
		steps[i] = steps[i - 1] * 10 % d;


	
	dp[0][0] = 1;
	for(int i = 0;i <= 10000;i++){
		for(int j = 0;j < d;j++){
			for(int k = 0;k < 10;k++){
				dp[(j + k) % d][i + 1] = (dp[(j + k) % d][i + 1] + dp[j][i]) % mod;
			}
		}
	}
	//cout << dp[0][1] << "\n";
	for(int i = 0;i < (int)s.size();i++){
		for(int j = 0;j < s[i] - '0' + (i == ((int)s.size() - 1));j++){
			ll need = (j + sum) % d;// * steps[(int)s.size() - i - 1] % d;
	//		cerr << need << "\n";
			need = (d - need) % d; 
	//		cerr << need << " " << i << "\n";
			res = (res + dp[need][(int)s.size() - i - 1]) % mod;
			if(j == 0 && i == 0)
				res = (res - 1 + mod) % mod;
		}
	//	cerr << res << "=\n";
		sum += s[i] - '0';
	}
	cout << res;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,m,x,a[13][13],c[13],ans=hell;
void solve(){
    cin>>n>>m>>x;
    rep(i,0,n){
    	cin>>c[i];
    	rep(j,0,m){
    		cin>>a[i][j];
    	}
    }
    rep(i,0,1<<n){
    	int w=0,f[13]={0};
    	rep(j,0,n){
    		if((i>>j)&1){
    			w+=c[j];
    			rep(k,0,m){
    				f[k]+=a[j][k];
    			}
    		}
    	}
    	int g=1;
    	rep(j,0,m){
    		if(f[j]<x) g=0;
    	}
    	if(g) ans=min(ans,w);
    }
    if(ans<hell) cout<<ans<<endl;
    else cout<<-1<<endl;
}

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

Measured memory_bytes: 3556
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long H, long long W, long long A, long long B){
    REP(i, B){
        REP(j, A) cout<<0;
        REP(j, W-A) cout<<1;
        cout<<endl;
    }
    REP(i, H-B){
        REP(j, A) cout<<1;
        REP(j, W-A) cout<<0;
        cout<<endl;
    }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(H, W, A, B);
    return 0;
}


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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll x = c - a - b;
    if (x < 0) {
        puts("No");
        return 0;
    }
    if (4*a*b < x*x) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
par=[-1]*n
def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def union(x,y):
    x,y=find(x),find(y)
    if x!=y:
        if x>y:
            x,y=y,x
        par[x]+=par[y]
        par[y]=x

for i in range(m):
    x,y,z=map(int,input().split())
    union(x-1,y-1)

ans=0
for i in range(n):
    if par[i]<0:
        ans+=1
        n+=par[i]
print(ans+n)

Measured memory_bytes: 5572
/*
                  友利奈緒の力でACしてくれ！！！！！！！！！！！！
                  Charlotteまだ見てない人は見ような！！！！！！！

                  ／　 /:／　　　　　　　　　　　 　 ＼:ヽ　＼
  　　　　　　　 /　　／　　　　　　 　 　 　 　 　 　 　 ＼　　ヽ
  　　　　　＼__L 彡　　　　　　　　　　　　　　　　　　　 ヽ　　',
  　　　　　　　ﾌ /　　　/　　/　 /　　　,　　 　 　 　 ヽ　　', 　ｊ
  　　　　　　　ﾚ　　　 /　　/ 　/　 　 　 　 　 　 　 　 ', 　ヽ　j
  　　　 　 　 // 　 　 !　/_l＿/__ノ 　　{ ＼}　　　　 　 ',　　',/
  　　　　　　i ﾊ 　 　 {　从j　ﾊ　i　　　 ',　 ト-､}　 i i　 }　　jj
  　　　　　　( ﾊ　　　(　 川　ハ ﾊ　 !　 '　ﾊ　 ﾊ　j j　,' 　 八
  　　　 ＜＿,ｨ∧　　　斗芹ﾃミxハ ﾊ　 ﾚ　} /__ﾚﾚ　/ 　 ∧ ＼　ﾉ
  　　　 　 　 ∨　＼ 　ゝ　辷:ソ　　 　)　芹ﾚ心ヾレ′　/ ト--　´
  　　　＼ｰ‐'　ﾉ　　 ＼ゝ　　　　　　 　 　 ゞ:_ソ "/ 　／ 　ヽ
  　　　　 　 フ　　　　i八 " "　　　,　　　　　　　ム彡　　　　＼
  　　　　 　/　　/　　j　 ト　　　　　　 　 　 " "イト＜　 　 　 ＼＼
  　　　　 /　　/　　　j　/／ヽ､ 　 ∩　　 　 イ　{ {　　￣ フフへ ＼＼
  　　　　(　／　　　 ,/ / 　　i　＞――＜ニニニﾆ┐　 〃／: : ヽ　ヽヽ
  　　　　／　　ィT´/ /┌―　￣￣ /::: , ,)　 　 　 〃／／: : : : : :}　ヽヽ)
  　　　/ /　 ∧ヾi┌― { {￣　　　 ﾉ:::トﾟ<　 　 　 ∥//: : : : : : : : i　 ﾉ ﾉ
  . 　　( 人　 {:ヽヾi∨　∧V　　　 /:::/　､ヽ　　　 ∥/: : : : : : : : : :}　/
  　　　V　( ∧: :＼'∨　∧V　　 ﾉ:::/　 ∧ 〉＿__∥: : : : : :／: : : :ﾚ
  　　 　 　 /∧: : : : ∨　∧V┬ｲ:::ﾉ　 〈 TT　|　|{{: : : : ／: : : : : ∧　　 ﾉ
  　　　 　 (　ハ: : : : :∨'T∧Vi　i (　 　 V　!　!　{{: : ／ : : : : : : /　ｰ　ノ
  　　　　　V　ハ: : : : :∨ﾍ∧V　i ゝゝ　 i／⌒＼{／ : : : : : : : /ｰ― ´
  　　　　　 ∨　ヽ: : : : :∨ﾍ∧∨i　〉 〉 /　/二　 ): : : : : : : : :/

          (https://seesaawiki.jp/asciiart/d/Charlotteより)
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) REP(i,n+1)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RREP(i,n+1)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define PERM(c) sort(ALL(c)); for(bool cp = true;cp;cp = next_permutation(ALL(c)))
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1E9+7;
int dx[] = {1,0,-1,0}; int dy[] = {0,1,0,-1};
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  sort(ALL(s));
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
def move(up,bottom,right,left,front,back,direction):
    if direction == "N":
        return (front,back,right,left,bottom,up)
    elif direction == "S":
        return (back,front,right,left,up,bottom)
    elif direction == "E":
        return (left,right,up,bottom,front,back)
    elif direction == "W":
        return (right,left,bottom,up,front,back)
    
up,front,right,left,back,bottom = input().split()
direction = list(input())

for i in range(len(direction)):
    up,bottom,right,left,front,back = move(up,bottom,right,left,front,back,direction[i])
    
print(up)

Measured memory_bytes: 7488
n=int(input())
s=input()
M=0
for i in range(1,n):
  s1=s[0:i]
  s2=s[i:n]
  S1=set(s1)
  S2=set(s2)
  m=len(S1&S2)
  M=max(M,m)
print(M)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
inline void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
inline void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
using namespace std;

vector<int>E[100000], G[100000];
int l[100000], d[100000], b[100000], cnt[200001], u[200000], v[200000], r[200000], que[100000];
int main() {
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]); u[i]--; v[i]--; r[i] = q;
		l[u[i]]++; l[v[i]]++;
	}
	rep(i, n)E[i].reserve(l[i]), G[i].reserve(l[i]), l[i] = 0;
	rep(i, q) {
		int a; reader(a); r[a - 1] = i;
	}
	rep(i, m) {
		E[u[i]][l[u[i]]] = v[i]; G[u[i]][l[u[i]]++] = r[i];
		E[v[i]][l[v[i]]] = u[i]; G[v[i]][l[v[i]]++] = r[i];
	}
	d[0] = 1; b[0] = q;
	int s = 0, g = 1;
	while (s != g) {
		int p = que[s++];
		rep(i, l[p]) {
			int a = E[p][i];
			if (d[a] == 0) {
				d[a] = d[p] + 1; que[g++] = a;
			}
			if (d[a] == d[p] + 1)
				b[a] = max(b[a], min(b[p], G[p][i]));
		}
	}
	rep(i, n)cnt[b[i]]++;
	int ans = 0;
	rep(i, q) {
		ans += cnt[i];
		writer(ans, '\n');
	}
}

Measured memory_bytes: 19172
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s, t; cin >> s >> t;
  int ans = INF;
  for (int i = 0; i + t.length() <= s.length(); ++i) {
    int diff = 0;
    REP(j, t.length()) diff += s[i + j] != t[j];
    chmin(ans, diff);
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;
#define pb push_back
#define db(x) cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 312

int n;
int freq[4];
double dp[MAXN][MAXN][MAXN];
int vis[MAXN][MAXN][MAXN];

double solve(int a, int b, int c)
{
    if (a == 0 && b == 0 && c == 0)
        return 0;

    if (vis[a][b][c])
        return dp[a][b][c];
    vis[a][b][c] = 1;

    double p_waste = (n - (a + b + c))/double(n);
    dp[a][b][c] = p_waste / (1 - p_waste) + 1;
    if (a)
    {
        double p = a/double(a+b+c);
        dp[a][b][c] += p * solve(a - 1, b, c);
    }
    if (b)
    {
        double p = b/double(a+b+c);
        dp[a][b][c] += p * solve(a + 1, b - 1, c);
    }
    if (c)
    {
        double p = c/double(a+b+c);
        dp[a][b][c] += p * solve(a, b + 1, c - 1);
    }

    return dp[a][b][c];
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int v;
        scanf("%d", &v);
        freq[v]++;
    }
    solve(freq[1], freq[2], freq[3]);
    printf("%.10lf\n", dp[freq[1]][freq[2]][freq[3]]);
    
}

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

using namespace std;

class TopologicalSort {
public:
  int n;
  vector< vector<int> > G;
  vector<bool> used;
  vector<int> indeg;
  vector<int> out;

  TopologicalSort(int _n): n(_n), G(n), used(n), indeg(n), out(0) {}

  void bfs(int start) {
    queue<int> q;
    q.push(start);
    while (!q.empty()) {
      int cur = q.front(); q.pop();
      out.push_back(cur);
      for (int v: G[cur]) {
	indeg[v]--;
	if (indeg[v] == 0 && !used[v]) {
	  used[v] = true;
	  q.push(v);
	}
      }
    }
  }
  
  void add_edge(int from, int to) {
    G[from].push_back(to);
  }
  
  vector<int> build() {
    fill(indeg.begin(), indeg.end(), 0);
    fill(used.begin(), used.end(), 0);
    for (int i = 0; i < n; ++i)
      for (int v: G[i]) indeg[v]++;

    for (int i = 0; i < n; ++i) {
      if (indeg[i] == 0 && !used[i]) bfs(i);
    }
    return out;
  }
};

int main() {
  int n;
  scanf("%d", &n);

  vector< vector<int> > a(n, vector<int>(n - 1));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n - 1; ++j) {
      scanf("%d", &a[i][j]);
      a[i][j]--;
    }
  }

  vector< vector<int> > ids(n, vector<int>(n));
  int n_v = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n - 1; ++j) {
      if (i < a[i][j]) {
	ids[i][a[i][j]] = n_v++;
      }
    }
  }

  TopologicalSort tp = TopologicalSort(n_v);
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j < n - 1; ++j) {
      int from = ids[min(i, a[i][j - 1])][max(i, a[i][j - 1])];
      int to = ids[min(i, a[i][j])][max(i, a[i][j])];
      tp.add_edge(from, to);
    }
  }
  vector<int> res = tp.build();
  if (res.size() != n_v) {
    printf("-1\n");
    return 0;
  }

  reverse(res.begin(), res.end());
  vector<int> dp(n_v, 0);
  int ans = 0;
  for (int i: res) {
    for (int v: tp.G[i]) {
      dp[i] = max(dp[i], dp[v] + 1);
    }
    ans = max(ans, dp[i]);
  }
  printf("%d\n", ans + 1);
  return 0;
}



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

int main(){
  ll n;
  cin >> n;
  ll ans1 = 1;
  for(ll i=2; i<=sqrt(n); ++i){
    if(n%i == 0) ans1= i;
  }
  ll ans2 = n/ans1;
  cout << ans1+ans2-2 << endl;
}

Measured memory_bytes: 256
N = int(input())
pf = {}
answer = 0

for i in range(2,int(N**0.5)+1):
    while N % i ==0:
        pf[i] = pf.get(i, 0) + 1
        N //= i
    
    if N < i:
        break
if N > 1:
    answer += 1
    
for j, k in pf.items():
    sq = 1
    for l in range(k):
        answer += 1
        k -= sq
        sq += 1
        if k == 0:
            break
        elif k < 0:
            answer -= 1
            break

print(answer)

Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  ll n,m;
  cin>>n>>m;
  if(n>=m){
    cout<<"0";
    return 0;
  }
  vector<ll> x(m),a(m-1);
  rep(i,m){
  	cin>>x[i];
  }
  sort(x.begin(),x.end());
 
  for(ll i=m-2;i>=0;i--){
  	a[i]=x[i+1]-x[i];
  }
  
  sort(a.begin(),a.end());
  
  int64_t ans=x[m-1]-x[0];
  
  rep(i,n-1){
  	ans-=a[m-2-i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4608
#define DEBUG
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
#define all(x) begin(x), end(x)
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
#define TCC template<class C
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
#define ENI typename enable_if<
#define DTOR , Dbg&>::type operator<<
#define RIS return *this
TCC> static auto o(C *x)->decltype(os << *x, 0);
TCC> static char o(...);
TCC> ENI sizeof o<C>(0)!=1 DTOR(const C &x) {os<<x; RIS;}
TCC> Dbg &dump(C b, C e) {
    int ii = 0;
    for(C i = (os << "\n[", b); i!=e and ii<26; i++, ii++) *this << ", "+2*(i==b) << *i;
    RIS << ']';
}
TCC> ENI sizeof o<C>(0)==1 DTOR(const C &x) {
    return dump(all(x));
}
TCC, size_t X> ENI !is_same<C, const char>::value DTOR(C (&x)[X]) {
    return dump(all(x));
}
TCC, class D> Dbg &operator<<(const pair<C, D> &x) {RIS<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(ostream&)) { os << x; RIS; }
} dbg;
void err(istringstream *iss) { delete iss; }
TCC, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#ifdef DEBUG
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#else
#define bug(args...) 0
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
int T = 1, Q, cn;
const int inf = 1000000007, mxn = -1;
#define im(a, b) if (a>=(b)) a -= b; else if (a<0) a += b;

int K;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    // cin >> T;
    auto inputAll = [&]()->void {
        
    };
    auto kase = [&]()->void {
        // cout << "Case " << cn << ": ";
        cin>>K;
        int mod=0;
        for(int i=0;i<10000000;i++){
            mod=(mod*10+7)%K;
            if(mod==0)cout<<i+1<<'\n',exit(0);
        }
        cout<<"-1\n";
    };
    auto resetAll = [&]()->void {
        
    };
    while (cn++!=T) inputAll(), kase(), resetAll();
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 4e5+6;
const ll inf =1e18;
 
 

ll h[MAX],a[MAX];
int main(){
	fastio;
	ll k,n,m,q,b,u,v,ans=0;
	cin>>n>>m;
	f(i,1,n+1){
		cin>>h[i];
	}
	f(i,1,m+1){
		cin>>u>>v;
		a[u]=max(a[u],h[v]);
		a[v]=max(a[v],h[u]);
	}
	f(i,1,n+1){
		if(h[i]>a[i]) ans++;
	}
	cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;

const vector<vector<int>> dir4 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
const vector<vector<int>> dir8 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}, {1, 1}, {-1, 1}, {1, -1}, {-1, -1}};

int main()
{
    int h, w; cin >> h >> w;
    vector<vector<bool>> a(h + 2, vector<bool>(w + 2));
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            char c; cin >> c;
            a[i][j] = (c == '#');
        }
    }

    bool res = true;
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            bool f = false;
            if(a[i][j]) {
                for(auto d: dir4)if(a[i + d[0]][j + d[1]])f = true;
                if(!f)res = false;

            }
        }
    }
    cout << (res ? "Yes" : "No") << endl;
}

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

int main()
{
    int N, answer = 0;
    vector<int> A(200000, 0);
    vector<int> K(200000, 0);

    cin >> N;

    for (int i = 0; i < N-1; i++)
    {
        cin >> A.at(i);
    }
    
    for (int j = 0; j < N-1; j++)
    {
        K.at(A.at(j)-1) ++;
    }

    for (int k = 0; k < N; k++)
    {
        cout << K.at(k) << endl;
    }
    
    
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#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 REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    VI a(n);
    int s=0,ave=0;
    rep(i,n){
        cin>>a[i];
        s+=a[i];
    }
    double c;
    c= (s/(double)n);
    ave=round(c);
    int ans=0;
    rep(i,n){
        if(a[i] == ave){

        }
        else{
            ans+=(a[i]-ave)*(a[i]-ave);
        }
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 7;
const int K = 11;

int c[N];
int dp[K][N];
vector<int> g[N];

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

	for (int i = 0; i < K; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = -1;
		}
	}
	int n, m;
	cin >> n >> m;
	while (m--) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int i = 0; i < n; i++) {
		g[i].push_back(i);
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int v, d;
		cin >> v >> d >> c[i];
		v--;
		dp[d][v] = i;
	}
	for (int j = K - 1; j > 0; j--) {
		for (int i = 0; i < n; i++) {
			for (auto t : g[i]) {
				dp[j - 1][t] = max(dp[j - 1][t], dp[j][i]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (dp[0][i] == -1) {
			cout << 0 << '\n';
		} else {
			cout << c[dp[0][i]] << '\n';
		}
	}
}


Measured memory_bytes: 11256
fun main(args: Array<String>) {
    abc061b()
}

fun abc061b() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val ab = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
        .flatten()

    val count = (1..n).map { num -> ab.count { it == num } }
        .joinToString(separator = System.lineSeparator())

    println(count)
}


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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

ll x[100];
int main() {
  int n;
  cin >> n;
  repi(n) cin >> x[i];
  ll res = LLONG_MAX;
  repi(101) {
    ll r = 0;
    repj(n) r += (x[j] - i) * (x[j] - i);
    updatemin(res, r);
  }
  cout << res << endl;
}


Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

const int mod=1e9+7;

int main(){
	int n;	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)	cin>>a[i];
	sort(a.begin(),a.end());
	if(n%2==0){
		for(int i=1;i<n;i+=2){
			if(a[i]!=a[i-1]||a[i]!=i){
				cout<<0<<endl;
				return 0;
			}
		}
		ll ret=1;
		for(int i=0;i<n;i+=2)	ret=(ret*2)%mod;
		cout<<ret<<endl;
	}
	else{
		if(a[0]!=0){
			cout<<0<<endl;
			return 0;
		}
		for(int i=2;i<n;i+=2){
			if(a[i]!=a[i-1]||a[i]!=i){
				cout<<0<<endl;
				return 0;
			}
		}
		ll ret=1;
		for(int i=1;i<n;i+=2)	ret=(ret*2)%mod;
		cout<<ret<<endl;
	}
	return 0;
}


Measured memory_bytes: 640
use std::collections::HashMap;

const MOD: i64 = 1000000007;


fn main() {
    let n: i64 = read();

    let mut prime_count: HashMap<i64, i64> = HashMap::new();
    for mut t in 2..(n + 1) {
        let limit = t;
 
        for i in (2..).take_while(|&x| x * x <= limit) {
            let mut count = 0;
            while t % i == 0 {
                count += 1;
                t /= i;
            }
            if count > 0 {
                let c = prime_count.entry(i).or_insert(0);
                *c += count;
            }
        }

        if t != 1 {
            let c = prime_count.entry(t).or_insert(0);
            *c += 1;
        }
    }

    let mut res = 1; 
    for c in prime_count.values() {
        res *= c + 1;
        res %= MOD;
    }

    println!("{:?}", res);
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}



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

r_list = [ [i,input().split()] for i in range(n)]

s_list = list(set([r[1][0] for r in r_list]))
s_list.sort()

r_map = {}
for r in r_list:
    if r[1][0] not in r_map:
        r_map[r[1][0]] = [[r[0], int(r[1][1])]]
    else:
        r_map[r[1][0]].append([r[0], int(r[1][1])])

for s in s_list:
    r_map[s].sort(key= lambda x: x[1], reverse=True)


for s in s_list:
    for r in r_map[s]:
        print(r[0]+1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m),r(n);
  for (int i=0;i<m;i++){
    cin >> a[i] >> b[i];
  }
  for (int i=0;i<m;i++){
    r[a[i]-1]++;
    r[b[i]-1]++;
  }
  for (int i=0;i<n;i++){
    cout << r[i] << endl;
  }
}

Measured memory_bytes: 256
while True:
    a = int(input())
    if a == 0:
        break
    else:
        x = 1000-a
        b = int(x/500)
        c = int((x-500*b)/100)
        d = int((x-500*b-100*c)/50)
        e = int((x-500*b-100*c-50*d)/10)
        f = int((x-500*b-100*c-50*d-10*e)/5)
        g = int((x-500*b-100*c-50*d-10*e-5*f)/1)
        y = b+c+d+e+f+g
        print(y)



Measured memory_bytes: 5588
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 998244353;
    public static void main(String[] args) throws IOException {
        Main main = new Main();

        main.solve();
//        long ans = main.solve();

        out.flush();
    }
    void solve() throws IOException {
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        int  maxn = a[n-1];
        boolean[] rec = new boolean[maxn+1];
        int ans = 0, idx = 0;
        while(idx<n){
            int r = idx, num = a[idx];
            while(r<n&&a[r]==num) r++;
            if(!rec[num]&&r-idx==1) ans++;
            if(!rec[num]){
                for(int j=num; j<=maxn; j+= num){
                    rec[j] = true;
                }
            }
            idx = r;
        }
        out.println(ans);
    }

    int paIn(String s){return Integer.parseInt(s);}
}

Measured memory_bytes: 59884
#include <stdio.h>
#include <string.h>
int main() {
  int n;
  char S[11], T[11];
  gets(S);
  gets(T);
  for (int i = 0; i < strlen(S); i++) {
    if (S[i]==T[i]) {
      n += 1;
    }
  }
  if (n == strlen(S)) {
    printf("Yes");
  }
  else {
    printf("No");
  }
  return 0;
}

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

using namespace std;


typedef long long ll;


int main()
{
    //freopen("", "r", stdin);freopen("", "w", stdout);
    int n, m;
    cin>>n>>m;
    vector<pair<int, int>>a;
    for (int i=0; i<n; i++){
        int x, y;
        cin>>x>>y;
        a.push_back({x, y});
    }
    sort(a.begin(), a.end());
    ll ans=0;
    ll sum=0;
    for (int i=0; sum<m && i<n; i++){
        ans+=min((ll)a[i].second, (m-sum))*a[i].first;
        sum+=a[i].second;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1400
package main

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

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextMega()
	n := len(s) + 1
	up, down := make([]int, n), make([]int, n)
	for i := 1; i < n; i++ {
		if s[i-1] == '<' {
			up[i] = up[i-1] + 1
		} else {
			up[i] = 0
		}
	}
	for i := n - 2; i >= 0; i-- {
		if s[i] == '>' {
			down[i] = down[i+1] + 1
		} else {
			down[i] = 0
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		ans += max(up[i], down[i])
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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


int N;
matrix ans;


matrix make_m(int n) {
    matrix m(n, vector<char>(n, '.'));
    if (n == 3) {
        m[0][0] = m[0][1] = 'a';
        m[1][2] = m[2][2] = 'a';
    }
    else if (n == 4) {
        m[0][0] = m[0][1] = m[2][2] = m[2][3] = 'a';
        m[0][2] = m[1][2] = m[2][0] = m[3][0] = m[3][2] = m[3][3] = 'b';
        m[0][3] = m[1][0] = m[1][1] = m[1][3] = 'c';
        m[2][1] = m[3][1] = 'd';
    }
    else if (n == 5) {
        m[0][0] = m[0][1] = m[4][3] = m[4][4] = 'a';
        m[0][2] = m[0][3] = m[1][0] = m[2][0] = m[2][4] = m[3][4] = m[4][1] = m[4][2] = 'b';
        m[0][4] = m[1][1] = m[1][2] = m[1][4] = m[2][3] = m[3][0] = m[3][3] = m[4][0] = 'c';
    }
    else if (n == 6) {
        m[0][0] = m[0][1] = m[1][2] = m[1][3] = m[2][5] = m[3][5] = m[5][1] = m[5][2] = 'a';
        m[0][2] = m[0][3] = m[1][0] = m[2][0] = m[5][3] = m[5][4] = 'b';
        m[0][4] = m[0][5] = m[1][1] = m[2][1] = m[3][0] = m[4][0] = m[4][5] = m[5][5] = 'c';
        m[3][4] = m[4][4] = 'd';
    }
    else if (n == 7) {
        m[0][0] = m[0][1] = m[1][6] = m[2][6] = m[5][3] = m[5][4] = m[6][1] = m[6][2] = 'a';
        m[0][2] = m[0][3] = m[1][0] = m[2][0] = m[3][6] = m[4][6] = m[6][3] = m[6][4] = 'b';
        m[0][4] = m[0][5] = m[1][1] = m[1][2] = m[2][5] = m[3][0] = m[3][5] = m[4][0] = m[5][6] = m[6][6] = 'c';
        m[4][5] = m[5][5] = 'd';
    }
    return m;
}


int main() {
    cin >> N;
    if (N == 2) {
        cout << -1 << endl;
        return 0;
    }
    ans = matrix(N, vector<char>(N, '.'));
    if (N < 8) ans = make_m(N);
    else if (N % 4 == 0) {
        matrix m4 = make_m(4);
        rep(k, N / 4) {
            rep(i, 4) rep(j, 4) {
                ans[k*4+i][k*4+j] = m4[i][j];
            }
        }
    }
    else {
        matrix m4 = make_m(4);
        int x = 4 + (N % 4);
        matrix mx = make_m(x);
        rep(k, (N - x) / 4) {
            rep(i, 4) rep(j, 4) {
                ans[k*4+i][k*4+j] = m4[i][j];
            }
        }
        int k = N - x;
        rep(i, x) rep(j, x) {
            ans[k+i][k+j] = mx[i][j];
        }
    }
    rep(i, N) {
        rep(j, N) cout << ans[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 2176
/*
  AOJ 2189
  Title:Additon game
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

char buf[1001];


main()
{
  int i,j,len,sum,N,ret;
  
  scanf("%d ",&N);
  for(i=0;i<N;i++)
    {
      scanf("%s",buf);
      len=strlen(buf);
      for(j=sum=0;j<len;j++)
	sum += (buf[j]-'0');
      ret = (((sum - 1)/9)& 1) ^ (len & 1);

      printf("%s wins.\n",ret?"Audrey":"Fabre");
    }
  return(0);
}

Measured memory_bytes: 596