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

using namespace std;

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, n;
    cin >> x >> n;
    if(n == 0) {
        cout << x << '\n';
    }
    else {
        vector<int> arr(n);
        for(int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        sort(arr.begin(), arr.end());
        int lower = lower_bound(arr.begin(), arr.end(), x) - arr.begin();
        int pos = lower, lo = x, up = x;
        while(pos >= 0) {
            if(arr[pos] == lo) {
                pos--;
                lo--;
            }
            else {
                break;
            }
        }
        pos = lower;
        while(pos < n) {
            if(arr[pos] == up) {
                pos++;
                up++;
            }
            else {
                break;
            }
        }
        if(abs(x - lo) <= abs(x - up)) {
            cout << lo << '\n';
        }
        else {
            cout << up << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#!/usr/bin/env python


s = int(input())
def f(n):
    if n % 2 == 0:
        return n/2
    else:
        return 3*n+1

A = [s]
for i in range(1,1000000):
    A.append(f(A[i-1]))
    if len(list(set(A))) != i+1:
        print(i+1)
        break

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

using namespace std;

int main() {
    string str;
    cin >> str;
    
    bool ans = false;
    for(int i = 0; i < str.size(); i++){
        if('C' == str[i]){
            ans = true;
        }else if(ans && 'F' == str[i]){
            cout << "Yes" << endl;
            return 0; 
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
vector<int> s(100009);

int main(){
  int N,M;
  int cnt=0;
  cin >> N >> M;
  vector<int> L(M),R(M);
  for(int i=0;i<M;i++)cin >> L[i] >> R[i];
  for(int i=0;i<M;i++){
    s[L[i]]++; s[R[i]+1]--;
  }
  for(int i=0;i<N;i++){s[i+1]+=s[i];}
  for(int i=1;i<=N;i++){if(s[i]==M)cnt++;}
  cout << cnt << endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int x;
    cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        for(int x=0;x<9;x++){
            for(int y=0;y<9;y++){
                System.out.println(""+(x+1)+"x"+(y+1)+"="+((x+1)*(y+1)));
            }
        }
    }
}

Measured memory_bytes: 24052
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int a, b; cin >> a >> b;
  int ans = a + b;
  chmax(ans, a - b);
  chmax(ans, a * b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

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

	int c[26];
	int s[365][26];

	for (int i = 0; i < 26; ++i)
		std::cin >> c[i];

	for (int i = 0; i < 365; ++i)
		for (int j = 0; j < 26; ++j)
			std::cin >> s[i][j];

	int t[365];
	for (int i = 0; i < 365; ++i)
		t[i] = rand() % 26;

	/*
	// 満足度の計算
	int score = 0;
	for (int i = 0; i < 365; ++i)
	{
		score += s[i][t[i]];

		for (int j = 0; j < 26; ++j)
		{
			for (int k = i; k >= 0; --k)
			{
				if(score != )
				score -=
			}
		}
	}
	*/
	for (int i = 0; i < 365; ++i)
		std::cout << t[i] + 1 << std::endl;

}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int n,k,ans=1000000000,m=-1,p=-1;
int x[100000];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i+k-1<n;i++){
        ans=min(ans,abs(x[i]-x[i+k-1])+min(abs(x[i]),abs(x[i+k-1])));
    }
    cout<<ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
 
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n; cin >> n;
		if(n==0)break;
		int ans=0;
		int l=0,r=0;
		for(int i=0;i<n;i++){
			string s; cin >> s;
			if(s=="lu")l++;
			if(s=="ld")l--;
			if(s=="ru")r++;
			if(s=="rd")r--;
			r=min(1,r);
			l=min(1,l);
			r=max(0,r);
			l=max(0,l);
			if(ans%2==0&&l*r==1)ans++;
			else if(ans%2&&l==0&&r==0)ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;
vi a;
void gen(int ndig, int n){
    a.PB(n);

    if(ndig==10){
        return;
    }
    else{
        int dig=n%10;
        if(dig==0){
            gen(ndig+1,n*10+dig);
            gen(ndig+1,n*10+dig+1);
        }
        else if(dig==9){
            gen(ndig+1,n*10-1+dig);
            gen(ndig+1,n*10+dig);
        }
        else{
            gen(ndig+1,n*10+1+dig);
            gen(ndig+1,n*10-1+dig);
            gen(ndig+1,n*10+dig);
        }

    }
}
int32_t main(){
    ios::sync_with_stdio(false);
    int k;
    cin>>k;
    for(int i=1;i<=9;i++){
        gen(1,i);
    }
    k--;
    sort(a.begin(),a.end());
    vi b;
    int l=0;
    b.PB(1);
    for(int i=0;i<a.size();i++){
        if(a[i]==b[b.size()-1]){

        }
        else{
            b.PB(a[i]);
        }
    }
    cout<<b[k]<<"\n";

    return 0;
}

Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }
        long T = 1;
        long A = 1;
        for (int i = 0 ; i < n ; i++ ) {
            long x = 0;
            long y = 0;
            if (T % t[i] == 0) {
                x = T / t[i];
            } else {
                x = T / t[i] + 1;
            }
            if (A % a[i] == 0) {
                y = A / a[i];
            } else {
                y= A / a[i] + 1;
            }
            T = Math.max(x, y) * t[i];
            A = Math.max(x, y) * a[i];
        }
        System.out.println(T + A);

    }

}

Measured memory_bytes: 25072
#include <stdio.h>


int main(void)
{
  
  int H, W;
  int i, j;
  
  while( scanf("%d %d", &H, &W),  H || W ){
    
    for( i = 0; i < H; i++ ){
      for( j = 0; j < W; j++ ){
        
        if( (i+j) % 2 ) {printf(".");}
        else            {printf("#");}
      }
      puts("");
    }
    
    puts("");
  }
  
  return 0;    
 
}       
      

Measured memory_bytes: 588
//verma_ankit484

#include<bits/stdc++.h>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll mod = (ll) 1e9+7;

using namespace std;

int main()
{
  IOS
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  ll n;
  cin >> n;
  vector<string> vc(n);
  for(ll i = 0; i < n; i++) {
    cin >> vc[i];
  }
  for(ll i = 0; i < n; i++) {
    sort(vc[i].begin(), vc[i].end());
  }
  sort(vc.begin(), vc.end());
  ll c = 1;
  string ss = vc[0];
  ll s = 0;
  for(ll i = 1; i < n; i++) {
    if(ss == vc[i]) {
      c++;
    }
    else {
      s += (c*(c-1)/2);
      c = 1;
      ss = vc[i];
    }
  }
  s += (c*(c-1)/2);
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    string S, T;
    cin >> S >> T;
    int ans = T.size();
    rep(start, S.size() - T.size() + 1) {
        int diff = 0;
        rep(i, T.size()) {
            if (S[start + i] != T[i]) diff++;
        }
        ans = min(ans, diff);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int a, b; cin >> a >> b;
    int ans = max(0, a - 2 * b);
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

ll n, ans = 0;

void calc(ll x, ll use) {
  if (x > n) return;
  if (use == 0b111) ans++;
  calc(x * 10 + 3, use | 0b001);
  calc(x * 10 + 5, use | 0b010);
  calc(x * 10 + 7, use | 0b100);
}

int main() {
  cin >> n;
  calc(0, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MSIZE = 404;

long long dp[MSIZE][MSIZE];

long long arr[MSIZE];
long long pref[MSIZE];

long long Sum(int l, int r) {
    l = max(l, 0);
    return pref[r] - (l ? pref[l - 1] : 0LL);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, 0, sizeof dp);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    memcpy(pref, arr, sizeof arr);
    for (int i = 1; i < n; i++) {
        pref[i] += pref[i - 1];
    }

    for (int len = 1; len <= n; len++) {
        for (int l = 0; l + len <= n; l++) {
            int r = l + len - 1;
            if (len == 1) {
                dp[l][r] = 0;
            } else {
                dp[l][r] = 1e18;
                for (int m = l; m < r; m++) {
                    dp[l][r] = min(dp[l][r], dp[l][m] + dp[m + 1][r] + Sum(l, r));
                }
            }
        }
    }
    cout << dp[0][n - 1] << endl;
}

Measured memory_bytes: 1536
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
if a in [4, 6, 9, 11] and b in [4, 6, 9, 11] or a in [1, 3, 5, 7, 8, 10, 12] and b in [1, 3, 5, 7, 8, 10, 12]:
  print('Yes')
else:
  print('No')









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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    const auto& modinv = [](unsigned long a, unsigned long b = 1) -> unsigned long{
        unsigned long r{b % MOD}, n{MOD - 2};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long N;
    cin >> N;
    vector<unsigned long> fac(N + 1, 1), invfac(N + 1, 1);
    for(unsigned long i{1}; i <= N; ++i)fac[i] = fac[i - 1] * i % MOD;
    invfac.back() = modinv(fac.back());
    for(unsigned long i{N}; i--; )invfac[i] = invfac[i + 1] * (i + 1) % MOD;
    vector<vector<unsigned long>> edge(N);
    vector<unsigned long> jisu(N);
    for(unsigned long i{1}, a, b; i < N; ++i){
        cin >> a >> b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
        ++jisu[a];
        ++jisu[b];
    }
    assert(N < 50000 || *max_element(jisu.begin(), jisu.end()) > 2);
    vector<unsigned long> ord(N);
    iota(ord.begin(), ord.end(), 0UL);
    sort(ord.begin(), ord.end(), [&jisu](auto i, auto j){return jisu[i] > jisu[j];});
    map<pair<unsigned long, unsigned long>, pair<unsigned long, unsigned long>> memo;
    const auto& tree_dp = [&modinv, &fac, &invfac, &edge, &memo](auto f, unsigned long now, unsigned long prev) -> pair<unsigned long, unsigned long> {
        if(memo.count({now, prev}))return memo[{now, prev}];
        if(memo.count({now, now})){
            auto t = memo[{now, now}], s = memo[{prev, now}];
            unsigned long cnt{t.first}, ans{t.second};
            (ans *= modinv(s.second, invfac[cnt - 1] * fac[cnt - s.first - 1] % MOD * fac[s.first])) %= MOD;
            cnt -= s.first;
            return memo[{now, prev}] = {cnt, ans};
        }
        unsigned long cnt{0}, ans{1};
        for(const auto& i : edge[now])if(i != prev){
            auto t = f(f, i, now);
            cnt += t.first;
            (ans *= invfac[t.first] * t.second % MOD) %= MOD;
        }
        (ans *= fac[cnt]) %= MOD;
        return memo[{now, prev}] = {cnt + 1, ans};
    };
    vector<unsigned long> ans(N);
    for(const auto& i : ord)ans[i] = tree_dp(tree_dp, i, i).second;
    copy(ans.begin(), ans.end(), ostream_iterator<unsigned long>(cout, "\n"));
    return 0;
}


Measured memory_bytes: 69360
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

count = [0] * 3
flag = [False] * N
for i in range(N):
    if i >= K and T[i - K] == T[i]:
        if flag[i - K]:
            pass
        else:
            flag[i] = True
            continue
    if T[i] == 'r':
        count[0] += 1
    elif T[i] == 's':
        count[1] += 1
    else:
        count[2] += 1
#     print(i, count)
            

print(count[0] * P + count[1] * R + count[2] * S)

Measured memory_bytes: 41840
#include <stdio.h>
#include <stdlib.h>

void swap(int *, int *);
int partition(int A[], int, int);

int main()
{
  int i, n, *A, q;

  scanf("%d", &n);
  A = (int *)malloc( sizeof(int) * n );    /* 数列Aの領域を動的に確保 */
  
  for( i = 0; i<n; i++ )
    scanf("%d", &A[i]);

  q = partition(A, 0, n-1);

  for( i = 0; i<n; i++ )
    {
      if( i == q )
	printf("[%d]", A[i]);
      else
	printf("%d", A[i]);

      if( i != n-1 )
	printf(" ");
    }
  printf("\n");

  return 0;
}

/* int型の aとbを交換する関数 */
void swap(int *a, int *b)
{
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}

/* 配列 A[ p..r ] を A[ p..q − 1] の各要素が A[q] 以下で、A[ q +1.. r ] の各要素が A[ q ] より大きい   A[ p..q − 1] と A[q + 1..r ] に分割する関数 
   戻り値： インデックスq */
int partition(int A[], int p, int r)
{
  int i, j , x;

  x = A[r];
  i = p-1;

  for( j = p; j<r; j++ )
    {
      if( A[j] <= x )
	{
	  i++;
	  swap(&A[i], &A[j]);
	}
    }
  swap(&A[i+1], &A[r]);
  return i+1;
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double low = 0, high = M_PI / 2;
    for(int i = 0; i < 100; i++){
        double mid = (low + high) / 2;
        double deal;
        if(tan(mid) < b / a){
            deal = a * b - a * a / 2 * tan(mid);
        }else{
            deal = b * b / 2 / tan(mid);
        }
        if(deal * a < x){
            high = mid;
        }else{
            low = mid;
        }
    }
    fcout << low / M_PI * 180 << endl;
}


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

using namespace std;

int n;
int arr[100005];

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> arr[i];
	for(int i=n-2;i>=0;i--)
	{
		if(arr[i]>arr[i+1]) arr[i]--;
	}
	bool ok=1;
	for(int i=1;i<n;i++)
		ok&=(arr[i]>=arr[i-1]);
	cout << (ok?"Yes":"No") << endl;
}

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

ll gcd(ll x,ll y){
    if(x%y!=0) return gcd(y,x%y);
    else return y;
}

ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
}

int main(){
    ll a,b;
    while(cin >> a >> b){
        cout << gcd(a,b) << " " << lcm(a,b) << endl;
    }
    return 0;
}



Measured memory_bytes: 3004
import java.util.Scanner;

//足りないトランプを表示する。

public class Main {
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		
		//カードの配列
		int[][] array = new int[4][13];
        //所持数
        int have = sc.nextInt();
        //記号
        String kigo;
        String supe = "S" ;
        String hart = "H" ;
        String curo = "C" ;
        String daia = "D" ;
        //カードの数字
        int num;
        //記号を数値化したもの
        int kigonum = 0;
        
        //配列に初期値を入力
        for(int i=0;i<array.length;i++){
                for(int j=0;j<array[i].length;j++){
                    array[i][j]=0;
                }
			}
		
        //カードを入力
		for (int i=0;i<have;i++){
            kigo = sc.next();
			num=sc.nextInt();
            
            //記号を数値化
            if(kigo.equals(supe)) kigonum=0;
            else if(kigo.equals(hart)) kigonum=1;
            else if(kigo.equals(curo)) kigonum=2;
            else if(kigo.equals(daia)) kigonum=3;
            
            array[kigonum][num-1]=1;
		}
		kigo = "";
		//カードのチェック
			for(int i=0;i<array.length;i++){
                for(int j=0;j<array[i].length;j++){
                if(array[i][j]==0){
                    if(i==0) kigo="S";
                    else if(i==1) kigo="H";
                    else if(i==2) kigo="C";
                    else if(i==3) kigo="D";
                    System.out.println(kigo +" "+ (j+1));
                }
			}
        }
		sc.close();
	}
}


Measured memory_bytes: 26116
#include <bits/stdc++.h>
using namespace std;
#define maxn 100
typedef long long ll;
char s[103];
bool par(string s, int l, int r)
{
    for(int i =l ;i < r;i ++)
    {
        int j =r - 1 - i + l;
        if(s[i] != s[j])
            return false;
        if(j < i)
            break;
    }
    return true;
}
int main(void)
{
    string s;
    cin>>s;
    int n = s.length();
    if(par(s,0,n)&&par(s,0,(n-1)/2)&&par(s,(n+3)/2-1,n))
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
  
  int N,K;
  string S;
  
  cin>>N>>K;
  
  cin>>S;
  
  if(S.at(K-1)=='A'){
    S.at(K-1)='a';
  }
  if(S.at(K-1)=='B'){
    S.at(K-1)='b';
  }
  if(S.at(K-1)=='C'){
    S.at(K-1)='c';
  }
  
  cout<<S<<endl;
  
  
}
  
  
  

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll solve(ll n, ll x, const vector<ll> &a, const vector<ll> &p) {
	if (n == 0LL) {
		return x > 0LL;
	} else if (x <= a[n - 1LL] + 1LL) {
		return solve(n - 1LL, x - 1LL, a, p);
	} else {
		return p[n - 1LL] + 1LL + solve(n - 1LL, x - 2LL - a[n - 1LL], a, p);
	}
}

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

	ll n, x;
	cin >> n >> x;

	vector<ll> a(n + 1), p(n + 1);
	a[0] = p[0] = 1;
	for (ll i = 0; i < n; i++) {
		a[i + 1] = a[i] * 2 + 3;
		p[i + 1] = p[i] * 2 + 1;
	}


	ll ans = solve(n, x, a, p);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
int main(){
	int n,a,b;
	while(~getIII(n,a,b)){
		int p1=a*n,p2=b;
		printf("%d\n",min(p1,p2));
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;

	return 0;
}

Measured memory_bytes: 3556
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n;
    ll h,w;
    cin >> n >> h >> w;
    vector<ll>a(n),b(n);
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++){
        if (a[i] >= h && b[i] >= w){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

const int MOD = 1E9 + 7;

int n;

inline int qpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    int res = qpow(10, n);
    int minus = qpow(8, n);
    (minus += 2LL * (qpow(9, n) - qpow(8, n))) %= MOD;
    (res -= minus) %= MOD;
    cout << (res + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 3608
// C - Streamline
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()

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

	if(M<=1){
		cout<< 0 <<endl;
		return 0;
	}

	vi X(M); rp(i,M) cin>>X[i];
	sort(all(X));

	vi P;
	int pre = X[0];
	rp(i,M-1){
		int now = X[i+1];
		P.push_back(abs(now-pre));
		pre = now;
	}
	sort(all(P));

	ll ans = 0;
	rp(i,M-N) ans += (ll)P[i];

	cout<< ans <<endl;
}

Measured memory_bytes: 1276
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9;


int N, v[50];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v, v+N);
    double res = 0;
    double div = 1.0;
    for (int i = N - 1; i >= 1; i--) {
        div *= 2;
        res += v[i] / div;
    }
    res += v[0] / div;
    printf("%7lf", res);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
char s[222222];
int a[222222],pa;
int l[222222],pl;
int r[222222],pr;
int d[222222],pd;
int vis[222222];
int la[222222],to[222222];
int main()
{
	int n=io::F()<<1;
	scanf("%s",s+1);
	s[0]=s[n]='1';
	for(register int i=1;i<=n;++i)
		if(s[i]=='1'&&s[i-1]=='1')l[++pl]=i;
			else if(s[i-1]=='1')d[++pd]=i;
					else if(s[i]=='1')d[++pd]=i;
	if(pl&1){puts("No");return 0;}
	if(pl%4==0)
	{
		for(register int i=1;i+i<=pl;++i)
			a[l[i]]=a[l[i+pl/2]]=++pa;
		for(register int i=1;i<=pd;i+=2)
			a[d[i]]=a[d[i+1]]=++pa;
		int cnt=0;
		++pa;
		for(register int i=1;i<=n;++i)
			if(a[i]==0)
			{
				a[i]=pa;
				++cnt;
				if(cnt==2)cnt=0,++pa;
			}
		puts("Yes");
		for(register int i=1;i<=n;++i)printf("%d ",a[i]);
		return 0;
	}
	for(register int i=2;i<pd;i+=2)
		if(d[i+1]-d[i]==1)a[d[i]]=a[d[i-1]]=++pa,d[i-1]=d[i]=0;
	std::sort(d,d+pd+1);
	pd=std::unique(d,d+pd+1)-d-1;
	if(pd<=2){puts("No");return 0;}
	for(register int i=5;i<=pd;i+=2)
		a[d[i]]=a[d[i+1]]=++pa;
	a[d[1]]=a[d[4]]=++pa;
	a[d[2]]=a[d[3]]=++pa;
	for(register int i=1;i<=pl;++i)
		if(l[i]>=d[2]&&l[i]<=d[3])r[++pr]=l[i],l[i]=0;
	std::sort(l,l+pl+1);
	pl=std::unique(l,l+pl+1)-l-1;
	for(register int i=1;i+4<=pl;i+=4)
		a[l[i]]=a[l[i+2]]=++pa,a[l[i+1]]=a[l[i+3]]=++pa;
	for(register int i=1;i+4<=pr;i+=4)
		a[r[i]]=a[r[i+2]]=++pa,a[r[i+1]]=a[r[i+3]]=++pa;
	if(pl%4==1){a[l[pl]]=a[r[pr]]=++pa;}
	if(pl%4==3){a[l[pl]]=a[r[pr]]=++pa,a[l[pl-1]]=a[r[pr-1]]=++pa,a[l[pl-2]]=a[r[pr-2]]=++pa;}
	if(pl%4==2){a[l[pl-1]]=a[r[pr-3]]=++pa,a[l[pl]]=a[r[pr-1]]=++pa,a[r[pr-2]]=a[r[pr]]=++pa;}
	if(pl%4==0){a[l[pl-3]]=a[r[pr-1]]=++pa,a[l[pl-1]]=a[r[pr]]=++pa,a[l[pl-2]]=a[l[pl]]=++pa;}
	int cnt=0;
	++pa;
	for(register int i=1;i<=n;++i)
		if(a[i]==0)
		{
			a[i]=pa;
			++cnt;
			if(cnt==2)cnt=0,++pa;
		}
	for(register int i=1;i<=n;++i)
		if(!la[a[i]])la[a[i]]=i;
			else to[la[a[i]]]=i,to[i]=la[a[i]];
	int now=0;
	cnt=0;
	while(now!=n&&cnt<=2000000)vis[now]=1,++cnt,now=to[now+1];
	if(cnt>2000000){puts("No");return 0;}
	for(register int i=1;i<n;++i)if(vis[i]+'0'!=s[i]){puts("No");return 0;}
	puts("Yes");
	for(register int i=1;i<=n;++i)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 7040
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	var yymm, mmyy bool
	yymm = true
	mmyy = true
	a, _ := strconv.Atoi(s[0:2])
	b, _ := strconv.Atoi(s[2:4])
	if a == 0 || 13 <= a {
		mmyy = false
	}
	if b == 0 || 13 <= b {
		yymm = false
	}
	if yymm && mmyy {
		fmt.Println("AMBIGUOUS")
		return
	}
	if !yymm && !mmyy {
		fmt.Println("NA")
		return
	}
	if yymm {
		fmt.Println("YYMM")
		return
	}
	fmt.Println("MMYY")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
     int y[7];
    int x[6][6]={{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
    int a,b,c,d;
    int q;
    cin>>y[1]>>y[2]>>y[3]>>y[4]>>y[5]>>y[6];
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>a>>b;
        for(int j=1;j<=6;j++){
            if(a==y[j]){
                c=j;
            }
            if(b==y[j]){
                d=j;
            }
        }
        cout<<y[x[c-1][d-1]]<<endl;
    }
    return 0;
}



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

int main(){
  int N;
  int K;
  cin>>N>>K;
  vector <int> vec (N);
  int num=0;
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
    if(vec.at(i)>=K)
      num++;
  }
  cout << num <<endl;
}
  

Measured memory_bytes: 640
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
dp = [[0]*3 for _ in range(n)]

a,b,c = nm()

dp[0][0]=a
dp[0][1]=b
dp[0][2]=c

for i in range(1,n):
  a,b,c = nm()
  dp[i][0] = max(dp[i-1][1]+a, dp[i-1][2]+a)
  dp[i][1] = max(dp[i-1][0]+b, dp[i-1][2]+b)
  dp[i][2] = max(dp[i-1][0]+c, dp[i-1][1]+c)

print(max([dp[n-1][0],dp[n-1][1],dp[n-1][2]]))


Measured memory_bytes: 82544
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int a[3];
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  sort(a,a+3);
  printf("%d\n",a[2]*10+a[1]+a[0]);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
    int week;
    scanf("%d", &week);

    double debt = 100; // *1000yen
    while (week--) {
        debt = ceil(debt * 1.05);
    }

    printf("%.f\n", debt * 1000);

    return 0;
}

Measured memory_bytes: 632
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define rnt re int
#define re register
#define I inline int
#define V inline void
#define ll long long int
#define FOR(i,a,b) for(rnt i=a;i<=b;i++)
#define ROF(i,a,b) for(rnt i=a;i>=b;i--)
const int N=1e7+1,mod=998244353;
int n,ans,fac[N],inv[N],pw[N];
I Pow(ll t,rnt x){
	ll s=1;
	for(;x;x>>=1,t=t*t%mod)if(x&1)s=s*t%mod;
	return s;
}
V check(int&x){x-=mod,x+=x>>31&mod;}
I C(rnt x,rnt y){return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;}
int main(){
	cin>>n,fac[0]=inv[0]=pw[0]=1;
	FOR(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=Pow(fac[n],mod-2);
	ROF(i,n-1,1)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	FOR(i,1,n)check(pw[i]=pw[i-1]<<1);
	FOR(i,n/2+1,n)check(ans+=1ll*pw[n-i]*C(n,i)%mod);
	check(ans<<=1),check(ans=Pow(3,n)+mod-ans);
	cout<<ans;
	return 0;
}

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

int main() {

    char s[11];
    char t[11];

    scanf("%s%s", s, t);

    int isCheck = 1;
    for (int i = 0; i < strlen(s); i++) {
        if (s[i] != t[i]) {
            isCheck = 0;
            break;
        }
    }

    printf("%s", (isCheck == 1 ? "Yes" : "No"));

    return 0;

}


Measured memory_bytes: 1708
#include <iostream>
using namespace std;
string str[3];
int res;
void fun(int mem) {
    if (str[mem].empty()) {
        res = mem;
        return;
    }
    int card = str[mem][0] - 'a';
    str[mem].erase(str[mem]. begin());
    fun(card);
}

int main(void){
    // Your code here!
    cin >> str[0] >> str[1] >> str[2];
    fun(0);
    printf("%c", res + 'A');
}


Measured memory_bytes: 256
def solve(string):
    k, a, b = map(int, string.split())
    return "OK" if b - a >= k or min(map(lambda x: x % k, range(a, b + 1))) == 0 else "NG"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9088
#include<iostream>
using namespace std;
int n,x,y;
int a,b;
int s;
int main(){
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		if(a>=x&&b>=y) s++;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	float x1,y1,x2,y2,x3,y3,xp,yp;
	int flag;
	
	while(scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
		flag=1;
		if(y1==y2){
			if((yp-y1)*(y3-y1)<0)
				flag=0;
		}else{ 
			if(( xp-( x1-(y1-yp)*(x1-x2)/(y1-y2) ) )*( x3-( x1-(y1-y3)*(x1-x2)/(y1-y2) ) )<0)
				flag=0;
		}
		if(y3==y1){
			if((yp-y3)*(y2-y3)<0)
				flag=0;
		}else{
			if(( xp-( x3-(y3-yp)*(x3-x1)/(y3-y1) ) )*( x2-( x3-(y3-y2)*(x3-x1)/(y3-y1) ) )<0)
				flag=0;
		}
		if(y2==y3){
			if((yp-y2)*(y1-y2)<0)
				flag=0;
		}else{
			if(( xp-( x2-(y2-yp)*(x2-x3)/(y2-y3) ) )*( x1-( x2-(y2-y1)*(x2-x3)/(y2-y3) ) )<0)
				flag=0;
		}
		if(flag==1)
			printf("YES\n");
		else
			printf("NO\n");
	}
	//for(i=0;i<=1000000000;i++);
	return 0;
}

Measured memory_bytes: 608
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();

int main(){
  int h,n;
  cin>>h>>n;
  vector<int> dp(h+1,INT_MAX-10000);
  //dp [x] - minimum total cost to get the value x
  dp[0]=0;
  for(int c = 0;c<n;c++){
    int value,cost;
    cin>>value>>cost;
    for(int i = 0;i<=h;i++){
      //dp[i] -> dp[i+value]
      int j=min(h,i+value);
      dp[j]=min(dp[j],dp[i]+cost);
    }
  }
  cout<<dp[h]<<'\n';
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n,t,a[100005],mx[100005],ans=0,m=0;
cin>>n>>t;

rep(i,1,n)cin>>a[i];
mx[n]=a[n];
ren(i,n-1,1)mx[i]=max(mx[i+1],a[i]);

rep(i,1,n-1)
{
	if(mx[i+1]-a[i]==m)
	ans++;
	else if(mx[i+1]-a[i]>m)
	{
		ans=1;m=mx[i+1]-a[i];
	}
}
ol(ans);

return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); ++(i))
#define Rep(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define ALLIN(v) rep(i,v.size())cin>>v[i]
#define all(v) (v).begin(),(v).end()
#define bet(a,x,b) a<=x&&x<b
#define fi first
#define se second
using namespace std;

using ll=long long;
using ull=unsigned long long;
using arr=vector<int>;
using mat=vector<arr>;
using pi=pair<int,int>;
template<typename T>
using vec=vector<T>;
template<typename T>
using pq=priority_queue<T>;
template<typename T>
using rpq=priority_queue<T,vec<T>,greater<T>>;

int main(void){
  int N,K; cin>>N>>K;
  
  int able=(N-1)*(N-2)/2;
  if(able<K){
    cout<<-1;
    return 0;
  }
  
  int M=N-1+able-K;
  cout<<M<<endl;
  int rem=M-N+1,now=2;
  for(int i=2; i<=N; ++i){
    cout<<1<<" "<<i<<endl;
  }
  while(rem>0){
    if(rem>=N-now){
      for(int i=now+1; i<=N; ++i){
        cout<<now<<" "<<i<<endl;
      }
      rem-=N-now;
    }
    else{
      for(int i=now+1; i<=now+rem; ++i){
        cout<<now<<" "<<i<<endl;
      }
      rem=0;
    }
    ++now;
  }
}


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

int main(void)
{
  // 探すのはお菓子を持っていない人
  int sunuke[105] = {0};

  int N; // すぬけの人数
  int K; // お菓子の種類
  cin >> N >> K;
  // お菓子の種類数分、全て調べる
  for (int i = 0; i < K; i++)
  {
    int d; // あるお菓子を持っている子供の数
    cin >> d;
    for (int j = 0; j < d; j++)
    {
      int A; // お菓子を持っている子供の番号、１から始まる
      cin >> A;
      sunuke[A] = 1; // お菓子を持っているフラグを立てる
    }
  }

  int count = 0; // お菓子を持っていない人を数える
  for (int i = 1; i <= N; i++)
  {
    if (sunuke[i] == 0)
    {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3536
import collections

N = int(input())
hList = list(map(int, input().split()))
count = 0
n_p = collections.Counter([ i + hList[i] for i in range(len(hList))])

for i in range(N):
  if i - hList[i] > 0:
    count += n_p.get(i - hList[i], 0)

print(count)

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


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

    int n;
    cin>>n;
    int a[n];
    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++){
            if(abs(a[i]-a[j])%(n-1)==0){
                cout << a[i] << " " << a[j] << endl;
                return 0;
            }
        }
    }
}


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

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

	// freopen("input.txt","r",stdin);
	
	int n,k;
	cin >> n >> k;

	if (n%k) cout << 1;
	else cout << 0;

	return 0;
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, cnt = 0;
  cin >> n;
  for (ll a = 1; a <= n; a++) {
    cnt += (n - 1) / a;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3632
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
char S[110];
char T[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);printf("%d\n",a+b/2);
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

const int inf = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  
  vector<int> h(n, 0);
  for (int& x : h) scanf("%d", &x);

  vector<int> dp(n, inf);
  dp[0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j : {i + 1, i + 2})
      if (j < n) dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));

  printf("%d", dp.back());

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
  ll N,K;
  cin>>N>>K;
    
vector<ll> A(N);
  for(ll i=0;i<N;i++){
  cin>>A[i];
  }
  
ll ans;
  ans=0;
ll sum;  
  for(ll i=0;i<K;i++){
  ans=ans+A[i];
  }
  sum=ans;
  
  for(ll i=0;i<N-K;i++){
//       cout<<sum<<endl;
  sum=sum-A[i];
  sum=sum+A[i+K];
  ans=max(ans,sum);

  }
  
  double k;
  k=0;
 if((ans+K)%2==1){k=5;}
  ans=(ans+K)/2;

 
  cout<<ans<<"."<<k<<endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;
int n, k, b[100001];
int Max = 0;
int sum = 0;

bool judge(int P){
		if(P < Max){
			return false;
		}
		int tr = 1;
		int rest = P;
		for(int i = 0; i < n; i++){
			if(rest - b[i] >= 0){
				rest = rest - b[i];
			}
			else{
				tr++;
				rest = P;
				rest = rest - b[i];
			}
		}
		if(tr <= k){
			return true;
		}
		else{
			return false;
		}
	
}

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> b[i];
		if(b[i] > Max){
			Max = b[i];
		}
		sum += b[i];
	}
	int Left = Max;
	int Right = sum;
	while(true){
		int center = (Left + Right)/2;
		if(judge(center)){
			Right = center;
		}
		else{
			Left = center + 1;
		}
		if(Left >= Right){
			cout << Left << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1552
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int x=Integer.parseInt(str[0]);
        int n=Integer.parseInt(str[1]);
        TreeSet<Integer> ts=new TreeSet<>();
        for(int i=0;i<=101;i++)
        ts.add(i);
        str=br.readLine().split(" ");
        for(int i=0;i<n;i++)
        ts.remove(new Integer(Integer.parseInt(str[i])));
        int t1=ts.floor(x);
        int t2=ts.ceiling(x);
        if((int)Math.abs(t1-x)<(int)Math.abs(t2-x))
        pw.println(t1);
        else if((int)Math.abs(t1-x)>(int)Math.abs(t2-x))
        pw.println(t2);
        else
        pw.println(Math.min(t1,t2));
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32996