akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define maxn	500005
#define inf		int(21e8)
#define mod		int(1e9+7)
#define db		double
#define ll		long long
#define si 		stack<int>
#define qi 		queue<int>
#define vi 		vector<int>
#define pi 		pair<int, int>
#define pq  	priority_queue< int, vector<int>, greater<int> >
using namespace std;
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod;
	for (; b; b >>= 1)
		res = (res * ((b & 1) ? a : 1)) % mod,
		a = a * a % mod;
	return res;
}
ll gcd(ll a, ll b) {
	return b ? gcd(a, b) : a;
}
ll a[500005], b[500005];
ll sa[500005], sb[500005];
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i ++) cin >> a[i], sa[i] = sa[i - 1] + a[i];
	for(int i = 1; i <= m; i ++) cin >> b[i], sb[i] = sb[i - 1] + b[i];
	int now = m, ans = 0;
	for(int i = 0; i <= n; i ++) {
		while(sa[i] + sb[now] > k && now > 0) now --;
		if(sa[i] + sb[now] <= k) ans = max(ans, i + now);
	}
	cout << ans << endl;
	system("pause");
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int ,int> > v(n);
    for(int i=0 ; i<n; i++)
    {
        v[i].second=i;
        cin>>v[i].first;
    }
    sort(v.begin() , v.end());
    for(int i=0 ; i<n ; i++)
    {
        cout<<v[i].second+1<<" ";
    }
    cout<<endl;
    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

ll memo[1000];
ll fib(ll n) {
  if(n == 0) return 2;
  else if(n == 1) return 1;
  else if(memo[n]) return memo[n];
  else return memo[n] = fib(n-1) + fib(n-2);
}

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

  int a, b, c, k; cin >> a >> b >> c >> k;
  int ma = max(a, max(b, c));
  int d = ma;
  for(int i=0;i<k;++i) {
    ma *= 2;
  }
  cout << a + b + c - d + ma << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	b := make([]int, n)
	copy(b, a)
	sort.Sort(sort.Reverse(sort.IntSlice(b)))

	for i := range a {
		if a[i] == b[0] {
			fmt.Println(b[1])
		} else {
			fmt.Println(b[0])
		}
	}
}


Measured memory_bytes: 8064
import sys
from collections import deque
input = sys.stdin.readline

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)

dist = [[-1] * n for _ in range(n)]
for i in range(n):
    queue = deque([(i, 0)])
    while queue:
        v, c = queue.popleft()
        for v_next in graph[v]:
            if dist[i][v_next] == -1:
                dist[i][v_next] = c + 1
                queue.append((v_next, c+1))

# print(dist)
ans_len = n + 1
for i in range(n):
    if dist[i][i] != -1:
        ans_len = min(ans_len, dist[i][i])
if ans_len == n + 1:
    print(-1)
else:
    for i in range(n):
        if dist[i][i] == ans_len:
            start_v = i
            break

    dist = [-1] * n
    prev_v = [-1] * n
    queue = deque([(start_v, 0)])
    while queue:
        v, c = queue.popleft()
        if v == start_v and c != 0:
            break
        for v_next in graph[v]:
            if dist[v_next] == -1:
                dist[v_next] = c + 1
                prev_v[v_next] = v
                queue.append((v_next, c+1))

    ans = []
    # print(start_v)
    # print(dist)
    # print(prev_v)
    v = start_v
    for i in range(ans_len):
        ans.append(v+1)
        v = prev_v[v]

    print(ans_len)
    print(*ans, sep='\n')


Measured memory_bytes: 53612
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define pb           push_back
#define ff           first
#define ss           second
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
using namespace std;
const int mod = 1e9 + 7;
ll expo(ll a,ll b,ll m = mod){
	a%=mod;
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%m;
		a = (a*a)%m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}

void add_self(int &a,int b){
    a+=b;
    if(a>=mod) a-=mod;
}

int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
// 	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		bool can[n][n];
		for(int i=0;i<n;i++){
		    for(int j=0;j<n;j++){
		        cin>>can[i][j];
		      //  cout<<can[i][j]<<" ";
		    }
		  //  cout<<endl;
		}
		int dp[1<<n];
		mem(dp,0);
		dp[0] = 1;
		    for(int mask = 0; mask < (1<<n); mask++){
		        int a = __builtin_popcount(mask);
		        for(int b=0;b<n;b++){
		            if(can[a][b] && !(mask&(1<<b))){
		                int m2 = mask|(1<<b);
		                add_self(dp[m2],dp[mask]);
		              //  cout<<dp[m2]<<" ";
		            }
		        }
		    }
		
		cout<<dp[(1<<n)-1]<<"\n";
	}
    return 0;
}


Measured memory_bytes: 11812
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, x;
    cin >> N >> x;
    vector<int> v(N);
    for (auto &&i : v) {
        cin >> i;
    }

    SORT(v);
    int ans = 0;
    int i   = 0;
    while (0 < x && i < N) {
        x -= v[i++];
        ans++;
    }
    if (x != 0)
        ans--;
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, pointer;
ll con, h[MAXN];
ll a[MAXN], b[MAXN], dp[MAXN];
vector<ll> M, C;

ld getIntersection(int l1, int l2) {
    if (l2 == SZ(M)) return 1e20;
    return (ld) (C[l1] - C[l2]) / (M[l2] - M[l1]); 
}

ll query(ll k) {
    ll res = 0;
    int dau = 0, cuoi = SZ(M)-1;
    while (dau <= cuoi) {
        int mid = (dau + cuoi) >> 1;
        if (k <= getIntersection(mid, mid+1)) cuoi = mid-1; else dau = mid+1;
    }
    res = M[dau] * k + C[dau];
    return res;
}

bool isBad(int l1, int l2, int l3) {
    // bad khi giao cua l1 va l3 nam ben trai giao cua l1 va l2 // intersection(l1,l2) has x-coordinate (c1-c2)/(m2-m1)
    // intersection(l1,l3) has x-coordinate (c1-c3)/(m3-m1)
    return (ld) (C[l3] - C[l1]) / (M[l1] - M[l3]) < (ld) (C[l2] - C[l1]) / (M[l1] - M[l2]);
}

void add(ll m, ll c) {
    M.emplace_back(m);
    C.emplace_back(c);
    while (SZ(M) >= 3 && isBad(SZ(M)-3, SZ(M)-2, SZ(M)-1)) {
        M.erase(M.end()-2);
        C.erase(C.end()-2);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> con;
    FOR(i,1,n) cin >> h[i];
    dp[1] = 0;
    add(-h[1], dp[1] + h[1] * h[1]);
    pointer = 0;
    FOR(i,2,n) {
        dp[i] = query(2*h[i]) + con + h[i] * h[i];
        if (i != n) add(-h[i], dp[i] + h[i] * h[i]);
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 8808
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
const char bn = '\n';
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 (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

bool is_ok(string S){
    REP(i,S.size()-1){
        // debug(mp(S[i], S.end()[-i-2]))
        if(S[i] != S.end()[-i-2])
            return false;
    }
    if(S.back()=='1') return false;
    return S[0]=='1';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    if(is_ok(S)){
        int last = N-1;
        for(int i=N-2;i>=0;i--){
            cout << i+1 << " " << last+1 << bn;
            if(S[i]=='1') last = i;
        }
    }else{
        cout << -1 << bn;
    }

}

Measured memory_bytes: 1664
package main

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

var sc = bufio.NewScanner(os.Stdin)

const NIL = -1

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func getHeight(i int) int {
	var height_1, height_2 int

	if A[i].left == NIL && A[i].right == NIL {
		return 0
	}

	if A[i].left != NIL {
		height_1 = getHeight(A[i].left) + 1
	}
	if A[i].right != NIL {
		height_2 = getHeight(A[i].right) + 1
	}
	if height_1 > height_2 {
		return height_1
	} else {
		return height_2
	}
}

type Tree struct {
	parent int
	left   int
	right  int
}
type Trees [100000]Tree

var A Trees

func main() {
	var depth int
	var id, l_key, r_key int
	sc.Split(bufio.ScanWords)
	n := nextInt()

	for i := 0; i < n; i++ {
		A[i].parent = NIL
	}
	for i := 0; i < n; i++ {
		id = nextInt()
		l_key = nextInt()
		r_key = nextInt()
		A[id].left = l_key
		A[id].right = r_key
		if l_key != NIL && r_key != NIL {
			A[l_key].parent = id
			A[r_key].parent = id
		} else if l_key != NIL && r_key == NIL {
			A[l_key].parent = id
		} else if l_key == NIL && r_key != NIL {
			A[r_key].parent = id
		}
	}
	for i := 0; i < n; i++ {
		fmt.Printf("node %d: parent = %d, ", i, A[i].parent)
		if A[i].parent == NIL {
			fmt.Printf("sibling = -1, ")
		} else if A[A[i].parent].left == i {
			fmt.Printf("sibling = %d, ", A[A[i].parent].right)
		} else {
			fmt.Printf("sibling = %d, ", A[A[i].parent].left)
		}
		fmt.Printf("degree = ")
		if A[i].left != NIL && A[i].right != NIL {
			fmt.Printf("2, ")
		} else if A[i].left == NIL && A[i].right == NIL {
			fmt.Printf("0, ")
		} else {
			fmt.Printf("1, ")
		}
		num := i
		for A[num].parent != NIL {
			depth++
			num = A[num].parent
		}
		fmt.Printf("depth = %d, ", depth)
		depth = 0
		fmt.Printf("height = %d, ", getHeight(i))

		if A[i].parent == NIL {
			fmt.Printf("root\n")
		} else if A[i].left == NIL && A[i].right == NIL {
			fmt.Printf("leaf\n")
		} else {
			fmt.Printf("internal node\n")
		}
	}
}



Measured memory_bytes: 1108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, result = 1;
  cin >> N >> M;
  
  for (int i = N + M; i > N + M - 2; i--) {
    result *= i;
  }
  
  result /= 2;
  result -=N * M;
  
  cout << result << endl;
}

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

int n;
string s;
long long dp[4096][4096];
const int mod=1e9+7;

int main(){
	cin>>n;
	cin>>s;
	dp[1][1]=1;
	for(int i=2;i<=n;++i){
		if(s[i-2]=='<'){
			dp[i][1]=0;
			for(int j=2;j<=i;++j)
				dp[i][j]=(dp[i][j-1]+dp[i-1][j-1])%mod;
			}
		else {
			dp[i][i]=0;
			for(int j=i-1;j>=1;--j)
				dp[i][j]=(dp[i][j+1]+dp[i-1][j])%mod;
		}
	}
	long long ans=0;
	for(int i=1;i<=n;++i) ans+=dp[n][i],ans%=mod;
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 94720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r){
  if(l>=r) return;
  int root = pre[pos++];
  int m = distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}

void solve(){
  pos = 0;
  rec(0,pre.size());
  for(int i=0;i<n;i++){
    if(i) cout << " ";
    cout << post[i];
  }
  cout << endl;
}

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

  for(int i=0;i<n;i++){
    cin >> k;
    pre.push_back(k);
  }

  for(int i=0;i<n;i++){
    cin >> k;
    in.push_back(k);
  }

  solve();

  return 0;
}



Measured memory_bytes: 3152
from collections import defaultdict
n,m=map(int,input().split())
ab=defaultdict(lambda: [])
for i in range(m):
  a,b=map(int,input().split())
  ab[a].append(b)
for aa in ab[1]:
  for bb in ab[aa]:
    if bb == n:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

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

int main(void){
	int h,w;
	scanf("%d %d",&h,&w);
	char s[51][51];
	for(int i = 0;i < h*w;i++){
			scanf("%s",&s[i]);
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(s[i][j]=='#'){
				if(s[i - 1][j] == '.' && s[i][j - 1] == '.' && s[i][j + 1] == '.' && s[i + 1][j] == '.'){
					printf("No");
					return 0;
				}
			}
		}
	}
	printf("Yes");
	return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin>>s;
  
  vector<string> v;
  int cnt=0,start;
  bool flag=true;
  for(long long int i=0;i<s.size();i++){
    if(flag){
      start=i;
      flag=false;
    }
    if(s[i]==s[i+1]){
      cnt++;
    }else{
      v.push_back(s.substr(start,cnt+1));
      cnt=0;
      flag=true;
    }
  }
  cout<<v.size()-1<<endl;
}
///////////////////////////

Measured memory_bytes: 5876
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <cstring>

int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> s(n);
  for (int i = 0; i < n; ++i)
    std::cin >> s[n - 1 - i];
  std::vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    int cost = dp[i - 1] + std::abs(s[i] - s[i - 1]);
    for (int j = 2; j <= k && j <= i; ++j) {
      cost = std::min(cost,
        dp[i - j] + std::abs(s[i] - s[i - j]));
    }
    dp[i] = cost;
  }
  std::cout << dp[n - 1] << std::endl;
  return 0;
}

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

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  x += 499;
  cout << x / 1000 * min(a, b * 2) + (x - (x / 1000) * 1000) / 500 * min(a, b) << endl;
  return 0;
}



Measured memory_bytes: 3128
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		k--;
		String ans = s.substring(0,k);
		if(s.substring(k,k+1).equals("A")){
			ans = ans+"a";
		}else if(s.substring(k,k+1).equals("B")){
			ans = ans+"b";
		}else{
			ans = ans+"c";
		}
		ans = ans+s.substring(k+1,s.length());
		System.out.print(ans);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int h[1000001];
int main(){
    h[1]=1;
    for(int i=2;i<=1000000;i*=2)h[i]=1;
    for(int i=1;i<=1000000;i++){
        if(h[i]){
            for(int j=i*3;j<=1000000;j*=3)if(h[j]==0)h[j]=2;
        }
    }
    for(int i=1;i<=1000000;i++){
        if(h[i]){
            for(int j=i*5;j<=1000000;j*=5)if(h[j]==0)h[j]=3;
        }
    }
    int a,b;
    while(scanf("%d",&a),a){
        scanf("%d",&b);
        int ret=0;
        for(int i=a;i<=b;i++)if(h[i])ret++;
        printf("%d\n",ret);
    }
}


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

using lint = long long;

lint gcd(lint x, lint y){
    lint r = x % y;
    while(r != 0LL){
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

lint lcm(lint x, lint y){
    return x / gcd(x, y) * y;
}

int main(){
    lint a, b;
    while(cin >> a >> b){
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ios()                \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)

int gcd(int a, int b) {
    if (a < b) return gcd(b,a);
    int r;
    while((r = a%b)) {
        a = b;
        b = r;
    }
    return b;
}

signed main()
{
    ios();
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int cnum = b/c - (a-1)/c;
    int dnum = b/d - (a-1)/d;
    int g = gcd(c,d);
    int l = c * d / g;
    int cdnum = b/l - (a - 1)/l;
    cout << b - a + 1 - (cnum + dnum - cdnum) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const

inline
ll getint(){
	re ll num=0;
	re char c;
	while(!isdigit(c=gc()));
	while(isdigit(c))num=(num<<1)+(num<<3)+(c^48),c=gc();
	return num;
}

inline
void outint(ll a){
	static char ch[23];
	if(a==0)pc('0');
	while(a)ch[++ch[0]]=(a-a/10*10)^48,a/=10;
	while(ch[0])pc(ch[ch[0]--]);
}

int h,w;
int a[501][501];
struct op{
	int a,b,c,d;
	void out(){
		cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	}
};
vector<op> v;
int main(){
	h=getint();
	w=getint();
	for(int re i=1;i<=h;++i){
		for(int re j=1;j<=w;++j)a[i][j]=getint();
	}
	for(int re i=1;i<=h;++i){
		for(int re j=1;j<w;++j){
			if(a[i][j]&1){
				a[i][j]-=1;
				a[i][j+1]+=1;
				v.push_back(op{i,j,i,j+1});
			}
		}
	}
	for(int re i=1;i<h;++i){
		if(a[i][w]&1){
			a[i][w]-=1;
			a[i+1][w]+=1;
			v.push_back(op{i,w,i+1,w});
		}
	}
	outint(v.size());pc('\n');
	for(int re i=0;i<v.size();++i){
		v[i].out();
	}
	return 0;
}

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

int main()
{
    int c[4] ={};
    for(int i=0; i<3; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        c[a]++;
        c[b]++;
    }
    int one = 0;
    int two = 0;
    for(auto e: c){
        if(e == 1) one++;
        if(e == 2) two++;
    }
    
    if(one == 2 && two == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

int n, a[100100], dp[100100];

int main() {
	cin>>n;
	for(int i = 0; i < n; i++) {
		cin>>a[i];
		if(i) dp[i] = abs(a[i] - a[i-1]) + dp[i-1];
		if(i > 1) dp[i] = min(dp[i], abs(a[i] - a[i-2]) + dp[i-2]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct Point{
	int x;
	int y;
};
struct Line{
	int a;
	int b;
	int c;
	bool operator <(Line y) const {
		return mp1(this->a,this->b,this->c) < mp1(y.a,y.b,y.c);
	}
};

int gcd(int x,int y){
	if(y == 0)return x;
	return gcd(y,x%y);
}

Line f(Point A,Point B){
	Line ret;
	ret.a = A.x-B.x;
	ret.b = A.y-B.y;
	int g = gcd(abs(ret.a),abs(ret.b));
	if(ret.a < 0)g *= -1;
	if(ret.a == 0 && ret.b < 0)g *= -1;
	ret.a /= g;
	ret.b /= g;
	ret.c = -(ret.a*(A.x+B.x)+ret.b*(A.y+B.y));
	return ret;
}
bool g(Line l,Point A){
	return l.a*A.x+l.b*A.y+l.c == 0;
}

int main(){
	int n;
	int x[1002],y[1002];
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&x[i],&y[i]);
	}
	
	int a = y[0]-y[1];
	int b = x[1]-x[0];
	int c = -(a*x[0]+b*y[0]);
	bool t = true;
	rep(i,n){
		if(a*x[i]+b*y[i]+c != 0){
			t = false;
			break;
		}
	}
	if(t){
		puts("No");
		return 0;
	}
	
	Point p[1002];
	rep(i,n){
		p[i].x = x[i];
		p[i].y = y[i];
	}
	
	map<Line,int> cnt;
	rep(i,n)rep(j,n){
		if(i == j)continue;
		cnt[f(p[i],p[j])] ++;
	}
	for(map<Line,int>::iterator itr = cnt.begin() ; itr != cnt.end() ; ++itr){
		//printf("%d %d %d %d\n",itr->fr.a,itr->fr.b,itr->fr.c,itr->sc);
		if(itr->sc == n){
			puts("Yes");
			return 0;
		}
		if(itr->sc == n-1){
			int CNT = 0;
			rep(i,n){
				p[i].x *= 2; p[i].y *= 2;
				if(g(itr->fr,p[i]))CNT ++;
				p[i].x /= 2; p[i].y /= 2;
			}
			if(CNT == 1){
				puts("Yes");
				return 0;
			}
		}
		if(itr->sc == n-2){
			int CNT = 0;
			rep(i,n){
				p[i].x *= 2; p[i].y *= 2;
				if(g(itr->fr,p[i]))CNT ++;
				p[i].x /= 2; p[i].y /= 2;
			}
			if(CNT == 2){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 34316
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    string res = "Yes";
    vector<int> t(n+1);
    vector<int> x(n+1);
    vector<int> y(n+1);
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 1; i <= n; i++) {
        int dt = t[i] - t[i-1];
        int dx = x[i] - x[i-1];
        int dy = y[i] - y[i-1];
        if((dt-dx-dy)%2 == 1 || dt < abs(dx)+abs(dy)){
            res = "No";
            break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
typedef double db;
typedef long long ll;
using namespace std;
int main(){
	int d, t, s;
	scanf("%d%d%d",&d,&t,&s);
	if(s * t >= d) 
		printf("Yes\n");
	else 
		printf("No\n");

	return 0;
}


Measured memory_bytes: 3736
N,Q = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(N-1):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
T = [0 for _ in range(N+1)]
for _ in range(Q):
    p,x = map(int,input().split())
    T[p] += x
hist = [0 for _ in range(N+1)]
stack = [1]
hist[1] = 1
while stack:
    x = stack.pop()
    for y in G[x]:
        if hist[y]==0:
            T[y] += T[x]
            stack.append(y)
            hist[y] = 1
print(*T[1:])

Measured memory_bytes: 119188
#include <iostream>

using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b) {
		if (a == 1 && b != 1) cout << "Alice";
		else if (b == 1 && a != 1) cout << "Bob";
		else {
			if (a == b) cout << "Draw";
			else {
				if (a > b) cout << "Alice";
				else cout << "Bob";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import math

n=int(input())
alist=list(map(int, input().split())) 
blist=[]
for i in range(n):
    blist.append([])

for i in range(n):
    ima=n-i-1
    kosu=math.floor(n/(ima+1))
    nanko=0
    #print(ima, kosu)
    for j in range(kosu-1):
        #nima=(kosu-j-1)*(ima+1)
        nima=(ima+1)*(kosu-j)-1
        #print(nima)
        if blist[nima][0]==1:
            nanko+=1
    nanko=nanko%2
    if alist[ima]==nanko:
        blist[ima]=[0]
    else:
        blist[ima]=[1]

#print(blist)
kotaelist=[]
for bl in range(n):
    if blist[bl]==[1]:
        kotaelist.append(bl+1)

print(len(kotaelist))
for s in kotaelist:
    print(s, end =" ")

Measured memory_bytes: 30384
#include<iostream>
 
int main() {
  char S[4];

  std::cin >> S;
 
  if(S[0]==S[1]) {
    if(S[0]==S[2] || S[0]==S[3]) {
      std::cout << "No";
      return 0;
    }
    if(S[0]!=S[2] && S[2]==S[3]) {
      std::cout << "Yes";
      return 0;
    }
    else {
      std::cout << "No";
      return 0;
    }
  }
  else if(S[0]==S[2]) {
    if(S[0]==S[3]) {
      std::cout << "No";
      return 0;
    }
    if(S[1]!=S[3]) {
      std::cout << "No";
      return 0;
    }
    else {
      std::cout << "Yes";
      return 0;
    }
  }
  else if(S[0]==S[3]) {
    if(S[1]!=S[2]) {
      std::cout << "No";
      return 0;
    }
    else {
      std::cout << "Yes";
      return 0;
    }
  }
  else {
    std::cout << "No";
  }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

typedef struct {
    int *stk;
    int ptr;
    int size;
} Stk;

bool initStk(Stk *s, int size) {
    if((s->stk = malloc(size * sizeof(int))) == NULL) {
        return false;
    }

    s->ptr = 0;
    s->size = size;
    return true;
}

bool isStkEmpty(Stk *s) {
    return s->ptr <= 0;
}

bool isStkFull(Stk *s) {
    return s->ptr >= s->size;
}

bool pushStk(Stk *s, int x) {
    if(isStkFull(s)) {
        return false;
    }

    s->stk[s->ptr++] = x;
    return true;
}

bool popStk(Stk *s, int *x) {
    if(isStkEmpty(s)) {
        return false;
    }

    *x = s->stk[--s->ptr];
    return true;
}

void teminateStk(Stk *s) {
    free(s->stk);

    s->ptr = s->size = 0;
}

int main(void) {
    Stk stk;

    initStk(&stk, 20000);

    char buf[20000 + 1];
    fgets(buf, sizeof(buf), stdin);
    buf[strlen(buf) - 1] = '\0';

    int bPos;
    for(int i = 0; i < strlen(buf); i++) {
        switch(buf[i]) {
            case '\\':
                pushStk(&stk, i);
                break;
            case '/':
                if(!popStk(&stk, &bPos)) {
                    buf[i] = '*';
                }
            default:;
        }
    }

    for(int i = 0; !isStkEmpty(&stk); i++) {
        popStk(&stk, &bPos);
        buf[bPos] = '*';
    }

    int area[20000] = {0};
    int areaNum = 0;
    int areaSum = 0;
    int pos = 0;
    for(int i = 0; i < strlen(buf); i++) {
        switch(buf[i]) {
            case '\\':
                pushStk(&stk, pos);
                break;
            case '/':
                if(!popStk(&stk, &bPos)) {
                    break;
                }
                area[areaNum] += pos - bPos;
                areaSum += pos - bPos;
                if(isStkEmpty(&stk)) {
                    areaNum++;
                }
                break;
            case '*':
                continue;
            default:;
        }

        pos++;
    }

    printf("%d\n", areaSum);
    printf("%d", areaNum);
    if(0 < areaNum) {
        printf(" ");
    }
    for(int i = 0; i < areaNum;) {
        printf("%d", area[i]);
        i++;
        if(i < areaNum) {
            printf(" ");
        }
    }
    puts("");

    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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 long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};


int main()
{
    int h, w; cin >> h >> w;
    vector<string> S;
    string s;
    rep(i, h)
    {
        cin >> s;
        S.push_back(s);
    }

    rep(i, h)
    {
        rep(j, w)
        {
            if (S[i][j] == '#') continue;

            int cnt = 0;
            rep(k, 8)
            {
                int x = j + dx[k];
                int y = i + dy[k];
                if (y < 0 || y >= h) continue;
                if (x < 0 || x >= w) continue;
                if (S[y][x] == '#') cnt++;
            }
            S[i][j] = cnt + '0';
        }
    }

    rep(i, h) cout << S[i] << endl;
}

Measured memory_bytes: 256
#coding: utf-8
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        # xの根を探索
        if self.parents[x] < 0:
            return x
        else:
            # 再帰的に根を探索
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        # 2つの木をマージする。
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def are_same(self, x, y):
        # 2つの要素の根が同じかどうかを調べる
        return self.find(x) == self.find(y)

    def members(self, x):
        # xと同じ根の要素をリストで出力
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == self.n]

    def roots(self):
        # 根である要素をリストで出力
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{} {}".format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uni = UnionFind(N)
for i in range(M):
    x, y, z = map(int, input().split())
    uni.union(x-1, y-1)
print(uni.group_count())

Measured memory_bytes: 69592
n = int(input());_h=0
li = []
for _ in range(n):
	x,y,h = map(int,input().split())
	li.append((x,y,h))
	if not _h:
		_x,_y,_h = x,y,h
for i in range(101):
	for j in range(101):
		H = _h + abs(i-_x) + abs(j-_y)
		if all(h==max(0,H-abs(i-x)-abs(j-y)) for (x,y,h) in li):
			print(i,j,H)
			exit()
		else:
			pass

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

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

    int n;
    cin >> n;

    map<int, int> mp;
    REP(i, n){
        int a;
        cin >> a;
        if(mp[a - 1]) mp[a] = mp[a - 1] + 1;
        else mp[a] = 1;
    }

    int maxi = -1e9;
    for(auto x : mp) maxi = max(maxi, x.second);
    cout << n - maxi << endl;

    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)//sからnまでのループ
#define rep(i, n) rep2(i, 0, n)//0からnまでのループ

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long int x;
    bool done = false;
    bool zero = false;
    long long int MAX = pow(10, 18);
    long double tot = 1;
 
 
    rep(i,n) {
        cin >> x;
        tot *= x;
        if (x == 0) {
            zero = true;
        }
        else if (tot > MAX) {
            done = true;
        }
    }
 
    if (zero) {
        cout << 0 << endl;
    }
    else if (done) {
        cout << -1 << endl;
    }
    else {
        cout << (long long int)tot << endl;
    }
 
 
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *r,*l,*p;
  int key;
};
 
typedef struct node * Node;
Node root, NIL;
int max;

void insert(int k){
  int H;
  Node y=NIL,x=root,z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  while( x != NIL ){   
    y = x;
    if ( z->key < x->key ){ 
      x = x->l; 
    }
    else {
      x = x->r; 
    }
  } 
  z->p = y; 
  if ( y == NIL ){  
    root = z;
  }   
  else {
    if (z->key < y->key) { 
      y->l = z; 
    }
    else { 
      y->r = z; 
    }
  }
}
  
void inorder(Node u){   
  if ( u == NIL ) return; 
  inorder(u->l); 
  printf(" %d", u->key);
  inorder(u->r); 
}
 
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
  
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  max = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int v = max(X, Y);
    long long res = INF;
    for (int i = 0; i <= v; i++) {
        int tmp = max(X - i, 0);
        chmin(res, (long long)(A * max(X - i, 0) + B * max(Y - i, 0) + C * 2 * i));
    }
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 888
# frozen_string_literal: true

n = gets.to_i
xys = n.times.map do
  a = gets.to_i
  a.times.map { gets.split.map(&:to_i) }
end

ans = 0

(1 << n).times do |bit|
  count = 0

  xys.each_with_index do |xy, i|
    next if bit[i] == 0

    valid = true

    xy.each do |x, y|
      until bit[x - 1] == y
        valid = false
        break
      end
    end

    if valid == true
      count += 1
    else
      count = 0
      break
    end
  end

  ans = count if count >= ans
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define endl '\n'
const int INF = (1 << 30);
using namespace std;
typedef long long int ll;
typedef pair<int,bool> pib;
 
int p[100005], q[100005];
 
void solve(){
    long long int w, h, ans=0, c;
    cin >> w >> h;
    vector<pib> v(w+h);
    REP(i,w){
        cin >> c;
        v[i] = pib(c,true);
        ans += v[i].first * (h+1);
    }
    REP(i,h){
        cin >> c;
        v[i+w] = pib(c,false);
        ans += v[i+w].first * (w+1);
    }
 
    long long int x=w, y=h, goal = w*h;
 
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
 
    for(auto it=v.begin(); goal > 0; it++){
        if(it->second){
            x--;
            goal -= y;
            ans -= y*it->first;
        }else{
            y--;
            goal -= x;
            ans -= x*it->first;
        }
    }
    cout << ans << endl;
}
 
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    solve();
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k,ans;
int x,y;
int cnt[11111];
signed main(){
	cin>>n>>x>>y;
	x--,y--;
	rep(i,n){
		for(int j=i;j<n;j++){
			int unuse=j-i;
			int use=0;
			if(abs(x-i)<abs(y-i)){
				use=abs(x-i)+1+abs(y-j);
			}
			else{
				use=abs(y-i)+1+abs(x-j);
			}
			cnt[min(use,unuse)]++;
			//cout<<i+1<<"-"<<j+1<<" "<<min(use,unuse)<<endl;
		}
	}
	rep(i,n-1){
		cout<<cnt[i+1]<<endl;
	}
}

Measured memory_bytes: 256
N = int(input().strip())
B = list(map(int, input().strip().split()))

A = []

for i in range(N):
    if i == 0:
        A.append(B[i])
    elif i == N - 1:
        A.append(B[i-1])
    else:
        A.append(min([B[i-1], B[i]]))

print(sum(A))

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

class B
{
    static void Main()
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        var ans = new List<int>();
        if (s.Length == t.Length)
        {
            int cnt = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) cnt++; 
            }
            Console.WriteLine(cnt);
            return;
        }
        for (int i = t.Length; i < s.Length; i++)
        {
            var a = s[(i - t.Length)..i];
            int cnt = 0;
            for (int j = 0; j < t.Length; j++)
            {
                if (a[j] != t[j]) cnt++;
            }
            ans.Add(cnt);
        }
        Console.WriteLine(ans.Min());
    }
}

Measured memory_bytes: 27140
#include<cstdio>
int main(){
char s[100001]={};
scanf("%s",s);
int a[26]={};
for(int i=0;true;i++){
if(s[i]==0)break;
else a[s[i]-'a']++;
}
for(int i=0;i<26;i++){
if(a[i]==0){
printf("%c\n",i+'a');
break;
}
if(i==25)printf("None\n");
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, a[100010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 0, n){
        cin >> a[i];
    }
    int ans = 1, now = 1;
    rep(i, 1, n){
        if(a[i] > a[i - 1]){
            now++; chmax(ans, now);
        }else if(a[i] < a[i - 1]){
            now = 1;
        }
    }
    now = 1;
    rep(i, 1, n){
        if(a[i] < a[i - 1]){
            now++; chmax(ans, now);
        }else if(a[i] > a[i - 1]){
            now = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int n,m;cin>>n>>m;int pa[n]={0},npa[n]={0},ac=0,wa=0,t[m];string s[m];
    for(int i=0;i<m;i++){
        cin>>t[i]>>s[i];
        if(s[i]=="AC"){
            if(pa[t[i]-1]==0) {
                ac++;
                pa[t[i]-1]++;
                npa[t[i]-1]=i;
            }
        } 
    }
    for(int i=0;i<m;i++){
        if(s[i]=="WA"&&pa[t[i]-1]>0&&i<=npa[t[i]-1]) wa++;
    }
    cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 6912
#include<stdio.h>
#define INFINITY 1000000000

int A[500000];
int num=0;
int n1,n2;
int L[5000000/4];
int R[5000000/4];

void merge(int A[],int left,int mid,int right){
  int i,k,j;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=INFINITY;
  R[n2]=INFINITY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
num++;
    }
   else{
     num++;
  A[k]=R[j];
  j=j+1;
    }
  }
}
void mergesort(int A[],int left,int right){
  if(left+1<right){
    int mid;
    mid = (left + right)/2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, mid, right);
  }
}
int main(){
  int n,i;
  scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&A[i]);
}
mergesort(A,0,n);
for(i=0;i<n;i++){
if(i==n-1){
printf("%d\n",(int)A[i]);
break;
}
printf("%d ",(int)A[i]);
}
printf("%d\n",num);

return 0;
}



Measured memory_bytes: 5696
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int H, W;	cin >> H >> W;
	vector<string> a(H);
	for (int i = 0; i < H; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < W + 2; ++i) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < H; ++i) {
		cout << '#' << a[i] << '#' << endl;
	}
	for (int i = 0; i < W + 2; ++i) {
		cout << '#';
	}
	cout << endl;
	cin >> H;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int n, m;
    cin >> n >> m;
    VI a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    auto c = convolution<998244353>(a, b);
    int sz = n + m - 1;
    rep(i, sz) cout << c[i] << " \n"[i == sz-1];
}


Measured memory_bytes: 19052
using namespace std;

#include <cstdio>

int a[10];

bool dfs(int i, int l, int r){
	if (i == 10){
		return true;
	}
	if (l < a[i] && dfs(i + 1, a[i], r)){
		return true;
	}
	if (r < a[i] && dfs(i + 1, l, a[i])){
		return true;
	}
	return false;
}

int main(){
	int n;
	scanf("%d", &n);
	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = 0; j < 10; j++)
		{
			scanf("%d", &a[j]);
		}
		printf("%s\n", dfs(0, 0, 0) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

void Main() {
	ll A, B; cin >> A >> B;
	// int sum = A;
	// FOR(i, A + 1, B + 1) {
	// 	sum ^= i;
	// 	debug(i);
	// 	debug(sum);
	// } 
	int mod = (B - A) % 4;
	if (A % 2 == 0) {
	    switch (mod)
	    {
	    case 0:
	    	cout << B << endl;
	    	break;
	    case 1:
	    	cout << ((B- 1) ^ B) << endl;
	    	break;
	    case 2:
	    	cout << ((B - 2) ^ (B - 1) ^ B) << endl;
	    	break;
	    case 3:
	    	cout << ((B - 3) ^ (B - 2) ^ (B - 1) ^ B) << endl;
	    	break;
	    
	    default:
	    	break;
	    }
		return;
	}
	switch (mod)
	{
	case 0:
		cout << A << endl;
		break;
	case 1:
		cout << (A ^ B) << endl;
		break;
	case 2:
		cout << (A ^ (B - 1) ^ B) << endl;
		break;
	case 3:
		cout << (A ^ (B - 2) ^ (B - 1) ^ B) << endl;
		break;
	
	default:
		break;
	}
}

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


Measured memory_bytes: 256
# B - Making Triangle
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i] and L[i]+L[j]+L[k]>2*max(L[i],L[j],L[k]):
                ans += 1
print(ans)

Measured memory_bytes: 68488
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y,ans=1;
    cin>>x>>y;
    while(2*x<=y){
        x=x*2;
        ans++;
    }
    cout<<ans<<endl;





}






























































Measured memory_bytes: 256