akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
//-- 小文字97-122(+32)
struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> siz;

  UnionFind(int N)
      : par(N)
      , siz(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) {
      par[i] = i;
      siz[i] = 1;
    }
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx==ry) {
      return; //xとyの根が同じ(=同じ木にある)時はそのまま
    } else {
      if (size(rx) < size(ry))
        swap(rx, ry);
      par[ry] = rx;           //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
      siz[rx] += siz[ry]; // 大きさを付け換える
    }
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x)
  {
    return siz[root(x)];
  }
};
int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind fav(n);
  vector<int> fav_par(n, 0);
  vector<int> res(n, 0);
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    res[a]--;
    res[b]--;
    fav.unite(a, b);
  }

  rep(i, k)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (fav.same(a, b)) {
      res[a]--;
      res[b]--;
    }
  }
  rep(i, n)
  {
    res[i] += fav.size(i) - 1;
    cout << res[i];
    if (i != n - 1)
      cout << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2432
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = 26
D = inp()
c = inpl()
s = [inpl() for _ in range(D)]
last = [0] * n
res = [-1] * D
for d in range(D):
    ans = -1
    mx = -INF
    for i in range(n):
        now = s[d][i]
        for j in range(n):
            if i == j: continue
            now -= s[d][j] * (last[j]+1)
        if now > mx:
            mx = now
            ans = i
    res[d] = ans+1
    for j in range(n):
        last[j] += 1
        if j == ans: last[j] = 0
for x in res:
    print(x)

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

vector<int> topologicalSort(const Graph &G){
	int n = G.size();
	vector<int> in(n),ret;
	queue<int> que;
	for(int i = 0;i < n;i++){
		for(int to : G[i]) in[to]++;
	}
	for(int i = 0;i < n;i++){
		if(!in[i]) que.push(i);
	}
	while(!que.empty()){
		int v = que.front(); que.pop();
		ret.push_back(v);
		for(int to : G[v]){
			in[to]--;
			if(!in[to]) que.push(to);
		}
	}
	return ret;
}

signed main(){
	int n,m;
	cin >> n >> m;
	Graph G(n);
	for(int i = 0;i < m;i++){
		int s,t;
		cin >> s >> t;
		G[s].push_back(t);
	}
	auto topo = topologicalSort(G);
	for(int v : topo) cout << v << endl;
}


Measured memory_bytes: 3692
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File              : b.py
# Author            : recurze
# Date              : 21:54 18.01.2019
# Last Modified Date: 21:56 18.01.2019

s = str(raw_input())
ans = float('inf')
for i in xrange(len(s) - 2):
    ans = min(ans, abs(int(s[i:i+3]) - 753))
print ans


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a,b;
    cin>>a>>b;
    int ha=(a+49)/50*2+1;
    int hb=(b+49)/50*2+1;
    a--;b--;
    cout<<ha+hb<<' '<<100<<endl;
    REP(i,ha){
        REP(j,100){
            cout<<(i%2==0 && j%2==0 && i*25+j/2<a ?'.':'#');
        }
        cout<<endl;
    }
    REP(j,100)cout<<'.';
    cout<<endl;
    REP(i,hb-1){
        REP(j,100){
            cout<<(i%2==0 && j%2==0 && i*25+j/2<b ?'#':'.');
        }
        cout<<endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=2010;
char s[2];
int f[N][N],s1[N+N][N],s2[N+N][N],p1[N],p2[N];
int main() {
    int n;
    cin>>n;
    memset(f,127/3,sizeof(f));
    f[0][0]=0;
    for(int i=1;i<=n+n;i++) {
	int x;
	scanf("%s%d",s,&x);
	if(s[0]=='B') s1[i][x]=1,p1[x]=i;
	else s2[i][x]=1,p2[x]=i;
	for(int j=n;j;j--) {
	    s1[i][j]+=s1[i-1][j]+s1[i][j+1]-s1[i-1][j+1];
	    s2[i][j]+=s2[i-1][j]+s2[i][j+1]-s2[i-1][j+1];
	}
    }
    for(int i=0;i<=n;i++)
	for(int j=0;j<=n;j++) {
	    if(i) f[i][j]=min(f[i][j],f[i-1][j]+s1[p1[i]][i+1]+s2[p1[i]][j+1]);
	    if(j) f[i][j]=min(f[i][j],f[i][j-1]+s1[p2[j]][i+1]+s2[p2[j]][j+1]);
	}
    cout<<f[n][n];
    return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 62;

lli a,b;
lli ans = 0;

lli f(lli x){
  if(x%4 == 0) return x;
  else if(x%4 == 1) return 1;
  else if(x%4 == 2) return x+1;
  else return 0;
}

int main(){
  cin >> a >> b;
  if(a == 0) cout << f(b) << endl;
  else cout << (f(a-1)^f(b)) << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a[25],b[25],c[25],ans=0;
int main(void){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<n;i++)cin>>c[i];
	ans+=b[a[0]];
//	cout<<b[a[0]]<<endl;
	for(int i=1;i<n;i++){
		ans+=b[a[i]];
//		cout<<b[a[i]]<<' ';
		if(a[i]-1==a[i-1]){
			ans+=c[a[i-1]];
//			cout<<c[a[i]];
		}
//		cout<<endl;
	}
	cout<<ans;
	return 0;
}

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

int main(){
	int H, W, K; cin >> H >> W >> K;
	char s[H][W];
	int ans[H][W];
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> s[i][j];
		}
	}
	int prev = 0, cnt = 1;
	for(int i=0; i<H; i++){
		vector<int> a;
		for(int j=0; j<W; j++){
			if(s[i][j] == '#') a.push_back(j);
		}
		if(a.size() > 0){
			if(a.size() == 1){
				for(int j=prev; j<=i; j++){
					for(int k=0; k<W; k++){
						ans[j][k] = cnt;
					}
				}
				cnt++;
			}else{
				int t = 0;
				for(int k=0; k<W; k++){
					for(int j=prev; j<=i; j++){
						if(k <= a[t]) ans[j][k] = cnt;
						else{
							if(t == a.size() - 1){
								ans[j][k] = cnt;
							}else{
								cnt++;
								t++;
								ans[j][k] = cnt;
							}
						}
					}
				}
				cnt++;
			}
			prev = i+1;
		}else{
			if(i == H-1){
				for(int k=prev; k<H; k++){
					for(int j=0; j<W; j++){
						ans[k][j] = ans[prev-1][j];
					}
				}
			}
		}
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cout << ans[i][j] << " ";
		}
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 1152
n = int(input())
p = list(map(float, input().split()))

# コインをn回投げて、表がj枚の確率
dp = [[0] * (n+1) for _ in range(n+1)]

dp[0][0] = 1
for i in range(n):
    dp[i+1][0] = dp[i][0] * (1-p[i])
    for j in range(n):
        dp[i+1][j+1] = dp[i][j] * p[i] + dp[i][j+1] * (1-p[i])
print(sum(dp[n][(n+1)//2:]))


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

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

ll N, M, R;
vector<VL> d;
VL r;
vector<bool> went;
ll num, ans;

void warshall_floyd() {
    REP(k, num) REP(i, num) REP(j, num) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
}

void dfs(ll depth, ll now, ll cost) {
    if(depth == R) {
        ans = min(cost, ans);
        return;
    }
    REP(i, R) if(!went[i]) {
        went[i] = true;
        if(now == -1)
            dfs(depth + 1, i, 0);
        else
            dfs(depth + 1, i, cost + d[r[now]][r[i]]);
        went[i] = false;
    }
}

int main() {
    cin >> N >> M >> R;
    num = N;
    d.assign(N, VL(N, LINF));
    went.resize(R);
    r.resize(R);
    REP(i, R) r[i] = IN() - 1;
    REP(i, M) {
        LCIN(A, B, C);
        d[--A][--B] = d[B][A] = C;
    }
    warshall_floyd();
    ans = LINF;
    dfs(0, -1, 0);
    cout << ans << "\n";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[55];
int n;
bool check(){
    for(int i=1;i<n;++i){
        if(a[i]>=a[i+1])
        return false;
    }
    return true;
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    int flag=0;
    if(check()){puts("YES");return 0;}
    for(int i=1;i<n;++i){
        for(int j=i+1;j<=n;++j){
            swap(a[i],a[j]);
            if(check()){
                flag=1;
                break;
            }
            swap(a[i],a[j]);
        }
        if(flag)break;
    }
    if(flag)puts("YES");
    else puts("NO");

}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll A,B,K;
  cin>>A>>B>>K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      if(A%2)A--;
      B+=A/2;
      A/=2;
    }
    else{
      if(B%2)B--;
      A+=B/2;
      B/=2;
    }
  }
  cout<<A<<" "<<B<<endl;
  return 0;
}


Measured memory_bytes: 256
s=set(list(input()))
ns=0
ew=0
if 'N' in s and 'S' in s:
  ns=1
elif 'N' not in s and 'S' not in s:
  ns=1

if 'E' in s and 'W' in s:
  ew=1
elif 'E' not in s and 'W' not in s:
  ew=1

if ns&ew:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int a[1<<17],b[1<<17];
main()
{
	int n,m;
	while(cin>>n>>m,n)
	{
		for(int i=0;i<n;i++)a[i]=b[i]=0;
		for(;m--;)
		{
			int s,k;cin>>s>>k;
			if(k==1)
			{
				int x;cin>>x;
				x--;
				a[x]+=s;
				b[x]+=s;
			}
			else
			{
				for(;k--;)
				{
					int x;cin>>x;x--;b[x]+=s;
				}
			}
		}
		int ans=1e9;
		int id=0;
		for(int i=0;i<n;i++)
		{
			if(a[id]>a[i])id=i;
		}
		int M=0;
		for(int i=0;i<n;i++)if(i!=id)M=max(M,b[i]);
		ans=M-a[id]+1;
		id=0;
		for(int i=0;i<n;i++)
		{
			if(b[id]<b[i])id=i;
		}
		M=1e9;
		for(int i=0;i<n;i++)if(i!=id)M=min(M,a[i]);
		ans=max(ans,b[id]-M+1);
		cout<<ans<<endl;
	}
}



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

int main() {
	int a,b;
  	cin>>a>>b;
  
  int ans=-1;
  
  for(int i=0;i<=1000;i++){
  if(floor(i*0.08)==a&&floor(i*0.1)==b){
  	ans=i;
    break;
  }
    
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> yama(10);
    for(int i=0;i<10;i++){
        cin >> yama[i];
    }
    sort(yama.begin(),yama.end());
    cout << yama[9] << "\n" << yama[8] << "\n" << yama[7] << "\n";
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a = 0, b = 0;
    rep(i, 0, s.size()){
        if(i % 2 == s[i] - '0') a++;
        else b++;
    }
    cout << min(a, b) << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  long a[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i]-1;
  }
  printf("%ld\n", sum);

  return 0;
}

Measured memory_bytes: 128
import copy
function = 0
start = 1
end = 2
replaceStr = 3
reverseStart=0
reverseEnd=0
str = 3
reverseTarget=[]
reversedStr=[]
inStr = list(input())
outStr = copy.deepcopy(inStr)
commandNumber = int(input())
for currentNumber in range(commandNumber):
    command = input().split(" ") # [commandName, start, end (replaceStr)]
    if command[function] == "print":
        printStart = int(command[start])
        printEnd = int(command[end])
        print("".join(outStr[printStart:printEnd+1]))
    
    elif command[function] == "reverse":
        reverseStart = int(command[start])
        reverseEnd = int(command[end])
        reverseTarget.append(outStr[reverseStart:reverseEnd+1])
        reversedStr = reverseTarget[-1][::-1]
        outStr[reverseStart:reverseEnd+1] = reversedStr
    
    elif command[function] == "replace":
        replaceStart = int(command[start])
        replaceEnd = int(command[end])
        replaceStr = list(command[str])
        outStr[replaceStart:replaceEnd+1] = replaceStr


Measured memory_bytes: 6380
import java.util.*;

class Main{       
   public static void main(String[] args){

      Scanner sc = new Scanner(System.in);                                            
            
      int N = sc.nextInt();
      int a[] = new int[N];
      
      for(int i = 0;i < N;i++){
          a[i] = sc.nextInt();
      }
      
      Arrays.sort(a);
      
      int start = a[0];
      int end = a[a.length - 1];
      
     int sum = Integer.MAX_VALUE;
     
     for(int i = start; i <= end;i++){
         int ans = 0;
         for(int j = 0;j < N;j++){
           ans += (a[j]-i)*(a[j] - i);         
         }
         sum = Math.min(sum,ans);
     }

      System.out.println(sum);
      
   }
}
        
        



Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,b=1;
    cin>>N;
    vector<int> d;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        d.push_back(a);
    }
    sort(d.begin(),d.end());
    for(int i=0;i<N;i++){
        if(d[i]<d[i+1]){
            b=b+1;
        }
    }
    cout<<b<<endl;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  ll tot = 0;
  rep(i,n) tot ^= a[i];
  rep(i,n) {
    ll ans = a[i] ^ tot;
    cout << ans << ' ';
  }
}

Measured memory_bytes: 4668
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;

int INF=1e8;
int d[100][100];
vector<tuple<int,int,int>> V;

int main(){
    fill(d[0],d[100],INF);
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++){
        d[i][i]=0;
    }
    for(int i=0;i<M;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        d[a][b]=d[b][a]=c;
        V.emplace_back(a,b,c);
    }
    for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
    int ans=0;
    for(auto v:V){
        if(d[get<0>(v)][get<1>(v)]!=get<2>(v)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin>>tt; while(tt--)
#define mp make_pair
#define pb push_back
#define lchild (2*node+1)
#define rchild (2*node+2)
#define f first
#define s second
#define br cout<<endl
#define MOD (1000000007LL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

ull pwr(ull base, ull p, ull mod=MOD){
    ull ans = 1;
    while(p){
        if(p&1)ans=((ans%mod) * (base%mod))%mod;
        base=((base%mod) * (base%mod))%mod;
        p/=2;
    }
    return ans;
}

const int N = (int) 1e6+500;
int n;
int root[N];

void build(){
    for(int i=0; i<n; ++i){
        root[i]=i;
    }
}
int get_root(int a){
    if(root[a]!=a){
        root[a]=get_root(root[a]);
    }
    return root[a];
}

bool un(int a, int b){
    a = get_root(a);
    b = get_root(b);
    if(a==b){
        return false;
    }
    else{
        root[a] = b;
        return true;
    }
}

vector<pair<ll, int> >vx,vy;
vector<tuple<ll, int, int> > edge;

int main(){
    FIO
    cin >> n;
    build();
    for(int i=0; i<n; ++i){
        ll x,y;
        cin >> x >> y;
        vx.pb(mp(x,i));
        vy.pb(mp(y,i));
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());

    for(int i=0; i<vx.size()-1; ++i){
        ll cost = abs(vx[i].f - vx[i+1].f);
        edge.pb(make_tuple(cost, vx[i].s, vx[i+1].s));
    }
    for(int i=0; i<vy.size()-1; ++i){
        ll cost = abs(vy[i].f - vy[i+1].f);
        edge.pb(make_tuple(cost, vy[i].s, vy[i+1].s));
    }
    ll res = 0;
    sort(edge.begin(), edge.end());

    for(int i=0; i<edge.size(); ++i){
        ll d; int u,v;
        tie(d,u,v) = edge[i];
        if(un(u,v)){
            res += d;
        }
    }

    cout << res << endl;

return 0;
}


Measured memory_bytes: 10084
SS, T = $<.map &:chomp
SS.tr!(??,?.)
(SS.size-T.size).downto(0){|from|
  to = from + T.size
  if T[/^#{SS[from...to]}$/]
    $* << SS[0...from].tr(?.,?a) + T + SS[to..-1].tr(?.,?a)
  end
}
puts $*.empty? ? :UNRESTORABLE : $*.min


Measured memory_bytes: 1788
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }
      
      int sum = 0;
      
      for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
          sum += a[i] * a[j];
        }
      }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23764
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;






int main(void) {
	string S;
	cin >> S;
	int c = 0;
	for(int i=0; i< S.length(); i++) {
		if( S[i] == '1' ) c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    int n,x;
    cin >> n >> x;

    vector<int> result(2*n-1,-1);

    if(x == 1 || x == 2*n - 1){
        cout << "No" << endl;
    }else{
        int j = (2*n-1)/2;
        result[j] = x;
        result[j+1] = 1;
        result[j-1] = 2*n-1;
        j = 0;
        for(int i = 2; i < 2*n-1; i++){
            if(i == x){
                continue;
            }
            while(result[j] != -1){
                j++;
            }
            result[j] = i;
            j++;
        }

        cout << "Yes" << endl;

        for(int i = 0; i < 2*n-1; i++){
            cout << result[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2304
n = int(input())
arr = []
for i in range(n):
  [a,b] = map(int,input().split())
  arr.append([a,b])
for i in range(2,n):
  if arr[i-2][0]==arr[i-2][1] and arr[i-1][0]==arr[i-1][1] and arr[i][0]==arr[i][1]:
    print('Yes')
    break
else:
  print('No')
  


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 5e2 + 5;
const int mod = 1e9 + 7;
int n , a[maxn][maxn];
ll dp[maxn][maxn];
ll sum[maxn][maxn];
ll sum1[maxn][maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 1 ; j <= n ; ++j){
            if(i != j)cin >> a[i][j];
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
            sum1[i][j] = sum1[i - 1][j] + sum1[i][j - 1] - sum1[i - 1][j - 1] + (i < j ? a[i][j] : 0);
        }
    }
    for(int i = 1 ; i <= n ; ++i){
        dp[i][1] = sum1[i][i];
        for(int j = 2 ; j <= i ; ++j){
            dp[i][j] = 1e18;
            for(int k = 1 ; k < j ; ++k){
                dp[i][j] = min(dp[i][j] , dp[j - 1][k]
                               + sum1[i][i] - sum1[i][j-1] - sum1[j - 1][i] + sum1[j-1][j-1]
                               + sum[i][k - 1] - sum[j-1][k - 1]);
//                cout << sum1[i][i] - sum1[i - 1][j] - sum1[i][j-1] + sum1[j-1][j-1] << endl;
            }
        }
    }
    cout << *min_element(dp[n]+1,dp[n]+n+1);
}


Measured memory_bytes: 7168
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<stack>
#include<sstream>
#include<string>
#include<cassert>
#include<ctime>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
int kase = 0;
int n, m;
const double eps = 1e-10;
stack<int> s;
const int maxn = 200020;
int a[maxn];

int main()
{
	while (cin >> n >> m)
	{
		memset(a, 0, sizeof(a));
		for (int i = 0; i < m; i++)
		{
			int tmp;
			scanf("%d", &tmp);
			s.push(tmp);
		}
		while (!s.empty())
		{
			int tmp = s.top();
			s.pop();
			if (a[tmp] == 0)
			{
				printf("%d\n", tmp);
				a[tmp] = 1;
			}
		}
		for (int i = 1; i <= n; i++)
			if (a[i] == 0)
				printf("%d\n", i);

	}
}

Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int k;

int main(){
    cin >> k;
    vector<ll> a(k);
    Rep(i,k){
        cin >> a[i];
    }
    vector<ll> maxc(k+1);
    maxc[k]=2;
    vector<ll> minc(k+1);
    minc[k]=2;
    for(int i=k-1;i>=0;--i){
        if(i==k-1){
            if(2%a[k-1]!=0){
                put("-1");
                return 0;
            }
        }
        if(i>0){
            ll mi = (minc[i+1]-1)/a[i-1]+1;
            ll ma = (maxc[i+1]+a[i]-1)/a[i-1];
            if(ma>=mi&&mi>0){
                maxc[i]=ma*a[i-1];
                minc[i]=mi*a[i-1];
            }else{
                put("-1");
                return 0;
            }
        }else{
            ll mi = minc[i+1];
            ll ma = maxc[i+1]+a[i]-1;
            maxc[i] = ma;
            minc[i] = mi;
        }
    }
    cout << minc[0] << " " << maxc[0] << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	string S, T;
	cin >> S >> T;
	int len = T.size();
	if(T.substr(0, len-1) == S){
		cout << "Yes";
	}else{
		cout << "No";
	}
	return 0;
}


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

using namespace std;
#define ll long long
#define go ios::sync_with_stdio(0)
int main()
{
    go;
    ll x,ans=0;
    cin>>x;
    map <ll,ll> cnt;
    for(ll i=2;i*i<=x;i++)
    {
        while(x%i==0)
        {
            x/=i;
            cnt[i]++;
        }
    }
    if(x!=1)
        cnt[x]++;
    for(pair<ll,ll> xx : cnt)
    {
        ll now=xx.second;
        for(ll i=1;;i++)
        {
            if(now-i>=0)
            {
                ans++;
                now-=i;
            }
            else
                break;
        }
    }
    cout<<ans;
    return 0;
}


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

int main()
{
	char c;
		cin >> c;
	if ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
}

Measured memory_bytes: 256
# abc149_c.py
import sys
import time
import unittest
from io import StringIO
import numpy as np


def resolve():
    X = int(input())
    x = np.array([i for i in range(2, -(-X // 2))])
    while 0 in (X % x):
        X += 1
    print(X)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def assertTLE(self, input):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin

    # def test_入力例_n(self):
    #     input = """val"""
    #     self.assertTLE(input)

    def setUp(self):
        self.startTime = time.time()

    def tearDown(self):
        t = time.time() - self.startTime
        print('%s: %.3f' % (self.id(), t), flush=True)

    def test_入力例_1(self):
        input = """20"""
        output = """23"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """99992"""
        output = """100003"""
        self.assertIO(input, output)


if __name__ == "__main__":
    if "IS_LOCAL" in locals():
        suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
        unittest.TextTestRunner(verbosity=0).run(suite)
    else:
        resolve()


Measured memory_bytes: 14736
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>

using namespace std;
using ll = long long;

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    vector<int> count(n,0);
    for(int i = 1;i <= n - 1;++i){
        for(int j = i + 1;j <= n;++j){
            if(i <= x && y <= j){
                int a = j - i;
                int b = j - y + x - i + 1;
                ++count[min(a,b)];
               //cout << "i = " << i << ",j = " << j << ",dist = " << min(a,b) << endl;
            }
            else if(i <= x){
                int a = j - i;
                int b = x - i + y - j + 1;
                ++count[min(a,b)];
                //cout << "i = " << i << ",j = " << j << ",dist = " << min(a,b) << endl;
            }
            else if(y <= j){
                int a = j - i;
                int b = i - x + j - y + 1;
                ++count[min(a,b)];
                //cout << "i = " << i << ",j = " << j << ",dist = " << min(a,b) << endl;
            }
            else{
                int a = j - i;
                int b = y - j + i - x + 1;
                ++count[min(a,b)];
                //cout << "i = " << i << ",j = " << j << ",dist = " << min(a,b) << endl;
            }
        }
    }
    for(int i = 1;i < n;++i){
        cout << count[i] << endl;
    }
}


Measured memory_bytes: 888
N, M = map(int, input().split())
A = list(map(int, input().split()))
opes = [tuple(map(int, input().split())) for _ in range(M)]
opes.sort(key=lambda x:-x[1])

D = []
lenD = 0
for B, C in opes:
    D += [C]*B
    lenD += B
    if lenD >= N:
        break

A.sort()
for i, d in enumerate(D[:N]):
    if A[i] >= d:
        break
    A[i] = d

print(sum(A))


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

using namespace std;

using int64 = long long;

struct Event {
  enum EventType { UNDEFINED, ADD, REMOVE, QUERY } event_type;
  int query_id = -1;
  int64 x = INT64_MIN;
};

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

  int n, q;
  cin >> n >> q;

  vector<pair<int64, Event>> events;
  for (int i = 0; i < n; i++) {
    int64 s, t, x;
    cin >> s >> t >> x;
    events.push_back(make_pair(
        s * 4 - 1 - x * 4, Event({Event::ADD, -1, x})));
    events.push_back(make_pair(
        t * 4 - 3 - x * 4, Event({Event::REMOVE, -1, x})));
  }
  for (int i = 0; i < q; i++) {
    int64 d;
    cin >> d;
    events.push_back(make_pair(d * 4, Event({Event::QUERY, i, INT64_MIN})));
  }

  sort(events.begin(), events.end(), [](const auto& p1, const auto& p2) {
    return p1.first < p2.first;
  });

  set<int64> x_set;
  x_set.insert(INT64_MAX);
  vector<int64> answers(q);
  for (const auto& event : events) {
    if (event.second.event_type == Event::ADD) {
      x_set.insert(event.second.x);
    } else if (event.second.event_type == Event::REMOVE) {
      x_set.erase(event.second.x);
    } else if (event.second.event_type == Event::QUERY) {
      answers[event.second.query_id] = *x_set.begin();
    }
  }

  for (int64 answer : answers) {
    if (answer == INT64_MAX) answer = -1;
    cout << answer << endl;
  }
}


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

#define ll long long
#define mod 1000000007
ll task(ll y, ll k)
{
    ll x = 1;
    for(ll i=0; i<k; i++)
    {
        x=x*y%mod;
    }
    return x;
}
int main()
{
    ll n;
    cin >> n;
    ll ans = task(10,n) - task(9,n) - task(9,n) + task(8,n);
    ans%=mod;
    if(ans < 0)
    ans=(ans+mod)%mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <queue>

using namespace std;

typedef long long int ll;

int main(void){
  int K;
  cin >> K;
  queue<ll> q;
  for(int i=1;i<=9;i++){
    q.push(i);
  }
  if(K <= 9){
    cout << K << endl;
    return 0;
  }
  //10以上なら次のように行う
  for(int i=1;i<=9;i++){
    ll num = q.front();
    q.pop();
    int low = num%10;
    if(low - 1 >= 0)
      q.push(10*num + low - 1);
    q.push(10*num + low);

    if(low + 1 < 10)
      q.push(10*num + low + 1);
  }
  for(int i=10;i<K;i++){
    //cout << q.front() << endl;
    ll num = q.front();
    q.pop();
    int low = num%10;
    if(low - 1 >= 0)
      q.push(10*num + low - 1);
    q.push(10*num + low);

    if(low + 1 < 10)
      q.push(10*num + low + 1);

  }
  cout << q.front() << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
class Main{
	
    Scanner sc = new Scanner(System.in);
	int S;
	int h,m,s;
	void goo(){
		S = sc.nextInt();
		h=S/3600;
		m=S%3600/60;
		s=S%60;
		System.out.println(h+":"+m+":"+s);
	}
	public static void main(String[]agrs){
		new Main().goo();
	}
}
	

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

int main() {
	int n,a;
	cin >> n;
	int ans = 0;
	for (int i = 1; i < n+1; i++) {
		cin >> a;
		if (i % 2 == 1 && a % 2 == 1) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

vector<int> G[100100];

vector<int> par(100100, -1);

void bfs() {
  queue<pair<int, int>> q;
  q.push({0, 0});
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    //cout << p.first << endl;
    if (par[p.first] != -1) continue;
    par[p.first] = p.second;
    for (int v: G[p.first]) {
      if (par[v] != -1) continue;
      q.push({v, p.first});
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  bfs();
  cout << "Yes\n";
  FOR(i, 1, n) cout << par[i] + 1 << '\n';




  
  return 0;
}

Measured memory_bytes: 10796
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>

using namespace std;

int main() {
	int n, a[100];
	int counter=0;
	long long z[100], ans[200] = { 0 };

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == a[i - 1]) {
			counter += 1;
		
		}
		if (counter == n - 1) {
			cout << 0 << endl;
			return 0;
		}
	}

	
	for (int j = 0; j < 200; j++) {
		for (int i = 0; i < n; i++) {
			ans[j] += (a[i] -  j+100)*(a[i] - j+100);
		}
		if (ans[j] < 0)ans[j] = 10000;
	}

	sort(ans, ans + 200);

	

	cout << ans[0] << endl;

	return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
k = 200010
fact = [0] * k
fact[0] = 1

for i in range(k-1):
  fact[i+1] = (fact[i] * (n - i) * pow((i+1), mod -2 , mod))% mod


ans = pow(2, n, mod) - fact[a] - fact[b] - 1
ans = ans % mod
print(ans)



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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll n, m, v1, v2 ;
    cin >> n >> m ;
    v1 = (n * (n - 1)) / 2 ;
    v2 = (m * (m - 1)) / 2 ;
    cout << (v1 + v2) ;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var v = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToList();
        var result = 0;
        var ov = new List<int>();
        var ev = new List<int>();

        for(int i = 0; i < n; i++)
        {
            if (i % 2 == 0)
            {
                ov.Add(v[i]);
            }
            else
            {
                ev.Add(v[i]);
            }
        }

        var od = ov.GroupBy(g => g).OrderByDescending(o => o.Count());
        var ed = ev.GroupBy(g => g).OrderByDescending(o => o.Count());

        var a = od.First().Key;
        var b = ed.First().Key;

        if (a == b)
        {
            if (ov.Distinct().Count() != 1 && ev.Distinct().Count() != 1)
            {
                var ass = od.Skip(1);
                var bss = ed.Skip(1);

                var aa = ass.First().Count();
                var bb = bss.First().Count();

                if (aa > bb)
                {
                    a = ass.First().Key;
                }
                else
                {
                    b = bss.First().Key;
                }
            }
            else
            {
                b = a + 2;
            }
        }
        for(int i = 0; i < v.Count; i += 2)
        {
            if (a != v[i])
            {
                result++;
            }
        }
        for(int i = 1; i < v.Count; i += 2)
        {
            if (b != v[i])
            {
                result++;
            }
        }
        Console.WriteLine(result);


        
    }
}



Measured memory_bytes: 40380
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	long N,K;
	cin >> N >> K;
	vector<long> vec;
	long tmin;
	for (long i=0; i<N; i++) {
		long tmp;
		cin >> tmp;
		vec.push_back(tmp);
	}
	for (long i=0; i<N-K+1; i++) {
		if (i==0) {
			tmin = abs(vec[i])+abs(vec[i+K-1]-vec[i]) < abs(vec[i+K-1])+abs(vec[i+K-1]-vec[i])? abs(vec[i])+abs(vec[i+K-1]-vec[i]):abs(vec[i+K-1])+abs(vec[i+K-1]-vec[i]); 
		} else {
			if (tmin>abs(vec[i])+abs(vec[i+K-1]-vec[i])) tmin=abs(vec[i])+abs(vec[i+K-1]-vec[i]);
			if (tmin>abs(vec[i+K-1])+abs(vec[i+K-1]-vec[i])) tmin=abs(vec[i+K-1])+abs(vec[i+K-1]-vec[i]);
		}
	}
	cout << tmin << endl;
	return 0;
}


Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String[] strA = insBR.readLine().split(" ");
			int[] intA = new int[strA.length];
			for(int i = 0;i < strA.length ;i++){
				intA[i] = Integer.parseInt(strA[i]);
			}
			int intCount = 0;
			for(int i = intA[0]; i <= intA[1]; i++){
				int intDiv = intA[2] % i;
				if(intDiv == 0){
					intCount++;
				}
			}
			System.out.println(intCount);
		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}
	}

}



Measured memory_bytes: 24428
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXN = 2e5 + 10;

char s[MAXN];

int n;
int nxt[26][MAXN], dp[MAXN];

inline void precompute() {
  for (int i = 0; i < 26; ++i) {
    nxt[i][n] = n + 1;
    for (int j = n - 1; j >= 0; --j) {
      nxt[i][j] = nxt[i][j+1];
      if (s[j] - 'a' == i) nxt[i][j] = j+1;
    } 
  }
}

inline void reconstruct() {
  int curr = 0;
  while (curr < n) {
    // printf("%d ", curr);
    for (int i = 0; i < 26; ++i) {
      if (dp[curr] == dp[nxt[i][curr]] + 1) {
        curr = nxt[i][curr];
        printf("%c", 'a' + i);
        break;
      }
    }
  }
  printf("\n");
}

int main(void) {
  scanf("%s", s);
  n = strlen(s);
  
  precompute();
  
  for (int i = n; i >= 0; --i) {
    dp[i] = MAXN;
    for (int j = 0; j < 26; ++j)
      dp[i] = min(dp[i], 1 + dp[nxt[j][i]]);
  }
  
  // printf("%d\n", dp[0]);
  reconstruct();
  
  return 0;
}

Measured memory_bytes: 21504
#include <iostream>
#include <algorithm>
using namespace std;
int a[4];
int x[4]={1,4,7,9};
int main(){
  for(int i=0;i<4;i++)cin>>a[i];
  sort(a,a+4);
  for(int i=0;i<4;i++){
    if(a[i]!=x[i]){
      cout<<"NO\n";
      return 0;
    }
  }
  cout<<"YES\n";
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;

    vector<ll> s(A + 2), t(B + 2);
    s[0] = -1e18;
    s[A + 1] = 1e18;
    t[0] = s[0];
    t[B + 1] = s[A + 1];
    for (int i = 1; i < A + 1; i++) cin >> s[i];
    for (int i = 1; i < B + 1; i++) cin >> t[i];
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    while (Q--) {
        ll x;
        cin >> x;
        auto sR = lower_bound(s.begin(), s.end(), x) - s.begin();
        auto tR = lower_bound(t.begin(), t.end(), x) - t.begin();

        ll ans = 1e18;
        for (int j = -1; j < 1; j++) {
            for (int k = -1; k < 1; k++) {
                auto xs = s[sR + j], xt = t[tR + k];
                ans = min(ans, min(abs(x - xs), abs(x - xt)) + abs(xs - xt));
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2944