akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<deque>
using namespace std;
using ll = long long int;
ll x[4] = { 0,0,1,-1 };
ll y[4] = { -1,1,0,0 };

bool isValid(ll x, ll y, ll a, ll b, vector<vector<char>>& v) {
    //return x >= 0 && y >= 0 && x < a && y < b && v[x][y] == '.';
    if (x >= 0 && x < a && y >= 0 && y < b && v[x][y] == '.')
        return 1;
    else
        return 0;
}

int main() {
    ll h, w;
    cin >> h >> w;
    ll sx, sy, dx, dy;
    cin >> sx >> sy >> dx >> dy;
    sx--; sy--; dx--; dy--;
    vector<vector<char>> v(h, vector<char>(w));
    vector<vector<ll>> vis(h, vector<ll>(w, 1e6));
    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
            cin >> v[i][j];
        }
    }
    deque<pair<ll, ll>> dq;
    dq.push_front({ sx,sy });
    vis[sx][sy] = 0;

    while (!dq.empty()) {
        pair<ll, ll> pr = dq.front();
        dq.pop_front();
        for (ll i = 0; i < 4; ++i) {
            if (isValid(pr.first + x[i], pr.second + y[i], h, w, v)) {
                if (vis[pr.first + x[i]][pr.second + y[i]] > vis[pr.first][pr.second]) {
                    vis[pr.first + x[i]][pr.second + y[i]] = vis[pr.first][pr.second];
                    dq.push_front({ pr.first + x[i] , pr.second + y[i] });
                }
            }
        }
        /*for (ll i = -1; i <= 1; i++)
        {
            for (ll j = -1; j <= 1; j++)
            {
                if (abs(i + j) == 1 && isValid(pr.first + i, pr.second + j,h,w,v))
                {
                    if (vis[pr.first + i][pr.second + j] > vis[pr.first][pr.second])
                    {
                        vis[pr.first + i][pr.second + j] = vis[pr.first][pr.second];
                        dq.push_front({ pr.first + i , pr.second + j });
                    }
                }
            }
        }*/
        for (ll i = -2; i <= 2; ++i) {
            for (ll j = -2; j <= 2; ++j) {
                if (isValid(pr.first + i, pr.second + j, h, w, v)) {
                    if (vis[pr.first + i][pr.second + j] > vis[pr.first][pr.second] + 1) {
                        vis[pr.first + i][pr.second + j] = vis[pr.first][pr.second] + 1;
                        dq.push_back({ pr.first + i , pr.second + j });
                    }
                }
            }
        }
        
    }

    if (vis[dx][dy] == 1e6) {
        cout << "-1" << endl;
    }
    else {
        cout << vis[dx][dy] << endl;
    }
    return 0;
}

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

#define INF (1<<30)

int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main()
{
	int N,n,d;
	while(cin >> N, N)
	{
		int f[500][500];
	
		for(int y=0; y<500; y++)
		for(int x=0; x<500; x++)
		{
			f[y][x]=-1;	
		}		
		
		f[250][250] = 0;
		for(int i=1; i<N; i++)
		{
			cin >> n >> d;
			for(int y=0; y<500; y++)
			for(int x=0; x<500; x++)
			{
				if(f[y][x]==n)
				{
					f[y+dy[d]][x+dx[d]] = i;
				}
			}
		}
		
		int maxX=-INF,maxY=-INF,minX=INF,minY=INF;
		for(int y=0; y<500; y++)
		for(int x=0; x<500; x++)
		{
			if(f[y][x]!=-1)
			{
				maxX = max(maxX,x);
				maxY = max(maxY,y);
				minX = min(minX,x);
				minY = min(minY,y);				
			}
		}
		
		cout << maxX-minX+1 << " " << maxY-minY+1 << endl;
	}
}

Measured memory_bytes: 1840
require 'set'

class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  n = InputLine.to_i

  s = [nil] * n
  n.times do |i|
    s[i] = InputLine.to_s
  end

  puts Set.new(s).size.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 46320
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  int res=0;
  rep1(i,n){
    if(i%3==0||i%5==0)continue;
    res+=i;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
  return vector<T>(a);
}
 
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
 
  long long n, a, ans = 0;
  cin >> n;
  vector<vector<ll> > x(n), y(n);
  for(int i = 0; i < n; i++){
    cin >> a;
    long long X, Y;
    for(int j = 0; j < a; j++){
      cin >> X >> Y;
      X--;
      x[i].push_back(X);
      y[i].push_back(Y);
    }
  }
  for(ll bit = 0; bit < (1ll << n); bit++){
    long long tmp = bit;
    vector<int> honest(n);
    for(int i = 0; i < n; i++){
      honest[i] = tmp % 2;
      tmp /= 2;
    }
    bool judge = false;
    for(int i = 0; i < n; i++){
      if(honest[i] == 1){
        for(int j = 0; j < (int)x[i].size(); j++){
          if(honest[x[i][j]] != y[i][j]){
            judge = true;
          }
        }
      }
    }
    if(judge) continue;
    long long sum = 0;
    for(int i = 0; i < n; i++){
      sum += honest[i];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>
#include <iostream>
#include <map>
#include <cmath>
#include <bitset>

using namespace std;

const int CMax = 100005;

int main()
{
    int A, B, C;

    scanf("%d %d %d", &A, &B, &C);

    if (
        (A == B && C != A) ||
        (A == C && B != A) ||
        (C == B && C != A)
    ) printf("Yes\n");
    else printf("No\n");
}



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

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {
          String[] s = in.readLine().split(" ");
          int n = Integer.parseInt(s[0]);
          int k = Integer.parseInt(s[1]);

          String line = in.readLine();
          int[] a = new int[n];
          char regex = ' ';
          boolean isContinue = true;
          for(int i=0, offset=0,next=0; isContinue; i++, offset = ++next) {
            if((next = line.indexOf(regex,offset)) == -1) {
              next = line.length();
              isContinue = false;
            }
            a[i] = Integer.parseInt(line.substring(offset,next));
          }

          int ps = 0;
          for(int i=n; i>0; i--)
            ps += i;
          long[] al = new long[ps];
          // List<Long> list = new LinkedList<>();
          for(int i=0, m=0; i<n; i++) {
            long sum = 0;
            for(int j=i; j<n; j++) {
              sum += (long)a[j];
              // list.add(sum);
              al[m++] = sum;
            }
          }

          long ans = 0;
          for(int i=62;i>=0;--i) {
            long b = 1L << i;
            int cnt = 0;
            for(long v: al) {
              if(v == 0) continue;
              if( (v&b) > 0 )
                ++cnt;
              if(cnt == k) {
                ans |= b;
                // list.removeIf(e -> (e&b) == 0);
                for(int j=0; j<ps; j++) {
                  if((al[j] & b) == 0) al[j] = 0;
                }
                break;
              }
            }
          }

          System.out.println(ans);
      }
      catch(IOException e) {
        System.err.println(e);
      }
  }
}

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

int main()
{
	int w;
	int ryokin;

	while(1){
		cin >> w;
		if(w == -1) break;
		if(w <= 10) ryokin = 1150;
		else if(w <= 20) ryokin = 1150 + 125 * (w - 10);
		else if(w <= 30) ryokin = 1150 + 125 * 10 + 140 * (w - 20);
		else ryokin = 1150 + 125 * 10 + 140 * 10 + 160 * (w - 30);
		ryokin = 4280 - ryokin;
		cout << ryokin << endl;
	}


	return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
//#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007
//#define N 12
#define sz 1000*1000

 int main(){

 int n,k; cin>>n>>k;
 int a[n];
 for(int i=0;i<n;i++) cin>>a[i];

 sort(a,a+n);

  ll sum =0,ans=n;

  for(int j=n-1;j>=0;j--){
      if(sum + a[j] < k)
            sum += a[j];
      else{
            ans = j;
            }
  }

  cout<<ans<<endl;

return 0;
 }

Measured memory_bytes: 3644
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
#define vi vector<int>
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

struct s{
  int p,i,r;
};

//比較関数（降順）
bool cmpP(const s &a, const s &b){
  return a.p > b.p;
}

//比較関数（昇順）
bool cmpI(const s &a, const s &b){
  return a.i < b.i;
}

int main()
{

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

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

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
    string s;
    cin >> s;
    cout << s[0];
    s.erase(s.begin());
    cout << s.length()-1 << s[s.length()-1];
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] arg) {
    Scanner sc = new Scanner(System.in);
    int inputSec = sc.nextInt();
    sc.close();
    int h = inputSec / 60 / 60;
    int m = inputSec / 60 % 60;
    int s = inputSec % 60;
    System.out.println(h + ":" + m + ":" + s);
  }
}



Measured memory_bytes: 26280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


//条件が複数ある場合は段階に分けるのも手
int main() {

int N; cin >> N ;
string S; cin >> S ;

int r=0,g=0,b=0;

rep(i,N){
  if(S[i]=='R') r++;
  else if(S[i]=='G') g++;
  else b++;
}

ll ans=(ll)r*g*b;//まず組み合わせパターン全てを算出

ll sub=0;

rep(i,N-2){
  for(int j=i+1;j+(j-i)<N;j++){
    if(S[i]!=S[j]&&S[j]!=S[j+(j-i)]&&S[i]!=S[j+(j-i)]){
      sub++;
    }
  }
}

cout << ans-sub << endl;

return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int c[n];
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        c[--a]++;
    }

    int ccps[n+1], ccss[n+2];
    memset(ccps, 0, sizeof(ccps));
    memset(ccss, 0, sizeof(ccss));
    for (int i = 0; i < n; i++) {
        ccps[c[i]] += c[i];
        ccss[c[i]]++;
    }

    for (int i = 1; i <= n; i++) {
        ccps[i] += ccps[i-1];
    }
    for (int i = n; i >= 0; i--) {
        ccss[i] += ccss[i+1];
    }

    int j = n;
    for (int i = 1; i <= n; i++) {
        while (ccps[j] + 1ll * j * ccss[j+1] < 1ll * i * j) {
            j--;
        }
        cout << j << "\n";
    }

    return 0;
}


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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e5+5;
int r,c;

bool f(int x, int y){
  return x>=0&&y>=0&&x<r&&y<c;
}

void solve() {

  int x1,y1,x2,y2;
  cin>>r>>c;
  cin>>x1>>y1;
  cin>>x2>>y2;
  x1--,x2--,y1--,y2--;
  vvi a(r,vi(c));
  vvi d(r,vi(c,infl));
  rep(i,0,r){
    rep(j,0,c){
      char ch;
      cin>>ch;
      a[i][j]=(ch=='.');
    }
  }
  set<vi> pq;
  pq.insert({0,x2,y2});
  while(sz(pq)){
    vi v = *pq.begin();
    pq.erase(pq.begin());
    if(v[0]>=d[v[1]][v[2]])
      continue;
    d[v[1]][v[2]]=v[0];
    vi dx={0,0,1,-1}, dy={1,-1,0,0};
    rep(i,0,4){
      int x = v[1]+dx[i], y=v[2]+dy[i];
      if(f(x,y)&&a[x][y])
        pq.insert({v[0],x,y});
    }
    fr(del_x,-2,2){
      fr(del_y,-2,2){
        int x = v[1]+del_x, y=v[2]+del_y;
        if(f(x,y)&&a[x][y])
          pq.insert({v[0]+1,x,y});
      }
    }
  }
  int ans = d[x1][y1]==infl?-1:d[x1][y1];
  cout<<ans;
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}


Measured memory_bytes: 21180
IDENTIFICATION DIVISION.
PROGRAM-ID. 162A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC  X(3).
*>
PROCEDURE DIVISION.
  ACCEPT N.
  IF N(1:1) = '7' OR N(2:1) = '7' OR N(3:1) = '7' 
    DISPLAY 'Yes'
  ELSE
    DISPLAY 'No'
  END-IF.
*>
  STOP RUN.


Measured memory_bytes: 3788
# -*- coding: utf-8 -*-
# template: v1.2

import io
import sys
import math

CASES = "abcdefghijklmnopqrstuvwxyz"

def solve(s):
    # implement process
    for c in CASES:
        if s.count(c) % 2 != 0:
            return "No"
    return "Yes"

def main():
    # input
    s = input()
    
    # process
    ans = str( solve(s) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
abaccaba
"""
_EXPECTED = """\
Yes

"""

def logd(str):
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 8988
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static Scanner in;

    private static int n;
    private static int[] a;
    private static double[][][] dp;

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

        for(int i=0; i<n; i++) a[i] = in.nextInt();

        dp = new double[n+1][n+1][n+1];

        for(int i=0; i<n+1; i++) {
        	for(int j=0; j<n+1; j++) {
        		Arrays.fill(dp[i][j], -1);
        	}
        }
        
        int one=0;
        int two=0;
        int three=0;

        for(int i=0; i<n; i++) {
            switch(a[i]) {
	            case 1: one++; break;
	            case 2: two++; break;
	            case 3: three++; break;
                default:
                    break;
            }
        }

        System.out.println(solve(one, two, three));

    }

    private static double solve(int one, int two, int three) {
        if (one<0 || two<0 || three<0) return 0;

        if (one+two+three==0) return 0;

        if (dp[one][two][three]!=-1) return dp[one][two][three];

        double A = one*1.0/n*solve(one-1, two, three);
        double B = two*1.0/n*solve(one+1, two-1, three);
        double C = three*1.0/n*solve(one, two+1, three-1);

        return dp[one][two][three] = n*(1+A+B+C)/(one+two+three);

    }

}


Measured memory_bytes: 308756
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll n;

int main()
{
	scanf("%lld", &n);
	
	ll h = 1, t = n, m, ans = n;
	
	while (h <= t) {
		m = (h+t)/2;
		
		ll j = m/2LL*6LL;
		j += m/2LL*5LL;
		
		if (m%2==1)
			j+=6;
		
		if (j >= n)
			t = m-1, ans = min(ans, m);
		else
			h = m+1;
	}
	
	printf("%lld", ans);
}


///6 5 6 5

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> 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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=998244353;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

using mint = modint998244353;

struct S{
    mint a;
    int size;
};

struct F{
    mint c, d;
};

S op(S l, S r){
    return S{l.a + r.a, l.size + r.size};
}

S e(){
    return S{0, 0};
}


S mapping(F f, S x){
    return S{x.a * f.c + x.size * f.d, x.size};
}

F composition(F l, F r){
    return F{r.c * l.c, r.d * l.c + l.d};
}

F id(){
    return F{1, 0};
}

int main(){
    int n,q;cin >> n >> q;
    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        int x;cin >> x;
        a[i] = S{x, 1};
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    while(q--){
        int t;cin >> t;
        if(t == 0){
            int l,r,c,d;cin >> l >> r >> c >> d;
            seg.apply(l, r, F{c, d});
        }
        else{
            int l,r;cin >> l >> r;
            cout << seg.prod(l, r).a.val() << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 19324
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  int p = s.rfind("FESTIVAL");

  for (int i = 0; i < p; ++i) {
    putchar(s[i]);
  }
  putchar(LF);

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int x;
  cin >>x;
  if(x<1200) {
cout << "ABC" << endl;
  }
else {
cout << "ARC" << endl;
}
}

Measured memory_bytes: 256
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;


#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define  pi               acos(-1)

map<string,int>v;
int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll x=n%k;
    ll y=abs((n/k+1)*(k)-n);
    //cout<<x<<" "<<y<<endl;
    cout<<min(x,y)<<endl;
    End
}
/* pray for me
Do before die
*/


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

using namespace std;

int main()
{
	int n;
	long long a[87];
	a[0] = 2;
	a[1] = 1;
	
	cin >> n;
	
	for (int i = 2; i <= n; i++)
		a[i] = a[i-1]+a[i-2];
		
	cout << a[n];
}

Measured memory_bytes: 256
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)


int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,j=0,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     string s,sm="ABC";
     cin>>s;
     if(s==sm){
        cout<<"ARC"<<endl;
     }
     else{
        cout<<sm<<endl;
     }

     return EXIT_SUCCESS;
}



Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n;
std::string a[3];

signed main(){
	scanf("%ld", &n);
	for(int i = 0; i < 3; i++){
		std::cin >> a[i];
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		int flag = 0;
		for(int j = 0; j < 3; j++){
			if(a[j][i] == a[(j+1)%3][i]){
				flag++;
			}
		}
		if(flag == 0){
			ans += 2;
		}else if(flag == 1){
			ans += 1;
		}
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=105;
int n,k,d[MAXN],a[MAXN][MAXN];
bool vis[MAXN];

int main()
{
    read(n); read(k);
    for (register int i=1;i<=k;++i)
    {
        read(d[i]);
        for (register int j=1;j<=d[i];++j)
        {
            read(a[i][j]);
            vis[a[i][j]]=true;
        }
    }
    int ans=0;
    for (register int i=1;i<=n;++i)
        if(!vis[i]) ++ans;
    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll  unsigned long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
ll  a[100010],b[100010],c[100010];
ll  n;
ll  ans=0;
int main()
{

    cin>>n;
    n++;
    for(long long int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    b[1]=1,c[n]=a[n];
    for(long long int i=2;i<=n;i++)
    {
        b[i]=(b[i-1]-a[i-1])*2;
    }
    for(long long int i=n-1;i>=1;i--)
    {
        c[i]=c[i+1]+a[i];
    }
    for(long long int i=1;i<=n;i++)
    {
        ans+=min(b[i],c[i]);
    }
    for(long long int i=1;i<=n;i++)
    {
        if(a[i]>b[i])
        {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5964
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
//#include <search.h>
#include <algorithm>
//#include <vector>
using namespace std;
int main()
{
 int n,arr[100],m,a,b;
 long long int sum=0;
 cin>>n;
 for(int i=0;i<n;++i){
    cin>>arr[i];
 }
 cin>>m;
 while(m--){
    sum=0;
    cin>>a>>b;
    for(int i=0;i<n;++i){
      if(i==a-1) sum+=b;
      else sum+=arr[i];
    }
    cout<<sum<<endl;
 }


return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long int a[1000], b[1000], c[1000], d[1000000],dd[1000000],e[3000000];

int main() {


	int x, y, z, k;
	cin >> x >> y >> z >> k;
	int i,j,l;
	for (i = 0; i < x; i++) {
		cin >> a[i];
	}
	for (i = 0; i < y; i++) {
		cin >> b[i];
	}
	for (i = 0; i < z; i++) {
		cin >> c[i];
	}
	l = 0;
	for (i = 0; i < x; i++) {
		for (j = 0; j < y; j++) {
			d[l] = a[i] + b[j];
			l++;
		}
	}
	sort(d, d + x * y);
    //for(i = 0;i<x*y;i++){
    //  cout << d[i] << ' ';
    //}
  //cout << endl;
	for (i = 0; i < k; i++) {
		if (i >= x * y)break;
		dd[i] = d[x * y - i - 1];
	}
	int maxd;
	if (k < x * y) {
		sort(dd, dd + k);
		maxd = k;
	}
	else {
		sort(dd, dd + x * y);
		maxd = x * y;
	}
  //for(i=0;i<maxd;i++){
  //  cout << dd[i] << ' ';
  //}cout << endl;
	l = 0;
	for (i = 0; i < maxd; i++) {
		for (j = 0; j < z; j++) {
			e[l] = dd[i] + c[j];
          l++;
		}
	}
	sort(e, e + maxd * z);
  //for(i=0;i<maxd*z;i++){
  //  cout << e[i] << ' ';
  //}cout << endl;
	for (i = 0; i < k; i++) {
		cout << e[maxd * z - 1 - i] << endl;
	}
	return 0;


}

Measured memory_bytes: 34888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

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 = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        long[] ans = new long[N];
        
        int p = 1;
        for(int i = 0; i < N; i++){
            ans[0] += A[i] * p;
            p *= -1;
        }
        
        for(int i = 1; i < N; i++){
            ans[i] += ans[i-1] * -1 + 2 * A[i-1];
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < N; i++){
            sb.append(ans[i]);
            if (i != N) sb.append(" ");
        }
        
        System.out.println(sb);
        
    }
}


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


int main(){
	int n;
	cin >> n;
	n%=100;
	n%=10;
	if(n==3) cout << "bon" << endl;
	else if(n==2 || n==4 || n==5 || n==7 || n==9) cout << "hon" << endl;
	else cout << "pon" << endl;
	return 0;
}

Measured memory_bytes: 3596
while 1:
        try:
                a, b = map(int,raw_input().split())
        except EOFError:
                break
        ac, bc = a, b
        while 1:
                if a < b:
                        b = b - a
                elif b < a:
                        a = a - b
                elif a == b:
                        x = [a,ac*bc/a]
                        print "{:.10g} {:.10g}".format(*x)
                        break

Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,s,e) for(ll i=s;i<e;++i)

int main()
{
    int a,b;
    double h,m;
    cin >> a >> b >> h >> m;

    h=M_PI/6*(h+m/60);
    m=M_PI*m/30;

    double th=(max(h,m)-min(h,m));

    double c = sqrt(a*a+b*b-2*a*b*cos(th));

    cout << setprecision(20) << c << endl;

    return 0;
}

Measured memory_bytes: 4076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		String air = s.nextLine();
		String c = s.nextLine();
		int ans = 0;

		int a = 0;
		int b = 0;
		int now = 0;

		//全部Wにするとき
		for(int i=0; i<n; i++) {
			if(c.charAt(i) == 'R') {
				a++;
			}
			ans = a;
		}

		//端からRを増やしていくとき
		for(int i=0; i<n; i++) {
			if(c.charAt(i) == 'R') {
				a--;
			}else {
				b++;
			}
			now = Math.max(a, b);
			ans = Math.min(now, ans);
		}

		System.out.println(ans);

	}

}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    string S;
    cin >> S;

    if(S.length() % 2 != 0){
        cout << "No" << endl;
        return 0;
    }else{
        for(ll i = 0; i < S.length(); i+=2){
            if(S[i] == 'h' && S[i+1] == 'i'){

            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    // if(true){
    //     cout << "Yes" << endl;
    // }else{
    //     cout << "No" << endl;
    // }


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
struct A
{
	int length;
};
struct B
{
	bool in;
	bool bo;
};
A rope[100100];
B note[100100];
int ans[100100];
int pa=0;
int cnt=0;
int main()
{
	int n,limit;
	bool fl=false;
	scanf("%d%d",&n,&limit);
	for(int i=1;i<=n;i++)
		scanf("%d",&rope[i].length);
	for(int i=1;i<=n-1;i++)
		if(rope[i].length+rope[i+1].length<limit)
			note[i].bo=true;
		else
			fl=true;
	if(!fl)
	{
		printf("Impossible");
		return 0;
	}
	bool bo1,bo2;
	for(int i=1;i<=n-1;i++)
		if(!note[i].bo)
		{
			ans[pa]=i;
			pa++;
			cnt++;
			bo1=true;
			bo2=true;
			for(int j=1;bo1||bo2;j++)
			{
				if(bo1&&!note[i+j].in&&note[i+j].bo&&i+j<=n-1)
				{
					ans[pa]=i+j;
					pa++;
					cnt++;
					note[i+j].in=true;
				}
				else
					bo1=false;
				if(bo2&&!note[i-j].in&&note[i-j].bo&&i-j>=1)
				{
					ans[pa]=i-j;
					pa++;
					cnt++;
					note[i-j].in=true;
				}
				else
					bo2=false;
			}
		}
	if(cnt<n-1)
	{
		printf("Impossible");
		return 0;
	}
	printf("Possible\n");
	for(int i=pa-1;i>=0;i--)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 1792
N,M,Q=map(int,input().split(' '))
abcd = [list(map(int,input().split(' '))) for i in range(Q)]
def bfs(n,l):
    if n==N:
        res = 0
        for i in abcd:
            a,b,c,d=i
            if l[b-1]-l[a-1]==c:
                res += d
        return res
    else:
        return max([bfs(n+1,l+[i]) for i in range(l[-1],M+1)])
ans = 0
for i in range(1,M+1):
    ans = max(ans,bfs(1,[i]))
print(ans)

Measured memory_bytes: 9172
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;

  sc.scan(N);

  int[] p = new int[N];

  int sum = 0;
  foreach (i; 0 .. N)
    sc.scan(p[i]);

  sort(p);
  reverse(p);

  sum += p[0] / 2;
  foreach (i; 1 .. N)
    sum += p[i];

  writeln(sum);
}


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

int main(void)
{
    ll N, Q;
    cin >> N >> Q;
    vector<vector<ll>> G(N);
    vector<ll> value(N);
    rep(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, Q)
    {
        ll p, x;cin >> p >> x;p--;
        value[p] += x;
    }

    auto solve = [&](auto solve, ll n, ll p) -> void {
        for (auto v : G[n])
            if (v != p)
            {
               value[v] += value[n];
                solve(solve, v, n);
            }
        return;
    };

    solve(solve, 0, -1);
    rep(i, N)
    {
        if (i > 0)
            cout << " ";
        cout << value[i];
    }
    cout << endl;
}

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

int main() {
  int A,B,C,K,ans=0;
  cin >> A >> B >> C >> K;

  if (K <= A) {
    ans += K;
  } else if (K<= A+B) {
    ans += A;
  } else if (K<= A+B+C) {
    ans += A;
    ans -= K-(A+B);
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#define maxn 55
#include<algorithm>
int a[maxn];
int f[maxn];


int open()
{
    freopen("datain.txt","r",stdin);
    freopen("dataout.txt","w",stdout);
}

int main(void)
{
   // open();
    int n,m,s,i,j,k,ma;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(i=0;i<n;i++)
            scanf("%d",&a[i]);
        std::sort(a,a+n);
        for(i=n-1,s=0;i>=n-m;i--)
            s+=a[i];
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>s[i][j];
        }
    }
    cout<<s[0][0]<<s[1][1]<<s[2][2]<<'\n';
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    c=SI()
    if ord(c)>=97:print("a")
    else:print("A")

main()

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

using namespace std;

int main() {
   ios_base :: sync_with_stdio(0);
   cin.tie(0) , cout.tie(0);
   int n;
   cin >> n;
   vector<vector<pair<int , int> > > persons(n + 1 , vector<pair<int , int> >());
   for (int i = 1; i <= n; i++) {
      int t;
      cin >> t;
      persons[i].push_back({0 , 0});
      for (int j = 1; j <= t; j++) {
         int p , x;
         cin >> p >> x;
         persons[i].push_back({p , x});
      }
   }
   vector<int> bin(n + 1 , 0);
   int ans = 0;
   while (!bin[n]) {
      bin[0]++;
      for (int i = 0; i < n; i++) {
         if (bin[i] >= 2) {
            bin[i + 1]++;
            bin[i] = 0;
         }
      }
      bool ok = true;
      int sum = 0;
      for (int i = 1; i <= n && ok; i++) {
         if (!bin[i - 1]) {
            continue;
         }
         sum++;
         for (int j = 1; j < (int)persons[i].size() && ok; j++) {
            int p = persons[i][j].first , x = persons[i][j].second;
            if (bin[p - 1] && x == 0) {
               ok = false;
            }
            if (!bin[p - 1] && x == 1) {
               ok = false;
            }
         }
      }
      if (ok) {
         ans = max(ans , sum);
      }
   }
   cout << ans << '\n';
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

const int MAX = 3000;
int a[MAX][MAX], p[MAX][MAX], h[MAX][MAX], w[MAX][MAX];
signed main(){
	int H, W, q;
	scanf("%lld%lld%lld", &H, &W, &q);
	rrep(i,H){
		string str;
		cin >> str;
		rrep(j,W)a[i][j] = str[j-1]-'0';
		rrep(j,W)p[i][j] = a[i][j];
	}
	
	rrep(i,H)rrep(j,W)p[i][j] += p[i][j-1];
	rrep(i,H)rrep(j,W)p[i][j] += p[i-1][j];
	rrep(i,H)rrep(j,W){
		h[i][j] += h[i-1][j];
		if(a[i][j] and a[i-1][j])h[i][j]++;
	}
	rrep(i,H)rrep(j,W)h[i][j] += h[i][j-1];
	rrep(i,H)rrep(j,W){
		w[i][j] += w[i][j-1];
		if(a[i][j] and a[i][j-1])w[i][j]++;
	}
	rrep(i,H)rrep(j,W)w[i][j] += w[i-1][j];
	
	rep(i,q){
		int x[2], y[2];
		rep(j,2)scanf("%lld%lld", &y[j], &x[j]);
		x[0]--;y[0]--;
		int ps = p[y[1]][x[1]]+p[y[0]][x[0]]-p[y[1]][x[0]]-p[y[0]][x[1]];
		int hs = h[y[1]][x[1]]+h[y[0]+1][x[0]]-h[y[1]][x[0]]-h[y[0]+1][x[1]];
		int ws = w[y[1]][x[1]]+w[y[0]][x[0]+1]-w[y[1]][x[0]+1]-w[y[0]][x[1]];
		printf("%lld\n", ps-hs-ws);
	}
	
	/*printf("\n");
	rrep(i,H){
		rrep(j,W)printf("%lld ", h[i][j]);
		printf("\n");
	}*/
	return 0;
}







Measured memory_bytes: 169344
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  bool flag1 = false;
  bool flag2 = false;
  for(int i = 0; i < s.size(); i++)
  {
    if(!flag1 && s[i] == 'C' && s[i] != 'F') {
      flag1 = true;
    }
    if(flag1 && s[i] == 'F') {
      flag2 = true;
    }
  }
  if(flag2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<int> X(M);
    for (int i = 0; i < M; i++)
    {
        std::cin >> X[i];
    }

    std::sort(X.begin(), X.end());
    std::vector<int> sub(M - 1);
    for (int i = 0; i < M - 1; i++)
    {
        sub[i] = X[i + 1] - X[i];
    }

    std::sort(sub.begin(), sub.end());

    int ans = 0;
    for (int i = 0; i < M - N; i++)
    {
        ans += sub[i];
    }

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

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

int N;
string A[3];

signed main(void) {
	cin >> N;
	rep(i, 3) {
		cin >> A[i];
	}
	
	string tmp;
	int ans = 0;
	rep(i, N) {
		tmp = "";

		rep(j, 3) {
			if (j==0) {
				tmp += A[j][i];
			} else {
				bool find = false;
				rep (k, tmp.length()) {
					if (tmp[k] == A[j][i]) {
						find = true;
					}
				}
				if (!find) {
					tmp += A[j][i];
				}
			}
		}

		ans += tmp.length()-1;

	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


int solve(int T, int L, int D) {;
    vector<int> time(200005);
    int ret = 0;
    for (int i = 1; i <= T; i++) {
        int x; cin >> x;
        if (x >= D) {
            time[i]++;
            time[i+L]--;
        }
    }
    for (int i = 1; i <= T; i++) {
        time[i] += time[i-1];
    }
    for (int i = 1; i < T; i++) {
        if (time[i] > 0) {
            ret++;
        }
    }
    return ret;
}

int main(){
    int T, L, D;
    vector<int> ans;
    while (1) {
        cin >> T >> L >> D;
        if (!T && !L && !D) break;
        ans.push_back(solve(T, L, D));
    }
    for (auto &i: ans) {
        cout << i << endl;
    } 
}





Measured memory_bytes: 3848
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC134
{
    class Program2
    {
        static void Main()
        {
            // D*2+1見れる
            var input = Console.ReadLine().Split(' ').Select(int.Parse);
            Console.WriteLine((int)Math.Ceiling((double)input.First() / (input.Skip(1).First() * 2 + 1)));
        }
    }
}


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

using ll = long long;
const int MOD = (int) 1e9 + 7;

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

    unsigned long N, X;
    cin >> N >> X;

    ll S[N];
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }
    sort(S, S +N);

    vector<vector<ll> > dp(N + 1, vector<ll>(X + 1, 0));
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= X; ++j) {
            if (i == 0) {
                dp[i][j] = j;
            } else {
                dp[i][j] = 0;
            }
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= X; ++j) {
            dp[i + 1][j] += dp[i][j % S[i]];
            dp[i + 1][j] %= MOD;
            dp[i + 1][j] += dp[i][j] * i % MOD;
            dp[i + 1][j] %= MOD;
        }
    }

    cout << dp[N][X] << '\n';

    return 0;
}


Measured memory_bytes: 158592
#include <iostream>

using namespace std;

int main() {
	int L;
    while(1){
        cin>>L;
        if(!L)break;
        
        int A[12],M,N;
        for(int i=0;i<12;i++){
            cin>>M>>N;
            A[i] = M-N;
        }
        
        int sum=0;
        for(int i=0;i<13;i++){
            if(i == 12){
                cout<<"NA"<<endl;
                break;
            }
            sum += A[i];
            if(sum >= L){
                cout<<i+1<<endl;
                break;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1e9+7;
typedef pair<ll,ll> P;
ll n,m;
ll dp[100005];
int main(){
    cin >> n >> m;
    ll s;
    bool floor[100005] = {0};
    rep(i,m){
        cin >> s;
        floor[s] = true;
    }
    dp[0] = 1;
    if (floor[1]) dp[1] = 0;
    else dp[1] = 1;
    FOR(i,2,n+1){
        if (floor[i]) dp[i] = 0;
        else{
            dp[i] = (dp[i-1]+dp[i-2])%MOD;
        }
    }
    PRINT(dp[n]);
}


Measured memory_bytes: 1152
"""
aを10^3くらいまででいいよね
"""
# print(19**5-10**5)
x = int(input())
# a>0 b>0のとき
for i in range(10**3):
    for j in range(i+1,10**3):
        if j ** 5 - i ** 5 == x:
            print(j,i)
            exit()
# a>0, b<0のとき
for i in range(10**3):
    for j in range(10**3):
        if i**5 + j**5 == x:
            print(i,-j)
            exit()
            

Measured memory_bytes: 65880