akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kamol Paul
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
class AStationAndBus {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string data;
	    in>>data;
	    set<char> x;
	    for(char dd : data) x.insert(dd);
	    if(x.size()>1){
	        out<<"Yes";
	    }
	    else out<<"No";
	}
};


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


Measured memory_bytes: 256
#include <stdio.h>
     
    int main(void)
    {
            int n,m,x,a[100],i,b=0,c=0,j;
     
            scanf("%d%d%d",&n,&m,&x);
     
            for (i=1;i<=m;i++)
                    scanf("%d",&a[i]);
     
            for (i=x;i<n;i++)
                    for (j=1;j<=m;j++)
                            if (i==a[j])
                                    b++;
     
            for (i=x;i>=1;i--)
                    for (j=1;j<=m;j++)
                            if (i==a[j])
                                    c++;
     
            if (b>c)
                    printf("%d\n",c);
            else
                    printf("%d\n",b);
     
            return 0;
    }

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

using ll = long long;

int main() {
  
  ll N,A,B;
  cin >> N >> A >> B;
  
  ll x = N/(A+B), y = N%(A+B);
  
  ll ans;
  ans += x*A;
  
  ans += min(y,A);
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int l = fs.nextInt();
		double lDouble = (double)l;
		double divided3 = lDouble / 3;
		System.out.println(String.format("%.7f", divided3 * divided3 * divided3));
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


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

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


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



void solve(void)
{
  int n;cin>>n;
  vector<int> vec (n,0);
  for (int i = 0; i < n; i++)
  {
     cin>>vec[i];
  }
  sort(ALL(vec));
  int res =0 ;
  for (int i = 0; i < n; i++)
  {
    for (int j = i+1; j < n; j++)
    {
      for (int k = j+1; k < n; k++)
      {
        if((vec[k] < vec[i] + vec[j])&& (vec[i] != vec[j]) && (vec[j] != vec[k])&& (vec[i] != vec[k]))
        {
          // DEBUG(i,j,k,"\n");
          res++;
        }
      }
      
    }
    
  }
  cout<<res<<endl;
  

  return;
}

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

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

  return 0;
}


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

int main() {
	string s;
	int K;
	cin >> s >> K;
	for (char& i : s) {
		if (i != 'a' && 'z' + 1 - i <= K) {
			K -= 'z' + 1 - i;
			i = 'a';
		}
	}
	s.back() = (s.back() - 'a' + K) % 26 + 'a';
	cout << s;
}

Measured memory_bytes: 512
ABCD = input()

for i in range(2 ** 3):
    eq = ''
    for j in range(3):
        eq += ABCD[j]
        if (i >> j) & 1:
            eq += '+'
        else:
            eq += '-'
    else:
        eq += ABCD[3]
    if eval(eq) == 7:
        print(eq + '=7')
        exit()


Measured memory_bytes: 81552
l,r = gets.split.map{ |x| x.to_i }

res = 2018

mod_set = {}

(l..r).each_with_index{ |i, idx|
	mod_set[i % 2019] = true
	if idx >= 2019 then
		break
	end
}

arr = mod_set.keys.sort

(0...arr.size).each{ |i|
	((i+1)...arr.size).each{ |j|
		ex = arr[i] * arr[j] % 2019
		if res > ex then
			res = ex
		end
	}
}

puts res

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

int main() {
  string N;
  cin >> N;
  rep(i, 3) {
    if (N[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3572
# 夏休みN日間
# 夏休みの宿題がM個出されており、i番目の宿題をやるにはAi日間
# 複数の宿題を同じ日にやることはできず、宿題をやる日には遊べない
# 最大何日間遊べるか、終わらない場合は-1を出力

N,M= map(int,input().split())
A = list(map(int,input().split()))
hwd = sum(A)

if hwd > N:
    print(-1)
else:
    print(N - hwd)

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

using namespace std;

#ifndef errOut
#define errOut(s)
#endif

using Value = int32_t;
using Count = int64_t;

struct Row {
    Value a;
    Value b;

    explicit Row() : a(0), b(0) {
    }

    Value diff() const {
        return a - b;
    }
};

ostream &operator<<(ostream &os, const Row &row) {
    os << "a: " << row.a << ", " << "b: " << row.b;
    return os;
}

Count calc(std::vector<Row> &rows) {
    Count ret = 0;
    for (auto &&row: rows) {
        if (row.diff() >= 0) {
            continue;
        }
        ret += row.a;
        row.b -= row.a;
        row.a = 0;
    }

    std::sort(rows.begin(), rows.end(), [](Row x, Row y) -> bool {
        if (x.diff() == 0 && y.diff() == 0) {
            return x.b > y.b;
        }
        if (x.diff() == 0) {
            return true;
        }
        if (y.diff() == 0) {
            return false;
        }
        if (x.diff() > 0 && y.diff() > 0) {
            return x.b > y.b;
        }
        if (x.diff() >= 0) {
            return true;
        }
        if (y.diff() >= 0) {
            return false;
        }
        return x.diff() > y.diff();
    });

    auto itr = rows.rbegin();
    for (; itr != rows.rend(); ++itr) {
        const auto &row = *itr;
        if (row.diff() < 0) {
            continue;
        }
        ret += row.diff();
        ++itr;
        break;
    }
    for (; itr != rows.rend(); ++itr) {
        const auto &row = *itr;
        ret += row.a;
    }
    return ret;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<Row> rows(n, Row());
    bool anyDiff = false;
    for (int i = 0; i < n; ++i) {
        std::cin >> rows[i].a >> rows[i].b;
        if (rows[i].diff()) {
            anyDiff = true;
        }
    }
    if (!anyDiff) {
        std::cout << 0 << std::endl;
        return 0;
    }
    std::cout << calc(rows) << std::endl;
    return 0;
}


Measured memory_bytes: 384
n,m=map(int,input().split())
l,r=map(int,input().split())
l_max,r_min=l,r
for i in range(m-1):
    l,r=map(int,input().split())
    if l_max<l: l_max=l
    if r_min>r: r_min=r
print(max(r_min-l_max+1,0))

Measured memory_bytes: 44264
n,m = map(int,input().split())
ab = []
for i in range(n):
  a,b = map(int,input().split())
  ab.append([-a,b])
ab.sort()
ab.reverse()
#print(ab)
here = 0
ans = 0
pool = []
import heapq
for i in range(m+1):
  while True:
    if here == n:
      break
    elif ab[here][0] == -i:
      heapq.heappush(pool,-ab[here][1])
      here += 1
    else:
      break
  try:
    #print(pool)
    ans -= heapq.heappop(pool)
    #print(pool)
  except:
    pass
print(ans)

Measured memory_bytes: 24148
// AOJ 0535: Crossing Black Ice
// 2017.10.26 bal4u@uu

#include <stdio.h>

char map[95][95]; int w, h;
int ans;

int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

void check(int r, int c, int k)
{
	int i, r2, c2, f;

	map[r][c] = 0;
	for (f = 0, i = 0; i < 4; i++) {
		r2 = r + mv[i][0], c2 = c + mv[i][1];
		if (r2 >= 0 && r2 < h && c2 >= 0 && c2 < w && map[r2][c2])
			check(r2, c2, k+1), f = 1;
	}
	map[r][c] = 1;

	if (!f && k+1 > ans) ans = k+1;
}

int main()
{
	int r, c, x; 

	while (scanf("%d%d", &w, &h) && w > 0) {
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) scanf("%d", &x), map[r][c] = x;
		ans = 0;
		for (r = 0; r < h; r++) for (c = 0; c < w; c++)	if (map[r][c]) check(r, c, 0);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1748
//kid_kb//

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;

int main()
{
    kb
    //                                            Let's Fight !!!!!!!
    ll t;
//    cin>>t;
    t=1;
    while(t--){
        ll x;
        cin>>x;
        if(x>=30)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}




Measured memory_bytes: 3604
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int k,x;
    cin>>k>>x;
    if(500*k>=x)print("Yes")
    else print("No")
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int count,n,g;
	int MIN = 0x7fffffff;
	count = 0;
	scanf("%d",&n);
	while(n--)
	{ 
		scanf("%d",&g);
		if((g&-g)<MIN)
		MIN = (g&-g);
     }
     while(MIN>1)
    {
      MIN/=2;
     count++;
      }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	string s ; cin >> s;
	int n = s.size() ;
	stack<int> st1 ;
	stack<int> st2 ;
	int nb = 0 ;
	for(int i = 0 ; i < n ; i++){
		if(s[i] == '0'){
			if(st2.size()){
				st2.pop() ;
				nb += 2 ;
			}
			else st1.push(0) ;
		}
		else if(s[i] == '1'){
			if(st1.size()){
				st1.pop() ;
				nb += 2;
			}
			else st2.push(1) ;
		}
	}
	cout << nb << endl; 
	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

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

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

// ---------------------
#define INF 922337203685477580
typedef long long ll;

ll dp[110][110];
ll matrix[110][2];

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

  REP(i, N) {
    cin >> matrix[i][0] >> matrix[i][1];
  }

  // for (int i = 0; i < N - 1; i++) {
  //   dp[i][i + 1] = matrix[i][0] * matrix[i][1] * matrix[i + 1][1];
  // }
  for (int i = 0; i < N; i++) {
    dp[i][i] = 0;
  }

  // cout << dp[0][1] << endl;

  for (int l = 2; l <= N; l++) {
    for (int i = 0; i < N - l + 1; i++) {
      int j = i + l - 1;

      dp[i][j] = INF;

      for (int k = i; k < j; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + matrix[i][0] * matrix[k][1] * matrix[j][1]);
      }
    }
  }




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

  return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    ll N, K;
    cin >> N >> K;

    int A[N], F[N];
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> F[i];

    sort(A, A+N);
    sort(F, F+N, greater<int>());

    ll l = -1;
    ll r = 1000000000005;
    while(l+1<r){
        ll mid = (l+r)/2;
        ll total = 0;
        for(int i=0; i<N; i++){
            if((ll)A[i]*F[i]>mid) total = total + (ll)A[i] - mid/F[i];
        }
        if(total > K) l = mid;
        else r = mid;
    }
    cout << r << endl;

    return 0;
}


Measured memory_bytes: 1792
from collections import deque
n = int(input())
edges=[[]for i in range(n)]
nodes=[None]*n
for i in range(1,n):
    a , b = map(int, input().split())
    edges[a-1].append(i)
    edges[b-1].append(i)
    nodes[i]=(a-1,b-1)
ma =0
for i in range(n):
    ma=max(ma,len(edges[i]))

col=[None]*n
d = deque([(0,0)])
while d:
    t=1
    v , ex_col = d.pop()
    for i in edges[v]:
        if col[i] is None:
            if t==ex_col:
                t+=1
            col[i]=t
            a1,b1=nodes[i]
            if a1==v:
                d.append((b1,t))
            else:
                d.append((a1,t))
            t+=1

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


Measured memory_bytes: 33672
# dp[i][j]：i枚で表がj枚になる確率
# 1 - sum(:dp[N][(N+1)//2])を求めればいいため，dp[N][(N+1)//2:]は求める必要が無い
# jが大きい順に更新すればdp[i][j]のjを保持する必要はない

N = int(input())
P = list(map(float, input().split()))
overhalf_N = (N+1)//2
underhalf_N = overhalf_N - 1

dp = [0]*(N+1) # dp[N][j]：N枚で表がj枚になる確率

dp[0] = 1
for i in range(overhalf_N):
  pc = 1 - P[i]
  for j in range(i+1, 0, -1):
    dp[j] = dp[j-1] * P[i] + dp[j] * pc
  dp[0] = dp[0] * pc

for i in range(overhalf_N,N):
  pc = 1 - P[i]
  for j in range(underhalf_N, 0, -1):
    dp[j] = dp[j-1] * P[i] + dp[j] * pc
  dp[0] = dp[0] * pc

print(1-sum(dp[:overhalf_N]))


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


class UnionFind {
protected:
  int size;
  vector<int> _leader;
  vector<int> _rank;
  
public:
  UnionFind(int s);
  int leader(int i);
  int merge(int i, int j);
};

UnionFind::UnionFind(int s) {
  size = s;
  _leader = vector<int>(size);
  for (int i = 0; i < size; i++) { _leader.at(i) = i; }
  _rank = vector<int>(size, 1);
}

int UnionFind::leader(int i) {
  int cur = i;
  int nxt = _leader.at(cur);
  vector<int> seen;
  while (cur != nxt) {
    seen.push_back(cur);
    cur = nxt;
    nxt = _leader.at(cur);
  }
  for (auto j : seen) _leader.at(j) = cur;
  return cur;
}

int UnionFind::merge(int i0, int j0) {
  int li = leader(i0);
  int lj = leader(j0);
  if (li == lj) return li;
  int ri = _rank.at(li);
  int rj = _rank.at(lj);
  if      (ri < rj)  return _leader.at(li) = lj;
  else if (ri > rj)  return _leader.at(lj) = li;
  else {
    (_rank.at(lj))++;
    return _leader.at(li) = lj;
  }
}


typedef pair<int, int> Pair;

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N, K, L; cin >> N >> K >> L;
  UnionFind ufRoad(N);
  UnionFind ufRail(N);

  for (int i = 0; i < K; i++) {
    int p, q; cin >> p >> q; p--; q--;
    ufRoad.merge(p, q);
  }
  for (int i = 0; i < L; i++) {
    int r, s; cin >> r >> s; r--; s--;
    ufRail.merge(r, s);
  }
  
  map<Pair, int> mp;
  for (int i = 0; i < N; i++) {
    int rd = ufRoad.leader(i);
    int rl = ufRail.leader(i);
    mp[make_pair(rd, rl)]++;
  }
  for (int i = 0; i < N; i++) {
    int rd = ufRoad.leader(i);
    int rl = ufRail.leader(i);
    if (i > 0) cout << " ";
    cout << mp[make_pair(rd, rl)];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 15104
a,b,c,x,y=map(int,input().split())
if a+b<=2*c:
    print(a*x+b*y)
else:
    if x<y:
        if b>=2*c:
            print(2*y*c)
        else:
            print(b*(y-x)+2*x*c)
    else:
        if a>=2*c:
            print(2*x*c)
        else:
            print(a*(x-y)+2*y*c)

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

int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string a,b;
	cin >> a >> b;
	if(a.length() > b.length())
    {
        cout << "GREATER";
        return 0;
    }
    else if(b.length() > a. length())
    {
        cout << "LESS";
        return 0;
    }
    int x,y;
    for(int i = 0; i < a. length(); i++)
    {
        x = a[i] - '0';
        y = b[i] - '0';
        if(x > y)
        {
            cout << "GREATER";
            //cout << x << y;
            return 0;
        }
        else if(y > x)
        {
            cout << "LESS";
            return 0;
        }
    }
    cout << "EQUAL";

}


Measured memory_bytes: 3632
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstring>
#include<queue>
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
const int MAXN=1005;
const long double EPS=1e-13;
int n;
long double S[2],E[2];
long double d[MAXN];
bool vis[MAXN];
struct circle
{
	long double x,y,r;
}C[MAXN];
long double jl(int i,int j)
{
	long double o=sqrt((C[i].x-C[j].x)*(C[i].x-C[j].x)+(C[i].y-C[j].y)*(C[i].y-C[j].y));
	o=o-C[i].r-C[j].r;
	if(o<EPS)
		o=0.0;
	return o;
}
void dj(int s,int t)
{
	fill(d,d+MAXN,-1);
	int mi=s;
	vis[s]=1;
	d[s]=0.0;
	while(1)
	{
		int k=mi;
		mi=-1;
		if(k==t)
			break;
		vis[k]=1;
		for(int i=1;i<=n+2;i++)
		{
			if(vis[i])
				continue;
			long double o=jl(k,i);
			if((d[i]==-1)||d[k]+o<d[i])
			{
				d[i]=d[k]+o;
			}
			if(d[i]!=-1&&(mi==-1||d[mi]>d[i]))
				mi=i;
		}
	}
}
int main()
{
	cin>>S[0]>>S[1]>>E[0]>>E[1];
	scanf("%d",&n);
	C[1].x=S[0];
	C[1].y=S[1];
	C[1].r=0;
	C[n+2].x=E[0];
	C[n+2].y=E[1];
	C[n+2].r=0;
	for(int i=2;i<=n+1;i++)
	{
		cin>>C[i].x>>C[i].y>>C[i].r;
	}
	dj(1,n+2);
	cout<<setiosflags(ios::fixed)<<setprecision(10)<<d[n+2];
}

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

int main() {
  long long k,x;
  cin >> k >> x;
  
  for(long long i = x-k+1; i <= x+k-1; i++){
    if(i==x+k-1){
      cout << i << endl;
    }
    else{
      cout << i << ' ';
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>

using namespace std;

typedef pair<int, int> P;

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

    map<int, vector<int>> m;
    for(int i=0; i<N; i++){
        int a, b;
        cin >> a >> b;
        m[a].push_back(b);
    }

    priority_queue<int> q;
    int ans = 0;
    for(int i=M-1; i>=0; i--){
        for(auto e : m[M-i]){
            q.push(e);
        }
        if(q.empty()) continue;

        ans = ans + q.top();
        q.pop();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10880
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int s = Integer.valueOf(arr01[0]);
        int w = Integer.valueOf(arr01[1]);

        System.out.println(s > w ? "safe" : "unsafe");

    }

}


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

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

	for(int i = 1; i <= 2000; i++) {
		int x = floor(0.08 * i);
		int y = floor(0.1 * i);

		if(x == a && y == b) {
			printf("%d\n", i);
			return 0;
		}
	}

	printf("-1\n");
	return 0;
}

Measured memory_bytes: 256
using System;
public class Program
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var Hs = Console.ReadLine().Split(' ');
        var HsInt = new int[N];
        for (int i = 0; i < N; i++)
        {
            HsInt[i] = int.Parse(Hs[i]);
        }

        var maxLength = 0;
        var tempLength = 0;

        for (int i = 0; i < N - 1; i++)
        {
            if (HsInt[i] >= HsInt[i + 1])
            {
                tempLength++;
                if (tempLength > maxLength)
                {
                    maxLength = tempLength;
                }
            }
            else
            {
                tempLength = 0;
            }
        }

        Console.WriteLine(maxLength);
    }
}

Measured memory_bytes: 23004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define MOD 1000000007
#define sz5 100005
#define sz6 1000005
#define UP upper_bound
#define LB lower_bound
#define F first
#define S second
#define PI pair<int,int>
#define PL pair<ll,ll>
#define VI vector<int>
#define VL vector<ll>

void test_case(void) {

}

int main() {
    FAST

    #ifndef ONLINE_JUDGE
        // freopen("in", "r", stdin);
        // freopen("out", "w", stdout);
    #endif

    int n,la,lb;
    cin>>n;
    int height[n+5], dp[n+5];
    for(la=1;la<=n;la++)
        cin>>height[la];

    dp[0]=dp[1]=0;
    dp[2]=abs(height[1]-height[2]);
    for(la=3;la<=n;la++){
        dp[la]=min(abs(height[la]-height[la-1])+dp[la-1], dp[la-2]+abs(height[la]-height[la-2]));
    }

    cout<<dp[n]<<endl;


    return 0;
}

Measured memory_bytes: 4396
#include <stdio.h>

int main(void)
{
    int n,i,x;
    
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(i%3==0) printf(" %d",i);
        else
        {
            x=i;
            while(x!=0)
            {
                if(x%10==3)
                {
                    printf(" %d",i); break;
                }
                x/=10;
            }
        }
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2104
N, H = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)

maxa = max(A)

res = 0

for b in B:
    if b < maxa or H <= 0:
        break
    H -= b
    res += 1

res += int((H + maxa - 1) / maxa) if H > 0 else 0

print(res)


Measured memory_bytes: 11344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
    }
    int cnt = 0;
    for(int i=1;i<n-1;i++){
        if((p[i]-p[i-1])*(p[i+1]-p[i])>0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n,a,b;cin>>n>>a>>b;
  string s;cin>>s;
  int fc=1, ac=0;
  
  rep(i, s.size()){
    bool f=1;
    if(s[i]=='c')f=0;
    if(s[i]=='a' && ac>=a+b)f=0;
    if(s[i]=='b' && (ac>=a+b || fc>b))f=0;

    if(f){
      cout<<"Yes"<<endl;
      ac++;
      if(s[i]=='b')fc++;
    }else{
      cout<<"No"<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	vector<char> line(n);
	foreach(i, line)cin>>i;
	line.erase(unique(all(line)), line.end());
	cout << line.size() << endl;
	return 0;
}



Measured memory_bytes: 384
/*Be patient && calm!
All our dreams can come true, if we have the courage to pursue them.
The secret of getting ahead is getting started.
It is hard to beat a person who never gives up.
First, solve the problem. Then, write the code.
Fix the cause, not the symptom.
Simplicity is the soul of efficiency.
Make it work, make it right, make it fast.*/
// #include<bits\stdc++.h>
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<algorithm>
#include<sstream>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.first > b.first);
// }
// bool spOrder(const pair<int, int> &a,
//              const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first > b.first;
//  }





void solve()
{
    double n,x,t;
    cin >> n >> x >> t;
    double d = ceil(n / x);
    cout.precision(0);
    cout << fixed << d * t << lin;
}





int main()
{
    // auto start = clock();
    fast_io;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    // int c = 1;
    while (t--)
    {
        // cout << "Case " << c << ":"
        // << lin;
        solve();
        // if(t)
        // {
        //     cout << lin;
        // }
        // c++;
    }
    // auto stop = clock();
    // cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int M, res;
  rd(M);
  res = 48 - M;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int M, res;
//   rd(M);
//   res = 48 - M;
//   wt(res);
// }


Measured memory_bytes: 256
H,W = gets.split.map(&:to_i)
S = H.times.map{gets.chomp}
D = Array.new(H){Array.new(W){nil}}

X = Y = [-1,0,1]

H.times do |h|
  W.times do |w|
    if S[h][w] == "#"
      D[h][w] = "#"
      next
    end

    count = 0
    X.each do |x|
      Y.each do |y|
        ww = w + x
        hh = h + y
        next if ww < 0 || W <= ww
        next if hh < 0 || H <= hh
        count += 1 if S[hh][ww] == "#"
      end
    end
    D[h][w] = count
  end
end

H.times do |h|
  puts D[h].join
end

Measured memory_bytes: 2172
#include<iostream>
#include<cmath>
#include<cstring>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char s[13];
	//char x;
	scanf("%s", s);
	int i;
	ll tmp, mint = INT_MAX;
	for(i=0; (i+2)<strlen(s); i++){
		tmp = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
		mint = abs(tmp-753)<mint ? abs(tmp-753) : mint;
	}
	cout << mint << endl;
	return 0;
}


Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    a,b,c=LMIIS()
    print(max(c-a+b,0))





    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<stdio.h>

#include<limits.h>


int main(void){


  int i,n,a;


  int min=INT_MAX, max=INT_MIN;


  long long sum=0;


  scanf("%d",&n);


  for(i=0;i<n;i++) {


      scanf("%d", &a);


      if(a<min) min=a;


      if(max<a) max=a;


      sum+=a;


  }


  printf("%d %d %lld\n",min,max,sum);


return 0;


}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}



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

class Program
{
    static void Main()
    {
        int K = int.Parse(Console.ReadLine());
        String[] arr = Console.ReadLine().Split();
        int A, B;
        A = int.Parse(arr[0]);
        B = int.Parse(arr[1]);
        Console.WriteLine(A <= B / K * K ? "OK" : "NG");
        return;
    }
}

Measured memory_bytes: 27460
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int main() {
    int d, n; cin >> d >> n;
    int ans = n;
    for (int i = 0; i < d; ++i) {
        ans *= 100;
    }
    if (n == 100) cout << ans + (d == 0 ? 1 : (int)pow(100, d)) << endl;
    else cout << ans << endl;
}




Measured memory_bytes: 512
N=int(input())
A=[int(x)for x in input().split()]
B=[]
p = 10 ** 9 + 7
if N%2==0:
    B= sorted([2*i-1 for i in range(1,N//2+1)]*2)
    if sorted(A)==B:
        ans=2**(N//2)%p
    else:
        ans=0
else:
    B= [0]+sorted([2*i for i in range(1,N//2+1)]*2)
    if sorted(A)==B:
        ans=2**(N//2)%p
    else:
        ans=0
print(int(ans))
 

Measured memory_bytes: 13880
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<set>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, M;

void MAIN() {
    scanf("%d%d", &N, &M);

#ifdef MYTEST
    M = (N-1) / 2;
#endif
    int a = 0, b = 1;
    set<int> se;
    REP (i, M) {
	int k;
	while (1) {
	    k = abs(a - b);
	    k = min(k, N-k);
	    if (N % 2 == 0 && k * 2 == N) {
		a--;
		continue;
	    } else if (se.count(k)) {
		a--;
		continue;
	    } else {
		break;
	    }
	}
	assert(a == 0 || b < a);
	assert(b < N);
	assert(a < N);
	printf("%d %d\n", a+1, b+1);
	se.insert(k);
	eprintf("%d\n", k);
	a--;
	if (a < 0) a += N;
	b++;
    }
    assert((int)se.size() == M);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 7960
#include <iostream>
#include <vector>
#include <ios>
#include <limits.h>
using namespace std;
int n, k, sum;

int GetMax(int a, int b) { return (a > b ? a : b); }

int getMinCand(int s, int q)
{
	return ((double)s / (double)q + 0.9999);
}

bool partition(const vector<int>& vN, int minCand)
{
	int i, subsum = 0, s = vN.size(), w = 0, p = 0, r;
	for (i = 0; i < s; ++i){
		if (w + vN[i] <= minCand){
			w += vN[i];
		}else{
			subsum += w;
			w = vN[i];
			++p;
			if (p == k)
				return false;
			if (i != s - 1){
				r = getMinCand(sum - subsum, k - p);
				if (r > minCand)
					return false;
			}
		}
	}

	return true;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	vector<int> vN(n, 0);
	int maxV = INT_MIN;
	for (int i = 0; i < n; ++i){
		cin >> vN[i];
		sum += vN[i];
		if (vN[i] > maxV)
			maxV = vN[i];
	}
	int minCand = getMinCand(sum, k);
	minCand = GetMax(minCand, maxV);

	while (!partition(vN, minCand))
		++minCand;

	cout << minCand << "\n";

	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,tmp;
map<string,int> m;
int nid=0,f[55],n,ans=0;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>tmp>>f[i];
		m[tmp]=i;
	}
	cin>>s;
	for(int i=m[s]+1;i<n;i++) ans+=f[i];
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
from math import gcd
from functools import reduce
def gcds(*numbers):
  return reduce(gcd, numbers)
K = int(input())
ans1 = 0
ans2 = 0
ans3 = 0
for a in range(1, K + 1):
  for b in range(a, K + 1):
    for c in range(b, K + 1):
      if a == b and b == c:
        ans1 += gcds(a, b, c)
      elif a == b or b == c or c == a:
        ans2 += gcds(a, b, c)
      else:
        ans3 += gcds(a, b, c)
print(ans1 + 3 * ans2 + 6 * ans3)

Measured memory_bytes: 9644
n, k = map(int, input().split())
d = list(map(str, input().split()))

while (1):
   c = [x for x in str(n)]

   ok = 1
   for x in c:
      if x in d:
         ok = 0
         break

   if ok == 1:
      break

   n += 1

print(n)


Measured memory_bytes: 2940
# include <iostream>
# include <string>
# include <bitset>

using namespace std;

int main() {
    string S;
    cin >> S;
    int L = S.length();
    int digits[L - 1];
    for (int i = 0; i < L; i++){
        digits[i] = S[i] - '0';
    }

    long long ans = 0;
    for (int bit = 0; bit < (1 << (L - 1)); bit++) {
        long long temp  = 0;

        for (int i = 0; i <= L - 2; i++){
            bool is_plus = bit & (1 << (L - 2 - i));

            temp = temp * 10 + digits[i];
            if (is_plus) {
                ans += temp;
                temp = 0;
            }
        }
        temp = temp * 10 + digits[L - 1];
        ans += temp;
    }
    cout << ans;
}


Measured memory_bytes: 256
/*
                                        //     //     //\\\\\\\\\
                                        \\    //      \\        \\
                                        //   //       //         \\
                                        \\  //        \\          \\
                                        // //         //           \\
                                        \\//          \\            \\       
                                        //\\          //            //
                                        \\ \\         \\           //
                                        //  \\        //          //
                                        \\   \\       \\         //
                                        //    \\      //        //
                                        \\     \\     \\/////////
*/

#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vint vector <int>
#define vll vector <long long int>
#define endl cout<<'\n'
#define fre(i,l,n) for(long long int i=l;i<n;++i)
#define fr(i,l,n) for(long long int i=l;i<=n;i++)
#define rfre(i,n,l) for(long long int i=n-1;i>=l;i--)
#define rfr(i,n,l) for(long long int i=n;i>=l;--i)
#define tab '\t'
#define debug cout<<'*';
#define s(a) cin>>a
#define p(a) cout<<a
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef pair<int,pair<int,int> > tii;
typedef vector<int> vec;
typedef vector<long long> vecll;
typedef vector<pair<int,int> > vec_pii;
typedef vector<pair<long long int,long long int> > vec_pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<pair<int,int> > > vvpii;
typedef vector<vector<pair<ll,ll> > > vvpll;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define Pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define sf(n) scanf("%lld",&(n))
#define pf(n) printf("%lld\n",(n))
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define w(t) while(t--)
#define flt(a) cout<<fixed<<setprecision(a)
#define cntSetBits(n) __builtin_popcountll(n)
/*****************************
*****************************/




void solve()
{
    ll n;
    s(n);
    vecll arr(n);
    ll kd = 0;
    fre(i,0,n)
    {
        s(arr[i]);
        kd ^= arr[i];
    }
    fre(i,0,n)
    {
        arr[i] ^= kd;
        p(arr[i]);p(" ");
    }
    endl;
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll t=1;
    // s(t);
    w(t)
    {
        solve();
    }
    return 0;
}









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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  if (a < k) {
    ans += a;
    k -= a;
    if (b < k) {
      k -= b;
      if (0 < k) {
        ans -= k;
      } else {
      }
    } else {
    }
  } else {
    ans += k;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3648
// Ryo Kamoi
//#define DEBUG

#include<iostream>
#include<string>
#include<set>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

set<char> alpset;
map<char, int> alp;

int n;
string eq[15];

int perm[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int pow10lst[9] = {1, 10, 100, 1000, 10000,
            100000, 1000000, 10000000, 100000000};
int coeff[10];
vector<int> firstalp;
vector<int> goaleq;

int str2int(string s) {
    int output = 0;
    REP(i, s.size()) {
        output += perm[goaleq[i]] * pow10lst[s.size()-1-i];
    }
    return output;
}

int factorial(int n) {
    if (n==0) return 1;
    return n*factorial(n-1);
}

int main() {
    while(1) {
        cin >> n;
        if (n==0) break;

        alpset = set<char>();

        REP(i, n) {
            string s;
            cin >> s;
            eq[i] = s;
            REP(j, s.size()) {
                alpset.insert(s[j]);
            }
        }

        set<char>::iterator it;
        int idx = 0;
        for(it=alpset.begin(); it!=alpset.end(); ++it) {
            alp[*it] = idx;
            idx ++;
        }

        REP(i, 10) coeff[i] = 0;
        firstalp = vector<int>();
        REP(i, n-1) {
            REP(j, eq[i].size()) {
                coeff[alp[eq[i][j]]] += pow10lst[eq[i].size()-1-j];
            }
            if (eq[i].size() > 1) {
                firstalp.push_back(alp[eq[i][0]]);
            }
        }
        firstalp.push_back(perm[alp[eq[n-1][0]]]);

        goaleq = vector<int>();
        REP(i, eq[n-1].size()) {
            goaleq.push_back(alp[eq[n-1][i]]);
        }
        int output = 0;
        do {
            bool flag = true;
            // detect zero
            REP(i, firstalp.size()) {
                if (perm[firstalp[i]]==0) {
                    flag = false; break;
                }
            }
            if (!flag) continue;

            int upbound = (perm[alp[eq[n-1][0]]]+1) * pow10lst[eq[n-1].size()-1];
            int sum = 0;
            REP(i, alpset.size()) {
                sum += perm[i] * coeff[i];
                if (sum > upbound) break;
            }
            int goal = str2int(eq[n-1]);
            if (sum == goal) {
                output++;
            }
        } while (next_permutation(perm, perm+10));

        output /= factorial(10-alpset.size());
        cout << output << endl;
    }
}




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

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    Set<Integer> d = new HashSet<Integer>();
    int n = scan.nextInt();

    for(int i = 0; i < n; i++){
      d.add(scan.nextInt());
    }

    System.out.println(d.size());
  }
}

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

int main() {
    string s, t;
    string ans;
    
    cin >> s >> t;
    ans += t;
    ans += s;
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	string S;
	cin >> S;
	vector<string> a =
	{
		"KIHBR","KIHBRA","KIHBAR","KIHBARA",
		"KIHABR","KIHABRA","KIHABAR","KIHABARA",
		"AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA",
		"AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"
	};
	bool ok = false;
	for (int i = 0; i < 16; ++i) {
		if (a[i] == S) ok = true;
	}
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
count = 0
while 1:
    flag = 0

    for a in A:
        if a%2 != 0:
            flag = 1
    if flag == 1:
        break

    else:
        count += 1
        A = [a/2 for a in A]
print(count)

Measured memory_bytes: 3060