akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef complex<double> Point;
const double EPS = 1e-8;
Point rotate(Point a, double b, Point c = Point()){
    return (a - c) * polar(1.0, b) + c;
}
int sign(double x){
    if(x > 0) return 1;
    if(x < 0) return -1;
    return 0;
}

int main(){
    int N, D;
    while(cin >> N >> D && N){
        Point lp = Point(-D, 0);
        Point rp = Point( D, 0);

        for(int i = 0; i < N; i++){
            double vl, vr, t;
            cin >> vl >> vr >> t;
            vl = vl / 180 * M_PI;
            vr = vr / 180 * M_PI;
            if(vl == vr){
                Point dir = rotate(rp - lp, M_PI / 2);
                dir /= abs(dir);
                lp += vl * t * dir;
                rp += vr * t * dir;
            }else if(sign(vl) * sign(vr) >= 0){
                Point center = lp + (rp - lp) / (abs(vl) - abs(vr)) * abs(vl);
                double th;
                if(sign(vl) != 0) th = abs(vl) * t / abs(lp - center);
                else              th = abs(vr) * t / abs(rp - center);
                lp = rotate(lp, (abs(vl) < abs(vr) ? 1 : -1) * sign(vl) * th, center);
                rp = rotate(rp, (abs(vl) < abs(vr) ? 1 : -1) * sign(vr) * th, center);
            }else {
                Point center = lp + (rp - lp) / (abs(vl) + abs(vr)) * abs(vl);
                double th = abs(vl) * t / abs(lp - center);
                assert(abs(th - abs(vr) * t / abs(rp - center) < EPS));
                lp = rotate(lp, -1 * sign(vl) * th, center);
                rp = rotate(rp, +1 * sign(vr) * th, center);
            }
        }
        assert(abs(abs(rp - lp) - 2 * D) < EPS);
        Point answer = (lp + rp) / 2.0;
        printf("%.5f\n%.5f\n", answer.real(), answer.imag());
    }
    return 0;
}

Measured memory_bytes: 1272
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        p: [f64; n],
    }

    let mut tbl = vec![vec![0.0; n + 1]; n + 1];
    tbl[0][0] = 1.0;

    for pos in 0..n {
        tbl[pos + 1][0] = tbl[pos][0] * (1.0 - p[pos]);
        for cnt in 1..n + 1 {
            tbl[pos + 1][cnt] = tbl[pos][cnt] * (1.0 - p[pos]) + tbl[pos][cnt - 1] * p[pos];
        }
    }

    let mut ans = 0.0;
    for cnt in n / 2 + 1..n + 1 {
        ans += tbl[n][cnt];
    }
    println!("{}", ans);
}


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

using namespace std;

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

  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int sum = 0;
  bool div = true;
  while (div) {
    for (int i = 0; i < N; i++) {
      if (A.at(i) % 2 == 0) {
        A.at(i) /= 2;
        if (i == N - 1) {
          sum++;
        }
      } else {
        div = false;
        break;
      }
    }
  }

  cout << sum << endl;
}


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

int main(){
  long N;
  cin >> N;
  
  int digit = 0;
  long accum = 0;
  long fact = 1;
  vector<long> accum_list;
  vector<long> fact_list;
  
  while(accum < N){
    accum_list.push_back(accum);
    fact_list.push_back(fact);
    digit++;
    fact *= 26;
    accum += fact;
  }
  
  
  string answer;
  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  int index;
  
  if (accum == N){
    while (digit > 0){
      answer.push_back('z');
      digit--;
    }
    cout << answer;
    return 0;
  }
      
  
  if (digit > 1){
    digit--;
    N -= accum_list[digit];
    index = N / fact_list[digit];
    if (index * fact_list[digit] == N){
      answer.push_back(alphabet[index - 1]);
      while (digit > 0){
        answer.push_back('z');
        digit--;
      }
      cout << answer;
      return 0;
    }
    answer.push_back(alphabet[index]);
    N -= fact_list[digit] * index;
  }
  while (digit > 1){
    digit--;
    index = N / fact_list[digit];
    if (index * fact_list[digit] == N){
      answer.push_back(alphabet[index - 1]);
      while (digit > 0){
        answer.push_back('z');
        digit--;
      }
      cout << answer;
      return 0;
    }
    answer.push_back(alphabet[index]);
    N -= fact_list[digit] * index;
  }
  answer.push_back(alphabet[N - 1]);
  

  
  cout << answer;
  
  return 0;
}

Measured memory_bytes: 3128
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        count=0
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        count=count+1
        print(count)


Measured memory_bytes: 5596
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
d = [0]*(n+1)
for x in range(k):
    for i in range(n):
        l = max(0,i-a[i])
        r = min(n-1,i+a[i])+1
        d[l] += 1
        d[r] -= 1
    for i in range(n): d[i+1] += d[i]
    if x == k-1: break
    for i in range(n):
        if d[i] != n: break
    else:
        break
    a = d[:]
    d = [0]*(n+1)
print(*d[:n])

Measured memory_bytes: 169668
import java.util.*;
import java.io.*;
class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt(), b = sc.nextInt();
                int diff = a - b * 2;
                if(diff<=0){
                        System.out.println(0);
                }else{
                        System.out.println(diff);
                }
        }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	int[] A = new int[100000 + 1];

	for (int i = 0; i < N; i++) {
	    int value = Integer.parseInt(scan.next());
	    A[value]++;
	}

	int i = 1;
	int j = 100000;
	while(i < j) {
	    for (; i < j; i++) {
		if(A[i] > 1) break;
	    }
	    for (; i < j; j--) {
		if(A[j] > 1) break;
	    }
	    if(i != j && A[i] > 1 && A[j] > 1) {
		A[i]--;
		A[j]--;
	    }
	}
	if(A[i] > 1) A[i] = A[i] % 2;
	
	int count = 0;
	for (int k = 1; k < 100000; k++) {
	    count += A[k];
	}

	System.out.println(count);
	scan.close();
    }
}


Measured memory_bytes: 48716
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define rep(i,a) for(int i = 0 ; i < a ; i++) 

bool maze[12][12];
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
bool inmaze(int x,int y){
  return (0<=x && x<12) && (0<=y && y<12);
}

void dfs(int x,int y){
  if(!inmaze(x,y))return;
  maze[x][y] = false;
  rep(i,4)
    if(maze[x+dx[i]][y+dy[i]])
      dfs(x+dx[i],y+dy[i]);
}
int main(void){
  string s;
  while(cin>>s){
    rep(i,12)maze[0][i] = s[i] - '0';

    loop(i,1,12){
      cin>>s;
      rep(j,12)maze[i][j] = s[j] - '0';
    }
    int cnt = 0;
    rep(i,12)rep(j,12)
      if(maze[i][j]){
	cnt++;
	dfs(i,j);
      }
    cout<<cnt<<endl;
    //rep(i,12)rep(j,12)cout<<(j?' ':'\n')<<maze[i][j];
  }
}

Measured memory_bytes: 1180
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.emplace_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.emplace_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  using _pi = pair<int, int>;
  vector<_pi> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<_pi> res(1, _pi(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

#pragma endregion library

int main(){
    int n; cin >> n;
    ll ans = 1;
    Sieve sv(1000006);
    repi(i,1,n){
        auto ps = sv.factor(i);
        ll now = 1;
        for(auto p:ps){
            now *= (p.second+1);
        }
        ans += now;
    }
    cout << ans-1 << '\n';
    

}


Measured memory_bytes: 7792
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(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;
}


int main() {
  std::cout<<std::fixed<<std::setprecision(10);
  int N, K;
  cin >> N >> K;

  int bunbo = 0;
  vector<int> ret(N);
  for(int i=0; i<N; ++i) {
    int ren = ceil(log2((float)K/(i+1)));
    chmax(ren, 0);
    ret[i] = ren;
    chmax(bunbo, ren);
  }

  int denom = 0;
  rep(i, N) {
    int d = pow(2, bunbo-ret[i]);
//    cout << "d " << i << " " << d << endl;
    denom += d;
  }

  bunbo = pow(2, bunbo) * N;
//  cout << bunbo << endl;
//  cout << denom << endl;

//  printf("%.6f\n", (double)denom / bunbo);
  cout << (double)denom / (double)bunbo << endl;

  return 0;
}


Measured memory_bytes: 640
import sys
    
    
def main():
    x, a, b = map(int, input().split())

    if -a + b <= x:
        if -a + b <= 0:
            print('delicious')
        else:
            print('safe')
    else:
        print('dangerous')
    
    return 0


if __name__ == '__main__':
    sys.exit(main())


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

int n, m;
int a[200000], b[200000];
int cnt[200002];

int main() {
  while (cin >> n >> m) {
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < m; i++) {
      cin >> a[i] >> b[i];
      if (a[i] == 1) {
	cnt[b[i]]++;
      }
      if (b[i] == n) {
	cnt[a[i]]++;
      }
    }

    bool possible = false;
    for (int i = 1; i <= n; i++) {
      if (cnt[i] == 2) {
	possible = true;
	break;
      }
    }
    cout << (possible ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  }
}


Measured memory_bytes: 2688
n,*a=`dd`.split.map &:to_i;f=0
puts %w(Second First)[loop{
	b=a.map{|e|e&1^1}
	s=b.reduce :+
	(s==n&&a[0]-=1)||(s==n-1&&(0...n).find{|i|b[i]==0&&a[i]>1&&a[i]-=1})||(break f^=s&1)
	g=a.reduce :gcd
	a=a.map{|e|e/g}
	f^=1
}]

Measured memory_bytes: 31972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
    class Program
    {   
            
        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            int[] a = new int[n];

            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            int max = a[1] - a[0];
            int min = a[0];
            for (int i = 1; i <= n - 1; i++)
            {
                max = Math.Max(max, a[i] - min);
                min = Math.Min(min, a[i]);
            }

            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 10872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 100000
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int a[MAXN+5], n;
inline int GCD(int a, int b){return b ? GCD(b,a%b) : a;} 
bool Calc()
{
	int even = 0; bool one = false, sum = 0;
	for(rint i = 1; i <= n; sum ^= (a[i]^1)&1, even += !(a[i]&1), one |= a[i] == 1, i++);
	if(one) return sum; if(even&1) return 1; if(!(even&1) && even < n-1) return 0;
	int g = 0; for(rint i = 1; i <= n; a[i] -= a[i]&1, g = GCD(g,a[i]), i++);
	for(rint i = 1; i <= n; a[i++] /= g); return Calc()^1;
}
int main(){n = read(); for(rint i = 1; i <= n; a[i++] = read()); puts(Calc()?"First":"Second"); return 0;}

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

int main()
{
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];
    int res = 35;
    for(int i = 0; i < N; ++i) {
        int tmp = 0;
        while(A[i]%2 == 0) { A[i] /= 2; ++tmp; }
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = sc.next()
    var ans = 0
    repeat(n) {
        if (it == 0 || s[it] != s[it - 1]) {
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 31280
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0318?year=2015

#include <bits/stdc++.h>

using namespace std;

int member[110] = {};

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

    for (int i = 0; i < 3; ++i) {
        int t;
        cin >> t;
        while (t--) {
            int idx;
            cin >> idx;
            member[idx] += pow(2, i);
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (member[i] == 4 or member[i] == 6 or member[i] == 7) {
            ans++;
        }
    }

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

/*
 * 2進法を使ってカウント。
 * A,B,Cそれぞれに属しているとき+1,+2,+4する。
 * 4(Cのみ),6(BとC),7(A,B,C全部)
 * が条件をみたす。
 *
 */


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

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

    vector<int> a(N), b(N);

    for (int i = 0; i < N; i++)
        a[i] = b[i] = (i+1) * N;
    reverse(begin(b), end(b));

    for (int i = 0; i < N; i++)
    {
        int j; cin >> j;
        j--;
        a[j] += i;
    }

    for (const int x : a)
        cout << x << " ";
    cout << endl;

    for (const int x : b)
        cout << x << " ";
    cout << endl;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int X, N;
  cin >> X >> N;
  set<int> p;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    p.insert(x);
  }
  for(int i = 0; i < 1000; i++){
    if(!p.count(X - i)){
    cout << X - i <<endl;
    return 0;
    } else if(!p.count(X + i)){
      cout << X + i <<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<climits>
#include<string>
#include<stack>
#include<queue>

const long long MOD = 10e9 + 7;

typedef long long ll;

using namespace std;

vector<int> graph1[100001];
vector<int> graph2[100001];
int size1[100001];
int size2[100001];

int b=1;

int visited[100001];
int parents[100001];
//int parents1[100001];
//int parents2[100001];

void DFS(vector<int>* graph, int* size, int N, int k){
	visited[k]=1;
	int maxpath=0;
	for(int i=0;i<graph[k].size();i++){
		int child = graph[k][i];
		if(visited[child]==0)
			DFS(graph, size , N ,child);
		maxpath=max(maxpath,size[child] + 1);
	}
	size[k] = maxpath;
}



int solve(int N, int M){
	for(int i=1;i<=N;i++){
		if(visited[i]==0)
			DFS(graph1,size1,N,i);	
	}
	for(int i=1;i<=N;i++){
		visited[i]=0;
	}
	for(int i=1;i<=N;i++){
		if(visited[i]==0)
			DFS(graph2,size2,N,i);	
	}
	int maxsize=0;	
	for(int i=1;i<=N;i++){
			maxsize=max(maxsize, size1[i]+size2[i]);
	}
	return maxsize;
}

int main(){
	int N,M,x,y;
	cin>>N>>M;
	for(int i=0; i<M; i++){
		cin >> x >> y;
		graph1[x].push_back(y);
		graph2[y].push_back(x);
		//parents1[y]++;
		//parents2[x]++;
		
	}
	cout<<solve(N,M)<<endl;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll k;
    cin >> k;
    string ans;
    REP(i, k){
        ans += "ACL";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b&&(a||b))
    {
          if(a>b)
        cout<<b<<' '<<a;
    else cout<<a<<' '<<b;
    cout<<endl;
    }

}

Measured memory_bytes: 1160
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int tower[1005];
int main()
{
	for(int i=1;i<=999;i++)
		tower[i]=tower[i-1]+i;
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=2;i<=999;i++)
		if(tower[i-1]-a==tower[i]-b)
		{
			printf("%d\n",tower[i-1]-a);
			return 0;
		}
	return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
const int N = 100000 + 5;
long long n, top, a[N], q[5],ans;
int main(){
	scanf("%d", &n);
	for( int i = 1; i <= n; i++ ) cin>>a[i];
	sort(a+1,a+n+1);
	for( int i = n-3; i >= 1; i-- )
		if( a[i] == a[i+1] &&a[i] == a[i+2] &&a[i]== a[i+3] ){
			ans = a[i]*a[i];
			break;
		}
	for( int i = n-1; i >= 1; i-- ){
		if( a[i] == a[i+1] && a[i] != q[top] ) q[++top] = a[i];
		if( top == 2 ) break;
	}
	ans = max(ans,q[1]*q[2]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(void) {
    char s[200001];

    scanf("%s", s);

    long int k = 0, ans = 0;
    int i;

    for (i = 0; i < strlen(s); i++) {
        if (s[i] == 'A')
            k++;
        else if (s[i] == 'B' && s[i + 1] == 'C') {
            ans += k;
            i++;
        }
        else
            k = 0;
    }

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

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static String map[][];
	static boolean used[][];
	static int h, w;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		h = sc.nextInt();
		w = sc.nextInt();
		map = new String[h][];
		used = new boolean[h][w];
		for(int i = 0;i < h;i++){
			map[i] = sc.next().split("");
		}

		if(search(0, 0)){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}

	}

	static boolean search(int a, int b){
		map[a][b] = ".";

		if(a+1 < h && b+1 < w && map[a+1][b].equals("#") && map[a][b+1].equals("#")){
			return false;
		}else if((a-1 >= 0 && map[a-1][b].equals("#")) || (b-1 >= 0 && map[a][b-1].equals("#"))){
			return false;
		}else if(a+1 < h && map[a+1][b].equals("#")){
			return search(a+1, b);
		}else if(b+1 < w && map[a][b+1].equals("#")){
			return search(a, b+1);
		}if(a == h-1 && b == w-1){
			return true;
		}else{
			return false;
		}
	}
}

Measured memory_bytes: 9808
import math


def task(x):
    table = {}
    for i in range(-1000, 1000):
        table[i] = int(math.pow(i, 5))

    for i in range(-1000, 1000):
        for j in range(-1000, 1000):
            if table[i] - table[j] == x:
                print(i, j)
                return
    print(0, 0)


x = int(input())

task(x)


Measured memory_bytes: 9640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    string s;
    cin >> s;
    if (s=="SUN")
    {
        cout << "7" << endl;
    }    
    else if (s=="MON")
    {
        cout << "6" << endl;
    }
    else if (s=="TUE")
    {
        cout << "5" << endl;
    }
    else if (s=="WED")
    {
        cout << "4" << endl;
    }
    else if (s=="THU")
    {
        cout << "3" << endl;
    }
    else if (s=="FRI")
    {
        cout << "2" << endl;
    }
    else if (s=="SAT")
    {
        cout << "1" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

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

    vector<vector<ll>> dp(2,vector<ll>(str.size()+1,0));

    dp[0][0] = 1;

    for(int i = 0; i < str.size(); i++){
        if(str[i] == '1'){
            dp[0][i+1] += dp[0][i]*2;
            dp[0][i+1] %= MOD;
            dp[1][i+1] += dp[0][i];
            dp[1][i+1] += dp[1][i]*3;
            dp[1][i+1] %= MOD;
        }else{
            dp[0][i+1] += dp[0][i];
            dp[0][i+1] %= MOD;
            dp[1][i+1] += dp[1][i]*3;
            dp[1][i+1] %= MOD;
        }
    }

    cout << (dp[1][str.size()] + dp[0][str.size()])%MOD << endl;

    return 0;
}

Measured memory_bytes: 2896
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
char order[100010];
bool mp[100010];
bool pre,last;
int n;
bool turn(bool a)
{
	if(a)return false;
	return true;
}
bool judge1()
{
	mp[1]=mp[2]=1;
	pre=true;
	if(order[1]=='o')
	last=1;
	else
	last=0;
	for(int i=2;i<=n;i++)
	{
		if(mp[i])
		{
			if(order[i]=='o')
			mp[i+1]=pre;
			else
			mp[i+1]=turn(pre);
		}
		else
		{
			if(order[i]=='o')
			mp[i+1]=turn(pre);
			else
			mp[i+1]=pre;
		}
		pre=mp[i];
	}
	if(mp[n]==last&&mp[n+1]==mp[1])
	{
		for(int i=1;i<=n;i++)
		{
			if(mp[i])printf("S");
			else printf("W");
		}
		printf("\n");
		return true;
	}
	return false;
}
bool judge2()
{
	mp[1]=1,mp[2]=0;
	pre=true;
	if(order[1]=='o')
	last=0;
	else
	last=1;
	for(int i=2;i<=n;i++)
	{
		if(mp[i])
		{
			if(order[i]=='o')
			mp[i+1]=pre;
			else
			mp[i+1]=turn(pre);
		}
		else
		{
			if(order[i]=='o')
			mp[i+1]=turn(pre);
			else
			mp[i+1]=pre;
		}
		pre=mp[i];
	}
	if(mp[n]==last&&mp[n+1]==mp[1])
	{
		for(int i=1;i<=n;i++)
		{
			if(mp[i])printf("S");
			else printf("W");
		}
		printf("\n");
		return true;
	}
	return false;
}
bool judge3()
{
	mp[1]=0,mp[2]=0;
	pre=false;
	if(order[1]=='o')
	last=1;
	else
	last=0;
	for(int i=2;i<=n;i++)
	{
		if(mp[i])
		{
			if(order[i]=='o')
			mp[i+1]=pre;
			else
			mp[i+1]=turn(pre);
		}
		else
		{
			if(order[i]=='o')
			mp[i+1]=turn(pre);
			else
			mp[i+1]=pre;
		}
		pre=mp[i];
	}
	if(mp[n]==last&&mp[n+1]==mp[1])
	{
		for(int i=1;i<=n;i++)
		{
			if(mp[i])printf("S");
			else printf("W");
		}
		printf("\n");
		return true;
	}
	return false;
}
bool judge4()
{
	mp[1]=0,mp[2]=1;
	pre=false;
	if(order[1]=='o')
	last=0;
	else
	last=1;
	for(int i=2;i<=n;i++)
	{
		if(mp[i])
		{
			if(order[i]=='o')
			mp[i+1]=pre;
			else
			mp[i+1]=turn(pre);
		}
		else
		{
			if(order[i]=='o')
			mp[i+1]=turn(pre);
			else
			mp[i+1]=pre;
		}
		pre=mp[i];
	}
	if(mp[n]==last&&mp[n+1]==mp[1])
	{
		for(int i=1;i<=n;i++)
		{
			if(mp[i])printf("S");
			else printf("W");
		}
		printf("\n");
		return true;
	}
	return false;
}
int main()
{
	while(scanf("%d",&n)!=EOF)
	{
		scanf("%s",order+1);
		if(judge1())continue;
		if(judge2())continue;
		if(judge3())continue;
		if(judge4())continue;	
		printf("-1\n");
	}
	return 0;
}

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

int main(){
  
  int D;
  cin >> D;
  
  switch(D){
    case 22:
      cout << "Christmas Eve Eve Eve" << endl;
      break;
    case 23:
      cout << "Christmas Eve Eve" << endl;
      break;
    case 24:
      cout << "Christmas Eve" << endl;
      break;
    case 25:
      cout << "Christmas" << endl;
      break;      
    default :
      break;
  }
  return 0;
}

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    vector<set<int>> x(10);
    for(int i = 0; i < N; i++){
        int d = S[i] - '0';
        x[d].insert(i);
    }
    int ans = 0;
    for(int a = 0; a <= 9; a++){
        for(int b = 0; b <=9; b++){
            for(int c = 0; c <= 9; c++){
                int pos = -1;
                if(x[a].upper_bound(pos) == x[a].end()) continue;
                pos = *x[a].upper_bound(pos);
                if(x[b].upper_bound(pos) == x[b].end()) continue;
                pos = *x[b].upper_bound(pos);
                if(x[c].upper_bound(pos) == x[c].end()) continue;
                pos = *x[c].upper_bound(pos);
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5044
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<ll> vecll;
typedef vector<ld> vecld;
typedef vector<bool> vecbl;
typedef vector<vector<ll> > matll;
typedef vector<vector<ld> > matld;
typedef vector<vector<bool> > matbl;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

// nのk乗(mod p = prime)
ll power(ll n, ll k) {
	ll p = prime;
	if (k == 1) {
		return n;
	}
	ll m = n * n;
	m %= p;
	if (k % 2 == 0) {
		return power(m, k / 2);
	}
	m = power(m, k / 2);
	m *= n;
	m %= p;
	return m;
}

// nCk(mod p = prime)
ll com(ll n, ll k) {
	// nCk
	ll p = prime;

	ll ans = 1;
	for (ll i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= p;
	}

	for (ll i = 2; i <= k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	for (ll i = 2; i <= n-k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	return ans;
}

vector<pll> pfac(ll n) {
	// prime factorization
	ll m = n;
	vecll primes;
	for (ll i = 2; i <= n; i++)
	{
		if (m % i == 0) {
			while (true) {
				primes.push_back(i);
				m /= i;
				if (m % i == 0) {
					continue;
				}
				else {
					break;
				}
			}
		}
		if (m == 1) {
			break;
		}
	}

	vector<pll> primep;
	ll pre, now, index;
	pre = -1;
	index = 0;
	for (ll i = 0; i < primes.size(); i++)
	{
		now = primes[i];
		if (pre == now) {
			primep[index].second++;
		}
		else {
			index++;
			primep.push_back(make_pair(now, 1));
			pre = now;
		}
	}

	return primep;

}

vecll divisors(vector<pll> primep) {
	vecll primes, primes2;
	for (ll j = 0; j < primep[0].second; j++)
	{
		primes.push_back(pow(primep[0].first, j));
	}

	for (ll i = 1; i < primep.size(); i++)
	{
		primes2 = vecll();
		for (ll j = 0; j < primes.size(); j++)
		{
			for (ll k = 0; k < primep[i].second; k++)
			{
				primes2.push_back(primes[j] * pow(primep[i].first, k));
			}
		}
		primes = vecll();
		for (ll i = 0; i < primes2.size(); i++)
		{
			primes[i] = primes2[i];
		}
	}

	return primes;
}


int main() {
	//
	ll n;
	cin >> n;
	ll sum, sum3, sum5, sum15;
	sum = 0;
	sum3 = 0;
	sum5 = 0;
	sum15 = 0;

	sum = (1 + n) * n / 2;
	sum3 = (1 + n / 3) * (n / 3) / 2 * 3;
	sum5 = (1 + (n / 5)) * (n / 5) / 2 * 5;
	sum15 = (1 + (n / 15)) * (n / 15) / 2 * 15;

	sum += -sum3 - sum5 + sum15;
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    bool flag[101]={};
    int n;cin>>n;
    rep(i,n){
        int t;cin>>t;
        flag[t]=true;
    }
    int ans=0;
    rep(i,101){
        if(flag[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 202
using namespace std;
int n;
int a[N];
int main()
{
	/*freopen("test.inp","r",stdin);
	freopen("test.out","w",stdout);*/
	ios::sync_with_stdio(0);
	cin>>n;
	for (int i=1; i <= 2*n; i++)
		cin>>a[i];
	sort(a+1,a+1+2*n);
	int res=0;
	for (int i=1; i <= 2*n; i+=2)
		res+=min(a[i],a[i+1]);
	cout<<res;
	return 0;
}

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

M = 10**9 + 7

def mpow(n, p)
	if p == 1
		return n
	end
	
	m = (n ** 2) % M
	q = p / 2
	if p % 2 == 0
		return mpow(m, q) % M
	else
		return (mpow(m, q) * n) % M
	end
end

def mminus(a, b)
	n = a - b
	if n < 0
		n = n + M
	end
	return n
end

def mmulti(m, n)
	return m * n % M
end

def mfact(n)
	a = 1

	for i in 1..n
		a = mmulti(a, i)
	end
	
	return a
end

def minv(a)
	return mpow(a, M - 2)
end

def mcombi(n, k)
	min = [k, n - k].min
	max = [k, n - k].max
	return n if min == 1
	return 1 if min == 0
	
	a = 1
	for i in (max+1)..n
		a = mmulti(a, i)
	end
	
	b = mfact(k)
	
	return mmulti(a, minv(b))
end

(x, a, b)  = STDIN.gets.chomp.split(/\s/).map { |e| e.to_i }

ans = mminus(mminus(mpow(2, x) - 1, mcombi(x, a)), mcombi(x, b))

puts ans


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;   cin >> n >> m;
    if (n & 1) {
        for (int i = 1; i <= m; i++) {
            cout << i << ' ' << n - i << '\n';
        }
    }
    else {
        int t = (m + 1) / 2, t2 = t << 1;
        for (int i = 1; i <= t; i++) {
            int a = t - i + 1, b = a + i * 2 - 1;
            cout << a << ' ' << b << '\n';
        }
        for (int i = 1; i <= m - t; i++) {
            int a = t2 + m - t - i + 1, b = a + i * 2;
            cout << a << ' ' << b << '\n';
        }
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++){
        if(i%3>0){
            if(i%5>0){
                sum+=i;
            }
        }
    }
    cout<<sum;
    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  int n, a, b;
  Read(n), Read(a), Read(b);
  puts(b - a & 1 ? "Borys" : "Alice");
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


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


int main(){
    long long int K;
    cin >> K;
    long long int N = 7;
    long long int i = 1;
    long long int output = -1;

    if (K % 2 == 0){
        cout << output << '\n';
        return 0;
    }

    while (i < 7 * K + 1)
    {
        if( N % K == 0){
            output = i;
            break;
        }
        N %= K;
        N = 10 * N + 7;

        i += 1;
    }  
    cout << output << '\n';

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
 
signed main()
{
	
	int n; cin>>n;
	int ans = n-1;
	for(int i=1; i*i <=n; i++)
	{
		if(n%i == 0)
		{
			int k = n/i;
			ans = min(ans, k+i-2);
		}
	}
	cout<<ans<<"\n";
}

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

using namespace std;

int main(){
	
	while(1){
		
		int d,e;
		
		cin >> d >> e;
		
		if(d==0&&e==0) break;
		
		double mi=1000.;
		
		for(int i=0;i<=d;i++){
			int j=d-i;
			double len=sqrt((i*i)+(j*j));
			
			mi=min(mi,abs(len-e));
		}
		cout << mi << endl;
	}
	
	
	
	return 0;
}
	


Measured memory_bytes: 3208
# your code goes here
N,M,X_c,Y_c = map(int,input().split())

X = list(map(int,input().split()))
Y = list(map(int,input().split()))

X.sort()
Y.sort()

if max(X[-1],X_c) < min(Y[0],Y_c):
	print('No War')
else:
	print('War')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  co(min(b,c)<<" ");
  if(b+c>=a) co(b+c-a);
  else co(0);
  return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#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;
#define ll long long
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define nl "\n"
#define fout(x) fixed<<setprecision(x)
#define one(x) __builtin_popcountll(x)
#define F first
#define S second
#define or_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(), order_of_key()
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << fout(10)<<x;}
void __print(double x) {cerr << fout(10)<<x;}
void __print(long double x) {cerr << fout(10)<<x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
const int mod=1e9+7;
const double eps=1e-9;
const double PI=acos(-1.0);
 
ll qpow(ll n,ll k){ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

// ****************************************************



int main()
{
	ll a, b, n;
	cin>>n>>a>>b;
	ll ans=qpow(2, n);
	ll f=1, fa=1, fna=1, fb=1, fnb=1;
	for(int i=2; i<=a; i++) fa=(fa*i)%mod;
	for(int i=2; i<=b; i++) fb=(fb*i)%mod;

	fa=qpow(fa, mod-2);
	fb=qpow(fb, mod-2);



	for(int i=n; i>=n-a+1; i--) fa=(fa*i)%mod;
	for(int i=n; i>=n-b+1; i--) fb=(fb*i)%mod;
	//debug(fa, fb);
	ans=(ans-fa-fb)%mod;
	ans=(ans+mod)%mod;
	cout<<ans-1<<endl;
	return 0;
	fa=(fa*fna)%mod;
	fa=(fa*f)%mod;
	fb=(fb*fnb)%mod;
	fb=(fb*f)%mod;
	ans=(ans-fa-fb)%mod;
	ans=(ans+mod)%mod;
	cout<<ans-1<<endl;
    return 0;
}


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

vector<ll> L, P;

ll f(int n, ll x){
	if(n==0) return x<=0? 0:1;
	ll m = L[n]/2 + 1;
	//left: xの補正: L[n-1]範囲の前にある B が邪魔だ
	if(m > x) return f(n-1, x-1);
	//right: xの補正: L[n-1]範囲の前にある B+L[n-1]+P が邪魔だ
	else if(m < x) return P[n-1] + 1LL + f(n-1, x-m);
	//mid
	else return P[n-1] + 1LL;
}

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

	L.push_back(1);
	P.push_back(1);
	for(int i=0; i<N; ++i){
		L.push_back(L[i]*2LL + 3LL);
		P.push_back(P[i]*2LL + 1LL);
	}

	cout<< f(N, X) <<endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
a, b, turn = 0, 0, 1
while len(A) != 0:
    if turn & 1:
        a += A.pop()
    else:
        b += A.pop()
    turn += 1
print(a-b)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string s;
  cin >> s;

  if(s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3) )
  	cout << "Bad" << endl;
  else
	cout << "Good" << endl;
  

}

Measured memory_bytes: 256
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

X = int(input())

i = -1000
val = i**5
vals = defaultdict(int)
while val <= 10**9:
    vals[val] = i
    i += 1
    val = i**5

d = defaultdict(int)
for a, akon in vals.items():
    for b, bkon in vals.items():
        val = a-b
        if d[val] == 0:
            d[val] = (akon, bkon)
# print(len(d))
if X in d.keys():
    a, b = d[X]
    print(a, b)



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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a[3];

int main(){
    for(int i = 0; i < 3; i++)  cin >> a[i];
    sort(a,a+3);
    ll ans = 0;
    for(int i = 1; i < 3; i++){
        ans += a[i]-a[i-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
import math

N, K = map(int, input().split())

K_list = [K]
tmp = K

for i in range(1, K):
    if tmp < 1:
        break
    else:
        tmp = tmp / 2
        tmp2 = math.ceil(tmp)
        K_list.append(tmp2)

KN_list = []
count = 0

for i in range(len(K_list)):
    if K_list[i] > N :
        count += 1
        pass
    elif K_list[i] == N:
        KN_list.append(K_list[i])
    else:
        KN_list.append(K_list[i])  
if N+1 not in KN_list:
    KN_list.insert(0, N+1)



ans = 0
for i in range(len(KN_list)-1):
    tmp = KN_list[i] - KN_list[i+1]
    tmp = tmp * (0.5**(i+count))
    ans += tmp

ans = ans/N

print(ans)


Measured memory_bytes: 12384
#include <stdio.h>

int main(int argc, char **argv)
{
	int i, n, flag = 0;
	
	scanf("%d", &n);
	
	for (i = 1; i < 10; i++)
		if ((n % i == 0) && (n / i < 10)){
			flag = 1;
			break;
		}
	
	if (flag)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(a,n) for (int i=a;i<n;i++)
#define per(a,n) for (int i=n-1;i>=a;i--)
#define fro(n) for (int i=0;i<n;i++)
#define rev(n) for (int i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int> VI;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=4294967297;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main() {
auto start = chrono::high_resolution_clock::now(); 

#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
#endif
long double timestarts=chrono::system_clock::now().time_since_epoch().count()/1e-6;
FIO






// Solving Area Starts
int n,ans=0,k,z;
cin>>n;
for(int c=1;c<n;c++){
        k=n-c;
        z=sqrt(k);
        for(int j=1;j<z+1;j++){
                if(k%j==0){
                        if(k/j==k/(k/j)) ans+=1;
                        else ans+=2;
                }
        }
}
cout<<ans<<endl;


//Solving Area ends




auto end = chrono::high_resolution_clock::now(); 
double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
time_taken *= 1e-6; 
#ifndef ONLINE_JUDGE
        cout << "Time " << fixed << time_taken << setprecision(6); 
        cout << " milsec" << endl;
#endif

}

Measured memory_bytes: 3684
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

string S = "12+1290";
string SS = "";
int cur = 0;

int digit() {
    assert(isdigit(S[cur]));
    int n = S[cur] - '0';
    cur++;
    return n;
}

ll number() {
    ll n = digit();
    while (cur < S.size() && isdigit(S[cur])) {
        n = n * 10 + digit();
    }
    return n;
}

ll formula() {
    if (S[cur] == '-') {
        cur++;
        ll n = formula();
        if (n == 0) {
            return 2;
        } else if (n == 1) {
            return 1;
        } else {
            return 0;
        }
    } else if (S[cur] == '(') {
        cur++;
        ll a = formula();
        char op = S[cur];
        cur++;
        if (cur < S.size()) {
            ll b = formula();
            if (op == '*') {
                a = min(a, b);
            } else {
                a = max(a, b);
            }
        }
        assert(S[cur] == ')');
        cur++;
        return a;
    } else {
        return number();
    }
}

ll parse(int p, int q, int r) {
    int len = S.size();
    for (int i = 0; i < len; i++) {
        if (S[i] == 'P') {
            S[i] = p + '0';
        } else if (S[i] == 'Q') {
            S[i] = q + '0';
        } else if (S[i] == 'R') {
            S[i] = r + '0';
        }
    }
    return formula();
}

int solve() {
    int count = 0;
    for (int p:{0, 1, 2}) {
        for (int q:{0, 1, 2}) {
            for (int r:{0, 1, 2}) {
                S = SS;
                cur = 0;
                if (parse(p, q, r) == 2) {
                    count++;
                }
            }
        }
    }
    return count;
}

int main() {
    while (true) {
        cin >> SS;
        if (SS == ".") {
            break;
        }
        cout << solve() << endl;
    }
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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; }

const int m = 2019;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
//mod2019で0となる部分を求める
//10と2019は素であるため逆元が定義できる
//よって累積和がs_i-s_j%2019==0となるi,jを求める
//->s_i==s_j(mod2019)となる組を求めればよい

reverse(s.begin(),s.end());
vector<int> cnt(m,0);
int x=1,tot=0;
ll ans = 0;
rep(i,s.size()){
    cnt[tot]++;
    tot += (s[i]-'0')*x;
    tot%=m;
    ans+=cnt[tot];//それまでに見つかっている同じ累積和の個数を足す
    x = (x * 10) % m;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>

int main(void){
    int n, i, j, flag = 0;
    scanf("%d", &n);

    for(i = 0; i <= n / 4; i++){
        for(j = 0; j <= n / 7; j++){
            if(4 * i + 7 * j == n){
                flag = 1;
            }
        }
    }

    if(flag == 1){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
def calc(N, M):
    if N == 1 and M == 1:
        return 1
    if N == 1:
        return M - 2
    if M == 1:
        return N - 2
    # N >= 2 and M >= 2:
    return (N - 2) * (M - 2)

N, M = [int(_) for _ in input().split()]

print(calc(N, M))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define test(t) int t;cin>>t;while(t--)
#define lli long long int
#define pb push_back
#define MAX 1000000007
#define mod 1000000007
#include <iostream>
const lli infl=0x3f3f3f3f3f3f3f3fLL;

int main()
{  ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
  // test(t)
   {
       lli s,b,c,n,d,sum=0;
     cin>>n;
     map<int,int> m;lli a[n+1];
    for(int i=2;i<=n;i++)
    {
        cin>>a[i];m[a[i]]++;
    }
    for(int i=1;i<=n;i++)
        cout<<m[i]<<endl;

     cout<<endl;
   }


return 0;
}


Measured memory_bytes: 14596