akhauriyash/Code-Regression huggingface dataset:
using System;

class C
{
	static long[] Read() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    static void Main()
    {
        long[] n = Read(), a = Read(), b = Read(), c = new long[n[0] + 1], d = new long[n[1] + 1];
        long s = 0, j = n[1];
        for (int i = 1; i <= n[0]; i++) c[i] = c[i - 1] + a[i - 1];
        for (int i = 1; i <= n[1]; i++) d[i] = d[i - 1] + b[i - 1];
        for (int i = 0; i <= n[0]; i++)
        {
            if (c[i] > n[2]) break;
			while (d[j] > n[2] - c[i]) j--;
            s = Math.Max(s, i + j);
        }
        Console.WriteLine(s);
    }
}


Measured memory_bytes: 72532
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	
	string S;
	cin>>S;
	int mini=1000000000;
	fx(S.size()-2){
		string a=S.substr(x,3);
		int b=atoi(a.c_str());
		int h=abs(b-753);
		mini=min(mini,h);
	}
	ce(mini)
	
}


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




int main(){
    ll N, K; cin >> N >> K;
    vector<ll> H(N), DP(N+1);
    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = 1; i <= N; i++) DP[i] = 1e9;
    for(int i = 0; i < N; i++){
        ll x = DP[i];
        for(int j = 1; i+j < N && j <= K ; j++){
            DP[i+j] = min(DP[i+j], DP[i]+abs(H[i]-H[i+j])); 
        }
    }   
    cout << DP[N-1] << endl;     

}

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(br.readLine());
			sum += a[i];
		}
		br.close();

		int mod = 998244353;
		long[][] dp = new long[n + 1][sum + 1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= sum; j++) {
				dp[i + 1][j] += dp[i][j] * 2;
				dp[i + 1][j] %= mod;
				int j2 = j + a[i];
				if (j2 <= sum) {
					dp[i + 1][j2] += dp[i][j];
					dp[i + 1][j2] %= mod;
				}
			}
		}

		int sum2 = sum / 2;
		long rem = 0;
		for (int j = sum2 + 1; j <= sum; j++) {
			rem += dp[n][j];
		}
		rem *= 3;
		rem %= mod;
		long total = power(3, n, mod);
		long ans = (total - rem + mod) % mod;

		if (sum2 * 2 == sum) {
			long[][] dp2 = new long[n + 1][sum2 + 1];
			dp2[0][0] = 1;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j <= sum2; j++) {
					dp2[i + 1][j] += dp2[i][j];
					dp2[i + 1][j] %= mod;
					int j2 = j + a[i];
					if (j2 <= sum2) {
						dp2[i + 1][j2] += dp2[i][j];
						dp2[i + 1][j2] %= mod;
					}
				}
			}
			long rem2 = dp[n][sum2] - dp2[n][sum2] + mod;
			rem2 *= 3;
			rem2 %= mod;
			ans = (ans - rem2 + mod) % mod;
		}

		System.out.println(ans);
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			val = val * x % m;
		}
		return val;
	}
}


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

int main() {
    int N;
    cin >> N;
    vector<int> t(N - 1), s(N - 1), f(N - 1);
    rep(i, N - 1) cin >> t[i] >> s[i] >> f[i];

    rep(i, N) {
        ll now = 0;

        for (int j = i; j < N - 1; j++) {
            if (now <= s[j])
                now = s[j] + t[j];
            else {
                if (now % f[j] != 0)
                    now += f[j] - now % f[j];
                now += t[j];
            }
        }
        cout << now << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N,M  = map(int,input().split())
p_list=["WA"]*N
count = [0]*2
wa_count= [0]*N
for  i in range(M):
    p,s = input().split()
    p = int(p)
    if(p_list[p-1]=="WA" and s=="WA"):
        wa_count[p-1]+=1
    elif(p_list[p-1]=="WA" and s=="AC"):
        p_list[p-1]=s
        count[0]+=1 
        count[1]+=wa_count[p-1]

print(' '.join(list(map(str,count))))

Measured memory_bytes: 16596
#2019/10/10
A, B = map(int, open(0).read().split())
if A==1 and B!=1:
    print("Alice")
elif A!=1 and B==1:
    print("Bob")
elif A==1 and B==1:
    print("Draw")
else:
    print("Alice" if A>B else "Bob" if B>A else "Draw")

Measured memory_bytes: 2940
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	private static final int[] D_Y = { 0, 1, 0,-1};
	private static final int[] D_X = { 1, 0,-1, 0};

	private static final char WALL = '#';
	private static final char ROAD = '.';

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();

		String [] map  = new String [h];
		for(int i = 0; i < h; i++) {
			map[i] = sc.next();
		}

		Queue<Integer> q = new LinkedList<>();
		int ans = 0;

		for(int startY = 0; startY < h; startY++) {
			for(int startX = 0; startX < w; startX++) {
				boolean [][] isSearched = new boolean[h][w];

				if(map[startY].charAt(startX) == WALL) continue;

				q.add(startY);
				q.add(startX);
				q.add(0);
				isSearched[startY][startX] = true;

				while(!q.isEmpty()) {
					int nowY = q.poll();
					int nowX = q.poll();
					int dist = q.poll();

					for(int direction = 0; direction < D_Y.length; direction++) {
						int newY = nowY + D_Y[direction];
						if(newY < 0 || h <= newY) continue;

						int newX = nowX + D_X[direction];
						if(newX < 0 || w <= newX) continue;

						int newDist = dist+1;

						char c = map[newY].charAt(newX);

						if(isSearched[newY][newX] == false && c == ROAD) {
							q.add(newY);
							q.add(newX);
							q.add(newDist);
							isSearched[newY][newX] = true;

							ans = Math.max(ans, newDist);
						}
					}

				}


			}
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 31988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x_count = sc.nextInt();
		int y_count = sc.nextInt();

		long[] x_lines = new long[x_count];
		long[] y_lines = new long[y_count];

		long mod = (1000000000 + 7);


		for(int i = 0;i < x_count;i++){
			x_lines[i] = sc.nextLong();
		}
		for(int i = 0;i < y_count;i++){
			y_lines[i] = sc.nextLong();
		}

		long x_sum = 0,y_sum = 0;

		for(int i = 0;i < x_count;i++){
			int k = i + 1;
			x_sum += (k - 1) * x_lines[i] - (x_count - k) * x_lines[i];
			x_sum %= mod;
		}
		for(int i = 0;i < y_count;i++){
			int k = i + 1;
			y_sum += (k - 1) * y_lines[i] - (y_count - k) * y_lines[i];
			y_sum %= mod;
		}

		long sum = (x_sum * y_sum) % mod;

		System.out.println(sum);

		sc.close();
	}

}


Measured memory_bytes: 86920
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 123456789
//0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;
vector<pii> graph[2525];
int N;
vector<ll> a;
int main(){
	int N;
	cin >> N;
	vector<int> s(N);
	rep(i,N)cin>>s[i];
	sort(s.begin(),s.end());
	int sum=0;
	for(int i=0;i<N;i++)sum+=s[i];
	if(sum%10==0){
		int cnt=0;
		for(int i=0;i<N;i++){
			if(s[i]%10!=0){
				sum-=s[i];
				break;
			}else{
				cnt++;
			}
		}
		if(cnt!=N)cout<<sum<<endl;
		else cout<<0<<endl;
	}else{
		cout<<sum<<endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
signed main(){
  int H,W;
  cin>>H>>W;
  vector<bitset<52>> A(H+2);
  rep(i,1,H+1){
    rep(j,1,W+1){
      char X;
      cin>>X;
      if(X=='#')
        A[i].set(j);
    }
  }
  string ans="Yes";
  rep(i,1,H+1){
    rep(j,1,W+1){
      if(A[i].test(j)){
        if(!A[i].test(j-1)){
          if(!A[i].test(j+1)){
            if(!A[i-1].test(j)){
              if(!A[i+1].test(j)){
                ans="No";
                break;
              }
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {

	std::string s, t;

	std::cin >> s >> t;

	for (size_t i = 0; i < s.length(); i++) {
		bool flag = true;
		for (size_t j = 0; j < s.length(); j++) {
			if (s[(i + j) % s.length()] != t[j]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}

	std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
bool f[200],s[200];
int main()
{
	int n;
	int h;
	int m=0;
	scanf("%d",&n);
	char a[200];
	scanf("%s",a);
	for(int i=0;i<n;i++)
	{
		f[a[i]-'a']=true;
		memset(s,false,sizeof(s));
		for(int j=i+1;j<n;j++)
		{
			s[a[j]-'a']=true;
		}
		h=0;
		for(int j=0;j<26;j++)
		{
			if(f[j]&&s[j])
			{
				h++;
			}
		}
		m=max(m,h);
	}
	printf("%d\n",m);
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,z,cnt=0;
	cin>>a>>b;
	for(int x=0;x<=a;x++)
	{
		for(int y=0;y<=a;y++)
		{
			int z=b-(x+y);
			if((z>=0)&&(z<=a))
			{
				cnt++;
			}
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

#define MAX(a,b) ((a)>(b)?(a):(b))

using namespace std;


struct BINNODE {
	int parent;
	int degree;
	int sibling;
	int left;
	int right;

	BINNODE () { // default constructor
		parent=-1;
		degree=0;
		sibling=-1;
		left=-1;
		right=-1;
	}
};


void preorderwalk(vector<BINNODE>& node, int root) {
	if(root==-1) return;
	printf(" %d",root);
	preorderwalk(node,node[root].left);
	preorderwalk(node,node[root].right);
	return;
}

void inorderwalk(vector<BINNODE>&node, int root) {
	if(root==-1) return;
	inorderwalk(node,node[root].left);
	printf(" %d",root);
	inorderwalk(node,node[root].right);
	return;
}

void postorderwalk(vector<BINNODE>&node, int root) {
	if(root==-1) return;
	postorderwalk(node,node[root].left);
	postorderwalk(node,node[root].right);
	printf(" %d",root);
	return;
}

int main() {
	int n;
	int i;
	int id,left,right,root;
	vector<BINNODE> node;
	scanf("%d",&n);
	node.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d%d%d",&id,&left,&right);
		node[id].left=left;
		node[id].right=right;
		if(left==-1 && right==-1) {
			node[id].degree=0;
		} else if(left==-1) {
			node[id].degree=1;
			node[right].parent=id;
			node[right].sibling=-1;
		} else if(right==-1) {
			node[id].degree=1;
			node[left].parent=id;
			node[left].sibling=-1;
		} else {
			node[id].degree=2;
			node[left].parent=id;
			node[right].parent=id;
			node[left].sibling=right;
			node[right].sibling=left;
		}
	}
	for(i=0; i<n; ++i) {
		if(node[i].parent==-1) root=i;
	}
	printf("Preorder\n");
	preorderwalk(node,root);
	printf("\n");
	printf("Inorder\n");
	inorderwalk(node,root);
	printf("\n");
	printf("Postorder\n");
	postorderwalk(node,root);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2748
# 等差数列 or 例外
import sys
from collections import Counter

s = sys.stdin.readline().rstrip()
k = int(sys.stdin.readline())

ans = 0

def f(s):
    num = 0
    prev = s[0]
    counter = 1
    for letter in s[1:]:
        if prev != letter:
            num += counter // 2
            counter = 1
            prev = letter
        else:
            counter += 1
    num += counter // 2
    return num


if len(Counter(s)) == 1:
    ans = len(s) * k // 2
else:
    s1 = f(s)
    s2 = f(s+s) - s1
    ans = s1 + s2 * (k-1)

print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int n, k;
long long a[200005];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for(int i=  1; i <= n; ++i) cin >> a[i];
	sort(a + 1, a + n + 1);
	long long ans = 0;
	for(int i = 1; i <= n - k; ++i) ans += a[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string to_str(int n)
{
    string num;
    while(n > 0)
    {
        num = (char)(n % 10 + '0') + num;
        n /= 10;
    }
    return num;
}

bool is_all_seven(const string& n)
{
    for(auto c : n)
    {
        if(c != '7')
            return false;
    }
    return true;
}

int main()
{
    long long K; cin >> K;

    long long s = 0, ans = 0;
    while(true)
    {
        for(int i=0; i<10; ++i)
        {
            if(s % 10 == 7)
                break;

            if(i == 9)
            {
                cout << -1 << endl;
                return 0;
            }

            s += K;
        }
        ++ans;
        s /= 10;

        string num = to_str(s);
        if(is_all_seven(num))
        {
            ans += num.size();
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
int main()
{
    int n,a;
    scanf("%d",&n);
    a=n%10;
    if(a==2||a==4||a==5||a==7||a==9)
        printf("hon");
    else if(a==0||a==1||a==6||a==8)
        printf("pon");
    else
        printf("bon");
    return 0;
}

Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
    int a,b;
    cin >> a >> b;
    int ans = 1;
    for(int i=0;i<a;i++){
        if(ans < b){
            ans *= 2;
        }else{
            ans += b;
        }
    }
    cout << ans;
}



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

using namespace std;

typedef long long llint;

int n;
int a[101010];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int j = a[a[i]];
    if (i == j) ans++;
  }
  cout << ans / 2 << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
}

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

int main()
{
    int N;
    cin >> N;
    if (N == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    int64_t L, Lm1, Lm2;
    Lm2 = 2;
    Lm1 = 1;
    for (int i = 2; i < N + 1; i++)
    {
        L = Lm2 + Lm1;
        Lm2 = Lm1;
        Lm1 = L;
    }
    cout << L << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;


int main(){
  int a, b, c;
  cin >> a >> b >> c;

  if((a > c && c > b) || (b > c && c > a)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N = in.i();
        String[] s = new String[N];
        int[] t = new int[N];
        for(int i = 0; i < N; i++){
            String[] u = in.ss();
            s[i] = u[0];
            t[i] = Integer.parseInt(u[1]);
        }
        String X = in.s();

        for(int i = 0; i < N; i++){
            if(s[i].equals(X)){
                int ans = 0;
                for(int j = i+1; j < N; j++){
                    ans += t[j];
                }
                out.println(ans);
            }
        }
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 22612
#include<stdio.h>
int n,a,b,r,t[3000]={0};
int main()
{
	for(a=0;a<=1000;a++)
		for(b=0;b<=1000;b++)
			t[a+b]++;
	for(;~scanf("%d",&n);)
	{
		for(a=r=0;a<=2000;a++)
			if(n-a>=0&&n-a<=2000)
				r+=t[n-a]*t[a];
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long


using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);	
    cin.tie(NULL); cout.tie(NULL);
    
    string s, t; cin >> s >> t;
    
    if(s.length() == t.length()-1 && s == string(t.begin(), t.end()-1)) cout << "Yes";
    else cout << "No";
    
    return 0;
}


Measured memory_bytes: 3652
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInt >>= print . ( `mod` 1000 ) . ( 1000 - ) . ( `mod` 1000 )

Measured memory_bytes: 3844
// APC 001 B
#include <iostream>

int main() {
	int N;
	std::cin >> N;
	int *a = new int[N];
	int *b = new int[N];
	for(int i = 0; i < N; i++) {
		std::cin >> a[i];
	}
	for(int i = 0; i < N; i++) {
		std::cin >> b[i];
	}

	// すべての iにおいて、a[i] <= b[i] になればよい
	long long numAdd = 0;
	long long numCanAdd = 0;
	for(int i = 0; i < N; i++) {
		if(a[i] > b[i]) {
			numAdd += a[i] - b[i];
		}
		if(a[i] + 2 <= b[i]) {
			// 整数除
			numCanAdd += (b[i] - a[i]) / 2;
		}
	}

	if(numAdd <= numCanAdd) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 384
n,m = map(int,raw_input().strip().split())

arr = []

for i in range(n):
    arr.append(list(map(int,raw_input().strip().split())))

arr = sorted(arr)

val = 0
co = 0
for i in range(n):
    if val+arr[i][1] < m:
        co+=arr[i][1]*arr[i][0]
        val+=arr[i][1]
    else:
        co+=arr[i][0]*(m-val)
        break
print(co)


Measured memory_bytes: 23540
(n,m,p),*l=[list(map(int,s.split()))for s in open(0)];d=[0]*2+[9e99]*n
for i in range(n*2):
 for a,b,c in l:
  if d[b]>d[a]-c+p:d[b]=[d[a]-c+p,-9e99][i>n]
 if i==n:x=d[n]
print([max(-x,0),-1][d[n]!=x])

Measured memory_bytes: 47676
#include "bits/stdc++.h"
using namespace std;

int main()
{
    long long n;
    cin >> n;
    string c;
    cin >> c;

    long long p1 = 0, p2 = n - 1;
    long long ans = 0;
    while (p1 < p2)
    {
        if (c[p1] == 'W' && c[p2] == 'R')
        {
            swap(c[p1], c[p2]);
            p1++;
            p2--;
            ans++;
        }
        else if (c[p1] == 'R' && c[p2] == 'W')
        {
            p1++;
            p2--;
        }
        else if (c[p1] == 'W' && c[p2] == 'W')
            p2--;
        else if (c[p2] == 'R' && c[p2] == 'R')
            p1++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
while True:
    n = int(raw_input())
    if n == 0:
        break
    s = raw_input()
    for _ in range(n):
        l = s[0]
        count = 0
        r = ''
        for c in s:
            if c == l:
                count += 1
            else:
                r += str(count) + l
                count = 1
                l = c
        r += str(count) + l
        s = r
    print s

Measured memory_bytes: 4280
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  int a,b;
  scanf("%d %d", &a, &b);
  if (a+b == 15) {
    printf("+\n");
  } else if (a*b == 15) {
    printf("*\n");
  } else {
    printf("x\n");
  }



  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

// struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visited[MAX]; // 訪問状況


int main() {
    // input
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) {
        cin >> h[i];
    }
    // solve
    int cnt = 0;
    rep(i, n) {
        if (h[i] == 0) continue;
        while (h[i] != 0) {
            for (int l = i; l < n; l++) {
                if (h[l] == 0) break;
                h[l]--;
            }
            cnt++;
        }
    }
    cout << cnt << "\n";
    // output
}

Measured memory_bytes: 3512
#include<iostream>
#include<cstdio>
#include<limits.h>
#define SENTINEL INT_MAX
using namespace std;
typedef long l;
int n;

void Merge(char idID[],char ID[],long S[],int left,int mid,int right){
  int n1 = mid-left+1;
  int n2 = right-mid;
  l L[n1+3];
  l R[n2+3];
  char CL[n1+3];
  char CR[n2+3];

  for(int i=1;i<=n1;i++){
    L[i] = S[left+i-1];
    CL[i] = idID[left+i-1];
  }
  for(int j=1;j<=n2;j++){
    R[j]=S[mid+j];
    CR[j]=idID[mid+j];
  }
  L[n1+1]=R[n2+1]=SENTINEL;
  int i=1;
  int j=1;
  for(int k=left;k<=right;k++){
    if(L[i]<=R[j]){
      S[k]=L[i];
      idID[k] = CL[i];
      i=i+1;
    }
    else{
      S[k]=R[j];
      idID[k] = CR[j];
      j=j+1;
    }
  }
}

void Merge_Sort(char idID[],char ID[],long S[],int left,int right){
  if(left<right){
    int mid = (left+right)/2;
    Merge_Sort(idID,ID,S,left,mid);
    Merge_Sort(idID,ID,S,mid+1,right);
    Merge(idID,ID,S,left,mid,right);
  }
}




int Partition(char ID[],l A[],l p,l r){
  l x = A[r];
  l i = p-1;
  for(int j=p;j<r;j++){
    if(A[j] <= x){
      i = i+1;
      char ch = ID[i];
      ID[i] = ID[j];
      ID[j] = ch;
      l h=A[i];
      A[i] = A[j];
      A[j] = h;
    }
  }
  char ch = ID[i+1];
  ID[i+1] = ID[r];
  ID[r] = ch;
  l h = A[i+1];
  A[i+1] = A[r];
  A[r] = h;
  return i+1;
}

void Quicksort(char ID[],l A[],l p,l r){
  if(p<r){
    l q = Partition(ID,A,p,r);
    Quicksort(ID,A,p,q-1);
    Quicksort(ID,A,q+1,r);
  }
}


int main(){
  
  while(scanf("%d",&n) != EOF){
    // declare dynamic arrays
    char *ID = new char[n+2]; 
    l *A = new l[n+2];
    l *idA = new l[n+2];
    char *idID = new char[n+2];
    l k=0;
    
    for(int i=1;i<=n;i++){
      cin >> ID[i] >> A[i];
      idID[i] = ID[i];
      idA[i] = A[i];
      if(k<A[i])k=A[i];
    }
   
    // use merge_sort to create array that is able to judge whether the Quicksort is stable
    Merge_Sort(idID,ID,idA,1,n);
    // idID is stable because Merge_Sort is stable sorting algorithm
   

    // use Quicksort
    Quicksort(ID,A,1,n);

    bool stable = true;
    for(int i=1;i<=n;i++){
      if(idID[i] != ID[i])stable = false;
    }

    // judge whether the Quicksort is stable
    // if "stable" is true, the sort is stable
    if(stable)printf("Stable\n");
    else printf("Not stable\n");
    for(int i=1;i<=n;i++){
      printf("%c %ld\n",ID[i],A[i]);
    }
    
    // delete dynamic arrays
    delete [] ID;
    delete [] A;
    delete [] idID;
    delete [] idA;
  }
  return 0;
}

Measured memory_bytes: 2416
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
int dp[100010][101];
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    string n;
    int d;
    cin>>n>>d;
    dp[0][0] = 1;
    for(int i=1;i<=100000;i++)
    {
        for(int j=0;j<d;j++)
        {
            int lel = j;
            for(int k=0;k<=9;k++)
            {
                dp[i][j]+=dp[i-1][lel];
                lel--;
                if(lel<0) lel+=d;
            }
            dp[i][j]%=mod;
        }
    }
    int ans = 1e9+6, sm = 0;
    for(int i=0;i<n.size();i++)
    {
        while(n[i]!='0')
        {
            ans += dp[n.size()-i-1][(d-sm)%d];
            sm++;
            sm%=d;
            n[i]--;
        }
        ans%=mod;
    }
    if(sm==0)
        ans=(ans+1)%mod;
    cout<<ans;
    return 0;
}

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

int main() {
	int N, A;
	cin >> N;/*支払う値段*/
	cin >> A;/*持っている1円玉の枚数*/

	if ((N % 500) == 0) {/*支払う金額が500円で割り切れれば*/
		cout << "Yes" << endl;
	}
	else if ((N % 500) <= A) {/*その余りが持っている一円より少ないか*/
		cout << "Yes" << endl;
	}
	else  {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

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

            PriorityQueue<Double> pq = new PriorityQueue<Double>();
            for (int i = 0; i < N; i++) {
                pq.add((double) v[i]);
            }
            for (; pq.size() > 1;) {
                double d = pq.poll();
                double d2 = pq.poll();
                pq.add((d + d2) / 2);
            }

            System.out.println(pq.poll());
        }
    }
}


Measured memory_bytes: 27252
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=1e5+5;
int n,k,a[N],d;

void init()
{
	scanf("%d%d",&n,&k);int i;
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
	d=a[1];
	for(i=2;i<=n;++i) d=__gcd(d,a[i]);
}

void work()
{
	if(k%d) printf("IMPOSSIBLE\n"),exit(0);
	for(int i=1;i<=n;++i) if(a[i]>=k) printf("POSSIBLE\n"),exit(0);
	printf("IMPOSSIBLE\n");
}

int main()
{
	init();work();
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main() {
	list<int> L;
    list<int>::iterator cur = L.end();
	int num_query; scanf("%d", &num_query);
	int command, tmp;
	for (int loop = 0; loop < num_query; loop++) {
		scanf("%d", &command);
		switch (command) {
		case 0:
			scanf("%d", &tmp);
            cur = L.insert(cur, tmp);
			break;
		case 1:
			scanf("%d", &tmp);
            if (tmp > 0) {
				for (int i = 0; i < +tmp; i++) cur++;
			} else {
				for (int i = 0; i < -tmp; i++) cur--;
			}
			break;
		case 2:
            cur = L.erase(cur);
			break;
    	}
	}
    for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
        printf("%d\n", *it);
    }
	return 0;
}



Measured memory_bytes: 18352
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


int n, x, y, d;
vector<int> v[200005];
bool dp[200005];

int dfs(int x, int y) {
    int mx1 = 0, mx2 = 0;
    for (int i = 0; i < (int)v[x].size(); ++i) {
        int to = v[x][i];
        if (to == y) continue;
        int z = dfs(to, x);
        if (z + mx1 + 1 > d) {
            d = z + mx1 + 1;
        }
        if (z >= mx1) mx2 = mx1, mx1 = z;
        else if (z >= mx2) mx2 = z;
    }
    d = max(d, mx1 + 1);
    return mx1 + 1;
}

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i < n; ++i) {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 0);
    dp[1] = 1, dp[2] = 0;
    for (int i = 3; i <= d; ++i) {
        if (!dp[i - 1]) dp[i] = true;
        if (!dp[i - 2]) dp[i] = true;
    }
    cout << (dp[d] ? "First\n" : "Second\n");
    return 0;
}



Measured memory_bytes: 26368
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, K, X, Y);
  print(min(N, K) * X + max(N - K, 0) * Y);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>

string s;
int dp[100100][20];

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin>>s;
  dp[0][0]=1;
  rep(i,s.size()){
    int c;
    if(s[i]=='?') c=-1;
    else c=s[i]-'0';
    rep(j,13){
      rep(k,10){
        if(c!=-1&&c!=k) continue;
        dp[i+1][(10*j+k)%13]+=dp[i][j];
        dp[i+1][(10*j+k)%13]%=M;
      }
    }
  }

  cout<<dp[s.size()][5]<<endl;
  


}

Measured memory_bytes: 16080
N = int(input())
utility = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0] * 3 for _ in range(N+1)]
for i, u in enumerate(utility):
    a, b, c = u
    dp[i+1][0] = a + max(dp[i][1], dp[i][2])
    dp[i+1][1] = b + max(dp[i][0], dp[i][2])
    dp[i+1][2] = c + max(dp[i][0], dp[i][1])
print(max(dp[N]))

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

int main(){
    vector<string> week = {"MON", "TUE", "WED", "THU", "FRI", "SAT","SUN"};
    string S; cin >> S;
    int count = 0;
    for(string s : week){
        if(s == S){
            break;
        }
        count++;
    }
    if(count  == 6) cout << 7 << endl;
    else cout << 6 - count << endl;

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    string S, A="ABC";
    cin>>S;
    int ans=0;
    for(int i=0; i<=n-3; ++i){
        if(A==S.substr(i,3)) ++ans;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  long n,r,rj,ri,max;
  scanf("%ld", &n);
  scanf("%ld", &r);
  rj = r;
  ri = r;
  n--;
  max = -1000000000;
  for(; 0 < n; n--) {
    scanf("%ld", &r);
    if(max <= 0) {
      ri = rj;
      rj = r;
    }else{
      if(r > rj) rj = r;
      if(r < ri) {
	ri = r;
	rj = r;
      }
    }
    if(rj - ri > max) max = rj - ri;
  }

  printf("%ld\n", max);
  
  return 0;
}

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

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

map<string, vector<string>> data;
string startkey;

bool input(){

  data.clear();
  int n;
  cin>>n;
  if(n==0)return false;

  rep(i,n){
    string str;
    cin>>str;

    string key;
    vector<string> val;
    int keypos = 0;
    rep(j,str.size()){
      if(str[j]==':'){
	key = str.substr(0,j);
	keypos= j+1;
      }
      if(str[j]==',' || str[j]=='.'){
	val.push_back(str.substr(keypos, j-keypos));
	keypos = j+1;
      }
    }
    if(i==0)startkey = key;
    data[key]=val;
  }
  return true;
}

map<string,set<string>> memo;

set<string> rec(string key){

  if(memo.find(key)!=memo.end())return memo[key];

  set<string> ret;

  if(data[key].size()==0){
    ret.insert(key);
  }else{
    for(auto i:data[key]){
      set<string> result = rec(i);
      for(auto j:result){
	ret.insert(j);
      }
    }
  }
  return memo[key]=ret;
}

int solve(){
  memo.clear();
  // for(auto i: data){
  //   cout<<"||"<<i.first<<endl;
  //   for(auto j: i.second){
  //     cout<<j<<endl;
  //   }
  // }

  set<string> res = rec(startkey);

  // for(auto i: res){
  //   cout<<"res | "<<i<<endl;
  // }
  return res.size();
}

int main(){
  while(input())cout<<solve()<<endl;
}

Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <bitset>
#include <cstdio>
#include <sstream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <cctype>
#include <iomanip>
#include <list>
#include <cstring>

#define INF 2000000000
#define ull unsigned long long int
#define vi vector<int>
#define vii vector<ii>

#define UNVISITED 0
#define OPENED 1
#define CLOSED 2

#define PI 3.14159


using namespace std;

int aray[64];


int n, q;
int arayToTree[128];
int tree[128];

int left(int a) {
    return ( a << 1);
}

int right(int a) {
    return ((a << 1) +1);
}

int build(int node, int l, int r) {
    
    if(l == r) {
        tree[node] = aray[l];
        arayToTree[l]= node;
    }
    else {
        tree[node] =  max(build(left(node), l, (l+r)/2), build(right(node), (l+r)/2+1, r));
    }

    return tree[node];
}

int rq(int node, int l, int r, int x, int y) {

    if(l > y || r < x) return 0;

    if(l >= x && r <= y) return tree[node];

    return max(rq(left(node), l, (l+r)/2,x, y),rq(right(node), (l+r)/2+1, r, x, y));



}

int req(int x, int y) {

    return rq(1, 1, 26, x, y);

}


void updateTree(int node) {
    tree[node] = max(tree[left(node)],tree[right(node)]);
    if(node <= 1) return;
    updateTree(node/2);

}

int update(int x, int a) {
    
    aray[x] = a;
    tree[arayToTree[x]] = a,
    updateTree(arayToTree[x]/2);


}

void add(int n) {
    update(n, aray[n]+1);
}

void remove(int n) {
    update(n, aray[n]-1);
}

int main () {
    
    string s;   
    cin >> s;
    build(1, 1, 26);  

    int lower = 1, upper = 1;
   // update(s[0]-'a'+1, 1);
/*
    bool ok = false;

   while(lower <= s.size()) {
        int r = req(1, 26);

        cout << r << " " << lower << " " << upper << endl;
        if(r < (upper-lower)/2) {
            update(s[lower-1]-'a'+1, aray[(s[lower-1]-'a'+1)]-1);
            lower++;
        }
        else if(upper < s.size()-1){
            update(s[upper]-'a'+1, aray[(s[upper]-'a'+1)]+1);
            upper++;

        }
        else {
        
            update(s[lower-1]-'a'+1, aray[(s[lower-1]-'a'+1)]-1);
            lower++;
        }
        
        if(r > (upper - lower + 1)/2 && r >= 2) {
            cout << lower << " " << upper << endl;
            ok = true;
            break;
        }


    } */

    pair <int, int> sol(-1,-1);
    for(int a = 0; a < s.size(); a++) {
        for(int b= a+1; b < s.size() && b <= a + 2; b++) {

            for(int i = a; i <= b; i++) {
                add(s[i]-'a'+1);
                
            }
            
            if(req(1, 26) > (b -a+1)/2) {
                sol = make_pair(a+1, b+1);
            } 
            
            for(int i = a; i <= b; i++) {
                remove(s[i]-'a'+1);
            }
        }
    }

    cout << sol.first << " " << sol.second << endl;
   
 

    return 0;
}


Measured memory_bytes: 512
from collections import Counter
    
n = int(input())
v = list(map(int, input().split()))

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
  print(n-(a[0][1]+b[0][1]))
else:
  print(min(n-(a[0][1]+b[1][1]),n-(a[1][1]+b[0][1])))

Measured memory_bytes: 20572
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      long n = Long.parseLong(f.readLine());
      
      HashMap<Long,Long> hmap = new HashMap<Long,Long>();
      
      long MAXN = 200;
      for(long k = 0; k < MAXN; k++){
         hmap.put(k*k*k*k*k,k);
      }
      
      for(long k = 0; k < MAXN; k++){
         long a = k*k*k*k*k;
         long b5 = a-n;
         long b = -1;
         boolean neg = b5 < 0;
         b5 = Math.max(b5,-1*b5);
         if(hmap.containsKey(b5)){
            b = hmap.get(b5);
         } else {
            continue;
         }
         
         if(neg){
            b *= -1;
         }
         
         out.println(k + " " + b);
         break;
      }
      
      
      
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 36640
import bisect
A,B,Q = map(int, input().split())
INF = 10**18
ss = [-INF] + [int(input()) for _ in range(A)] + [INF]
tt = [-INF] + [int(input()) for _ in range(B)] + [INF]
xx = [int(input()) for _ in range(Q)] 
for x in xx:
    b = bisect.bisect_right(ss, x)
    d = bisect.bisect_right(tt, x)
    ans=INF
    for s in [ss[b-1], ss[b]]:
        for t in [tt[d-1], tt[d]]:
            d1 = abs(s - x) + abs(t - s)
            d2 = abs(t - x) + abs(s - t)
            ans = min(ans, d1,d2)
    print(ans)
            

Measured memory_bytes: 16144
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int S;
	cin >> S;
	vector<ll> dp(S+1, 0);
	dp[0] = 1;
	for(int i = 3; i <= S; ++i){
		for(int j = 3; j <= i; ++j){
			dp[i] += dp[i-j];
			dp[i] %= MOD;
		}
	}
	cout << dp[S] << endl;
	return 0;
}


Measured memory_bytes: 3616
import           Data.List

main :: IO ()
main = do
    _  <- fmap read getLine :: IO Int
    ls <- fmap (map read . words) getLine :: IO [Int]
    putStrLn $ if judge ls then "Yes" else "No"

judge :: [Int] -> Bool
judge ls = ma < sum res
  where
    sls = sort ls
    ma  = last sls
    res = init sls


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


using namespace std;
int main()
{

string s;
cin>>s;
int y=0;
if(s[0]=='o'){
    y+=100;
}
if(s[1]=='o'){
    y+=100;
}
if(s[2]=='o'){
    y+=100;
}
cout<<700+y<<endl;


    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from bisect import bisect_left, bisect_right
import heapq

INF = float("inf")


class ErasableHeap(object):
    # https://qiita.com/Salmonize/items/638da118cd621d2628d1
    def __init__(self):
        self.data = []
        self.event = []

    def push(self, x):
        return heapq.heappush(self.data, x)

    def erase(self, x):
        return heapq.heappush(self.event, x)

    def _check(self):
        while self.event and\
                self.data[0] == self.event[0]:
            heapq.heappop(self.data)
            heapq.heappop(self.event)

    def front(self):
        self._check()
        return self.data[0]

    def pop(self):
        self.check()
        return heapq.heappop(self.data)

    def __len__(self):
        self._check()
        return len(self.data)


def main():
    N, Q = map(int, input().split())
    XST = [0]*N
    for i in range(N):
        s, t, x = map(int, input().split())
        XST[i] = (x, s-x, t-x)
    D = [0]*Q
    for i in range(Q):
        D[i] = int(input())
    event = []
    for x, s, t in XST:
        event.append((s, 1, x))
        event.append((t, -1, x))

    event.sort()

    head = 0
    stack = ErasableHeap()
    for t, p, x in event:
        while D[head] < t:
            if len(stack) == 0:
                print(-1)
            else:
                print(stack.front())
            head += 1
            if head >= Q:
                return
        if p == 1:
            stack.push(x)
        else:
            stack.erase(x)

    while head < len(D):
        if len(stack) == 0:
            print(-1)
        else:
            print(stack.front())
        head += 1
        if head >= Q:
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 155796
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
#include <cmath>

class Node
{
public:
	int p;
	int y;
	int index;
	int no;

	Node(){};
	bool operator <(const Node & nodeObj) const
	{
		//return (p <= nodeObj.p) && (y < nodeObj.y) ;
		if (p < nodeObj.p)
		{
			return true;
		}
		else if ( p == nodeObj.p )
		{
			if (y < nodeObj.y)
			{
				return true;
			}
		}
		return false;
	}
};

bool comp1(const Node& a, const Node& b) 
{
	return (a.p <= b.p) && (a.y <= b.y);
}

bool comp(const Node& a, const Node& b) {
  
  return a.index < b.index;
}

int main(int argc, char **argv)
{
	int N, M;
	cin >> N >> M;

	std::vector<Node> city;

	for (int i = 0; i < M; i++)
	{
		Node tmp;
		cin >> tmp.p >> tmp.y;
		tmp.index = i;
		city.push_back(tmp);
	}

	sort(city.begin(), city.end());
	//sort(city.begin(), city.end(), comp1);
	/*
	for(int i = 0; i < M; i++)
	{
		cout << city[i].index << " ";
	}
	cout << endl;
	*/
	int pre_p = 0, cnt_y = 0;

	for (int i = 0; i < M; i++)
	{
		if (pre_p != city[i].p)
		{
			cnt_y = 1;
			pre_p = city[i].p;
		}
		else
		{
			cnt_y++;
		}
		
		city[i].no = cnt_y;
	}


	sort(city.begin(), city.end(), comp);

	for (int i = 0; i < M; i++)
	{
		printf("%06d%06d", city[i].p, city[i].no);
		if (i < M - 1)
		{
			printf("\n");
		}
	}

	return 0;

}

Measured memory_bytes: 3312