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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;

	lli ans = INF;
	//abピザを何枚買うか決める。
	REP(i,0,200100){
		lli X = max(0LL,x-i/2);
		lli Y = max(0LL,y-i/2);

		lli cost = X*a+Y*b+i*c;
		ans = min(ans,cost);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main(){
  int A,B; cin >> A >> B;
  if(A>=13) cout << B << endl;
  else if(6<=A && A<=12) cout << B/2 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    from collections import defaultdict,deque
    input = sys.stdin.readline
    N = int(input())
    Tree = defaultdict(list)
    for _ in range(N-1):
        u,v,w = map(int, input().split())
        Tree[u].append([v,w])
        Tree[v].append([u,w])
        
    visited = {}
    answer = [0]*N
    que = deque()
    que.append([1,0])
    while que != deque():
        tmp = que.pop()
        visited[tmp[0]] = 1
        for i in Tree[tmp[0]]:
            if not i[0] in visited:
                if (tmp[1] + i[1])%2 == 1:
                    answer[i[0]-1] = 1
                que.append([i[0],tmp[1] + i[1]])
    print(*answer,sep="\n")
    
main()

Measured memory_bytes: 96860
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>=(0);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)


int dp[110][110],A[2][110];

int main(){
    int N; cin >> N;
    rep(i,2)rep(j,N) cin >> A[i][j];

    rep(i,2)rep(j,N+1) dp[i][j] = -1;
    dp[0][0] = A[0][0];
    dp[1][0] = A[0][0] + A[1][0];

    for(int i = 1;i<N;++i) dp[0][i] = dp[0][i-1] + A[0][i];
    for(int i = 1;i<N;++i) dp[1][i] = A[1][i] + max(dp[0][i],dp[1][i-1]);

    cout << dp[1][N-1] << endl;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

#[allow(dead_code)]
fn readval<T: FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    
    buf.trim().parse::<T>().ok().unwrap()
}

fn readvec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();

    buf.trim().split(" ")
              .map(|c| c.parse::<T>().ok().unwrap())
              .collect::<Vec<T>>()
}

fn main() {
    let nm = readvec::<usize>();
    let (n, m) = (nm[0], nm[1]);

    let mut ab: Vec<Vec<u64>> = vec![];
    for _ in 0..n {
        ab.push(readvec::<u64>());
    }
    
    ab.sort();

    let mut res = m as u64;
    let mut ans = 0;

    for i in 0..n {
        if res == 0 {
            break;
        }

        else if res >= ab[i][1] {
            ans += ab[i][0] * ab[i][1];
            res -= ab[i][1];
        }

        else {
            ans += ab[i][0] * res;
            res = 0;
        }
    }

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


}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  string s, t;
  cin >> s >>t;

  int ans = 0;
  for (int i = 0; i < 3; i++) if (s[i] == t[i]) {
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

  unsigned long long a, b, c;
  cin >> a >> b >> c;
  if(a % (b + c) > b){
    cout << b * (a / (b + c)) + b;
  }else{
    cout << b * (a / (b + c)) + a % (b + c);
  }
  return 0;
}


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n, m;
  cin >> n >> m;

  int x = 0;
  REP(i, 0, n){
      int k;
      cin >> k;
      int bitmask = 0;
      REP(j, 0, k){
          int a;
          cin >> a;
          bitmask |= (1<<a);   //bitmasking in 1-index
      }
      x = (i == 0) ? bitmask : (x & bitmask);
  }

  cout << __builtin_popcount(x) << endl;



  return 0;
}


Measured memory_bytes: 256
package main
import . "fmt"
func main() {
  var n,x,m int
  var s string
  Scan(&n)
  Scan(&s)
  x,m = 0,0
  for i:=0;i<n;i++ {
    switch (s[i:i+1]) {
      case "I" : x++
      case "D" : x--
    }
    if m < x { m = x }
  }
  Println(m)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> d;

bool fo(int n)
{
    while (n > 0) {
        int tmp = n % 10;
        if (find(d.begin(), d.end(), tmp) != d.end())
            return false;
        n /= 10;
    }
    return true;
}

int main()
{
    int n, k; cin >> n >> k;
    d.resize(k);
    for (int i = 0; i < k; ++i) cin >> d[i];
    int ans = -1;

    for (int i = n; i < n * 11; ++i) {
        if (fo(i)) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())
inline void Fail(){
	printf("0");
	exit(0);
}

int a,b,c,d,e,f,ans1,ans2;
double den;

bool check(int sum,int x,int y){
	for(int i=0;i<=sum/x;i++){
		int lft=sum-i*x;
		if(lft%y==0)return true;
	}
	return false;
}

int main(){
	den=-1;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	for(int i=0;i<=f;i+=100){
		for(int j=0;j<=i/100*e;j++){
			if(i+j>f)break;
			if(check(i/100,a,b)&&check(j,c,d)){
				double cur=(double)j/(double)(i+j);
				if(cur>den){
					den=cur;
					ans1=i+j;
					ans2=j;
				}
			}
		}
	}
	printf("%d %d",ans1,ans2);
	return 0;
}

Measured memory_bytes: 256
a = 2, 3, 5
 
def f(n):
  m = memo.get(n)
  if m is None:
    m = min([d * n] + [f(k) + abs(p * k - n) * d + c for p, c in zip(a, b) for k in (n // p, 0--n // p)])
    memo[n] = m
  return m
 
t = int(input())
for _ in range(t):
  n, *b, d = map(int, input().split())
  memo = {0: 0, 1: d}
  print(f(n))

Measured memory_bytes: 11112
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int n,m,X;
   cin >> n >> m >> X;

   VI c(n);
   vector<VI> a(n,VI(m));
  rep(i,n){
    cin >> c.at(i);
    rep(j,m){
      cin >> a.at(i).at(j);
    }
  }
  int cst=100000000;
  rep(i,(1<<n)){
    vector<VI> b=a;
    VI d=c;
    rep(k,n){
      if(i & (1<<k)){
        d.at(k)=0;
        rep(x,m)b.at(k).at(x)=0;
      }
    }
    bool chk=true;
    int cnt=0;
    rep(l,n)cnt+=d.at(l);
    rep(k,m){
      int sum=0;
      rep(l,n){
        sum+=b.at(l).at(k);
      }
      
      if(sum<X)chk=false;
    }
    if(chk){
      cst=min(cst,cnt);
    }
  }
  if(cst==100000000)cout << -1 << endl;
  else cout << cst << endl;
}

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

#define ipow(a,b)+0.5 (int)pow(a,b)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fi first
#define se second

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,a,b) for(int i=a;i<=b;i++)

using namespace std;
typedef long long ll;
typedef long double ld;

class Task
{
public:
    void solve(istream& in,ostream& out)
    {
        int n;
        in>>n;

        out<<f(n)<<endl;
    }

    ll f(ll n)
    {
        ll k=1000000007;
        ll f[n+1];

        f[0]=1;

        for(int i=1;i<=n;i++)
        {
            f[i]=i*f[i-1];
            f[i]%=k;
        }

        return f[n];
    }
};


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Task solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in,out);
	out.flush();

    return 0;
}





Measured memory_bytes: 1024
/*
  B - すぬけ君の塗り絵 2 イージー / Snuke's Coloring 2 (ABC Edit)
  <http://abc047.contest.atcoder.jp/tasks/abc047_b>
*/

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

int main(int argc, char const *argv[]) {
  int W, H, N;
  int x, y, a;
  int w0, w1, h0, h1;
  int i;

  scanf("%d %d %d", &W, &H, &N);
  w0 = 0;
  w1 = W;
  h0 = 0;
  h1 = H;

  for( i=0; i<N; i++ ){
    scanf("%d %d %d", &x,&y,&a );
    if( (a==1)&&(x>w0) ) w0 = x;
    if( (a==2)&&(x<w1) ) w1 = x;
    if( (a==3)&&(y>h0) ) h0 = y;
    if( (a==4)&&(y<h1) ) h1 = y;
  }
  if( ((w1-w0)<0) || ((h1-h0)<0) ){
    printf("%d\n", 0);
  }else{
    printf( "%d\n", (w1-w0)*(h1-h0) );
  }

  return 0;
}


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

int main(){
  int a = 0;
  cin >> a;
  if(a==22) cout << "Christmas Eve Eve Eve" << endl;
  if(a==23) cout << "Christmas Eve Eve" << endl;
  if(a==24) cout << "Christmas Eve" << endl;
  if(a==25) cout << "Christmas" << endl;
}

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

int main() {
  int m,n;
  string cmd;
  int dx[4] = {0,1,0,-1};// north, east, south, west
  int dy[4] = {1,0,-1,0};
  int dir;
  int x,y, k;

  while( cin>>m>>n && (m||n) ){
    x=1; y=1; dir=0;
    while( cin>>cmd ){
      //      cout << "cmd:"<<cmd<<"\tx="<<x<<" y="<<y <<" dir="<<dir<< endl;

      k=0;
      if( cmd=="FORWARD" ){
	cin >> k;
      }else if( cmd=="BACKWARD" ){
	cin >> k;
	k=-k;
      }else if( cmd=="RIGHT" ){
	dir = (dir+1)%4;
      }else if( cmd=="LEFT" ){
	dir = (dir+4-1)%4;
      }else {
	break;
      }

      x+=(k*dx[dir]); y+=(k*dy[dir]);
      if( x<1 ) x=1;
      else if( x>m ) x=m;
      if( y<1 ) y=1;
      else if( y>n ) y=n;
    }
    cout << x << " " << y << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b - a <= 0)
		cout << "delicious\n";
	else if (b - a <= x)
		cout << "safe\n";
	else
		cout << "dangerous\n";

	return 0;
}

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

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define int long long
#define ull unsigned long long
#define pii pair<int,int>
#define vii vector<int>
#define f first
#define s second
#define endl "\n"
#define all(container) container.begin(), container.end()
#define onlyunique(v) v.erase(unique(all(v)), v.end());

#define TRACE
#ifdef AYUSH
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

int const mod = 1e9 + 7;
int const inf = 1e18;

int power(int x, int y, int mod = 2e18) { int ans = 1; x %= mod; while (y) {if (y & 1)ans = (x * ans) % mod; x = (x * x) % mod; y >>= 1;} return ans;}
int modinv(int a, int m) {return power(a, m - 2, m);}

void solve() {
	string a, b;cin>>b>>a;
	if(a.substr(0, a.size()-1) == b){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}

}
signed main() {
	IOS
	int t = 1, T = 1;
	// cin>>t;
	while (t--) {
		// cout<<"Case #"<<T<<": ";
		solve();
		// ++T;
	}
	return 0;
}

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

#define N 1000000
int main() {
  vector<int> table(N,1);
  table[0]=table[1]=0;
  for (int i=2; i*i<N; i++)
    if (table[i])
      for (int j=i*2; j<N; j+=i)
        table[j] = 0;
  int n;
  while(cin>>n) {
    int ans=0;
    for (int i=2;i<=n;i++) {
      if (table[i]) ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 4804
#include <stdio.h>
#define Fori(g) for(int i=0;i<g;i++)
#define	Forj(g) for(int j=0;j<g;j++)
#define min(aa,bb)  (aa<bb)?aa:bb
#define max(aa,bb)  (aa<bb)?bb:aa
//#define gcd(aa,bb)  ((!bb)?aa:gcd(bb,aa%bb))

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",(a<b*2)?0:(a-b*2));
	return 0;
}

Measured memory_bytes: 128
H, W, K = gets.split.map(&:to_i)
c = []
H.times{
    c << gets.chomp
}
r = 0
(2 ** H).times{|h|
    (2 ** W).times{|w|
        s = []
        c.each{|l|
            s << l.dup
        }
        #warn "%d,%d,%p" % [h, w, s]
        H.times{|i|
            if (h >> i) % 2 == 1
                s[i] = "." * W
            end
        }
        W.times{|i|
            if w % 2 == 1
                H.times{|j|
                    s[j][i] = "."
                }
            end
            w /= 2
        }
        #warn s.inspect
        sum = s.sum{|l|l.count("#")}
        if sum == K
            r += 1
        end
    }
}
puts r


Measured memory_bytes: 14372
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
vert = [[0] * W for _ in range(H)]; hori = [[0] * W for _ in range(H)];
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            hori[i][j] = hori[i][j-1] + 1 if j > 0 else 1
    for j in range(W-2, -1, -1):
        if grid[i][j] == '.' and grid[i][j+1] == '.':
            hori[i][j] = hori[i][j+1] 
for j in range(W):
    for i in range(H):
        if grid[i][j] == '.':
            vert[i][j] = vert[i-1][j] + 1 if i > 0 else 1
    for i in range(H-2, -1, -1):
        if grid[i][j] == '.' and grid[i+1][j] == '.':
            vert[i][j] = vert[i+1][j]
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            ans = max(ans, hori[i][j] + vert[i][j] - 1)
print(ans)

Measured memory_bytes: 124376
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int N,M,R;
int r[8];
int dist[201][201];

int visited[8];

int main(){
  cin >> N >> M >> R;
  for(int i=0;i<R;++i){
    cin >> r[i];
    r[i]--;
  }

  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if(i!=j) dist[i][j] = 1000000000;
    }
  }

  for(int i=0;i<M;++i){
    int a,b,c;
    cin >> a >> b >> c;
    dist[a-1][b-1] = c;
    dist[b-1][a-1] = c;
  }

  for(int k=0;k<N;++k){
    for(int i=0;i<N;++i){
      for(int j=0;j<N;++j){
        dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }

  int min_total_dist = 1000000000;
  std::vector<int> v(R);
  std::iota(v.begin(),v.end(),0);
  do{
    int total_dist = 0;
    for(int i=0;i<R-1;++i){
      total_dist += dist[r[v[i]]][r[v[i+1]]];
    }
    if(min_total_dist>total_dist) min_total_dist = total_dist;
  }while(std::next_permutation(v.begin(),v.end()));

  cout << min_total_dist << endl;
  return 0;
}


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

using namespace std;

int main()
{
    long long int a,b,x, i = 0;

    cin>> a>> b>> x;

    if( a% x == 0) i++;

    i += ((b/x)-(a/x));

    cout<< i<< endl;

    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int64_t pow(int64_t a,int64_t b,int64_t p)
{
	if(b==0)return 1;
	if(b%2==0)
	{
		int64_t d=pow(a,b/2,p);
		return (d*d)%p;
	}
	else
	{
		return (a*pow(a,b-1,p))%p;
	}
}

void mkfact(vector<int64_t> &vec,int64_t n,int64_t p)
{
	vec.resize(n+1);
	for(auto&& i:vec)
		i=1;
	
	for(int64_t i=1;i<=n;i++)
	{
		vec[i]=vec[i-1];
		vec[i]*=i;
		vec[i]%=p;
	}
	return;
}

void mkifact(vector<int64_t> &ivec,vector<int64_t> &vec,int64_t n,int64_t p)
{
	ivec.resize(n+1);
	for(auto&& i:ivec)
		i=1;
	
	for(int64_t i=1;i<=n;i++)
	{
		ivec[i]=vec[i];
		ivec[i]=pow(vec[i],p-2,p);
	}
	return;
}

const lint mod=1e9+7;

int main()
{
	lint H,W,A,B;

	cin >> H >> W >> A >> B;

	vector<lint> v,iv;
	mkfact(v,H+W,mod);
	mkifact(iv,v,H+W,mod);
	lint ans=0;
	for(lint h=H-A,w=B+1;h>0 && w<=W;h--,w++)
	{
		lint i,j;
		lint f=0,s=0;

		i=h-1;
		j=w-1;
		f=((v[i+j]*iv[i])%mod)*iv[j];
		f%=mod;
		
		i=H-h;
		j=W-w;
		s=((v[i+j]*iv[i])%mod)*iv[j];
		s%=mod;

		ans+=(f*s)%mod;
		ans%=mod;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
n,x,y=map(int,input().split())

d=[[-1 for i in range(n)] for j in range(n)]
for i in range(n):
  d[i][i]=0
num=[0 for i in range(n)]
g=[[i+1] for i in range(n-1)]
g.append([])
for i in range(1,n):
  g[i].append(i-1)
x-=1
y-=1
g[x].append(y)
g[y].append(x)

def bfs(start,dist=0):
  #global d
  #global g
  q=[start]
  while q:

    dist+=1
    now=q.pop(0)
    #print("now",now,"q",q,"d",d)
    for i in g[now]:
      if d[start][i]!=-1:
        continue
      else:
        d[start][i]=d[start][now]+1
        q.append(i)
 
for i in range(n):
  bfs(i)

for i in range(n-1):
  for j in range(i+1,n):
    if d[i][j]>=n:
      continue
    num[d[i][j]]+=1

for i in range(1,n):
  print(num[i])

Measured memory_bytes: 78940
#include <bits/stdc++.h>
using namespace std;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n;
double t[110], v[110];


int main(){
  double ans = 0.0;
   cin >> n;

   for(int i = 0; i < n; i++)   cin >> t[i];
   for(int i = 0; i < n; i++)   cin >> v[i];
    t[n] = v[n] = 0;
    for(int i = n-1; i >= 0; i--)   v[i] = min(v[i], v[i+1]+t[i]);

    double nv = 0, nt = 0;
   
   for(int i = 0; i < n; i++){

       while(t[i] > 0){
                  //printf("%lf %lf\n", ans, nv);
           if(nv-t[i] == v[i+1]){
                ans += (nv+v[i+1])*t[i]/2;
                t[i] = 0;
                nv = v[i+1];
           }
           else if(nv == v[i]){
               ans += v[i] * 0.5;
               t[i]-=0.5;
           }
           else{
               ans += (nv*2 + 0.5)*0.5/2;
               t[i] -= 0.5;
               nv += 0.5;
           }
       }
   }

    printf("%.8f\n", ans);
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n_, m_, d_;cin >> n_ >> m_ >> d_;
    double n = n_;
    double m = m_;
    double d = d_;
    if(d_ == 0){
        printf("%.9lf\n", (n-d)*(m-1)/n/n);
    }else{
        printf("%.9lf\n", 2.0*(n-d)*(m-1)/n/n);
    }
    return 0;
}


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

bool calc(ll n) {
  vector<pair<ll, ll>> p;
  for(int i = 2; i*i <= n; i++) {
    if(n % i != 0) continue;
    int cnt = 0;
    while(n % i == 0) {
      n /= i;
      cnt++;
    }
    p.push_back({i, cnt});
  }
  if(n != 1) p.push_back({n, 1});
  if(p.size() == 1) {
    if(p[0].second == 1) {
      return true;
    }
  }
  return false;
}

int main() {
  int x;
  cin >> x;
  for(int i = x; i <= 100003; i++) {
    bool ok = calc(i);
    if(ok) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3628
N = int(input())
max_num = (0,0) #(数値,idx)
max_candi = (0,0) #(数値,idx)
for i in range(N):
    A = int(input())
    if max_candi[0] < A and max_num[0] < A:
        max_candi = max_num
        max_num = (A,i)
    elif max_candi[0] < A:
        max_candi = (A,i)

for i in range(N):
    if i == max_num[1]:
        print(max_candi[0])
    else:
        print(max_num[0])

Measured memory_bytes: 4668
#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cout << "\n\nTime elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
}
#else
#define endl '\n'
#define trace(...)
#define start_routine()
#define end_routine()
#endif

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }
const ll maxn = 100005;
ll dp[maxn][102];
ll dp2[maxn][102];

ll sum(ll x){
    ll s = 0;
    while(x>0){
        s += x%10;
        x/=10;
    }
    return s;
}

int main()
{ 
    start_routine();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        string s;
        cin>>s;
        // stringstream harsh(s);
        // ll n;
        // harsh>>n;
        // n/=3;
        // n%=mod;
        // trace(n);
        ll d; cin>>d;
        rep(i,10) {
            dp[s.length()-1][i%d] += 1;
        }
        repr(i,s.length()-1) {
            rep(j,d) {
                    rep(k,10) {
                        dp[i][(j+k)%d] = (dp[i][(j+k)%d] + dp[i+1][j])%mod;
                    }
            }
        }
        ll ans = 0, su = 0;
        rep(i,s.length()-1) {
            rep(j,s[i]-48){
                ll index = (100*d - j - su )%d;
                ans = (ans + dp[i+1][index])%mod;
            }
            su += s[i]-48; su%=d;
        }
        rep(i,10){
            if((su+i)%d == 0 && i<=s[s.length()-1]-48){
                ans = (ans + 1)%mod;
            }
        }
        ans--;
        ans = ans+mod;
        ans %= mod;
        cout<<ans<<endl;
    }
    end_routine();
}

Measured memory_bytes: 10624
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
using namespace std;

int mypower(int x, int y){ //xのy乗
  int result = 1;
  for(int i=0;i<y;i++){
    result *= x;
  }
  return result;
}

int main(){
  int N,A,B,C;
  cin >> N >> A >> B >> C;
  int l[N] = {};
  for(int i=0;i<N;i++){
    cin >> l[i];
  }

  int mp = 100000;
  int mypow[N] = {};
  mypow[0] = 1;
  for(int i=1;i<N;i++){
    mypow[i] = mypow[i-1] * 4;
  }
  int jMax = mypow[N-1] * 4;

  for(int j=1;j<jMax;j++){
    int tmpA = 0;
    int tmpB = 0;
    int tmpC = 0;

    int take[3] = {0,0,0};
    int tmpMP = 0;
    for(int i=0;i<N;i++){
      int tmp = (j/mypow[i])%4;
      if(tmp == 1){
        if(tmpA > 0) tmpMP += 10;
        tmpA += l[i];
        take[0]++;
      }else if(tmp==2){
        if(tmpB > 0) tmpMP += 10;
        tmpB += l[i];
        take[1]++;
      }else if(tmp==3){
        if(tmpC > 0) tmpMP += 10;
        tmpC += l[i];
        take[2]++;
      }
    }
    if(take[0] == 0 || take[1] == 0 || take[2] == 0){
      continue;
    }

    tmpMP += abs(A - tmpA);
    tmpMP += abs(B - tmpB);
    tmpMP += abs(C - tmpC);
    if(tmpMP < mp){
      mp = tmpMP;
    }
  }

  cout << mp << "\n";
  return 0;
}


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

using namespace std;

const int N = 200200;
const int mod = 1e9 + 7;

int fac[N], ifac[N], inv2[N];

void add(int &x,int y) {
  x += y;
  if (x >= mod) x -= mod;
}

int mul(int x,int y) {
  return (long long) x * y % mod;
}

int pw(int x,int y) {
  int ans = 1;
  for (; y > 0; y >>= 1) {
    if (y & 1) ans = mul(ans, x);
    x = mul(x, x);
  }
  return ans;
}

void precalc() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i) fac[i] = mul(fac[i - 1], i);
  ifac[N - 1] = pw(fac[N - 1], mod - 2);
  for (int i = N - 1; i > 0; --i) ifac[i - 1] = mul(ifac[i], i);
  inv2[0] = 1;
  for (int i = 1; i < N; ++i) inv2[i] = mul(inv2[i - 1], (mod + 1) >> 1);
}

int C(int n,int k) {
  if (n < k || k < 0) return 0;
  return mul(fac[n], mul(ifac[k], ifac[n - k]));
}

int main() {
  precalc();
  int b, w;
  scanf("%d %d", &b, &w);
  int cb = 0, cw = 0;
  for (int i = 0; i < b + w; ++i) {
    if (i > 0) {
      add(cb, mul(C(i - 1, b - 1), inv2[i]));
      add(cw, mul(C(i - 1, w - 1), inv2[i]));
    }
    printf("%d\n", mul(inv2[1], mod + 1 - cb + cw));
  }
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i,m) {
        int k;
        cin >> k;
        rep(j,k) {
            int x;
            cin >> x;
            s[i].push_back(x);
        }
    }
    vector<int> p(m);
    rep(i,m) cin >> p[i];
    int ct = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
        vector<int> A;
        for (int i = 0; i < n; i++) {
            if (bit & 1<<i) A.push_back(1);
            else A.push_back(0);
        }
        bool ok = true;
        rep(i,m) {
            int sum = 0;
            rep(j,s[i].size()) {
                sum += A[s[i][j]-1];
            }
            sum %= 2;
            if (sum != p[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ct++;
    }
    cout << ct << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N; cin>>N;
  string s; cin>>s;
  int a[N];
  int b[N];
  a[0] = 0;
  REP(i,N-1){
    a[i+1] = a[i]+(s[i]=='W');
  }
  b[N-1] = 0;
  REPR(i,N-2){
    b[i] = b[i+1]+(s[i+1]=='E');
  }
  int r;
  REP(i,N){
    if(i==0){r = a[0]+b[0];}
    else{ r = min(a[i]+b[i],r); if(r==0){break;}}
  }
  cout << r;
}


Measured memory_bytes: 2948
#include <iostream>
using namespace std;
int main(void){
    long int H, W;
    cin >> H >> W;
    long int max;
    max = H * W / 2;
    if (H * W % 2 == 1)
        max ++;
    if (H == 1 || W == 1)
        max = 1;
    cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
#define ll long long
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define rrep(i,a,b) for(ll i=a;i>b;i-=1)
#define vi vector<ll>
#define vii vector<vector<ll> >
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define tr(c,i) for( typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mp make_pair
#define hell 1000000007
#define F first
#define S second
//debug
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
ll t=1;

ll w[100000],v[100000],dp[100000];

void solve()
{
    int n;
    cin>>n;
    int m;
    cin>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i];
        cin>>v[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=m;j>=0;j--)
        {
            if(j>=w[i]) dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout<<dp[m];
}
int main()
{
    int i;
  	ios_base::sync_with_stdio(false);
	cin.tie(0);
    cout.tie(0);
  	//cin>>t;
  	while(t--)
	solve();
	return 0;
}


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

typedef long long ll;

#define Forn(i, n) for(int i=1; i<=(n); i++)
#define forn(i, n) for(int i=0; i<(n); i++)
#define lid id<<1|1
#define rid (id<<1)+2

int T, A, B, C, D, l, r, len; 
char ret[2005];
string s;

inline int calc(int x, int y)
{
    return (x+y)/(y+1);
}

inline void brute()
{
    int tot=A+B, lst=0;
//    cout<<"start to ()"<<endl;
    Forn(i, tot)
    {
        A--;
        if(A>=0&&B>=0&&calc(max(A, B), min(A, B))<=len&&lst+1<=len)
            ret[i]='A', lst++;
        else
            A++, B--, ret[i]='B', lst=0;
    }
    for(int i=C; i<=D; i++)
        putchar(ret[i]);
//    if(ret[r]!='A') puts("ERROR");
    puts("");
}

inline int check(int x)
{
    int a=A-x/(len+1)*len-x%(len+1);
    int b=B-x/(len+1);
    if(a<0||b<0) return 0;
    return b<=1LL*len*a;
}

inline void solve()
{
    l=-1, r=A+B+1;
//    cout<<"len="<<len<<endl;
    while(l+1<r)
    {
        int m=l+r>>1;
        if(check(m)) l=m;
        else r=m;
    }
    int a=A-r/(len+1)*len-r%(len+1);
    int b=B-r/(len+1);
    l=r;
    r=l+b-a*len+1;
    for(int i=C; i<=min(D, l); i++) putchar(i%(len+1)?'A':'B');
    for(int i=max(C, l+1); i<=D; i++) putchar((i-r)%(len+1)?'B':'A');
    puts("");
}

int main()
{
    scanf("%d", &T);
    while(T--)
    {
        scanf("%d %d %d %d", &A, &B, &C, &D);
        len=calc(max(A, B), min(A, B));
        if(A+B<=2000) brute();
        else solve();
    }
    return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
f=lambda x:int(x)-1
p=list(map(f,input().split()))
par=[j for j in range(n)]
def find(x):
  if x==par[x]:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
 
def union(a,b):
  ra=find(a)
  rb=find(b)
  if ra!=rb:
    par[ra]=rb
 
for i in range(m):
  v,w=map(f,input().split())
  union(v,w)
 
ans=0
for j in range(n):
  if find(j)==find(p[j]):
    ans+=1
print(ans)

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

int main() { long long N;
cin >> N;
vector<long long> a(N + 1);
a.at(0) = 10e9 + 10;
erep(i, N) cin >> a.at(i);
sort(a.begin(), a.end());
reverse(a.begin(), a.end());

 long long lin1 = 0;  long long lin2 = 0;
 long long cnt = 0; bool gonext = true;

// rep(i, N - 3){
//   if(a.at(i) == a.at(i + 1) && a.at(i) == a.at(i + 2) && 
//   a.at(i) == a.at(i + 3)){
//     lin1 = a.at(i); lin2 = a.at(i);
//     gonext = false;
//   }
// }

// if(gonext){
erep(i, N - 1){
if(a.at(i - 1) != a.at(i) && a.at(i) == a.at(i + 1)){
  cnt++;
  if(i <= N - 3 && cnt == 1){
  if(a.at(i) == a.at(i + 1) && a.at(i) == a.at(i + 2) && 
  a.at(i) == a.at(i + 3)){
    lin1 = a.at(i); lin2 = a.at(i);
    break;
  }
  }

  if(cnt == 1){
    lin1 = a.at(i);
  }
  if(cnt == 2) lin2 = a.at(i);
}
}
// }
 long long ans = lin1 * lin2;
cout << ans << endl;
  return 0;
 
}

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


int mod(string num, int a) { 
    int res = 0; 
    for (int i = 0; i < num.length(); i++){ 
        res = (res*10 + (int)num[i] - '0') %a;
    } 
  
    return res; 
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0,w=0;
    for(int i=0;i<n;i++){
        if(s[i] == 'W'){
            w++;
        }
        else{
            r++;
        }
    }
    int count = 0;
    for(int i=0;i<r;i++){
        if(s[i] == 'W'){
            count++;
        }
    }
    cout<<count;

    
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
using namespace std;
template<class TT>inline void read(TT &xx)
{
	xx=0;char cc=getchar();bool ff=false;
	while(cc<'0'||cc>'9'){if(cc=='-')ff=true; cc=getchar();}
	while(cc>='0'&&cc<='9'){xx=(xx<<3)+(xx<<1)+cc-'0';cc=getchar();}
	if(ff) xx=-xx;
}
int main()
{
   long long n,x,t;
   read(n);read(x);read(t);
   printf("%lld\n",t*(long long)ceil((double)n/x));
   return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

int n,x,count = 1;

cin >> n;

if (1 <= n && n <= 9)
{
    cout << n << endl;
}else if (10 <= n && n <= 99)
{
    cout << 9 << endl;
}else if (100 <= n && n <= 999)
{
    cout << 9+n-99 << endl;
}else if (1000 <= n && n <= 9999)
{
    cout << 9+900 << endl;
}else if (10000 <= n && n <= 99999)
{
    cout << 9+900+n-9999 << endl;
}else{
    cout << 9+900+90000 << endl;
}






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

const int INF=1e9;
const ll INFF=1e17;
const double EPS=1e-9;
const ll MOD=1e9+7;
const int MAXN=1e5+10;
int n,gr[MAXN];
bool vis[MAXN];
vector<vector<int> > g(MAXN);
void dfs(int v){
	gr[v]=0;
	vis[v]=1;
	for(auto u:g[v]){if(!vis[u]){dfs(u);gr[v]^=(gr[u]+1);}}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	REP(i,n-1){
		int t1,t2;
		cin >> t1 >> t2;t1--;t2--;
		g[t1].pb(t2);
		g[t2].pb(t1);
	}
	REP(i,n)vis[i]=0;
	dfs(0);
	cout << (!gr[0]?"Bob":"Alice") << '\n';
	return 0;
}


Measured memory_bytes: 10880
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
count = 0
lenA = len(A)
lenB = len(B)
lenC = len(C)
for b in B:
  count += (bisect.bisect_left(A, b))*(lenC-bisect.bisect_right(C, b))
print(count)


Measured memory_bytes: 105444
#include <stdio.h>

int main(void)
{
	int N;
	int i, j, x,count=0, flag=1;
	scanf("%d", &N);
	int a[N];
	for(i=0; i<N; i++){
		scanf("%d", &a[i]);
	}
	while(flag==1){
		flag=0;
		for(j=1;j<N;j++){
			if(a[j]<a[j-1]){
				x=a[j];
				a[j]=a[j-1];
				a[j-1]=x;
				count++;
				flag=1;
			}
		}
	}
	
	
	for(i=0; i<N-1; i++){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[N-1]);
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 2100
#include<iostream>

using namespace std;

int main(){
  int list[5], i, j, temp;
  cin >> list[0] >> list[1] >> list[2] >> list[3] >> list[4];
  for(i=0; i<5; i++){
    for(j=i+1; j<5; j++){
      if(list[i] <= list[j]){
	temp = list[i];
	list[i] = list[j];
	list[j] = temp;
      }
    }
  }
  for(i=0; i<4; i++)cout << list[i] << " ";
  cout << list[4] << endl;
}

Measured memory_bytes: 3096
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

immutable EPS = 10e-12;

double solve(cdouble a, cdouble b, cdouble c) {
	return (a.re - b.re) * (c.im - b.im) - (a.im - b.im) * (c.re - b.re);
}

void main()
{
	foreach (line; stdin.byLine) {
		auto x = line.chomp.split(",").map!(to!double);
		cdouble[4] a;
		a[0] = x[0] + x[1] * 1i;
		a[1] = x[2] + x[3] * 1i;
		a[2] = x[4] + x[5] * 1i;
		a[3] = x[6] + x[7] * 1i;
		
		int cnt;
		foreach (i; 0..4) {
			if (solve(a[i%4], a[(i+1)%4], a[(i+2)%4]) > EPS) cnt++;
		}
		if (cnt % 4) writeln("NO");
		else writeln("YES");
	}
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll mod = 1000000000 + 7;

ll powmod(ll x, ll y) {
    ll res = 1;
    for (int i = 0; i < y; i++) {
        res = (res * x) % mod;
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n);
    ans %= mod;
    ans = (ans + mod) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X,Y;
    cin >> X >> Y;
    ll ans = 0;
    if(X == 1 && Y == 1){
        ans += 400000;
    }
    if(X == 1){
        ans += 300000;
    }else if(X == 2){
        ans += 200000;        
    }else if(X == 3){
        ans += 100000;
    }
    if(Y == 1){
        ans += 300000;
    }else if(Y == 2){
        ans += 200000;        
    }else if(Y == 3){
        ans += 100000;
    }
    print(ans);

    

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std; 
 
#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/
 
void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}
 
int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;
 
	if(N==2)   return 1;
	if(N%2==0) return 0;
 
	for(i=3;i<N && N%i!=0;i+=2);
 
	if(i>=N) return 1;
	
	return 0;
}
 
int factorial(int N){  //Nの階乗を求める関数
	int ans=1;
 
	while(N--) ans*=(N+1);
	return ans;
}
 
//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;
 
    x = a[(first + last) / 2];
    i = first; j=last;
 
    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}
 
int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}
 
unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];
 
    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}

int main(){
    string N;

    cin>>N;
    if(N[0]=='7' || N[1]=='7' || N[2]=='7'){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3128
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    x=input()
    if (x=="RE"):
        re+=1
    if (x=="WA"):
        wa+=1
    if (x=="TLE"):
        tle+=1
    if (x=="AC"):
        ac+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)
    

Measured memory_bytes: 69872
#include<cstdio>
int n,x,lastans;
long long ans;
int main()
{
	scanf("%d",&n);
	scanf("%d",&lastans);
	for(int i=2;i<=n;i++) scanf("%d",&x),ans+=lastans>x?lastans-x:0,lastans=x<lastans?lastans:x;
	printf("%lld",ans);
	return 0;
}

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

int gcd(int a, int b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a % b);
}

int main() {
  int n;
  cin >> n;
  vector<int> A(n), bef(n), back(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];

    if (i == 0) bef[i] = A[i];
    else bef[i] = gcd(A[i], bef[i - 1]);
  }

  back[n - 1] = A[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    back[i] = gcd(A[i], back[i + 1]);
  }

  int ans = max(bef[n - 2], back[1]);

  for (int i = 1; i < n - 1; i++) {
    ans = max(ans, gcd(bef[i - 1], back[i + 1]));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/abc103/tasks/abc103_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    vector<ll> A(3); for(auto& in:A) cin >> in;
    sort(A.begin(),A.end());
    ll ans = 0;
    for(int i = 0; i < 2;i++){
        ans += A[i+1] - A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256