akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];

    vector<ll> C, X, Y;
    map<ll, int> mp;
    mp[0] = 0;
    C.push_back(0LL);
    X.push_back(0LL);
    Y.push_back(0LL);
    ll max_v = 0;
    for (int i = 0; i < N; ++i) {
        if (max_v < a[i]) {
            max_v = a[i];
            C.push_back(a[i]);
            mp[a[i]] = i + 1;
            X.push_back(0LL);
            Y.push_back(1LL);
//            Y[mp[a[i]]]++;
        } else {
            int it = lower_bound(all(C), a[i]) - C.begin();
            X[it] += a[i] - C[it - 1];
            Y[it - 1]++;
        }
    }
    for(int i = Y.size() - 1; i > 0;i--){
        Y[i-1] += Y[i];
    }

    vector<ll> ans(N + 1,0ll);

    for (int i = 1; i < C.size(); i++) {
        ans[mp[C[i]]] = Y[i] * (C[i] - C[i - 1]) + X[i];
    }

    rep(i,0,N){
        cout << ans[i+1] << endl;
    }


    return 0;
}


Measured memory_bytes: 11100
s = input()
n = len(s)
dp = [0 for _ in range(n)]
dp[-1] = int(s[-1])
cnt_dic = {}
tmp = 1
ans = 0
cnt_dic[0] = 1
cnt_dic[dp[-1]] = 1
for i in range(n-2, -1, -1):
    dp[i] = (dp[i+1] + int(s[i]) * pow(10, n-i-1, 2019)) % 2019
    if not dp[i] in cnt_dic:
        cnt_dic[dp[i]] = 0
    ans += cnt_dic[dp[i]]
    cnt_dic[dp[i]] += 1

print(ans)

Measured memory_bytes: 86744
{-# LANGUAGE BangPatterns     #-}
{-# LANGUAGE FlexibleContexts #-}
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State
import           Control.Monad.Trans.State
import           Data.Array.IArray
import           Data.Array.ST
import           Data.Array.Unboxed        (UArray)
import qualified Data.Array.Unboxed        as U
import           Data.Bits
import           Data.ByteString.Char8     (ByteString)
import qualified Data.ByteString.Char8     as BS
import           Data.Char
import           Data.Graph
import           Data.Int                  (Int64)
import           Data.List
import           Data.Maybe
import           Data.Proxy
import           Data.Sequence             (Seq, (<|), (><), (|>))
import qualified Data.Sequence             as Seq
import qualified Data.Set                  as S
import           Data.STRef
import qualified Data.Vector               as V
import qualified Data.Vector.Unboxed       as VU
import           Numeric

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- group . sort <$> readLnAsListWith unconsInt

  print $ sum $ map (\xs -> let l = length xs
                                h = head xs
                            in case compare l h of
                                 GT -> l - h
                                 EQ -> 0
                                 LT -> l) as





-- converter
unconsChar :: StateT BS.ByteString Maybe Char
unconsChar = StateT BS.uncons

unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

unconsInteger :: StateT BS.ByteString Maybe Integer
unconsInteger = StateT $ BS.readInteger . BS.dropWhile isSpace

-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith st = unfoldr (runStateT st) <$> BS.getLine

-- for unboxed vector
readLnAsUVecNWith :: VU.Unbox a => Int -> StateT BS.ByteString Maybe a -> IO (VU.Vector a)
readLnAsUVecNWith !n !st = VU.unfoldrN n (runStateT st) <$> BS.getLine

-- for boxed vector
readLnAsVecNWith :: Int -> StateT BS.ByteString Maybe a -> IO (V.Vector a)
readLnAsVecNWith !n !st = V.unfoldrN n (runStateT st) <$> BS.getLine

getAsString :: IO [String]
getAsString = map BS.unpack . BS.words <$> BS.getLine

getAsCharArray1DWithLength :: IO (Int, UArray Int Char)
getAsCharArray1DWithLength = BS.getLine >>= \ !cs ->
  let !n = BS.length cs
      !ary = (U.listArray (1,n) $ unfoldr BS.uncons cs) :: UArray Int Char
  in return (n, ary)

-- n: number of lines
-- m: number of chars per a line
getAsCharArray2D :: Int -> Int -> IO (UArray (Int,Int) Char)
getAsCharArray2D !n !m = U.listArray ((1,1),(n,m)) . unfoldr BS.uncons . BS.concat <$> replicateM n BS.getLine


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

int main()
{
	long long q , h , s , d, n;
	cin >> q >> h >> s >> d >> n;
	d = min( d , min( 2LL * s , min( 4LL * h , 8LL * q )));
	s = min( s , min( 2LL * h , 4LL * q ));
	h = min( h , 2LL * q );
	long long ans = 0;
	if( n % 2 == 0 ){
		ans = n / 2 * d;
	}
	else{
		ans = n / 2 * d;
		ans += s;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	string S;
	cin >> S;
	rep1(i, 4) {
		if (S[i] == S[i - 1]) {
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n; cin >> n;
  string s; cin >> s;
  
  if(n%2) {
    cout << "No" << endl;
  } else {
    for(int i=0;i<n/2;++i) {
      if(s[i] != s[i+n/2]) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
# coding:utf-8

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
word = list(set(s))
ans = 0

for w in word:
    ans = max(ans, s.count(w) - t.count(w))

print(max(0, ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define read(x) scanf("%d",&x)
using namespace std;
const int maxn = 1e3 + 10;

int n;
int b[maxn];
int a[maxn], c[maxn];

int main()
{   
	cin>>n;
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i++) read(b[i]);
	for(int i=1;i<n;i++) read(c[i]);
	ll res = 0;
	for(int i=1;i<=n;i++){
		int cur = a[i];
		int late = a[i-1];
		res += b[cur];
		if(a[i]==a[i-1]+1){
			res += c[a[i-1]];
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
a = [0, 0]
b = [100, 0]
root3 = math.sqrt(3)


def koch(a, b, n):
    if n == 1:
        s = [(a[0] * 2 + b[0]) / 3, (a[1] * 2 + b[1]) / 3]
        t = [(a[0] + b[0] * 2) / 3, (a[1] + b[1] * 2) / 3]
        u = [(s[0] + t[0] - root3 * t[1] + root3 * s[1]) / 2,
             (s[1] + t[1] + root3 * t[0] - root3 * s[0]) / 2]
        print(*s)
        print(*u)
        print(*t)
        print(*b)

    elif n > 1:
        s = [(a[0] * 2 + b[0]) / 3, (a[1] * 2 + b[1]) / 3]
        t = [(a[0] + b[0] * 2) / 3, (a[1] + b[1] * 2) / 3]
        u = [(s[0] + t[0] - root3 * t[1] + root3 * s[1]) / 2,
             (s[1] + t[1] + root3 * t[0] - root3 * s[0]) / 2]
        koch(a, s, n-1)
        koch(s, u, n-1)
        koch(u, t, n-1)
        koch(t, b, n-1)


print(*a)
koch(a, b, n)
if n == 0:
    print(*b)



Measured memory_bytes: 5752
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}

	const int N=1e6+10;
	//------------------FIXED------------------
	char A[N],B[N];
	void main()
	{
		int n=qread();scanf("%s%s",A+1,B+1);int lst=0,ans=1;
		fo(i,1,n+1) if(A[i]==B[i])
		{
			int len=i-lst-1;
			if(lst==0)
			{
				if(len==0) ans=(i>n?1:3);
				else ans=ans*qpower(3,len/2-1)%MOD*6%MOD;
			}
			else
			{
				if(len==0) ans=ans*(i>n?1:2)%MOD;
				else ans=ans*qpower(3,len/2-1)%MOD*2%MOD;
			}lst=i;
		}write(ans);
 	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define w(x)    int x; cin>>x; while(x--)
#define endl 	"\n"
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)
typedef long long ll;
#define mk(arr,n,type)   type *arr=new type[n]
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
void b_v_r()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
 
int main()
{
    b_v_r();
    int x[5],ans;
    for(int i=0;i<5;i++)
    {
        cin>>x[i];
        if(x[i]==0)
            ans = (i+1);
    }    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3572
import collections

n, a = map(int, input().split())
X = [int(i) - a for i in input().split()]
ans = 0
sums = collections.Counter([0, X[0]])
for i in X[1:]:
    sums2 = collections.Counter()
    for s, c in sums.items():
        sums2[s + i] += c
    sums += sums2
print(sums[0] - 1)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define rep(i,x,y) for(int i=(x);i<=(y);++i) 
inline int read(){
	char ch=getchar();int x=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int a[100010];
LL p[100010];
int main(){
	int n=read(),S=read();
	rep(i,1,n){
		a[i]=read(),p[i]=read();
	}
	int l=1,r=n;
	LL ans=0;
	while(l<=r){
		if(a[l]>=S){
			ans+=a[r]-S;
			break;
		}
		if(a[r]<=S){
			ans+=S-a[l];
			break;
		}
		ans+=a[r]-a[l];
		if(p[l]>=p[r]){
			while(p[l]>=p[r]&&l<r){
				p[l]+=p[r];
				--r;
			} 
		}
		else {
			while(p[l]<p[r]&&l<r){
				p[r]+=p[l];
				++l;
			} 
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;

int main(void){
	long ans = 0;
	long N;
	cin >> N;
	VI A(N),B(N),C(N);
	REP(i,N) cin >> A[i];
	REP(i,N) cin >> B[i];
	REP(i,N) cin >> C[i];

	SORT(A);
	SORT(C);

	REP(b,N){
		auto use_a = lower_bound(A.begin(),A.end(),B[b])- A.begin();
		auto use_c = N - (upper_bound(C.begin(),C.end(),B[b]) - C.begin());
		#ifdef DEBUG
			dump(use_a);
			dump(use_c);
		#endif
		ans += ((use_a)*(use_c));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(args...) do { cout << "DEBUG: " << #args << " -> "; err(args); } while (0)
#else
#define dbg(...)
#endif
void err() { cout<< endl; }
template<template<typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); }
template<typename T, typename... Args>
void err(T a, Args... args) { cout << a << ' '; err(args...); }
// -----------------------------------------------------------------------------

const int N = 2E5 + 100;
char s[N];

int main() {
    scanf("%s", s);
    int n = strlen(s);
    LL ans = 0, cnt0 = 0;
    FORD (i, n - 1, -1) {
        if (s[i] == 'W') cnt0++;
        else ans += cnt0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

constexpr ll mod=1e9+7;
ll mpow(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n/=2;
    }
    return ans;
}

int main(){
    int N,K;
    cin>>N>>K;
    //gcdがjであるものを上から求める
    //gcdがjの倍数になるのは全てがjの倍数になったとき
    vector<ll> dp(K+1);
    ll ans=0;
    for(int i=K;i>0;--i){
        dp[i]=mpow(K/i,N);
        for(int j=2*i;j<=K;j+=i){
            dp[i]-=dp[j];
            dp[i]=(dp[i]+mod)%mod;
        }
        ans+=dp[i]*i;
        ans%=mod;
    }
    cout<<ans<<endl;
}


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

bool mycompare(tuple<int,string,int> L, tuple<int,string,int> R){
  if(get<1>(L)!=get<1>(R)) return get<1>(L)<get<1>(R);
  return get<2>(L)>get<2>(R);
}

int main(){
  int N; cin >> N;
  vector<tuple<int,string,int>> rest(N);
  for(int i=0; i<N; i++){
    string S;
    int P;
    cin >> S >> P;
    rest.at(i)=make_tuple(i+1, S, P);
  }
  sort(rest.begin(),rest.end(),mycompare);
  for(int i=0; i<N; i++){
    cout << get<0>(rest.at(i)) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll dp[1111][22], sm[1111];
void dp1(ll x, ll len, int nm){
	// cout<<x<<" "<<len<<endl;
	if(len==0){
		assert(x==1);
		return;
	}
	for(int i=nm; i<=nm; ++i){
		if(dp[len][i]>=x){
			printf("%d",i);
			if(i-1>=0){
				if(dp[len-1][i-1]>=x){
					return dp1(x, len-1, i-1);
				}
				x-=dp[len-1][i-1];
			}
			if(dp[len-1][i]>=x){
				return dp1(x, len-1, i);
			}
			x-=dp[len-1][i];
			return dp1(x, len-1, i+1);
		}
		x-=dp[len][i];
	}
}
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        for(int i=0; i<10; ++i){
        	dp[1][i]=1;
        }
        sm[1]=9;
        if(n<=9){
        	printf("%d\n",n);
        	continue;
        }
        n-=9;
        for(int i=2; i<100; ++i){
        	sm[i]=0;
        	for(int j=0; j<10; ++j){
        		dp[i][j]=dp[i-1][j];
        		if(j-1>=0){
        			dp[i][j]+=dp[i-1][j-1];
        		}
        		dp[i][j]+=dp[i-1][j+1];
        		if(j!=0)
	        		sm[i]+=dp[i][j];
        	}
        	if(sm[i]>=n){
        		for(int j=1; j<10; ++j){
        			if(dp[i][j]>=n){
        				dp1(n, i, j);
        				break;
        			}
        			n-=dp[i][j];
        		}
        		break;
        	}
        	n-=sm[i];
        }
        printf("\n");
    }
  return 0;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int x = in.nextInt();
        int t = 0;
        final Map<Long, Integer> map = new HashMap<>();
        while (Math.pow(t, 5) < 1e18) {
            map.put((long) Math.pow(t, 5), t);
            map.put((long) Math.pow(-t, 5), -t);
            t++;
        }
        twoSum(x, map);
    }

    public static void twoSum(int target, Map<Long, Integer> map) {
        for (Map.Entry<Long, Integer> entry : map.entrySet()) {
            if (map.containsKey(target + entry.getKey())) {
                System.out.println(map.get(target + entry.getKey()) + " " + entry.getValue());
                return;
            }
        }
    }
}


Measured memory_bytes: 40968
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	mod := 1000000007

	n := nextInt()
	a := make([]int, n)
	b := make([]int, n+1)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		b[i+1] = b[i] + a[i]
	}

	// sumA := 0
	// for i := 0; i < n; i++ {
	// 	sumA += a[i]
	// }
	sum := 0
	for i := 0; i < n-1; i++ {
		sumA := (b[n] - b[i+1]) % mod
		sum += a[i] * sumA
		sum %= mod
	}

	fmt.Fprintf(out, "%d\n", sum)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func quickSort(val []int) []int {
	if len(val) < 2 {
		return val
	}

	pivot := val[0]

	left := []int{}
	right := []int{}

	for _, v := range val[1:] {
		if pivot > v {
			left = append(left, v)
		} else {
			right = append(right, v)
		}
	}

	left = quickSort(left)
	right = quickSort(right)

	ret := append(left, pivot)
	ret = append(ret, right...)

	return ret
}


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

int main()
{
    int n, w;
    cin >> n >> w;
    vector<long long> dp(w+1, -1LL);
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        v[i] = make_pair(x, y);
    }

    dp[0] = 0;

    for (int i = 0; i < n; i++){
        for (int j = w; j >= 0; j--) {
            if (j + v[i].first <= w) {
                dp[j + v[i].first] = max(dp[j + v[i].first], dp[j] + v[i].second);
            }
        }
    }
    long long ans = -2;
    for (int i = 0; i <= w; i++) {
        ans = max(dp[i], ans);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = []
for _ in range(n):
  a_ = int(input())
  a.append(a_)
a1 = sorted(a)
ans1 = a1[-1]
ans2 = a1[-2]
for i in range(n):
  if a[i] == ans1:
    print(ans2)
  else:
    print(ans1)

Measured memory_bytes: 19000
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

using namespace std;

long long calc(long long x) {
	if (x < 2) {
		return 0;
	}
	return x * (x - 1) / 2;
}

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

	vector<long long> ball(n + 1, 0);
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ball[a[i]]++;
	}

	long long total = 0;
	for (auto x: ball) {
		total += calc(x);
	}

	for (auto x: a) {
		long long ans = total - calc(ball[x]) + calc(ball[x] - 1);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 4992
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve
{   
    public static void Main()
    {
        var str = Console.ReadLine();
        var alphabet = Enumerable.Range('a', 26).ToArray();

        foreach (var c in alphabet)
        {
            if(!str.Any(e=>e==c))
            {
                Console.WriteLine((char)c);
                return;
            }
        }
        Console.WriteLine("None");

    }
}

Measured memory_bytes: 13408
def check(num, N): #Nからnumが作れるならreturn 1
    length = len(N)

    get_target = 0
    for i in range(length):
        if get_target == 0 and N[i] == num[0]:
            get_target = 1
            # print("target1", num)
        elif get_target == 1 and N[i] == num[1]:
            get_target = 2
            # print("target2", num)
        elif get_target == 2 and N[i] == num[2]:
            get_target = 3
            # print("target3", num)
    
    if get_target == 3:
        # print(num)
        return 1
    else:
        return 0


N = int(input())
S = input()

counter = 0
for i in range(1000):
    str_i = str(i)
    while len(str_i) <3:
        str_i = "0" + str_i
    
    counter += check(str_i, S)
print(counter)


Measured memory_bytes: 40812
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<ll> H(N);
	rep(i, N) cin >> H[i];

	int down = 0;
	bool can = true;
	rep(i, N-1) {
		if(H[i]>H[i+1]+1) {
			can = false;
			break;
		}else if(H[i]==H[i+1]+1) {
			if(down==0) down++;
			else {
				can = false;
				break;
			}
		} else if(H[i]==H[i+1]) {
			continue; 
		} else if(H[i]<H[i+1]) {
			down = 0; // reset
		}
	}

 	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;
	
  return 0;
}

Measured memory_bytes: 1024
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]

max_a = sorted(ab, key=lambda x: -x[0])[0][0]
bs = sorted([b for a,b in ab if b > max_a], reverse=True)
sum_bs = sum(bs)

if H <= sum_bs:
    for i in range(len(bs)):
        H -= bs[i]
        if H <= 0:
            print(i+1)
            exit()
else:
    H -= sum_bs
    print((H+max_a-1)//max_a + len(bs))


Measured memory_bytes: 72408
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
#define gcd __gcd

using namespace std;

typedef pair<int, int> pii;

ll n, k;
map <ll, ll> mp;

int main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 0 ; i < n ; i++){
        int x, y;
        cin >> x >> y;
        mp[x] += y;
	}
	ll tedad = 0;
	for (auto u : mp){
        tedad += u.S;
        if (tedad >= k){
            cout << u.F;
            return 0;
        }
	}
}


Measured memory_bytes: 4224
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    
    
    for i in range(H):
        for j in range(W):
            if i%2==0:
                if j%2==0:
                    print("#",end="")
                else:
                    print(".",end="")
            else:
                if j%2==0:
                    print(".",end="")
                else:
                    print("#",end="")
        print()
    print()


Measured memory_bytes: 7004
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  char a,b;
  cin >> a >> b;
  if(a==b) cout << 'H' << endl;
  else cout << 'D' << endl;
  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

class UnionFind{
public:
  vector<int> p;		// 親
  vector<int> rank;	// サイズ・各集合の根のみ有効
  UnionFind(int n){
    p.resize(n, -1);
    rank.resize(n, 1);
  }
  int root(int x){
    if(p[x] == -1)return x;
    else return p[x] = root(p[x]); // 深さを 1 にしている
  }
  void unite(int x, int y){
    x = root(x); y = root(y);
    if(x == y)return;
    if(rank[x] > rank[y]) swap(x, y); // rankの小さいものを下につける
    rank[y] += rank[x];
    p[x] = y;
  }
  //xが属すグループのサイズ
  int size(int x){ return rank[root(x)]; }
  bool same(int x, int y){ return (root(x) == root(y)); }
};

void solve()
{
  ll n, m, a, b;
  cin >> n >> m;
  UnionFind uf(n);
  for(int i = 0; i < m; ++i)
  {
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
  }

  set<int> st;
  for(int i = 0; i < n; ++i)
  {
    st.insert(uf.root(i));
  }
  cout << st.size() - 1;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    
    long sum=0;
    rep(i,m){
        int d;
        cin >> d;
        sum += d;
    }

    if(sum > n) cout << -1 << endl;
    else cout << n - sum << endl;
}


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

string field[505];
int H;
int W;

void input() {
  for (int i=0; i<H; i++) {
    cin >> field[i];
  }
}

void output() {
  for (int i=0; i<H; i++) {
    cout << field[i] << endl;
  }
}

int main() {
  while(scanf("%d %d", &H, &W),H||W) {
    input();

    int max_area = 0;
    // ???????????????
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
	int rightest = W;
	int k, l;
	for (k=i; k<H; k++) {
	  if (field[k][j] == '*') {
	    break;
	  }
	  
	  for (l=j; l<rightest; l++) {
	    if (field[k][l] == '*') {
	      rightest = l;
	      break;
	    }
	  }
	  int tmp_area = (k-i+1)*(l-j);
	  // printf("i:%d j:%d k:%d l:%d tmp_area:%d\n", i, j,k,l, tmp_area);
	  if (max_area < tmp_area) {
	    max_area = tmp_area;
	  }
	}
	// printf("i%d j%d max_area%d\n", i,j,max_area);
      }
    }
    printf("%d\n", max_area);
  }
}

Measured memory_bytes: 3304
#include <stdio.h>

struct Dice
{
	int n[6];
};

Dice InputDice()
{
	Dice d;
	for(int i = 0; i < 6; ++i)
	{
		scanf("%d", &d.n[i]);
	}
	
	return d;
}

Dice SetDice(int a, int b, int c, int d, int e, int f)
{
	Dice dice;
	dice.n[0] = a;
	dice.n[1] = b;
	dice.n[2] = c;
	dice.n[3] = d;
	dice.n[4] = e;
	dice.n[5] = f;
	
	return dice;
}

Dice Roll(Dice dice, char dir)
{
	switch(dir)
	{
		case 'N':
			return SetDice(dice.n[1], dice.n[5], dice.n[2], dice.n[3], dice.n[0], dice.n[4]);
		case 'S':
			return SetDice(dice.n[4], dice.n[0], dice.n[2], dice.n[3], dice.n[5], dice.n[1]);
		case 'W':
			return SetDice(dice.n[2], dice.n[1], dice.n[5], dice.n[0], dice.n[4], dice.n[3]);
		case 'E':
			return SetDice(dice.n[3], dice.n[1], dice.n[0], dice.n[5], dice.n[4], dice.n[2]);
	}
}

bool IsSame(Dice a, Dice b)
{
	for(int i = 0; i < 6; ++i)
	{
		if(a.n[i] != b.n[i])
		{
			return false;
		}
	}
	
	return true;
}

bool IsEqual(Dice a, Dice b)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		b = Roll(b, cmd[i]);
		if(IsSame(a, b))
		{
			return true;
		}
	}
	
	return false;
}

int FindSide(Dice a, int top, int front)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		a = Roll(a, cmd[i]);
		if(a.n[0] == top && a.n[1] == front)
		{
			return a.n[2];
		}
	}
	
	return -1;
}

int main()
{
	Dice A = InputDice(), B = InputDice();
	if(IsEqual(A, B))
	{
		printf("Yes\n");
	}	
	else
	{
		printf("No\n");
	}
	
    return 0;
}



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

int main() {
  int w, n; cin >> w >> n;
  vector<int> x(w);
  for (int i = 0; i < w; ++i) x[i] = i + 1;
  for (int i = 0; i < n; ++i) {
    char c;
    int a, b;
    cin >> a >> c >> b;
    --a; --b;
    swap(x[a], x[b]);
  }
  for (int i = 0; i < w; ++i) cout << x[i] << endl;
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define getMat(x, n, m, val) vector<vector<ll>> x(n, vector<ll> (m, val))
#define setp fixed<<setprecision
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll M=1000000000+7;
 
ll power(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

int main(){
    fastio;
    ll n;
    cin>>n;
    ll a[n];
    ll sum=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans=0;
    for(ll i=0;i<n-1;i++){
        sum-=a[i];
        ans = (ans%M + ((a[i]%M)*(sum%M))%M)%M;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String args[]) throws IOException {
        BufferedReader sR = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(sR.readLine());
        x *= x *= x;
        System.out.println(x);
        

    }
 
}

Measured memory_bytes: 24040
K=int(input())
a=0
from math import log10,ceil
from functools import lru_cache
@lru_cache(maxsize=None)
def sn(n):
    x=n
    y=0
    while x>0:
        y+=x%10
        x//=10
    return n/y
for i in range(K):
    if i<9:
        a+=1
        print(a)
        continue
    for d in range(int(log10(a))+1):
        y=10**(d+1)*ceil(a/(10**(d+1))+1)-1
        if d==0 or sn(y)<sn(at):
            at=y
    a=at
    print(a)

Measured memory_bytes: 4544
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    long long a=0,b=0;
    cin>>a>>b;
    if((a*b)%2==0){
        cout<<"Even"<<endl;
    }else{
        cout<<"Odd"<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const int MAX_DIGIT = 50;
ll dp[100][2];

int main()
{
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    rep(d, MAX_DIGIT)
    {
        ll mask = 1LL << (MAX_DIGIT - d - 1);

        int num = 0;
        rep(i, n) if (a[i] & mask) num++;

        ll cost0 = mask * num;
        ll cost1 = mask * (n - num);

        if (dp[d][1] >= 0) chmax(dp[d + 1][1], dp[d][1] + max(cost0, cost1));

        if (dp[d][0] >= 0)
        {
            if (k & mask)
            {
                chmax(dp[d + 1][1], dp[d][0] + cost0);
                chmax(dp[d + 1][0], dp[d][0] + cost1);
            }
            else
            {
                chmax(dp[d + 1][0], dp[d][0] + cost0);
            }

        }
    }
    cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
}

Measured memory_bytes: 1024
A, B, C, K = map(int, input().split())

if K == 0:
    print(A-B)
    exit()

A, B, C = B+C, C+A, A+B

if abs(A-B) > 10**18:
    print('Unfair')
else:
    if K % 2 == 1:
        print(A-B)
    else:
        print(-(A-B))

Measured memory_bytes: 3060
#include<iostream>
#include<set>

int main(void){
    int n, m;
    std::cin >> n >> m;
    std::multiset<int> as;
    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;
        as.insert(a);
    }
    // auto max = std::next(as.end(), -1);
    // as.erase(max);
    // max = std::next(as.end(), -1);
    // std::cout << *max << std::endl;
    for(int i = 0; i < m; i++){
        auto max = std::next(as.end(), -1);
        int redu = *max / 2;
        as.erase(max);
        as.insert(redu);
        // as.
        // std::cout << *max << std::endl;
    }
    long long ans = 0;
    for(auto i = as.begin(); i != as.end(); i++){
        ans += *i;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 8264
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

bool IsSquare(int a, int b) {
  int d = 1;
  for (int i = b; i > 0; i /= 10) {
    d *= 10;
  }
  int ret = b;
  for (int i = a; i > 0; i /= 10) {
    ret += (i % 10) * d;
    d *= 10;
  }

 const auto n = static_cast<int>(sqrt(ret));
  return n * n == ret;
}

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

  int a, b;
  cin >> a >> b;

  if (IsSquare(a, b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    l = []
    N = int(input())
    T, A = map(int, input().split())
    h = list(map(int, input().split()))
    for  i in range(N):
      l.append(abs(A-(T-h[i]*0.006)))
    print(l.index(min(l))+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');

            int x = int.Parse(line[0]);
            int y = int.Parse(line[1]);

            Console.WriteLine(Lcm(x,y));
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; ll H;
  scanf("%d %lld", &N, &H);
  vector<ll> a(N), b(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &a[i], &b[i]);
  }

  sort(b.begin(), b.end(), greater<ll>());
  ll wielding_max = *max_element(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (b[i] < wielding_max) { break; }
    if (H <= 0) { break; }
    H -= b[i];
    ++ans;
  }
  if (H > 0) {
    ans += (H + wielding_max - 1) / wielding_max;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b-a)%2 == 0) {
    cout << (b-a)/2 << nl;
  } else {
    ll ans = min(a, n-b+1);
    cout << ans + (b-a-1)/2 << nl;
  }
  return 0;
}



Measured memory_bytes: 256
N = int(input())
list = list(input())
n = 0
if N % 2 != 0:
	print("No")
else:
    for i in range(N//2):
        if not list[i] == list[i+ N//2]:
            print("No")
            break
        n += 1
    if n == N//2:
        print("Yes")


Measured memory_bytes: 2940
import numpy as np
n,m,c = map(int,input().split())
b=np.array(list(map(int,input().split())))
ans = 0
for _ in range(n):
  a = np.array(list(map(int,input().split())))
  if np.sum(a*b)+c >0:
    ans += 1
print(ans)

Measured memory_bytes: 12488
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

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


int n,s;
int used[10];

int saiki(int depth){
	if(depth==n){
		int p = 0;
		rep(i,10)if(used[i]==1)p+=i;
		if(p==s)return 1;
		return 0;
	}
	int ret = 0;
	
	for(int i=9;i>=0;i--){
		if(used[i]==0){
			used[i]=1;
			ret += saiki(depth+1);
			used[i]=0;
		}else{
			break;
		}
	}
	return ret;
}

int main(){
	rep(i,10)used[i]=0;
	
	while(1){
		cin>>n>>s;
		if(n==0)break;
		printf("%d\n",saiki(0));
	}
}

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

int main() {
  int a,b,c; cin >> a >> b >> c;
  cout << max(c - (a-b), 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = 1e16;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, a, b;
    cin >> N >> a >> b;
    int A[N];
    rep(i,N) cin >> A[i];
    int ans = 0;
    rep(i,N-1){
        int dis = A[i+1] - A[i];
        ans += min(dis*a, b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){ return (a%m + b%m+2*m)%m;}

ll mul(ll a, ll b, ll m = MOD){ return ((a%m+m)*(b%m+m))%m;}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100000+5;

int n;
int c[N][3];
bool vis[N][3];
int memo[N][3];

int DP(int pos, int now){
	if(pos == n){
		return 0;
	}
	if(vis[pos][now]) return memo[pos][now];
	int ans = 0;
	for(int i=0; i<3; i++){
		if(i == now) continue;
		ans = max(ans,c[pos][now]+DP(pos+1,i));
	}
	vis[pos][now] = true;
	return memo[pos][now] = ans;
}

int main(){
	ri(n);
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			ri(c[i][j]);
		}
	}
	int ans = 0;
	for(int i=0; i<3; i++){
		ans = max(ans,DP(0,i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10752
#include <limits>
#include <vector>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

typedef long long ll;

namespace libcomp {
namespace structure {

template <typename T>
struct MaxSegmentTreeTraits {
	typedef T value_type;
	T default_value() const { return numeric_limits<T>::min(); }
	T operator()(const T &a, const T &b) const { return max(a, b); }
};

template <typename Traits>
class SegmentTree {

public:
	typedef typename Traits::value_type value_type;

private:
	Traits m_traits;
	vector<value_type> m_data;
	size_t m_size;

	void initialize(){
		for(int i = static_cast<int>(m_size) - 2; i >= 0; --i){
			m_data[i] = m_traits(m_data[i * 2 + 1], m_data[i * 2 + 2]);
		}
	}

	value_type query(int a, int b, int k, int l, int r) const {
		if(r <= a || b <= l){ return m_traits.default_value(); }
		if(a <= l && r <= b){ return m_data[k]; }
		const value_type vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		const value_type vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return m_traits(vl, vr);
	}

public:
	explicit SegmentTree(size_t size, const Traits &traits = Traits()) :
		m_size(1), m_traits(traits)
	{
		while(m_size < size){ m_size *= 2; }
		m_data.resize(m_size * 2 - 1, m_traits.default_value());
		initialize();
	}

	template <typename Iterator>
	SegmentTree(
		Iterator first, Iterator last, const Traits &traits = Traits()) :
		m_size(1), m_traits(traits)
	{
		const size_t n = distance(first, last);
		while(m_size < n){ m_size *= 2; }
		m_data.resize(m_size * 2 - 1, m_traits.default_value());
		copy(first, last, m_data.begin() + m_size - 1);
		initialize();
	}

	void update(size_t i, const value_type &val){
		i += m_size - 1;
		m_data[i] = val;
		while(i > 0){
			i = (i - 1) / 2;
			m_data[i] = m_traits(m_data[i * 2 + 1], m_data[i * 2 + 2]);
		}
	}

	value_type query(size_t a, size_t b) const {
		return query(a, b, 0, 0, m_size);
	}

};

}
}

int main(){
	using libcomp::structure::MaxSegmentTreeTraits;
	using libcomp::structure::SegmentTree;
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i = 0; i < n; ++i){ cin >> x[i]; }
	SegmentTree< MaxSegmentTreeTraits<ll> > st(n + 1);
	ll max_sum = 0;
	for(int i = 0; i < n; ++i){
		const ll y = max(0ll, st.query(0, x[i])) + x[i];
		max_sum = max(max_sum, y);
		st.update(x[i], y);
	}
	cout << (static_cast<ll>(n) * (n + 1)) / 2 - max_sum << endl;
	return 0;
}

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

int main()
{
    int n, l, Count = 0, hight = 0;
    cin>>n>>l;

    int a[n];

    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    int i = 0;
    while(hight <= l)
    {
        Count++;
        hight += a[i++];
    }
    cout<<Count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}




int main(){
	int N, Y;
	cin >> N >> Y;
	
	for(int a=0; a<=Y/10000; a++){
	for(int b=0; b<=(Y-a*10000)/5000; b++){
		int c=N-a-b;
		
		if(a>=0 && b>=0 && c>=0){
		if(a*10000+b*5000+c*1000 == Y){
			cout << a << " " << b << " " << c << endl;
			return 0;
		}}
	}}
	
	cout << -1 << " " << -1 << " " << -1 << endl;
	
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
using namespace std;
inline int read(){
	ri x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
struct node{
	int x,y;
}a[105];
inline bool cmp(node p,node q){return atan2(p.y,p.x)<atan2(q.y,q.x);}
int main()
{
	ri n=read();
	rep(i,0,n-1) a[i].x=read(),a[i].y=read();
	sort(a,a+n,cmp);
	ll ans=0;
	rep(i,0,n-1){
		ri x=0,y=0;
		rep(j,0,n-1){
			x+=a[(i+j)%n].x;
			y+=a[(i+j)%n].y;
			ans=max(ans,1ll*x*x+1ll*y*y);
		}
	}
	printf("%.12lf",sqrt(ans));
	return 0; 
}

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

int n, a[100005];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		if(a[i] == a[i-1]) {
			i--;
			n--;
		}
	}
	int ans = 1, s = 1;
	for(int i=2;i<=n;i++) {
		if(s != i-1 && (a[i-2] < a[i-1]) != (a[i-1] < a[i])) {
			ans++;
			s = i;
		}
	}
	printf("%d\n",ans);
}


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

int main(){
    int n; cin >> n;
    int l;
    int sum=0;
    int MAX=1;
    rep(i, n){
        cin >> l;
        sum += l;
        MAX = max(MAX, l);
    }
    sum -= MAX;
    if(sum > MAX){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256