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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

bool g[101][101];

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

    ll sum = 0;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }

    if (sum % (N * (N + 1) / 2) != 0) {
        cout << "NO" << endl;
        return 0;
    }


    ll k = sum / (N * (N + 1) / 2);

    vector<ll> d(N);
    REP(i, N) {
        if (i + 1 == N) d[i] = A[0] - A[i] - k;
        else d[i] = A[i + 1] - A[i] - k; 
    }

    bool ans = true;
    REP(i, N) {
        if(d[i] == 0) continue;
        if(d[i] > 0 || (-d[i]) % N != 0) {
            ans = false;
            break;
        }
    }

    if (ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

int main(){

    int N;
    cin >> N;

    double A[N];
    double recip = 0.0;
    for(int i = 0; i < N; i++){
        cin >> A[i]; 
        recip += 1 / A[i];
    }

   double ans = 0.0;
    ans = 1 / recip; 

    cout << setprecision(10) <<  ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, m, c = map(int,input().split())
bsrc = list(map(int,input().split()))
asrc = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for a in asrc:
    tmp = c
    for i,j in zip(a,bsrc):
        tmp += i*j
    if tmp > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class myStack {
    // s[0]には常に何も入れない実装
    int size = 200;
    String[] s;
    int top;

    myStack() {
        s = new String[size];
        top = 0;
    }

    void initialize() {
        top = 0;
    }

    void push(String x) {
        if (isFull()) {
            System.err.println("stack overflow!");
            return;
        }

        s[++top] = x;
    }

    String pop() {
        if (isEmpty()) {
            System.err.println("stack is empty!");
            return null;
        }
        return s[top--];
    }

    boolean isEmpty() {
        return (top == 0);
    }

    boolean isFull() {
        return (top >= size - 1);
    }

    int eval() {
        String val = this.pop();
        if (isNumber(val)) {
            return Integer.parseInt(val);
        }

        int b = eval();
        int a = eval();

        switch (val) {
        case "+":
            return a + b;
        case "-":
            return a - b;
        case "*":
            return a * b;
        } 

        return 0; // unreachable
    }

    boolean isNumber(String x) {
        try {
            Integer.parseInt(x);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

}

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        myStack ms = new myStack();

        for (String s : input) {
            ms.push(s);
        }

        // evaluate
        while (ms.top != 1) {
            ms.push(String.valueOf(ms.eval()));
        }

        System.out.println(ms.pop());
    }
}


Measured memory_bytes: 24368
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    // ios_base :: sync_with_stdio(false);
    // cin.tie(NULL), cout.tie(NULL);
    ll n, i, ans = 0;
    cin >> n;
    vll latest(n, -1), it(n, 0);
    vector <vll> a(n);
    for(i = 0; i < n; i++)
    {
        a[i].resize(n - 1);
        for(ll j = 0; j < n - 1; j++)
            cin >> a[i][j];
    }
    for(i = 1; i <= MAX; i++)
    {
        ll nm = 0;
        for(ll j = 0; j < n; j++)
        {
            if(it[j] < n - 1)
            {
                ll v = a[j][it[j]] - 1;
                if(a[v][it[v]] == j + 1 && latest[v] < i && latest[j] < i)
                    latest[v] = latest[j] = i, it[j]++, it[v]++, nm++;
            }
        }
        if(nm == 0)
        {
            cout << "-1\n";
            return 0;
        }
        for(auto x : it)
            if(x != n - 1)
                nm = 0;
        if(nm)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 8064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.substring(2,3).equals(s.substring(3,4)) && s.substring(4,5).equals(s.substring(5,6))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  }
}


Measured memory_bytes: 21712
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
	int n;
	int x[1000], y[1000];
	double xd[3000], yd[3000], dist[3000];
	int next[3000];
	while(cin >> n, n){
		int vw, vc; cin >> vw >> vc;
		for(int i=0;i<n;i++){
			cin >> x[i] >> y[i];
			xd[i] = x[i];
			yd[i] = y[i];
			next[i] = -1;
		}
		int size = n;
		for(int i=0;i<n;i++){
			if(i+1 < n && y[i] < y[i+1]){
				for(int j=i+1;j+1<n;j++){
					if(y[j+1] == y[i]){
						next[i] = j+1;
						break;
					}
					if(min(y[j], y[j+1]) <= y[i] && y[i] <= max(y[j], y[j+1])){
						xd[size] = (y[i]-yd[j])*(xd[j+1]-xd[j])/(yd[j+1]-yd[j]) + xd[j];
						yd[size] = y[i];
						next[i] = size;
						next[size] = -1;
						size++;
						break;
					}
				}
			}
			if(i-1 >= 0 && y[i] < y[i-1]){
				for(int j=i-1;j-1>=0;j--){
					if(y[j-1] == y[i]){
						next[j-1] = i;
						break;
					}
					if(min(y[j], y[j-1]) <= y[i] && y[i] <= max(y[j], y[j-1])){
						xd[size] = (y[i]-yd[j])*(xd[j-1]-xd[j])/(yd[j-1]-yd[j]) + xd[j];
						yd[size] = y[i];
						next[size] = i;
						size++;
						break;
					}
				}
			}
		}
		vector< pair<double, int> > vp;
		for(int i=0;i<size;i++){
			dist[i] = 1e12;
			vp.push_back(make_pair(xd[i], i));
		}
		sort(vp.begin(), vp.end());
		dist[0] = 0;
		for(int i=0;i+1<vp.size();i++){
			int pos  = vp[i].second;
			int npos = vp[i+1].second;
			dist[npos] = min(dist[npos], dist[pos] + hypot(xd[pos]-xd[npos], yd[pos]-yd[npos])/vw);
			if(next[pos] != -1)
				dist[next[pos]] = min(dist[next[pos]], dist[pos] + (xd[next[pos]] - xd[pos])/vc);
		}
		printf("%.8lf\n", dist[n-1]);
	}
}

Measured memory_bytes: 0
import java .util.Scanner;

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 = sc.nextInt();
	int d = sc.nextInt();

	while(true){
	    //高橋の攻撃
	    c -= b;
	    if(c<=0) break;
	    //高橋が攻撃される
	    a -= d;
	    if(a<=0) break;
	}
	if(c<=0) System.out.print("Yes");
	else if(a<=0) System.out.print("No");
    }
}


Measured memory_bytes: 35692
#include<bits/stdc++.h>
#define i64 long long

using namespace std;

int main()
{
    i64 N;
    scanf("%lld", &N);
    i64 tmp = N;
    i64 sum = 0;
    while(tmp){
        sum = sum + (tmp%10);
        tmp /= 10;
    }

    if(N%sum == 0) puts("Yes");
    else puts("No");
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int w, h, x, y;

int main()
{
    cin >> w >> h >> x >> y;

    printf("%.6f %d\n", (double)w * h * 0.5, (x * 2 == w && y * 2 == h));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b) {
	while (b > 0) {
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int main(void) {
	int W, H, C;
	int g;
	if (scanf("%d%d%d", &W, &H, &C) != 3) return 1;
	g = gcd(W, H);
	printf("%d\n", C * (W / g) * (H / g));
	return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return b.second > a.second;
    }
    return a.first < b.first;
}

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

    int N;
    cin >> N;

    vector<int> p;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        p.push_back(a);
    }

    int ans = 10000000;

    for (int i = 0; i <= p[0]; ++i)
    {
        vector<int> tmp(N);
        for (int i = 0; i < N; ++i)
            tmp[i] = p[i];

        int cnt = 0;

        cnt += i;
        tmp[0] -= i;
        for (int i = 0; i < N - 1; ++i)
        {
            if (i == 0)
            {
                if (tmp[i] > tmp[i + 1])
                {

                    cnt += tmp[i] - tmp[i + 1];
                    tmp[i] = tmp[i + 1];
                }
            }
            if (tmp[i] > 0)
            {
                cnt += tmp[i] * 2;
                tmp[i + 1] -= tmp[i];
                tmp[i] = 0;
            }
        }

        if (tmp[N - 1] > 0)
        {
            cnt += tmp[N - 1];
        }
        ans = min(ans, cnt);
    }

    for (int i = 0; i <= p[N - 1]; ++i)
    {
        vector<int> tmp(N);
        for (int i = 0; i < N; ++i)
            tmp[i] = p[i];

        int cnt = 0;

        cnt += i;
        tmp[N - 1] -= i;
        for (int i = N - 1; i >= 1; --i)
        {
            if (i == N - 1)
            {
                if (tmp[i] > tmp[i - 1])
                {

                    cnt += tmp[i] - tmp[i - 1];
                    tmp[i] = tmp[i - 1];
                }
            }
            if (tmp[i] > 0)
            {
                cnt += tmp[i] * 2;
                tmp[i - 1] -= tmp[i];
                tmp[i] = 0;
            }
        }

        if (tmp[0] > 0)
        {
            cnt += tmp[0];
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3252
#include<stdio.h>
#define MAX 100001

int A[MAX];

int partion(int n){
    int i,j,tmp;
    int key=A[n-1];
    i=0;
    j=i-1;
    while(i<n-1){
          if(A[i]>key){i++;}
          else {
                j++;
                tmp=A[j];A[j]=A[i];A[i]=tmp;
                i++;
                }
          }
    j=j+1;
    tmp=A[j];A[j]=A[n-1];A[n-1]=tmp;
    return j;
    }



int main(){
    int i,n;
    scanf("%d",&n);
    for(i=0;i<n;i++){
                scanf("%d",&A[i]);
                }
    int key=partion(n);
    for(i=0;i<key;i++){
                printf("%d ",A[i]);
                }
    printf("[%d] ",A[key]);
    for(i=key+1;i<n;i++){
                printf("%d%c",A[i],i==n-1?'\n':' ');
                }
    return 0;
    }
              








Measured memory_bytes: 2132
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int X, result = 0;
  cin >> X;
  while (X / 500) {
    result += 1000;
    X -= 500;
  }
  while (X / 5) {
    result += 5;
    X -= 5;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int MAXN = 1000*100 + 1  ;
const int INF = INT_MAX;
int main (){
	fast_io();
	int a , b , c ,d ;
	cin >> a>> b >> c >> d ;
	int x = (a + d -1 )  / d ; 	
	int y = ( c + b - 1  ) / b ;
	if (x >= y )
		cout << "Yes" ;
	else
		cout << "No";
 	 
	return 0 ;

}
 


Measured memory_bytes: 3644
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] b = new int[n - 1];
		for(int i = 0; i < n - 1; i++) b[i] = scan.nextInt();
		int sum = b[0] + b[n - 2];
		for(int i = 0; i < n - 2; i++) {
			sum += Math.min(b[i], b[i + 1]);
		}
		System.out.println(sum);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


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

int main()
{
	string p, s;
	
	getline(cin, s);
	getline(cin, p);

	int a = 0;

	for (unsigned int i = 0; i < s.size(); i++){

		unsigned int j = 0;

		for (j = 0; j < p.size(); j++) {
			if (i + j < s.size()) {
				if ((p[j] != s[i + j]))
					break;
			}
			else if (p[j] != s[i + j - s.size()])
				break;
		}

		if (j == p.size()) {
			a = 1;
			break;
		}			
	}

	if (a == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a,b,x;
    string ans ="NO";
    cin >> a >> b >> x;
    if(a<=x){
    if(b>x-a){
        ans = "YES";
    }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: n, a, i, j, j2
  integer(8), allocatable :: xn(:)
  integer(8), parameter :: MX = 2500
  integer(8) :: dp1(-MX:MX), dp2(-MX:MX)
  read(*, *) n, a
  allocate(xn(n))
  read(*, *) (xn(i), i = 1, n)

  do i = 1, n
    xn(i) = xn(i) - a
  end do

  dp1(:) = 0
  dp1(0) = 1

  do i = 1, n
    dp2(:) = dp1(:)
    do j = -MX, MX
      j2 = j + xn(i)
      if (-MX <= j2 .and. j2 <= MX) then
        dp2(j2) = dp2(j2) + dp1(j)
      end if
    end do
    dp1(:) = dp2(:)
  end do

  write(*, "(i0)") dp2(0) - 1

  deallocate(xn)
  contains
end


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define inf 1e10
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
#define adj(N) vector<vector<int>> ADJ(N+1)
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	READV(X);
	READV(A);
	if(X<A)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<10<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)
	var cost int
	var cNum int
	if (c < a && c < b) || ((c < a || c < b) && c*2 < a+b) {
		n := Min(x, y)
		cost += c * 2 * n
		x -= n
		y -= n
		cNum += n * 2
	}
	if c*2 < a {
		cost += c * 2 * x
		x = 0
		cNum += 2 * x
	}
	if c*2 < b {
		cost += c * 2 * y
		y = 0
		cNum += 2 * y
	}
	cost += a * x
	cost += b * y

	fmt.Println(cost)
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
ll po(ll x,ll y,ll m){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%m;
		x=x*x%m;
	}
	return res;
}
ll n;
bool t[200010];

ll f[200010];

int main(){
	f[0]=0;
	for(ll i=1;i<200010;i++){
		ll pc=0;
		for(ll j=0;j<20;j++){
			if(i&(1<<j))pc++;
		}
		f[i]=f[i%pc]+1;
	}
	cin>>n;
	ll pc=0;
	rep(i,n){
		char z;
		cin>>z;
		t[i]=(z-'0');
		pc+=t[i];
	}
	ll m1,m2;
	if(pc-1>0){
		m1=0;
		rep(i,n){
			if(t[i])m1+=po(2,n-1-i,pc-1);
		}
		m1%=(pc-1);
	}
	{
		m2=0;
		rep(i,n){
			if(t[i])m2+=po(2,n-1-i,pc+1);
		}
		m2%=(pc+1);
	}
	rep(i,n){
		if(t[i]==0){
			ll rem=(m2+po(2,n-1-i,pc+1))%(pc+1);
			cout<<f[rem]+1<<"\n";
		}
		else{
			if(pc-1==0){
				cout<<0<<"\n";
			}
			else{
				ll rem=(m1-po(2,n-1-i,pc-1))%(pc-1);
				if(rem<0)rem+=pc-1;
				cout<<f[rem]+1<<"\n";
			}
		}
	}
}


Measured memory_bytes: 5352
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef __int128_t ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll solve(long long N, std::vector<long long> A) {
  ll ans = 1;
  ll max = 1;
  REP(i, 18) { max *= 10; }
  REP(i, N) {
    if (A[i] == 0) {
      return 0;
    }
  }
  REP(i, N) {
    ans *= A[i];
    if (ans > max) {
      return -1;
    }
  }
  return ans;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  cout << (long long)solve(N, std::move(A)) << endl;
  return 0;
}


Measured memory_bytes: 4076
while line = STDIN.gets
  l = line.chomp.split(',').map { |item| item.to_i }
  v2 = l.pop
  v1 = l.pop
  sum=0
  l.each do |e|
    sum+=e
  end
  dis = sum.to_f / (v1+v2).to_f
  dis *= v1.to_f
  sum=0
  i=0
  while sum < dis
    sum+=l[i]
    i+=1
  end 
  puts i
end

Measured memory_bytes: 8624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int x;
    cin >> x;
    cout << x*x*x << endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 200001;

int n, sz[N], mod = 1e9 + 7, ans;
vector <int> v[N];

int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int f(int x){
    return (powlog(2, x) - 1 - x + mod) % mod;
}
void dfs(int node, int pnode){
    sz[node] = 1;
    for(auto &i : v[node]){
        if(i == pnode) continue;
        dfs(i, node);
        sz[node] += sz[i];
    }
    int cur = f(n - 1);
    cur = (cur - f(n - sz[node]) + mod) % mod;
    for(auto &i : v[node]){
        if(i == pnode) continue;
        cur = (cur - f(sz[i]) + mod) % mod;
    }
    cur = 1LL * cur * powlog(powlog(2, n - 1), mod - 2) % mod;
    ans = (ans + cur) % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0 ; i < n - 1 ; i++){
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 0);
    ans = 1LL * ans * powlog(2, mod - 2) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 23168
N,K = map(int,input().split())
list_x = list(map(int,input().split()))
 
loop_cnt = N - K + 1
ans = 10**10
 
for i in range(loop_cnt):
  diff_between_0 = min(abs(list_x[i]), abs(list_x[i+K-1]))
  diff_between_max_min = abs(list_x[i+K-1] - list_x[i])
  _ = diff_between_0 + diff_between_max_min
  ans = min(ans,_)
 
print(ans)

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

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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    bool even = true;
    for(int i = 0; i < n; i++){
        if(a[i] % 2 != 0) {
            even = false;
            break;
        }
    }
    if(even) cout << "second" << endl;
    else cout << "first" << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MAXN 1000005
using namespace std;
ll n,a[MAXN],ch[3],ansch[2],cnt,ans;
char x;
bool bl1;
ll cnt2(ll i){
    ll ret=0;
    while(i%2==0){
        ret++;
        i/=2;
    }
    return ret;
}
int main(){
    cin>>n;
    for (int i=0; i<n; i++){
        cin>>x;
        a[i]=x-'1';
        if (a[i]==1) bl1=1;
    }
    if (bl1){
        ch[0]=ch[2]=0;
        ch[1]=1;
        ansch[0]=0;
        ansch[1]=1;
    }
    else{
        ch[0]=0;
        ch[2]=1;
        ansch[0]=0;
        ansch[1]=2;
    }
    if (ch[a[0]]==1) ans=1;
    for (int i=1; i<n; i++){
        cnt+=cnt2(n-i)-cnt2(i);
        if (cnt==0 && ch[a[i]]==1) ans=1-ans;
        // cout<<cnt<<endl;
    }
    cout<<ansch[ans]<<endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
int main() {
	int n, a, four = 0, two = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (!(a % 4))four++;
		if (!(a % 2))two++;
	}
	if (four * 2 + 1 >= n || four * 2 + (two - four) >= n)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def calc_h(cx,cy,xyh_item):
  res=abs(cx-xyh_item[0])+abs(cy-xyh_item[1])+xyh_item[2]
  return res

n=int(input())
xyh=[[int(x) for x in input().split()] for _ in range(n)]
xyh.sort(key=lambda x:x[0],reverse=True)

#平地の情報(ピラミッドの根元を除く)は役にたたないので捨てる
xyh0=[]
xyh1=[]
for item in xyh:
  if item[2]==0:
    xyh0.append(item)
  else:
    xyh1.append(item)

xyh=xyh1

for item0 in xyh0:
  if any([calc_h(item1[0],item1[1],item0)==item1[2] for item1 in xyh1]):
    xyh.append(item0)

n=len(xyh)

anslist=[]

for x in range(101):
  for y in range(101):
    c=0
    tmp=calc_h(x,y,xyh[0])
    for i in range(1,n):
      if tmp!=calc_h(x,y,xyh[i]):
        break
      else:
        c+=1
    #if c==n-1:
    #  print(x,y,tmp)
    anslist.append([c,x,y,tmp])


anslist.sort(key=lambda x:x[0])
print(*anslist[-1][1:])

Measured memory_bytes: 47600
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MAXN 1000000
#define MODD 1000000007
#define ll long long
using namespace std;

map<pair<ll,ll>,bool> hashed;
bool CanWin(ll X, ll Y) {

    if (hashed.find(make_pair(X,Y)) != hashed.end())
        return hashed[make_pair(X,Y)];
    bool canwin=false;
    for(ll i=1;2*i<=X;i++) {
        if (!CanWin(X-2*i,Y+i))
            canwin=true;
    }
    
    for(ll i=1;2*i<=Y;i++) {
        if (!CanWin(X+i,Y-2*i))
            canwin=true;
    }
    
    return hashed[make_pair(X,Y)]=canwin;
}

int main() {

    ll X,Y;
    cin>>X>>Y;
    if (X<Y)
        swap(X,Y);
    
    if (X-Y <= 1)
        cout << "Brown" << endl;
    else
        cout << "Alice" << endl;
    return 0;
    for(ll X=0;X<=20;X++)
        for(ll Y=X;Y<=20;Y++)
        {
            if (!CanWin(X,Y))
                printf("%lld %lld %d\n",X,Y,CanWin(X,Y));
        }
    
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

vector<bool> sieve(1000, true);
vector<ll> ans(1000, 1);
vector<ll> prime;

void update_ans(int x) {
    int j = 0;
    while(j < prime.size() and x != 1) {
        if(x%prime[j] == 0) {
            while(x%prime[j] == 0) {
                x = x/prime[j];
                ans[prime[j]]++;
            }
        }

        j++;
    }
}

int main() {

    //freopen("fighting_the_zombies.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);

    ll n; cin>>n;

    sieve[0] = sieve[1] = false;
    for(int i = 2;i < 1000;i++) {
        if(sieve[i]) {
            prime.pb(i);
            int j = 2*i;
            while(j < 1000) {
                sieve[j] = false;
                j += i;
            }
        }
    }

    for(int i = 2;i <= n;i++) {
        update_ans(i);
    }

    ll answer = 1;
    rep(i, 1000) answer = (answer*ans[i])%mod;

    cout<<answer<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string S;
   	cin >> S;
  
  	int n=S.size();
    bool flag =false;
  	int i=0;
  	while (i<n){
      if(S.at(i)!='U'&&S.at(i)!='D'){
      	switch(i%2){
          case 0:
              if(S.at(i)!='R')
              {
                flag=true;
              }
            break;
          default:
            if(S.at(i)!='L')
            {
              flag=true;
            }
            break;
        }
      }
      if (flag==true){
        break;
      }
      i++;
    }
    
      
    if (flag==true){
    	cout <<"No"<<endl;
    }else{
    	cout <<"Yes"<<endl;}
}

Measured memory_bytes: 256
#!/usr/bin/ruby

@paper = Array.new(10)
@paper.map!{|c| c = Array.new(10, 0) }

@patt = [[[-1,0],[0,-1],[0,0],[0,1],[1,0]], \
        [[-1,-1],[-1,1],[1,1],[1,-1]], \
        [[0,-2],[-2,0],[2,0],[0,2]]]

def drop(x, y, num)
  @patt[num].each do |xa, ya|
    next unless [x+xa, y+ya].all?{|x| (0...10) === x}
    @paper[x+xa][y+ya] += 1
  end
end

until gets.nil?
  x, y, size = $_.split(?,).map(&:to_i)
  drop(x, y, 0)
  drop(x, y, 1) if size > 1
  drop(x, y, 2) if size > 2
end

puts @paper.flatten.count(0), @paper.flatten.max

Measured memory_bytes: 6108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = { 0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1 };
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (a[x] == a[y])
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  map<int,int> m;
  rep(i,n){int k;
           cin>>k;
           if(m.count(k)){m[k]++;}
           else m[k]=1;}
  int l=0;
  for(auto x:m){
    if(x.second<x.first){l+=x.second;}
    else{l+=x.second-x.first;}}
  cout<<l<<endl;
}

Measured memory_bytes: 4736
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

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

		String s = br.readLine();
		String[] array = s.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
		int c = Integer.parseInt(array[2]);
		int d = Integer.parseInt(array[3]);

		if ((a * b) >= (c * d)) {
			System.out.println(a * b);
		} else {
			System.out.print(c * d);
		}
	}
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define lop(i,a,b) for(register int i = (a); i <= (b); ++i)
#define dlop(i,a,b) for(register int i = (a); i >= (b); --i)
#define bl(i) for(int i = head[u]; i; i = G[i].next)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)>(b)?(b):(a))
#define rint register int
#define abs(a) ((a)>0?(a):(-(a)))
#define eps (1e-7)
#define MP make_pair
typedef pair<int, int> pii;
inline int read() {
  register int c = getchar(), x = 0, f = 1;
  while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * f;
}
const int N = 200005;
int n;
priority_queue <pii> q;
int dead, cost, cnt;
struct build {
  int t1, t2;
  inline bool operator < (const build &rhs) const {
    return t2 == rhs.t2 ? t1 < rhs.t1 : t2 < rhs.t2;
  }
} b[N];
int main(void) {
  n = read();
  lop(i, 1, n) b[i].t1 = read(), b[i].t2 = read();
  sort(b + 1, b + 1 + n);
  lop(i, 1, n) {
    cost += b[i].t1, dead = b[i].t2;
    if (cost <= dead) q.push(MP(b[i].t1, b[i].t2));
    else {
      if (q.empty()) continue;
      pii x = q.top();
      if (cost - x.first <= dead && x.first > b[i].t1) {
        q.pop();
        q.push(MP(b[i].t1, b[i].t2));
        cost -= x.first;
      }
      else cost -= b[i].t1;
    }
  }
  puts((q.size() == (unsigned int)n) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int gcd(int a, int b) {
    if (a == 0)return b;
    return gcd(b % a, a);
}
int main() {
    init();

    int x, y; cin >> x >> y;
    cout << gcd(x, y) << "\n";
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    vector<string> ans;
    int l = s.size() - t.size() + 1;
    for (int i = 0; i < max(0, l); i++)
    {
        string tmp = s;
        for (int j = 0; j < t.length(); j++)
        {
            if (i + j > s.size() - 1)
                break;
            if (tmp[i + j] == '?' || tmp[i + j] == t[j])
                tmp[i + j] = t[j];
            else
                break;
            if (j == t.length() - 1)
            {
                for (int k = 0; k < tmp.length(); k++)
                {
                    if (tmp[k] == '?')
                        tmp[k] = 'a';
                }
                ans.push_back(tmp);
            }
        }
    }
    sort(ans.begin(), ans.end());
    cout << (ans.size() > 0 ? ans[0] : "UNRESTORABLE") << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	cin >> n;
	vector<P>a(n);
	rep(i, n) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	sort(a.begin(), a.end());
	rep(i, n) {
		if (i == n - 1) {
			cout << a[i].second;
			return 0;
		}
		cout << a[i].second << " ";
	}
}

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

int main() {
  int N, rec = 0;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
  	cin >> d[i];
  }
  for(int i = 0; i < N; i++){
  	for(int j = i+1; j < N; j++){
    	rec += d[i] * d[j];
    }
  }
  cout << rec << endl;
  return 0;
}


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

int shrink(char s);
int alp[26];
int ans = 1000;
string S;

int main() {
    cin >> S;
    for (int i = 0; i < 26; i++) {
        alp[i] = 0;
    }
    for (int i = 0; i < S.size(); i++) {
        alp[S[i] - 'a'] = 1;
    }

    int a = 'a';
    char b;
    for (int i = 0; i < 26; i++) {
        if (!alp[i]) continue;
        b = (char)(a + i);
        ans = min(ans, shrink(b));
    }
    cout << ans << '\n';

}

int shrink(char s) {
    string S_temp = S;
    int len = S.size();
    bool flag = true;
    int f = 0, cnt = 0;

    for (int f = 0; f < len; f++) {
        flag = false;
        for (int i = 0; i < len - f; i++) {
            if (S_temp[i] != s) flag = true;
        }
        if (!flag) break;
        for (int i = 0; i < len - 1; i++) {
            if (S_temp[i+1] == s or S_temp[i] == s) {
                S_temp[i] = s;
            }
        }
        cnt++;
        //cout << S_temp << '\n';
    }

    return cnt;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n,x,y;
  string s,t;
  cin>>h>>w>>n>>y>>x>>s>>t;
  bool isin=true;
  int lvr=x,rvl=x,uvd=y,dvu=y;
  for(int i=0;i<n;++i){
    if(s[i]=='L')lvr--;
    if(lvr<1){
      isin=false;
      break;
    }
    if(t[i]=='R'&&lvr<w)lvr++;
  }
  if(isin)for(int i=0;i<n;++i){
    if(s[i]=='R')rvl++;
    if(w<rvl){
      isin=false;
      break;
    }
    if(t[i]=='L'&&1<rvl)rvl--;
  }
  if(isin)for(int i=0;i<n;++i){
    if(s[i]=='U')uvd--;
    if(uvd<1){
      isin=false;
      break;
    }
    if(t[i]=='D'&&uvd<h)uvd++;
  }
  if(isin)for(int i=0;i<n;++i){
    if(s[i]=='D')dvu++;
    if(h<dvu){
      isin=false;
      break;
    }
    if(t[i]=='U'&&1<dvu)dvu--;
  }
  cout<<(isin?"YES":"NO");
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
int Gojou(long long int A,long long int B){
  long long int result=A*A*A*A*A;
  result-=B*B*B*B*B;
  return result;
}
int main() {
  int X;
  cin >> X;
  long long int A,B;
  int flag=0;
  long long int a=0,b=0;
  for(long long int i=0;i<=1000000;i++){
    for(long long int j=0;j<i;j++){
      if(Gojou(i,j)==X){
        flag=1;
        a=i;
        b=j;
        break;
      }
      if(Gojou(i,j)>X){
        break;
      }
    }
    if(flag==1){
      break;
    }
  }
  if(a==0){
    for(long long int i=0;i<=1000000;i++){
      for(long long int j=0;j>-1000000;j--){
        if(Gojou(i,j)==X){
          flag=1;
          a=i;
          b=j;
          break;
        }
        if(Gojou(i,j)>X){
          break;
        }
      }
      if(flag==1){
        break;
      }
    }
  }
  if(b==0){
    for(long long int i=0;i>=-1000000;i--){
      for(long long int j=i-1;j>=-1000000;j--){
        if(Gojou(i,j)==X){
          flag=1;
          a=i;
          b=j;
          break;
        }
        if(Gojou(i,j)>X){
          break;
        }
      }
      if(flag==1){
        break;
      }
    }
  }
  //long long int aaa=12;
  //long long int bbb=11;
  //cout << Gojou(aaa,bbb);
  cout << a << " " << b;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

class C{
  public:
    int h, p, q;
    C(){}
    C(int _h, int _p, int _q){ h = _h; p = _p; q = _q; }
    bool operator < (const C &c) const { return h < c.h; }
};

int main() {
  int N, M, A;
  while(cin >>N >>M >>A && N){
    vector<int> v(N);
    REP(i, N) v[i] = i + 1;
    vector<C> w(M);
    REP(i, M) cin >>w[i].h >>w[i].p >>w[i].q;
    SORT(w);
    REP(i, M) swap(v[w[i].p - 1], v[w[i].q - 1]);
    cout <<v[A - 1] <<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
 
int main(){
  int a, b, i;
  int sum, counter;
  while(scanf("%d %d", &a, &b) != -1){
    sum = a + b;
    for(i = 0; sum !=0; i++)
      sum = sum / 10;
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	bool judge=true;
	int t1=0,x1=0,y1=0,t2,x2,y2;
	for (int i=0;i<n;i++)
	{
		cin>>t2>>x2>>y2;
		int x=x2-x1;
		int y=y2-y1;
		if (x<0)
			x*=-1;
		if (y<0)
			y*=-1;
		int s=x+y;
		int t=t2-t1;
		if (t<s)
			judge=false;
		if ((t-s)%2!=0)
			judge=false;
		t1=t2,x1=x2,y1=y2;
	}
	if (judge)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

int main(){
 int x, a;
  cin >> x >> a;
  if(x >= a)
    cout << 10 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 998244353ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	doin();
	string s;
	stack<char> a;
	cin >> s;
	int ans = 0;
	for(auto i : s) {
		if(!a.empty() && a.top() != i)
			a.pop(), ans += 2;
		else
			a.push(i);
	}
	cout << ans;

	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	switch (ch) {
		case 'A': return 1;
		case 'C': return 2;
		case 'G': return 3;
		case 'T': return 4;
		default:  return 0;
	}
}

long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(long long key) { return key % M; }
int h2(long long key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h, l;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 0;
		else if (strlen(H[h]) == 0) {
			for (l = 0; l <= strlen(str); l++) {
				H[h][l] = str[l];
			}
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n;
	char str[L], com[9];
	for (i = 0; i < M; i++) H[i][0] = '\0';
	//scanf("%d", &n);

	cin >> n;

	for (i = 0; i < n; i++) {
		//scanf("%s %s" ,com, str);
		cin >> com >> str;

		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 17392