akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
        var S = ReadLine();
        var c = S.ToCharArray();
        var ans = "No";

        for (int i = 0; i < inp[0] + inp[1];i++) {
            if (i < inp[0]) {
                if (c[i] < '0' || c[i] > '9') {
                    ans = "No";
                    break;
                }
            } else if (i == inp[0]) {
                if (!(c[i] == '-')) {
                    ans = "No";
                    break;
                }
            } else {
                if (c[i] < '0' || c[i] > '9') {
                    ans = "No";
                    break;
                }
            }
            ans = "Yes";
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int min;
	int max;
	long long sum;
	
	min = 0;
	max = 0;
	sum = 0;
	
	scanf("%d", &a);
	for (b = 1; b <= a; b++){
		scanf("%d", &c);
		if (b == 1){
			min = c;
			max = c;
			sum = 0;
		}
		if (c > max){
			max = c;
		}
		if (c < min){
			min = c;
		}
		sum += c;
	}
	
	printf("%d %d %lld\n", min, max, sum);
	
	
	return (0);
}

Measured memory_bytes: 600
#include<algorithm>
#include <iostream>
#include<bitset>
#include<vector>
using namespace std;
int main() {
	int n,ans; cin >> n;int cnt = 0;
	ans = 0;
	for (int i = 1; i <= n;i += 2) {
		for (int j = 1;j <= n;j++) {
			if (i % j == 0)
				cnt++;
			if (cnt == 8) {
				ans++;
				break;
			}
		}
		cnt = 0;
	}
	cout << ans << endl;
}

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

using namespace std;


int main()
{

int t;
cin>>t;
int arr[t];
double rahul=0;
for(int i=0;i<t;i++){
    cin>>arr[i];
}
for(int i=0;i<t;i++)
{
 rahul+=double(1)/double(arr[i]);
}
cout<<setprecision(15)<<fixed<<double(1)/double(rahul);


return 0;
}

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

using namespace std;

int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << " Good" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define INF 2e9+10
typedef pair<int,int> edge;

vector<edge> g[100010];
bool check[100010];
int p[100010];

bool solve(int v){
    if(abs(p[v]) > int(1e9)) return false;
    for(edge e : g[v]){
        int to = e.first;
        int d = e.second;
        if(p[to] == INF){
            p[to] = p[v] + d;
            if(!solve(to)) return false;
        }else if(p[v] + d != p[to]){
            return false;
        }
    }
    return true;
}

int main(void){
    int n,m;
    cin>>n>>m;
    rep(_,m){
        int l,r,d;
        cin>>l>>r>>d;
        g[l].push_back({r,d});
        g[r].push_back({l,-d});
    }

    rep(i,100010){
        p[i] = INF;
    }

    rep(i,n){
        if(p[i] != INF)continue;
        p[i] = 0;
        if(!solve(i)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 12032
#include<cstdio>
#include<cstdlib>
using namespace std;
int n;
const int N=200003;
int m1,m2,d[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
		if(d[i]>m1) m2=m1,m1=d[i];
		else if(d[i]>m2) m2=d[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==m1) printf("%d\n",m2);
		else printf("%d\n",m1);
	}
	return 0;
}

Measured memory_bytes: 2304
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }



int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) {
		int n, ans = 0;
		cin >> n;
		lop(i, n) {
			int x;
			cin >> x;
			ans += i % 2 == 0 and x % 2;
		}
		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

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

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

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

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC";
	}
	else if (r < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}
	return 0;
}


Measured memory_bytes: 256
from itertools import product

s = input()

li = product(['', '+'], repeat=len(s))
st = set()
for c in li:
    ss = ''.join([a + b for (a, b) in zip(s,c)])
    if ss[-1] != '+':
        st.add(ss)
ans = 0
for sss in st:
    ans += eval(sss)

print(ans)


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

using namespace std;

int main(){
        bool flag[30]={0};
        string str;
        cin>>str;
        bool suc=true;
        for(int i=0;i<(int)str.size();i++){
                if(flag[str[i]-'a']){
                        suc=false;
                        break;
                }
                flag[str[i]-'a']=true;
        }
        if(suc){
                cout<<"yes"<<endl;
        }
        else{
                cout<<"no"<<endl;
        }
        return 0;
}


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

int a;
int b;
int c;

void input() {
    cin >> a;
    cin >> b;
    cin >> c;
}

int main() {
    input();

    if(a < b && b < c){
        cout << "Yes" << endl;

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

    }

    return 0;
}


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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    deque <string> st;
    string s;
    cin >> s;
    st.push_back(s);
    bool ok = false;
    int q;
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
           ok ^= 1;
        }
        else {
            int f;
            string u;
            cin >> f >> u;
            if (ok) {
                if (f == 1) f = 2;
                else f = 1;
            }
            if (f == 1) st.push_front(u);
            else st.push_back(u);
        }
    }
    while (st.size()) {
        if (ok) {
            s = st.back();
            reverse(s.begin(), s.end());
            for (auto to : s) cout << to;
            st.pop_back();
        }
        else {
            cout << st.front();
            st.pop_front();
        }
    }


}


Measured memory_bytes: 11728
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    cout << r*r << endl;
    return 0;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

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

    int cnt = 0;
    for (int i = 1; i < n - 1; i++)
    {
        vector<int> v;
        for (int j = -1; j <= 1; j++)
            v.push_back(p[i - j]);
        sort(all(v));
        if (v[1] == p[i])
            cnt++;
    }
    cout << cnt << endl;
}

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

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

    cin >> A >> B >> C >> X;
    int count = 0;

    for(int a = 0; a <= A; a++){
        for(int b = 0; b <= B; b++){
            for(int c = 0; c <= C; c++){
                int sum = 500 * a + 100 * b + 50 * c;
                if(sum == X) count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
# frozen_string_literal: true

s = gets.chomp.chars.uniq

if s.include?('N') && !s.include?('S') ||
   s.include?('S') && !s.include?('N') ||
   s.include?('E') && !s.include?('W') ||
   s.include?('W') && !s.include?('E')
  puts :No
else
  puts :Yes
end

Measured memory_bytes: 1788
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
string S1,S2,S3;
int main(){
	cin>>S1>>S2>>S3;

	cout<<S1[0]<<S2[0]<<S3[0]<<endl;

	return 0;
}


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

int main() {
    int N;
    std::cin >> N;

    double res = 0;
    for (int i = 0; i < N; i++) {
        int A;
        std::cin >> A;
        res += 1.0 / A;
    }

    std::cout << std::fixed << std::setprecision(10);
    std::cout << 1 / res << "\n";
}

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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		while (true) {
			String line = sc.nextLine();
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			} else {
				List<Point> treasure = new ArrayList<>();
				for (int i = 0; i < n; i++) {
					line = sc.nextLine();
					String[] lineAry = line.split(" ");
					treasure.add(new Point(Integer.parseInt(lineAry[0]), Integer.parseInt(lineAry[1])));
				}
				line = sc.nextLine();
				int m = Integer.parseInt(line);
				int trecount = 0;
				Point mypoint = new Point(10, 10);
				for (int i = 0; i < m; i++) {
					line = sc.nextLine();
					String[] lineAry = line.split(" ");
					int d = Integer.parseInt(lineAry[1]);
					if (lineAry[0].equals("N")) {
						for (int j = 0; j < d; j++) {
							mypoint.setY(mypoint.getY() + 1);
							for (Point tmp : treasure) {// tresure?????????????????´????????????????????????????´¢
								if (tmp.getX() == mypoint.getX() && tmp.getY() == mypoint.getY()) {
									trecount++;
									treasure.remove(tmp);
									break;
								}
							}
						}
					}
					if (lineAry[0].equals("E")) {
						for (int j = 0; j < d; j++) {
							mypoint.setX(mypoint.getX() + 1);
							for (Point tmp : treasure) {// tresure?????????????????´????????????????????????????´¢
								if (tmp.getX() == mypoint.getX() && tmp.getY() == mypoint.getY()) {
									trecount++;
									treasure.remove(tmp);
									break;
								}
							}
						}
					}
					if (lineAry[0].equals("S")) {
						for (int j = 0; j < d; j++) {
							mypoint.setY(mypoint.getY() - 1);
							for (Point tmp : treasure) {// tresure?????????????????´????????????????????????????´¢
								if (tmp.getX() == mypoint.getX() && tmp.getY() == mypoint.getY()) {
									trecount++;
									treasure.remove(tmp);
									break;
								}
							}
						}
					}
					if (lineAry[0].equals("W")) {
						for (int j = 0; j < d; j++) {
							mypoint.setX(mypoint.getX() - 1);
							for (Point tmp : treasure) {// tresure?????????????????´????????????????????????????´¢
								if (tmp.getX() == mypoint.getX() && tmp.getY() == mypoint.getY()) {
									trecount++;
									treasure.remove(tmp);
									break;
								}
							}
						}
					}
				}
				if (trecount == n) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
		}
	}
}

class Point {
	private int x;
	private int y;

	public void setX(int inX) {
		x = inX;
	}

	public void setY(int inY) {
		y = inY;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public Point() {
		x = 0;
		y = 0;
	}

	public Point(int inX, int inY) {
		x = inX;
		y = inY;
	}
}

Measured memory_bytes: 55140
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res;
	
	long N; cin >> N;
	long K; cin >> K;

	res = N - K + 1;

	cout << res << endl;
}

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

int main() {
  int n, x; cin >> n >> x;
  int answer = 0;
  int minimum = 1001;
  
  for (int i = 0; i < n; i++) {
    int m; cin >> m;
    x -= m;
    answer++;
    minimum = min(minimum, m);
  }
  
  answer += x / minimum;
  cout << answer << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
ans = []
n.times do |i|
  if i % 2 == 0
    ans << a[i]
  else
    ans.unshift(a[i])
  end
end
ans = ans.reverse if n % 2 == 1
ans.each do |x|
  print "#{x} "
end
puts ""

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

using namespace std;

#define int long long
#define forinc(a,b,c) for(int a=b, _=c; a<=_; ++a)
#define fordec(a,b,c) for(int a=b, _=c; a>=_; --a)
#define forv(a,b) for(auto &a:b)
#define rep(i,n) forinc(i,1,n)
#define repv(i,n) forinc(i,0,n-1)

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
#define fasty ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

#define bit(x, i) (x >> (i) & 1ll)
#define on(x, i) (x | (1ll << (i - 1)))
#define off(x, i) (x & ~(1ll << (i - 1)))

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const int maxn=2e5+5;
int N;
db A[maxn];

int32_t main(){
    cin>>N;
    forinc(i,1,N) cin>>A[i];
    map<ii,int> cnt;
    forinc(i,1,N){
        ll x = round(1ll*A[i]*1e9);
        int _2 = 0, _5 = 0;
        while(x % 2 == 0){
            _2++;
            x /= 2;
        }
        while(x % 5 == 0) {
            _5++;
            x /= 5;
        }
        cnt[{_2, _5}]++;
    }
    ll ans = 0;
    forv(u, cnt) {
        forv(v, cnt) {
            if(u.fi.fi + v.fi.fi >= 18 && u.fi.se + v.fi.se >= 18) {
                if(u < v) {
                    ans += 1ll * u.se * v.se;
                } else if(u == v) {
                    ans += 1ll * u.se * (v.se - 1) / 2;
                }
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5280
#import numpy as np
def bit(x):
    ans = 2
    if x == 0:
        return 1
    else:
        while x>1:
            ans *= 2
            x -= 1
        return ans
n,m = map(int,input().split())
#print(bit(m))
lis = []
#bitlis = np.ones(m,dtype=bool)
#print(bitlis)
for i in range(m):
    tmp = list(map(int,input().split()))
    lis.append(tmp[1:])
swtlis = list(map(int,input().split()))
#print(lis)
bitlis = 0
p = 0
ans = 0
for i in range(bit(n)):
    for j in range(len(lis)):
        p = 0
        for k in lis[j]:
            #print(bin(bitlis),bin(k))
            if bitlis & bit(k-1) == bit(k-1):
                p += 1
        if swtlis[j] != p%2:
            break
        elif j == len(lis)-1:
            ans += 1
    bitlis += 1
print(ans)
    

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;


using namespace std;


int main() {
    int N, count = 0;
    cin >> N;
    string S;
    cin >> S;
    for (int i = 0; i < N; i++) {
      string T = S.substr(i, 3);
      if (T == "ABC") {
          count++;
      }
    }
    cout << count << endl;
    return 0;
}



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

using namespace std;
string s[2010];
int l[2010][2010],r[2010][2010],u[2010][2010],d[2010][2010];
int main(){
	int i,j,h,w,mx = 0;
	cin >> h >> w;
	for(i=0;i<h;i++){
		cin >> s[i];
	}
	for(i=0;i<h;i++){
		l[i][0] = 0; r[i][w-1] = 0;
		for(j=1;j<w;j++){
			if(s[i][j-1]!='#') l[i][j] = l[i][j-1] + 1;
			else l[i][j] = 0;
		}
		for(j=w - 2;j>=0;j--){
			if(s[i][j+1]!='#') r[i][j] = r[i][j+1] + 1;
			else r[i][j] = 0;
		}
	}
	for(j=0;j<w;j++){
		u[0][j] = 0; d[h-1][j] = 0;
		for(i=1;i<h;i++){
			if(s[i-1][j]!='#') u[i][j] = u[i-1][j] + 1;
			else u[i][j] = 0;
		}
		for(i=h - 2;i>=0;i--){
			if(s[i+1][j]!='#') d[i][j] = d[i+1][j] + 1;
			else d[i][j] = 0;
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(s[i][j]=='#') continue;
			mx = max(mx,l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1);
		}
	}
	cout << mx << endl;
}
			

Measured memory_bytes: 67456
#include <stdio.h>

int main()
{
    int N, M;
    int K[12] = {0};
    int s[12][12] = {0};
    int p[12] = {0};
    int ans = 0;

    scanf("%d%d", &N, &M);

    for(int i = 0; i < M; i++) {
        scanf("%d", &K[i]);
        int tmp = 0;
        for (int j = 0; j < K[i]; j++)
        {
            scanf("%d", &tmp);
            s[i][tmp-1] = 1; // 電球のフラグ配列にする
        }
    }

    for (int i = 0; i < M; i++)
    {
        scanf("%d", &p[i]);
    }

    // bit全探索で解く
    for (int bit = 0; bit < (1 << N); ++bit) {
        int flag = 0;

        // 各電球についてループ
        for (int i = 0; i < M; i++) {
            int lamp = 0; // 電球がつくか
            int switch_num = 0;

            // どの桁の数字にフラグが立っているか
            for (int j = 0; j < N; j++) {
                if ((1 & bit >> j) == 1) { // j桁目にフラグが立っている
                    if (s[i][j] == 1) {
                        // フラグが立っている桁のs[i][桁]が1ならswitch_num++
                        switch_num++;
                    }
                }
            }

            // switch_numを2で割ったあまりがp[i]ならつく
            if ((switch_num %= 2) == p[i]) {
                lamp = 1;
            }

                // 電球がつかなかったら
                if (lamp == 0)
                {
                    flag = 1;
                    break;
                }
        }

        // 最後に判断
        if (flag == 0) {
            ans++;
        }
    }

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

Measured memory_bytes: 128
def mx(ls,m):
	global n
	sum = 0
	for i in range(m):
		sum += (n-i)*ls[-i-1]
	return sum

def mn(ls,m):
	global n
	sum = 0
	for i in range(m):
		sum += (n-i)*ls[i]
	return sum
	
def f(ls,m,s):
	global n
	count = 0
	if m > 0:
		if mx(ls,m) < s or mn(ls,m) > s: return 0
		for i in range(len(ls)):
			lls = ls[:]
			a = (n-m+1)*lls.pop(i)
			if s-a < 0:	break
			else: count += f(lls,m-1,s-a)
		return count
	else:
		return 1 if s == 0 else 0
			
ls = [i for i in range(10)]
while True:
	try:
		n,s = map(int, raw_input().split())
		print f(ls,n,s)
	except:
		break

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

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  int ans=0;
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  int max=h.at(0);
  for(int i=1;i<N;i++){
    if(h.at(i)>=max){
      max=h.at(i);
    }else{
      ans+=max-h.at(i);
      max=h.at(i);
    }
  }
  ans+=max;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/user/bin/env python3
# -*- conding: utf-8 -*-

def main():
    S = input()
    N = len(S)
    flag = 'No'

    s1 = S[:int((N-1)/2)]
    s2 = S[int((N+3)/2)-1:]

    if S == S[::-1]:
        if s1 == s1[::-1]:
            if s2 == s2[::-1]:
                flag = 'Yes'
    
    print(flag)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
N, Y = map(int, input().split())

Y //= 1000

for i in range(N + 1):
    for j in range(N + 1):
        k = N - i - j
        if k >= 0 and i * 10 + j * 5 + k == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 40812
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N];
    int sw = 0;
    int cnt;
    for(int i = 0; i < N; i++)
        cin >> A[i];
    do{
        cnt = 0;
        for(int i = 0; i < N; i++){
            if(A[i] % 2 == 0){
                A[i] = A[i] / 2;
                cnt++;
            }
        }
        if(cnt == N)
            sw++;
    }while(cnt == N);
    cout << sw << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define N 301000
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	if (flag)	x = -x;
}
using namespace std;
int n, Rt;
int cnt[N];
int fa1[N], fa2[N];
struct edge{
	int nxt, to;
}e[N << 1];
int head[N], ecnt = 1;
inline void addedge(int from, int to) {
	e[++ecnt] = (edge){head[from], to};
	head[from] = ecnt;
}

int blong[N];
bool evis[N << 1], etype[N << 1];
void dfs(int cur) {
	for (int &i = head[cur]; i; i = e[i].nxt) {
		if (evis[i])	continue;
		evis[i] = evis[i ^ 1] = true;
		etype[i] = true;
		int to = e[i].to; dfs(to);
	}
}

int main() {
	read(n); Rt = n + n + 1;
	for (int i = 1; i <= n; ++i) {
		read(fa1[i]);
		if (fa1[i] == -1)	fa1[i] = Rt;
		addedge(fa1[i], i); addedge(i, fa1[i]);
		++cnt[fa1[i]];
	}
	for (int i = 1; i <= n; ++i) {
		read(fa2[i]);
		if (fa2[i] == -1)	fa2[i] = Rt;
		else	fa2[i] += n;
		addedge(fa2[i], i + n); addedge(i + n, fa2[i]);
		++cnt[fa2[i]];
	}
	for (int i = 1; i <= n; ++i) {
		if ((cnt[i] & 1) != (cnt[i + n] & 1)) {
			puts("IMPOSSIBLE");
			return 0;
		}
		if (!(cnt[i] & 1))
			addedge(i, i + n), blong[i] = ecnt, addedge(i + n, i);
	}
	puts("POSSIBLE");
	dfs(1);
	for (int i = 1; i <= n; ++i) {
		if (cnt[i] & 1)	printf("0 ");
		else	printf("%d ", etype[blong[i]] ? 1 : -1);
	}
	return 0;
}


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

int main(){
    int r,d;
    long long int x,previous;
    cin >> r >> d >> x;
    previous = x;
    for(int i=0; i<10; i++){
        previous = r * previous - d;
        cout << previous << endl;
    }
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,a,b;

int main(void){
    scanf("%d%d%d",&n,&a,&b);
    int maxi=min(a,b),mini=0;
    for(int i=0;i<=min(a,b);i++){
        if(a+b-i<=n){
            mini=i;
            break;
        }
    }
    printf("%d %d\n",maxi,mini);
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n=int(input())
    edges=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b,c=map(int,input().split())
        a-=1
        b-=1
        edges[a].append([b,c])
        edges[b].append([a,c])
    q,k=map(int,input().split())
    k-=1
    d=[INF]*n
    d[k]=0

    # dfs (root=k)
    Q=[[k,0]]
    while(Q):
        v,dist=Q.pop()
        for u,cost in edges[v]:
            if d[u]>dist+cost:
                d[u]=dist+cost
                Q.append([u,d[u]])

    for _ in range(q):
        x,y=map(lambda x:int(x)-1,input().split())
        print(d[x]+d[y])

resolve()

Measured memory_bytes: 94240
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}
int main(){
    string s;
    vector<char> ss;
    cin >> s;
    int ans = 0;
    int count[2] = {0,0};
    for(int i = 0;i<s.size();i++){
        if(s[i] == '0'){
            if(count[1] > 0){
                ans = ans + 2;
                count[1]--;
            }
            else {
                count[0]++;
            }
        }
        else{
            if(count[0] > 0){
                ans = ans + 2;
                count[0]--;
            }
            else{
                count[1]++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import sys

def solve():
    m = int(sys.stdin.readline().rstrip())

    for i in range(m):
        train = sys.stdin.readline().rstrip()
        n = len(train)
        s = set()
        s.add(train)
        s.add(train[::-1])

        for j in range(1, n):
            # s.add(train[:j] + train[j:]) = train
            s.add(train[:j][::-1] + train[j:])
            s.add(train[:j] + train[j:][::-1])
            s.add(train[:j][::-1] + train[j:][::-1])

            s.add(train[j:] + train[:j])
            s.add(train[j:][::-1] + train[:j])
            s.add(train[j:] + train[:j][::-1])
            # s.add(train[j:][::-1] + train[:j][::-1]) = train[::-1]

        ans = len(s)
        print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int m=n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]==s[i+1]) m--;
		else continue;
	}
	cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;
    
    for(int i=0;i<S.size()-1;i++){
        if(S.substr(i,2) == "AC"){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;

}

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

int main(){
    int n;
    cin >> n;
    vi x(n), l(n);
    rep(i,n) cin >> x[i] >> l[i];
    vector<pair<int,int>> arm(n);
    rep(i,n){
        arm[i].first=x[i]+l[i];
        arm[i].second=x[i]-l[i];
    }
    sort(arm.begin(),arm.end());
    int ans=0;
    int now=-1e9;
    rep(i,n){
        if(now<=arm[i].second){
            ans++;
            now=arm[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include <stdio.h>
#include <math.h>
int main() {
	double a[1010];
	int n;
	double m = 0;
	double ans = 0;
	int i;

	while (scanf("%d", &n), n != 0) {
		m = 0;
		ans = 0;
		for (i = 0; i<n; i++) {
			scanf("%lf", &a[i]);
			m += a[i];
		}
		m /= (double)n;
		for (i = 0; i<n; i++) {
			ans += pow(a[i] - m, 2.0);
		}
		ans /= (double)n;
		printf("%lf\n", sqrt(ans));
	}
	return 0;
}


Measured memory_bytes: 2068
w,h,n=map(int,input().split())
x0=0
y0=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        x0=max(x0,x)
    elif a==2:
        w=min(w,x)
    elif a==3:
        y0=max(y0,y)
    else:
        h=min(h,y)
        
if x0>w or y0>h:
    print(0)
else:
    print((w-x0)*(h-y0))

Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int table[100][100];
int memo[100][100];

int w, h;
int xs, ys, xg, yg;
int n;

void solve(int xs, int ys, int c)
{
	if( memo[xs][ys] ) {
		return;
	}

	if( !( 0 < xs && xs < w+1 && 0 < ys && ys < h+1 && table[xs][ys] == c ) ) {
		memo[xs][ys] = 1;
		return;
	}
	
	if( xs == xg && ys == yg ) {
		memo[xs][ys] = 1;
		cout << "OK" << endl;
		throw "OK";
	}

	memo[xs][ys] = 1;	

	solve(xs+1, ys, c);
	solve(xs, ys+1, c);	
	solve(xs-1, ys, c);
	solve(xs, ys-1, c);

	return;
}

int main(int argc, char* argv[])
{
	while(1) {

		for( int i = 0; i < 100; i++ ) {
			for( int j = 0; j < 100; j++ ) {
				table[i][j] = 0;
				memo[i][j] = 0;
			}
		}		

		cin >> w >> h;

		if( w == 0 && h == 0 )
			break;
			
		cin >> xs >> ys;
		cin >> xg >> yg;
		cin >> n;

		for( int i = 0; i < n; i++ ) {

			int c; cin >> c;
			int d; cin >> d;
			int x, y; cin >> x >> y;

			if( d == 0 ) {

				table[x][y] = c;
				table[x][y+1] = c;

				table[x+1][y] = c;
				table[x+1][y+1] = c;

				table[x+2][y] = c;
				table[x+2][y+1] = c;

				table[x+3][y] = c;
				table[x+3][y+1] = c;																
				

			} else {

				table[x][y] = c;
				table[x+1][y] = c;

				table[x][y+1] = c;
				table[x+1][y+1] = c;

				table[x][y+2] = c;
				table[x+1][y+2] = c;
				
				table[x][y+3] = c;
				table[x+1][y+3] = c;								
			}
		}

		try {
			if( table[xs][ys] )
				solve(xs, ys, table[xs][ys]);
			cout << "NG" << endl;
		} catch(...) {
		}
	}

    return 0;
}

Measured memory_bytes: 3164
#pragma GCC optimize("Ofast")  
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++) 
#define REP(i,k,n) for (int (i) = (k); (i) <= (n); (i)++) 
#define REPR(i,k,n) for (int (i) = (k); (i) >= (n); (i)--)
#define watch(x) cout << (#x) << " = " << (x) << endl

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	/*---- continue Coding ;----*/

	ll int n, ans = 0;
	cin >> n;
	ll int a[n];
	rep(i, n) cin >> a[i];
	//rep(i, n) cout <<  a[i];
	for(ll int i=0; i<n-1; i++){
		if(a[i]>a[i+1]){
			ans += (abs(a[i] - a[i+1]));
			a[i+1] = a[i];
		}
	}
	cout << ans << "\n";

	/*---- break ;----*/

	cerr<<"Execution time: "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0;
}

Measured memory_bytes: 5332
n, q = map(int, raw_input().split())
n0 = 2**n.bit_length()
data = [0]*(n0*2)
def add(k, a):
    k += n0 - 1
    data[k] += a
    while k:
        k = (k - 1) / 2
        data[k] += a
def query(a, b, k, l, r):
    if b <= l or r <= a:
        return 0
    if a <= l and r <= b:
        return data[k]
    vl = query(a, b, 2*k+1, l, (l + r) / 2)
    vr = query(a, b, 2*k+2, (l + r) / 2, r)
    return vl + vr
def getSum(s, t):
    print query(s, t+1, 0, 0, n0)
for i in xrange(q):
    com, x, y = map(int, raw_input().split())
    [add, getSum][com](x, y)

Measured memory_bytes: 10808
listA=[]

for i in range(2):
    try:
        listA.append(list(map(int, input().split())))
        #listA<-[1,2,2,3,1]
        #print(listA)
        #ここに逐次処理を書けばいいと思う。
    except:
        break;
        #または、quit(),os.exit()をして止める。

N=(listA[0])[0]
K=(listA[0])[1]
listf=listA[1]

listf.sort()

if N-K>=1:
    print(sum(listf[0:N-K]))
else:
    print(0)

Measured memory_bytes: 26764
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int out = 0;
    out += (x / 500) * 1000;
    out += ((x % 500) / 5) * 5;
    System.out.println(out);
  }
}

Measured memory_bytes: 23892
#include<iostream>
#include<vector>
using namespace std;
const long mod=998244353;
string s;
int K;
long dp[303][303][303];
main()
{
	cin>>s>>K;
	s+="0";
	if(K>s.size())K=s.size();
	vector<int>A;
	int cnt=0,sum=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='1')cnt++;
		else
		{
			A.push_back(cnt);
			sum+=cnt;
			cnt=0;
		}
	}
	dp[0][sum][0]=1;
	for(int i=0;i<A.size();i++)
	{
		for(int j=0;j<=sum;j++)
		{
			int nAm=A[i]-(sum-j);
			if(nAm<0)nAm=0;
			for(int k=0;k<=K;k++)if(dp[i][j][k]>0)
			{
				dp[i][j][k]%=mod;
				int nAM=j;
				if(nAM>K-k+A[i])nAM=K-k+A[i];
				for(int l=nAm;l<A[i];l++)
				{
					dp[i+1][j-l][k]+=dp[i][j][k];
				}
				for(int l=nAm>A[i]?nAm:A[i],x=0;l<=nAM;l++)
				{
					dp[i+1][j-l][k+x]+=dp[i][j][k];
					x++;
				}
			}
		}
		sum-=A[i];
	}
	long ans=0;
	for(int k=0;k<=K;k++)(ans+=dp[A.size()][0][k])%=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 30956
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	n := 0
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	count := 0
	for i := 0; i < n; i++ {
		count += divBy2(a[i])
	}
	fmt.Println(count)
}

func divBy2(x int) int {
	count := 0
	for {
		if x%2 == 0 {
			count++
			x /= 2
		} else {
			break
		}
	}
	return count
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    int fx = 0;
    rep(i, (int)s.size()){
        fx += s[i] - '0';
    }
    if(n % fx == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = str(input())
L = len(N)
ans = 0
dp = [[0,0] for _ in range(L)]
s = list(map(int,N))
dp[0] = [s[0],11-s[0]]
for i in range(1,L):
    n = s[i]
    dp[i][0] = min(dp[i-1][0]+n,dp[i-1][1]+n)
    dp[i][1] = min(dp[i-1][1]+9-n,dp[i-1][0]+11-n)
print(min(dp[-1]))

Measured memory_bytes: 179056
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    RS int|>(fun c -> if c.[0]*500>=c.[1] then "Yes" else "No")|>stdout.WriteLine
    0


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int x, y;
    cin >> x >> y;
    vector<int> a = {1, 3, 5, 7, 8, 10, 12};

    if (x == 2 || y == 2)
    {
        cout << "No" << '\n';
        return 0;
    }

    bool is_x = false, is_y = false;
    rep(i, a.size())
    {
        if (x == a[i])
        {
            is_x = true;
        }
        if (y == a[i])
        {
            is_y = true;
        }
    }

    cout << (is_x == is_y ? "Yes" : "No") << '\n';

    return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, h;
int a[100100], b[100100];

int solve() {
    int max_a = 0;
    for (int i = 0; i < n; i++) max_a = max(max_a, a[i]);
    sort(b, b+n);
    int res = 0;
    for (int i = n-1; i >= 0; i--) {
        if (h <= 0 || b[i] < max_a) break;
        h -= b[i];
        res++;
    }
    if (h > 0)
        res += (h+max_a-1) / max_a;
    return res;
}

void input() {
    cin >> n >> h;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl


// int MOD = 998244353;
int MOD = 1000000007;

signed main(){

	ll n;
	cin >> n;
	vll h(n);
	rep(i,n)cin >> h[i];

	vll c(n);
	c[0] = 0;
	c[1] = abs(h[1]-h[0]);
	for(int i = 2;i < n;i++)c[i] = min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]));
	cout << c[n-1] << endl;



	return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://dp.contest.atcoder.jp/tasks/dp_a
// rm -r -f test;oj dl http://arc092.contest.atcoder.jp/tasks/arc092_b

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define sz 200000
typedef long long ll;
using namespace std;
int main()
{

        int r,g,b,k;
        cin>>r>>g>>b>>k;
        int ans=0;

        while(r>=g)
        {
            g=g*2;
            ans++;

        }
        while(g>=b)
        {
            b=b*2;
            ans++;
        }
     if(ans<=k)
        cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;

return 0;

}




Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	/*int n;
	scanf("%d", &n);
	printf("%f\n", (double)(n / 2 + n % 2) / n);
	int n, k, h[100000];
	int count = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		if (h[i] >= k) {
			count++;
		}
	}

	printf("%d\n", count);*/

	int n, a[100000];
	vector<pair<int, int>> v;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		v.push_back(make_pair(a[i], i + 1));
	}
	sort(v.begin(), v.end());
	int first = 1;
	for (vector<pair<int, int>>::iterator it = v.begin(); it != v.end(); it++) {
		if (first) {
			printf("%d", (*it).second);
			first = 0;
		}
		else {
			printf(" %d", (*it).second);
		}
	}
	printf("\n");

	return 0;
}

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

using LL = long long;

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

  list<int> l;
  queue<unique_ptr<set<int>>> q;
  for(auto i = 0; i < N; ++i) {
    int a;
    cin >> a;
    l.emplace_back(a);
    q.emplace(make_unique<set<int>>());
    q.back()->emplace(a);
  }

  auto merge = [](auto& base, auto& add) {
    if(base->size() < add->size()) swap(base, add);
    base->insert(begin(*add), end(*add));
  };

  LL answer = 0;
  l.sort();
  while(!l.empty()) {
    unique_ptr<set<int>> nex = make_unique<set<int>>();
    while(l.front() != *begin(*q.front())) {
      auto s = move(q.front());
      q.pop();
      merge(nex, s);
    }
    merge(nex, q.front());
    q.pop();
    nex->erase(l.front());
    l.pop_front();
    answer += nex->size();
    if(!nex->empty()) q.emplace(move(nex));
  }
  cout << answer << endl;
}

Measured memory_bytes: 32980
W,H,N = list(map(int,input().split()))
XYA = [list(map(int,input().split())) for _ in range(N)]
XMAX = W
XMIN = 0
YMAX = H
YMIN = 0
for xya in XYA:
    if xya[2] == 1:
        XMIN = max(XMIN,xya[0])
    elif xya[2] == 2:
        XMAX = min(XMAX,xya[0])
    elif xya[2] == 3:
        YMIN = max(YMIN,xya[1])
    elif xya[2] == 4:
        YMAX = min(YMAX,xya[1])
if XMIN >= XMAX or YMIN >= YMAX:
    print(0)
else:
    print((XMAX-XMIN)*(YMAX-YMIN))

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

int main() {
  float a,b;
  long long p;
  long long c = 0;
  int m = 10002;
  cin >> a >> b;

  for ( int i=0 ; i < m ; ++i ) {
    if ((floor(i*0.08) == a) && (floor(i*0.1) == b)){
      cout << i << endl;
      return 0;
    }
//    cout << floor(i*0.08) << endl;
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long N = sc.nextLong();
		int K = sc.nextInt();
		for(int i = 0; i < 40; i++) {
			long pow = (long)Math.pow(K, i);
			if(N < pow) {
				pw.print(i);
				break;
			}
		}
		pw.close();
	}
}

Measured memory_bytes: 21844
N = int(input())
K = int(input())
x = list(map(int, input().split()))

import math
ans = []
for i in range(N):
    a = math.sqrt((x[i] - 0) ** 2) * 2
    b = math.sqrt((x[i] - K) ** 2) * 2
    ans.append(min(a, b))
print(round(sum(ans)))

Measured memory_bytes: 3064