akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

// https://drken1215.hatenablog.com/entry/2019/01/13/033500
int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> cards(n);
    rep(i, n) cin >> cards[i];

    reverse(cards.begin(), cards.end());

    CumulativeSum sum(n), evensum(n);
    rep(i, n) sum.set(i, cards[i]);
    rep(i, n) if (i % 2 == 0)evensum.set(i, cards[i]);
    sum.calculate();
    evensum.calculate();

    vector<ll> ths, vals;
    rep(i, (n - 1) / 2) {
        ll th = (cards[i + 1] + cards[i * 2 + 2]) / 2 + 1;
        ll val = sum.getSum(i) + (evensum.getSum(n) - evensum.getSum(i * 2 + 1));
        ths.push_back(th);
        vals.push_back(val);
    }

    reverse(ths.begin(), ths.end());
    reverse(vals.begin(), vals.end());

    rep(_, q) {
        ll x;
        cin >> x;
        auto it = upper_bound(ths.begin(), ths.end(), x);
        int i = distance(ths.begin(), it);

        if (i == 0) cout << sum.getSum((n + 1) / 2 - 1) << endl;
        else cout << vals[i - 1] << endl;

    }


}

Measured memory_bytes: 6644
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
ll KMPMatch(string src, string pat){
    int ini[pat.size()], i=1, j=0;
    ini[0] = 0;
    while(i<pat.size()){
       if(pat[i] == pat[j]) j++, ini[i] = j, i++;
       else if(j == 0) ini[i] = 0, i++;
       else j = ini[j - 1];
    }
    i = j = 0;
    vll ret;
    while(j<pat.size()&&i<src.size()){
       if(src[i] == pat[j]) i++, j++;
       else if(j == 0) i++;
       else j = ini[j - 1];
       if(j==pat.size()) return i - pat.size();
    }
    return -1;
}
//-------------------------------------------------------------------

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n), b(n);
  re(i, n) std::cin >> a[i];
  re(i, n) std::cin >> b[i];
  vvl candi = vv(200001, 0, 0, ll);

  for(int i=0;i<32;i++){
    string s = "", s_rev = "", t = "";
    re(j, n){
      if(a[j]%2) s+='o', s_rev+="x";
      else s+='x', s_rev+="o";
      a[j]/=2;
    }
    re(j, n){
      if(b[j]%2) t+='o';
      else t+='x';
      b[j]/=2;
    }
    t += t+t;
    ll tmp = KMPMatch(t, s);
    ll tmp_rev = KMPMatch(t, s_rev);
    string td = "", tx="";
    for(int j=tmp+1;j<t.size();j++) td+=t[j];
    for(int j=0;j<=tmp;j++) td+=t[j];
    for(int j=tmp_rev+1;j<t.size();j++) tx+=t[j];
    for(int j=0;j<=tmp_rev;j++) tx+=t[j];
    ll tmp2 = KMPMatch(td, s)+1;
    ll tmprev2 = KMPMatch(tx, s_rev)+1;

    //std::cout << "0" << '\n';
    if(tmp!=-1){
      for(int j=tmp;j<n;j+=tmp2) {
        candi[(n-j)%n].push_back(0);
        //std::cout << (n-j)%n << " ";
      }
    }
    //std::cout << '\n';
    //std::cout << "1" << '\n';
    if(tmp_rev!=-1){
      for(int j=tmp_rev;j<n;j+=tmprev2) {
        candi[(n-j)%n].push_back(1);
        //std::cout << (n-j)%n << " ";
      }
    }
  }

  vvl ans = vv(0, 2, 0, ll);
  re(i, 200001){
    if(candi[i].size()!=32) continue;
    else{
      ll tmp = 0, sq = 1;
      re(j, 32){
        if(candi[i][j]==1) tmp += sq;
        sq *= 2;
      }
      ans.push_back(vll{i, tmp});
    }
  }
  sort(all(ans));
  re(i, ans.size()){
    std::cout << ans[i][0] << " " << ans[i][1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 77592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf n,x,total=0;
    cin >>n >>x;
    vector<intf> m(n);
    for(auto & e:m) cin>>e;

    rep(i,n){

        total += m[i];
        if(total>=x){
            cout << i+1 <<endl;
            return 0;
        }
    }

    cout << (x-total)/(*std::min_element(m.begin(),m.end())) + n <<endl;



}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int h, a;
  int ans = 0;

  cin >> h >> a;

  if(h%a == 0){
    cout << h/a << endl;
  }else{
    cout << h/a +1 << endl;
  }


}


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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		String answer = "";
		
		for(int i = 0; i < param.get(0).length(); i++){
			if(param.get(0).charAt(i) == '0'){
				answer+= 0;
			} else if(param.get(0).charAt(i) == '1'){
				answer+= 1;
			} else {
				if(answer.length() != 0) answer = answer.substring(0, answer.length()-1);
			}
		}
		System.out.println(answer);
	}
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  string s;
  cin >> s;

  int q;
  cin >> q;

  deque<char> ans;
  trav(k,s) ans.pb(k);
  int r = 0;
  while (q--) {
    int t;
    cin >> t;

    if (t==1) r^=1;
    else {
      int dir;
      char c;
      cin >> dir >> c;
      --dir;
      dir ^= r;
      if (dir) ans.pb(c);
      else ans.push_front(c);
    }
  }

  string out;
  trav(k, ans) out.pb(k);
  if (r) reverse(all(out));
  cout << out << endl;
}


Measured memory_bytes: 1368
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int g[16][16];

int main(){
    // Failed to predict input format
    int n;cin>>n;
    REP(i,n+1)REP(j,n+1)g[i][j]=-1;
    REP(i, n){
        int a;
        cin>>a;
        REP(j, a){
            int x,y;
            cin>>x>>y;
            g[i][x-1]=y;
        }
    }
    int ans=0;
    for(int i=0; i < (2<<(n-1)); i++){
        int cnt=0;
        debug(i)
        REP(j,n)
            if(i & (1<<j))cnt++;
        bool flag=true;
        REP(j, n){ // for all guys
            if(i & (1<<j)){//guy has to be honest
                REP(k, n){
                        if(g[j][k]==0 && (i & (1<<k)))flag=false; //honest guy says he's dishonest but not
                        if(g[j][k]==1 && !(i & (1<<k)))flag=false; //other way around
                    
                }
            }
        }
        if(flag)ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
ls = len(s)
dp = [[0 for _ in range(4)] for _ in range(ls+1)]
dp[0][0] = 1
mod = 10 ** 9 + 7

for i in range(1, ls+1):
    for j in range(4):
        #'?'のとき'ABC'の3通りに分岐させ、いずれも取らないので3倍
        dp[i][j] += dp[i-1][j] * (3 if s[i-1] == '?' else 1)
        if j > 0:
            #ほしい文字に変えた場合　または　ほしい文字の場合で取ったとき
            dp[i][j] += dp[i-1][j-1] if s[i-1] == 'ABC'[j-1] or s[i-1] == '?' else 0
        dp[i][j] %= mod
print(dp[ls][3])

Measured memory_bytes: 27616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ma = max(a, c);
	int mi = min(b, d);
	cout << max(0, mi - ma) << endl;
	return 0;
}

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

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

  long long h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  long long n = 0;
  n = ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2);
  cout << n << endl;

}

Measured memory_bytes: 256
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii;
// d = distance(lower_bound(all(x)), upper_bound(all(x)));
int INF = 1e9;
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

int main(){
  int M, D; cin >> M >> D; int a = 0;
  rep(i, 2, M+1) {
    rep(j, 10, D+1) {
      int d1 = j % 10, d2 = j / 10;
      if (d1 * d2 == i && d1 >= 2 && d2 >= 2) a++;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
priceList = []
t = raw_input()


for i in range(int(t)):
    priceList.append(int(input()))

maxv = -2000000000
minv = priceList[0]

for i in range(1, int(t)):
	if maxv < priceList[i] - minv:
		maxv = priceList[i] - minv
	if minv > priceList[i]:
		minv = priceList[i]
    
print maxv

Measured memory_bytes: 19036
/* package codechef; // don't place package name! */

import javax.swing.*;
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int H = s.nextInt();
        int N = s.nextInt();
        int A[] = new int[N];
        int sum=0;
        for(int i=0; i<N; i++)
        {
            A[i] = s.nextInt();
            sum+=A[i];
        }
        if(sum>=H)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 54576
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1 + 1e5;
typedef long long LL;
typedef pair < int, int > II;
typedef pair < int, II > III;

int n;
string s;

int main()
{
    #define TASK "ABC"
 //   freopen(TASK".inp","r",stdin);
 //   freopen(TASK".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100100;
vector<int> lista[N];
int dp[N];


int solve(int u){
	int &ans=dp[u];
	if(ans!=-1)
		return ans;
	ans=0;
	for (int i = 0; i < lista[u].size(); ++i)
	{	
		int v=lista[u][i];
		ans=max(ans,solve(v));
	}
	ans++;
	return ans;
}

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

	memset(dp,-1,sizeof(dp));
	int n,a,b,m;
	cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		cin>>a>>b;
		lista[a].push_back(b);
	}
	int rs=0;
	for (int i = 1; i <= n; ++i)
	{
		rs=max(rs,solve(i));
		// cout<<i<<" "<<solve(i)<<"\n";
	}
	cout<<rs-1<<'\n';
}

Measured memory_bytes: 8192
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a;
}


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

using namespace std;


#define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));



    return 0;
}


Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int ac=0,bc=0,cc=0,flag=0;
  string a,b,c;
  cin>>a>>b>>c;
  while(1){
    if(flag==0){
      if(ac==a.size()){
	cout<<'A'<<'\n';
	break;
      }else{
	if(a[ac]=='a'){
	  flag=0;
	}else if(a[ac]=='b'){
	  flag=1;
	}else{
	  flag=2;
	}
	ac++;
      }
    }else if(flag==1){
      if(bc==b.size()){
	cout<<'B'<<'\n';
	break;
      }else{
	if(b[bc]=='a'){
	  flag=0;
	}else if(b[bc]=='b'){
	  flag=1;
	}else{
	  flag=2;
	}
	bc++;
      }
    }else{
      if(cc==c.size()){
	cout<<'C'<<'\n';
	break;
      }else{
	if(c[cc]=='a'){
	  flag=0;
	}else if(c[cc]=='b'){
	  flag=1;
	}else{
	  flag=2;
	}
	cc++;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MAXN = 100010;
const int MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000000;

int n, m;
map<ll, ll> F;

int main()
{
	
	n = inp();
	m = inp();
	for (int i = 1; i <= n; ++ i)
	{
		int x = inp();
		int y = inp();
		F[x] += y;
	}
	ll ans = 0;
	for (int i = 1; i <= m; ++ i)
	{
		auto it = F.begin();
		while (it->Y == 0)
		{
			F.erase(it);
			it = F.begin();
		}
		it->Y --;
		ans += it->X;
	}
	cout << ans << endl;
	
	return 0;
}


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

int main(){
  string s,ans;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(ans == "" && s.at(i) == 'B') continue;
    if(s.at(i) == '0'){
      ans += '0';
    }
    else if(s.at(i) == '1'){
      ans += '1';
    }
    else{
      ans.pop_back();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.datetime;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto H = s[1].to!long;
    auto A = new long[](N);
    auto B = new long[](N);
    foreach (i; 0..N) {
        s = readln.split.map!(to!int);
        A[i] = s[0].to!long;
        B[i] = s[1].to!long;
    }

    auto pq = new BinaryHeap!(Array!(Tuple!(int, long)), "a[1] < b[1]");
    foreach (i; 0..N) pq.insert(tuple(0, A[i]));
    foreach (i; 0..N) pq.insert(tuple(1, B[i]));

    int cnt = 0;
    while (!pq.empty) {
        auto t = pq.front;
        pq.removeFront;
        if (t[0] == 1) {
            H -= t[1];
            cnt += 1;
            if (H <= 0) {
                cnt.writeln;
                return;
            }
        } else {
            cnt += (H - 1) / t[1] + 1;
            cnt.writeln;
            return;
        }
    }
}


Measured memory_bytes: 8124
N,M = map(int,input().split())
G = [[] for _ in range(max(N,M)+1)]
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
dist = [-1 for _ in range(N + 1)]
dist[1]= 0
from collections import deque
#print(G)
q = deque()
q.append(1)
while (len(q) > 0):
    v = q.popleft();
    for nv in G[v]:
        #print(nv)
        if dist[nv] != -1: continue
        dist[nv] = v 
        #print(dist[v],"dist")
        q.append(nv)
print("Yes")
for x in range(2,len(dist)):
    print(dist[x])




Measured memory_bytes: 41216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 2e5 + 5;
const int MOD = 1000000000;
const LL INF = (2e5)*(1e9) + 5;
LL a[MAXN];
LL sum[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n)
	{
		LL tot = 0;
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			sum[i] = sum[i - 1] + a[i];
			tot += a[i];
		}
		LL Min = INF;
		for (int i = 1; i<n; i++)
		{
			if (Min>abs(2 * sum[i] - tot))
				Min = abs(2 * sum[i] - tot);
		}
		cout << Min << endl;
	}

	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{

    int h,n,flag,i,j,ans,sum;
    double k,temp;
    while(~scanf("%d%d",&n,&h))
    {
        int a[100005]={0},b[100005]={0};
        sum=ans=0;
        flag=0;
        for(i=0;i<n;i++)  scanf("%d%d",&a[i],&b[i]);
        //从大到小
        sort(a,a+n,cmp);
        sort(b,b+n,cmp);
        for(i=0,j=0;;)
        {
            if(b[j]>a[i]&&j<n) { sum+=b[j++]; ans++; }
            else
            {
                ans+=(h-sum)/a[i]+((h-sum)%a[i]!=0);
                printf("%d\n",ans);
                break;
            }
            if(sum>=h) {printf("%d\n",ans); break;}
        }
    }
    return 0;
}


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

int N;
const int MAX_N = 50 + 10;
int p[MAX_N];

bool is_sorted(int l[]) {
    bool ret = true;
    for (int i = 0; i < N-1; i++) {
        if (l[i] > l[i+1]) {
            ret = false;
            break;
        }
    }
    return ret;
}

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

    bool f = false;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            swap(p[i], p[j]);
            if (is_sorted(p)) {
                f = true;
                break;
            }
            else {
                swap(p[i], p[j]);
            }
        }
        if (f) break;
    }

    if (f) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> nums;
	long long pre[n + 1];
	pre[0] = 0;
	for(int i = 0; i < n; i++){
		long long temp;
		cin >> temp;
		nums.push_back(temp);
		pre[i + 1] = pre[i] + temp;
	}
	long long dp[n][n];
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			dp[i][j] = LLONG_MAX;
		}
	}
	
	for(int length = 0; length < n; length++){
		for(int start = 0; start < n-length; start++){
			if(length == 0){
				dp[start][start+length] = 0;
			}
			else{
				for(int k = 0; k < length; k++){
					dp[start][start+length] = min(dp[start][start+length], dp[start][start + k] + dp[start+k+1][start+length] + pre[start+length + 1] - pre[start]);
				}
			}
		}
	}
	
	cout << dp[0][n - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <string.h>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define INF 100000
#define MAX 10000
typedef long long int ll;
using namespace std;

int main()
{
 //  freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
 ll arr[100005],ans=0,n;
 cin>>n;
 for(ll i=0;i<2*n;i++)
  cin>>arr[i];
sort(arr,arr+2*n);
for(ll i=2*n-2;i>=0;i-=2)
{
  //cout<<arr[i]<<" ";
  ans+=arr[i];
}
//ans+=arr[i];
cout<<ans<<endl;
return 0;

}

Measured memory_bytes: 256
N = int(input())
dp = []

def dfs(x):
    if len(set(str(x))) == 3:
        dp.append(x)

    if x < 10**9:
        dfs(x*10+3)
        dfs(x*10+5)
        dfs(x*10+7)

dfs(0)
print(len([item for item in dp if item <= N]))


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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int main(){
  ll N;
  cin >> N;
  cout << N*(N-1)/2 << endl;
}
      
  
  
  

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

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		}	
		int max = -1000000000;
		int nowm = num[0];
		for(int i=1;i<n;i++){
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		}

		System.out.println(max);
	}
}




Measured memory_bytes: 100460
#include<iostream>
#include<set>
using namespace std;
typedef long long ll;
int main(){
  ll n,ans=0,r,l;
  cin >> n;
  ll a[n+1],b[n+1];
  set<ll> s;
  s.insert(0);
  s.insert(n+1);
  for(int i=1;i<=n;i++){
    cin >> a[i];
    b[a[i]]=i;
  }
  for(int i=1;i<=n;i++){
    auto it= s.upper_bound(b[i]);
    ans += (*it - b[i])*(b[i]- *(--it))*i;
    s.insert(b[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
#include<iostream>
using namespace std;
 
int main(){
   int n,m;
    cin>>n>>m;
    int a[n][m];
    int sum[n];
    int sum2[m+1];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
        sum[i]=0;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout<<a[i][j]<<" ";
            sum[i]+=a[i][j];
        }
        cout<<sum[i]<<endl;
    }
    for(int j=0;j<=m;j++){
        sum2[j]=0;
    }
    for(int j=0;j<m;j++){
        for(int i=0;i<n;i++){
            sum2[j]+=a[i][j];
        }
        cout<<sum2[j]<<" ";
        sum2[m]+=sum2[j];
    }
    cout<<sum2[m]<<endl;
    return(0);
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    

    REP(i, n) {
        h -= a[i];
    }

    if (h >= 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        
    }
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B>> C;
    if(A + B >= C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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


int main(){
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    rep(i, N){
        cin >> A.at(i);
    }
    // day 1
    for (auto Ai: A){
        X ++;
    }
    // day D * Ai + 1
    for (auto Ai: A){
        for (int i = 1; i <= D; i++){
            if (i * Ai + 1 <= D) X++;
        }
    }
    cout << X << endl;
}

Measured memory_bytes: 256
import math

MAX=10**6+3
table = list(range(MAX))
i=2
n=MAX
while i<n:
    table[i] = 2
    i+=2
p=3
while p*p<=n:
    if table[p]<p:
        p+=2
        continue
    x=p
    while x<=n:
        table[x]=p
        x+=p
    p+=2


def primeFactorSet(n):
    result = set()
    while table[n]!=1:
        result.add(table[n])
        n //= table[n]
    return result
    

n = int(input())
A = list(map(int,input().split()))
pairwise = True
flags = [False for _ in range(MAX)]

for i in range(n):
    a=A[i]
    if pairwise:
        t = primeFactorSet(a)
        for p in t:
            if flags[p]:
                pairwise = False
                break
            flags[p]=True
    if i==0:
        g=a
    else:
        g=math.gcd(g,a)
    
if g>1:
    print("not coprime")
elif pairwise:
    print("pairwise coprime")
else:
    print("setwise coprime")

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

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

    int max_ = 0, min_ = 1000;
    vector<int> v(n);
    rep(i, n){
        cin >> v.at(i);
        max_ = max(v.at(i), max_);
        min_ = min(v.at(i), min_);
    }

    long long sum = 0, sum_min = INF;
    for(int i = min_; i <= max_; i++){
        rep(j, n){
            sum += abs(v.at(j)-i)*abs(v.at(j)-i);
        }
        sum_min = min(sum, sum_min);
        sum = 0;
    }

    cout << sum_min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100111];

LL calc(LL k) {
    REP (i, N) {
	if (k < A[i]) return 0;
	k -= k % A[i];
    }
    return k;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    LL lo, hi;

    lo = 0; hi = 1LL<<60;
    while (hi - lo > 1) {
	LL mid = (lo + hi) / 2;
	if (calc(mid) > 2) hi = mid;
	else lo = mid;
    }

    if (calc(lo) != 2) {
	puts("-1");
	return;
    }
    LL ans_max = lo;

    hi = lo;
    lo = 0;
    while (hi - lo > 1) {
	LL mid = (lo + hi) / 2;
	if (calc(mid) >= 2) hi = mid;
	else lo = mid;
    }

    if (calc(hi) != 2) {
	puts("-1");
	return;
    }
    LL ans_min = hi;
    printf("%lld %lld", ans_min, ans_max);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 640
n, k = map(int, input().split())
list = [0] * (n + 1)

while k != 0:
    k = k - 1
    d = int(input())
    a = map(int,input().split())
    for num in a:
        list[num] = 1
        
print(list.count(0) - 1)

Measured memory_bytes: 9060
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	string s,t;
	cin>>s>>t;


	cout<<t<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;

const int D = 3;
int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(D));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < D; ++j) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> dp(n, vector<int>(D));
    for (int j = 0; j < D; ++j) {
        dp[0][j] = a[0][j];
    }
    for (int i = 1; i < n; ++i) {
        dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }
    int res = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11264
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort()
    m=A[-1]

    score=INF
    a=-1
    for i in range(n-1):
        if(score>abs(A[i]-m/2)):
            score=abs(A[i]-m/2)
            a=A[i]
    print(m,a)
resolve()

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int h = o[0];
            int w = o[1];
            var a = new string[h];
            for(int i =0;i<h;++i)
            {
                a[i] = Console.ReadLine();

            }
            var list = new List<string>();
            list.Add(GetSharp(w));
            for(int i=0;i<h;++i)
            {
                sb.Clear();
                sb.Append("#");
                sb.Append(a[i]);
                sb.Append("#");
                list.Add(sb.ToString());
            }
            list.Add(GetSharp(w));

            foreach(string sz in list)
            {
                Console.WriteLine(sz);
            }
        }
        private static StringBuilder sb = new StringBuilder();
        private static string GetSharp(int w)
        {
            w += 2;
            sb.Clear();
            for(int i=0;i<w;++i)
            {
                sb.Append("#");
            }
            return sb.ToString();
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  int a; cin>>a;
  int s=a + a*a +a*a*a;
  cout<<s<<endl;
  
}








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

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

    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    int minv = pow(10, 9);
    int cnt = 0;
    int64_t ret = 0;
    for (int i = 0; i < N; i++) {
        if (abs(A[i]) < minv) minv = abs(A[i]);
        if (A[i] < 0) cnt++;
        ret += abs(A[i]);
    }
    if (cnt % 2 != 0) {
        ret -= minv * 2;
    }
    cout << ret << endl;


    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
//#define fisier 1
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int vis[1000003];
int a[200003];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        ++vis[a[i]];
    }
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        int flag=0;

        for(int j=2; j<=sqrt(a[i]); j++)
        {
            if(a[i]%j==0)
            {
                if(vis[j]) ++flag;
                if(vis[a[i]/j]) ++flag;

            }
        }
        if(a[i]==1 && vis[1]>=2) ++flag;
        else if(a[i]!=1 && (vis[1]>=1 || vis[a[i]]>=2)) ++flag;
        if(!flag) ++cnt;
    }
    cout<<cnt<<endl;


}



Measured memory_bytes: 8312
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

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; }


int main(){
    ll K;cin>>K;
    queue<ll> lun;
    for(ll i=1;i<=9;i++){
        lun.push(i);
    }
    for(ll i=0;i<K-1;i++){
        ll a = lun.front();
        lun.pop();
        ll m = a%10;
        if(m!=0){
            lun.push(10*a+m-1);
        }
        lun.push(10*a+m);
        if(m!=9){
            lun.push(10*a+m+1);
        }
    }
    cout<<lun.front()<<endl;


}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> L(N);
  REP(i,N) {
    int K;
    cin >> K;
    REP(j,K) {
      int l;
      cin >> l; --l;
      L[i].push_back(l);
    }
  }

  vector<vector<int>> S(M);
  REP(i,N)REP(j,L[i].size()) {
    S[L[i][j]].push_back(i);
  }

  UnionFind uf(N);
  REP(i,M){
    REP(j,S[i].size()) uf.unionSet(S[i][0], S[i][j]);
  }
  if(uf.size(0) == N) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}



Measured memory_bytes: 8952
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int modpow(int a, int p) {
	if (p == 0)return 1;
	if (p % 2 == 0) {
		int halfP = p / 2;
		int half = modpow(a, halfP);
		return half * half%mod;
	}
	else {
		return a * modpow(a, p - 1) % mod;
	}
}

vector<int> fact, fact_inv, inv;

/*  init_nCk :二項係数のための前処理
	計算量:O(n)
*/
void init_nCk(int SIZE) {
	fact.resize(SIZE + 5);
	fact_inv.resize(SIZE + 5);
	inv.resize(SIZE + 5);
	fact[0] = fact[1] = 1;
	fact_inv[0] = fact_inv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < SIZE + 5; i++) {
		fact[i] = fact[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
}

/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
	計算量:O(1)
*/
long long nCk(int n, int k) {
	if(n < k)return 0;
	if(n < 0 || k < 0)return 0;
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}
signed main(void) {
	string s;
	int k;
	cin >> k >> s;
	int n = s.size();
	int ans = 0;
	init_nCk(n + k);
	rep(i, k+1) {
		int tmp = modpow(25, k - i);
		tmp *= modpow(26, i);
		tmp %= mod;
		tmp *= nCk((k -i+n-1), (n - 1));
		tmp %= mod;
		ans += tmp;
		ans %= mod;
	}
	print(ans);
}

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != -1)
			{
				double x = 1;
				double y = 0;
				for (int i = 2; i <= n; i++)
				{
					double d = Math.Sqrt(x * x + y * y);
					double dx = -y / d;
					double dy = x / d;
					x += dx;
					y += dy;
				}
				Console.WriteLine("{0}", x);
				Console.WriteLine("{0}", y);
			}
		}
	}
}

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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int five = 0, seven = 0;
  for(int i = 0 ; i < 3 ; i++){
    if(a[i]==5){
      five++;
    }else if(a[i]==7){
      seven++;
    }
  }
  if(five==2 && seven==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256