akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

    
    int n,k;
    cin>>n>>k;
    ll ans=0;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    for(int l=0;l<=k;l++){
        for(int r=0;r<=k-l;r++){
            if(l+r>n)continue;
            vector<int> s;
            int d=k-l-r;
            ll now=0;
            for(int i=0;i<l;i++){
                s.push_back(v[i]);
                now+=v[i];
            }
            for(int i=n-1;i>=n-r;i--){
                s.push_back(v[i]);
                now+=v[i];
            }
            Sort(s);
            // cout<<"aaa"<<endl;
            for(int i=0;i<d;i++){
                if(i>=s.size()||s[i]>0)continue;
                now-=s[i];
            }
            ans=max(ans,now);
        }
    }
    fin(ans);


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<math.h>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N; cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    vector<int> dp(N+10);
    dp[1] = abs(h[1] - h[0]);
    rep(i,N-2){
        dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]),dp[i+1] + abs(h[i+2] - h[i+1]));
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define check system("pause")
#define all(x) (x).begin(),(x).end()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
const ll mod = 1e9+7;
const int N = 2e5+20;
#define dep(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mes(p,b) memset(p,b,sizeof(p))
#define sz(x) int(x.size())


ll a;
int p[N],e[N],num=0;
int f(ll a)
{
    int m=sqrt(a+0.5);//所有的取根号都要这么做
    for(int i=2;i<=m;i++)//一定是2开始，虽然可以很容检查出来 
    {
        if(a%i==0)
        {
            p[++num]=i;
            e[num]=0;
            while(a%i==0)
                e[num]++,a/=i;
            m=sqrt(a+0.5);//一个比较皮的常熟优化 
        }
    }
    if(a!=1)
    {
        p[++num]=a;
        e[num]=1;
    }
    return num;
}
int main(){
	cin>>a;
	f(a);ll ans=0;
	rep(i,1,num){
	//	de(e[i]); 
		ans+=(-1+sqrt(1+8*e[i]))/2;
	}
	cout<<ans;
  	return 0;
}



Measured memory_bytes: 3688
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean flag=false;
		String arare[] = new String[n];
		for(int i=0 ; i<n ; i++) {
			arare[i] = sc.next();
		}
		for(int k=0 ; k<arare.length ; k++) {
			if(arare[k].equals("Y")) {
				flag=true;
			}
		}
		if(flag) {
			System.out.println("Four");
		}else {
			System.out.println("Three");
		}
	}

}


Measured memory_bytes: 23124
package main

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

func process(in [4]int) (ret int) {
	var max int
	inited := false

	for _, v1 := range in[:2] {
		for _, v2 := range in[2:] {
			ret := v1 * v2
			if inited == false || max < ret {
				max = ret
				inited = true
			}
		}
	}
	return max
}

func scanNum() (n int) {
	fmt.Scanf("%d\n", &n)
	return
}

func scanStrings(n int) []string {
	sc := bufio.NewScanner(os.Stdin)

	ret := make([]string, n)
	for i := 0; i < n; i++ {
		if sc.Scan() {
			ret[i] = sc.Text()
		}
	}
	return ret
}

func main() {
	var in [4]int

	fmt.Scanf("%d %d %d %d", &in[0], &in[1], &in[2], &in[3])
	ret := process(in)
	fmt.Println(ret)
}


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

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += (ll)(N - i) * (i + 1);
    }
    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= (ll)u * (N - v + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>

// 入力文字列に含まれているアルファベット数を表示一覧にして表示
int main()
{
	// 'a': 0, 'b': 1,...に対応,大文字は小文字として扱って格納
	int aiAlphaList[26];
	char achInput[1200];
	int iCnt;
	int iIndex;	// 格納先のインデックス

	// 初期化
	for (iCnt = 0; iCnt < 26; iCnt++)
	{
		aiAlphaList[iCnt] = 0;
	}

	// EOFまで読み込み
	while(fgets(achInput, 1200, stdin) != NULL)
	{
		for (iCnt = 0; achInput[iCnt] != '\0' ; iCnt++)
		{
			if ('a' <= achInput[iCnt] && achInput[iCnt] <= 'z')		// 小文字
			{
				iIndex = achInput[iCnt] - 'a';
				aiAlphaList[iIndex]++;
			}
			else if ('A' <= achInput[iCnt] && achInput[iCnt] <= 'Z')	// 大文字
			{
				iIndex = achInput[iCnt] - 'A';
				aiAlphaList[iIndex]++;
			}
			else
			{
				// アルファベット以外は読み飛ばす
			}
		}
	}

	// カウント結果出力
	for (iCnt = 0; iCnt < 26; iCnt++)
	{
		printf("%c : %d\n", (iCnt + 'a'), aiAlphaList[iCnt]);
	}

	return 0;
}


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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> b;
        for(int i = 0; i < n; i++){
            int x;  cin>>x;
            b.push_back(x);
        }
        
        auto judge = [&]()->bool{
            if(b[0] != 1)   return false;
            for(int i = 1; i < b.size(); i++){
                if(b[i] != b[i-1]+1)    return false;
            }
            return true;
        };

        int ans = 0;
        for(;ans <= 10000; ans++){
            if(judge())    break;
            vector<int> v;
            for(int i = 0; i < b.size(); i++){
                if(b[i] != 1)   v.push_back(b[i]-1);
            }
            v.push_back(b.size());
            b = v;
        }
        if(ans > 10000) cout << -1 << endl;
        else            cout << ans << endl;
    }
    return 0;
}


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


int main()
{
	ll X,Y;
	cin>>X>>Y;
	if(X%Y==0)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<X<<endl;
	}
	return 0;
}


Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AMultipleOf2AndN solver = new AMultipleOf2AndN();
        solver.solve(1, in, out);
        out.close();
    }

    static class AMultipleOf2AndN {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n % 2 == 1) {
                n *= 2;
            }
            out.println(n);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
/*
フレームの描画
*/

#include<stdio.h>
int main(void){
  int h,w;/*フレームの縦、横の長さ*/
  int i,j;

  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0)
      break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i == 0 || i == h-1 || j == 0 || j == w-1)
	  printf("#");
	else
	  printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2040
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    ll a,b,k;
    cin >> a>>b>>k;
    if(k>a+b){
        a=0;
        b=0;
        cerr<<1<<endl;
    }else if(a<k&&k<=a+b){
        //cerr<<b+a-k<<endl;
        b+=a-k;
        a=0;
        
        //cerr<<2<<endl;
    }else{
        a-=k;
    }
    cout<<a<< ' '<<b<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    rep(i, m) cin >> b[i];
    int ans = 0;
    rep(i, n)
    {
        int ret = c;
        rep(j, m)
        {
            int t;
            cin >> t;
            ret += b[j] * t;
        }
        if (ret > 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b[100]={0},c=0;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a;i++){
        if(0<i){
            if(b[i]==b[i-1]) {
                b[i]=0;
                c++;
            }
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    string s; cin>>s;
    int q; cin>>q;
    while(q--){
        int k; cin>>k;
        ll cntD = 0, cntM = 0, cntDM = 0;
        ll ans = 0;
        for(int i=0; i<n; i++){
            if(0 <= i - k){
                if(s[i-k] == 'D'){
                    cntD--;
                    cntDM -= cntM;
                }
                else if(s[i-k] == 'M'){
                    cntM--;
                }
            }

            if(s[i] == 'D') cntD++;
            else if(s[i] == 'M'){
                cntM++;
                cntDM += cntD;
            }
            else if(s[i] == 'C'){
                ans += cntDM;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1948
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int n = sc.nextInt();
     long ans=0;
     for(int i=1;i<=n;i++){
      for(int j=1;j<=n/i;j++){
       ans += i*j;
      }
     }
     System.out.println(ans);

   }
}


Measured memory_bytes: 35768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i,n){cin >> v[i];}
    map<int,int> mp;
    for(int &x:v){
        mp[x]++;
    }

    int result=0;
    for(pair<int,int> x : mp){
        if(x.first>x.second){
            result+=x.second;
        }else if(x.first<x.second){
            result+=x.second-x.first;
        }
    }
    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 5120
#include <iostream>

using namespace std;

int main()
{
  string S;
  cin >> S;
  int n = 0;

  for (size_t i = 0; i < S.size(); i++) {
    if (S[i] == '+') {
      n++;
    } else {
      n--;
    }
  }

  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var (a,b) = scan.nextLine().split(" ").map{ it.trim().toLong() }.toTypedArray()
    var arr = scan.nextLine().split(" ").map{ it.trim().toLong() }.toTypedArray()
    arr = arr.sortedArray()
    var ans : Long = 0
    for(i in 0..b-1)
        ans +=arr[i.toInt()]
    println(ans)
}


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

int main() {
  int n,count = 0;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  bool flag = true;
  while(flag) {
    flag = false;
    for(int i = n-1; i > 0; i--) {
      if(a[i] < a[i-1]) {
        swap(a[i],a[i-1]);
        count++;
        flag = true;
      }
    }
  }
  
  rep(i,n) {
    if(i != n-1) cout << a[i] << ' ';
    else cout << a[i] << endl;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N,x;
    cin >> N >> x;
    int arr[N];
    for (int i = 0; i < N;i++){
        cin >> arr[i];
    }
    
    sort(arr, arr+N);
    int count=0;
    for(int i= 0; i< N;i++){
        if(x < 0){
            break;
        }
        x -= arr[i];
        count++;
    }
    if(x != 0){
        count--;
    }
    cout << count;
}


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



int main() {
ll X;
cin >> X;
ll ans =  X + 1 - 2;
for(ll i = 1; i*i <= X; ++i){
if(X % i == 0){
ans = min(ans, i+X/i-2);
}
}

cout << ans << endl;
}



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

int main(){
  	int i,C(0);
  	string A;
  	cin >> A;
  	for(i = 0 ; i < A.length() ; i ++){
      if(A.at(0) != 'A') break;
      if(i > 0 && A.at(i) != 'C' && A.at(i) >= 'A' && A.at(i) <= 'Z' || A.at(1) == 'C' || A.at(A.length() - 1) == 'C') break;
      if(A.at(i) == 'C') C++;
    }
  	if(C != 1) i = 0;
  	if(i == A.length()) cout << "AC" << endl; else cout << "WA" << endl;
}

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)

typedef long long LL;
typedef long double LD;

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

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N;
    cin >> N;
    vector<int> w(N+1, 0);
    for (int i = 1; i <= N; i++)
        cin >> w[i];

    vector<int> l(N+1, w[1]), r(N+1, w[N]);
    for (int i = 2; i <= N; i++)
        l[i] = l[i-1] + w[i];
    for (int i = N-1; i >= 1; i--)
        r[i] = r[i+1] + w[i];

    int ans = abs(l[1] - r[2]);
    for (int i = 1; i < N; i++) {
        int temp = abs(l[i] - r[i+1]);
        if (temp < ans) ans = temp;
    }

    // for (int i = 1; i <= N; i++)
    //     cout << w[i] << " ";
    // cout << endl;
    // for (int i = 1; i <= N; i++)
    //     cout << l[i] << " ";
    // cout << endl;
    // for (int i = 1; i <= N; i++)
    //     cout << r[i] << " ";
    // cout << endl;

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int answer[100100];
bool visited[100100];

/*struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};*/
using Graph = vector<vector< pair<int,int> > >;

void dfs(Graph &G,int v){
    visited[v] = true;
    for(auto it :G[v]){
        if(visited[it.first])continue;
        if(it.second%2)answer[it.first]=answer[v]^1;
        else answer[it.first]=answer[v];
        dfs(G,it.first);
    }
}

int main(){
    int n;
    cin >> n;
    Graph G(n);
    REP(i,n)answer[i]=0;
    REP(i,n)visited[i]=false;
    REP(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        G[a-1].push_back(make_pair(b-1,c));
        G[b-1].push_back(make_pair(a-1,c));
    }

    dfs(G,0);
    REP(i,n)cout << answer[i] << endl;
    return 0;
}

Measured memory_bytes: 8320
#include<cstdio>
#include<cstring>
#include<string>

int n,l;
char s[105][105];
char t[105];

int main()
{
	scanf("%d %d",&n,&l);
	for(int i = 1;i <= n;i++){
		scanf("%s",&s[i]);
		int j = 0;
		for(j = 1;j <= i;j++){
			if(strcmp(s[j],s[i]) > 0){
				//t = s[i];
				strcpy(t,s[i]);
				for(int k = i;k > j;k--){
					//s[k] = s[k - 1];
					strcpy(s[k],s[k - 1]);
				}
				//s[j] = t;
				strcpy(s[j],t);
				break;
			}
		}
	}
	for(int d = 1;d <= n;d++){
		printf("%s",s[d]);
	}
	return 0;
}

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

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

	string sa,sb;
	cin >> sa >> sb;

	int x = stoi( sa + sb );
	int y = (int)sqrt( x );

	cout << (y*y == x ? "Yes" : "No") << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m,k; cin>>m>>k;
    if (m==1){
        if (k>=1){
            cout<<"-1\n";
            return 0;
        }
        cout<<"0 0 1 1\n";
        return 0;
    }
    if (k>=(1<<m)){
        cout<<"-1\n";
        return 0;
    }
    cout<<k;
    rep(i,1<<m){
        if (i==k) continue;
        cout<<" "<<i;
    }
    cout<<" "<<k;
    RFOR(i,(1<<m)-1,0){
        if (i==k) continue;
        cout<<" "<<i;
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll X, K, D;
    cin >> X >> K >> D;
    X=abs(X);
    ll ans=0;
    ll times=abs(X)/abs(D);
    if(times>K){
        ans=X-D*K;
    }
    else{
        ll e=times;
        K-=e;
        X-=e*D;
        if(K%2==0){
            ans=X;
        }
        else{
            ans=abs(X-D);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>

int gcd(int a, int b){
	int r;
	if(a<b){
		r=a;
		a=b;
		b=r;
	}
	if(b==0){
		return a;
	}
	while(1){
		r=a%b;
		if(r==0){
			return(b);
		}
		a=b;
		b=r;
	}
}

int max(int a, int b){
	if(a>b){
		return a;
	}
	return b;
}

int main(){
	int N;
	scanf("%d",&N);
	int A[100000];
	int i;
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	int F[100000];
	int B[100000];
	F[0]=0;
	B[0]=0;
	for(i=0;i<N-1;i++){
		F[i+1]=gcd(F[i],A[i]);
		B[i+1]=gcd(B[i],A[N-1-i]);
	}
	int m;
	m=1;
	for(i=0;i<N;i++){
		m=max(m,gcd(F[i],B[N-1-i]));
	}
	printf("%d",m);
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
vector<int> v[200000];
int x[200000], y = 0, z = 0;
bool used[200000];
void mutu(int a, int b) {
	x[a] = b;
	if (b)z++;
	else y++;
	used[a] = true;
	f(i, v[a].size()) {
		if (!used[v[a][i]]) mutu(v[a][i], (b + 1) % 2);
	}
}
signed main() {
	int n;
	cin >> n;
	f(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	mutu(0, 0);
	if (min(y, z) <= n / 3) {
		int cnt = n / 3 - min(y, z), vx = 3, zz = 1;
		f(i, n) {
			if (i)cout << " ";
			if ((int)(y > z) == x[i]) {
				cout << vx;
				vx += 3;
			}
			else if (cnt) {
				cout << vx;
				vx += 3;
				cnt--;
			}
			else {
				cout << zz;
				zz++;
				if (zz % 3 == 0)zz++;
			}
		}
		return 0;
	}
	int vy = 1, vz = 2, cnt=1;
	f(i, n) {
		if (i)cout << " ";
		if (x[i]) {
			if (vz > n) {
				cout << cnt * 3;
				cnt++;
			}
			else {
				cout << vz;
				vz += 3;
			}
		}
		else {
			if (vy > n) {
				cout << cnt * 3;
				cnt++;
			}
			else{
				cout << vy;
				vy += 3;
			}
		}
	}
}


Measured memory_bytes: 19200
import sys

input = sys.stdin.readline

def comb(n, r):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

mod = 998244353
N, M, K = map(int, input().split())

fact = [1] * (N + 1)
for i in range(1, N + 1):
    fact[i] = (fact[i-1] * i) % mod #n!を計算
# print('fact:{}'.format(fact))
revfact = [1] * (N + 1) #逆元を定義
revfact[N] = pow(fact[N], mod - 2, mod) #n!のmod-2乗を計算
# print('revfact:{}'.format(revfact))
for i in reversed(range(1, N)): #N-1から1まで
    revfact[i] = ((i + 1) * revfact[i + 1]) % mod
# print('revfact:{}'.format(revfact))

ans = 0
for k in range(K + 1):
    ans += (M * pow(M - 1, N - 1 - k, mod) * comb(N - 1, k)) % mod
    ans %= mod
print(ans)

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


int main(){
  int n,k,ans=0;
  cin>>n>>k;
  vector<bool>ok(n);
  for(int i=0;i<k;i++){
    int d; cin>>d;
    for(int j=0;j<d;j++){
      int a; cin>>a;
      a--;
      ok[a]=1;
    }
  }
    for(int i=0;i<n;i++){
      if(!ok[i]) ans++;
    }
    cout<<ans;

  
 }


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
  int N;
  vector<long> A;
  cin >> N;
  for(int i = 0; i < N; i++){
    long tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  long max = A[0];
  long sum = 0;
  for(int i = 1; i < N; i++){
    if(A[i] < max){
      sum += max - A[i];
    }else if(A[i] > max){
      max = A[i];
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 5360
N=int(input())
p=list(map(int,input().split()))
s=set()
z=0
for i in range(N):
  p[i]//=400
  if p[i]<8:
    s.add(p[i])
  else:
    z+=1
print(max(1,len(s)),end=' ')
print(len(s)+z)

Measured memory_bytes: 61864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    if(s.size() == 3) Reverse(s);
    Cout(s);
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define F first
#define S second
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define N 200010
using namespace std;
void solve()
{
    ll n,m,k; cin>>n>>m>>k;
    vector<string> v(n);
    ll cnt=0,cnt1,ans=0;
    rep(i,0,n)
    {
        cin>>v[i];
        for(auto j:v[i])
            if(j=='#')
            cnt++;
    }

    rep(i,0,(1<<n))
    {
        cnt1=cnt;
        vector<string> tmp=v;
        rep(j,0,n)
        {
            if((i>>j)&1)
            {
                for(auto &k:tmp[j])
                {
                    if(k=='#')
                    {
                        cnt1--;
                        k='.';
                    }
                }
            }
        }

        rep(j,0,(1<<m))
        {
            vector<string> tmp1=tmp;
            ll cnt2=cnt1;
            rep(t,0,m)
            {
                if((j>>t)&1)
                {
                    for(int s=0;s<n;s++)
                    {
                        if(tmp1[s][t]=='#')
                        {
                            cnt2--;
                            tmp1[s][t]='.';
                        }
                    }
                }
            }
            if(cnt2==k)
            {
                ans++;
                //cout<<i<<" "<<j<<endl;
            }
        }
    }
    cout<<ans<<endl;
}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int t=1;
  //cin>>t;
  //freopen("b2.in", "r", stdin);
  //freopen("output2.txt", "w", stdout);
  for(int i=1;i<=t;i++)
  {
      solve();
  }
  return 0;
}



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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  for (int i = 0; i < N-2; i++) {
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2005;
const int MOD=1000000007;
int n,k;
int a[N];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(a[i]>a[j]) ans++;
	ans=ans*k%MOD;
	long long sn=0;
	for(int i=1;i<=n;i++)
	{
		int num=0;
		for(int j=1;j<=n;j++)
			if(a[j]>a[i]) num++;
		sn+=num;
	}
	sn%=MOD;
	long long sk=1LL*(k-1)*k/2%MOD;
	ans=(ans+sn*sk%MOD)%MOD;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3748
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

int n,m;
int s,t;
const ll mod = 1000000007;
const ll inf = 10000000000000000;
vector<pil> E[101010];

ll ds[101010];
ll dt[101010];

ll cs[101010];
ll ct[101010];

void dijkstra(int s, ll *d, ll *c){
    priority_queue<pli, vector<pli>, greater<pli>> pq;
    fill(d, d+n+1, inf);
    d[s] = 0;
    c[s] = 1;
    pq.emplace(0,s);
    while(!pq.empty()){
        auto p = pq.top(); pq.pop();
        if (d[p.second] < p.first)continue;
        for(auto e : E[p.second]){
            if (d[e.first] + e.second == d[p.second]){
                c[p.second] += c[e.first];
                c[p.second] %= mod;
            }
            if (d[p.second] + e.second < d[e.first]){
                d[e.first] = d[p.second] + e.second;
                pq.emplace(d[e.first], e.first);
            }
        }
    }
}

int main(){
    scanf("%d%d",&n,&m);
    scanf("%d%d",&s,&t);

    for(int i=0;i<m;i++){
        int u,v;
        ll d;
        scanf("%d%d%lld",&u,&v,&d);
        E[u].emplace_back(v,d);
        E[v].emplace_back(u,d);
    }

    dijkstra(s,ds,cs);
    dijkstra(t,dt,ct);

    ll ans = cs[t] * cs[t] % mod;
    ll shortest = ds[t];

    for(int i=1;i<=n;i++){
        if (ds[i] == dt[i] && ds[i] + dt[i] == shortest){
            ans -= cs[i] * ct[i] % mod * ct[i] % mod * cs[i] % mod;
            ans = (ans+mod)%mod;
        }
    }

    for(int u=1;u<=n;u++){
        for(auto e : E[u]){
            int v = e.first;
            ll d = e.second;
            if (ds[u] + dt[v] + d == shortest && ds[u]*2 < shortest && dt[v]*2 < shortest){
                ans -= cs[u] * ct[v] % mod * ct[v] % mod * cs[u] % mod;
                ans = (ans+mod)%mod;
            }
        }
    }

    printf("%lld\n", ans);
}


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

int main()
{
    int N;
    double ans=0;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        ans += 1.0/(double)A[i];
    }
    cout << fixed << setprecision(10);
    cout << 1.0/ans << endl;
}

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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

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

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);

    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i) {
      cin >> a[i];
    }
    reverse(a.begin(), a.end());

    vector<int> dp(n, MOD);
    dp[0] = a[0];
    for(int i=1;i<n;++i) {
      int pos = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
      dp[pos] = a[i];
    }

    int ans = lower_bound(dp.begin(), dp.end(), MOD) - dp.begin();
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 2e5 + 1;
int par[N] , sz[N];
int getp(int x){
	if(x == par[x]) return x;
	return par[x] = getp(par[x]);
}
int main(){
	int n , m;
	scanf("%d%d",&n,&m);
	for (int i = 0; i < n; ++i){
		par[i] = i;
		sz[i] = 1;
	}
	for (int i = 0,u,v; i < m; ++i){
		scanf("%d%d",&u,&v);
		u--,v--;
		u = getp(u);
		v = getp(v);
		if(u == v)continue;
		if(u > v)swap(u , v);
		par[v] = u;
		sz[u] += sz[v];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i){
		if(i == par[i]) ans = max(ans , sz[i]);
	}
	printf("%d\n",ans);
	
}	

Measured memory_bytes: 5372
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N, T;
  cin >> N >> T;
  int t[N];
  rep(i, N)
    cin >> t[i];
  //入力終了

  long long ans = 0;
  rep(i, N-1){
    ans += min(t[i+1]-t[i], T);
  }

  ans += T;

  //解答
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4368
import numpy as np
import math
import sys

n = list(map(int, input().split()))
a = list(map(int, input().split()))
a = np.asarray(a)

while True:
    tmpmin = np.min(a[a!=0])
    a[a!=tmpmin] %= tmpmin
    #print(a,tmpmin)
    if tmpmin == np.min(a[a!=0]):break
    if np.sum(a) == 0: break

print(tmpmin)

Measured memory_bytes: 23064
from heapq import heappush, heappop
def main():
    N, M, S = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        G[u].append((v, a, b))
        G[v].append((u, a, b))
    CD = [list(map(int, input().split())) for _ in range(N)]
    distance = [[1<<62]*2501 for _ in range(N)]
    q = [(0, 0, min(S, 2500))]
    distance[0][min(S, 2500)] = 0
    while q:
        d, v, vs = heappop(q)
        if distance[v][vs] != d:
            continue

        vc, vd = CD[v]
        ud = d + vd
        us = vs + vc
        if us > 2500:
            us = 2500
        if distance[v][us] > ud:
            distance[v][us] = ud
            heappush(q, (ud, v, us))

        for u, fee, b in G[v]:
            if fee > vs:
                continue
            ud = d + b
            us = vs - fee
            if us > 2500:
                us = 2500
            if distance[u][us] > ud:
                distance[u][us] = ud
                heappush(q, (ud, u, us))
    print("\n".join(str(min(d)) for d in distance[1:]))

main()


Measured memory_bytes: 24100
N, C = map(int, input().split())
ps = [[] for _ in range(C)]
for _ in range(N):
    s,t,c = map(int, input().split())
    ps[c-1].append((s,t))

imos = [0]*(10**5+1)
for c in range(C):
    ps[c].sort()
    cont = False
    for i, (s, t) in enumerate(ps[c]):
        if not cont:
            imos[s-1] += 1
        if i < len(ps[c])-1 and t == ps[c][i+1][0]:
            cont = True
        else:
            imos[t] -= 1
            cont = False

ans = t = 0
for a in imos:
    t += a
    ans = max(ans, t)
print(ans)



Measured memory_bytes: 17776
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define lp(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;

int main(){
	LL N, H;
	cin >> N >> H;
	vector<LL> a(N), b(N);
	LL maa=0;
	REP(i, N){
		cin>>a[i]>>b[i];
		maa=max(maa, a[i]);
	}
	vector<LL> u;
	foreach(i, b){
		if(i>maa)u.push_back(i);
	}
	sort(ALL(u), greater<LL>());
	int time = 0;
	foreach(i, u){
		H-=i;
		++time;
		if(H<=0){
			cout << time << endl;
			return 0;
		}
	}
	cout << time + (H + maa - 1) / maa << endl;
	return 0;
}


Measured memory_bytes: 2936
#include<stdio.h>
int main(){
  int ns,nt,i,sum=0,key,j,flag,l,m,r;
  int s[100000],t[100000];
  scanf("%d",&ns);
  for(i=0;i<ns;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&nt);
  for(i=0;i<nt;i++){
    scanf("%d",&t[i]);
  }
 
  for(i=0;i<nt;i++){
    l=0;
    r=ns;
    flag=0;
    key=t[i];
  while(l<r){
    m=(l+r)/2;
    if(key==s[m]){ flag=1;break; }
    if(key>s[m]){l=m+1;}
    else if(key<s[m]){r=m;}
  }
  if(flag==1) sum++;
  }
  printf("%d\n",sum);


  
  
  return 0;
}



Measured memory_bytes: 2368
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


template<unsigned int N> struct IsPrime {
	static const int size=(N>>5) + 1;
	unsigned int is_prime[size];
	constexpr IsPrime() : is_prime() {
		is_prime[0]=0x3;
		for(unsigned int i=2;i<N;i++)
		{
			if((is_prime[i>>5] & (1u<<(i&0x1f))) > 0)  continue;
			for(int j=i+i;j<N;j+=i)
				is_prime[j>>5]|=(1u<<(j&0x1f));
		}
	}
	constexpr bool operator[] (const int p) const
	{
		return (is_prime[p>>5] & (1u<<(p&0x1f))) == 0;
	}
};

template<int N> struct LikelyPrime {
	int sum[N+1];
	constexpr LikelyPrime(const IsPrime<N> pr) : sum() {
		for(int i=3;i<N;i++)
			sum[i+1]=sum[i]+((pr[i] && pr[(i+1)/2])?1:0 );
	}
	constexpr int operator[] (const int p) const
	{
		return sum[p];
	}
};

int main()
{
	io_speedup();
	constexpr IsPrime<100001> pr;
	constexpr LikelyPrime<100001> s(pr);
	int q=read<int>();
	REP(i,q)
	{
		int l,r;
		cin>>l>>r;
		print(s[r+1]-s[l]);
	}
}


Measured memory_bytes: 1024
N = int(input())
S = input()

ALIST = {
  'A': 1,
  'B': 2,
  'C': 3,
  'D': 4,
  'E': 5,
  'F': 6,
  'G': 7,
  'H': 8,
  'I': 9,
  'J': 10,
  'K': 11,
  'L': 12,
  'M': 13,
  'N': 14,
  'O': 15,
  'P': 16,
  'Q': 17,
  'R': 18,
  'S': 19,
  'T': 20,
  'U': 21,
  'V': 22,
  'W': 23,
  'X': 24,
  'Y': 25,
  'Z': 26
}

RLIST = {
  1: 'A',
  2: 'B',
  3: 'C',
  4: 'D',
  5: 'E',
  6: 'F',
  7: 'G',
  8: 'H',
  9: 'I',
  10: 'J',
  11: 'K',
  12: 'L',
  13: 'M',
  14: 'N',
  15: 'O',
  16: 'P',
  17: 'Q',
  18: 'R',
  19: 'S',
  20: 'T',
  21: 'U',
  22: 'V',
  23: 'W',
  24: 'X',
  25: 'Y',
  26: 'Z'
}

RESULT = ""
n = 0

for i in range(0, len(S)):
  n = ALIST[S[i]] + N
  if n > 26:
    n -= 26
  RESULT += RLIST[n]

print(RESULT)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int i,flag=0,n;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
        if(a[i]%2==0)
            if(a[i]%3!=0&&a[i]%5!=0)
            flag=1;
    if(flag==0)
        printf("APPROVED");
    else
        printf("DENIED");
    return 0;
}


Measured memory_bytes: 128
N = int(input())

FizzBuzz = []

for i in range(1, N+1):
  if i%3==0 and i%5==0:
    pass
  elif i%3==0:
    pass
  elif i%5==0:
    pass
  else:
    FizzBuzz.append(i)

print(sum(FizzBuzz))

Measured memory_bytes: 30060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,x,y;
        cin>>a>>x>>y;
        if(a*x<=y)
        cout<<a*x;
        else
        cout<<y;
    } 
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	sort(s.begin(), s.end());
	s.erase(std::unique(s.begin(), s.end()), s.end());
	cout << s.size();

}


Measured memory_bytes: 9600