akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef int      ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)    for (ll i = (ll)b; i < (ll)e; i++)
#define forr(i, b, e)    for (ll i = (ll)b; i < (ll)e; i++)
ll faster_in(){ll r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e9 + 7);
const lldb PI = acos(-1);
#define tam 320000
const ll MOD=1e9+7;
int v[tam];
int main()
{    
    int n,m;
    cin>>n>>m;
    int tot=0;
    forr(i,0,n)
    {
        cin>>v[i];
        tot+=v[i];
    }
    int c=0;
    forr(i,0,n)
    {
        if (tot<=v[i]*4*m)
            c++;
    }
    if (c>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";

}
// PLUS ULTRA!

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<ll>sum(n+5);
  map<ll,ll>mp;
  rep(i,n){
    sum[i+1]=sum[i]+a[i];
    mp[sum[i+1]]++;
  }
  ll ans=mp[0];
  rep(i,n){
    ans+=mp[sum[i+1]]-1;
    mp[sum[i+1]]--;
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	//cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N, K;
	scanf("%d%d", &N, &K);

	pair<int32_t, int32_t> orig[64];
	int32_t x[64], y[64];
	for (int32_t i = 0; i < N; i++) {
		scanf("%d%d", &x[i], &y[i]);
		orig[i].first = x[i];
		orig[i].second = y[i];
	}
	sort(x, x + N);
	sort(y, y + N);

	int64_t res = (int64_t)(x[N - 1] - x[0]) * (int64_t)(y[N - 1] - y[0]);
	for (int32_t left = 0; left < N; left++) {
		for (int32_t right = left + 1; right < N; right++) {
			for (int32_t bottom = 0; bottom < N; bottom++) {
				for (int32_t top = bottom + 1; top < N; top++) {
					int32_t included_cnt = 0;
					for (int32_t i = 0; i < N; i++) {
						if (orig[i].first < x[left] || x[right] < orig[i].first ||
						    orig[i].second < y[bottom] || y[top] < orig[i].second)
							continue;
						included_cnt++;
					}
					if (included_cnt < K)
						continue;
					res = min(res, (int64_t)(x[right] - x[left]) * (int64_t)(y[top] - y[bottom]));
				}
			}
		}
	}

	printf("%" PRId64 "\n", res);

	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int N, W;
ll w[100], wws[100];
int vs[100];
int dp[101][101][400];

void f(){
    for(int i=0;i<N;++i){
        for(int k=0;k<=N;++k){
            for(int j=0;j<=300;++j){
                dp[i+1][k][j] = max(dp[i+1][k][j], dp[i][k][j]);
                if(j > 0){dp[i+1][k][j] = max(dp[i+1][k][j], dp[i+1][k][j-1]);}

                if(k + 1 <= N && j + wws[i] <= 300){
                    dp[i+1][k+1][j + wws[i]] =
                        max(dp[i+1][k+1][j + wws[i]],
                            dp[i][k][j] + vs[i]);
                }
            }
        }
    }
}

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

    std::cin >> N >> W;

    for(int i=0;i<N;++i){
        std::cin >> w[i] >> vs[i];
        wws[i] = w[i] - w[0];
    }

    f();
    
    int res = 0;
    for(int i=1;i<=N;++i){
        if(w[0] * i > W){continue;}
    
        int mx = min<int>(W - w[0] * i, 300);
        res = max(res, dp[N][i][mx]);
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 16000
from sys import exit
from collections import Counter
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

N, M, K = map(int, input().split())

if M == 0:
    print(*np.zeros(N, dtype="int8"))
    exit()

exc = [set() for _ in range(N)]
edge = []

for _ in range(M):
    a, b = map(int, input().split())
    exc[a - 1].add(b - 1)
    exc[b - 1].add(a - 1)
    edge.append((a - 1, b - 1))

edge = np.array(edge).T
matr = csr_matrix((np.ones(M, dtype="int64"), edge), (N, N))
_, labels = connected_components(matr)
ct = Counter(labels)

for _ in range(K):
    c, d = map(int, input().split())
    if labels[c - 1] == labels[d - 1]:
        exc[c - 1].add(d - 1)
        exc[d - 1].add(c - 1)

ans = [ct[labels[i]] - len(exc[i]) - 1 for i in range(N)]
print(*ans)


Measured memory_bytes: 94324
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll a[110], n, m;
int main()
{
	scanf("%lld %lld", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	sort(a, a + n);
	ll sum = 0;
	ll cnt = 0;
	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (sum > m)
		{
			printf("%lld", cnt);
			return 0;
		}
		cnt++;
	}
	if (sum != m)
		cnt--;
	printf("%lld", cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  int s;
  REP(i, n) {
    cin >> a[i];
    if (i == 0) s = a[i];
    else
      s ^= a[i];
  }
  REP(i, n) {
    int b = a[i] ^ s;
    cout << b << " ";
  }
  cout << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3988
import sys
input = sys.stdin.readline

S = '-' + input().rstrip()
N = len(S) - 1

def solve(S):
    if S[1] == '0':
        return None
    if S[N] == '1':
        return None
    prev = 1
    graph = []
    for n in range(1,N//2 + 1):
        if S[n] != S[N-n]:
            return None
        if S[n] == '0':
            continue
        for i in range(prev,n):
            graph.append('{} {}'.format(i,n))
        prev = n
    graph += ['{} {}'.format(i,N) for i in range(prev,N)]
    return graph

graph = solve(S)

if graph is None:
    print(-1)
else:
    print('\n'.join(graph))


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

int main(){
    int x[4];
    int sum = 0;
    for(int i=0;i<4;i++){
        int y; cin >> y;
        sum += y;
        x[i] = y;
    }

    int ans = 100000;
    for(int i=0;i<4;i++){
        for(int j=i+1;j<4;j++){
            int rep = x[i] + x[j];
            int k = sum - rep;
            ans = min(abs(sum - 2*k), ans);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

map <vector <int>, string> mem;

int cnt = 0;

string quer(vector <int> a) {
    sort(all(a));

    if (mem.find(a) != mem.end())
        return mem[a];

    ++cnt;
    if (cnt > 210) {
        exit(1);
    }   

    cout << "? ";
    for (auto e : a)
        cout << e << ' ';
    cout << endl;
    string ans; cin >> ans;
    return mem[a] = ans;
}    

int n;
vector <int> sub(int s) {
    vector <int> ans;
    for (int i = 0; i < n; ++i)
        ans.app(s + i);
    return ans;                
}   

signed main() {
    cin >> n;
    int l = 1, r = n+1;
    while (l < r - 1) {
        int m = (l + r) >> 1;
        if (quer(sub(l)) == quer(sub(m)))
            l = m;
        else
            r = m;
    }                           

    vector <int> a;
    for (int i = 0; i < n - 1; ++i)
        a.app(r + i);

    vector <bool> used(2 * n + 1);
    for (int e : a)
        used[e] = 1;

    vector <char> ans(2 * n + 1);

    vector <int> fr, fb;
    for (int i = 1; i <= 2 * n; ++i) {
        if (!used[i]) {
            vector <int> t = a;
            t.app(i);
            if (quer(t) == "Red") {
                ans[i] = 'R';
                fr.app(i);  
            }   
            else {
                ans[i] = 'B';
                fb.app(i);
            }   
        }
    }   

    int m = n/2;
    a.clear();
    for (int i = 0; i < m; ++i)
        a.app(fr[i]);
    for (int i = 0; i < m; ++i)
        a.app(fb[i]);
    for (int i = 1; i <= 2 * n; ++i) {
        if (used[i]) {
            vector <int> t = a;
            t.app(i);
            if (quer(t) == "Red") {
                ans[i] = 'R';
            }   
            else {
                ans[i] = 'B';
            }   
        }   
    }   

    cout << "! ";
    for (int i = 1; i <= 2 * n; ++i)
        cout << ans[i];
    cout << endl;
}


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

#define MOD 1000000007
LL powmod(LL a, LL n){
    if(n == 0) return 1;
    if(n % 2) return (a*powmod(a,n-1)) % MOD;
    LL c = powmod(a, n/2);
    return (c*c) % MOD;
}
LL inv(LL a){
    return powmod(a, MOD-2);
}
LL fact[1100000];
LL invfact[1100000];

LL ncr(LL n, LL r){
    if(r < 0 || n < 0) return 0;
    if(n < r) return 0;
    LL a = fact[n];
    a = (a * invfact[r]) % MOD;
    a = (a * invfact[n-r]) % MOD;
    return a;
}
void init(){
    fact[0] = 1;
    invfact[0] = 1;
    LL inv2 = inv(2);
    for(LL i = 1; i < 1100000; i++){
        fact[i] = (i*fact[i-1]) % MOD;
        invfact[i] = inv(fact[i]);
    }
}

// call init();

int main(){
	init();
	LL n;
	cin >> n;
	LL ans = (n-1) * fact[n-1];
	ans %= MOD;
	LL k = n-2;
	for(LL a = 1; a*2 <= k; a++){
		LL cur = fact[k-a];
		cur = (cur * fact[n-1-a]) % MOD;
		cur = (cur * invfact[k-2*a]) % MOD;
		ans -= cur;
		ans %= MOD;
	}
	if(ans < 0) ans += MOD;
	cout << ans << endl;
}


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

/* define const */

/* finish defineing const */

int main()
{
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = 0; i < tx-sx; i++) cout << 'R';
  for (int i = 0; i < ty-sy; i++) cout << 'U';
  for (int i = 0; i < tx-sx; i++) cout << 'L';
  for (int i = 0; i < ty-sy; i++) cout << 'D';
  cout << 'D';
  for (int i = 0; i < tx-sx+1; i++) cout << 'R';
  for (int i = 0; i < ty-sy+1; i++) cout << 'U';
  cout << 'L';
  cout << 'U';
  for (int i = 0; i < tx-sx+1; i++) cout << 'L';
  for (int i = 0; i < ty-sy+1; i++) cout << 'D';
  cout << 'R' << endl;
}


Measured memory_bytes: 256
dct = {
    0: (0, 0, 1),
    5: (0, 0, -1),
    2: (0, 1, 0),
    3: (0, -1, 0),
    1: (1, 0, 0),
    4: (-1, 0, 0)
}

def calc(x, y):
    res = (
        x[1] * y[2] - x[2] * y[1],
        x[2] * y[0] - x[0] * y[2],
        x[0] * y[1] - x[1] * y[0]
    )
    return res

if __name__ == "__main__":
    a = [int(x) for x in input().split()]
    Q = int(input())

    for _ in range(Q):
        x, y = map(int, input().split())
        
        for i, value in enumerate(a):
            if x == value:
                x_ind = i
            elif y == value:
                y_ind = i
        
        s, t = dct[x_ind], dct[y_ind]

        res = calc(s,t)
        for key in dct:
            if dct[key] == res:
                print(a[key])
                break



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    string s,t;
    cin>>s>>t;
    f(i,s.length())
    {
        string temp;
        temp += s[s.length() - 1];
        temp += s.substr(0, s.length() - 1);
        s = temp;
        //cout<<temp<<endl;
        if(s == t) {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}

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

using namespace std;

#define ll long long
#define mod 1000000007

void solve(){

    int n, k; cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; ++i) cin >> arr[i];
    int dp[n];
    dp[0] = 0;
    for(int i = 1; i < n; ++i){
        dp[i] = INT_MAX;
        for(int j = max(0, i-k); j < i; ++j)
            dp[i] = min(dp[i], dp[j] + abs(arr[j]-arr[i]));
    }
    cout << dp[n-1] << endl;
    return;
}

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

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

int main(){
  int n,d; cin >> n>> d;
  int view = 1+d*2;
  int ret=1;
  while(1){
    if(ret * view >= n){
      cout << ret << endl;
      return 0;
    }
    ret++;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define df 0

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >> n;
  bool flag=false;
  long int sum=0,MIN_b=1200000000;
  for(int i=0;i<n;i++){
    long int a,b; cin >> a >> b;
    if(a>b){
      flag=true;
      sum+=a;
      if(b<MIN_b)MIN_b=b;
      if(df)cout << sum <<"\n";
    }else{
      sum+=a;
      if(df)cout << sum <<"\n";
    }
  }
  cout << (flag?sum-MIN_b:0);
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

int main() {
	int n;
	ll a, b;
	ll h[100000];
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin>>h[i];
	}
	ll hi, lo;
	hi = 1000000000;
	lo = 0;
	while (hi != lo) {
		ll mid = (hi + lo) / 2LL;
		ll need = 0;
		for (int i = 0; i < n; i++) {
			if(h[i]-b*mid>0)
				need+=(h[i] - b * mid - 1LL) / (a - b) + 1LL;
		}
		if (need > mid) {
			lo = mid + 1LL;
		}
		else {
			hi = mid;
		}
	}
	cout << hi << endl;
	return 0;
}

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

bool judge(string&s){
	string s2=s;
	reverse(s2.begin(),s2.end());
	return s!=s2;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s;
	cin>>s;
	bool yes=true;
	int n=s.size();
	if(judge(s))yes=false;
	string s2=s.substr(0,(n-1)/2);
	if(yes==true&&judge(s2))yes=false;
	cout<<(yes?"Yes":"No")<<"\n"s;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

a, b = map(int, input().split())

ans = a - b * 2

if (ans >= 0):
    print(ans)
else:
    print(0)



Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;
}

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

#define REP(i,n) for(int i=0; i<n; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod1 1000000007
#define ll long long
#define clr0(arr) memset(arr,0,sizeof(arr))
#define clrval(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

void showList(vector<int>adj[], int n){

	for(int u=1; u<=n; u++){
		cout<<u<<" -> ";

		for(auto it=adj[u].begin(); it!=adj[u].end(); it++){
			cout<<*it<<" ";
		}
		cout<<"\n";
	}
}

void dfsUtil(vector<int>adj[], int ele, bool visited[]){

	if(visited[ele])
		return;

	cout<<ele<<" ";
	visited[ele]=true;

	for(auto it=adj[ele].begin(); it!=adj[ele].end(); it++){
		dfsUtil(adj,*it,visited);
	}
}

void dfs(vector<int>adj[], int n){

	bool visited[n+1];
	REP(i,n+1)
		visited[i]=false;

	for(int u=1; u<=n; u++){
		dfsUtil(adj,u,visited);
	}

	cout<<"\n";
}

int dp[100010];

int solveUtil(vector<int>adj[], int ele){

	if(dp[ele] != -1)
		return dp[ele];

	int ans=0;
	for(auto it=adj[ele].begin(); it!=adj[ele].end(); it++){
		int tempAns = 1 + solveUtil(adj,*it);

		ans=max(ans,tempAns);
	}

	dp[ele] = ans;
	return ans;
}

int solve(vector<int>adj[], int n){

	clrval(dp,-1);

	int ans=1;
	for(int u=1; u<=n; u++){
		ans=max(ans,solveUtil(adj,u));
	}

	return ans;
}

void bfs(vector<int>adj[], int n){
	queue<int> q;     
	q.push(1);      
	bool visited[n+1] = {false};     

	while(q.empty() == false){          
		int temp = q.front();         
		q.pop();         
		cout<<temp<<" ";         
		visited[temp]=true;          

		for(auto it = adj[temp].begin(); it!=adj[temp].end(); it++){              
			if(visited[*it]==false)                 
				q.push(*it);          
		}
	} 
}

void addEdge(int u, int v, vector<int>adj[]){
	adj[u].push_back(v);
	// adj[v].push_back(u);
}

int main(){

	int n,m;
	cin>>n>>m; //input

	vector<int>adj [n+1];

	REP(i,m){
		int u,v;
		cin>>u>>v;

		addEdge(u,v,adj);
	}

	// showList(adj,n);
	// dfs(adj,n);
	// bfs(adj,n);

	cout<<solve(adj,n)<<"\n";

	return 0;
}


Measured memory_bytes: 11320
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<queue>
#include<stack>
#include<list>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pt;
typedef pair<ll,ll> pll;

#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i,n) for(int i = 0;i<n;i++)
#define Fr(i,l,r) for(int i = l;i <= r;i++)
#define rF(i,n) for(int i = n-1;i>=0;i--)


//#define min(a,b) a>b?b:a
//#define max(a,b) a>b?a:b
#define all(arr) arr.begin(),arr.end()
//#define sort(vec) sort(vec.begin(),vec.end())
//#define reverse(vec) reverse(vec.begin(),vec.end())


ll Lpow(ll a,ll b)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2)
            ans = (ans*a);
        a = (a*a);
        b = b/2;
    }
    return ans;
}

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

double dp[3002][3002];

signed main()
{
    fastio;
    
    int n;
    cin >> n;
    vector<double> arr(n+1);
    
    F(i,n)
    cin >> arr[i+1];
    
    for(int i = 1;i<=n;i++)
    {
        if(i == 1)
        {
            dp[i][1] = arr[i];
            dp[i][0] = 1 - arr[i];
        }
        else
        {
            for(int j = 0;j<=i;j++)
            {
                dp[i][j] = dp[i-1][j-1] * arr[i] + dp[i-1][j] * (1 - arr[i]);
            }
        }
    }
    
    double ans = 0.00;
    
    for(int i = n/2 + 1;i<=n;i++)
        ans += dp[n][i];
    
    cout << fixed << setprecision(10) << ans << endl;
    
    return 0;
}


Measured memory_bytes: 68992
w, h, n = [ int(v) for v in input().split() ]
u, d, l, r = h, 0, 0, w

for i in range(n):
    x, y, a = [ int(v) for v in input().split() ]
    if a == 1 and x >= l:
        l = x
    elif a == 2 and x <= r:
        r = x
    elif a == 3 and y >= d:
        d = y
    elif a == 4 and y <= u:
        u = y



print(max(0,r-l)*max(0,u-d))

Measured memory_bytes: 38384
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    string s; cin >> s;
    int k; cin >> k; //k番目は高々k文字
    vector<string> sub;
    REP(i, s.length()){
        for(int j = 1; j <= k && i+j <= s.length(); j++){
            sub.push_back(s.substr(i, j));
        }
    }
    
    sort(sub.begin(), sub.end());
    sub.erase(unique(sub.begin(), sub.end()), sub.end());
    cout << sub[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
x, k, d = map(int, input().split())

# k回　dだけ変化

n=abs(x)//d
if k>=n:
  k=k-n
else:
  n=k
  k=0
  
if k%2 == 0:
  x=abs(x)-d*n
else:
  x=abs(x)-d*(n+1)

print(abs(x))

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

int main() {
  string a;
  cin >> a;
  vector<ll> chars(26, 0);
  ll n = a.length();
  for (auto i : a) {
    chars[i - 'a']++;
  }
  ll ans = n * (n - 1) / 2;
  for (auto i : chars) {
    if (i > 1) {
      ans -= i * (i - 1) / 2;
    }
  }
  // 何もしないこともある
  cout << ans + 1 << endl;
}


Measured memory_bytes: 640
n = int (input())
a,b = map(int,input().split())
for i in range(n-1):
    c,d = map(int,input().split())
    if (c>=a and d>=b):
        a=c
        b=d
    else:
        left = (a+c-1)//c
        right = (b+d-1)//d
        mx = max(left,right)
        a= c*mx
        b=d*mx
print(a+b)

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

vector<ll> s(100010, -1);
const ll MOD = 1e9 + 7;

ll modStep(int n) {
    if (s[n] != -1) return s[n];
    if (n == 0) return s[0] = 1;
    if (n == 1) return s[1] = 1;
    else return s[n] = (modStep(n-2) + modStep(n-1)) % MOD;
}

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

    int n, m;
    scanf("%d %d", &n, &m);
    vector<int> a(m);

    
    for (int i = 0; i < m; i++) {
        scanf("%d", &a[i]);
        s[a[i]] = 0;
    }

    ll ans = modStep(n);

    cout << ans << endl;
}

Measured memory_bytes: 5932
#include <iostream>
using namespace std;
int main(void){
    int n, v[20], m=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        int c;
        cin>>c;
        m+=max(0, v[i]-c);
    }
    cout<<m<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define l unsigned long long
int main(){
	
	int n;
	cin>>n;
	vector<l> integer(n);
	for(auto &x: integer) cin>>x;
	sort(integer.begin(), integer.end());
	for(int i=1;i<n;i++){
			if( integer[i] == integer[i-1]){
				cout<<"NO";
				return 0;
			}
		
	}
	cout<<"YES";
	
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  int ans=0;

  rep(i,n-1){
    int tmp=0;
    while(i<n-1){
      if(h[i]>=h[i+1]){
        tmp++;
        i++;
      }
      else break;
    }
    chmax(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int n,x,ans,a[100001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(x>n) ans++;
		else a[x]++;
	}
	for(int i=1;i<=n;i++)
		if(a[i]<i) ans+=a[i];
		else if(a[i]>i) ans+=a[i]-i;
	cout<<ans<<endl;
 	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
  int k,s;

  cin >> k >> s;

  int ans = 0;

  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (0 <= s - i - j && s - i - j <= k) {
        ans++;
      }
    }
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b,x] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  if fromIntegral x <= (fromIntegral (a^2 * b) / 2 :: Double) then
    print $ (pi / 2 - atan (2 * fromIntegral x / fromIntegral (a * b^2))) / pi * 180
  else
    print $ atan (2 * fromIntegral (a^2 * b - x) / fromIntegral (a^3)) / pi * 180


Measured memory_bytes: 508
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Removing Blocks
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], rcpsums[MAX_N + 1];

/* subroutines */

inline int powmod(int a, int b) {
  int p = 1;
  while (b) {
    if (b & 1) p = (ll)p * a % MOD;
    a = (ll)a * a % MOD;
    b >>= 1;
  }
  return p;
}

/* main */

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

  rcpsums[0] = 1;
  int fn = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &as[i]);
    rcpsums[i + 1] = (rcpsums[i] + powmod(i + 2, MOD - 2)) % MOD;
    fn = (ll)fn * (i + 1) % MOD;
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int d = ((ll)rcpsums[i] + rcpsums[n - 1 - i] + (MOD - 1)) % MOD;
    sum = (sum + (ll)d * as[i] % MOD) % MOD;
  }

  printf("%lld\n", (ll)sum * fn % MOD);
  return 0;
}

/*
  In case of n == 3:
  123: 1-3 + 2-3 + 3-3
  132: 1-3 + 2-3 + 2-2
  213: 1-3 + 1-1 + 3-3
  231: 1-3 + 3-3 + 1-1
  312: 1-3 + 1-2 + 2-2
  321: 1-3 + 1-2 + 1-1

  1-3 x 6 -> 1-1 x 6, 2-2 x 6, 3-3 x 6
  1-2 x 2, 2-3 x 2 -> 1-1 x 2, 2-2 x 4, 3-3 x 2
  1-1 x 3, 2-2 x 2, 3-3 x 3

  1-1 x 11, 2-2 x 12, 3-3 x 11
  In case of n == 4:
 */


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(void){
  
  int N,M;
  cin >> N >> M;

  int town[N];

  fill(town,town+N,0);

  for(int i = 0 ;i<M;++i){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--;
    tmp2--;
    town[tmp1]++;
    town[tmp2]++;
  }
  
  for(int i = 0; i < N;++i){
    cout << town[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(S.contentEquals("SUN")) {
            System.out.println(7);
        }else if(S.contentEquals("MON")) {
        	System.out.println(6);
        }else if(S.contentEquals("TUE")) {
        	System.out.println(5);
        }else if(S.contentEquals("WED")) {
        	System.out.println(4);
        }else if(S.contentEquals("THU")) {
        	System.out.println(3);
        }else if(S.contentEquals("FRI")) {
        	System.out.println(2);
        }else if(S.contentEquals("SAT")) {
        	System.out.println(1);
        }

	}
}






Measured memory_bytes: 21844
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	s = chomp(s);
	char win = 'd';
	for(int i=0;i<3;i++){
	    if(s[3*i] != 's' && s[3*i] == s[3*i+1] && s[3*i] == s[3*i+2]) win = s[3*i];
	}
	for(int i=0;i<3;i++){
	    if(s[i] != 's' && s[i] == s[i+3] && s[i+6] == s[i]) win = s[i];
	}
	if(s[4] != 's'){
	    if(s[0] == s[4] && s[0] == s[8]) win = s[0];
	    else if(s[2] == s[4] && s[2] == s[6]) win = s[2];
	}

	writeln(win);
    }
}

Measured memory_bytes: 2384
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,w,a,b;
	cin>>h>>w>>a>>b;
	for(ll i=0;i<h;i++)
	{
	   for(ll j=0;j<w;j++)
	   {
	       if((i<b)^(j<a))
	        cout<<1;
	       else
	        cout<<0;
	   }
	   cout<<endl;
	}
    return 0;
}


//252908XL

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	ll ans = 0, cnt = 0;
	for(auto& x : s) {
		if( x == 'B' ) cnt++;
		else ans += cnt;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


 
void solve(void)
{  
  int N;cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  if(vec[0] != 0)
  {
    cout<<-1<<endl;
    return;
  }
  int res = 0;
  for (int i = 1; i < N; i++)
  {
    if(vec[i] - vec[i-1] == 1)
    {
      res ++;
    }
    else if(vec[i] <= vec[i-1])
    {
      res += vec[i];
    }
    else
    {
      cout<<-1<<endl;
      return;
    }
    
    
  }
  cout<<res<<endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 4776
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

ll solve(vector<ll> C);

int main() {

    ll N;
    string S;

    cin >> N >> S;

    vector<ll> C(26, 0);

    rep(i, N) {
        C[S[i] -'a']++;
    }

    ll ans;

    ans = solve(C);

    cout << ans;

    return 0;
}

ll solve(vector<ll> C) {
    ll tmp = 1, D = pow(10, 9) + 7;

    rep(i, 26) {
        if (C[i] > 0) {
            tmp *= C[i] + 1;
            if (tmp > D) {
                tmp %= D;
            }
        }
    }
    tmp--;

    return tmp;
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  int ans;
  if (n % k == 0) ans = 0;
  else ans = 1;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
long long mod=1e9+7;
int main(){
	int n;
	cin>>n;
	long long dp[101][4][4][4]={};//a:0,t:1,g:2,c:3
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				dp[3][i][j][k]=1;
			}
		}
	}
	dp[3][0][2][3]=0;
	dp[3][0][3][2]=0;
	dp[3][2][0][3]=0;
	for(int i=4;i<=n;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				for(int l=0;l<4;l++){
					for(int m=0;m<4;m++){
						if(m==0&&j!=0&&k==2&&l==3){
							continue;
						}else if(m==0&&j==2&&k!=3&&l==3){
							continue;
						}
						(dp[i][j][k][l]+=dp[i-1][m][j][k])%=mod;
					}
				}
			}
		}
		//
		dp[i][0][2][3]=0;
		dp[i][0][3][2]=0;
		dp[i][2][0][3]=0;
	}
	long long ans=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				(ans+=dp[n][i][j][k])%=mod;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int a,b;
int main() {
	//freopen("1.txt","r",stdin);
	read(a);read(b);
	if (a>b) swap(a,b);
	if ((b-a)%2==0) printf("%d\n",(a+b)/2);
	else printf("IMPOSSIBLE\n");
	return 0;
}

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

using namespace std;
typedef long long ll;

int h,w;
char p[1010][1010];
int dp[1010][1010];
int mod=1e9+7;
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)
        scanf("%s",p[i]+1);
    //dp[1][1]=1;
    for(int i=1;i<=w;i++){
        if(p[1][i]!='#') dp[1][i]=1;
        else break;
    }
    for(int i=2;i<=h;i++){
        if(p[i][1]!='#') dp[i][1]=1;
        else break;
    }
    for(int i=2;i<=h;i++)
     for(int j=2;j<=w;j++)
        if(p[i][j]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
     cout<<dp[h][w]%mod<<endl;
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

void solve(){
	int x;
	cin >> x;
	if(x >= 30){
		cout << "Yes\n";
	}	
	else cout << "No\n";
	return ;
}

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t = 1;

	while(t--){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
 
int main(){
    long long int a;
    scanf("%lld",&a);
 
    char name[100];
    int i=0;
    
    while(a!=0){
        a--;
        int b = a%26;

        name[i] ='a'+ b;
        a/=26;
        i++;
    }
 
    for(int j=i-1;j>=0;j--){
        printf("%c",name[j]);
    }
    
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

struct UnionFind {
    vector<ll> par, s;
    UnionFind(ll n) : par(n), s(n, 1) { iota(ALL(par), 0); }
    ll find(ll x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(ll x, ll y) {
        x = find(x), y = find(y);
        if(x == y) return;
        if(s[x] < s[y]) par[x] = y, s[y] += s[x];
        else par[y] = x, s[x] += s[y];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    ll size(int x) { return s[find(x)]; }
};

int main(void) {
    ll n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<set<ll>> g1(n);
    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g1[a].insert(b);
        g1[b].insert(a);
        uf.unite(a, b);
    }
    vector<ll> blo(n);
    REP(i, k) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        if(uf.same(a, b) && g1[a].find(b) == g1[a].end()) {
            blo[a]++;
            blo[b]++;
        }
    }

    REP(i, n) {
        ll num = uf.size(i) - g1[i].size() - blo[i] - 1;
        cout << num << (i==n-1 ? '\n' : ' ');
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 17280
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto c = RD!string;
	auto str = "aiueo";
	bool ans;
	foreach (s; str)
	{
		if (s == c[0])
			ans = true;
	}
	
	writeln(ans ? "vowel" : "consonant");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=sc.nextInt();
		}
		
		int ans = bubbleSort(arr);
		for(int i=0;i<arr.length;i++)
		{
			if(i==arr.length-1)
			{
				System.out.print(arr[i]);
			}
			else
			{
				System.out.print(arr[i]+" ");
			}
		}
		System.out.println();
		System.out.println(ans);
	}
	
	public static int bubbleSort(int[] arr)
	{
		int count = 0;
		for(int i=0;i<arr.length;i++)
		{
			for(int j=0;j<arr.length-1-i;j++)
			{
				//每一轮放最大的到最后
				if(arr[j]>arr[j+1])
				{
					int temp = arr[j];
					arr[j] = arr[j+1];
					arr[j+1] = temp;
					count++;
				}
			}
		}
		
		return count;
	}
}



Measured memory_bytes: 26340
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

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

    int sum = 0;
    for (int i = 1; i <= N; i++)
    {
        sum += i;
    }

    cout << sum << endl;

    return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if(N % 2 == 1){
  	cout << "No" << endl;
  }else{
  	for(int i = 0; i < N/2; i++){
    	if(S.at(i) != S.at(i + N /2)){
        	cout << "No" << endl;
           break;
        }
      if(i == (N/2) - 1){
      	cout << "Yes" << endl;
      }
    }
  }
}

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

int main(){
  int N;
  cin>>N;
  int y=0;
  for(int i=0;i<25;i++)if(N>=4*i&&(N-4*i)%7==0)y++;
  if(y)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ans=0;
pair<int,int> pp[220000];
string s,sa[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    sort(aa,aa+n);
    rep(i,n-1){
        cnt+=aa[n-(i+1)/2-1];
    }
    cout<<cnt;
}

Measured memory_bytes: 12020
import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main(){
  int[] lists;
  foreach(i; 0..10){
    lists.length++;
    lists[i] = readln.chomp.to!int;
  }
  
  sort!("a > b")(lists);

  foreach(e; lists[0..3])
   writeln(e);
}

Measured memory_bytes: 1056
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	S := getString()

	diffCnt := 0
	for i := 0; i < len(S)/2; i++ {
		if S[i] != S[len(S) - 1 - i] {
			diffCnt++
		}
	}
	fmt.Println(diffCnt)
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999


int main(void){
    int* A;
    NEW(A,7);
    scanf("%d %d %d %d %d %d",&A[1],&A[2],&A[3],&A[4],&A[5],&A[6]);

    int* count;
    NEW(count,5);
    for(int i=1;i<=4;i++){
        count[i]=0;
    }
    for(int i=1;i<=6;i++){
        if(A[i]==1){
            count[1]++;
        }
        else if(A[i]==2){
            count[2]++;
        }
        else if(A[i]==3){
            count[3]++;
        }
        else if(A[i]==4){
            count[4]++;
        }
    }
    
    int c1,c2;
    c1=0;
    c2=0;
    for(int i=1;i<=4;i++){
        if(count[i]==1){
            c1++;
        }
        else if(count[i]==2){
            c2++;
        }
    }

    if(c1==2&&c2==2){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

	int S,h,m,s;

	scanf("%d",&S);

	h=S/3600;
	S=S-h*3600;
	m=S/60;
	s=S-m*60;

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

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



int main(){
    int n; cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];
    deque<int> v;

    rep(i,0,n){
        int b=lower_bound(v.begin(),v.end(),a[i])-v.begin();
        if(b==0){
            v.push_front(a[i]);
        }
        else{
            v[b-1]=a[i];
        }
    }
    cout<<v.size()<<endl;
}

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

 #include <stdio.h>

 int main(){
   int i,j,a[3],b[3],cnt=0;
   for(i=0;i<3;i++){
     scanf("%d %d",&a[i],&b[i]);
   }
   for(i=1;i<=4;i++){
     cnt=0;
     for(j=0;j<3;j++){
       if(i==a[j])cnt++;
       if(i==b[j])cnt++;
     }
     if(cnt>=3){
       printf("NO\n");
       return 0;
     }
   }
   printf("YES\n");
 }

Measured memory_bytes: 128