akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const ll mod = 1e11 + 7;
const int maxn = 2e5+5;
int d[maxn];
int fi(int x) {
    return d[x] < 0 ? x : d[x] = fi(d[x]);
}
void merge(int x,int y) {
    x = fi(x);
    y = fi(y);
    d[x] += d[y];
    d[y] = x;
}
void solve() {
    int n;
    cin >> n;
    vector<pair<pair<int,int>,int>>v;
    memset(d, -1, sizeof(d));
    f1(n) {
        int x, y;
        cin >> x >> y;
        v.pb({{x,y},i});
    }
    sort(all(v));
    stack<pair<int,int>>st;
    for (auto &i : v) {
        int mi = i.F.S;
        while (st.size() && i.F.S >= st.top().F){
            //cout << i.F.S<<' '<<st.top().F<<endl;
            mi = min(mi, st.top().F);
            merge(i.S, st.top().S);
            st.pop();
        }
        st.push({mi,i.S});
    }
    f1(n) {
        cout << -d[fi(i)] << '\n';
    }
    
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        solve();
    }
    
}

Measured memory_bytes: 11056
while True:
    a,op,b = input().split()
    a=int(a)
    b=int(b)
    if op == "?": break
    elif op =="+":
        print(a+b)
    elif op =="-":
        print(a-b)
    elif op =="*":
        print(a*b)
    else:
        print(a//b)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define Cerr(x) cerr << (x) << endl
#define fi first
#define se second

ll n, cnt, ans = LINF, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k, l[ohara];
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

void dfs(ll now, ll _a, ll _b, ll _c, ll syn)
{
    if (now == n - 1)
    {
        if (_a == 0 || _b == 0 || _c == 0)
            return;
        cnt = abs(_a - a) + abs(_b - b) + abs(_c - c) + syn * 10;
        //if(_a==98&&_c==80)cerr<<_a<<" "<<_b<<" "<<_c<<" "<<syn<<"\n";
        ans = min(ans, cnt);
    }
    else
    {
        if (_a == 0)
            dfs(now + 1, _a + l[now + 1], _b, _c, syn);
        else
            dfs(now + 1, _a + l[now + 1], _b, _c, syn + 1);
        if (_b == 0)
            dfs(now + 1, _a, _b + l[now + 1], _c, syn);
        else
            dfs(now + 1, _a, _b + l[now + 1], _c, syn + 1);
        if (_c == 0)
            dfs(now + 1, _a, _b, _c + l[now + 1], syn);
        else
            dfs(now + 1, _a, _b, _c + l[now + 1], syn + 1);
        dfs(now + 1, _a, _b, _c, syn);
    }
    return;
}

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

    cin >> n >> a >> b >> c;
    rep(i, n) cin >> l[i];
    dfs(-1LL, 0LL, 0LL, 0LL, 0LL);
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Keep_calmYou_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);//freopen("out.txt","w",stdout);
typedef long long ll;
typedef long double ld;
using namespace std;


int main()
{
    Keep_calmYou_are_still_learning;

    int n;
    cin>>n;
    cout<<(n+1)/2<<'\n';

    return 0;
}


Measured memory_bytes: 256
fn main() {
    use std::io;
    let mut input1 = String::new();
    let mut input2 = String::new();

    let _ = io::stdin().read_line(&mut input1);
    let _ = io::stdin().read_line(&mut input2);

    let inputs: Vec<isize> =
        input2.trim().split_whitespace().map(|x| x.parse::<isize>().unwrap()).collect();

    let mut results: Vec<isize> = vec![0; 8];
    for val in &inputs {
        match *val {
            1...399 => results[0] += 1,
            400...799 => results[1] += 1,
            800...1199 => results[2] += 1,
            1200...1599 => results[3] += 1,
            1600...1999 => results[4] += 1,
            2000...2399 => results[5] += 1,
            2400...2799 => results[6] += 1,
            2800...3199 => results[7] += 1,
            _ => results.push(1),
        }
    }
    let mut min = 0;
    for index in 0..8 {
        if results[index] > 0 {
            min = min + 1;
        }
    }
    let mut max = min.clone();
    if results.len() > 8 {
        for index in 8..results.len() {
            if results[index] > 0 {
                max = max + 1;
            }
        }
    }
    if min == 0 && max > 0 {
        min = 1;
    }
    println!("{} {}", min, max);
}


Measured memory_bytes: 4352
/*  ex4_1 Golden Apple
    pandacodeb  */

#include <stdio.h>
#include <math.h>

int findLeast(double numApple, double range);

int main(void){
    double numApple, range;
    scanf("%lf %lf", &numApple, &range);
    int numPeople = findLeast(numApple, range);     //最小人数の計算
    printf("%d\n", numPeople);
    return 0;
}

int findLeast(double numApple, double range){
    double realRange = 2*range + 1;                 //本当の監視可能な範囲の計算
    int numLeast = (int) ceil(numApple/realRange);  //最小人数の計算
    return numLeast;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

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

	char c[26] = {0};

	int len = (int)s.size();

	REP(i, len){
		c[s[i] - 'a']++;
	}
	REP(i, 26){
		if (c[i] == 0){
			cout << (char)('a' + i) << endl;
			return 0;
		}
	}

	cout << "None" << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int dp[5][2000010] = {0};
int a[200010];
signed main(){
    int l;
    cin >> l;
    rep(i,l)cin >> a[i+1];
    for(int i = 1;i <= l;i++){
        dp[0][i] = dp[0][i-1] + a[i];
        if(a[i] != 0)dp[1][i] = min(dp[0][i-1],dp[1][i-1])+a[i]%2;
        else dp[1][i] = min(dp[0][i-1],dp[1][i-1])+2;
        dp[2][i] = min({dp[0][i-1],dp[1][i-1],dp[2][i-1]})+(a[i]+1)%2;
        if(a[i] != 0)dp[3][i] = min({dp[0][i-1],dp[1][i-1],dp[2][i-1],dp[3][i-1]})+a[i]%2;
        else dp[3][i] = min({dp[0][i-1],dp[1][i-1],dp[2][i-1],dp[3][i-1]})+2;
        dp[4][i] = min({dp[0][i-1],dp[1][i-1],dp[2][i-1],dp[3][i-1],dp[4][i-1]})+a[i];
    }
    cout << min({dp[0][l],dp[1][l],dp[2][l],dp[3][l],dp[4][l]}) << endl;
    // rep(i,l+1){
    //     rep(j,5)cerr << dp[j][i] << " ";
    //     cerr << endl;
    // }

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://abc107.contest.atcoder.jp/tasks/abc107_b

Measured memory_bytes: 18688
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
static const int MAX_N = 500000;

int N;
P p[MAX_N];
ll memo[MAX_N + 1], memo2[MAX_N];

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%lld %lld", &p[i].first, &p[i].second);
	sort(p, p + N);
	for(int i = 0; i < N; i++){
		if(i == 0){
			memo[i + 1] = p[i].second;
		}else{
			memo[i + 1] = memo[i] + p[i].second - (p[i].first - p[i - 1].first);
		}
		memo2[i + 1] = memo2[i] + (p[i + 1].first - p[i].first) - p[i].second;
	}
	ll res = 0;
	ll max_diff = 0;
	for(int i = 1; i <= N; i++){
		max_diff = max(max_diff, memo2[i - 1]);
		res = max(res, memo[i] + max_diff);
	}
	printf("%lld\n", res);
	return 0;
}



Measured memory_bytes: 18380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 1e5 + 20;

string s;
ll n, c[26];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> s;
	n = s.size();
	for (int i = 0; i < n; i++)
		c[s[i] - 'a'] ++;
	for (int i = 0; i < 26; i++)
		c[i] = (i ? c[i-1] : 0) + c[i] * (c[i] - 1) / 2;
	cout << n * (n-1) / 2 - c[25] + 1 << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int res = 0;

    FOR(i, 0, a) {
        FOR(j, 0, b) {
            FOR(k, 0, c) {
                if (500 * i + 100 * j + 50 * k == x) {
                    res++;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
S = input()
s = []
if S[0]=='0':s = [0]
for x in S.replace('01', '0,1').replace('10','1,0').split(','):
    s.append(len(x))
M = len(s)
ans = [0] * M
ans[0] = sum(s[:2*K+1])

for i in range(2, M, 2):
    ans[i] = ans[i-2] - s[i-2] - s[i-1] + sum(s[min(i+2*K-1,M):i+2*K+1])
print(max(ans))

Measured memory_bytes: 6744
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
char ans[5];
int main(void){
	REP(i,5)ans[i]=' ';
	int n,m;
	cin>>n>>m;
	int s[m];
	char c[m];
	REP(i,m)cin>>s[i]>>c[i];
	REP(i,m){
		if(ans[s[i]]!=' '){
			if(ans[s[i]]!=c[i]){
				cout<<-1;
				return 0;
			}
		}
		else{
			ans[s[i]]=c[i];
		}
	}
	if(ans[1]==' '&&n!=1)ans[1]='1';
	if(ans[1]=='0'&&n!=1){
		cout<<-1;
		return 0;
	}
	FORN(i,1,n+1){
		if(ans[i]==' ')cout<<0;
		else cout<<ans[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int place[5];//アンテナA~Eの座標を格納する配列(入力のa,b,c,d,eに相当)
    int lim;//アンテナが直接通信可能な距離の最大値(入力のkに相当)
    int i,j;//カウンター変数
    int flag = 1;//flagが1ならすべてのアンテナは直接通信可能
    
    //入力のa~eをここで受け取る
    for(i = 0; i < 5; i++){
        scanf("%d", &place[i]);
    }
    
    //入力のkはここで受け取る
    scanf("%d", &lim);
    
    /*
    各アンテナA~Eについて自身よりも東側に位置するアンテナ全てとの距離を求める
    直接通信不可能なアンテナの組があったらflagを0にした上で内側のループを抜ける
    */
    for(i = 0; i < 5; i++){
        for(j = i+1; j < 5; j++){
            if(place[j] - place[i] > lim){
                flag = 0;
                break;
            }
        }
    }
    
    //flagが1ならすべてのアンテナは直接通信可能　0なら直接通信不可能な組がある
    if(flag){
        puts("Yay!");
    }else{
        puts(":(");
    }
    
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  
  int sumN, sumM; 
  
  if (N < 2) sumN =0;
  else sumN = N*(N-1)/2;
    
  if (M < 2) sumM =0;
  else sumM = M*(M-1)/2;
  
  cout << sumN + sumM << endl; 
}


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

int n,m;
int pre[20];
int dp[maxn];
int cnt[]={0,2,5,5,4,5,6,3,7,6};

inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0' || ch>'9')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9')
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	} 
	return x*f;
}

int main()
{
	n=read(), m=read();
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	while(m--)
	{
		int x=read();
		pre[x]=1;
		for(int i=cnt[x];i<=n;i++)
			dp[i]=max(dp[i],dp[i-cnt[x]]+1);
	}	
	
	int tmp=n;
	while(tmp)
	{
		for(int i=9;i;i--)
		{
			if(pre[i] && tmp>=cnt[i] && dp[tmp-cnt[i]]==dp[tmp]-1)
			{
				cout<<i;
				tmp-=cnt[i];
				break;
			}
		}
	}
	
//	system("pause");
	return 0;
} 

Measured memory_bytes: 4032
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;
 
	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;
 
	    	return this.s-p.s;
	    }
 	}
 // 	class Sort implements Comparator<String> 
	// { 
	//     public int compare(String a, String b) 
	//     { 
	//     	return (a+b).compareTo(b+a);
	//     } 
	// }
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	int upperBound(long a[],long key)
	{
		int l=0,r=a.length-1;
		int i=-1;
 
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid]<key)
				l=mid+1;
 
			else{
				i=mid;	
				r=mid-1;
			}
			
		}
		return i;
	}
	int lowerBound(Pair[] a , long key)
	{
		int l = 0, r = a.length- 1;
		int i = -1;
 	
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid].f<key)
			{
				i=mid;
				l=mid+1;	
			}
 
			else
				r=mid-1;
			
		}
		return i;
	}
 
	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}
	
 
	int mod= 1000000007;
	long gcd(long x ,long y)
	{
		if(y==0)
			return x;
		return gcd(y,x%y);
	}
 
	// ArrayList<Integer> a[];
	// TreeMap<Integer, Long> map;
	// int vis[];
	// long d[];
	// void dfs(int ver, int m)
	// {
	// 	map.put(ver, d[m % 3]);
	// 	for(int v : a[ver])
	// 	{
	// 		if(vis[v] == 0){
	// 			vis[v] = vis[ver] + 1;
	// 			dfs(v, m + 1);
	// 		}
	// 	}
	// }
 
 	int countSetBits(long n) 
    { 
        int count = 0; 
        while (n > 0) { 
            n &= (n - 1); 
            count++; 
        } 
        return count; 
    }

	void solve() throws IOException{
		int r = nextInt();
		int g = nextInt();
		int b = nextInt();
		int k = nextInt();

		while(g <= r && k-- > 0)
			g *= 2;

		while(b <= g && k-- > 0)
			b *= 2;
	
		if(b > g && g > r)
			out.println("Yes");
		else
			out.println("No");
	}
	
	
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
 
		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Main().run();
	}
}



Measured memory_bytes: 33060
#include <iostream>
#include <cstdio>
#include <string>
#define ll long long
#define in(a) scanf("%d",&a)
#define yes printf("Yes")
#define no printf("No")
using namespace std;
string s;
ll i,a,b;
int main(){
	in(a);in(b);
	getline(cin,s);
	getline(cin,s);
	if(s.length()!=a+b+1){
		no;
		return 0;
	}
	for(i=0;i<s.length();i++){
		if(i==a&&s[i]!='-'){
			no;return 0;
		}else if(i!=a)if(s[i]<48||s[i]>57){
			no;return 0;
		}
	}
	yes;
	return 0;
}

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

int main(){
    int a, b, c;
    string s;
    cin >> a >> s;
    if(a >= 3200)cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int result = sc.nextInt();
			result = result*10 + sc.nextInt();
			result = result*10 + sc.nextInt();
			System.out.println((result%4 == 0)? "YES" : "NO");
		}catch(Exception e){
			e.printStackTrace();
		}
	} 
}

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

int main() {
    char b; cin >> b;

    if(b=='A'){
        cout << 'T' << endl;
    }
    else if(b=='T') cout << 'A' << endl;
    else if(b=='G') cout << 'C' << endl;
    else cout << 'G' << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cin>>n;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    string s;

    cin>>s;
    if(d>c){
        bool can=true;
        //bからd
        int tb=b-1;

        while(true){
            if(s[tb]=='#'||tb>=s.size()){can=false;break;}
            else if(tb==d-1){break;}
            if(s[tb+1]=='#'){
                tb+=2;
            }else{
                tb++;
            }
        }

        if(can==false){
            cout<<"No"<<endl;return 0;
        }
        tb=a-1;

        while(true){
            if(s[tb]=='#'||tb>=s.size()){can=false;break;}
            else if(tb==c-1){break;}
            if(s[tb+1]=='#'){
                tb+=2;
            }else{
                tb++;
            }
        }

        if(can==false){
            cout<<"No"<<endl;return 0;
        }else{
            cout<<"Yes"<<endl;
        }

    }else{
        bool can=true;
        bool j=false;
        int tb=b-1;
        int ji=0;
        while(true){
           // cout<<tb<<endl;

            if(s[tb]=='#'||tb>=s.size()){can=false;break;}
            else if(tb==d-1){
                if(tb+1<s.size()&&tb-1>=0&&s[tb+1]=='.'&&s[tb-1]=='.'){j=true;ji=tb;}
                break;
            }

            if(tb+1<s.size()&&tb-1>=0&&s[tb+1]=='.'&&s[tb-1]=='.'){j=true;ji=tb;}
            if(s[tb+1]=='#'){
                tb+=2;
            }else{
                tb++;
            }
        }


        if(can==false||j==false){
            cout<<"No"<<endl;
            return 0;
        }
        //cout<<ji<<endl;


        tb=a-1;

        while(true){
            //cout<<tb<<endl;




            if(s[tb]=='#'||tb>=s.size()){can=false;break;}
            else if(tb==c-1){break;}
            if(s[tb+1]=='#'||tb+1==ji){
                tb+=2;
            }else{
                tb++;
            }
        }


        if(can==false){
            cout<<"No"<<endl;return 0;
        }else{
            cout<<"Yes"<<endl;
        }


    }




    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[] s = in.next().toCharArray();
		int length = s.length;
		int i = 0;

		while(i < length) {

			int r = 0;
			while(i<length && s[i] == 'R') {
				r++;
				i++;
			}

			int l = 0;
			while(i<length && s[i] == 'L') {
				l++;
				i++;
			}

			int R , L;
			R = (int)Math.ceil(r/2.0);
			L = (int)(r/2.0);

			R += (int)(l/2.0);
			L += (int)Math.ceil(l/2.0);

			for(int j = 1; j < r; j++)
				System.out.println(0);
			System.out.println(R);
			System.out.println(L);
			for(int j = 1; j < l; j++)
				System.out.println(0);
		}

	}
}

Measured memory_bytes: 43152
import heapq
from itertools import repeat, starmap
from operator import mul

R = lambda: map(int, input().split())
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
    b, c = R()
    i = b
    while i and a[0][0] < c:
        x, y = a[0]
        if i < y:
            heapq.heapreplace(a, (x, y - i))
            i = 0
        else:
            heapq.heappop(a)
            i -= y
    if i < b:
        heapq.heappush(a, (c, b - i))
print(sum(starmap(mul, a)))


Measured memory_bytes: 21548
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
vector<long long>a;
vector<long long>b;
char c[10];
	int n;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
		scanf("%lld", &x);
s=x;
ans=x;
y=0;
	f(i, n-1){
scanf("%s",c);
scanf("%lld", &x);
ans+=x;
if(c[0]=='+'){
s+=x;
}
else{
y+=x;
a.push_back(s);
b.push_back(x);
s=0;
}
	}
a.push_back(s);
if(b.size()==0){
printf("%lld\n",ans);
return 0;
}
s=b[0]+a[1];
z=s;
	f(i, b.size()-1){
s+=(a[i+2]-a[i+1]+b[i+1]);
z=min(z,s);
	}
z=min(z,y);
ans-=(z*2);

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
double a,b,x;

double from_rad_to_dosu(double x){
  return x*180/M_PI;
}

double katamuki_syo(double kakudo){
  return a*a*(2*b-a*tan(kakudo))/2;
}

double katamuki_dai(double kakudo){
  return a*b*b/(2*tan(kakudo));
}

int main(){
  cin>>a>>b>>x;
  double ans=0,min=0,max=M_PI/2,kakudo,ze_gosa=1,so_gosa=1;
  while(ze_gosa>0.00000001 || so_gosa>0.00000001){
    //cout<<fixed<<setprecision(12)<<"min:"<<min<<" max:"<<max<<endl;
    double tmp;
    kakudo=(min+max)/2;
    if(tan(kakudo)<b/a){
      tmp=katamuki_syo(kakudo);
      //cout<<" syo,tmp:"<<tmp<<endl;
    }else{
      tmp=katamuki_dai(kakudo);
      //cout<<" dai,tmp:"<<tmp<<endl;
    }
    if(x<tmp) min=kakudo;
    else max=kakudo;
    //cout<<fixed<<setprecision(12)<<"tmp:"<<tmp<<endl;
    ze_gosa=abs(tmp-x);
    so_gosa=abs((tmp-x)/x);
  }
  
  cout<<fixed<<setprecision(12)<<from_rad_to_dosu(kakudo);
}

Measured memory_bytes: 256
s=input()
t=input()
ok=False
snum=[]
tnum=[]
for i in range(len(s)):
    snum.append(ord(s[i]))
snum.sort()
for i in range(len(t)):
    tnum.append(ord(t[i]))
tnum.sort(reverse=True)
if len(s)>=len(t):
    round=len(t)
else:
    round=len(s)
for i in range(round):
    if (snum[i]<tnum[i]) or (snum==tnum[:round]and len(t)>len(s)):
        ok=True
        break
print("Yes"if ok else"No")

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

int main()
{
    char str[200001]="";
    int cot=0,p_a=0,len=0;
    bool ex_a=false;
    scanf("%s",str);
    len=strlen(str);
    for(int i=0;i<len;i++){
	if(str[i]=='A' && ex_a==false){
	    ex_a=true;
	    p_a=i;
	}
	else if(str[i]=='Z' && ex_a==true)
	    cot=i-p_a+1;
    }

    printf("%d",cot);
    return 0;
}





Measured memory_bytes: 384
N, K = list(map(int, input().split()))


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


print(len(Base_10_to_n(N, K)))

Measured memory_bytes: 2940
a=list(map(int,input().split()))
b,c=[],[]
ans=set()
for _ in range(a[1]):
    b.append(int(input()))
    c.append(list(map(int,input().split())))
for i in range(a[1]):
    for j in range(b[i]):
        ans.add(c[i][j])
print(a[0]-len(ans))

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

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

    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1), c(n - 1);
    rep(i, 0, n) cin >> a[i + 1];
    rep(i, 0, n) cin >> b[i + 1];
    rep(i, 0, n - 1) cin >> c[i + 1];
    int ans = 0;
    rep(i, 1, n + 1) {
        int x = a[i];
        ans += b[a[i]];
        if (i)
            if (a[i] == a[i - 1] + 1)
                ans += c[a[i] - 1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline

def main():
    a, b, c = map(int, input().split())
    tmp = c - a - b
    if tmp <= 0:
        print("No")
    else:
        if 4 * a * b < tmp * tmp:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()

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

lint a[2000010],n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	lint result=0,cur=0,r=0;
	for(int i=0;i<n;i++){
		while(r<n&&(cur&a[r])==0){
			cur^=a[r];r++;
		}
		cur^=a[i];
		result+=r-i;
	}
	cout<<result<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=0;i<n;i++)
    {
      scanf("%d", &A[i]);
    }
  
  /*Initialize*/
  for(i=0;i<VMAX;i++)
    {
      C[i]=0;
    }
  
  /*Record*/
  for(j=0;j<n;j++)
    {
      C[A[j]]++;
    }
  
  /*Add*/
  for(i=1;i<VMAX;i++)
    {
      C[i] = C[i] + C[i-1];
    }
  
  /*Write*/
  for(i=n-1;i>=0;i--)
    {
      B[C[A[i]]] = A[i];
      C[A[i]]--;
    }

  for(i=1;i<=n;i++)
    {
      if(i>1)printf(" ");
      printf("%d", B[i]);
    }
  printf("\n");

  return 0;
  /*Write*/
  for(i=n-1;i>=0;i--)
    {
      B[C[A[i]]] = A[i];
      C[A[i]]--;
    }

  for(i=1;i<=n;i++)
    {
      if(i>1)printf(" ");
      printf("%d", B[i]);
    }
}



Measured memory_bytes: 9580
import math
from collections import defaultdict
ml=lambda:map(float,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())

"""========main code==============="""

a,b=input().split()
a=int(a)
b_=""
for i in str(b):
    if i!='.':
        b_+=i
      
b_=int(b_)
a*=b_
print(int(a//100))


Measured memory_bytes: 65260
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main() {
    ios;
   ll p,n;cin>>p>>n;
   int ar[n];
   ll su=0;
   f(i,0,n){cin>>ar[i];
    if(i==0)
   su+=ar[i];
      else su+=ar[i]-ar[i-1]; 
   }
   su+=p-ar[n-1];
   ll ans=p;
   f(i,0,n)
   {   
       if(i==0&&p-(ar[i]+p-ar[n-1])<ans)ans=p-(ar[i]+p-ar[n-1]);
       else if(p-(ar[i]-ar[i-1])<ans)ans=p-(ar[i]-ar[i-1]);
   }
   cout<<ans;
   
 
    
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int n;
	cin >> n;

	int tourist = 0;
	vi color(8);
	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] <= 399) {
			color[0]++;
		}
		else if (a[i] <= 799) {
			color[1]++;
		}
		else if (a[i] <= 1199) {
			color[2]++;
		}
		else if (a[i] <= 1599) {
			color[3]++;
		}
		else if (a[i] <= 1999) {
			color[4]++;
		}
		else if (a[i] <= 2399) {
			color[5]++;
		}
		else if (a[i] <= 2799) {
			color[6]++;
		}
		else if (a[i] <= 3199) {
			color[7]++;
		}
		else {
			tourist++;
		}
	}

	int colorNum = 0;
	for (int i = 0; i < 8; i++) {
		if (color[i] == 0) continue;
		colorNum++;
	}

	if (tourist == 0) {
		cout << colorNum << " " << colorNum << endl;
	} else {
		cout << (colorNum == 0 ? 1 : colorNum)
			<< " "
			<< (colorNum + tourist) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
  int tmp;
  bool ary[6]={};
  for(int i=0;i<5;i++){
    cin>>tmp;
    ary[tmp]=true;
  }
  for(int i=0;i<6;i++){
    if(!ary[i])cout<<i<<endl;
  }
}


Measured memory_bytes: 3632
from collections import deque
N, M = map(int, input().split())
G = [[] for i in range(N)]
for m in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

color = [-1 for i in range(N)]
visits = [False for i in range(N)]
paths = deque()


def Bipartial():
    paths.append(0)
    color[0] = 0
    while paths:
        x = paths.pop()
        visits[x] = True
        for g in G[x]:
            if visits[g] and color[g] == color[x]:
                return False
            elif not visits[g]:
                paths.append(g)
                color[g] = (color[x]+1) % 2
    return True


if Bipartial():
    B = color.count(0)
    W = color.count(1)
    ans = B * W - M
else:
    ans = (N * (N - 1)) // 2 - M
print(ans)

Measured memory_bytes: 64032
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	string s;
	long long int a,ct=0;
	cin>>a;
	forr(i,1,a+1)
	{
		forr(j,1,a+1)
		{
			forr(k,1,a+1)
			{
				int x=__gcd(__gcd(i,j),k);
				ct+=x;
			}
		}
	}
	cout<<ct;
	
	return 0;	
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
using namespace std;
int fac[105];
int main() {
    int n; cin>>n;
    memset(fac, 0, sizeof fac);
    for(int i=1; i<=n; i++) {
        int x = i;
        for(int j=2; j*j<=x; j++) {
            while(x%j==0) {
                fac[j]++;
                x/=j;
            }
        }
        if(x != 1) fac[x]++;
    }
    int sum = 0;
    for(int i=2; i<=n; i++) if(fac[i]) if(fac[i]>=74) sum++;
    int t1 = 0, t2 = 0;
    for(int i=2; i<=n; i++) if(fac[i]) {
        if(fac[i]>=24) t1++;
        else if(fac[i]>=2) t2++;
    }
    if(t1) sum+=t1*t2+t1*(t1-1);
    t1 = 0, t2 = 0;
    for(int i=2; i<=n; i++) if(fac[i]) {
        if(fac[i]>=14) t1++;
        else if(fac[i]>=4) t2++;
    }
    if(t1) sum+=t1*t2+t1*(t1-1);
    t1 = 0, t2 = 0;
    for(int i=2; i<=n; i++) if(fac[i]) {
        if(fac[i]>=4) t1++;
        else if(fac[i]>=2) t2++;
    }
    if(t1) sum+=t1*(t1-1)/2*t2;
    if(t1 > 1) sum+=t1*(t1-1)*(t1-2)/2;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int n, m;
int S[3];

int toC( int a, int b, int c )
{
	if( !a && !b )
		return 0;

	if(c&1)
		return toC(a>>1,b>>1,c>>1);
	if(b&1)
		return toC(c>>1,b>>1,a>>1)+toC((a|b|c)>>1,0,0)+1;
	if(a&1)
		return toC(a>>1,b>>1,c>>1)+2*toC((a|b|c)>>1,0,0)+2;
}

int main()
{
	while( scanf( "%d%d", &n, &m ), n|m )
	{
		rep( i, 3 )
			S[i] = 0;

		rep( t, 3 )
		{
			int c;
			scanf( "%d", &c );

			rep( i, c )
			{
				int a;
				scanf( "%d", &a );

				S[t] |= 1<<a-1;
			}
		}

		int ans = std::min( toC(S[0],S[1],S[2]), toC(S[2],S[1],S[0]) );
	
		printf( "%d\n", ans<=m?ans:-1 );
	}
	
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	// diverta 2019 Programming Contest-D, 1095, 
	ll ans = 0;
	ll n; cin >> n;
	ll sq = sqrt(n);
	for (ll i = 1; i <= sq; ++i) {
		if ((n - i) % i == 0) ans += (n - i) / i > i ? (n - i) / i : 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
using ll = long long;
using namespace std;

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

ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll e = lcm(c, d);
  ll count = 0;
  count += b / c;
  count += b / d;
  count -= b / e;
  count -= (a-1) / c;
  count -= (a-1) / d;
  count += (a-1) / e;
  ll ans = b - a + 1 - count;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
program sample
    implicit none
  
    integer(8) :: a,b,c,d,i,j,n,h,w,k,m,x(4),sum
  
    
  
    ! 整数を読み込む
    read(*,*) n,k
    
        m=n/k
        sum=m**3
    if(mod(k,2)==1)then
            write(*,*)sum
    else
        if(mod(n,k)>=k/2)then
            m=n/k+1
        else
            m=n/k
        end if
        sum=sum+m**3
        write(*,*)sum
    end if
    


    stop
  end program sample
  

Measured memory_bytes: 2760
row = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(row[K - 1])

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,g;
    int arr[100]={0};
    scanf("%d",&a);
    for(b=0;b<a;b++)
    {
        scanf("%d",&arr[b]);

    }
    scanf("%d",&c);
    for(d=0;d<c;d++)
    {
        scanf("%d%d",&e,&f);
       g=arr[e-1];
       arr[e-1]=f;
        f=0;
        for(b=0;b<a;b++)
        {
            f=arr[b]+f;
        }
        printf("%d\n",f);
        arr[e-1]=g;


    }


}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int q = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(sa[i]);
		}
		Obj[] arr = new Obj[q];
		Obj[] arr2 = new Obj[q];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.i = i;
			o.l = Integer.parseInt(sa[0]);
			o.r = Integer.parseInt(sa[1]);
			arr[i] = o;
			arr2[i] = o;
		}
		br.close();

		int[] pre = new int[n + 1];
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			if (map.containsKey(c[i])) {
				pre[i + 1] = map.get(c[i]);
			}
			map.put(c[i], i + 1);
		}

		Arrays.sort(arr, (o1, o2) -> o1.r - o2.r);
		BIT bit = new BIT(n);
		int j = 1;
		for (Obj o : arr) {
			while (j <= o.r) {
				bit.add(j, 1);
				if (pre[j] > 0) {
					bit.add(pre[j], -1);
				}
				j++;
			}
			o.ans = bit.sum(o.r) - bit.sum(o.l - 1);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			pw.println(arr2[i].ans);
		}
		pw.flush();
	}

	static class Obj {
		int i, l, r;
		long ans;
	}

	static class BIT {
		int n;
		long[] arr;

		public BIT(int n) {
			this.n = n;
			arr = new long[n + 1];
		}

		void add(int idx, long val) {
			for (int i = idx; i <= n; i += i & -i) {
				arr[i] += val;
			}
		}

		long sum(int idx) {
			long sum = 0;
			for (int i = idx; i > 0; i -= i & -i) {
				sum += arr[i];
			}
			return sum;
		}
	}
}


Measured memory_bytes: 134684
fun main(args: Array<String>) = ABC160E.main()

object ABC160E {
    fun main() {
        val (X, Y, A, B, C) = readInts()
        val p = readLongs()
        val q = readLongs()
        val r = readLongs()

        val red = p.sorted().takeLast(X)
        val green = q.sorted().takeLast(Y)
        val non = r

        val all = red + green + non
        val eats = all.sorted().takeLast(X+Y)
        val ans = eats.sum()
        println(ans)
    }


    /*####################################################################################*/

    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
}

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

int main() {
int n,k;
string s;
cin >> n >> k >> s;
char x = s.at(k-1);
if (x == 'A'){
s.at(k-1) = 'a';
}
if (x == 'B'){
  s.at(k-1) = 'b';
}
if (x == 'C'){
  s.at(k-1) = 'c';
}
cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int w;
void solve(){
  int cnt=0;
  for(int i = 0; i < 10; i++){
    if(w & (1<<i)){
      if(cnt)cout << " ";
      cnt++;
      cout << (1<<i);
    }
  }
  cout << endl;
}
int main(){
  while(cin >> w){
    solve();
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)



int main(){
	int n;
	cin >> n;
	bool p = 1;
	for (int i = 1; i <= n;i++) {
		if (n == i * 108 /100) {
			if (108 * i % 100 == 0) {
				cout << (int)100 * n / 108 << endl;
			}
			else cout << (int)100 * n / 108 + 1 << endl;
			p = 0;
			break;
		}
	}
	if (p == 1)cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int bignumlen = 2200;
const int Blen = 8;
const ll base = 100000000;
const int baseHash = 31;
const ld PI = acos(-1);

//Remember limit for IT, etc...
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
//If TLE let's use int instead of ll

ll a, b;

void solveProblem() {
    a %= b;
    cout << min(a, abs(a - b));
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> a >> b;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
using namespace std;
typedef pair<int,int> ii;

int fact[2000005];
int mod = 1000000007;
long long qexp(long long b, long long p){
    long long res = 1;
    while(p){
        if(p&1) res = (res * b) % mod;
        b = (b * b) % mod;
        p >>= 1;
    }
    return res;
}
int inv(long long b){ return qexp(b, mod-2); }
int choose(int N, int C){
	if(N < C) return 0;
	int res = fact[N];
	res *= inv(fact[C]);
	res %= mod;
	res *= inv(fact[N-C]);
	res %= mod;
	return res;
}

int ans = 0;
void fix(int &x){
	x %= mod;
	if(x < 0) x += mod;
}

signed main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	fact[0] = 1;
	for(int i = 1;i <= 2000000;i++) fact[i] = (fact[i-1] * i) % mod;
	
	int N; cin >> N;
	ans = (N-1)*fact[N-1];
	fix(ans);
	
	for(int len = 2;len < N-1;len++){
		int places = N - 3;
		int take = len - 2;
		int notake = places - take;
		
		int ways = choose(take + 1, notake);
		if(ways == 0) continue;
		fix(ways);
		
		
		
		ways *= fact[len];
		ways %= mod;
		ways *= fact[N-1-len];
		ways %= mod;
		
		//cout << len << " " << ways << "\n";
		
		int loss = ways;
		loss %= mod;	
		
		ans -= loss;
		ans %= mod;
		if(ans < 0) ans += mod;
	}
	
	cout << ans;
}





Measured memory_bytes: 19272
#include <stdio.h>
int main(){
  int a,b,c,d,e,k;

  scanf("%d\n%d\n%d\n%d\n%d\n%d",&a,&b,&c,&d,&e,&k);

  if(e-a <= k){
    printf("Yay!");
  }else{
    printf(":(");
  }


  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int m;
    cin >> m;
    vector<LL> d(m), c(m);
    rep(i, m) cin >> d[i] >> c[i];

    vector<pair<int, int>> del(10);
    del[0] = make_pair(1, 1);
    rep1(i, 10){
        int now = i+i;
        int ct = 1, dig = 1;
        while(now != i){
            while(now > 9){
                now = now/10 + now%10;
                ct++;
            }
            if(now != i){
                now += i;
                ct++;
                dig++;
            }
        }
        // cout << dig << " " << ct << endl;
        del[i] = make_pair(dig, ct);
    }

    LL ans = 0;
    vector<int> rem;
    rep(i, m){
        LL unit = (c[i]-1)/del[d[i]].first;
        ans += unit * del[d[i]].second;
        c[i] -= del[d[i]].first*unit;
        // cout << c[i] << endl;
        rep(j, c[i]) rem.push_back(d[i]);
    }

    LL now = rem[0];
    rep1(i, rem.size()){
        now += rem[i];
        ans++;
        while(now > 9){
            now = now/10 + now%10;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9584
N, K, Q = map(int, input().split())

ac = [0] * (N + 1)
for i in range(Q):
    A = int(input())
    ac[A] += 1
for i in range(1, N + 1):
    if K - (Q - ac[i]) > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 50904
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	ll N, M;
	cin >> N >> M;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());

	vector<ll> cum(N);
	cum[0] = A[0];
	for(int i=1; i<N; i++) cum[i] = cum[i-1] + A[i];

	ll ub = 1e12, lb = 0;
	map<ll, pair<ll, ll>> m;
	while(ub-lb>1){
		ll z = (lb+ub)/2;

		ll count = 0;
		ll total = 0;
		for(int i=0; i<N; i++){
			int ubi = N, lbi = 0;
			if(A[0]+A[i]<z) continue;

			while(ubi-lbi>1){
				int k = (ubi+lbi)/2;
				if(A[k]+A[i]>=z){
					lbi = k;
				} else {
					ubi = k;
				}
			}
			int k = lbi;
			total += cum[k] + A[i]*(k+1);
			count += (k+1);
			debug(" ", z, i, k);
		}

		m[z] = {count, total};
		debug(z, count, total);
		if(count > M) lb = z;
		else ub = z;
	}

	debug(lb, ub);
	ll ans = m[ub].second + lb * (M - m[ub].first);
	cout << ans << endl;

	return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

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

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

    int n; std::cin >> n;
    vi a(n); rep(i, n) std::cin >> a[i], a[i]--;
    vector<bool> visited(n);
    int cur = 0, ans = 0;
    visited[0] = true;
    while (ans < n && !visited[1]) {
        cur = a[cur];
        visited[cur] = true;
        ans++;
    }
    std::cout << (visited[1] ? ans : -1) << "\n";
}


Measured memory_bytes: 640
import sys


def resolve():
    readline = sys.stdin.readline

    def func(n: int, a: int):
        res = 0
        while n > 0:
            res += n % a
            n = int(n / a)
        return res

    N = int(readline())

    res = N
    for i in range(N + 1):
        tmp = func(i, 6) + func(N - i, 9)
        res = min(res, tmp)
    print(res)

resolve()


Measured memory_bytes: 9160