akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void)
{
int n,i,input,max=-1000001,min=1000001;
long long int sum=0;
scanf("%d",&n);

for(i=0;i<n;i++)
{
scanf("%d",&input);
sum+=input;
if(input>max) max = input;
if(input<min) min = input;
}
printf("%d %d %lld\n",min,max,sum);
return 0;
}

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

int main() {
	long n,k;
  	cin >> n >> k;
  	vector<long> h(n);
    long ans = 0;
  	for(long i = 0; i< n; i++){
      cin >> h[i];
    }
  	for(long i = 0; i<n; i++){
        if(k<=h[i]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o D_Hate_Factorization.exe D_Hate_Factorization.cpp 
Execute: ./D_Hate_Factorization
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int X; 
	cin >> X; 
	
	// Find all divisors of X
	vector<int> divisors_X; 
	int sqrt_X = (int) floor(sqrt( (double) X)); 
	for(int i = 1; i <= sqrt_X; i++) {
		if( X % i == 0) {
			divisors_X.push_back(i); 
			divisors_X.push_back(X / i); 
		}
	}
	sort(divisors_X.begin(), divisors_X.end()); 
	
	// Find cases when A & B are both positive. 
	int A; 
	for(int i = 0; i < divisors_X.size(); i++) {
		for(int B = 0; B <= X; B++) {
			A = B + divisors_X.at(i); 
			if( pow(A,5) - pow(B,5) == X ) {
				cout << A << " " << B << endl;
				return 0; 
			} 
			if( pow(A,5) - pow(B,5) > X ) {
				break; 
			}
		}
	}
	
	// Find cases when A > 0 but B < 0. 
	// Treat it like B > 0 so A^5 + B^5 instead of A^5 - B^5. 
	for(int i = 0; i < divisors_X.size(); i++) {
		for(int B = 0; B <= divisors_X.at(i); B++) {
			A = divisors_X.at(i) - B; 
			// cout << "Tried: " << divisors_X.at(i) << " " << A << " " << B << endl; 
			if( pow(A,5) + pow(B,5) == X ) {
				cout << A << " " << -B << endl;
				return 0; 
			} 
		}
	}
	
	return 0; 
} 


Measured memory_bytes: 4060
import java.util.*;

public class Main {

    private static final int MOD = 998244353;
    private static long[] fact;

    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();

        fact = new long[N];
        fact[0] = 1;
        for (int i = 1; i < N; i++) {
            fact[i] = i*fact[i-1];
            fact[i] %= MOD;
        }

        long ans = 0;
        long col = M;
        for (int x = N-1; x >= 0; x--) {
            if (x <= K) {
                long now = (col*comb(N-1,x))%MOD;
                ans += now;
                ans %= MOD;
            }
            col *= M-1;
            col %= MOD;
        }
        System.out.println(ans);
    }

    private static long comb(int n, int k) {
        return (fact[n]*pow(fact[k],MOD-2)%MOD)*pow(fact[n-k],MOD-2)%MOD;
    }

    private static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b%2 == 0) {
            long half = pow(a,b/2);
            return half*half%MOD;
        } else {
            return pow(a,b-1)*a%MOD;
        }
    }
}


Measured memory_bytes: 37328
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

bool correct(int other, int next, int turn){
  if(turn == 1){
    return other > next;
  }else{
    return other < next;
  }
    
}

int main(int argc, char *argv[]){
  string s;
  while(cin >> s){
    if(s == "#")break;
    int foot[2];//left, right
    bool turn = 0;// 0 is left, 1 is right
    int violate = 0;
    int Min = 1e8;
    //left start
    for (int t = 0; t < 2; t++) {
      foot[0] = 0;
      foot[1] = 2;
      turn = t;
      violate = 0;
      for (int i = 0; i < s.length(); i++) {
        //correct left foot motion
        char tmp = s[i];
        int next = atoi(&tmp) - 1;
        if(correct(foot[(turn + 1)&1]%3, next%3, turn)){
          violate++;
          turn = !turn;
        }
        //std::cout << violate << std::endl;
        foot[turn&1] = next;
        //std::cout << "left:" << next_foot[0] << std::endl;
        turn = !turn;
      }
      Min = min(Min, violate);
    }
    std::cout << Min << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1324
s=list(input())

f=1

if not s[0]=="A":
    f=-1

b=s[2:len(s)-1]

c=0

for i in range(len(b)):
    if b[i]=="C":
        c+=1
    else:
        if not b[i].islower():
            f=-1

if not c==1:
    f=-1

if not s[1].islower():
    f=-1
  
if not s[len(s)-1].islower():
    f=-1
      
if f>0:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(0) 
typedef long long int ll;
using namespace std;
const int MOD=1e9+7;
const int size=1e5+5;

ll a[size],b[size];

int main()
{
	ll n;
	cin >> n;
	ll even=n,odd;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		if(a[i]%2)
			even--;
	}
	ll b3[100],b2[100];
	b3[0]=1;
	for(int i=1;i<90;i++)
		b3[i]=b3[i-1]*3;
	b2[0]=1;
	for(int i=1;i<90;i++)
		b2[i]=b2[i-1]*2;
	cout << b3[n]-b2[even] <<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
 
class Main
{
    public static void main(String[] args)
    {
        int x,y,z;
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        x = a + b;
        y = a -b;
        z = a * b;
        int[] array = {x,y,z};
        Arrays.sort(array);
        System.out.println(array[2]);
        scanner.close();
    }
}

Measured memory_bytes: 21844
/*input
5
2 6 1 4 5

*/
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;cin>>n;
    unordered_map<ll,ll> mx;
    ll arr[n];
    for(ll i=0;i<n;i++)cin>>arr[i],mx[arr[i]]++;
    if(mx.size()==n)cout<<"YES";
	else cout<<"NO";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 10056
// B - YYMM or MMYY
#include <bits/stdc++.h>
using namespace std;
#define ote(x) cout<<(x)<<endl

int main(){
	int s; cin>>s;
	int u = s/100, d = s%100;
	bool um = 1<=u && u<=12, dm = 1<=d && d<=12;
	if(um && dm)ote("AMBIGUOUS");
	else if(!um && dm)ote("YYMM");
	else if(um && !dm)ote("MMYY");
	else ote("NA");
}

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

int main() {
  vector<char> a(3);
  rep(i, 3) cin>>a[i];
  int cnt = 0;
  rep(i, 3) if (a[i]=='1') cnt++;
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
long long dp[100003][13],power[100003];
int main(){
	cin>>s;
	power[0]=1;
	for(int i=1;i<100003;i++)power[i]=power[i-1]*10%13;
	dp[s.size()][0]=1;
	for(int i=s.size()-1;i>=0;i--)
		if(s[i]!='?')
			for(int j=0;j<13;j++)
				dp[i][j]=(dp[i+1][((j-power[s.size()-i-1]*(s[i]-'0'))%13+13)%13]+dp[i][j])%1000000007;
		else
			for(int j=0;j<13;j++)
				for(int k=0;k<10;k++)
					dp[i][j]=(dp[i+1][((j-power[s.size()-i-1]*k)%13+13)%13]+dp[i][j])%1000000007; 
	cout<<dp[0][5];
}

Measured memory_bytes: 11392
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000000 + 7;
const ll INF = LLONG_MAX;
const ll MAX_V = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

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

int main() {
    int n, k, a[55],sum=0;
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++)sum += a[n-i-1];
    cout << sum << endl;
    return 0;
}

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

*/
int main(){
  ll N; cin>>N;
  vector<ll> A(N,0);
  rep(i,N) cin>>A[i];
  ll ans = 1000;
  ll r = 0;
  for(ll i=0; i<N-1; i++){
    if(A[i]<A[i+1]){
      r+=ans/A[i];
      ans%=A[i];
    }
    else if(A[i]>A[i+1]){
      ans+=r*A[i];
      r=0;
    }
// cout<<"i:"<<i<<"r:"<<r<<"ans"<<ans<<endl;
  }
  if(r) ans += r*A[N-1];
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


template <typename T>
std::vector<T> divisibles(T n) {
  std::vector<T> a;

  for (T i = 1, r; i * i <= n; i ++)
    if (n % i == 0) {
      a.push_back(i);

      if ((r = n / i) != i)
        a.push_back(r);
    }

  std::sort(ALL(a));

  return a;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A[222222];

  std::cin >> N;

  std::map<int, std::vector<int>> map;
  std::map<int, int> dist;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    dist[A[i]] ++;

    if (map.count(A[i]) == 0)
      map[A[i]] = divisibles(A[i]);
  }

  int C = 0;

  for (const auto& kv : dist) {
    int x = kv.first, c = kv.second;

    bool valid = true;

    for (const auto& d : map[x])
      if (dist.count(d)) {
        if (d == x) {
          if (dist[d] > 1) {
            valid = false;

            break;
          }
        }
        else {
          valid = false;
        
          break;
        }
      }

    if (valid)
      C += c;
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 46644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e7+5;
ll a[N];
void solve(){
    int n;
    cin>>n;
    ll sum = 0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=a[i]*a[j];
        }
    }
    cout<<sum<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3672
def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p

def main():
    n, a, b = map(int, input().split())
    mod = 10**9 + 7
    ans = pow(2, n, mod) - cmb(n, a, mod) - cmb(n, b, mod) - 1
    while ans < 0:
        ans += mod
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int prev = -1;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int a = scanner.nextInt();
            if (prev == a) {
                ans++;
                prev = -1;
            } else {
                prev = a;
            }
        }
        System.out.println(ans);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 22484
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;*/
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
typedef long long ll;
typedef pair<ll, ll> Pa;

/*
template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

typedef modint<MOD> m;
m func[400001];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
m comb(m n, m r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}*/

int dp[3001][3001];
string s, t;

int main() {
	cin >> s >> t;
	dp[0][0] = 0;
	int mv = 0;
	rep(i, s.size()) {
		rep(j, t.size()) {
			dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			mv = max(mv, dp[i + 1][j + 1]);
		}
	}
	int y = s.size();
	int x = t.size();
	string strkeep = "";
	while (x != 0 && y != 0) {
		int a = dp[y][x];
		if (y != 0 && dp[y][x] == dp[y - 1][x]) y--;
		else if (x != 0 && dp[y][x] == dp[y][x - 1]) x--;
		else if (dp[y][x] == dp[y - 1][x - 1] + 1) {
			x--;
			y--;
			strkeep = s[y] + strkeep;
		}
	}
	cout << strkeep;
}


Measured memory_bytes: 35456
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readIntegerList()
    val pList = readIntegerList()
    var tmp = 0.0
    for (i in 0 until k) {
        tmp += (1 + pList[i])
    }

    var ans = tmp
    for (i in k until n) {
        tmp -= (1 + pList[i - k])
        tmp += (1 + pList[i])
        ans = max(ans, tmp)
    }

    out.println(ans / 2)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

int main() {
  int w, a, b; cin >>w >>a >>b;
  int ans;
  
  if (b<=a && a<=b+w) ans = 0;
  else if (b<=a+w && a+w<=b+w) ans = 0;
  else if (a<b) ans = b-(a+w);
  else ans = a-(b+w);
  
  cout <<ans <<endl;
}


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

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] sl = str.split(" ");
        int N = Integer.parseInt(sl[0]);
        int Y = Integer.parseInt(sl[1]);
        int[] ans = {-1,-1,-1};
        for (int i=N;i>=0;i--){
            for (int j=N-i;j>=0;j--){
                for (int k=N-i-j;k>=0;k--){
                    if (i+j+k!=N){
                        continue;
                    }
                    if (i*10000+j*5000+k*1000==Y){
                        ans[0] = i;
                        ans[1] = j;
                        ans[2] = k;
                    }
                }
            }
        }
        for (int i=0;i<3;i++){
            System.out.println(ans[i]);
        }
    }
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

using P = pair<double,double>;

double W, H;
int N;
int count(double s, vector<P>& p, int pv){
  if(p[pv].FF == 0){
	if(s <= p[pv].SS) return N*2;
	int res = 0;
	REP(i,2*N)
	  if(p[i].FF == 0 && p[i].SS <= s) ++res;
	return res;
  }
  
  int res = 0;
  REP(i,2*N){
	if(p[i].SS <= (p[pv].SS - s) / p[pv].FF * p[i].FF + s)
	  ++res;
  }
  return res;
}

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

  while(cin>>W>>H>>N,W){
	vector<P> ps(N*2);
	REP(i,N*2){
	  cin >> ps[i];
	}
	N++;
	int N2 = N*2;
	ps.EB(W,0);
	ps.EB(W,H);

	vector<double> evs;
	REP(i,N2) REP(j,i){
	  if(ps[i].FF == ps[j].FF)
		continue;

	  double b = ps[i].SS - (ps[i].SS - ps[j].SS) / (ps[i].FF - ps[j].FF) * ps[i].FF;
	  if(0 <= b && b <= H)
		evs.PB(b);
	}
	evs.PB(0);
	evs.PB(H);
	SORT(evs);

	double ans = 0.;
	REP(i,SZ(evs)-1){
	  if(evs[i+1] - evs[i] <= EPS) continue;
	  double mid = (evs[i] + evs[i+1]) / 2.;
	  vector<double> angs(N2);
	  REP(j,N2) angs[j] = atan2(ps[j].SS-mid, ps[j].FF);
	  SORT(angs);
	  double lb = max(0., min(H, tan(angs[N-1]) * W + mid));
	  double ub = max(0., min(H, tan(angs[N]) * W + mid));
	  ans += (ub - lb) * (evs[i+1] - evs[i]);
	}

	cout << fixed << setprecision(9) << ans/H/H << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define s second
#define int long long
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e5+5;


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int>vec(n);
  vec.at(0) = 1;
    int a = 0;
  for(int i = 0;i < m;i++){
    int t;
    int r;
    cin >> t >> r;
    if(vec.at(t-1) > 100 && vec.at(t-1) % 100 != r)
    {a = 1;}
    else{vec.at(t-1) = 100+r;}
  }    

  if((vec.at(0)%100==0||vec.at(0) <= 50 )&& vec.size() == 1)
  {cout << 0 << endl;}
  else if(vec.at(0) % 100 == 0)
    {cout << -1 << endl;}
 else if(a == 1)
    {cout << -1 << endl;}
  else{for (int i = 0; i < n; i++)
  {cout << vec.at(i) % 100;}
       cout << endl;}
    
}

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

using ll = long long;

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> low(n), high(n);
        for(int i = 0; i < n; ++i) {
            cin >> low[i] >> high[i];
        }

        // build NFA
        const int fin = n * 4; // finish node
        vector<vector<vector<int>>> nfa(n * 4 + 1, vector<vector<int>>(10));
        for(int i = 0; i < n; ++i) {
            if(low[i] < 10) { // Pi -> Pi+1
                for(int x = low[i]; x <= min(9, high[i]); ++x) {
                    nfa[i * 4][x].push_back(i * 4 + 4);
                }
            } else {
                // Pi -> Qi -> Pi+1
                nfa[i * 4][low[i] / 10].push_back(i * 4 + 1);
                const int ub = low[i] / 10 == high[i] / 10 ? high[i] % 10 : 9;
                for(int x = low[i] % 10; x <= ub; ++x) {
                    nfa[i * 4 + 1][x].push_back(i * 4 + 4);
                }
            }
            // Pi -> Ri -> Pi+1
            for(int x = low[i] / 10 + 1; x < high[i] / 10; ++ x) {
                nfa[i * 4][x].push_back(i * 4 + 2);
            }
            for(int x = 0; x <= 9; ++x) {
                nfa[i * 4 + 2][x].push_back(i * 4 + 4);
            }
            if(high[i] >= 10) {// Pi -> Si -> Pi+1
                nfa[i * 4][high[i] / 10].push_back(i * 4 + 3);
                const int lb = low[i] / 10 == high[i] / 10 ? low[i] % 10 : 0;
                for(int x = lb; x <= high[i] % 10; ++x) {
                    nfa[i * 4 + 3][x].push_back(i * 4 + 4);
                }
            }
        }

        // build DFA
        map<int, array<int, 10>> dfa;
        {
            queue<int> que;
            que.push(1);
            set<int> vis = {1};
            while(!que.empty()) {
                const int S = que.front();
                que.pop();
                for(int x = 0; x <= 9; ++x) {
                    int nS = 0;
                    for(int i = 0; i < 4 * n; ++i) {
                        if(!(S & (1 << i))) continue;
                        for(auto const to : nfa[i][x]) {
                            nS |= 1 << to;
                        }
                    }
                    dfa[S][x] = nS == 0 ? -1 : nS;
                    if(nS == 0 || vis.count(nS)) continue;
                    que.push(nS);
                    vis.insert(nS);
                }
            }
        }

        map<int, ll> memo;
        function<ll(int)> solve = [&] (int S) {
            if(memo.count(S)) return memo[S];
            if(S == (1 << fin)) return 1LL;
            for(int x = 0; x <= 9; ++x) {
                if(dfa[S][x] == -1) continue;
                memo[S] += solve(dfa[S][x]);
            }
            if(S & (1 << fin)) {
                memo[S] += 1;
            }
            return memo[S];
        };

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



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

typedef complex<double> P;
#define EPS (1e-10)

int main()
{
	int n;
	while(cin>>n && n!=0){
		int ans=1;
		vector<P> points;
		for(int i=0;i<n;i++){
			double x,y; cin>>x>>y;
			points.push_back(P(x,y));
		}
		for(int a=0;a<n;a++){
			for(int b=a+1;b<n;b++){
				if(abs(points[b]-points[a])+EPS>2.0) continue;
				P sa=P(points[b]-points[a])/2.0;
				P rev[2];
				rev[0]=sa*P(0,1.0)/abs(sa);
				rev[1]=sa*P(0,-1.0)/abs(sa);
				double l=sqrt(1-abs(sa)*abs(sa));

				for(int k=0;k<2;k++){
					P center=points[a]+sa+rev[k]*l;
					int t_ans=2;
					for(int id=0;id<n;id++){
						if(id==a || id==b) continue;
						if(abs(center-points[id])+EPS<1.0){
							t_ans++;
//							cout<<abs(center-points[id])<<endl;
						}
					}
					
//					cout<<t_ans<<endl;
					ans=max(ans,t_ans);
				}
			}
		}

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

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

int main() {
  int n,cnt=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<s.size()-2;i++) {
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define inf 1e18+7
#define int long long
int32_t main() {
	int n,W;
	int w[101],v[101];
	int dp[100005]; // min weight for that value
	fill(dp,dp+100005,inf);
	cin>>n>>W;
	for (int i = 0; i < n ; i++) {
	    cin>>w[i]>>v[i];
	}
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
	    for(int j=100003;j>=0;j--)
    	    {
	        if(v[i]<=j)
    	        dp[j]=min(dp[j-v[i]]+w[i],dp[j]);
    	    }
	}
	int ans=-1;
	for(int i=0;i<100002;i++)
	{
	    if(W>=dp[i])
	    {
	        ans=max(ans,i);
	    }
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define MOD 1000000007
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------
int sum[510][510];

int sumt(int x1, int y1, int x2, int y2) {
    return sum[x2][y2] - sum[x1][y2] - sum[x2][y1] + sum[x1][y1];
}

//--MAIN-----------------------------------
void Main() {
    int N, M, Q;
    cin >> N >> M >> Q;

    rep(i, M) {
        int l, r;
        cin >> l >> r;
        ++sum[l][r];
    }

    reps(i, 1, N+1) {
        reps(j, 1, N+1) {
            sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
        }
    }

    rep(i,Q){
        int p,q; cin>>p>>q;
        cout<< sumt(p-1,p-1,q,q)<<"\n";
    }
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

main() {
    char X; cin >> X;
    if(X=='3'||X=='5'||X=='7') cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

using namespace std;
int N;

int main(){
    cin >> N;
    double sum;
    for(int i=0;i<N;i++){
        double x;
        string s;
        cin >> x >> s;
        if (s == "JPY"){
            sum += x;
        }
        else{
            sum += x * 380000.0;
        }
    }
    cout << sum << endl;
    return 0;
}

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


int main(){
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    long long tmp1,tmp2,tmp3;
    long long i=A;
    long long tmp,gcd,lcm,C_tmp=C,D_tmp=D;

    // 最小公倍数の算出
    if(C<D){
        tmp = C;
        C = D;
        D = tmp;
    }
    long long k = C%D;
    while(k!=0){
        C=D;
        D=k;
        k=C%D;
    }
    gcd = D;
    C=C_tmp,D=D_tmp;
    lcm = C*D/gcd;


    long long ans;
    ans = B - A + 1;
    ans -= B/C - (A-1)/C;
    ans -= B/D - (A-1)/D;
    ans += B/lcm - (A-1)/lcm;
    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

const int MAX = 3000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX], COMARR[MAX][MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void COMARRinit(){
	for(int i = 0; i < MAX; i++) {
		for(int j = 0; j < MAX; j++) {
			COMARR[j][i] = COM(j, i);
		}
	}
}

int main() {
	// 前処理
	COMinit();
	COMARRinit();

	int n, k;
	cin >> n >> k;
	repp(i, 1, k + 1){
		ll a, b;
		a = COMARR[k - 1][i - 1];
		b = (n - k + 1 >= 0) ? COMARR[n - k + 1][i] : 0;
		// cout << a << " " << b << endl;
		cout << a * b % MOD << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

bool solve() {
  int N;
  cin >> N;
  if (N == 0) return false;
  int W, H;
  cin >> W >> H;
  auto f = vect(W, vect(H, 0));
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    f[x][y] = 1;
  }
  int S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i <= W - S; i++) {
    for (int j = 0; j <= H - T; j++) {
      int res = 0;
      for (int x = i; x < i + S; x++) {
        for (int y = j; y < j + T; y++) { res += f[x][y]; }
      }
      chmax(ans, res);
    }
  }
  cout << ans << endl;
  return true;
}

signed main() {
  fastio();
  // solve();
  // int t; cin >> t; while(t--)solve();
  while (solve()) {}
  return 0;
}



Measured memory_bytes: 3136
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, double> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;


class SegTree {
public:
	int n, height;
	vector<ll> dat;
	
	ll def = 0;
	ll operation(int a, int b) {
		return a + b;
	}

	// ????????????_n????????????????´???°???
	SegTree(int _n) {
		n = 1;
		height = 1;
		while (n < _n) {
			n *= 2;
			height++;
		}
		dat = vector<ll>(2 * n - 1, def);
	}

	// ??´???i(0-indexed)???x????¶????
	void add(int i, ll x) {
		i += n - 1;
		dat[i] += x;
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] += x;
		}
	}

	// ??´???i(0-indexed)?????????x?????´??°
	void change(int i, ll x) {
		i += n - 1;
		dat[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = operation(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}

	// ??????[a,b)?????????????????????k=[l,r)????????????????????????
	ll _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return def;	// ???????????????
		if (a <= l && r <= b)return dat[k];	// a,l,r,b????????§?????¨???????????????
		else {
			ll c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);	// ?????????
			ll c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);	// ?????????
			return operation(c1, c2);
		}
	}

	// ?????¨?????¨???_query()???????????????
	ll query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
};

int main() {
	int N, Q;
	cin >> N >> Q;
	SegTree seg(N);
	rep(i, Q) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a == 1) {
			cout << seg.query(b - 1, c) << endl;
		}
		else {
			seg.add(b - 1, c);
		}
	}

	return 0;
}

Measured memory_bytes: 4892
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
words = []
for i in range(n):
	a = int(input())
	w = []
	for _ in range(a):
		x, y = map(int, input().split())
		w.append([x-1, y])
	words.append(w)

#print(words)
ans = 0
for bit in range(1<<n):
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)]
	#print(is_honest)
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
http://abc065.contest.atcoder.jp/tasks/arc076_b
TLE
"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple


class DisjointSet(object):
    def __init__(self, size):
        self.rank = []
        self.p = []
        for i in range(size):
            self.makeSet(i)

    def makeSet(self, x):
        self.p.insert(x, x)
        self.rank.insert(x, 0)

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]


def kruskal(V, E, es):
    es.sort(key=lambda x: x.c)
    uf = DisjointSet(V)
    res = 0

    for i in range(E):
        e = es[i]
        if not uf.same(e.u, e.v):
            uf.unite(e.u, e.v)
            res += e.c
    return res


edge = namedtuple('edge', ['u', 'v', 'c'])
def main(args):
    N = int(input())
    cities = []
    for i in range(1, N+1):
        x, y = map(int, input().split())
        cities.append([x, y, i])

    es = []
    cities.sort(key=lambda x: x[0])
    prev_x, _, prev_i = cities[0]
    for x, y, i in cities[1:]:
        es.append(edge(prev_i, i, x - prev_x))
#        es.append(edge(i, prev_i, x - prev_x))
        prev_x = x
        prev_i = i

    cities.sort(key=lambda x: x[1])
    _, prev_y, prev_i = cities[0]
    for x, y, i in cities[1:]:
        es.append(edge(prev_i, i, y - prev_y))
#        es.append(edge(i, prev_i, y - prev_y))
        prev_y = y
        prev_i = i

    result = kruskal(N+1, len(es), es)
    print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 52880
N,M=map(int,input().split())
from collections import defaultdict
lang=[-1]*(M+1)
data=defaultdict(int)
def search(l):
    if lang[l]>=0:
        lang[l]=search(lang[l])
    elif lang[l]<0:
        return l
    return lang[l]
def union(i,j,lang):
    iidx=search(i)
    jidx=search(j)
    if iidx==jidx:
        return lang
    elif lang[iidx]<=lang[jidx]:
        lang[iidx]+=lang[jidx]
        lang[jidx]=iidx
    else:
        lang[jidx]+=lang[iidx]
        lang[iidx]=jidx
    return lang
for i in range(N):
    line=list(map(int,input().split()))
    data[line[1]]+=1
    for k in range(1,line[0]):
        data[line[k+1]]+=1
        lang=union(line[k],line[k+1],lang)
L=set()
for k in range(1,1+M):
    if data[k]==0:continue
    L|={search(k)}
if len(L)>1:
    print('NO')
elif len(L)==1:
    print('YES')

Measured memory_bytes: 16324
#include<bits/stdc++.h> 
long long a,b,x;
long long s,e;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a%x==0)s=a/x;
    else s=a/x+1;
    e=b/x;
    printf("%lld",e-s+1);
    return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main() {
    int n, h; cin >> n >> h;
    priority_queue<int> B;
    int a_max = 0;
    rp(i, 0, n){
        int a, b;
        scanf("%d%d", &a, &b);
        chmax(a_max, a);
        B.push(b);
    }
    int res = 0;
    int b_count = 0;
    res = h/a_max;
    if(h%a_max!=0) res++;
    
    while(!B.empty()) {
        int b = B.top(); B.pop();
        h -= b; b_count++;
        if(h > 0) {
            int a_count = h/a_max;
            if(h%a_max!=0) a_count++;
            chmin(res, a_count+b_count);
        }
        else{
            chmin(res, b_count);
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "Good";
            string sB = sS.Substring(0, 1);
            for (int i = 1; i < sS.Length; i++)
            {
                string sN = sS.Substring(i, 1);
                if (sN == sB) { sOut = "Bad"; break; }
                sB = sN;
            }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100005];
    scanf("%s", s);
    int sum=0, len=strlen(s), p=0, g=0;
    for(int i=0;i<len;i++)
    {
        if(s[i]=='g')
        {
            if(g>p)
            {
                sum++;
                p++;
            }
            else
                g++;
        }
        else
        {
            if(g>p)
                p++;
            else
            {
                sum--;
                g++;
            }
        }
    }
    printf("%d\n", sum);
    return 0;
} 


Measured memory_bytes: 384
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    ans = 'No'
    if 'C' in s:
        idx_c = s.index('C')
        if 'F' in s[idx_c:]:
            ans = 'Yes'

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10044
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<=n;i++)
using namespace std;
int main(){
	int K,A,B;
	bool a=false;
	cin>>K>>A>>B;
	rep(i,1,1001){
		if(i%K==0){
			if(i>=A &&i<=B){
				a=true;
				break;
			}
		}
	}
	if(a==true)
		cout<<"OK\n";
	else
		cout<<"NG\n";
	
}

Measured memory_bytes: 3596
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int x=getInt(),y=getInt(),g=gcd(x,y),X=x/g,Y=y/g;
		//System.out.println(g+" "+X+" "+Y);
		//System.out.println((X+Y-1)*g+1);
		System.out.println(x+y-g+1);
	}
	static int gcd(int a,int b) {
		return a%b==0?b:gcd(b,a%b);
	}
}

Measured memory_bytes: 26164
n, x, y = gets.split.map(&:to_i)
ans = Array.new(n, 0)
for k in 1..(n-1)
  ans[k] = n-k
end

for k in 1..(n-1)
  for i in 1..(y-1)
    dx = (i-x).abs
    if dx < k
      lf = y-(k-dx-1)
      ri = y+(k-dx-1)
      if 1 <= lf && lf-i > k
        ans[lf-i] -= 1
        ans[k] += 1
      end
      if ri <= n && ri-i > k && lf != ri
        ans[ri-i] -= 1
        ans[k] += 1
      end
    end
  end
end
for k in 1..(n-1)
  puts ans[k]
end

Measured memory_bytes: 3836
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X, A = MI()
    if X < A:
        print(0)
    else:
        print(10)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
n,m = map(int,input().split())
h = list(map(int,input().split()))
j = set()
ab = [list(map(int,input().split()))for i in range(m)]
for i in range(m):
    #a,b = map(int,input().split())
    a = ab[i][0]
    b = ab[i][1]
    if h[a-1] > h[b-1]:
        j.add(b)
    elif h[b-1] > h[a-1]:
        j.add(a)
    else:
        j.add(a)
        j.add(b)

print(n-len(j))

Measured memory_bytes: 100392
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    if (n == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    int ret = INF;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
                continue;
            ll p = x[i] - x[j], q = y[i] - y[j];
            int cnt = 0;
            for (int k = 0; k < n; k++)
            {
                for (int l = 0; l < n; l++)
                {
                    ll dx = x[k] - x[l], dy = y[k] - y[l];
                    if (dx == p && dy == q)
                        cnt++;
                }
            }
            ret = min(ret, n - cnt);
        }
    }
    cout << ret << endl;
}


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

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++)
        for (int j = 1; j < 10; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    long long count=0;
    vector<int>a(N);
    for(int i=0;i<N;i++){
     cin>>a.at(i);
     count=count+a.at(i);
    }
    sort(a.begin(),a.end());
    cout<<a.at(0)<<" "<<a.at(N-1)<<" "<<count<<endl;
    return 0;
    
}


Measured memory_bytes: 3152