akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

//#include "atcoder/all"
//using namespace atcoder;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	int nn = 2*n - 1;
	if(x <= 1 || nn <= x){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	vector<int> ans(nn, 0);
	ans[n-2] = x-1;
	ans[n-1] = x;
	ans[n] = x+1;
	int cnt = 1;
	rep(i,nn){
		if(ans[i] > 0) continue;
		while(x-1 <= cnt && cnt <= x+1) ++cnt;
		ans[i] = cnt++;
	}
	rep(i,nn) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 4016
#include <stdio.h>

int main(void)
{
	char a, b, temp, cup[] = {1, 0, 0};
	while (scanf("%c,%c%*c", &a, &b) != EOF) {
		a -= 'A';
		b -= 'A';
		if (!(cup[a] == cup[b])) {
			temp = cup[a];
			cup[a] = cup[b];
			cup[b] = temp;
		}
	}
	for (a = 0; a < 3; a++)
		if (cup[a])
			printf("%c\n", a + 'A');
	return 0;
}

Measured memory_bytes: 544
using System;
using System.Collections.Generic;
using System.Linq;

namespace practice
{
    class MainClass
    {
        public static void DrawRectangle(int H,int W)
        {
            for (int y = 0; y < H; y++)
            {

                for (int x = 0; x < W; x++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }

        public static void Main(string[] args)
        {
            while (true)
            {
                List<string> input = Console.ReadLine().Split(' ').ToList();
                int H = int.Parse(input[0]);
                int W = int.Parse(input[1]);
                if (H == 0 && W == 0)
                {
                    break;
                }
                DrawRectangle(H, W); 
            }
        }
    }
}


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

int main(){
int N,X,T;
  cin >> N >> X >> T;
  if(N % X != 0){
  cout << (abs(N/X)+1) * T <<endl;
  }
  else{
  cout << N/X * T <<endl;
  }
}


Measured memory_bytes: 3584
#include <cstdio>
#include <cstring>
#include <set>
const int MAXC = 1E5+5;
char buff[MAXC]{ };
std::set<char> three;
int L;
 
int main()
{
	scanf(" %s", &buff);
	L = strlen(buff);
	// Cases: "XXY" or "XYX"
	if(buff[0]==buff[1])
		return puts("1 2"), 0;
	for(int i = 0; i+2 < L; ++i)
	{
		three.clear();
		for(int j = 0; j < 3; ++j)
			three.insert(buff[i+j]);
		if(three.size() <= 2U)
			return printf("%d %d\n", i+1, i+3) & 0;
	}
	puts("-1 -1");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int d, g;
    cin>>d>>g;
    int p[d], c[d];
    for(int i=0; i<d; i++)
        cin>>p[i]>>c[i];
    int n= g/100;
    int sol[n+1][d][d];
    int opt[n+1][d];
    int min_i= g/100;
    for(int i=0; i<d; i++)
    {
        for(int j=0; j<d; j++)
        {
            sol[0][i][j] = 0;
        }
        opt[0][i] = 0;
    }
    for(int i=0; i<=n; i++)
    {
        if(i<p[0])
        {
            opt[i][0]= 100*i;
            sol[i][0][0] = i;
        }
        else
        {
            opt[i][0]= 100*p[0] + c[0];
            sol[i][0][0] = p[0];
        }
        for(int j=1; j<d; j++)
        {
            sol[i][0][j] = 0;
        }
        if(opt[i][0]>=g && i<min_i) min_i = i;
    }
    
    bool finished = false;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<d; j++)
        {
            opt[i][j] = opt[i][j-1];
            for(int k=0; k<d; k++)
            {
                sol[i][j][k] = sol[i][j-1][k];
            }
            //find max
            for(int m=1; m<=min(p[j], i); m++)
            {
                if(opt[i][j]<opt[i-m][j-1]+ m*(j+1)*100)
                {
                    opt[i][j] = opt[i-m][j-1]+ m*(j+1)*100;
                    for(int k=0; k<d; k++)
                    {
                        sol[i][j][k] = sol[i-m][j-1][k];
                    }
                    sol[i][j][j]=m;
                }
                if(m==p[j] && opt[i][j]<opt[i-m][j-1]+ m*(j+1)*100 + c[j])
                {
                    opt[i][j] = opt[i-m][j-1]+ m*(j+1)*100 + c[j];
                    for(int k=0; k<d; k++)
                    {
                        sol[i][j][k] = sol[i-m][j-1][k];
                    }
                    sol[i][j][j]=m;
                }
            }
            if(opt[i][j]>= g && i< min_i)
            {
                min_i = i;
                finished=true;
                break;
            }
        }
        if(finished) break;
    }
    cout<<min_i<<endl;
    
	return 0;
}


Measured memory_bytes: 45568
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int q = sc.nextInt();
		long[] d = new long[k];
		for(int i=0; i<k; i++)
			d[i] = sc.nextLong();

		long[] d2 = new long[k];
		for(int i=0; i<q; i++) {
			long n = sc.nextLong();
			long x = sc.nextLong();
			long m = sc.nextLong();
			
			x = x % m;
			for(int j=0; j<k; j++)
				d2[j] = d[j] % m;
			
			long sum = x;

			long cycle = 0;
			int cycleEqual = 0;
			for(int j=0; j<k; j++) {
				cycle += d2[j];
				if(d2[j]==0)
					cycleEqual++;
			}
			sum += cycle*((n-1)/k);
			
			int leftEqual = 0;
			for(int j=0; j<(n-1)%k; j++) {
				sum += d2[j];
				cycle += d2[j];
				if(d2[j]==0)
					leftEqual++;
			}

			long ans = n-1 - (sum/m);
			ans -= cycleEqual * ((n-1)/k);
			ans -= leftEqual;

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


Measured memory_bytes: 47500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll N , K;
	cin >> N >> K;
	vector<ll> a(N+1,0),s(N+1,0),allb(N+1,0);
	FOR(i,1,N+1){
		cin >> a[i];
		s[i] = s[i-1] + max(a[i],0ll);
		allb[i] = allb[i-1] + a[i];
	}
	ll ans = -INF;
	FOR(i,1,N-K+2){
		ans = max(ans,s[N]-s[i+K-1]+s[i-1]+max(0ll,allb[i+K-1]-allb[i-1]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
num = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(num[K-1])

Measured memory_bytes: 3060
s = input()

answer = "Yes"
for i, c in enumerate(s):
    if 0 == i % 2:
        if 'R' != c and 'U' != c and 'D' != c:
            answer = "No"
            break
    else:
        if 'L' != c and 'U' != c and 'D' != c:
            answer = "No"
            break
print(answer)


Measured memory_bytes: 2940
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String[] S = new String[N];
    for (int i = 0; i < N; i++) S[i] = sc.next();
    sc.close();

    Map<String, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++)
      map.compute(S[i], (k, v) -> v == null ? 1 : v + 1);
    Integer max = Collections.max(map.values());
	List<String> list = new ArrayList<>();
    for (Map.Entry<String, Integer> entry : map.entrySet())
      if (max.equals(entry.getValue())) list.add(entry.getKey());
	Collections.sort(list);
    for (String e : list)
      System.out.println(e);
  }
}


Measured memory_bytes: 83388
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
H = inintl()

ans = 0
cnt = 0
prev = H[0]

for i in range(1,n):
    if H[i] <= prev:
        cnt += 1
        prev = H[i]
    else:
        if cnt > ans:
            ans = cnt
        cnt = 0
        prev = H[i]

if cnt > ans:
    ans = cnt

print(ans)

Measured memory_bytes: 84804
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, c;
    cin >> a >> b >> c;
    if(a < b){
        (a < c && c < b) ? Yes() : No();
    }
    else{
        (a > c && c > b) ? Yes() : No();
    }
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int M, K;
    cin >> M >> K;
    if(M == 0 && K == 0) {
        cout << 0 << " " << 0 << endl;
        return 0;
    } else if(M == 1 && K == 0) {
        cout << 1 << " " << 0 << " " << 0 << " " << 1 << endl;
        return 0;
    } else if(M >= 2 && K < (1 << M)) {
        int now = (1 << M) - 1;
        while(now >= 0) {
            if(now != K)
                cout << now << " ";
            now--;
        }
        cout << K << " ";
        now = 0;
        while(now <= (1 << M) - 1) {
            if(now != K)
                cout << now << " ";
            now++;
        }
        cout << K << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int a,b;
    cin >> a >> b;
    int k=(a+b)/2;
    if(abs(a-k)==abs(b-k)){
        cout << k << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, dp[200], cnt;
string s = "#00000", r = "AGCT";

long long solve(int ix)
{
	long long retval = dp[ix - 1];
	if (ix >= 3) {
		retval = (retval - dp[ix - 3] + MOD)%MOD;
	}
	if (ix - 3 > 0) retval = (retval + solve(ix - 3))%MOD;
	return retval;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	dp[0] = 1;
	dp[1] = 4;
	dp[2] = 16;
	dp[3] = 61;
	for (int i = 4; i <= n; i++) {
		dp[i] = (3 * dp[i - 1]) % MOD;
		dp[i] = (dp[i] - dp[i - 3] + MOD) % MOD;
		//dp[i] = (dp[i] - dp[i - 3] + MOD) % MOD;
		dp[i] = (dp[i] - solve(i - 2) + MOD) % MOD;
		if (i >= 4) {
			dp[i] = (dp[i] - dp[i - 4] + MOD) % MOD;
			dp[i] = (dp[i] - dp[i - 4] + MOD) % MOD;
			dp[i] = (dp[i] - dp[i - 4] + MOD) % MOD;
		}
		dp[i] = (dp[i] + solve(i))%MOD;
	}
	cout << dp[n] << "\n";
	//system("pause");
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}



map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0) {
        ret[2]++;
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2) {
        while (n%i == 0) {
            ret[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        ret[n]++;
    }
    return ret;
}

int main()
{
    ll N;
    cin >> N;
    ll cnt0 = 0;
    ll cnt2 = 0;
    ll cnt4 = 0;
    rep(i, N) {
        ll a;
        cin >> a;
        if (a % 4 == 0) cnt4++;
        else if (a % 2 == 0) cnt2++;
        else cnt0++;
    }
    if (cnt2 == 0) {
        if (cnt4 >= cnt0-1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (cnt4 >= cnt0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double N, K;
  cin >> N >> K;

  double ans;
  double last;
  double count;
  for(int i = 1; i<=N; i++){
    count = 0;
    for(int j=i;j<K;j*=2){
      count ++;
    }
    ans = 1/(pow(2,count));
    last += ans;
  }

  last /= N;

  cout <<fixed << setprecision(12)<< last << endl;
}

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

int main() {
  int a, b, c;
  string ans = "NO";
  cin >> a >> b >> c;
  if(a==5||a==7){
    if(b==5||b==7){
      if(b==5||b==7){
        if(a+b+c==17){
          ans = "YES";
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vc = vector<char>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N, M; cin >> N >> M;
    vll X(M);
    for(int i=0; i<M; i++){
        cin >> X[i];
    }
    sort(X.begin(),X.end());
    vll d(0);
    for(int i=0; i<M-1; i++){
        d.emplace_back(X[i+1]-X[i]);
    }
    sort(d.begin(),d.end());
    ll n = d.size();
    ll ans = 0;
    for(int i=0; i<n-N+1; i++){
        ans += d[i];
    }
    cout << ans;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0; i<(int) (x); i++)
#define PI 3.14159265359
using namespace std;

int main()
{
	int n;
	cin >> n;
	int a;
	vector<int> result;
	result.resize(n);
	rep(i, n - 1)
	{
		cin >>a;
		result[a - 1]++;
	}
	rep(i, n)
			cout << result[i] << endl;
	return 0;
}

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

int main(void)
{
  int h[100],w[100];
  int k=0;
  do{
    k = k+1;
    cin >> h[k] >> w[k];
  }while(h[k] != 0 && w[k] != 0);

  k=1;
  while(h[k] != 0 && w[k] != 0){
    for(int i=1; i<=h[k]; i++){
      for(int j=1; j<=w[k]; j++){
        if((i+j)%2==0)
          cout << "#";
        else
          cout << ".";
      };
      cout << endl;
    };
    k = k+1;
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
  int X, Y, Z ,K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X); rep(i,X) cin >> A[i];
  vector<ll> B(Y); rep(i,Y) cin >> B[i];
  vector<ll> C(Z); rep(i,Z) cin >> C[i];
  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());
  sort(C.rbegin(), C.rend());

  vector<ll> E;
  for(int i = 0; i < X; i++){
    for(int j = 0; j < Y; j++){
      ll tmp = A[i] + B[j];
      E.push_back(tmp);
    }
  }
  sort(E.rbegin(), E.rend());

  vector<ll> ans;
  for(int i = 0; i < min(K, int(E.size())); i++){
    for(int j = 0; j < Z; j++){
      ll tmp = E[i] + C[j];
      ans.push_back(tmp);
    }
  }

  sort(ans.rbegin(), ans.rend());
  for(int i = 0; i < K; i++) cout << ans[i] << endl;
  return 0;
}



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


int main()
{
	string str;
	int q;
	cin >> str >> q;

	for (int i = 0;i < q;i++) {
		string order;
		int a, b;
		cin >> order >> a >> b;

		if (order == "replace") {
			string p;
			cin >> p;

			str = str.replace(a, b-a+1, p);
		}
		else if (order == "reverse") {
			string rev;
			rev = str[b];

			for (int j = b - 1;j >= a;j--) {
				rev += str[j];
			}

			str = str.replace(a, b-a+1, rev);
		}
		else {
			cout << str.substr(a, b - a + 1) << endl;
		}
	}

    return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
 
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 
int main()
{
  string s,t;
  char q[200005],w[200005];
  ll a,b,c,x;
  c=0;
  x=1;
  cin >> s >> t;
  a=s.length();
  rep(i,a){q[i]=s[i];
           w[i]=t[i];
          }
  rep(i,a)if(q[i]>90){b=q[i];
                      rep(j,a)if(q[j]==b)q[j]=x;
                      x++;
                     }
  x=1;
  rep(i,a)if(w[i]>90){b=w[i];
                      rep(j,a)if(w[j]==b)w[j]=x;
                      x++;
                     }
  rep(i,a)if(q[i]!=w[i])c++;
  if(c==0)printf("Yes");
  else printf("No");
}


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

int main()
{
  int n, p, q;
  cin >> n;
  vector<int> P(n), Q(n), R(n);
  for (int i = 0; i < n; i++)
  {
    cin >> P.at(i);
  }
  for (int i = 0; i < n; i++)
  {
    cin >> Q.at(i);
  }
  for (int i = 1; i <= n; i++)
  {
    R.at(i - 1) = i;
  }
  int cnt = 0;
  do
  {
    if (P == R)
    {
      p = cnt;
    }
    if (Q == R)
    {
      q = cnt;
    }
    cnt++;
  } while (next_permutation(R.begin(), R.end()));
  cout << abs(p - q) << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,W,R,L,K,P,Q,X,Y,Z,N,M;
string S,T;
ll V[1000007];

int main(){
  cin >> A >> B >> C >> D;
  cout << (A+1==C ? 1 : 0) << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;


template<class T> class BinaryIndexedTree {
    int N;
    vector<T> bit;
    
    public :
    BinaryIndexedTree(int _N): N(_N),bit(N + 1,(T)0){
    }

    void add(int i,T x) {
        while (i <= N) {
            bit[i] += x;
            i += (i & -i);
        }
    }

    T sum(int i) {
        T ret = 0;
        while (i > 0) {
            ret += bit[i];
            i -= (i & -i);
        }
        return ret;
    }

    int lower_bound(T x) {
        if (x <= 0) return 0;
        int i = 0;
        int K = 1;
        while (2*K > N) K <<= 1;
        for (;K > 0; K >>= 1) {
            if (i + K <= N && bit[i + K] < x) {
                x -= bit[i + K];
                i += K;
            }
        }
        return i + 1;
    }
};

int main() {
    int N,Q; cin >> N >> Q;
    vector<int> C(N);
    rep(i,N) cin >> C[i];
    vector<int> color(N + 1,-1);
    BinaryIndexedTree<int> bit(N);

    vector<vector<P>> query(N);
    rep(i,Q) {
        int l,r; cin >> l >> r;
        --r; --l;
        query[r].emplace_back(l,i);
    }

    vector<int> ans(Q);
    rep(i,N) {
        if (color[C[i]] >= 0) {
            bit.add(color[C[i]] + 1,-1);
        }
        color[C[i]] = i;
        bit.add(i + 1,1);
        for (P &p:query[i]) {
            int l = p.first,j = p.second;
            ans[j] = bit.sum(i + 1) - bit.sum(l);
        }
    }
    rep(i,Q) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 33244
import java.util.*;

//https://beta.atcoder.jp/contests/arc102/submissions/3118322

class Edge{
	int a,b,c;
	public Edge(int a,int b,int c){
		super();
		this.a=a;
		this.b=b;
		this.c=c;
	}
	@Override
	public String toString(){
		return a+" "+b+" "+c;
	}
}

class Main{
	static int nextBit(StringBuilder str,int idx){
		int v=str.indexOf("1",idx+1);
		return v==-1?str.length()-1:v;
	}

	public static void main(String[] $){
		int L=new Scanner(System.in).nextInt()-1;
		if(L==1){
			System.out.println("2 2\n1 2 0\n1 2 1");
			return;
		}

		int n=Integer.numberOfTrailingZeros(Integer.highestOneBit(L));
		
		StringBuilder sb=new StringBuilder();
		int[]m=new int[n+1];
		
		for(int i=n;i>=0;i--){
			m[n-i]=1<<i;
			sb.append((L&(1<<i))==0?0:1);
		}

		List<Edge> ret=new ArrayList<>();

		for(int i=1;i<=n;++i){
			ret.add(new Edge(i,i+1,0));
			ret.add(new Edge(i,i+1,m[i]));
		}

		int num=0;
		for(int i=0;i<=n;++i){
			if(sb.charAt(i)=='0')
				continue;
			num+=m[i];
			ret.add(new Edge(1,nextBit(sb,i)+1,num));
		}

		System.out.println(n+1+" "+ret.size());
		ret.forEach(System.out::println);
	}
}


Measured memory_bytes: 28244
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"
#define PI 3.141592653589793

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


void bubble_sort(int a[],int N){
    int num = 0;
    REP(i,N){
        int min_idx = i;
        for(int j=i+1;j<N;++j){
            if(a[j]<a[min_idx]){ min_idx = j; }
        }
        if(i!=min_idx){ swap(a[i],a[min_idx]); num++;}
    }
    REP(i,N-1){ printf("%d ",a[i]); }
    printf("%d\n",a[N-1]);
    printf("%d\n",num);
}

int main(){
    int N; cin>>N;
    int a[N]; CINA(a,N);
    bubble_sort(a,N);
}


Measured memory_bytes: 3152
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int size = s.size();
    int sum = 0;
    for (int i = 0; i < s.size(); i++) 
	{
        if (s[i] == 'S') 
		{
            sum++;
        }
        if (s[i] == 'T') 
		{
            if (sum > 0) 
			{
                sum--;
                size -= 2;
            }
        }
    }
    cout << size << endl;
    return 0;
}



Measured memory_bytes: 3368
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String[] st;
	    while(true){
		int n = ni(sc.readLine());
		if(n==0)
		    break;
		int max=0, min=500, now;
		for(int i=0; i<n; i++){
		    now = 0;
		    st = sc.readLine().split(" ");
		    for(int j=0; j<5; j++)
			now+=ni(st[j]);
		    if(now>max) max = now;
		    if(now<min) min = now;
		}
		System.out.println(max+" "+min);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
    static int ni(String p){
	int u=0;
	for(int i=0; i<p.length(); i++)
	    u = u*10 + (int)(p.charAt(i)-'0');
	return u;
    }
}

Measured memory_bytes: 24992
def main():
    n,m = map(int, input().split())
    lim = 10 ** n
    val = [list(map(int, input().split())) for _ in range(m)]
    for i in range(10**(n-1) if n >= 2 else 0, lim):
        for j, k in val:
            j = j - 1
            l = str(i)
            if l[j] != str(k):
                break
        else:
             print(i)
             exit()
    print(-1)

if __name__ == '__main__':
    main()
    

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

int dp[MAX_CAN][MAX_CAN];

int main() {
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  REP(i, MAX_CAN){
    REP(j, MAX_CAN){
        if(i - 1 >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        if(j - 1 >= 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]);
        if(dp[i][j] < 0) continue;
        if(i + 2 < MAX_CAN && j + 1 < MAX_CAN) dp[i + 2][j + 1] = max(dp[i + 2][j + 1], dp[i][j] + 1);
        if(i + 3 < MAX_CAN)                    dp[i + 3][j]     = max(dp[i + 3][j],     dp[i][j] + 1);
      } }
  int Q; cin >>Q;
  while(Q--){
    int C, A, N, ans = 0; cin >>C >>A >>N;
    REP(i, N + 1) if(C - i >= 0 && A - i >= 0) ans = max(ans, dp[C - i][A - i] + i);
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 5092
import java.util.Scanner;
public class Main{
	
	
	private static Scanner sc=new Scanner(System.in);
	private static int dp[];
	public static int findMinCost(int arr[],int n,int k){
		if(n>=arr.length)
			return Integer.MAX_VALUE;
		if(n==arr.length-1)
			return 0;
		
		if(dp[n]!=Integer.MAX_VALUE)
			return dp[n];
		
		int cost=Integer.MAX_VALUE;
		
		for(int i=1;i<=k;i++){
			if(n+i>=arr.length)
				break;
			cost=Math.min(cost,findMinCost(arr,n+i,k)+Math.abs(arr[n+i]-arr[n]));			
		}
		dp[n]=cost;
		return cost;
	}
	
	public static void main(String []args){
		int n=sc.nextInt();
		int k=sc.nextInt();
		int arr[]=new int[n];
		dp=new int[arr.length];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();
			dp[i]=Integer.MAX_VALUE;
		}
		System.out.println(findMinCost(arr,0,k));
		// for(int i=0;i<n;i++)
		 	// System.out.print(dp[i]+" ");
		
	}
}

Measured memory_bytes: 71404
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int cs,s;string ord,st;
void op(char o){
	if(o=='A')reverse(st.begin(),st.end());
	if(o=='J')rotate(st.rbegin(),st.rbegin()+1,st.rend());
	if(o=='C')rotate(st.begin(),st.begin()+1,st.end());
	if(o=='E')swap_ranges(st.begin(),st.begin()+s/2,st.begin()+(s+1)/2);
	if(o=='P'||o=='M')rep(i,s)if('0'<=st[i]&&st[i]<='9')
	st[i]=(st[i]-'0'+(o=='P'?9:1))%10+'0';
}
int main(){
	cin>>cs;
	while(cs--){
		cin>>ord>>st;s=st.size();
		rep(i,ord.size())op(ord[ord.size()-1-i]);
		cout<<st<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int p,q,r;cin>>p>>q>>r;
    co(min(min(p+q, q+r), p+r));
}


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

int main(){
  string s;cin >> s;
  if(s == "Sunny")cout << "Cloudy" << endl;
  else if(s == "Cloudy")cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  return 0;
}


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



int main(){
    int N, K; cin >> N >> K;
    //期待値
    vector<double> E(N);

    //数値
    vector<double> P(N);

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

    //期待値計算
    for(int i=0; i<N; ++i){
        if(P[i] == 1){
            E[i] = 1.0;
        }else{
            E[i] = ((P[i]*(2.0 * 1.0 + (P[i] - 1.0)))/2.0)/P[i];
        }
    }

    double ans = 0.0;
    double tmp = 0.0;

    for(int i=0; i<K; ++i){
        tmp += E[i];
    }

    ans = tmp;

    for(int i=K; i<N; ++i ){
        tmp -= E[i-K];
        tmp += E[i]; 
        ans = max(ans, tmp);
    }


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

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

using namespace std;

int main(){

int a,b,c;
cin>>a>>b>>c;
if(a==b||b==c||c==a){
 if(a-b>0||b-c>0||c-a>0){
   cout<<"Yes";
}
else {
cout<<"No";
}
}
 else {
cout<<"No";
}


}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	char a;
	cin>>a;
	cout<<char(a+1)<<Endl;
	return 0;
} 


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

int main() {
  int R,G,B,N,n;
  cin >> R >> G >> B >> N;
  n=0;
  for(int i=0;i<=N;i+= R){
    for(int j=0;(i+j)<=N;j += G){
      if(((N-i-j)%B)==0 && (N-i-j)>=0){
        n++;
      }
    }
  }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#define int long long
using namespace std;
int re(int i){return (i/2)*2;}
int solve(int i,int j,int l){
    return re(i)+re(j)+re(l);
}
#define vel vector<long long>
#define rep(i,n) for(int i=0;i<n;i++)
signed main(void){
    int n;cin >>n;
    vel a(n);
    rep(i,n){cin >>a[i];}
    vel s=a;sort(s.begin(),s.end());
    int ans=0;
    for(int i=0;i<n;i+=2){
        int x=lower_bound(s.begin(),s.end(),a[i])-s.begin();
        ans+=(x%2);
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 505
#define ll long long 
using namespace std;
	
int n,i,j,k,s[maxn][maxn];
ll a[maxn][maxn],b[maxn][maxn],f[maxn][maxn];

ll Suma(int x,int xx,int y,int yy){
	if (x>xx||y>yy) return 0;
	return a[xx][yy]-a[x-1][yy]-a[xx][y-1]+a[x-1][y-1];
}

ll Sumb(int l,int r){
	return b[r][r]-b[r][l-1]-b[l-1][r]+b[l-1][l-1];
}
	
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		for(j=1;j<i;j++) scanf("%d",&a[i][j]);
		for(j=i+1;j<=n;j++) scanf("%d",&a[i][j]);
		for(j=1;j<=n;j++) s[i][j]=a[i][j];
	}
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) 
		b[i][j]=a[i][j]*(i<j)+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
	for(i=1;i<=n;i++) for(j=1;j<=n;j++)
		a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
	memset(f,127,sizeof(f)),f[0][0]=0;
	for(i=0;i<n;i++) for(j=0;j<=i;j++) if (f[i][j]<1e18){
		for(k=i+1;k<=n;k++)
			f[k][i]=min(f[k][i],f[i][j]+Sumb(i+1,k)+Suma(i+1,k,1,j));
	}
	ll ans=1e18;
	for(i=0;i<=n;i++) ans=min(ans,f[n][i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 8636
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <fstream>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long
	long long h, w;
	cin >> h >> w;
	if (h < w) swap(h, w);
	long long ans = 100000000000000;
		for (int i = 1;i < h;++i) {
			long long a = i * w;
			long long b = ((w + 1) / 2) * (h - i);
			long long c = (w / 2) * (h - i);
			ans = min(ans, max(a, b) - min(a, min(b, c)));
		}
		for (int i = 1;i < w;++i) {
			long long a = i * h;
			long long b = ((h + 1) / 2) * (w - i);
			long long c = (h / 2) * (w - i);
			ans = min(ans, max(a, b) - min(a, min(b, c)));
		}
		ans = min(ans, ((h + 2) / 3) * w - (h / 3)*w);
		ans = min(ans, ((w + 2) / 3) * h - (w / 3)*h);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long Q = sc.nextLong();
    long H = sc.nextLong();
    long S = sc.nextLong();
    long D = sc.nextLong();
    long N = sc.nextLong();
    long u[] = new long[3];
    u[0]=Q*4;
    u[1]=H*2;
    u[2]=S;
    Arrays.sort(u);
    long U = u[0];
    if(U*2<=D){
      System.out.println(N*U);
      return;
    }
    if(U*2>D&&N%2==0){
      System.out.println((N/2)*D);
      return;
    }
    System.out.println((N/2)*D+U);

  }
  

  
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;
#define ALL(v) (v).begin(), (v).end()

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}
bool compare_by_b(pair<int,int> a,pair<int,int> b){
    if(a.second!=b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main()
{
int X;cin>>X;
int a,b;
bool ok=false;
for(int i=-200;i<=200;i++){
    for(int j=-200;j<=200;j++){
        if(pow(i,5)-pow(j,5)==X){
            a=i;b=j;ok=true;break;
    }

    }
    if(ok)break;
}
cout<<a<<" "<<b<<endl;
 }


 
    
        






Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int K,N,a[200001],maxi=0;

int main(){
    cin >> K >> N;
    for (int i=0;i<N;i++) cin >> a[i];
    
    a[N] = K + a[0];
    int tmp_maxi;
    for(int i=1;i<N+1;i++){
        tmp_maxi = a[i] - a[i-1];
        if(tmp_maxi >= maxi) maxi = tmp_maxi;
    }
    cout << K - maxi << endl;
}

Measured memory_bytes: 1024
use std::io::stdin;
use std::process::exit;

#[allow(dead_code)]
fn input_strs() -> Vec<char> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.chars().collect(),
        Err(_) => panic!("err"),
    }
}
 
#[allow(dead_code)]
fn input_ints() -> Vec<u64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("err"),
    }
}
 
#[allow(unused_variables)]
fn solve() {
    let l = input_ints();
    let n = l[0] as usize;
    let m = l[1] as usize;

    let mut a: Vec<Vec<char>> = Vec::new();
    let mut b: Vec<Vec<char>> = Vec::new();

    for _ in 0..n {
        a.push(input_strs());
    }
    for _ in 0..m {
        b.push(input_strs());
    }

    'all: for i in 0..n-m+1 {
        'o: for j in 0..n-m+1 {
            for k in 0..m {
                for l in 0..m {
                    if a[k+i][l+j] != b[k][l] {
                        continue 'o;
                    }
                }
            }
            println!("Yes");
            exit(0);
        }
    }

    println!("No");
}
 
fn main() {
    solve();
}


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

int main()
{
    vector<int> a(4);
    int sum = 0;
    string s;
    cin >> s;
    rep(i, 4) a[i] = (int)(s[i] - '0');
    for (int t = 0; t < (1 << 4); t++)
    {
        bitset<4> b(t);
        rep(i, 4)
        {
            if (b.test(i))
            {
                sum += a[i];
            }
            else
            {
                sum -= a[i];
            }
        }
        if (sum == 7)
        {
            rep(i, 4)
            {
                cout << a[i];
                if (i != 3) if(b.test(i+1)){
                    cout << "+";
                }else{
                    cout << "-";
                }
            }
            cout << "=7";
            return 0;
        }
        sum=0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////


int main() {
    ll k, t; cin >> k >> t;
    Vl a(t);
    rep(i, 0, t) cin >> a[i];
    sort(ALL(a), greater<ll>());
    ll l = 0, r = 0;
    rep(i, 0, t){
        if(l <= r) l += a[i];
        else r += a[i];
    }
    cout << max(0LL, abs(r-l)-1) << endl;

    return 0;
}




Measured memory_bytes: 3572
#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--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,a,b;
cin>>n>>a>>b;
string s;
cin>>s;
int A=0,B=0;
rep(i,n){
    if(s[i]=='a'){
        if(A+B<a+b){
            cout<<"Yes"<<endl;
            A++;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else if(s[i]=='b'){
        if(A+B<a+b&&B<b){
            cout<<"Yes"<<endl;
            B++;
        }   
        else{
            cout<<"No"<<endl;
        } 
    }
    else{
        cout<<"No"<<endl;
    }
}
return 0;
}

Measured memory_bytes: 848
x1, y1, x2, y2 = gets.split.map(&:to_i)
dx, dy = x2-x1, y2-y1
x3 = x2 - dy
y3 = y2 + dx

dx, dy = x3-x2, y3-y2
x4 = x3 - dy
y4 = y3 + dx
puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll df(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

ll dc(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}

string s, z;
ll k;
ll sol, sol2;

int main()
{
    cin >> s;
    z += s.back();
    z += s;
    cin >> k;
    if (s.size() == 1)
        return cout << k / 2, 0;

    int i, j;
    for (i = 1; i < s.size();)
    {
        if (s[i] == s[i - 1])
            sol++, i += 2;
        else
            i += 1;
    }
    for (j = 1; j < z.size();)
    {
        if (z[j] == z[j - 1])
            sol2++, j += 2;
        else
            j += 1;
    }

    if (i == s.size())
    {
        if (j == z.size())
            cout << sol + (k - 1) * sol2;
        else
            cout << dc(k, 2) * sol + df(k, 2) * sol2;
    }
    else
        cout << sol * k;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
set<int> SET;
vector<int> g;
int main()
{
  int N, M;
  cin >> N >> M;
  FOR(i,0,M) {
    int aa, bb;
    cin >> aa >> bb;
    if(aa==1) {
      SET.insert(bb);
    }
    if(bb==N) {
      g.push_back(aa);
    }
  }
  FOR(i,0,g.size()) {
    if(SET.count(g[i])) {
      puts("POSSIBLE");
      return 0;
    }
  }
  puts("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 5368
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)

using namespace std;

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


int main()
{
	int W, H, w, h;
	cin >> H >> W >> h >> w;

	ll sum = 0;

	REP(i, H)
	{
		REP(j, W)
		{
			if ((i + 1) % h == 0 && (j + 1) % w == 0)
			{
				sum -= ((1000 * (h*w - 1)) + 1);
			}
			else
			{
				sum += 1000;
			}
		}
	}

	if (sum <= 0)
	{
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	REP(i, H)
	{
		REP(j, W)
		{
			if ((i + 1) % h == 0 && (j + 1) % w == 0)
			{
				cout << -((1000 * (h*w - 1)) + 1);
			}
			else
			{
				cout << 1000;
			}
			if (j != W - 1)cout << ' ';
		}
		cout << endl;
	}


	return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <algorithm>

using namespace std;

int T1, T2;
long long A1, A2, B1, B2;
long long da1, da2, db1, db2, diff1, diff2, suma, sumb;
long long ans;

int main()
{
    scanf("%d%d", &T1, &T2); scanf("%lld%lld%lld%lld", &A1, &A2, &B1, &B2);
    da1 = A1 * T1; da2 = A2 * T2; db1 = B1 * T1; db2 = B2 * T2;
    diff1 = da1 - db1; diff2 = da2 - db2; suma = da1 + da2; sumb = db1 + db2;
    if (suma == sumb)
    {
        printf("infinity\n");
        return 0;
    }
    if ((diff1 < 0 && sumb > suma) || (diff1 > 0 && suma > sumb))
    {
        printf("0\n");
        return 0;
    }
    ans = abs(diff1) / abs(diff1 + diff2);
    if (abs(diff1) % abs(diff1 + diff2) != 0)
    {
        printf("%lld\n", ans * 2 + 1);
    }
    else
    {
        printf("%lld\n", ans * 2);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
typedef double db;
typedef long long ll;
typedef long double ld; 
typedef vector<int> vi; 
typedef pair<int, int> pa;
typedef unsigned int uint; 
typedef unsigned long long ull;

int main() {
	char a[3];
	int n = 3;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
}
	for (int i = 0; i < 3; i++) {
		cout << a[i];
	}
	return 0;
}

Measured memory_bytes: 3588