akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m;
    cin >> n >> m;
    vi p(m);
    vector<string> s(m);
    rep(i, m) cin >> p[i] >> s[i];
    vector<int> pens(n, 0);
    int acc = 0, pen = 0;
    rep(i, m) {
        if (pens[p[i]] >= 0 && s[i] == "AC") {
            acc++;
            pen += pens[p[i]];
            pens[p[i]] = -1;
        } else if (pens[p[i]] >= 0 && s[i] == "WA") {
            pens[p[i]]++;
        }
    }
    cout << acc << " " << pen << endl;
    return 0;
}


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    ll a[n]; f(i,0,n-1) cin >> a[i];
    bool zero = false;
    f(i,0,n-1) if(a[i] == 0) zero = true;
    if(zero) {
    	cout << 0;
    	return 0;
    }
    ll ans = 1;
    bool exceed = false;
    f(i,0,n-1) {
    	ll new_ans = ans * a[i];
    	cout << "";
    	if(ans != new_ans / a[i] || new_ans > (ll)1e18) {
    		exceed = true; break;
    	}
    	ans = new_ans;
    }
    if(exceed) cout << -1;
    else cout << ans;
    return 0;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c,d;
string s;
signed main()
{
	cin>>a>>b>>c>>d;
	if(d==1){
		cout<<1;
	}else{
		cout<<0;
	}
}

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


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
// rep(i,1,10) is from 1 to 9 and rep(I,10,1) is from 9 to 1
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res);
    else return (a*res*res);
}

// vi adj[1000000];

int check(long double m,vii a,int n)
{
    long double left=-1e18,right=1e18;

    rep(i,0,n)
    {
        long double dist;
        dist=sqrt(m*m-(a[i].S-m)*(a[i].S-m));
        left=max(left,dist);
        right=min(right,dist);
    }
    if(left<=right) return true;
    return false;
}


void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    int a,b,c;
    cin>>a>>b>>c>>k;
    int ans=min(k,a);
    if(k>=a) k-=a;
    if(k<=b) 
    {
        cout<<ans;
        return;
    }
    else
    {
        k-=b;
        ans-=k;
        cout<<ans;
    }
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define MAX 1000

int c[MAX + 1][MAX + 1];

int lcs(string x, string y) {
	int m = x.size();
	int n = y.size();
	int maxl = 0;
	x = ' ' + x;
	y = ' ' + y;
	for (int i = 0; i <= m; i++) {
		c[i][0] = 0;
	}
	for (int j = 1; j <= n; j++) {
		c[0][j] = 0;
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (x[i] == y[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i][j - 1], c[i - 1][j]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}
	return maxl;
}

int main()
{
	int q;
	cin >> q;
	string x, y;
	int l[150] = { 0 };

	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		l[i] = lcs(x, y);
	}
	for (int i = 0; i < q; i++) {
		cout << l[i] << endl;
	}
	return 0;
}


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

#define ntest 0

using namespace std;
int n;
long long res;
void solve() {
    cin >> n;
    for (int i = 1; i < n; ++i) res += (n-1)/i;
    cout << res;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3616
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS

int N=0;

int main() {
	scanf("%d",&N);
	if (N<=999) {
		printf("ABC\n");
	}
	else {

		printf("ABD\n");
	}
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stack>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,m,a,b,sum=0;
    cin >> n >> m;
    vector<int> h(n);
    vector<vector<int>> pv(n);
    rep(i,n){
        cin >> h[i];
    }
    rep(i,m){
        cin >> a >> b;
        pv[a-1].push_back(b-1);
        pv[b-1].push_back(a-1);
    }
    rep(i,n){
        int h1=h[i];
        if(pv[i].size()==0) sum++;
        for(int j=0,sz=pv[i].size(); j<sz; ++j){
            if(h1<=h[pv[i][j]]){
                break;
            }
            if(j==sz-1) sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 8720
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	string output;
	cin >> input;
	int input_size = input.size();
	if (input[0] == input[input_size - 1] ^ (input_size & 1))
	{
		cout << "First" << endl;
	}
	else
	{
		cout << "Second" << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    for (int i = n; i <= 999; ++i) {
        auto k = to_string(i);
        if(k[0] == k[1] && k[1] == k[2]){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
	int n,A[10000],B[10000],c=0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B,B+n);
	for (int i = 0; i < n; ++i)
	{
		if (A[i] != B[i])
		{
			c++;
		}
	}
	if (c == 2 || c == 0)
	{
		cout << "YES\n";
	}
	else
		cout <<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
int a[maxx];
int Gcd_pre[maxx];
int Gcd_bck[maxx];
int ans;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	Gcd_pre[1] = a[1];
	for(int i = 2; i <= n; i++) {
		Gcd_pre[i] = __gcd(a[i], Gcd_pre[i - 1]);
	}
	Gcd_bck[n] = a[n];
	for(int i = n - 1; i >= 1; i--) {
		Gcd_bck[i] = __gcd(a[i], Gcd_bck[i + 1]);
	}
	int ans = max(Gcd_pre[n - 1], Gcd_bck[2]);
	for(int i = 2; i <= n - 1; i++) {
		int L = Gcd_pre[i - 1];
		int R = Gcd_bck[i + 1];
		int GCD = __gcd(L, R);
		ans = max(ans, GCD);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1408
AB = [list(map(int,input().split())) for _ in [0]*3]

E = [[] for _ in [0]*4]
for a,b in AB:
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)

i = 0
for _ in [0]*2:
    d = [-1]*4
    d[i] = 0
    q = [i]
    while q:
        i = q.pop()
        for j in E[i]:
            if d[j]!= -1 : continue
            d[j] = d[i]+1
            q.append(j)
print("YES" if max(d)==3 else "NO")

Measured memory_bytes: 3064
import fractions

integral_count = int(input())
blackboard_integers = list(map(int, input().split()))

gcd_integers = list(set(blackboard_integers))
gcds = [0] * len(gcd_integers)
for i in range(len(gcd_integers)):
    if blackboard_integers.count(gcd_integers[i]) >= 2:
        for n in gcd_integers:
            gcds[i] = fractions.gcd(gcds[i], n)
    else:
        for n in gcd_integers[:i]:
            gcds[i] = fractions.gcd(gcds[i], n)
        for n in gcd_integers[i+1:]:
            gcds[i] = fractions.gcd(gcds[i], n)

print(max(gcds))

Measured memory_bytes: 16132
#include<iostream>
#include<string>
using namespace std;
int main() {
	string N;
	cin >> N;
	int num = 0;
	for (int i = 0; i < N.size(); ++i) {
		num += N[i] - '0';
	}
	if (stoi(N) % num == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

int main() {
	ll n, k, r, s, p, ans = 0;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	vector<bool>seen(n, false);
	for (ll i = 0; i < n; i++) {
		if (!seen[i]) {
			ll cost = r, cnt = 0;
			if (t[i] == 'r')cost = p;
			if (t[i] == 'p')cost = s;
			for (ll j = i ; j < n; j += k) {
				if (t[i] == t[j]) {
					seen[j] = true;
					cnt++;
				} else {
					break;
				}
			}
          ans += ((cnt + 1) / 2) * cost;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;

int main() {
    long long int n,w;
    long long int i,j;
    cin >> n >> w;

    w++;

    vector <vector <long long>> wv(n, vector <long long>(2));

    vector <vector <long long>> board(n, vector <long long>(w, 0));
    

    for (i = 0; i < n; i++) {
        for (j = 0; j < 2; j++) {
            cin >> wv.at(i).at(j);
        }
    }

    board.at(0).at(wv.at(0).at(0)) = wv.at(0).at(1);

    for (i = 1; i < n; i++) {
        long long current_w = wv.at(i).at(0);
        for (j = 0; j < current_w && j < w; j++) {
            board.at(i).at(j) = board.at(i-1).at(j);
        }
        for (j = 0; current_w + j < w; j++) {
            long long current_cost = wv.at(i).at(1) + board.at(i-1).at(j);
            if (current_cost > board.at(i-1).at(current_w + j)) {
                board.at(i).at(current_w + j) = current_cost;
            }
            else
            {
                board.at(i).at(current_w + j) = board.at(i-1).at(current_w + j);
            }
        }
    }
    //for (i = 0; i < n; i++) {
    //    for (j = 0; j < w; j++) {
    //        cout << board.at(i).at(j) << " ";
    //    }
    //    cout << endl;
    //}

    long long ans = -INF;

    for (long long a : board.at(n-1)) {
        if (ans < a)
            ans = a;        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 82272
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,D;
    cin >> N >> D;
    D = D*2+1;
    if(N%D==0){
        cout <<N/D<< "\n";
    }else{
        cout <<N/D+1<< "\n";
    }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll T;
    cin >> T;
    ll N, M, A, B;
    vector<ll> res;
    for(int i=0;i<T;i++){
        cin >> N >> M >> A >> B;
        res.push_back(floor_sum(N, M, A, B));
    }
    for(auto v : res) cout << v << endl;

    return 0;
}

Measured memory_bytes: 4288
//赤ペン先生

//全て〜　＝　１つでも間違ったらfalse
//文字列など限定的な範囲の時は、より少ない範囲がどちらか気にする

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

signed main(){

    string S;
    cin>>S;
    for (int i = 0; i < S.size() ; i++) {
        if(i%2 == 0 ){
          //  if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D')) {
            if (S[i] == 'L') {
                cout << "No";
                return 0;
            }
            }else {
           // if (!(S[i] == 'L' || S[i] == 'U' ||S[i] == 'D')) {
            if (S[i] == 'R') {
                cout << "No";
                return 0;
            }
        }
    }
    cout<< "Yes";

    return 0;
}


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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn switch_number(n1: i32, n2: i32) -> (i32, i32) {
    let tmp = n1;
    let n1 = n2;
    let n2 = tmp;
    (n1, n2)
}

fn main() {
    let A: i32 = read();
    let B: i32 = read();
    let C: i32 = read();
    let (A, B) = switch_number(A, B);
    let (A, C) = switch_number(A, C);
    println!("{} {} {}", A, B, C);
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		ArrayList<String> deck = new ArrayList<String>();
		String suit;
		int p = 0;
		for (int i = 0; i < 4; i++) {
			for (int j = 1; j < 14; j++) {
				if (i == 0) {
					suit = "S";
				} else if (i == 1) {
					suit = "H";
				} else if (i == 2) {
					suit = "C";
				} else {
					suit = "D";
				}
				deck.add(suit + " " + Integer.toString(j));
			}
		}
		for (int i = 0; i <= num; i++) {
			String test = scan.nextLine();
			for (int q = 0; q < deck.size(); q++) {
				if (deck.get(q).equals(test)) {
					deck.remove(q);
				}
			}
		}
		for (int q = 0; q < deck.size(); q++) {
			System.out.println(deck.get(q));
		}
	}
}


Measured memory_bytes: 26156
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    if(a==1||a==8||a==15||a==22||a==29)cout<<"fri"<<endl;
    else if(a==2||a==9||a==16||a==23||a==30)cout<<"sat"<<endl;
    else if(a==3||a==10||a==17||a==24)cout<<"sun"<<endl;
    else if(a==4||a==11||a==18||a==25)cout<<"mon"<<endl;
    else if(a==5||a==12||a==19||a==26)cout<<"tue"<<endl;
    else if(a==6||a==13||a==20||a==27)cout<<"wed"<<endl;
    else if(a==7||a==14||a==21||a==28)cout<<"thu"<<endl;
}


Measured memory_bytes: 3116
import heapq
Q = int(input())

A_left, A_right = [], []
A_left_sum, A_right_sum = 0, 0
heapq.heapify(A_left)
heapq.heapify(A_right)

B_sum = 0
for _ in range(Q):
    query = list(map(int,input().split()))

    if query[0] == 1:
        now = query[1]
        B_sum += query[2]

        l, r = len(A_left), len(A_right)
        if l <= r:
            heapq.heappush(A_right, now)
            A_right_sum += now

            out = heapq.heappop(A_right)
            A_right_sum -= out

            heapq.heappush(A_left, -out)
            A_left_sum += out
        else:
            heapq.heappush(A_left, -now)
            A_left_sum += now

            out = -heapq.heappop(A_left)
            A_left_sum -= out

            heapq.heappush(A_right, out)
            A_right_sum += out
    else:
        m = -A_left[0]
        ans = len(A_left) * m - A_left_sum - len(A_right) * m + A_right_sum + B_sum
        print("{0} {1}".format(m,ans))
        

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

using namespace std;

int main() {

    int N;
    int sum=0;
    int max=0;
    cin >> N;

    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
        if(A[i] > max){
            max = A[i];
        }
    }

    if(max < (sum-max) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	double n; cin >> n;
	if ((int)n % 2 == 0) {
		cout << (n / 2) / n << endl;
	}
	else {
		cout << ((n + 1) / 2) / n << endl;
	}
	cin >> n;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}

int main(){
  int k = getint(), x = getint();
  puts(k * 500 >= x ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,x,i,j,ans;
    while(true){
        cin >> n >> x;
        if (n==0) break;
        ans = 0;
        for(i=1;i<=n;i++){
            for(j=i+1;j<=n;j++){
                if (j < x-i-j && x-i-j <= n) ans += 1; 
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3088
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		FScanner sc=new FScanner();
		//Scanner sc=new Scanner(System.in);
		
		int[] num=sc.readIntL();
		int h=num[0];
		int w=num[1];
		
		String[][] grid=new String[h][w];
		
		for(int i=0; i<h; i++){
			grid[i]=sc.readStringL("");
		}
		
		trimRow(grid,h,w);
	}
	
	static void trimRow(String[][] grid, int h, int w){
		
		List<Integer> row=new ArrayList<Integer>();
		for(int i=0; i<h; i++){
			boolean wht=true;
			for(int j=0; j<w; j++){
				if(grid[i][j].equals("#")){
					wht=false;
				}
			}
			if(wht==true){
				row.add(i);
			}
		}
		
		String[][] ngrid=new String[h-row.size()][w];
		
		int cpy=0;
		
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(row.indexOf(i)==-1){
					ngrid[cpy][j]=grid[i][j];
				}
			}
			if(row.indexOf(i)==-1){
				cpy++;
			}
		}
		trimCol(ngrid,h-row.size(),w);
	}
	
	static void trimCol(String[][] grid, int h, int w){
		
		List<Integer> col=new ArrayList<Integer>();
		for(int j=0; j<w; j++){
			boolean wht=true;
			for(int i=0; i<h; i++){
				if(grid[i][j].equals("#")){
					wht=false;
				}
			}
			if(wht==true){
				col.add(j);
			}
		}
		
		String[][] ngrid=new String[h][w-col.size()];
		
		int cpy=0;
		
		for(int j=0; j<w; j++){
			for(int i=0; i<h; i++){
				if(col.indexOf(j)==-1){
					ngrid[i][cpy]=grid[i][j];
				}
			}
			if(col.indexOf(j)==-1){
				cpy++;
			}
		}
		for(String[] c: ngrid){
			System.out.println(String.join("",c));
		}
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			int i=sc.nextInt();
			return i;
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s,t,u;
  ll a,b;
  cin>>s>>t>>a>>b>>u;
  if (s==u){
    a--;
  } else {
    b--;
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int result = 0;
		for (int i = 1; i <= 9; i++)
			for (int j = 1; j <= 9; j++) {
				result += num(N, i, j) * num(N, j, i);
			}
		System.out.println(result);
	}
 
	static int num(int max, int head, int tail) {
		int result = 0;
 
		for (int i = 1; i <= max; i++)
			if (i % 10 == tail && head(i) == head)
				result++;
 
		return result;
	}
 
	static int head(int i) {
		while (i > 9) {
			i /= 10;
		}
		return i;
	}
}

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

int main(){
  int N,F=0,T;
  cin >> N;
  while(N>=0){
    if(!(N%7)) F = 1;
    N = N-4;
  }
  if(F) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  cout << "Yes" << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var cnt = 0;
            foreach(var i in Enumerable.Range(0, vals.Length-2))
            {
                if(vals[i+1]>vals[i] && vals[i+2]>vals[i+1])
                {
                    cnt++;
                }
                else if (vals[i + 1] < vals[i] && vals[i + 2] < vals[i + 1])
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13396
H,W,D=gets.split.map &:to_i
x=[0]*(H*W+1);y=[0]*(H*W+1);d=[0]*(H*W+1)
H.times{|i|gets.split.each_with_index{|e,j|x[e.to_i]=i;y[e.to_i]=j}}
(D+1..H*W).each{|i|d[i]=d[i-D]+(x[i]-x[i-D]).abs+(y[i]-y[i-D]).abs}
gets.to_i.times{x,y=gets.split.map &:to_i;p d[y]-d[x]}

Measured memory_bytes: 5372
import java.util.*;
class Main{
 public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    if(a.equals("AAA")){
    System.out.println("No");
    } else if(a.equals("BBB")){
     System.out.println("No");
    } else {
    System.out.println("Yes");
    } 
    
 } 
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int n,a[233333],ans;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],ans^=a[i];
	for(int i=1;i<n;i++)cout<<(ans^a[i])<<" ";
	cout<<(ans^a[n])<<endl;
}


Measured memory_bytes: 4304
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>

const int64_t cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.second > another.second;
}


int main()
{
   int64_t a,b,c,d;
   std::cin>> a;
   std::cin>> b;

   if( a == 1 )
   {
       if( b == 2 )
       {
           std::cout<< 3;
       }
       else
       {
           std::cout<< 2;
       }
   }
   else if( a == 2 )
   {
       if( b == 1 )
       {
           std::cout<< 3;
       }
       else
       {
           std::cout<< 1;
       }
   }
   else
   {
       if( b == 1 )
       {
           std::cout<< 2;
       }
       else
       {
           std::cout<< 1;
       }
   }
   
}


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

int N, K;

vector<int> v[100005];
ll MOD = 1000000007;


/*
  このノードに既に色が割り当てられている場合の、子孫ノードの色の割り当て方を返す
*/
ll dfs( int node, int parent_node ){
	
	// 子ノードの色の割り当て方
	// 親ノード・このノード のどちらとも重複しない塗り方は何通りか？
	ll available_colors = K - 1 - (parent_node == -1 ? 0 : 1); // 利用可能な色
	ll comb = 1; // 組み合わせ
	for ( size_t i = 0; i < v[node].size(); i++ ){
		int next_node = v[node][i];
		if ( next_node == parent_node )
			continue;
		
		comb = (comb * available_colors--) % MOD;
	}
	
	// 孫ノードの色の割り当て方
	for ( size_t i = 0; i < v[node].size(); i++ ){
		int next_node = v[node][i];
		if ( next_node == parent_node )
			continue;
		
		comb = (comb * dfs( next_node, node )) % MOD;
	}
	//cout << node << " " << comb << endl;
	return comb;
}



int main(){
	cin >> N >> K;
	
	for ( int i = 0; i < N-1; i++ ){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	ll result = (K * dfs( 0, -1 ))%MOD;
	cout << result << endl;
	
	
	return 0;
}



Measured memory_bytes: 11520
k=int(input())
if k==1:
  print('ACL')
elif k==2:
  print('ACLACL')
elif k==3:
  print('ACLACLACL')
elif k==4:
  print('ACLACLACLACL')
elif k==5:
  print('ACLACLACLACLACL')

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

int main(){
    int n=0,f=0,ha=0;
    cin >> n;
    f = n;
    while(n!=0){
        ha += n%10;
        n /= 10;
    }
    if(f%ha==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
q=int(input())

cnt=0
left=""
right=""

for i in range(q):
  qq=[x for x in input().rstrip().split()]

  if qq[0]=="2":
    t=int(qq[0])
    f=int(qq[1])
    c=qq[2]
    
    if cnt%2==1 and f==1:
      right=right+c
    
    elif cnt%2==1 and f==2:

      left=c+left
    elif cnt%2==0 and f==2:
  
      right=right+c
    elif cnt%2==0 and f==1:

      left=c+left

  else:
    cnt+=1

s=left+s+right
if cnt%2==1:
  print(s[::-1])
else:
  print(s)

Measured memory_bytes: 10272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    ll now = 0;
    rep(i,n){
        if(now>a[i]){
            ans += now-a[i];
        }else{
            now=a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4788
import scala.io.StdIn

object Main extends App {
  
  def loop(x: Int, y: Int): Unit = {
    if(x != 0 || y != 0){
      if(x <= y) println(x + " " + y)
      else println(y + " " + x)

      val Array(nextx, nexty) = StdIn.readLine().trim.split(' ').map(_.toInt)
      loop(nextx, nexty)
    } 
  }

  val Array(fx, fy) = StdIn.readLine().trim.split(' ').map(_.toInt)

  loop(fx, fy)

}


Measured memory_bytes: 47552
#include <iostream>
#include <string>

int main(){

	int A,B;
	int ans = -1;

	std::cin >> A >> B;

	for(int i = 1; i < 1001; i++){
		int c_8 = i*0.08;
		int c_10 = i*0.1;
		if(c_8 == A && c_10 == B){
			ans = i;
			break;
		}
	}

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


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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())
#define INF 1000000000

lld N, M, X;
lld C[13];
lld A[13][13];
lld ans;

void solved(lld n, lld m, vector<lld> s) {
    if(n == N) {
        for(int i = 0; i < s.size(); i++) {
            if(s[i] < X) {
                return;
            }
        }
        ans = min(ans, m);
        return;
    }
    solved(n + 1, m, s);
    for(int i = 0; i < s.size(); i++) {
        s[i] += A[n][i];
    }
    solved(n + 1, m + C[n], s);
}

int main() {
    cin >> N >> M >> X;
    for(int i = 0; i < N; i++) {
        cin >> C[i];
        for(int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    ans = INF;
    solved(0, 0, vector<lld>(M, 0));
    if(ans == INF) {
        cout << "-1" << endl;
    } else {
        cout << ans << endl;
    }
}

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

#define l first
#define r second
using namespace std;
const int maxn = 1e6 + 5;

struct Node {
    int l, r, id;

    bool operator < (const Node &rhs) const {
        return r < rhs.r;
    }
} q[maxn];

int n, a[maxn], c[maxn], last[maxn];

int lowbit(int x) {return x & (-x);}

void update(int i, int k) {
    while (i <= n) {
        c[i] += k;
        i += lowbit(i);
    }
}

int getSum(int i) {
    int res = 0;
    while (i > 0) {
        res += c[i];
        i -= lowbit(i);
    }
    return res;
}

int query(int l, int r) {
    return getSum(r) - getSum(l - 1);
}

int res[maxn];

int main() {
    int m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= m; i++) scanf("%d%d", &q[i].l, &q[i].r), q[i].id = i;
    sort(q + 1, q + 1 + m);
    int ne = 1;
    for (int i = 1; i <= m; i++) {
        for (int j = ne; j <= q[i].r; j++) {
            if (last[a[j]]) update(last[a[j]], -1);
            last[a[j]] = j;
            update(j, 1);
        }
        res[q[i].id] = query(q[i].l, q[i].r);
        ne = q[i].r + 1;
    }
    for (int i = 1; i <= m; i++) printf("%d\n", res[i]);
    return 0;
}



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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  int N, K;
  ll ans=0;
  cin >> N >> K;
  rep(i, N){
    ll tmp; cin>>tmp;
    ans += (tmp>=K)?1:0;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
	public class Main{
      public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = compare(a+b,a-b);
        System.out.println(compare(c,a*b));
      }
      static int compare(int a,int b){
        if(a>=b)return a;
        else return b;
      }
    }


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

int main() {
  int n,k;
  cin >> n>> k;
  string a;
  cin >> a;

 
    
  for(int i=0;i<n;i++){
  if(i==k-1){
    int ans =a.at(i)+32;
    cout<< char(ans);
  }
    else cout << a.at(i);
  }

  
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

vector<pair<int,ll>> g[100000 + 10];
ll d[100000 + 10];

void dfs(int v, ll cost, int prev) {
  d[v] = cost;
  for (auto& u : g[v]) if (u.first != prev) {
    dfs(u.first, cost + u.second, v);
  }
}

int main2() {
  int N = nextInt();
  REP(i, N) g[i].clear();
  REP(_, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    int c = nextInt();
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  int Q = nextInt();
  int K = nextInt() - 1;

  dfs(K, 0, -1);

  REP(qqq, Q) {
    int x = nextInt() - 1;
    int y = nextInt() - 1;
    cout << d[x] + d[y] << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 14336
#include<cassert>
#include<cmath>
#include<map>
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
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)
#define eprintf(s...)  fprintf(stderr, s)

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; }

const int MAX = 10000000;
int min_factor[MAX+1];
vector<int>prime;
void make_prime() {
    for (int i=2; i<=MAX; i+=2) min_factor[i] = 2;
    for (int i=3; i<=MAX; i+=3) if (!min_factor[i]) min_factor[i] = 3;
    for (int i=5, d=2; i*i<=MAX; ) {
	if (!min_factor[i]) {
	    min_factor[i] = i;
	    for (int j=i*i; j<=MAX; j+=i)
		if (!min_factor[j]) min_factor[j] = i;
	}
	i += d; d = 6 - d;
    }
    for (int i=2; i<=MAX; i++) {
	if (min_factor[i]==0) min_factor[i] = i;
	if (min_factor[i]==i) prime.push_back(i);
    }
}

LL is_sq(LL x) {
    LL y = sqrt(x);

    if (y) y--;
    while (y*y < x) y++;
    if (y*y == x) return y;
    else return 0;
}

int N;
LL S[100111];
LL T[100111], U[100111];
map<LL, LL> mp, inv;

LL safe_mul(LL x, LL y) {
    if (x < 0 || y < 0) return -1;
    if ((double)x * (double)y > 1e15) return -1;
    return x * y;
}


int main() {
    make_prime();


    scanf("%d", &N);
    REP (i, N) scanf("%lld", S+i);

    REP (i, N) {
	T[i] = 1;
	U[i] = 1;
	for (int p=0; ; p++) {
	    LL t = (LL)prime[p] * prime[p] * prime[p];
	    if (t > S[i]) break;
	    int c = 0;
	    while (S[i] % prime[p] == 0) {
		S[i] /= prime[p];
		c++;
	    }

	    c %= 3;
	    REP (j, c) T[i] *= prime[p];
	    REP (j, (3-c)%3) U[i] = safe_mul(U[i], prime[p]);
	}

	if (LL p = is_sq(S[i])) {
	    U[i] = safe_mul(U[i], p);
	} else {
	    U[i] = safe_mul(safe_mul(U[i], S[i]), S[i]);
	}
	T[i] *= S[i];
	if (U[i] != -1) inv[T[i]] = U[i];
	mp[T[i]]++; 
//	eprintf("%lld %lld %lld\n", S[i], T[i], U[i]);
    }

    int ans = 0;
    EACH (e, mp) {
	if (e->first == 1) {
	    ans++;
	} else if (inv.count(e->first)) {
	    LL x = inv[e->first];
	    if (mp.count(x)) {
		if (e->first < x) {
		    int y = mp[x];
		    assert(y);
		    ans += max(e->second, (LL)y);
		}
	    } else {
		ans += e->second;
	    }
	} else {
	    ans += e->second;
	}
    }

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

    return 0;
}



Measured memory_bytes: 54636
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int n, a, b, s=0;
    scanf("%d%d%d", &n, &a, &b);
    for (int i=1; i<=n; i++)
    {
        int c=0;
        int m = i;
        for (int j=0; j<5; j++)
        {
            c+= m%10;
            m = m/10;
        }
        if (a<=c && c<=b)
            s += i;
    }
    printf("%d\n", s);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}

/*ライブラリゾーン！！！！！！！！！！！！！！！*/
map<string, int> mp;
signed main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	mp[s] = 1;
	for (int i = 1; i < n; i++) {
		string w;
		cin >> w;
		if (mp[w] != 0 || s[s.size() - 1] != w[0]) {
			cout << "No" << endl;
			goto loop;
		}
		mp[w] = 1;
		s = w;
	}
	cout << "Yes" << endl;
loop:;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504
H,W = map(int,input().split())
C = []
for i in range(10):
  c = list(map(int,input().split()))
  C.append(c)

A = []
for i in range(H):
  a =  list(map(int,input().split()))
  A.append(a)

#最短距離 (V:頂点数,E:辺数)
#BFS : コスト1 O(E)
#Dijkstra : コスト任意 O(ElogE)
#Floyd Warshall O(V^3) →　今回 V=10 → OK

#「「「Floyd Warshall」」」
#→全点間の重み付きグラフ　経路最小化
#点j→点kに行くまでの最小コスト経路(j→k or j→i→k)
#===========================================================
#iを動かして
#「j→i」のコスト　と　「j→i→kのコスト」　の小さいほうを d[j][k]に採用
#ということを繰り返す
#→直感的には、これでは「2点間コスト」or「3点間コスト」の小さいほうを選んでいるだけっぽいで、
#4点間コスト,5点間コスト,...が最小の場合を考慮していないのでは...
#→実は大丈夫
#===========================================================
#・上の例で,右の経由コストがd[j][k]のコストに採用された場合は(i=i0として)
#「j→i0→k」のコスト と　「j→i0→i1→kのコスト」　の小さいほうを d[j][k]に採用
#これをiを動かして繰り返してコストの最小値を求めるのでn点間最小値も網羅している！！

dist = C[:]
for i in range(10):
  for j in range(10):
    for k in range(10):
      dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k])

ans = 0
for i in range(H):
  for j in range(W):
   if(A[i][j] >= 0): #0以上
     ans += dist[A[i][j]][1]
print(ans)


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

int main() {
  int n,k;
  cin >> n >> k;
  if(n<=10)
  cout << k+100*(10-n) << endl;
  else cout << k << endl;
}


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

int main() {
	char a[8];
	int b, pass, cnt;
	while (scanf("%s", a) != EOF) {
		scanf("%d", &b);
		cnt = 1;
		pass = atoi(a) + b;
		while (pass > 9) {
			pass /= 10;
			cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}


Measured memory_bytes: 2032
#include <iostream>

using namespace std;

int main(){

  int A,B,C,X,Y;
  long long int sum,left,ans1,ans2;
  long long int min = 500000000;
  
  cin >> A >> B >> C >> X >> Y;

  ans1 = A*X + B*Y;
  if(X < Y){
    sum = C * X * 2;
    left = Y - X;
    for(int i = 0; i <= left; i++){
      int left_sum = i * B + (left - i) * C * 2;
      if(left_sum < min){
	min = left_sum;
      }
    }
    ans2 = sum + min;
  }
  else{
    sum = C * Y * 2;
    left = X - Y;
    for(int i = 0; i <= left; i++){
      int left_sum = i * A + (left - i) * C * 2;
      if(left_sum < min){
	min = left_sum;
      }
    }
    ans2 = sum + min;
  }

  if(ans1 < ans2){
    cout << ans1 << "\n";
  }
  else{
    cout << ans2 << "\n";
  }
  
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool tr[15];
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
int main() {
  int a=0,n,b,A,B,t,T,sa,sb,ans=0;
  string worda,wordb,answord;
  bool flag;
  cin>>n;
  cin>>worda>>wordb;
  rep(i,n){cout<<worda[i]<<wordb[i];}
  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  
  cout<<endl;
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

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

signed main()
{
  int n, k, x;
  int sum = 0;
  cin >> n >> k;

  for (int i = 0; i < n; i++){
    cin >> x;
    sum += min(x, abs(x - k)) * 2;
  }

  cout << sum << endl;

  return (0);
}




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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll a,b,c,d,ans;
    cin >> a >> b >> c >> d;
    if(b <= c) ans = 0;
    else{
        if(a<=c && b<=d) ans = b - c;
        else if(a<=c && d<=b) ans = d - c;
        else if(c<=a && b<=d) ans = b - a;
        else if(c<=a && a<=d && d<=b) ans = d - a;
        else ans = 0;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

void hora(int tc) {
	string s;
	cin>>s;
	LL tot = 0;
	int n = s.size() - 1;
	for(int i = 0;i < (1<<n);i++) {
		LL curr = s[0] - '0';
		for(int j = 0;j < n;j++) {
			if(i & (1<<j)) {
				tot += curr;
				curr = 0;
			}
			curr = curr * 10 + s[j + 1] - '0';
		}
		tot += curr;
	}
	cout<<tot<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 256