akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    int n;
    cin >> n;
    int i;
    vector<int>f(n);
    for (i = 0; i < n; i++)
    {
        f.at(i) = 0;
    }
    int a;
    for (i = 1; i < n; i++)
    {
        cin >> a;
        f.at(a-1)++;
    }
    for (i = 0; i < n; i++)
    {
        cout << f.at(i) << endl;
    }

}

Measured memory_bytes: 4040
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int dp[111][5][5][5];
const int mod = 1e9 + 7;

bool isok(int a, int b, int c, int d){
    if(a == 0 && b == 1 && c == 2)return false;
    if(b == 0 && c == 1 && d == 2)return false;

    swap(a, b);
    if(a == 0 && b == 1 && c == 2)return false;
    if(b == 0 && c == 1 && d == 2)return false;
    swap(a, b);

    swap(b, c);
    if(a == 0 && b == 1 && c == 2)return false;
    if(b == 0 && c == 1 && d == 2)return false;
    swap(b, c);

    swap(c, d);
    if(a == 0 && b == 1 && c == 2)return false;
    if(b == 0 && c == 1 && d == 2)return false;
    swap(c, d);

    return true;
}

int main(){
    INIT;
    cin >> n;
    dp[0][4][4][4] = 1;
    REP(i, n){
        REP(j, 5){
            REP(k, 5){
                REP(l, 5){
                    REP(m, 4){
                        if(!isok(j, k, l, m))continue;
                        (dp[i + 1][k][l][m] += dp[i][j][k][l]) %= mod;
                    }
                }
            }
        }
    }
    LL ans = 0;
    REP(i, 4)REP(j, 4)REP(k, 4){
        ans += dp[n][i][j][k];
    }
    cout << ans% mod << endl;
}

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

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

	int e=0,w=0,s=0,n=0;
	for(int i=0; i<S.size(); i++){
		if(S[i]=='E') e++;
		if(S[i]=='W') w++;
		if(S[i]=='S') s++;
		if(S[i]=='N') n++;
	}

	if(s>0&&n==0 || n>0&&s==0 || e>0&&w==0 || w>0&&e==0){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    public static void main(String[] args) {
	long N = Long.parseLong(scan.next());
	long K = Long.parseLong(scan.next());

	System.out.println(K * pow(K-1, N-1));
	scan.close();
    }

    private static long pow(long x, long y) {
	if(y == 0) return 1;

	if(y % 2 == 0) {
	    long x2 = pow(x, y/2);
	    return x2 * x2;
	} else {
	    long x2 = pow(x, y/2);
	    return x * x2 * x2;
	}
    }
}


Measured memory_bytes: 22996
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  if (n / 100 == n % 10) {
    Yes();
  } else {
    No();
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
from collections import Counter
def solve():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for i in range(10)]
    A = []
    for i in range(H):
        a = list(map(int, input().split()))
        A += a


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

    ans = 0
    for num, count in counter.items():
        if num == -1:
            continue
        ans += C[num][1] * count
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 41308
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, C = map(int, readline().split())

    if (A < C < B) or (B < C < A):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 60908
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;
    for( int i=0 ; i<n ; i++ ){
        cin >> R[i];
    }

    int maxv = -2000000000;
    int minv = R[0];

    for( int i=1 ; i<n ; i++ ){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}



Measured memory_bytes: 3872
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<int>abc(3);
	for (int i = 0;i < 3;i++) {
		cin >> abc[i];
	}
	sort(abc.begin(), abc.end());
	cout << abc[2] * 10 + abc[1] + abc[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  int ans;
  for (int x = 1; x <= n; ++x) {
    //if (n <= (double)x*1.08 && (double)x*1.08 < n) 
    if ((int)(x*1.08) == n) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

bool LF_PRIME_SEQUENCE(const long &n, vector<long> &vPrime){
    if(n < 2){
        return false;
    }
    vPrime.clear();
    vPrime.push_back(2);
    for (long i = 2; i * i <= n; i++){
        int iPrimeType = 1;
        for(long j = 0; j < vPrime.size(); j++){
            if(i % vPrime[j] == 0){
                iPrimeType = 0;
                break;
            }
            if(i < vPrime[j] * vPrime[j]){
                break;
            }
        }
        if(iPrimeType == 1){
            vPrime.push_back(i);
        }
    }
    return true;
}

int main(){
    long N;
    scanf("%ld", &N);
    vector<long> vPrime;
    if(!LF_PRIME_SEQUENCE(N, vPrime)){
        printf("%d", 0);
    } else {
        long nSum = 0;
        for(long int i = 0; i < vPrime.size(); i++){
            int nCount = 0;
            while(N % vPrime[i] == 0){
                N /= vPrime[i];
                nCount++;
            }
            if(nCount != 0){
                int k = 0;
                for (int j = 1; j < nCount + 2; j++){
                    k += j;
                    if(k > nCount){
                        nSum += (j - 1);
                        break;
                    }
                }
            }
        }
        if(N != 1){
            nSum++;
        }
        printf("%d", nSum);
    }
    
    return 0;
}


Measured memory_bytes: 3908
const main = (input: any) => {
  const a: number = input.split(' ')[0];
  const b: number = input.split(' ')[1];
  const d: number = b - a;
  let sum: number = 0;
  for (let i = 1; i <= d; i++) {
    sum = sum + i;
  }
  console.log(sum - b);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

ll calc(ll n){
	return ((n + 1)*n) / 2;
}

int main() {
	ll a;
	cin >> a;
	ll high = INF, low = 0;
	while(high - 1 != low){
		ll mid = (high + low) / 2;
		if(a <= calc(mid)){
			high = mid;
		}else{
			low = mid;
		}
	}
	cout << high << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 102
#define MAX 100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"

const int inf = (int)1e18 + 10;
int dp[MAX][2] = {{0}};
vec v[MAX];
void dfs(int x , int p){
     dp[x][0] = 1;
     dp[x][1] = 1;
	for(int i = 0 ; i <  v[x].size() ; i++){
		int y = v[x][i];
		if(y == p) continue;
		dfs(y , x);
		dp[x][0] *= (dp[y][0] + dp[y][1]);
		dp[x][1] *= dp[y][0];
		dp[x][0] %= mod;
		dp[x][1] %= mod;
	}
	
}
signed main(){
  fast;
  int n , x , y;
  cin >> n;
  for(int i = 1 ; i < n ; i++){
  	cin >> x >> y;
  	v[x].pb(y);
  	v[y].pb(x);
  }

  dfs(1 , 0);

  cout << (dp[1][0] + dp[1][1] ) % mod << endl;


}	

Measured memory_bytes: 14208
#include<stdio.h>
int main(){
  int A[100],N;
  int i,j,k,flag=1,temp,num=0;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
      }


  while(flag){
    flag=0;
    for(j=N-1;j>0;--j){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	num++;
      }
    }
  }

  printf("%d",A[0]);
    for(j=1;j<N;j++){
      printf(" %d",A[j]);
    }
    printf("\n");
    printf("%d\n",num);

    return 0;
    
}
      
      
      
  
  



Measured memory_bytes: 2140
#include <stdio.h>
 
int pNode(int i);
int lChild(int i);
int rChild(int i);
void maxHeapify(int i);
void buildMaxHeap(void);
 
int A[500001];
int n;
 
main(){
 
    int i;
 
    scanf("%d", &n);
 
    for(i=1; i<=n; i++){
        scanf("%d", &A[i]);
    }
     
    buildMaxHeap();
     
    for(i=1; i<=n; i++){
        printf(" %d", A[i]);
    }
     
    printf("\n");
     
    return 0;
     
}
 
int pNode(int i){
    return (int)i/2;
}
 
int lChild(int i){
    return 2*i;
}
 
int rChild(int i){
    return 2*i+1;
}
 
void maxHeapify(int i){
    int l = lChild(i);
    int r = rChild(i);
    int max, tmp;
     
    if(l <= n && A[l] > A[i]){
        max = l;   
    }else{
        max = i;
    }
    if(r <= n && A[r] > A[max]){
        max = r;   
    }
    if(max != i){
        tmp = A[i];
        A[i] = A[max];
        A[max] = tmp;
        maxHeapify(max);
    }
}
 
void buildMaxHeap(void){
    int i;
    for(i=(int)n/2; i>0; i--)
        maxHeapify(i);
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define int      long long
using namespace std;
int32_t main()
{
 int a,b,c,d;
 cin >> a >> b >> c >> d;
 int op1=a*c;
 int op2=a*d;
 int op3=b*c;
 int op4=b*d;
 cout << max(op1,max(op2,max(op3,op4))) << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const auto INF =(long long)1e7;
int N;
using ll =long long;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int i=0;
    int e=-1;
  	bool f = false;
    while(i<=b&&i<=d){
      if(i>=a&&i>=c) {
        f=true;
        e++;}
      i++;
    }
    cout << (f?e:0);
  	return 0;
}

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

typedef long long ll;
static const int MOD=1000000007;

int main(){
    int n;
    cin >> n;
    string s1;
    string s2;
    cin >> s1;
    cin >> s2;
    ll ans;
    bool check=true;
    if(s1[0]==s2[0]){
        ans=3;
    }else{
        ans=6;
        check=false;
    }
    if(check){
        bool checkX=true;
        for(int i=1;i<s1.size();i++){
            if(checkX){
                if(s1[i]==s2[i]){
                    ans*=2;
                }else{
                    checkX=false;
                    ans*=2;
                    i++;
                }
                ans%=MOD;
            }else{
                if(s1[i]!=s2[i]){
                    ans*=3;
                    i++;
                }else{
                    checkX=true;
                }
                ans%=MOD;
            } 
        }
    }else{
        bool checkX=false;
        for(int i=2;i<s1.size();i++){
            if(checkX){
                if(s1[i]==s2[i]){
                    ans*=2;
                }else{
                    checkX=false;
                    ans*=2;
                    i++;
                }
                ans%=MOD;
            }else{
                if(s1[i]!=s2[i]){
                    ans*=3;
                    i++;
                }else{
                    checkX=true;
                }
                ans%=MOD;
            } 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <iomanip>
#include <cassert>
#include <string.h>
#include <cstdio>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef unsigned long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e8;
const LL LINF = 1e16;
const LL mod = 1e9 + 7;
const LL MAX = 1e5 + 7;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt_w = 0, cnt_e = 0;
	FOR(i, 1, n)
		if (s[i] == 'E')
			++cnt_e;

	int ans = n;
	FOR(i, 0, n)
	{
		if (s[i] == 'E' && i)
			--cnt_e;

		int curr = cnt_w + cnt_e;
		ans = min(ans, curr);		

		if (s[i] == 'W')
			++cnt_w;

	}

	cout << ans << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 720
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int S = sc.nextInt();
        // スペース区切りの整数の入力
        int W = sc.nextInt();
        if (W >= S){
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }

    }
}

Measured memory_bytes: 35760
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

main(){
    int a, b, t, num;
    cin >> a >> b >> t;
    num = t / a;
    cout << num * b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define loop(i,a,b) for(i=a;i<b;i++)
    #define rloop(i,a,b) for(i=a;i>=b;i--)
    #define vi vector<int>
    #define vs vector<string>
    const int inf=1e9+1;
    const ll INF=1e16;
    #define MOD 1000000007
    #define mod 1000000009
    #define pi 3.14159265358979323846
     
     
    int main(){
    	ll n,t,i,j;
    	cin>>n>>t;
    	ll sum=0;
    	ll sum2=0;
    	vector<ll> t2(n);
    	cin>>j;
    	t2[0]=j;
    	loop(i,1,n){
    		cin>>j;
    		sum2+=t2[i-1];
    		t2[i]=j-sum2;
    	}
    	loop(i,0,n){
    		sum+=min(t2[i],t);
    	}
    	sum+=t;
    	cout<<sum<<endl;
    }

Measured memory_bytes: 1792
import numpy as np

N = int(input())
N_sqrt = int(np.sqrt(N))+1
N_ = [i for i in range(2, N_sqrt) if N % i == 0]

if len(N_) == 0:
    print(N-1)
else:
    pair = [(i, int(N/i)) for i in N_]
    my_lambda = lambda x : sum(x)
    x = list(map(my_lambda, pair))
    print(min(x)-2)


Measured memory_bytes: 12508
#include<stdio.h>
char st[15];
void out(int n,int now,int max){
	if(now>=n){
		printf("%s",st);
		puts("");
		return ;
	}
	for(int i=97;i<=max+1;i++){
		st[now]=i;
		out(n,now+1,i>max?i:max);
	}
}
int main(){
	int n;
	scanf("%d",&n);
	out(n,0,96);
	return 0;
	
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	int Q=in();
	REP(i,Q){
		string T=in<string>();
		if(T=="print"){
			int u=in(),v=in();
			out(S.substr(u,v-u+1));
		}
		else if(T=="replace"){
			int u=in(),v=in();
			string P=in<string>();
			S.replace(u,v-u+1,P.c_str());
		}
		else{
			int u=in(),v=in();
			string sub = S.substr(u,v-u+1);
			reverse(ALL(sub));
			S.replace(u,v-u+1,sub.c_str());
		}
	}
	
	return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,k;
    cin>>n>>m>>k;
    long long int a,b;
    long long int A[n];
    long long int B[m];
    for (int i=0;i<n;i++) {
        cin>>a;
        A[i]=a;
    }
    long long int Sa[n+1];
    Sa[0]=0;
    for (int i=0;i<n;i++) {
        Sa[i+1]=Sa[i]+A[i];
    }
    for (int i=0;i<m;i++) {
        cin>>b;
        B[i]=b;
    }
    long long int Sb[m+1];
    Sb[0]=0;
    for (int i=0;i<m;i++) {
        Sb[i+1]=Sb[i]+B[i];
    }
    int ans=0,j=m;
    for (int i=0;i<=n;i++) {
        if (Sa[i]>k) {
            break;
        }
        while (Sb[j]>k-Sa[i]) {
            j--;
        }
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9880
#!/usr/bin/env python3
#ABC142 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
        
    return divisors

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n % m)

P = [1] + primes(10**6)
f = defaultdict(lambda : 0)
for i in P:
    f[i] = 1
a,b = LI()
A,B = make_divisors(a),make_divisors(b)
ans = 0
fa = defaultdict(lambda : 0)
fb = defaultdict(lambda : 0)

for i in A:
    fa[i] = 1
for i in B:
    fb[i] = 1

ans = 0
lst = []
p = []
for i in A:
    if fa[i] and fb[i]:
        if f[i]:
            ans += 1
            p.append(i)
        else:
            lst.append(i)
for i in lst:
    for j in p:
        if gcd(i,j) != 1:
            break
    else:
        ans += 1
print(ans)






Measured memory_bytes: 56064
#include<bits/stdc++.h>
using namespace std;
int64_t mod=1000000007;
vector<int64_t> f(2001),fi(2001);
int64_t pw(int64_t x,int64_t y){
  int64_t z;
  if(y==0) return 1;
  else{
    z=pw(x,y/2)*pw(x,y/2)%mod;
    if(y%2==1) z=z*x%mod;
    return z;
  }
}
int64_t cmb(int64_t x,int64_t y){
  int64_t z;
  z=f.at(x)*fi.at(y)%mod;
  z=z*fi.at(x-y)%mod;
  return z;
}
int main() {
  int64_t n,k,i,ans=0;
  cin>>n>>k;
  f.at(0)=1;
  fi.at(0)=1;
  for(i=1;i<=n;i++){
    f.at(i)=f.at(i-1)*i%mod;
    fi.at(i)=fi.at(i-1)*pw(i,mod-2)%mod;
  }
  for(i=1;i<=k;i++){
    if(i<=n-k+1) cout<<cmb(k-1,i-1)*cmb(n-k+1,i)%mod<<endl;
    else cout<<0<<endl;
  }
}

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

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

    String[] sl = r.readLine().split("[\\s]+");
    
    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int c = Integer.parseInt(sl[2]);

    if(a > b)
    {
      int t = a;
      a = b;
      b = t;
    }
    
    if(b > c)
    {
      int t = b;
      b = c;
      c = t;
    }
    
    if(a > b)
    {
      int t = a;
      a = b;
      b = t;
    }
    
    if(a == b && b == c)
    {
      System.out.println(0);
      System.exit(0);
    }
    
    if(b == c)
    {
      if((b - a) % 2 == 0)
      {
        System.out.println((b - a) / 2);
        System.exit(0);
      }
      else
      {
        System.out.println((b - a + 1) / 2 + 1);
        System.exit(0);
      }
    }
    
    if(a == b)
    {
      System.out.println(c - a);
      System.exit(0);
    }

    // a < b < c
    
   int v = 0;
   v += c - b;
   a += c - b;
   b += c - b;
   
   if((b - a) % 2 == 0)
   {
     System.out.println(v + (b - a) / 2);
     System.exit(0);
   }
   else
   {
     System.out.println(v + (b - a + 1) / 2 + 1);
     System.exit(0);
   }

  }
}


Measured memory_bytes: 23252
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
// lower_boundは二分探索
struct edge { int to, cost; };
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

ll binary_search(vector<int>&s,int a) {
	llint l = -1;
	llint r = (llint)s.size();
	while (r - l > 1) {
        int mid=(l+r)/2;
		if (s[mid]>=a) r = mid;
		else l = mid;
	}
	return r;
}

//remono君のコード書き換え
int main() {
	int n;
	cin >> n;
	hei(int) a(n), b(n), c(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n)cin >> b[i];
	rep(i, 0, n)cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	llint ans = 0;
	rep(i, 0, n) {
		ans += (binary_search(a, b[i]))*(n -binary_search(c, b[i]+1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int n,m;
vector<int> v;
long long int fac[1<<18];
long long int inv[1<<18];
long long int mypow(long long int x,long long int b){
	x%=mod;
	long long int res=1;
	while(b){
		if(b&1)
			res=res*x%mod;
		b>>=1;
		x=x*x%mod;
	}
	return res;
}
long long int P(int n,int m){
	if(n<m) return 0;
	return fac[n]*inv[n-m]%mod;
}
long long int dp[17][1<<16];
void add(long long int& x,long long int y){
	x=(x+y)%mod;
}
long long int cnt[1<<16];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0,x;i<m;i++){
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end(),greater<int>());
	fac[0]=1;
	inv[0]=1;
	cnt[0]=1;
	for(int i=1;i<(1<<16);i++){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=mypow(fac[i],mod-2);
		cnt[i]=(i&1)?(mod-cnt[i>>1]):cnt[i>>1];
	}
	dp[0][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<(1<<n);j++){
			if(dp[i][j]){
				add(dp[i+1][j],dp[i][j]);
				int remain=(1<<n)-j-1;
				for(int k=0;k<n;k++)
					if((1<<k)&remain)
						add(dp[i+1][j|(1<<k)],dp[i][j]*P(remain+1-v[i],(1<<k)-1)%mod*(1<<k)%mod);
			}
		}
	long long int ans=0;
	for(int i=0;i<(1<<n);i++)
		add(ans,cnt[i]*dp[m][i]%mod*fac[(1<<n)-i-1]%mod);
	ans=ans*(1<<n)%mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[101],k,ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1,greater<int>());
	for(int i=1;i<=k;i++)
	    ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

class segtree {
  struct node {
    node() {}
    long long h = 0, add = 0;
    void apply(int l, int r, long long x) {
      h -= x;
      add += x;
    }
    node(int x) : h(x) {}
  };

  node merge(const node& a, const node& b) const {
    return node();
  }

  int n;
  vector<node> t;

  void push(int v, int l, int r) {
    t[v << 1].apply(l, r, t[v].add);
    t[v << 1 | 1].apply(l, r, t[v].add);
    t[v].add = 0;
  }

  template<typename... M> void modify(int v, int tl, int tr, int l, int r, const M&... m) {
    if (l <= tl and tr <= r) {
      t[v].apply(tl, tr, m...);
      return;
    }
    if (tl > r or l > tr) {
      return;
    }
    push(v, tl, tr);
    int tm = tl + tr >> 1;
    modify(v << 1, tl, tm, l, r, m...), modify(v << 1 | 1, tm + 1, tr, l, r, m...);
    t[v] = merge(t[v << 1], t[v << 1 | 1]);
  }

  node get(int v, int tl, int tr, int l, int r) {
    if (l <= tl and tr <= r) {
      return t[v];
    }
    if (tl > r or l > tr) {
      return node();
    }
    push(v, tl, tr);
    int tm = tl + tr >> 1;
    return merge(get(v << 1, tl, tm, l, r), get(v << 1 | 1, tm + 1, tr, l, r));
  }

  node getElem(int v, int tl, int tr, int k) {
    if (tl == tr) {
      return t[v];
    }
    push(v, tl, tr);
    int tm = tl + tr >> 1;
    if (k <= tm) {
      return getElem(v << 1, tl, tm, k);
    } else {
      return getElem(v << 1 | 1, tm + 1, tr, k);
    }
  }

public:
  segtree(int _n) {
    int p = 1;
    while ((1 << p) < _n) {
      ++p;
    }
    n = 1 << p;
    t.resize(n << 1);
    for (int i = n - 1; i >= 1; --i) {
      t[i] = merge(t[i << 1], t[i << 1 | 1]);
    }
  }

  template<class T> segtree(const vector<T>& a) {
    int p = 1;
    while ((1 << p) < a.size()) {
      ++p;
    }
    n = 1 << p;
    t.resize(n << 1);
    for (int i = 0; i < a.size(); ++i) {
      t[i + n] = a[i];
    }
    for (int i = n - 1; i >= 1; --i) {
      t[i] = merge(t[i << 1], t[i << 1 | 1]);
    }
  }

  template<typename... M> void modify(int l, int r, const M&... m) {
    modify(1, 0, n - 1, l, r, m...);
  }

  node get(int l, int r) {
    return get(1, 0, n - 1, l, r);
  }

  node getElem(int k) {
    return getElem(1, 0, n - 1, k);
  }
};

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

  long long n, d, a;
  cin >> n >> d >> a;
  vector<pair<int, int>> t(n);
  for (int i = 0; i < n; ++i) {
    cin >> t[i].first >> t[i].second;
  }
  sort(t.begin(), t.end());
  vector<long long> x(n), h(n);
  for (int i = 0; i < n; ++i) {
    x[i] = t[i].first, h[i] = t[i].second;
  }
  segtree tr(h);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    long long y = tr.getElem(i).h;
    if (y > 0) {
      int j = upper_bound(x.begin(), x.end(), x[i] + 2 * d) - x.begin() - 1;
      tr.modify(i, j, (y + a - 1) / a * a);
      ans += (y + a - 1) / a;
    }
  }
  cout << ans;

  return 0;
}

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

typedef complex<double> P;
int N,M;

struct uni {
  int d[10005];
  void init(){
    memset(d,-1,sizeof( d ) );
  }
  int find( int a ){ return d[a]<0?a:(d[a]=find(d[a])); }
  void merge(int a,int b){
    a = find(a); b = find(b);
    if( a == b ) return;
    if( d[a] > d[b] ) swap(a,b);
    d[a] += d[b]; d[b] = a;
  }
  bool same(int a,int b){
    return find(a) == find(b);
  }
};

vector<P> v;
uni U;

struct edge{
  int a,b;
  double c;
  bool operator<(const edge& e) const{
    return c < e.c;
  }
};

vector<edge> E;

int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
    int x,y; cin >> x >> y;
    v.push_back( P( x, y ) );
  }
  for(int i=0;i<M;i++){
    int p,q; cin >> p >> q; p--; q--;
    E.push_back( (edge){ p, q, abs( v[p] - v[q] ) } );
  }
  sort( E.rbegin(), E.rend() );
  double res = 0.0;
  U.init();
  for(int i=0;i<M;i++){
    if( !U.same( E[i].a , E[i].b ) ){
      U.merge(E[i].a,E[i].b);
    } else {
      res += E[i].c;
    }
  }
  printf("%.3lf\n",res);
}

Measured memory_bytes: 1988
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


int main(){

	int N;
	char buf[3];
	stack<int> S;
	bool FLG = true;

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%s",buf);

		if(buf[0] == 'A'){
			S.push(1);
		}else{
			if(!S.empty()){
				S.pop();
			}else{
				FLG = false;
				break;
			}
		}
	}

	if(!S.empty())FLG = false;

	if(FLG){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 2668
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define int long long 
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;

int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 




void solve()
{
    int a,b;
    int v,w;
    int t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    if(w<v){
        int ans=abs(b-a);
        int rex=(v-w)*t;
        if(ans<=rex){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
        return;
    }
    else{
        cout<<"NO"<<endl;
    }
 return;
}


int32_t main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3612
def score(card)
  ace = 0
  min = 0
  max = 0
  card.each do |c|
    case c
    when "A"
      min += 1
      ace += 1
    when "2".."9"
      min += c.ord - "0".ord
    else
      min += 10
    end
  end
  max = min
  use = 0
  ace.times do
    if max + 10 <= 21
      max += 10
      use += 1
    end
  end
  [min, max, use]
end

n = gets.to_i
n.times do
  hand = Array.new
  hand = gets.split
  card = gets.split
  case score(hand)[1]
  when 21
    puts "blackjack"
  when 0..20
    card.each do |c|
      case score(hand)[1]
      when 0..16
        hand.push(c)
      when 17
        hand.push(c) if score(hand)[2] > 0
      else
        break
      end
    end
    if score(hand)[0] > 21
      puts "bust"
    elsif score(hand)[1] <= 21
      puts score(hand)[1]
    else
      puts score(hand)[0]
    end
  else
    puts "bust"
  end
end

Measured memory_bytes: 6120
#include <stdio.h>
int isPrime(int p) {
	int i=0;
	if(p < 2) {
		return 0;
	}	else if (p ==2) {
		return 1;
	}
		else if (p % 2 == 0) {
			return 0;
		}
		for(i = 3; i * i <=p;i+=2) {
			if(p%i==0) {
				return 0;
			}
		}
	return 1;
}


int main(void) {
	int n,p,i,cnt=0;
	
	scanf("%d",&n);
	
	for ( i = 0; i < n; i++) {
   	 scanf("%d", &p);
    if (isPrime(p)==1) {
      	cnt++;
    }
  }
 
  printf("%d\n", cnt);
  return 0;
}
 


Measured memory_bytes: 2028
import math
K=int(input())

if K%7==0:
    L=9*K//7
else:
    L=9*K

if L%2==0 or L%5==0:
    ans=-1
else:
    r=10%L
    for i in range(1,10**6+1):
        if r==1:
            ans=i
            break
        else:
            r=10*r%L
print(ans)


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

ll N, n, M, K;

int main(){
    cin >> N >>K;
    deque<ll> v{};
    priority_queue<ll> mine{};
    REP(i,N){
        ll a; cin >> a;
        v.push_back(a);
    }
    ll ans = 0;
    ll R = min(N,K);
    for(int A = 0; A <= R; ++A){
        for(int B = 0; B <= R-A; ++B){
            deque<ll> replica = v;
            int chuck = K-(A+B);
            ll sum = 0;
            REP(i,A){
                mine.push(-replica.front()); replica.pop_front();
            }
            REP(i,B){
                mine.push(-replica.back()); replica.pop_back();
            }
            while(!mine.empty() && mine.top() > 0 && chuck > 0){mine.pop();--chuck;}
            while(!mine.empty()){ sum -= mine.top() ; mine.pop();}
            ans = max(ans, sum);
        }
    }
    cout << ans;
}

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 count = 0;

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'o') {
				count++;
			}
		}
		System.out.print(700+ (count *100));
	}
}


Measured memory_bytes: 21076
#include<cstdio>
#include<algorithm>
#define MN 200001
using namespace std;
 
const int MOD=1e9+7;
int qa[MN],qb[MN],n,x,y,X,Y;
char a[MN],b[MN];
int main(){
    scanf("%s%s",a+1,b+1);
    for (int i=1;a[i];i++) qa[i]=qa[i-1]+a[i]-'A'+1;
    for (int i=1;b[i];i++) qb[i]=qb[i-1]+b[i]-'A'+1;
    scanf("%d",&n);
    while(n--){
        scanf("%d%d%d%d",&x,&y,&X,&Y);
        puts((qa[y]-qa[x-1])%3==(qb[Y]-qb[X-1])%3?"YES":"NO");
    }
}

Measured memory_bytes: 1536
W,H,x,y,r = raw_input().split(' ')
W,H,x,y,r = int(W),int(H),int(x),int(y),int(r)
 
if x-r <0 or y-r <0 or x+r >W or y+r>H:
  print "No"
else:
  print "Yes"

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

int main() {
  ll x;
  cin >> x;
  for (int a = -120; a <= 120; a++) {
    for (int b = -120; b <= 120; b++) {
      if (pow(a, 5)-pow(b, 5) == x) {
        cout << a << ' ' << b << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

int main() {
  int k,n;
  cin >> k >> n;
  int dis=0;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int x;
    cin >> x;
    vec.at(i)=x;
  }
  for(int i=0; i<n-1; i++){
    int x=vec.at(i+1)-vec.at(i);
    if (dis<x) dis=x;
  }
  if(k-vec.at(n-1)+vec.at(0)>dis) dis=k-vec.at(n-1)+vec.at(0);
  cout << k-dis << endl;
}

Measured memory_bytes: 1152
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const h = str => {
    return str.split('').map(x => {
        switch(x) {
            case 'A':
                return 1;
            case 'C':
                return 2;
            case 'G':
                return 3;
            case 'T':
                return 4;
        }
    })
    .reduce((acc, x, i) => acc + x*Math.pow(4, i+1));
}

line.slice(1, line.length-1).reduce((acc, x) => {
    const cmd = x.split(' ');
    const key = h(cmd[1]);
    switch(cmd[0]) {
        case 'insert':
            acc[key] = true;
            break;
        case 'find':
            console.log(acc[key] ? 'yes' : 'no');
            break;
    }

    return acc;
}, []);



Measured memory_bytes: 279420
program ABC104A
    implicit none
    integer(8)::R

    read(5,*)R

    if(R<1200)then
        print'(A)',"ABC"
    else if(R<2800)then
        print'(A)',"ARC"
    else
        print'(A)',"AGC"
    end if
    
end program ABC104A

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int T;
	cin >> T;
	for(int i = 0; i < T; ++i)
	{
		vector< vector<int> > data(3, vector<int>(10));
		vector<int> num(9);
		for(int i = 0; i < 9; ++i)
		{
			cin >> num[i];
		}
		vector<char> color(9);
		for(int i = 0; i < 9; ++i)
		{
			cin >> color[i];
		}
		for(int i = 0; i < 9; ++i)
		{
			if(color[i] == 'R')
			{
				data[0][num[i]]++;
			}
			else if(color[i] == 'G')
			{
				data[1][num[i]]++;
			}
			else if(color[i] == 'B')
			{
				data[2][num[i]]++;
			}
		}
		int count = 0;
		for(int i = 0; i < 3; ++i)
		{
			for(int j = 1; j <= 9; ++j)
			{
				if(data[i][j] >= 3)
				{
					++count;
					data[i][j] -= 3;
				}
			}
		}
		for(int i = 0; i < 3; ++i)
		{
			for(int j = 1; j <= 7; ++j)
			{
				while(data[i][j] >= 1 && data[i][j + 1] >= 1 && data[i][j + 2] >= 1)
				{
					++count;
					data[i][j] -= 1;
					data[i][j + 1] -= 1;
					data[i][j + 2] -= 1;
				}
			}
		}
		if(count == 3)
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 0 << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1216
from sys import stdin
input = stdin.readline
N = map(int, input().split())
L = list(map(int, input().split()))

c=0

for i in range(len(L)-2):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j] and L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:c=c+1

print(c)              

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

int main() {
    
    int n;
    cin >> n;
    int p[n];
    rep(i, n) 
        cin >> p[i];

    int min_val = 1e9;
    int ans = 0;
    for(int i = 0; i < n; i++){
        min_val = min(min_val, p[i]);
        if(min_val == p[i]){
            ans++;
        }
    }
    cout << ans << endl;
    // int ans = 0;
    // for(int i = 0; i < n; i++){
    //     int pp = p[i];
    //     bool f = false;
    //     for(int j = 0; j <= i; j++){
    //         if(pp <= p[j]){
    //             f = true;
    //         } else {
    //             f = false;
    //             break;
    //         }
    //     }
    //     if(f){
    //         ans++;
    //     }
    // }
    // cout << ans << endl;
    // return 0;
}

Measured memory_bytes: 1024
num = int(input())
ac = 0
tle = 0
wa = 0
re = 0
 
for i in range(num):
  word = input()
  if word == "AC":
    ac += 1
  if word == "TLE":
    tle += 1
  if word == "WA":
    wa += 1
  if word == "RE":
    re += 1
 
print("AC x " + str(ac)) 
print("WA x " + str(wa)) 
print("TLE x " + str(tle)) 
print("RE x " + str(re)) 

Measured memory_bytes: 9212
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, a[N], c[2], p, s, d;
int gcd(int a, int b) { return b?gcd(b, a%b):a; }
int simulate()
{
    c[0] = c[1] = 0;
    for(int i = 1; i <= n; ++i) ++c[a[i]&1];
    if(c[0]&1) return 1;
    if((~c[0]&1)&&c[1] >= 2) return 0;
    for(p = 1; p <= n&&(~a[p]&1); ++p);
    if(a[p] == 1)
    {
        for(int i = 1; i <= n; ++i) s ^= (a[i]-1)&1;
        return s;
    }
    --a[p], d = a[1]; 
    for(int i = 2; i <= n; ++i) d = gcd(d, a[i]);
    for(int i = 1; i <= n; ++i) a[i] /= d;
    return simulate()^1;
}
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    puts(simulate()?"First":"Second");
    return 0;
}

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

using namespace std;
using ll = long long;

ll next(ll n, ll k)
{
    ll num = n + n / (k - 1);
    for (ll i = 1;; i++) {
        if (num - (num / k) - 1 == n) {
            return num;
        }
        num++;
    }
}

int main()
{
    ll N, k;
    cin >> N >> k;
    ll num = 0;
    for (ll i = 2; i <= N; i++) {
        num = next(num, k);
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 3104
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int a = -1;
		int b = -1;
		for(int i=0; i<s.length; i++) {
			if(i<s.length-1 && s[i]==s[i+1]) {
				a = i+1;
				b = i+2;
				break;
			}
			if(i<s.length-2 && s[i]==s[i+2]) {
				a = i+1;
				b = i+3;
				break;
			}
		}
		System.out.println(a + " " + b);
		
		sc.close();
	}
}


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

int main()
{
    int n, k, l [50];
    int sum = 0;

    cin >> n >> k;

    for (int i = 0; i < n; i++){
        cin >> l[i];
    }

    sort(l, l + n);
    reverse(l, l + n);

    for (int i = 0; i < k; i++){
        sum += l[i];
    }

    cout << sum << endl;

    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for (int i = 0; i < b; i++) {
        for (int j = 0; j < a; j++) {
            cout << "0";
        }
        for (int j = 0; j < w - a; j++) {
            cout << "1";
        }
        cout << endl;
    }
    for (int i = 0; i < h - b; i++) {
        for (int j = 0; j < a; j++) {
            cout << "1";
        }
        for (int j = 0; j < w - a; j++) {
            cout << "0";
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100, MAXK = 100000, MOD = 1000000007;

int dp[MAXK + 2];

int main() {
	int N, K;
	cin >> N >> K;
	dp[0] = 1;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		int sum = 0;
		for(int j = K; j >= K - a; j--)
			sum = (sum + dp[j]) % MOD;
		for(int j = K; j >= 0; j--) {
			int oval = dp[j];
			dp[j] = sum;
			sum = (sum + MOD - oval) % MOD;
			if(j - a - 1 >= 0)
				sum = (sum + dp[j - a - 1]) % MOD;
		}
	}
	cout << dp[K] << endl;
}


Measured memory_bytes: 640