akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;


class UnionFindTree
{
   private:
      int N;
      int *rootnum;
      int *rank;
      int *unionnum;

   public:
      UnionFindTree(int n){
         /*0からn-1までの要素をunionとしてもつ*/
         N = n;
         rootnum = new int[N];
         rank = new int[N];
         unionnum = new int[N];
         for( int i = 0 ; i < N ; i++ ){
            rootnum[i] = i;
            rank[i] = 0;
            unionnum[i] = 1;
         }
      }
      
      int Find( int j ){
         if( rootnum[j] == j ){
            return j;
         }
         else{
            return rootnum[j] = Find(rootnum[j]);
         }
      }

      void Union( int i , int j ){
         int x = Find(i);
         int y = Find(j);
         if( x == y ) return;
         N--;
         if( rank[x] < rank[y] ){
            rootnum[y] = x;
            unionnum[x] += unionnum[y];
         }else{
            rootnum[x] = y;
            unionnum[y] += unionnum[x];
            if( rank[x]==rank[y] ) rank[x]++;
         }
      }

      int Num( int j ){
         /*与えられた要素の入っている集合の要素数を答える*/
         int x = Find(j);
         return unionnum[x];
      }

      int UnionNum(){
         /*集合の数を答える*/
         return N;
      }

      ~UnionFindTree(){
         delete rootnum;
         delete rank;
         delete unionnum;
      }

};


int main(){
   int N;
   cin >> N;
   vector<pair<int,int>> xs;
   vector<pair<int,int>> ys;
   vector<pair<int,pair<int,int>>> edges;
   for(int i = 0 ; i < N; i++){
      int x,y;
      cin >> x >> y;
      xs.emplace_back(make_pair(x,i));
      ys.emplace_back(make_pair(y,i));
   }
   sort(xs.begin(),xs.end());
   sort(ys.begin(),ys.end());
   
   for(int i = 0; i+1< N; i++ ){
      edges.emplace_back(make_pair(xs[i+1].first-xs[i].first,make_pair(xs[i].second,xs[i+1].second)));
      edges.emplace_back(make_pair(ys[i+1].first-ys[i].first,make_pair(ys[i].second,ys[i+1].second)));
   }
   sort(edges.begin(),edges.end());
   UnionFindTree uft(N);
   long long ans = 0;
   int rest = N-1;
   for(int i = 0 ; rest>0&&i<(int)edges.size(); i++){
      int weight=edges[i].first;
      int u=edges[i].second.first;
      int v=edges[i].second.second;
      if(uft.Find(u)!=uft.Find(v)){
         rest--;
         ans+=weight;
         uft.Union(u,v);
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 8980
<?php
list($a,$b,$c,$d)=explode(" ",trim(fgets(STDIN)));
$ans=(int)max($a*$c,$a*$d,$b*$c,$b*$d);
if($a<0 && $b>=0){
  $ans=max($ans,0);
}
if($c<0 && $d>=0){
  $ans=max($ans,0);
}
echo $ans;

Measured memory_bytes: 16228
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <class T>
bool uax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool uin (T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 1e5 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

set <int> st;

int f(int s) {
    if (s & 1)
        return s * 3 + 1;
    return s / 2;
}

int main () {
    to_pray();

    int s;
    cin >> s;
    int i = 1;

    while(!false) {
        if (st.count(s) > 0) {
            cout << i << '\n';
            break;
        }
        st.insert(s);
        s = f(s);
        ++i;
    }

    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cout << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;

pair<int,int>get(string s) {
    int mi = 0;
    int cur = 0;
    for (auto i:s) {
        if (i == '(') {
            cur++;
        }
        else {
            cur--;
        }
        mi = min(mi, cur);
    }
    return {cur,mi};
}
pair<int,int>get2(string s) {
    reverse(all(s));
    int mi = 0;
    int cur = 0;
    for (auto i:s) {
        if (i == ')') {
            cur++;
        }
        else {
            cur--;
        }
        mi = min(mi, cur);
    }
    return {cur,mi};
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector<pair<pii,int>>v1,v2;
    int n;
    cin >> n;
    ll tot = 0;
    vector<int>ans,ans2;
    f(n) {
        string s;
        cin >> s;
        pii p = get(s);
        tot += p.F;
        if (p.F >= 0) {
            v1.pb({p,i+1});
        }
        else {
            p = get2(s);
            v2.pb({p,i+1});
        }
        //cout << p.F <<' '<<p.S<<endl;
        //tot += p.F;
    }
    if (tot) {
        cout << "No\n";
        exit(0);
    }
    sort(v1.begin(), v1.end(), [](pair<pii,int> x,pair<pii,int> y){
        return x.F.S > y.F.S;
    });
    sort(v2.begin(), v2.end(), [](pair<pii,int> x,pair<pii,int> y){
        return x.F.S > y.F.S;
    });
    int cur = 0;
    for(auto i:v1) {
        if (i.F.S + cur < 0) {
            cout << "No\n";
            exit(0);
        }
        ans.pb(i.S);
        cur += i.F.F;
    }
    cur = 0;
    for(auto i:v2) {
        if (i.F.S + cur < 0) {
            cout << "No\n";
            exit(0);
        }
        ans2.pb(i.S);
        cur += i.F.F;
    }
    cout << "Yes\n";
}

Measured memory_bytes: 20964
import sys

cin = sys.stdin
# cin = open("in.txt", "r")

N = int(cin.readline())
s = cin.readline().rstrip()
s = s+s[0]

first_two = ['SS', 'SW', 'WS', 'WW']
SW_dict = {'S': 'W', 'W': 'S'}


# WA first time for only testing N+1==0
# test case
# 4
# xxxx

idList = ['S']*(N+2)
for f2 in first_two:
    idList[0] = f2[0]
    idList[1] = f2[1]
    for i in range(2, N+2):
        if idList[i-1]=='S':
            if s[i-1]=='o':
                idList[i] = idList[i-2]
            else:
                idList[i] = SW_dict[idList[i-2]]

        else: # i-1=='W'
            if s[i-1]=='o':
                idList[i] = SW_dict[idList[i-2]]
            else:
                idList[i] = idList[i-2]
    if idList[N]==idList[0] and idList[N+1]==idList[1]:
        print(''.join(idList[:-2]))
        exit(0)

print(-1)



Measured memory_bytes: 4852
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

void solve(){
    int n, k;

    cin >> n >> k;
    cout << floor(log(n) / log(k)) + 1 << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 640
def main():
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    pairs1 = []
    pairs2 = []
    for i in range(N):
        ref = A[i]
        count1 = 0
        count2 = 0
        for j in range(N):
            if j < i and A[j] < ref:
                count2 += 1
            elif j > i and A[j] < ref:
                count1 += 1
        count2 += count1
        pairs1.append(count1)
        pairs2.append(count2)

    # print(A)
    # print(pairs1)
    # print(pairs2)
    ans = 0
    for i in range(N):
        ans += pairs1[i]*K % div
        ans += pairs2[i]*K*(K-1)//2 % div
    return ans % div

if __name__ == '__main__':

    print(main())

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  ll ans = 0;

  ll n = s.length()/2;
  REP(i,n){
    if(s[i]!=s[s.length()-1-i]) ans ++;
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
using namespace std;
#define int long long
void fast(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int32_t main()
{
    fast();
    int n, k;
    cin >> n >> k;
    int l = 0; int r = 1e18;
    // n - m*k <= k
    // n/k - m <= 0;
    // n/k <= m
    int m=n/k;
    int t= n-m*k;
    cout << min(t,abs(k-t)) << "\n";
}

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

int N, M, Q, ans;
int a[100], b[100], c[100], d[100];
deque<int> A;

void solve(int num, int now) {
  if (num == N) { 
    int tmp = 0;
    for (int i = 0; i < Q; ++i) {
      int ax = a[i]-1;
      int bx = b[i]-1;
      // printf("%d ", A[i]);
      /*
      if (A[0] >= 4) {
        printf("%d ", A[i]);
      }*/
      if (A[bx] - A[ax] == c[i]) {
        tmp += d[i];
      }
    }
    // printf("%d\n", tmp);
    /*
    if (A[0] >= 4) {
      printf("%d\n", tmp);
    }*/
    ans = max(ans, tmp);
  } else {
    if (now == M) {
      A.push_back(now);
      solve(num+1, now);
      A.pop_back();
    } else {
      A.push_back(now);
      solve(num+1, now);
      A.pop_back();
      A.push_back(now+1);
      solve(num+1, now+1);
      A.pop_back();
      solve(num, now+1);
    }
  }
  return;
}
 
int main () {
  cin >> N >> M >> Q;
  ans = 0;
  for (int i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  for (int i = 1; i <= M; ++i) {
    A.push_back(i);
    solve(1, i);
    A.pop_back();
  }
  printf("%d\n", ans);
  return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	char s[n+1];
	scanf("%s", s);
	
	int ans = 0;
	for(int i=0; i<10; i++) for(int j=0; j<10; j++) for(int k=0; k<10; k++){
		int m[] = {i, j, k}, idx = 0;
		for(int l=0; l<n; l++){
			if(idx>2) break;
			if(s[l]-'0'==m[idx]) idx++;
		}
		if(idx>2) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp1, tmp2;
    string S;
    bool flag=true;
    
    cin >> A >> B ;
    
    ans = A+2*(B-A);
    cout << ans << endl;

    // if(A == B)
    // 	cout << C <<endl;
    // else if (B==C)
    // 	cout << A <<endl;
    // else
    // 	cout << B <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

int h,w,d;
int a[301][301];
map<int,pii> m;
vector< vector<int> > pre(90005);


int main()
{
    cin >> h >> w >> d;
    for(int i=0;i<h;++i) for(int j=0;j<w;++j) cin >> a[i][j], m[a[i][j]] = pii(i,j);
    for(int i=1;i<=d;++i)
    {
        pre[i].push_back(0);
        for(int j=i+d; j<=h*w;j+=d)
        {
            pii last = m[j-d];
            pii cur = m[j];
            pre[i].push_back(pre[i][pre[i].size()-1] + abs(last.x-cur.x)+abs(last.y-cur.y));
        }
    }
    int q,l,r; cin >> q;
    while(q--)
    {
        cin >> l >> r;
        int posl = l/d, posr = r/d, pos = l%d;
        if(l%d==0) --posl,--posr,pos=d;
        int ans = pre[pos][posr]-pre[pos][posl];
        cout << ans << endl;
    }
}



Measured memory_bytes: 11392
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
	string str;
	int count = 0, ans = 0;
	cin >> str;
	for (size_t i = 0; i < str.length(); i++) {
		if (str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T') {
			count++;
		}
		else {
			ans = max(ans, count);
			count = 0;
		}
	}
	ans = max(ans, count);
	cout << ans;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top = 0;
int S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a;
  int b;
  char s[100];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(b + a);
    }
    else if(s[0] == '-'){
      a = pop();
      b = pop();
      push(b - a);
    }
     else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(b * a);
    }
    else if(s[0] == '/'){
      a = pop();
      b = pop();
      push(b / a);
    }
    else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2128
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLine().trim().toInt()
    val xList = sc.nextLine().trim().split(' ').map { it.toInt() }

    var minCost = Integer.MAX_VALUE
    for (x in 1..100) {
        val newCost = costAtX(x, xList)
        minCost = if (newCost < minCost) newCost else minCost
    }
    println(minCost)
}

fun costAtX(x: Int, points: List<Int>): Int {
    var cost = 0
    for (point in points) {
        cost += (x - point) * (x - point)
    }
    return cost
}


Measured memory_bytes: 34232
import collections

local = False
if local:
    file = open("C.txt", "r")

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

K,N = [int(_) for _ in inp().split()]
arr = [int(_) for _ in inp().split()]

temp = 0
max_dist = -1

for a in arr:
    cur_dist = a-temp

    max_dist = max(max_dist, cur_dist)

    temp = a

max_dist = max(max_dist, arr[0] + K-temp)

print(str(K-max_dist))

Measured memory_bytes: 77900
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> grid(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> grid[i][j];
        }
    }
    vector<int> exist(h, -1);
    int idx = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (grid[i][j] == '#') // 列にイチゴがあるかを確認
            {
                for (int k = idx; k <= i; k++)
                {
                    exist[k] = i;
                }
                idx = i + 1;
                break;
            }
        }
    }
    if (idx != h)
    {
        for (int j = idx; j < h; j++)
        {
            exist[j] = idx - 1;
        }
    }
    // print(exist);
    vector<vector<int>> ans(h, vector<int>(w, -1));
    for (int i = 0; i < h; i++)
    {
        if (exist[i] == i)
        {
            int idx = 0;
            for (int j = 0; j < w; j++)
            {
                if (grid[i][j] == '#')
                {
                    for (int k = idx; k <= j; k++)
                    {
                        ans[i][k] = j;
                    }
                    idx = j + 1;
                }
            }
            if (idx != w)
            {
                for (int j = idx - 1; j < w; j++)
                {
                    ans[i][j] = idx - 1;
                }
            }
        }
        // print(ans[i]);
    }
    // cout << "+++" << endl;
    idx = 1;
    map<string, int> mp;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (j)
            {
                cout << ' ';
            }
            string num = "";
            num += to_string(exist[i]);
            num.push_back('-');
            num += to_string(ans[exist[i]][j]);
            if (mp.count(num))
            {
                cout << mp[num];
            }
            else
            {
                mp[num] = idx;
                ++idx;
                cout << mp[num];
            }
        }
        cout << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
};

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

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; 
    ll x;
    ll a = 0, b = 0;
    map<ll, int> m;
    cin >> n;
    rep(i,n){
        cin >> x; 
        m[x]++;
    }
    map<ll, int>::reverse_iterator it = m.rbegin();
    for(it; it!=m.rend(); it++){
        if(it -> second > 1){
            if(a==0 && b == 0 && it->second >= 4){
                a = it->first;
                b = it->first;
                break;
            }
            else if(a == 0 && it->second >= 2){
                a = it->first;
            }
            else if(a != 0 && b==0 && it->second >=2){
                b = it->first;
                break;
            }
        }
    }
    cout << a*b;
    return 0;
}


Measured memory_bytes: 9780
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    char c;
    cin >> c;
    char res = (c + 1);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>to(100000);
vector<int>done;
vector<int>memo;
int dp(int i){
  if (done.at(i)){
  return memo.at(i); 
  }
  else{
  memo.at(i)=0;
  for (int b:to.at(i)){
	memo.at(i)=max(memo.at(i),dp(b)+1);
  }
    //当たり前やんか、一回触ったらそれをdoneに書き込まないと
    done.at(i)=1;
    
return memo.at(i);
  }
}
/*i=0  3               
1     2
2     0
3     1
 4    4

0(3 2)
1(2 3)
2(0)
3(2)
4(2 1 0)*/


int main(){
//入力は同じでいい
  int N,M;
  cin >>N>>M;
  done.resize(N);
  memo.resize(N);//これはdp(i)の値をmemo.at(i)に入れる。
   
for(int i= 0;i<M;i++){
  int a,b;
  	cin >>a>>b;
  --a;
  --b;
  //0番目からのスタートにしたいから。
  to.at(a).push_back(b);
 //これで木の入力は済んだはず
}
 priority_queue<int>q;
 for (int i=0;i<N;i++){
   //cout <<dp(i)<<endl;//dpを出力させる
   q.push(dp(i));//ここでdp(i)はi番目出発の最長経路を表す数値 or 戻り値でそれを返す関数。
 }
 cout <<q.top()<<endl; 
}


Measured memory_bytes: 9852
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int N=s.nextInt();
		int all=0;
		int i=0;
		
		for(i=1;i<=N;i++){
			all+=i;
		}
		System.out.print(all);

	}

}

Measured memory_bytes: 21972
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a /= 2
            b += a
        elif a%2 == 1:
            a -= 1
            a /= 2
            b += a
    elif i%2 == 1:
        if b%2 == 0:
            b /= 2
            a += b
        elif b%2 == 1:
            b -= 1
            b /= 2
            a += b
print(int(a),int(b))


Measured memory_bytes: 3064
N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

class SegmentTree():
    def __init__(self, n, op, e):
        self.n = n
        self.op = op
        self.e = e
        self.log = (n - 1).bit_length()
        self.size = 1 << self.log
        self.d = [e] * (2 * self.size)

    def update(self, k):
        self.d[k] = self.op(self.d[2 * k], self.d[2 * k + 1])

    def build(self, arr):
        #assert len(arr) <= self.n
        for i, a in enumerate(arr):
            self.d[self.size + i] = a
        for i in range(1, self.size)[::-1]:
            self.update(i)

    def set(self, p, x):
        #assert 0 <= p < self.n
        p += self.size
        self.d[p] = x
        for i in range(1, self.log + 1):
            self.update(p >> i)

    def get(self, p):
        #assert 0 <= p < self.n
        return self.d[p + self.size]

    def prod(self, l, r):
        #assert 0 <= l <= r <= self.n
        sml = smr = self.e
        l += self.size
        r += self.size
        while l < r:
            if l & 1:
                sml = self.op(sml, self.d[l])
                l += 1
            if r & 1:
                r -= 1
                smr = self.op(self.d[r], smr)
            l >>= 1
            r >>= 1
        return self.op(sml, smr)

    def all_prod(self):
        return self.d[1]

    def max_right(self, l, f):
        #assert 0 <= l <= self.n
        #assert f(self.e)
        if l == self.n: return self.n
        l += self.size
        sm = self.e
        while True:
            while l % 2 == 0: l >>= 1
            if not f(self.op(sm, self.d[l])):
                while l < self.size:
                    l = 2 * l
                    if f(self.op(sm, self.d[l])):
                        sm = self.op(sm, self.d[l])
                        l += 1
                return l - self.size
            sm = self.op(sm, self.d[l])
            l += 1
            if (l & -l) == l: return self.n

    def min_left(self, r, f):
        #assert 0 <= r <= self.n
        #assert f(self.e)
        if r == 0: return 0
        r += self.size
        sm = self.e
        while True:
            r -= 1
            while r > 1 and (r % 2): r >>= 1
            if not f(self.op(self.d[r], sm)):
                while r < self.size:
                    r = 2 * r + 1
                    if f(self.op(self.d[r], sm)):
                        sm = self.op(self.d[r], sm)
                        r -= 1
                return r + 1 - self.size
            sm = self.op(self.d[r], sm)
            if (r & -r) == r: return 0

st = SegmentTree(300001, max, 0)

for i in range(N):
    a = A[i]
    l = r = 0
    v = st.prod(max(0, a - K), min(a + K + 1, 300001))
    st.set(a, max(st.get(a), v + 1))

print(st.all_prod())

Measured memory_bytes: 126496
#include <stdio.h>
#include <limits.h>

int main() {
	long n,count,x,i;
	scanf("%ld",&n);
	if(n&1) {
		printf("0");
		return 0;
	}
	count=0;
	x=10;
	while(n>=x){
		count+=(n/x);
		if(x>(LONG_MAX/5)) {
			break;
		}
		x*=5;
	}
	printf("%ld",count);
	return 0;
}

Measured memory_bytes: 128
import numpy as np

N,K = map(int,input().split())
x = list(map(int,input().split()))
min_t = None
for i in range(N-K+1):
  t = min(abs(x[i])+abs(x[i]-x[i+K-1]), abs(x[i+K-1])+abs(x[i]-x[i+K-1]))
  if min_t == None:
    min_t = t
  if min_t > t:
    min_t = t
print(min_t)
  



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n;
int a[125252];
int s[125252];

const int N = 1<<18;
int bit[N+10];
void init(){
  REP(i,N+10)bit[i]=0;
}
void add(int p, int v){
  for(;p<=N;p+=p&-p){
    bit[p] += v;
  }
}
int sum(int p){
  int ret = 0;
  for(;p>0;p-=p&-p){
    ret += bit[p];
  }
  return ret;
}

// ok(x) : 答えはx以上か？
// <--> 数列mにx未満の数が n*(n+1)/4+1 個未満であるか？
bool ok(int x){
  init();
  const int C = 1<<17;
  int base = C;
  ll cnt = 0;
  REP(i,n){
    int b = a[i]<x ? -1 : 1;
    base -= b;
    add(base+b, 1);
    cnt += sum(base-1);
  }
  ll tgt = (ll)n*(n+1)/4+1;
  return cnt < tgt;
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)s[i] = a[i];
  sort(s,s+n);
  int low = 0, high = n;
  while(low+1<high){
    int x = (low+high)/2;
    // ok(y) : 答えはy以上か？
    if(ok(s[x])){
      low = x;
    }else{
      high = x;
    }
  }
  printf("%d\n", s[low]);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n, m, count=0, ans=0,a,b,c,k;
  string s;
 
  cin >> a >> b >> c >> k;
  ans=min(k,a);
  k-=a;
  if(k<=0) {
    cout << ans << endl;
    return 0;
  }

  k-=b;
  if(k<=0) {
    cout << ans << endl;
    return 0;
  }
  ans-=k;
  cout << ans << endl;
  

}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(2000000)
input = sys.stdin.readline
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)

    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
        else:
            self.parents[xRoot] = yRoot
            if self.size[xRoot] == self.size[yRoot]:
                self.size[yRoot]+=1

N,M = map(int,input().split())
P = list(map(int,input().split()))
dic = {}
dic2 = {}
for i in range(1,N+1):
    dic[P[i-1]]=i
    dic2[i]=P[i-1]

tree = UnionFind(N)
for _ in range(M):
    x,y = map(int,input().split())
    tree.union(x,y)

indexGroup = {}
for i in range(1,N+1):
    root = tree.find(i)
    if root not in indexGroup:
        indexGroup[root]=set()
    indexGroup[root].add(i)

for p,i in dic.items():
    root = tree.find(i)
    if p in indexGroup[root]:
        n = dic2[p]
        dic[p] = p
        dic2[p] = p
        dic[n] = i
        dic2[i] = n

count = 0
for p,i in dic.items():
    if p==i:
        count += 1
print(count)



Measured memory_bytes: 105168
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	ll n, m, k;
	cin>>n>>m>>k;
	vector<vector<P> > l(n);
	REP(i, m) {
		ll a, b, c;
		cin>>a>>b>>c;
		--a;
		--b;
		l[a].pb(P(b, c));
		l[b].pb(P(a, c));
	}
	vector<ll> shop(k);
	REP(i, k) {
		ll gomi;
		cin>>gomi;
		--gomi;
		shop[i] = gomi;
	}
	priority_queue<P> que;
	vector<ll> dir(n, INF * INF);
	REP(i, k) {
		que.push(P(0, shop[i]));
		dir[shop[i]] = 0;
	}
	while(!que.empty()) {
		P np = que.top();
		que.pop();
		if(dir[np.second] != np.first) continue;
		REP(i, l[np.second].size()) {
			if(dir[l[np.second][i].first] > dir[np.second] + l[np.second][i].second) {
				dir[l[np.second][i].first] = dir[np.second] + l[np.second][i].second;
				que.push(P(dir[l[np.second][i].first], l[np.second][i].first));
			}
		}
	}
	ll res = 0;
	REP(i, n) {
		REP(j, l[i].size()) {
			ll k = (ll)(double(dir[l[i][j].first] - dir[i] + l[i][j].second) / 2 + 0.5);
			res = max(res, dir[i] + k);
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 8776
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint solve (set<int> &num, multiset<int> &nums){
    lint ret = 0;
    for (auto itr = num.begin(); itr != num.end(); ++itr){
        lint k = *itr;
        lint count = nums.count(k) + nums.count(k + 1) + nums.count(k - 1);
        ret = max(ret, count);
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, a;
    cin >> n;
    multiset<int> nums;
    set<int> num;
    for (int i=0; i<n; ++i){
        scanf("%d", &a);
        nums.insert(a);
        num.insert(a);
    }
    cout << solve(num, nums) << "\n";
    return 0;
}

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

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

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

    int ans = 0;
    for (int i = 1; i < n; i++)
        if (h[i - 1] > h[i])
            ans += h[i - 1] - h[i];
    ans += h[n - 1];

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

Measured memory_bytes: 3624
// 大整数整除 abc176-B 
// a%b?=0
// 每a一位数%b相加最后加和判断取模
// 如18%9
// 1%9=1,(1+8)%9==0 故成立18%9==0
  
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;
string a;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>a;
	ll ans=0,r=0;
	/*for (ll i=0;i<a.size();i++)
	{
		ans+=a[i]-'0';
	}*/
	/*if (ans%9==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	*/
	for (ll i=0;i<a.size();i++)
	{
		ans=r*10+a[i]-'0';
		r=ans%9;
	}
	if (r==0)
	cout<<"Yes"<<endl;
	else 
	cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 3788
#include<stdio.h>

int main(){
	int r,c;
	scanf("%d %d",&r,&c);
	int ary1[r][c];
	int i,j;
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&ary1[i][j]);
		}
	}
	int k=0;
	int a=0;
	int ary2[c+1];
	for (i=0;i<=c;i++){
		ary2[i]=0;
	}
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			printf("%d ",ary1[i][j]);
			a+=ary1[i][j];
			ary2[j]+=ary1[i][j];
			if(j+1==c){
				printf("%d\n",a);
				ary2[j+1]+=a;
				a=0;
			}
		}
	}
	for(i=0;i<=c;i++){
		printf("%d",ary2[i]);
		if(i!=c){
			printf(" ");
		}
		if(i==c){
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s, t; cin >> s;
	for(char c : s){
		if(t.size() && t[t.size() - 1] == 'S' && c == 'T') t.pop_back();
		else t += c;
	}
	cout << t.size() << endl;
	return 0;
}

Measured memory_bytes: 916
h, w, k = map(int, input().split())
s = [list(input()) for i in range(h)]
l = [[0] * w for i in range(h + 1)]
c = 1
for i in range(h):
    if "#" in s[i]:
        for j in range(w):
            l[i + 1][j] = c
            if s[i][j] == "#" and "#" in s[i][j + 1:]:
                c += 1
        c += 1
        if l[i][0] == 0:
            m = i
            while l[m][0] == 0:
                l[m] = l[m + 1]
                m -= 1
                if m < 1:
                    break
    else:
        l[i + 1] = l[i]
for i in l[1:]:
    print(*i)

Measured memory_bytes: 13404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int MOD = 998244353;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y) {
	return ((ll)x * y) % MOD;
}

const int N = 4010;
int n;
int a[N];
int b[N];
int c[N];
int m, L1, L2;
char s[N];
int p2[N];

void reduce() {
	//cerr << "REDUCE" << endl;
	while(true) {
		//cerr << L1 << " " << L2 << endl;
		if (L1 > L2) {
			swap(a, b);
			swap(L1, L2);
		}
		for (int i = 0; i < L1; i++)
			b[L2 - L1 + i] ^= a[i];
		while(L2 > 0 && b[L2 - 1] == 0) L2--;
		if (L2 == 0) break;
	}
}

int solve() {
	if (L1 > m) return 0;
	for (int i = 0; i < m; i++)
		b[i] = 0;
	int ans = 0;
	for (int i = m - 1; i >= L1 - 1; i--) {
		if (c[i] == 1) ans = add(ans, p2[1 + i - L1]);
		if (b[i] != c[i]) {
			for (int j = 0; j < L1; j++)
				b[i - L1 + 1 + j] ^= a[j];
		}
	}
	int p = L1 - 1;
	while(p >= 0 && b[p] == c[p]) p--;
	if (p < 0 || b[p] < c[p]) ans = add(ans, 1);
	return ans;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	p2[0] = 1;
	for (int i = 1; i < N; i++)
		p2[i] = add(p2[i - 1], p2[i - 1]);

	scanf("%d", &n);
	scanf("%s", s);
	m = strlen(s);
	for (int i = 0; i < m; i++)
		c[i] = s[m - 1 - i] - '0';
	scanf("%s", s);
	L1 = strlen(s);
	for (int i = 0; i < L1; i++)
		a[i] = s[L1 - 1 - i] - '0';
	n--;
	while(n--) {
		scanf("%s", s);
		L2 = strlen(s);
		for (int i = 0; i < L2; i++)
			b[i] = s[L2 - 1 - i] - '0';
		reduce();
	}
	/*
	printf("%d ", L1);
	for (int i = 0; i < L1; i++)
		printf("%d", a[i]);
	printf("\n");
	*/
	printf("%d\n", solve());

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int i,n=0;
    cin>>s;
    for (i=0;i<s.length();i++)
    if (s[i]=='C') n=1;
    else if (s[i]=='F'&&n==1)
    { cout<<"Yes"<<endl; return 0; }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,y;
  cin>>n>>y;
  y=y/1000-n;
  int a,b,c;
  a=b=c=-1;
  int x=y%4;
  int r=x+(y-9*x)/36*4;
  int q=(y-9*r)/4;
  if(r>=0&&q>=0&&q+r<=n)
    {a=r;
     b=q;
     c=n-q-r;
     }
cout <<a<<" "<<b<<" "<<c<<endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {

    public static int max_array (int[] array) {
        int maximum = array[0];
        for (int i = 1; i < array.length; i++) {
            maximum = Math.max(maximum, array[i]);
        }

        return maximum;
    }

    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int hp = sc.nextInt();
        int[] a = new int[n];
        Integer[] b = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        int a_max = max_array(a);
        Arrays.sort(b, Collections.reverseOrder());

        long cnt = 0L;
        for (int i = 0; i < n; i++) {
            if (b[i] < a_max) {
                break;
            }
            cnt++;
            hp -= b[i];
            if (hp <= 0) {
                System.out.println(cnt);
                return;
            }
        }

        System.out.println(cnt+(int)Math.ceil((double)hp/(double)a_max));
    }
}

Measured memory_bytes: 83052
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
ll N,A,B;
int main() {
    cin >> N >> A >> B;
    if (A>B)swap(A,B);
    if (abs(A-B)%2==0) {
        cout << (abs(A-B)/2)<< endl;
    } else {
        cout << min((A+B-1)/2,(2*N-A-B+1)/2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int P;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=5005;
int n,res,t,cf[N],f[N];
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&P);
	cf[2]=1;for(R int i=3,j=n,k=2;i<=j;++i,--j,++k)cf[i]=cf[j]=k;
	f[0]=1;
	fp(i,2,n){
		R int p=cf[i];
		fp(j,p,n-1)upd(f[j],f[j-p]);
	}
	fp(i,0,n-1)upd(res,mul(n-i,f[i]));
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())

p = [((1+int(i))*int(i)/2)/int(i) for i in input().split()]

m = check = sum(p[0:K])
for i in range(K,N):
  check = check+p[i]-p[i-K]
  m = max(m,check)
print(m)

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

int main() {
  string N; cin>>N;
  int sum=0;
  for(auto v:N) {
    sum+=(int)v-48;
  }
  if(sum%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

const int INF = 1001001001;
int N, M, S, T;
int dist[100005][3];

signed main() {
  cin >> N >> M;
  vector<vector<int>> edge(N);
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    edge[x].push_back(y);
  }
  cin >> S >> T;
  --S; --T;

  rep(i,N) rep(j,3) dist[i][j] = INF;
  queue<pair<int, int>> Q;
  Q.push(make_pair(S, 0));
  dist[S][0] = 0;

  while(!Q.empty()) {
    int v = Q.front().first;
    int len = Q.front().second;
    Q.pop();
    int nlen = (len+1) % 3;
    for (int u : edge[v]) {
      if (dist[u][nlen] != INF) continue;
      dist[u][nlen] = dist[v][len] + 1;
      Q.push(make_pair(u, nlen));
    }
  }

  int ans = dist[T][0];
  if (ans == INF) ans = -3;
  cout << ans/3 << endl;
}


Measured memory_bytes: 6912
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int H, A;
	cin >> H >> A;

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


}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
double pi = 3.1415926535;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    string s;
    cin >> s;
    int cnt = 0;
    int n = s.size();
    REP(i,26){
        char c = i + 'a';
        int cnt1 = 0;
        REP(j,n){
            if(s[j] == c) cnt1++;
        }
        cnt += (cnt1*(cnt1-1))/2;
    }

    cout << (n*(n-1)/2)-cnt+1 << endl;
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

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

int main() {
  int N;
  char S[(int)3e5];
  scanf("%d%s", &N, S);

  int sum[N+1];
  sum[0] = 0;
  REP(i, N)
    sum[i+1] = sum[i] + (S[i] == 'W' ? 1 : 0);

  int ans = INF;
  REP(leader, N)
    ans = min(ans, sum[leader] + (N - leader - 1 - (sum[N] - sum[leader+1])));

  printf("%d\n", ans);
  return 0;
}


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


int main() {
  int a, p;
  cin >> a >> p;
  cout << (a*3+p)/2 << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main(void){
        int n, k, s = 0;

        vector<int> a;
        cin >> n >> k;
        while (n--){
                int v;
                cin >> v;
                a.push_back(v);
        }
        sort(a.begin(), a.end());
        for (int i = 0 ; i < k ; i++)
                s += a[i];
        cout << s;
        return (0);
}


Measured memory_bytes: 3636