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

int f(int r){
    if(r == 0) return 0;
    int cnt = 0;
    int cp = r;
    while(cp){
        if(cp & 1) cnt++;
        cp /= 2;
    }
    return f(r % cnt) + 1;
}

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> x(n);
    int pc = 0;
    for(int i = 0; i < n; i++){
        x[i] = s[i] - '0';
        if(x[i] == 1) pc++;
    }
    vector<int> ans(n);
    for(int b = 0; b < 2; b++){
        int npc = pc;
        if(b == 0) npc++; else npc--;
        if(npc <= 0) continue;
        int r0 = 0;
        for(int i = 0; i < n; i++){
            r0 = r0 * 2 % npc;
            r0 = (r0 + x[i]) % npc;
        }
        int k = 1;
        for(int i = n-1; i >= 0; i--){
            if(x[i] == b){
                if(b == 0) ans[i] = f((r0 + k) % npc) + 1;
                else ans[i] = f((r0 - k + npc) % npc) + 1;
            }
            k = k * 2 % npc;
        }
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}   

Measured memory_bytes: 5164
#include<iostream>
#include<string>
#include<vector>
 
using namespace std;
 
int main(){
	int N;
	string S;
	cin>>N>>S;
	vector<long long> rgb(3,0);
	for(int i=0;i<N;i++){
		if(S[i]=='R') rgb[0]++;
		if(S[i]=='G') rgb[1]++;
		if(S[i]=='B') rgb[2]++;
	}
	long long ans=rgb[0]*rgb[1]*rgb[2];
	
	for(int j=0;j<N;j++){
		for(int i=0;i<j;i++){
			long long k=2*j-i;
			if(k>=N) continue;
			if(S[i]==S[j]||S[j]==S[k]||S[k]==S[i]) continue;
			ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3612
console.log(require('fs').readFileSync('/dev/stdin','utf8').trim().split(/[ |\n]/).slice(1).map((k,i,a)=>`node ${++i}: key = ${k}, `+((i-1)?`parent key = ${a[(i>>1)-1]}, `:'')+(2*i<=a.length?`left key = ${a[2*i-1]}, `:'')+(2*i<a.length?`right key = ${a[2*i]}, `:'')).join('\n'));


Measured memory_bytes: 16520
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (n); i++)

using namespace std;

int main()
{
    int k, a, b; 
    cin >> k;
    cin >> a;
    cin >> b;
  	int v1 = (a - 1) / k;
  	int v2 = b / k;
  	if(v1 == v2) cout << "NG";
    else cout << "OK";
    cout << endl;
  	
    return 0;
}

Measured memory_bytes: 3596
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a;
    cin >> a;
    if( a == 3 || a == 5 || a == 7){
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    
    
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
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 <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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a * 100 + b * 10 + c) % 4 == 0) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 256
import sys
import copy
l = [int(c) for c in input().split()]
A=l[0]
B=l[1]
M=l[2]
a=[int(c) for c in input().split()]
b=[int(c) for c in input().split()]
H = [list(map(int,input().split())) for c in range(M)]

a_sorted = sorted(a)
b_sorted = sorted(b)

MinPrice = a_sorted[0]+b_sorted[0]

for i in range(M):
    if MinPrice > a[H[i][0]-1]+b[H[i][1]-1]-H[i][2]:
        MinPrice = a[H[i][0]-1]+b[H[i][1]-1]-H[i][2]

print(MinPrice)


Measured memory_bytes: 40640
N = int(input())
seq = list(map(int, input().split()))
print(" ".join(map(str, seq)))
for i in range(1, N):
    key = seq[i]
    j = i-1
    while j >= 0 and seq[j] > key:
        seq[j+1] = seq[j]
        j -= 1
    seq[j+1] = key
    print(" ".join(map(str, seq)))

Measured memory_bytes: 7652
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
n = int(raw_input())
a = map(int, raw_input().split())
ans = min(map(how_many_times_divisible, a))
 
print ans

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

#define SLAY ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LL long long
#define PII pair<int , int>
#define PLL pair<long long , long long>
#define INPUT freopen("/Users/amrfahmy/Documents/Problem solving/CF/CF/input.txt", "r", stdin);
using namespace std;
 
const LL MOD = 1000000007;
LL a[1000000];
LL b[1000000];
LL n,q,c,cnt,mx,m,temp,k;
string str;
vector< int > dp;

bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
    return (a.first < b.first);
}


int main()
{
    bool readfromfile=false; if(!readfromfile){SLAY} else{INPUT}
    
 

//    cin>>n;
//    cin>>n>>m;
//    for(int i = 0 ; i < n ; i++)cin>>a[i];
//    for(int i = 0 ; i < n ; i++)cin>>b[i];

    string str1 , str2;
    cin>>str1>>str2;
    cout<<str2<<str1;
    
    return 0;
}



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

int main(){
  int h,n,ans=0;
  cin >> h>>n;
  vector<int>dp(h+1000,1000000000);
  dp.at(0)=0;
  for(int i=0;i<n;i++){
    int s,d;
    cin >> s >>d;
    for(int j=0;j<h+1;j++){
      int f=min(j+s,h);
      dp.at(f)=min(dp.at(f),dp.at(j)+d);
    }
  }
  cout <<dp.at(h)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int n,k;
    cin >> n >> k;
    int a[n] = {0};
    int d;
    for(int i=0;i<k;++i){
        cin >> d;
        for(int j=0;j<d;++j){
            int temp;
            cin >> temp;
            a[temp-1] = 1;
        }
    }
    int c=0;
    for(int i=0;i<n;++i){
        if(a[i] == 0){
            c++;
        }
    }
    cout << c << endl;
}

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

int main(){
  long long mnum = 1000000007;
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  long long btotal = 0;
  long long ans = 0;
  for (int i = n-1; i > 0; i--) {
    btotal += a[i];
    btotal %= mnum;
    ans += btotal * a[i-1] % mnum;
    ans %= mnum;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4832
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}



ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s, t;
ll mo = 998244353;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, t;
	cin >> a >> b >> t;
	REP(i,0,  t) {
		if (a * (i+1) <= t+0.5) ans += b;
	}
	cout << ans << endl;
	/*cin >> n;
	vll v(n), c(n);
	rep(i, n) cin >> v[i];
	rep(i, n) cin >> c[i];
	rep(i, n) {
		if (v[i] - c[i] > 0) ans += v[i] - c[i];
	}
	cout << ans << endl;*/
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, raw_input().split())
c = [0]*(N+1)
for i in range(1,M+1):
  a, b = map(int, raw_input().split())
  if a in [1, N]:
    c[b] += 1
  if b in [1, N]:
    c[a] += 1
r = 'IMPOSSIBLE'
for j in range(1,N+1):
  if c[j]==2:
    r = 'POSSIBLE'
print r

Measured memory_bytes: 10500
flowers_num = int(input())
target_heights = list(map(int, input().split()))

max_height = max(target_heights)

watering_sum = 0
for row_i in range(1, max_height + 1):
    should_water = False

    for target_height in target_heights:
        if row_i <= target_height:
            should_water = True
        elif should_water:
                watering_sum += 1
                should_water = False

    if should_water:
        watering_sum += 1
        should_water = False

print(watering_sum)


Measured memory_bytes: 3060
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();
        System.out.printf("%d %d %.5f",a/b,a%b,(double)a/(double)b);
    }
}


Measured memory_bytes: 26472
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, K;
  string S;
  cin >> N >> K >> S;
  vector<int> zeroOne;
  int begin = 0;
  for(int i=0; i<N; i++) {
    if(S[i] != S[begin]) {
      zeroOne.push_back(i-begin);
      begin = i;
    }
  }
  zeroOne.push_back(N-begin);

  vector<int> sumZeroOne(zeroOne.size()+1);
  sumZeroOne[0] = 0;
  for(int i=0; i<zeroOne.size(); i++)
    sumZeroOne[i+1] = sumZeroOne[i] + zeroOne[i];

  int ans = 0;
  if(S[0] == '0')
    ans = sumZeroOne[min((int)sumZeroOne.size()-1, 2*K)] - sumZeroOne[0];
  int ib = S[0] == '0' ? 1 : 0;
  for(int i=ib; i<sumZeroOne.size(); i+=2) {
    int tmp = sumZeroOne[min((int)sumZeroOne.size()-1, i+2*K+1)] - sumZeroOne[max(i,0)];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define chmax(x,y) x=max(x,y)
const ll INF = 1e18;
ll dp[200001][4]; // [N+1][skip+1]

int main() {
  int N; cin>>N;
  vector<int> A(N);
  rep(i, N) cin>>A[i];

  rep(i, N+1) rep(j, 4) dp[i][j] =-INF;
  dp[0][0] = 0;

  rep(i, N){
		rep(k, 3){
			chmax(dp[i+1][k], dp[i][k] + ((i+k)%2? 0:A[i]));
			chmax(dp[i+1][k+1], dp[i][k]);
		}
  }

  cout << dp[N][N%2+1] << endl;

}


Measured memory_bytes: 10356
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let m: usize = parse!(it);
    let mut s = 0;
    let mut l = 0;
    for _ in 0..m {
        let (d, c): (usize, usize) = parse!(it, 2);
        s += c * d;
        l += c;
    }

    println!("{}", l - 1 + (s - 1) / 9);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

vector<vi> g(maxn);

int cant[maxn*10];

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

    int n;
    cin >> n;
    int sum = 0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin >> a;
        cant[a]++;
        sum+=a;
    }
    int q;
    cin >> q;

    while(q--)
    {
        int x,y;
        cin >> x >> y;
        swap(x,y);
        sum -= cant[y]*y;
        sum += cant[y]*x;

        cant[x] += cant[y];
        cant[y] = 0;
        cout << sum << endl;
    }


	return 0;

}



Measured memory_bytes: 6304
#include <iostream>
using namespace std;
typedef long long LL;
LL getMinArea1(LL H,LL W)
{
	LL minArea=W<H?W:H;
	return minArea;

}
LL getMinArea2(LL H,LL W)
{
	LL h=H/3+1;
	LL maxAreaH = h*W;
	LL minAreaH=(H-h)*(W/2);
	
	LL areaH1 = maxAreaH-minAreaH;
	if (areaH1<0){
		areaH1=-areaH1;
	}

	h=H/3;
	minAreaH = h*W;
	if (W%2==0){
		maxAreaH=(H-h)*(W/2);
	}else{
		maxAreaH=(H-h)*(W/2+1);
	}
	
	LL areaH2 = maxAreaH-minAreaH;
	if (areaH2<0){
		areaH2=-areaH2;
	}
	LL areaH=areaH1<areaH2?areaH1:areaH2;
	
	LL w=W/3+1;
	LL maxAreaW = w*H;
	LL minAreaW=(W-w)*(H/2);
	LL areaW1 = maxAreaW-minAreaW;
	if (areaW1<0){
		areaW1=-areaW1;
	}

	w=W/3;
	minAreaW = w*H;
	if (H%2==0){
		maxAreaW=(W-w)*(H/2);
	}else{
		maxAreaW=(W-w)*(H/2+1);
	}
	LL areaW2 = maxAreaW-minAreaW;
	if (areaW2<0){
		areaW2=-areaW2;
	}
	LL areaW=areaW1<areaW2?areaW1:areaW2;

	return areaH<areaW?areaH:areaW;
}
int main(int argc, char* argv[])
{
	LL H,W;
	cin>>H>>W;
	if (H%3==0 || W%3==0){
		cout<<0<<endl;
		return 0;
	}
	LL minArea1=getMinArea1(H,W);
	LL minArea2=getMinArea2(H,W);
	LL minArea=minArea1<minArea2?minArea1:minArea2;
	cout<<minArea<<endl;

	return 0;
}

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

int main() {
  long N, X, A, pre = 0, ans = 0;
  cin >> N >> X;
  while (cin >> A) {
    int sum = pre + A;
    if (sum > X) ans += sum - X, max(A -= sum - X, 0L);
    pre = A;
  }
  cout << ans << "\n"; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int a = Integer.parseInt(s.substring(0,1));
		int b = Integer.parseInt(s.substring(1,2));
		int c = Integer.parseInt(s.substring(2,3));
		int d = Integer.parseInt(s.substring(3,4));
		String print = "";
		 if (a+b+c+d==7) print = String.format("%d+%d+%d+%d=7", a,b,c,d);
         if (a-b+c+d==7) print = String.format("%d-%d+%d+%d=7", a,b,c,d);
         if (a-b-c+d==7) print = String.format("%d-%d-%d+%d=7", a,b,c,d);
         if (a-b-c-d==7) print = String.format("%d-%d-%d-%d=7", a,b,c,d);
         if (a-b+c-d==7) print = String.format("%d-%d+%d-%d=7", a,b,c,d);
         if (a+b-c+d==7) print = String.format("%d+%d-%d+%d=7", a,b,c,d);
         if (a+b+c-d==7) print = String.format("%d+%d+%d-%d=7", a,b,c,d);
         if (a+b-c-d==7) print = String.format("%d+%d-%d-%d=7", a,b,c,d);

         System.out.println(print);	
         sc.close();
     }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  rep(i, N) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(all(B));
  set<ll> se;
  rep(i, N) if(i&1) se.insert(B[i]);
  int cnt = 0;
  rep(i, N) if(i&1 && !se.count(A[i])) cnt++;
  cout << cnt << endl;
  return 0;
}


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

namespace AIZUproject08
{
    class Data
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public int Evaluation { get; set; }
    }
    class Program
    {
        static void Main()
        {
            List<Data> datalist = new List<Data>();
            Data data;
            int N = int.Parse(Console.ReadLine());
            for (int i=0;i< N;i++)
            {
                var temp = Console.ReadLine().Split(' ');
                data = new Data();
                data.ID = i + 1;
                data.Name = temp[0];
                data.Evaluation = int.Parse(temp[1]);
                datalist.Add(data);
            }
            datalist = datalist.OrderBy(n => n.Name).ThenByDescending(n => n.Evaluation).ToList();
            foreach (var ans in datalist)
            {
                Console.WriteLine(ans.ID);
            }
        }
    }
}


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

int main()
{
	int N, K, Q;

	cin >> N >> K >> Q;

	int *point = new int[N]();
	
	int clear;

	for (int i = 0; i < Q; i++) {
		cin >> clear;

		point[clear - 1]++;
	}

	for (int i = 0; i < N; i++) {
		if (Q - point[i] < K) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	delete[] point;

	return 0;
}

Measured memory_bytes: 1024
H = 1
W = 1
while H and W:
    H, W = input().split()
    H = int(H)
    W = int(W)
    if H == 0\
    and W == 0:
        break

    for h in range(H):
        for w in range(W):
            if h == 0 or h == H - 1:
                print("#", end = "")
            elif w == 0 or w == W - 1:
                print("#", end = "")
            else:
                print(".", end = "")

            if w == W - 1:
                print()
    print()

Measured memory_bytes: 9076
#00:58
n,u = map(int,input().split())
wv = [[] for _ in range(4)]
for i in range(n):
  w,v = map(int,input().split())
  if i == 0:
    w0 = w
  wv[w-w0].append(v)
#print(wv)
z = []
for d in range(4):
  wv[d].sort(reverse=True)
  z.append(len(wv[d]))
cum = []
for d in range(4):
  tmp = [0]
  for x in wv[d]:
    tmp.append(tmp[-1]+x)
  cum.append(tmp)
#print(cum)
#print(z)
can = [0]
for i0 in range(z[0]+1):
  y0 = cum[0][i0]
  for i1 in range(z[1]+1):
    y1 = cum[1][i1]
    for i2 in range(z[2]+1):
      y2 = cum[2][i2]
      for i3 in range(z[3]+1):
        y3 = cum[3][i3]
        if i0*w0 + i1*(w0+1) + i2*(w0+2) + i3*(w0+3) <= u:
          can.append(y0+y1+y2+y3)
#print(can)
print(max(can))

Measured memory_bytes: 49248
use proconio::input;
#[allow(unused_imports)]
use proconio::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

fn main() {
    input! {
        n: usize,
        m: usize,
    }

    if n == m {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}


Measured memory_bytes: 2116
n,k=map(int,input().split())
if n>=k:
    a=k-1
else:
    a=n
b=[1/n]*n
for i in range(1,a+1):
    j=i
    while i<k:
        b[j-1]=1/2*b[j-1]
        i=i*2
print(sum(b))

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
char a;
bool n=false,e=false,w=false,s=false;
int main() {
	while(cin>>a){
	if(a=='N'){n=true;}else
		if(a=='E'){e=true;}else
		if(a=='W'){w=true;}else
			if(a=='S'){s=true;}}
    if((n==true&&e==true&&w==true&&s==true)||(n==true&&e==false&&w==false&&s==true)||(n==false&&e==true&&w==true&&s==false)){
    cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 256
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
var num = x.split(" ").map(Number);
var a = num[0];
var b = num[1];
if( a > b ) {
  console.log("a > b");
} else if( a < b ) {
  console.log("a < b");
} else {
  console.log("a == b");
}

Measured memory_bytes: 15648
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;
 
int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> A(N), B(N);
    for (int i=0; i<N;i++)
        cin>>A[i]>>B[i];
    vector<int> L(M), R(M);
    for (int i=0; i<M; i++)
        cin>>L[i]>>R[i];
 
    vector<pair<int, int>> AB(N);
    for (int i=0; i<N; i++)
        AB[i] = make_pair(A[i], B[i]);
    sort(AB.begin(), AB.end());
    for (int i=0; i<N; i++)
        A[i] = AB[i].first,
        B[i] = AB[i].second;
 
    A.push_back(1000000001);
    B.push_back(0);
    vector<int> C(N+1);
    C[0] = B[0];
    for (int i=1; i<=N; i++)
        C[i] = B[i-1]^B[i];
 
    vector<vector<int>> E(N+1);
    vector<vector<int>> EI(N+1);
    for (int i=0; i<M; i++)
    {
        int x = int(lower_bound(A.begin(), A.end(), L[i])-A.begin());
        int y = int(lower_bound(A.begin(), A.end(), R[i]+1)-A.begin());
        E[x].push_back(y);
        EI[x].push_back(i);
        E[y].push_back(x);
        EI[y].push_back(i);
    }
 
    vector<bool> V(N+1);
    vector<int> ans;
 
    function<int (int)> f = [&](int p)
    {
        if (V[p])
            return 0;
        V[p] = true;
 
        int s = C[p];
        for (int i=0; i<(int)E[p].size(); i++)
            if (f(E[p][i]) != 0)
            {
                ans.push_back(EI[p][i]);
                s ^= 1;
            }
        return s;
    };
 
    for (int r=0; r<=N; r++)
        if (!V[r])
            if (f(r)!=0)
            {
                cout<<-1<<endl;
                return 0;
            }
    
    sort(ans.begin(), ans.end());
    cout<<ans.size()<<endl;
    for (int i=0; i<(int)ans.size(); i++)
        cout<<" "<<ans[i]+1;
    cout<<endl;
}

Measured memory_bytes: 22256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int N,M;
    cin>>N>>M;
    if(N==M) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <stack>
using namespace std;
int main(){
    int count=0;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[i+1]){
            count ++;
        }
    }   
    cout << count-1 << endl;
}


Measured memory_bytes: 512
use std::collections::HashMap;
use std::collections::VecDeque;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();

    s.trim().parse().ok().unwrap()
}

fn s_to_vec_deq(s: String)->VecDeque<char>{

    let mut vd: VecDeque<char> = VecDeque::new();

    for c in s.chars(){
        vd.push_back(c);
    }

    vd
}

fn main(){

    let a: String = read();let b: String = read();let c: String = read();
    
    let mut hashMap: HashMap<char, VecDeque<char>> = HashMap::new();
    
    hashMap.insert('a', s_to_vec_deq(a));
    hashMap.insert('b', s_to_vec_deq(b));
    hashMap.insert('c', s_to_vec_deq(c));
    
    let mut current = hashMap.get_mut(&'a').unwrap().pop_front().unwrap();
    
    while(true){
        let c = match hashMap.get_mut(& current).unwrap().pop_front(){
            Some(x) =>  x,
            _ => '\0'
        };

        if c == '\0' {
            break;
        }
        current = c;
    }

    current = match current{
        'a' => 'A',
        'b' => 'B',
        'c' => 'C',
        _ => '\0'
    };

    println!("{}", current);
    
}



Measured memory_bytes: 4352
use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        s: (usize, usize),
        t: (usize, usize),
        mut board: [Chars; h],
    }
    for b in board.iter_mut() {
        b.insert(0, '@');
        b.push('@');
    }
    board.insert(0, vec!['@'; w + 2]);
    board.push(vec!['@'; w + 2]);
    let h = h + 2;
    let w = w + 2;
    let inf = 1000000 + 1;
    let mut dp = vec![vec![inf; w]; h];
    dp[s.0][s.1] = 0;
    let mut q = std::collections::VecDeque::new();
    q.push_back(s);
    while let Some((x, y)) = q.pop_front() {
        let d = dp[x][y] + 1;
        for &(dx, dy) in [(0, 1), (1, 0), (0, !0), (!0, 0)].iter() {
            let mut pos = (x, y);
            for _ in 0..k {
                pos.0 += dx;
                pos.1 += dy;
                if board[pos.0][pos.1] == '@' {
                    break;
                }
                if dp[pos.0][pos.1] == inf {
                    dp[pos.0][pos.1] = d;
                    q.push_back(pos);
                } else if dp[pos.0][pos.1] < d {
                    break;
                }
            }
        }
    }
    if dp[t.0][t.1] == inf {
        println!("-1");
    } else {
        println!("{}", dp[t.0][t.1]);
    }
}

fn main() {
    run();
}


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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    string S[6];
    for(int i=0; i<H; i++) cin >> S[i];//stringで横一列読み込み

    int ans = 0;
    for(int a=0; a<(1<<H); a++) for(int b=0; b<(1<<W); b++){//[<<]でビットをずらして一つ隣の記号を読みに行かせてるのねなるほど理解
        int cnt = 0;
        for(int i=0; i<H; i++) for(int j=0; j<W; j++) if(nth_bit(a, i) && nth_bit(b, j) && S[i][j] == '#') cnt++;
        if(cnt == K) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        long a=Integer.parseInt(st.nextToken());
        long b=Integer.parseInt(st.nextToken());
        long c=Integer.parseInt(st.nextToken());
        if(a%2==0 || b%2==0 || c%2==0){ System.out.println(0); }
        else{
            System.out.println(Math.min(a*b,Math.min(a*c, b*c)));
        }
    }
}

Measured memory_bytes: 8144
class Node:
    def __init__(self, num, left,  right):
        self.id = num
        self.left = left
        self.right = right
        self.parent = -1
        self.brother = -1
        if self.left== -1 and self.right==-1:
        	self.child = 0
        elif self.left != -1 and self.right!=-1:
        	self.child = 2
        else:
        	self.child = 1
        self.depth = 0
        self.height = 0
        self.type = None

    def show_info(self):
        print('node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(self.id, self.parent, self.brother, self.child, self.depth, self.height, self.type))

def SetNode(I_Line):
	L = list(map(int, I_Line.split()))
	num = L[0]
	left = L[1]
	right = L[2]
	node = Node(num, left, right)
	T[num] = node
	if left != -1:
		T[-1] -= left
	if right != -1:
		T[-1] -= right

def setPBD(i,p,b,d): #??????????????????
    node = T[i]
    node.parent = p
    node.brother = b
    node.depth = d
    if node.parent == -1:
        node.type = "root"
    elif node.child == 0:
        node.type = "leaf"
    else:
        node.type = "internal node"
    if node.left != -1:
        setPBD(node.left, i, node.right, node.depth + 1)
    if node.right != -1:
        setPBD(node.right, i, node.left, node.depth + 1)

def setH(i): #??????????????????
    node = T[i]
    if node.left == -1:
        leftheight = 0
    else:
        leftheight = setH(node.left) + 1
    if node.right == -1:
        rightheight = 0
    else:
        rightheight = setH(node.right) + 1
    node.height = max(leftheight, rightheight)
    return node.height

n = int(input())
T = [None] * n
T.append(int(n * (n-1)/2))
for i in range(n):
    x = input()
    SetNode(x)

root = T[-1]
setPBD(root, -1, -1, 0)
setH(root)
T.pop()

pre = []
def preoder(x): #??????????????????
	if x == -1: return
	else:
            node = T[x]
            pre.append(str(x))
            preoder(node.left)
            preoder(node.right)
print("Preorder")
preoder(root)
print(" " + " ".join(pre))

ino = []
def inoder(x):
	if x == -1: return
	else:
            node = T[x]
            inoder(node.left)
            ino.append(str(x))
            inoder(node.right)
print("Inorder")
inoder(root)
print(" " + " ".join(ino))

pos = []
def postoder(x):
	if x == -1: return
	else:
            node = T[x]
            postoder(node.left)
            postoder(node.right)
            pos.append(str(x))
print("Postorder")
postoder(root)
print(" " + " ".join(pos))

Measured memory_bytes: 7784
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    n = int(input())
    s,t = list(map(str,input().split()))
    u = ''

    for i in range(n):
        u += s[i]
        u += t[i]

    print(u)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;

int main()
{
    long long N, D, A;
    cin>>N>>D>>A;
    vector<long long> X(N), H(N);
    for (int i=0; i<N; i++)
        cin>>X[i]>>H[i];

    vector<pair<long long, long long>> XH(N);
    for (int i=0; i<N; i++)
        XH[i] = make_pair(X[i], H[i]);
    sort(XH.begin(), XH.end());
    for (int i=0; i<N; i++)
        X[i] = XH[i].first,
        H[i] = XH[i].second;

    long long ans = 0;
    long long S = 0;
    deque<pair<long long, long long>> Q;
    for (int i=0; i<N; i++)
    {
        while (!Q.empty() && Q.front().first<X[i])
        {
            S -= A*Q.front().second;
            Q.pop_front();
        }            
        long long n = (H[i]-S+A-1)/A;
        if (n>0)
        {
            ans += n;
            S += n*A;
            Q.push_back(make_pair(X[i]+2*D, n));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8064
def main():
    W, H, x, y = map(int, input().split())
    diff = 1e-5
    mid_W, mid_H = W / 2, H / 2
    if abs(x - mid_W) < diff and abs(y - mid_H) < diff:
        t = 1
    else:
        t = 0

    print(W*H/2, t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <set>
using namespace std;

typedef pair <int, int> pii;
typedef pair <int, pii> ppi;

const int MAX_N = 1e2 + 2, sq = 40000, MOD = 1e9 + 7;
int n, k, SQRT;
int dp[MAX_N][sq];
int DP[MAX_N][sq];
int cnt[sq];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

int main() {
	cin >> n >> k;
	if (n == 1) {
		cout << 1 << "\n";
		return 0;
	}

	if (n <= sq) {
		for (int i = 0; i <= n; i++)
			dp[0][i] = 1;
		for (int i = 1; i <= k; i++)
			for (int j = 1; j <= n; j++)
				dp[i][j] = _sum(dp[i][j - 1], dp[i - 1][n / j]);

		cout << dp[k][n] << "\n";
		return 0;
	}



	for (int i = 1; i < sq; i++)
		cnt[i] = (n / i) - (n / (i + 1));

	for (int i = 1; i < sq; i++) {
		if (n / i < sq)
			cnt[n / i]--;
	}

	for (int i = 0; i < sq; i++)
		dp[0][i] = 1;

	for (int i = 1; i <= k; i++) {
		for (int j = 1; j < sq; j++) {
			int d = min(n / j, sq - 1);
			dp[i][j] = _sum(dp[i][j - 1], _sum(DP[i - 1][j], dp[i - 1][d]));
		}

		for (int j = sq - 1; j; j--)
			DP[i][j] = _sum(DP[i][j + 1], _mul(cnt[j], dp[i - 1][j]));
	}

	cout << _sum(DP[k][1], dp[k][sq - 1]) << "\n";
	return 0;
}

Measured memory_bytes: 32000
#include <stdio.h>
 
int main(){
    long long int na;
    long long int hasil =0;
    scanf("%lld", &na);
    
    for (int i=1 ; i<=na ; i++){
        if (i%3 == 0 || i%5 == 0 ){
            continue;
        }
        else {
            hasil+=i;
        }
    }
    printf("%lld", hasil);

    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<string.h>
using namespace std;
#define M 1046527
#define L 14
#define NIL (-1)

char h[M][L],s[L],com[9];

int getchar(char ch){
    if(ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    return 0;
}

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

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

int Find(char str[]){
    long long key,i,o;
    key = getkey(str);
    for(i=0;;i++){

        o=(h1(key)+i*h2(key))%M;
        if(strcmp(h[o],str)==0) return 1;
        else if(strlen(h[o])==0) return 0;
    }
    return 0;
}

int minsert(char str[]){
    long long key,i,o;
    key=getkey(str);
    for(i=0;;i++){
        o=(h1(key)+i*h2(key))%M;
        if(strcmp(h[o],str)==0) return 1;
        else if(strlen(h[o])==0){
            strcpy(h[o],str);

            return 0;
        }
    }
}

int main(){
    int n;
    for(int i=0;i<M;i++) h[i][0]='\0';
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %s",com,s);
        if(com[0]=='i'){

            minsert(s);
        }
        else{
            if(Find(s)){
                printf("yes\n");
            }
            else{
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 17060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n;
  cin >> n;
  ll ans = -1;
  rep(i,50000){
    double tmp = i;
    tmp *= 1.08;
    tmp1 = (ll)tmp;
    if(tmp1 == n){
      ans = i;
      break;
    }
  }
  if(ans != -1){
    cout << ans << endl;
  }else{
    cout << ":(" << endl;
  }

}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

dic = {}
def power(x, y):
   if y == 0:
       return 1
   elif y == 1:
       return x % mod
   elif y % 2 == 0:
       return power(x, y/2) ** 2 % mod
   else:
       return power(x, (y-1)/2) ** 2 * x % mod

for i in range(N):
	if not A[i] in dic:
		dic[A[i]] = 1
	else:
		dic[A[i]] += 1

if N%2 == 0: # 偶数の時
	for i in range(N//2):
		if N-1-2*i not in dic:
			print(0)
			break
		elif dic[N-1-2*i] != 2:
			print(0)
			break
		else:
			pass
	else:
		print(power(2,(N//2)))
else: # 奇数の時
	if A.count(0) != 1:
		print(0)
	else:
		for i in range(N//2-1):
			if N-1-2*i not in dic:
				print(0)
				break
			elif dic[N-1-2*i] != 2:
				print(0)
				break
			else:
				pass
		else:
			print(power(2,(N//2)))

Measured memory_bytes: 14580
#include <stdio.h>
#include <math.h>

struct Point {
  double x,y;
};

void kohho(int n,struct Point p1,struct Point p2);

int main(){
  struct Point p1={0.0,0.0};
  struct Point p2={100.0,0.0};
  int n;
 
  scanf("%d",&n);


  printf("%.8f %.8f\n",p1.x,p1.y);
  kohho(n,p1,p2);

  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}
  
void kohho(int n,struct Point p1,struct Point p2){

  if (n==0)        /*0の場合は除く*/
    return;
  struct Point s,t,u;
  double kakudo=M_PI * 60.0/180.0;/*ラジアンへの変換*/  
  
  s.x=(2.0*p1.x+1.0*p2.x)/3.0;          /*座標の計算*/
  s.y=(2.0*p1.y+1.0*p2.y)/3.0;
  t.x=(1.0*p1.x+2.0*p2.x)/3.0;
  t.y=(1.0*p1.y+2.0*p2.y)/3.0;
  u.x=(t.x-s.x)*cos(kakudo)-(t.y-s.y)*sin(kakudo)+s.x;
  u.y=(t.x-s.x)*sin(kakudo)+(t.y-s.y)*cos(kakudo)+s.y;

  kohho(n-1,p1,s);
 
  printf("%.8f %.8f\n",s.x,s.y);
  kohho(n-1,s,u);
  
  printf("%.8f %.8f\n",u.x,u.y);
  kohho(n-1,u,t);
  
  printf("%.8f %.8f\n",t.x,t.y);
  kohho(n-1,t,p2);

}
  



Measured memory_bytes: 2072
N, K = [int(_n) for _n in input().split()]
li = [0]*N
for i in range(K):
    input()
    A = [int(_n)-1 for _n in input().split()]
    for a in A:
        li[a]+=1
res = 0
for l in li:
    if l == 0:
        res += 1
print(res)

Measured memory_bytes: 67428
using System;
using System.Linq;

public class Program
{
	public static void Main()
	{
		int[] arr = Console.ReadLine().Split().Select(i => int.Parse(i))
			.ToArray();
		int n = arr[0];
		int m = arr[1];
		int[] C = Console.ReadLine().Split().Select(i => int.Parse(i))
			.ToArray();
		int[] T = new int[999999];
		for (int i = 0; i < 999999; i++)
		{
			T[i] = int.MaxValue;
		}
		T[0] = 0;
		for (int i = 0; i < m; i++)
		{
			for (int j = 0; j + C[i] < n + 1; j++)
			{
				T[j + C[i]] = Math.Min(T[j + C[i]], T[j] + 1);
			}
		}
		Console.WriteLine(T[n]);
	}
}

Measured memory_bytes: 13540
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int q;
    while(cin >>q && q != -1){
        double bef = q / 2;
        double stp = sqrt(0.00001 * q);
        while(sqrt((bef * bef * bef) - q) > stp){
            bef = bef - ((bef * bef * bef - q) / (3 * bef * bef));
        }
        printf("%.6lf\n", bef);
    }
    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n;
  int re=0;
  cin>>n;
  int a[n+1];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0; i<n-1;i++){
    if(a[i]==a[i+1]){
      re=1;
      break;
    }
  }
  if(re==1){
    cout<<"NO";
  }else{
    cout<<"YES";
  }
  return 0;
}

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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, t, a;

	cin >> n;
	ll x = 1, y = 1;
	REPU(i, 0, n) {
		cin >> t >> a;
		ll r = (x + t - 1) / t;
		amax(r, (y + a - 1) / a);
		x = r * t;
		y = r * a;
	}
	cout << (x + y) << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    for(int i = 1; i < s.size() - 1; i++){
        if(s[i - 1] == s[i + 1]){
            cout << i << " " << i + 2 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w,n;
set<pii> S;
vi row[252521];

int main(){
  scanf("%d%d%d",&w,&h,&n);
  REP(i,n){
    int x,y;
    scanf("%d%d",&x,&y);
    --x; --y;
    S.insert(pii(x,y));
    row[y].push_back(x);
  }
  REP(i,h)row[i].push_back(w);
  REP(i,h)sort(ALL(row[i]));
  int cy = 0, cx = 0;
  int ans = w;
  int tmp = 0;
  while(true){
    tmp++;
    // move to right
    if(S.count(pii(cx+1,cy)) || cx+1==w){
      CHMIN(ans,tmp);break;
    }
    cx++;
    // update
    CHMIN(ans,*lower_bound(ALL(row[cy]),cx));
    // move to down
    if(S.count(pii(cx,cy+1))==0 && cy+1<h){
      cy++;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 21888
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){
  vi v(5);
  int ans = 0;
  for(int i=0;i<5;++i){
    cin>>v[i];
    if(v[i] == 0) ans = i+1;
  }
  cout<<ans<<endl;
  
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 3568
S=str(input())
T=str(input())
SL=len(S)
TL=len(T)
a=[]

for i in range(SL-TL+1):

    count=0

    for j in range(TL):

        if S[i+j]=='?' or T[j]=='?' or S[i+j]==T[j]:
            count += 1

    if count==TL:
        ans = S[:i].replace('?','a')+T+S[i+TL:].replace('?','a')
        a.append(ans)

if len(a)==0:
    print('UNRESTORABLE')
else:
    a.sort()
    print(a[0])










            


    


Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   bool flg = 0;
   rep(i,3){
      if(s[i] == s[i+1]) flg = 1;
   }

   if(flg) cout << "Bad" << endl;
   else cout << "Good" << endl;


   return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long n,m,i,s=0;
	cin>>n>>m;
	long long a[m];
	for(i=0;i<m;i++)
		cin>>a[i];
	for(i=0;i<m;i++)
		s=s+a[i];
	if(n-s>=0)
		cout<<n-s;
	else
		cout<<"-1";			
}

Measured memory_bytes: 3716
n, a_limit, b_limit = gets.split.map(&:to_i)
a_pass = 0
b_pass = 0
players = gets.chomp.split("")
players.each do |player|
  if player == "a"
    if a_pass + b_pass < a_limit + b_limit
      a_pass += 1
      puts "Yes"
    else
      puts "No"
    end
  elsif player == "b"
    if a_pass + b_pass < a_limit + b_limit && b_pass < b_limit
      b_pass += 1
      puts "Yes"
    else
      puts "No"
    end
  else # player == "c"
    puts "No"
  end
end


Measured memory_bytes: 11900