akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;

 		
int main() {

int N;
vec(A)
vec(B)
vec(C)
cin>>N;
fx(N){
	vecp(A)
}
fx(N){
	vecp(B)
}
fx(N){
	vecp(C)
}
sorts(A)
sorts(B)
sorts(C)
ll ans=0;
ll a=0,c=0;
fx(N){
  while(a<N&&A.at(a)<B.at(x)){a++;}
  while(c<N&&C.at(c)<=B.at(x)){c++;}
  
  ans+=a*(N-c);
}
ce(ans)
}


Measured memory_bytes: 1784
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, a, b) = (v[0], v[1], v[2]);
    let ans = min(n * a, b);
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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 INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    /*stack<char> st;
    int ans=0;
    rep(i,n){
        if(s[i]=='W')st.push(s[i]);
        else{
            if(!st.empty()){
                if(st.top()=='W'&&s[i]=='R'){
                    ans++;
                    st.pop();
                }else st.push(s[i]);
            }else st.push(s[i]);
        }
    }
    cout<<ans<<endl;*/
    int ans=0;
    int l=0,r=n-1;
    while(r-l>0){
        while(s[l]!='W'&&l<n)l++;
        while(s[r]!='R'&&r>=0)r--;
        if(r<=l)break;
        swap(s[l],s[r]);
        ans++;
        l++;
        r--;
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

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

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

    int n; cin>>n;
    int cnt[26]={};

    for(int i=0; i<n; ++i) {
        string s; cin>>s;
        int c[26]={};
        for(auto e: s) c[e-'a']++;
        if (i==0) {
            for(int j=0; j<26; ++j) cnt[j]=c[j];
        }
        else {
            for(int j=0; j<26; ++j) cnt[j]=min(cnt[j], c[j]);
        }
    }

    string res;
    for(int i=0; i<26; ++i)
        for(int j=0; j<cnt[i]; ++j) res+=char('a'+i);
    cout<<res<<endl;
}


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

int main(void){
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s<d)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

int main(){
  long long N; cin >> N;
  
  //N÷m=X...X (X<m)
  //N=m*X+X   (X<m)
  // =X(m+1)  (X<m)
  // >Xm
  // >X^2
  //sqrtN>X
  //sqrtN以下の数XがNを割り切ったらN/X-1はそうなはず
  
  int start=floor(sqrt(N));
  
  long long result=0;
  for(int i=start; i>0; i--){
    if(N%i==0){
      long long m=N/i-1;
      if(i<m) result+=m;
    }
  }
  cout << result << endl;
}

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

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<long long> a(n, 0);
		for (int i = 0; i < n; i++) cin >> a[i];
		vector<pair<long long, long long>> ai(n);
		for (int i = 0; i < n; i++) ai[i] = make_pair(a[i], i);
		sort(ai.begin(), ai.end(), greater<typeof(*ai.begin())>());
		vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 0));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= i; j++) {
				//左
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + ai[i].first * abs(ai[i].second - j));
				//右
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + ai[i].first * abs(ai[i].second - (n - 1 - i + j)));
			}
		}
		long long ans = 0;
		for (int i = 0; i <= n; i++) ans = max(ans, dp[n][i]);
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 34624
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(B, A * N);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>
#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 998244353;
const ll INF = 0x3F3F3F3F;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline T Ckmax(T &x, T y)
{
    return x = std::max(x, y);
}
template <typename T>
inline T Ckmin(T &x, T y)
{
    return x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
inline T Pow(T x, T y)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= MOD;
        (x *= x) %= MOD;
        y /= 2;
    }
    return r % MOD;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
}
inline ll read(void)
{
    char x;
    while (x = getchar(), x != '-' && !isdigit(x))
        ;
    char flg = x == '-';
    ll num = (flg ? getchar() : x) - '0';
    while (isdigit(x = getchar()))
        (num *= 10) += x - '0';
    return flg ? -num : num;
}
const int N = 1000 + 10;

int main()
{
	cinspu();
	int t;
	std::cin >> t;
	if (t == 25)
		std::cout << "Christmas" << std::endl;
	else if (t == 24)
		std::cout << "Christmas Eve" << std::endl;
	else if (t == 23)
		std::cout << "Christmas Eve Eve" << std::endl;
	else if (t == 22)
		std::cout << "Christmas Eve Eve Eve" << std::endl;
	return 0;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
m = [[int(x) for x in input().split()] for _ in range(M)]
cands = [min(a) + min(b)]
for x, y, c in m:
    cands.append(a[x - 1] + b[y - 1] - c)
print(min(cands))

Measured memory_bytes: 86332
fun main(args: Array<String>) {
    val N = nextInt()
    val S = next()
    var ans = 0
    for (n in 0.. N-3) {
        if (S.substring(n, n+3) == "ABC") ans += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta

Measured memory_bytes: 33272
#include<stdio.h>
int main()
{
    char s[10];
    int i,c1=0,c2=0;

    scanf("%s",s);

    for(i=0; s[i]!='\0'; i++)
    {
        if(s[i]=='A')
            c1++;

        else if(s[i]=='B')
            c2++;
    }


    if((c1==2 && c2==1)||(c1==1 && c2==2))
        printf("Yes\n");

    else
        printf("No\n");
}


Measured memory_bytes: 128
#include <stdio.h>
#include <queue>
#include <utility>

int main(void) {
  int i, j, k, h, w, n, inf = 10e9, dy[4] = {1, 0, 0, -1}, dx[4] = {0, 1, -1, 0};
  scanf("%d%d%d", &h, &w, &n);
  char m[h][w + 10];
  int ans = 0, bfs[h][w], cy[n + 1], cx[n + 1];
  for(i = 0; i < h; ++i) {
    scanf("%s", m[i]);
    for(j = 0; j < w; ++j) {
      if(m[i][j] > '0' && m[i][j] <= '9') cy[m[i][j] - '0'] = i, cx[m[i][j] - '0'] = j;
      if(m[i][j] == 'S') cy[0] = i, cx[0] = j;
    }
  }
  for(k = 0; k < n; ++k) {
    for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) bfs[i][j] = inf;
    bfs[cy[k]][cx[k]] = ans;
    std::queue< std::pair<int, int> > q;
    q.push(std::make_pair(cy[k], cx[k]));
    while( 1 ) {
      int s = 0;
      std::queue< std::pair<int, int> > qt;
      while(!q.empty()) {
        int nowy = q.front().first, nowx = q.front().second;
        q.pop();
        for(i = 0; i < 4; ++i) if(nowy + dy[i] >= 0 && nowy + dy[i] < h && nowx + dx[i] >= 0 && nowx + dx[i] < w && m[nowy + dy[i]][nowx + dx[i]] != 'X' && bfs[nowy + dy[i]][nowx + dx[i]] > bfs[nowy][nowx] + 1) {
          bfs[nowy + dy[i]][nowx + dx[i]] = bfs[nowy][nowx] + 1;
          if(nowy + dy[i] == cy[k + 1] && nowx + dx[i] == cx[k + 1]) {
            s = 1;
            break;
          }
          qt.push(std::make_pair(nowy + dy[i], nowx + dx[i]));
        }
        if(s) break;
        while(!qt.empty()) q.push(qt.front()), qt.pop();
      }
      if(s) {
       ans = bfs[cy[k + 1]][cx[k + 1]];
       break;
      }
    }
  }
  printf("%lld\n", ans);
  return 0; 
} 


Measured memory_bytes: 7460
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static Deque<String> list = new ArrayDeque<>();

    public static void main(String[] args) throws IOException{
        StringBuilder ans = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] sp = new String[2];
        
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                sp = br.readLine().split(" ");
                if (sp[0].equals("insert")) {
                    list.addFirst(sp[1]);
                } else if (sp[0].equals("delete")) {
                    list.remove(sp[1]);
                } else if (sp[0].equals("deleteFirst")) {
                    list.removeFirst();
                } else if (sp[0].equals("deleteLast")) {
                    list.removeLast();
                }
            }
            ans.append(list.poll());
            for (String s : list) {
                ans.append(" ");
                ans.append(s);
            }
            System.out.println(ans.toString());
       
    }
}



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

int main(){
  int N,L;
  cin >> N >> L;
  
  vector<string> S(N);
  for(int i=0; i<N; i++){cin >> S.at(i);}
  
  sort(S.begin(), S.end());
  for(int i=0;i<N;i++){cout << S.at(i);}cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n,t;
  cin>>n>>t;
  VEC<pair<int,int>>p(n);
  REP(i,0,n){
    cin>>p[i].second>>p[i].first;
  }
  sort(ALL(p));
  auto po = p.begin();
  REP(i,0,n){
    if(p[i].first <=t )++po;
  }
  auto cmp = [](pair<int,int>a, pair<int,int>b){return a.second<b.second;};
  sort(p.begin(),po,cmp);
  if(p[0].first<=t)
  cout<<p[0].second;
  else cout<<"TLE";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(ll i=(ll)m ; i < (ll) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll a[101010],cnt[500][500];
int main(){
    ll n,m;
    cin>>n>>m;
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        if(y<400)cnt[y][x]++;
        else {
            a[0]+=x+1;
            a[1]-=x;
            ll z=y-x-1;
            while(z<=n){
                a[z]-=y;
                a[z+1]+=y;
                z+=y;
            }
        }
    }
    rep(i,n)a[i+1]+=a[i];    
    rep(i,n)a[i+1]+=a[i];
    rep(i,400){
        if(i==0)continue;
        ll sum=0,num=0;
        rep(j,400)sum+=cnt[i][j]*j,num+=cnt[i][j];
        rep(j,n){
            sum+=num;
            sum-=cnt[i][(n*i-j-1)%i]*i;
            a[j]+=sum;
        }
    }
    rep(i,n)cout<<a[i]<<endl;    
    return 0;
}


Measured memory_bytes: 4228
#include <iostream>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int parent(int i) {return i / 2;}
int left(int i) {return i * 2;}
int right(int i) {return i * 2 + 1;}

int H = 0;

void insert(int A[], int key) {
  H++;
  A[H] = key;
  int cur_index = H;
  while (cur_index > 1 && A[parent(cur_index)] < A[cur_index]) {
    swap(A[parent(cur_index)], A[cur_index]);
    cur_index = parent(cur_index);
  }
}

void maxHeapify(int A[], int i) {
  int l = left(i);
  int r = right(i);
  int max_index;
  if (l <= H && A[l] > A[i]) {
    max_index = l;
  } else {
    max_index = i;
  }
  if (r <= H && A[r] > A[max_index]) {
    max_index = r;
  }

  if (max_index != i) {
    swap(A[i], A[max_index]);
    maxHeapify(A, max_index);
  }
}


int extract(int A[]) {
  if (H < 1) return -INFTY;
  int max_val = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(A, 1);
  return max_val;
}

int main() {
  int A[MAX+1];
  string operate;
  cin >> operate;
  while (operate.find("end") == string::npos) {
    if (operate.find("insert") != string::npos) {
      int val;
      cin >> val;
      insert(A, val);
    } else {
      cout << extract(A) << endl;
    }
    cin >> operate;
  }
  return 0;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s;
  cin >> s;
  constexpr int N = 13;
  vector<ll> dp(N);
  ll mod = 1e9 + 7;
  ll mul = 1;
  dp[0] = 1;
  for (int i = s.size() - 1; i >= 0; --i) {
    vector<ll> next_dp(N);
    if (s[i] == '?') {
      for (int k = 0; k < 10; ++k) {
        for (int j = 0; j < N; ++j) {
          int index = (k * mul + j) % N;
          next_dp[index] += dp[j];  
          next_dp[index] %= mod;
        }
      }
    } else {
      int k = (int)(s[i] - '0');
      for (int j = 0; j < N; ++j) {
        int index = (k * mul + j) % N;
        next_dp[index] += dp[j];  
        next_dp[index] %= mod;
      }
    }
    mul *= 10;
    mul %= N;
    dp = next_dp;
  }
  cout << dp[5] << endl;
  return 0;
}


Measured memory_bytes: 512
#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;

//Nが素数であるかどうか
bool is_prime(ll N){
  if (N == 1) return false;
  for (ll i = 2; i * i <= N; ++i){
    if (N % i == 0) return false;
  }
  return true;
}

vector<ll> enum_divisors(ll N){
  vector<ll> res;
  for (ll i = 1; i * i <= N; ++i){
    if (N % i == 0) {
      res.push_back(i);
      //重複しない時
      if (N / i != i) res.push_back(N / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

vector<ll> common_divisor(ll x, ll y){
  vector<ll> enum_x = enum_divisors(x);
  vector<ll> enum_y = enum_divisors(y);
  vector<ll> res;
  for (int i = 0; i < enum_x.size(); ++i){
    ll index = lower_bound(enum_y.begin(), enum_y.end(), enum_x[i]) - enum_y.begin();
    if (index == enum_y.size()) continue;
    if (enum_y[index] == enum_x[i]) res.push_back(enum_y[index]);
  }
  return res;
}
int main(){
  ll A, B; cin >> A >> B;
  vector<ll> common = common_divisor(A, B);
  ll ans = 0;
  rep(i, common.size()){
    if (is_prime(common[i])) ans++;
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 512
import sys
import heapq
input = sys.stdin.readline
n,m = map(int, input().split())
job_list = []
for i in range(n):
    a,b = map(int, input().split())
    job_list.append((a,b))
job_list.sort(key=lambda x:x[0])
# print(job_list)

hq = []
max_income = 0
j = 0
for i in range(1,m+1):
    while j < n and job_list[j][0] <= i:
        heapq.heappush(hq, (-job_list[j][1],job_list[j][0]))
        j += 1
    if len(hq) < 1:
        continue
    b_i, a_i = heapq.heappop(hq)
    max_income += -b_i

print(max_income)

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int b[n * 2 + 1];
    int center = n;
    int idx = center;

    rep(i, n) {
        b[idx] = a[i];
        if (idx <= center) {
            idx = (center - idx) + center + 1;
        } else {
            idx = center - (idx - center);
        }
    }
    if (idx > center) {
        //昇順
        int start = center + (center - idx) + 1;
        int end = idx - 1;
        for (int i = start; i < end; i++) {
            cout << b[i] << " ";
        }
        cout << b[end] << endl;
    } else {
        //逆順
        int start = idx + 1;
        int end = center  - (idx - center);
        for (int i = end; i > start; i--) {
            cout << b[i] << " ";
        }
        cout << b[start] << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 1e5 + 10;

vector<int> G[N];

struct state{
	int r, c, t, d;
	bool operator < (const state &rhs) const{
		return d > rhs.d;
	}
};

int dist[25][25][210];

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

inline int &getdist(state &s){
	return dist[s.r][s.c][s.t];
}

void go(state nxt, priority_queue<state> &q){
	int &d = getdist(nxt);
	if (d <= nxt.d) return;
	d = nxt.d;
	q.push(nxt);
}

int a[210];

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> tmp(h);
	rep(i, h) cin >> tmp[i];
	int n;
	cin >> n;
	vector<vector<string>> area(n+1, vector<string>(h));
	area[0] = tmp;

	MEMSET(a, -1);
	a[0] = 0;
	FOR(i, 1, n + 1){
		int x;
		cin >> x;
		a[x] = i;
		rep(j, h) cin >> area[i][j];
	}
	rep(i, 200) if (a[i + 1] < 0) a[i + 1] = a[i];

	rep(i, 25) rep(j, 25) rep(k, 210) dist[i][j][k] = 1e9;

	P start, goal;
	rep(i, h) rep(j, w){
		if (tmp[i][j] == 'S') start = MP(i, j);
		if (tmp[i][j] == 'G') goal = MP(i, j);
	}

	priority_queue<state> q;
	go({ start.first, start.second, 0, 0 }, q);
	while (!q.empty()){
		auto s = q.top();
		q.pop();

		if (getdist(s) < s.d) continue;

		if (s.r == goal.first && s.c == goal.second){
			cout << s.d << endl;
			return 0;
		}

		s.t = min(s.t+1, 200);
		++s.d;
		rep(d, 5){
			state nxt = s;
			if (d == 4) --nxt.d;
			nxt.r += dx[d], nxt.c += dy[d];
			if (nxt.r < 0 || nxt.r >= h || nxt.c < 0 || nxt.c >= w) continue;
			int na = a[nxt.t];
			if (area[na][nxt.r][nxt.c] == '#') continue;
			go(nxt, q);
		}
	}
	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 4228
N, D = (int(x) for x in input().split())
X = [None]*N
sq_list = [x**2 for x in range(40*D+1)]
def is_distance_sq(x: list, y: list) -> bool:
    distance_sq = sum([(x[i]-y[i])**2 for i in range(D)])
    return distance_sq in sq_list

for i in range(N):
    X[i] = [int(x) for x in input().split()]

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if is_distance_sq(X[i], X[j]):
            ans += 1

print(ans)


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

int main(){
  string s;
  int len,ans=0,cnt=0;
  cin>>s;
  len=s.length();
  
  rep(i,0,len){
    if(s.substr(i,1)=="A"||s.substr(i,1)=="C"||s.substr(i,1)=="G"||s.substr(i,1)=="T"){
      cnt++;ans=max(ans,cnt);
    }
    else{cnt=0;}
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define foe(i,a) for(__typeof(a.begin())i=a.begin();i!=a.end();++i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef double ld;
typedef long long L;
typedef long double lf;
typedef unsigned int uint;
typedef unsigned long long uL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f,mo=1e9+7;
template<typename A,typename B>inline bool upmx(A&x,const B&y){return x<y?x=y,1:0;}
template<typename A,typename B>inline bool upmn(A&x,const B&y){return x>y?x=y,1:0;}
template<typename T>inline T gcd(T x,T y){for(;y;swap(x,y))x%=y;return x;}
inline int Pow(int a,int b,int p=mo){int r=1;for(;b;b>>=1,a=1ll*a*a%p)if(b&1)r=1ll*r*a%p;return r;}
#ifdef flukehn
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
const int N=2011;
int a[N],n,b[N],K,Q;
inline bool cmp(int i,int j){
	return a[i]<a[j];
}
int c[N];
int chk(int m){
	rep(i,1,n-Q+1){
		memset(c,0,sizeof c);
		rep(j,i,n){
			if(a[b[j]]>a[b[i]]+m)c[b[j]]=-1;
			else c[b[j]]=1;
		}
		int res=0,l=0,t=0;
		rep(j,1,n+1){
			if(!c[j]){
				res+=max(0,min(j-l-K,t));
				l=j,t=0;
			}else if(c[j]>0)++t;
		}
		if(res>=Q)return 1;
	}
	return 0;
}
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	ios::sync_with_stdio(0);
	cin>>n>>K>>Q;
	int l=inf,r=-inf;
	rep(i,1,n){
		cin>>a[i];
		upmx(r,a[i]);
		upmn(l,a[i]);
		b[i]=i;
	}
	sort(b+1,b+n+1,cmp);
	r-=l,l=0;
	for(;l<r;){
		int m=l+r>>1;
		if(chk(m))r=m;
		else l=m+1;
	}
	cout<<l;
}

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

#define int long long

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

int N, K;
int x[100000], y[100000];
string c[100000];
int imos_W[2000][2000], imos_B[2000][2000];
int nW = 0, nB = 0;

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> c[i];
        if (c[i] == "W") {
            imos_W[x[i] % (2 * K)][y[i] % (2 * K)]++;
            nW++;
        } else {
            imos_B[x[i] % (2 * K)][y[i] % (2 * K)]++;
            nB++;
        }
    }
    for (int i = 0; i < 2 * K; i++) {
        for (int j = 1; j < 2 * K; j++) {
            imos_B[i][j] += imos_B[i][j - 1];
            imos_W[i][j] += imos_W[i][j - 1];
        }
    }
    for (int i = 0; i < 2 * K; i++) {
        for (int j = 1; j < 2 * K; j++) {
            imos_B[j][i] += imos_B[j - 1][i];
            imos_W[j][i] += imos_W[j - 1][i];
        }
    }
    int ans = 0;
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            int cur = nW;
            cur += imos_B[2 * K - 1][2 * K - 1] - imos_B[i + K][2 * K - 1] + imos_B[i][2 * K - 1];
            cur -= imos_B[2 * K - 1][j + K] - 2 * imos_B[i + K][j + K] + 2 * imos_B[i][j + K];
            cur += imos_B[2 * K - 1][j] - 2 * imos_B[i + K][j] + 2 * imos_B[i][j];
            cur -= imos_W[2 * K - 1][2 * K - 1] - imos_W[i + K][2 * K - 1] + imos_W[i][2 * K - 1];
            cur += imos_W[2 * K - 1][j + K] - 2 * imos_W[i + K][j + K] + 2 * imos_W[i][j + K];
            cur -= imos_W[2 * K - 1][j] - 2 * imos_W[i + K][j] + 2 * imos_W[i][j];
            ans = max(ans, cur);
        }
    }
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            int cur = nB;
            cur -= imos_B[2 * K - 1][2 * K - 1] - imos_B[i + K][2 * K - 1] + imos_B[i][2 * K - 1];
            cur += imos_B[2 * K - 1][j + K] - 2 * imos_B[i + K][j + K] + 2 * imos_B[i][j + K];
            cur -= imos_B[2 * K - 1][j] - 2 * imos_B[i + K][j] + 2 * imos_B[i][j];
            cur += imos_W[2 * K - 1][2 * K - 1] - imos_W[i + K][2 * K - 1] + imos_W[i][2 * K - 1];
            cur -= imos_W[2 * K - 1][j + K] - 2 * imos_W[i + K][j + K] + 2 * imos_W[i][j + K];
            cur += imos_W[2 * K - 1][j] - 2 * imos_W[i + K][j] + 2 * imos_W[i][j];
            ans = max(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int xx[4] = {0, 1, 0, -1};
int yy[4] = {1, 0, -1, 0};
int block[101][101];
int already[101][101];
int w, h;
int xs, ys;
int xg, yg;
int n;
int dfs(int nowx, int nowy);

int main(){
  while(1){
    memset(block, 0, sizeof(block));
    memset(already, 0, sizeof(already));
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    cin >> xs >> ys;
    cin >> xg >> yg;
    cin >> n;
    for(int i = 0; i < n; i++){
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      int high, wide;
      if(d){
	high = 4; wide = 2;
      }
      else{
	high = 2; wide = 4;
      }
      for(int j = 0; j < high; j++){
	for(int k = 0; k < wide; k++){
	  block[y+j][x+k] = c;
	}
      }
    }
    int ans = dfs(xs, ys);
    if(ans) cout << "OK" << endl;
    else cout << "NG" << endl;
  }
}

int dfs(int nowx, int nowy){
  int a = 0;
  already[nowy][nowx] = 1;
  if(nowx == xg && nowy == yg) return 1;
  for(int i = 0; i < 4; i++){
    int nextx = nowx + xx[i];
    int nexty = nowy + yy[i];
    if(0 < nextx && 0 < nexty && nextx <= w && nexty <= h && already[nexty][nextx] != 1 && block[nexty][nextx] == block[ys][xs]) a += dfs(nextx, nexty);
  }
  return a;
}

Measured memory_bytes: 1252
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#define out(v) cout<<v<<"\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);++i)
using vi = vector<int>;

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

  int x[N], y[N];
  rep(i, N) {
    cin >> x[i] >> y[i];
  }
  vi v(N);
  rep(i, N) v[i] = i;
  double ans = 0;
  do {
    double dist = 0;
    rep(i, N-1) {
      dist += sqrt((x[v[i]] - x[v[i+1]]) * (x[v[i]] - x[v[i+1]]) + (y[v[i]] - y[v[i+1]]) * (y[v[i]] - y[v[i+1]]));
    }
    rep(i, N) dist /= i+1;
    ans += dist;
  } while (next_permutation(all(v)));
  out(fixed << setprecision(15) << ans);

  return 0;
}


Measured memory_bytes: 256
H,W,D=map(int,input().split())
a=[list(map(int,input().split())) for i in range(H)]
Q=int(input())

y=[[-1,-1] for i in range(H*W+1)]
for i in range(H):
    for j in range(W):
        y[a[i][j]]=[i,j]

x=[0 for i in range(H*W+1)]
for i in range(D+1,H*W+1):
    x[i]=x[i-D]+abs(y[i][0]-y[i-D][0])+abs(y[i][1]-y[i-D][1])    

for q in range(Q):
    L,R=map(int,input().split())
    print(x[R]-x[L])

Measured memory_bytes: 20888
import math
A, B, H, M = map(int,input().split())

a = A * math.cos(math.radians(6 * M))
b = A * math.sin(math.radians(6 * M))
c = B * math.cos(math.radians(H*30+M/2))
d = B * math.sin(math.radians(H*30+M/2))

print(((c-a)**2 + (d-b)**2)**0.5)

Measured memory_bytes: 9572
<?php

list($n, $m) = LineIO::read();

$n = intval($n);
$m = intval($m);

$res = 0;

if ($n > 1 && $m > 1)
{
    $res = ($n - 2) * ($m - 2);
}
else if ($n === 1 && $m === 1)
{
    $res = 1;
}
else
{
    $res = $n * $m - 2;
}

LineIO::write($res);


class LineIO
{
    public static function read() {
        return explode(' ', trim(fgets(STDIN)));
    }

    public static function write($str = '') {
        echo $str . PHP_EOL;
    }
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		double[] A = new double[N];
		for(int i = 0; i < N; i++)
			A[i] = sc.nextInt();
		Arrays.sort(A);
		int[] B = new int[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		Arrays.sort(B);
		double[] C = new double[N];
		for(int i = 0; i < N; i++)
			C[i] = sc.nextInt();
		Arrays.sort(C);
		for(int i = 0; i < N; i++) {
			long AB = 0, BC = 0;
			AB = - 1 - Arrays.binarySearch(A, B[i]-0.1);
			BC = N + 1 + Arrays.binarySearch(C, B[i]+0.1);
			ans += AB * BC;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 95428
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,t,a,b,m,c,d,y,x,k,s,r,temp,n;
    t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n;
        n=n%10;
        if(n==3)cout<<"bon";
        else if(n==0 or n==1 or n==6 or n==8)cout<<"pon";
        else cout<<"hon";
    }
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var dices = new List<int[]>();
            for (int i = 0; i < N; i++)
            {
                var intArry = Array.ConvertAll(Console.ReadLine().Split(" "), int.Parse);
                dices.Add(intArry);
            }

            int cnt = 0;
            foreach (var item in dices)
            {
                if (item[0] == item[1])
                {
                    cnt++;
                    if (cnt >= 3)
                    {
                        break;
                    }
                } else
                {
                    cnt = 0;
                }
            }

            if (cnt < 3)
            {
                Console.WriteLine("No");
            } else
            {
                Console.WriteLine("Yes");
            }

        }
    }
}


Measured memory_bytes: 27844
Sa = list(input())
Sb = list(input())
Sc = list(input())

turn = Sa.pop(0)

for i in range(len(Sa)+len(Sb)+len(Sc)):
    if turn == "a":
        if len(Sa) != 0:
            turn = Sa.pop(0)
        else:
            print("A")
            quit()
    elif turn == "b":
        if len(Sb) != 0:
            turn = Sb.pop(0)
        else:
            print("B")
            quit()
    elif turn == "c":
        if len(Sc) != 0:
            turn = Sc.pop(0)
        else:
            print("C")
            quit()


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

int a[101];

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

  int n, m, x;
  cin >> n >> m >> x;

  for (int i = 0; i < m; ++i) {
    int s;
    cin >> s;

    ++a[s];
  }

  for (int i = 0; i < 100; ++i) a[i+1] += a[i];

  cout << min(a[x], m - a[x]) << '\n';

  return (0);
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	string S;

	cin >> S;

	bool f = false;
	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 0) {
			if (S[i] == 'L') {
				f = true;
			}
		} else {
			if (S[i] == 'R') {
				f = true;
			}
		}
	}

	if (f) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=200005;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;
ll f=0,k=1;
map<pll,ll>m;
ll dp1[MAX],dp2[MAX];
ll red,blue;
ll ans;
ll dp[MAX];

ll lca(ll u,ll v){
	while(u!=v){
		ll l1,l2;
		l1 = log2(u);
		l2 = log2(v);
		//cout<<l1<<"$$"<<l2<<endl;
		if(l1<l2)
			swap(u,v);
		u /=2;
	}
	return u;
}





signed main(){
	boost;
	int t=1;
	// cin>>t;
	while(t--){
		int n;
		cin>>n;
		int g=1;
		int temp;
		int sum=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				temp = __gcd(i,j);
				for(int k=1;k<=n;k++){
					g = __gcd(temp,k);
					sum+=g;
				}
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N;
long long H;
const int MAX = 110000;

typedef pair<long long,long long> pll;
pll inp[MAX];

long long sum[MAX];

int main() {
    while (cin >> N >> H) {
        for (int i = 0; i < N; ++i) {
            cin >> inp[i].second >> inp[i].first;
        }
        sort(inp, inp+N, greater<pll>());
        
        long long maxa = 0;
        sum[0] = 0;
        for (int i = 0; i < N; ++i) {
            sum[i+1] = sum[i] + inp[i].first;
            chmax(maxa, inp[i].second);
        }
        
        long long res = H;
        for (long long i = 0; i <= N; ++i) {
            long long rem = H - sum[i];
            if (rem < 0) {
                chmin(res, i);
                continue;
            }
            long long add = (rem + maxa - 1) / maxa;
            chmin(res, add + i);
        }
        cout << res << endl;
    }
}






Measured memory_bytes: 2560
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <list>
using namespace std;

int main()
{
	int N;
  	int water = 0;
    cin >> N;
    vector<int> h(N);
  	for(int i = 0; i < N; i++){
    	cin >> h[i];
    }
  	while(true){
      int max = 0;
      list<int> A;
      for(int i = 0; i < N; i++){
          if(max < h[i]){
              max = h[i];
              A = {};
              A.push_back(i);
          } else if(max == h[i]){
            A.push_back(i);
          }
      }
      if(max == 0)
        break;
      int pre = 100;
      int cnt = 0;
      while(!A.empty()){
          int a = A.front();
          A.pop_front();
          h[a] -= 1;
          if(a != pre+1)
              cnt++;
          pre = a;
      }
      water += cnt;
    }
  	cout << water << endl;
}



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

signed main(void){
    int n,m; cin >> n >> m;
    vector<vector<int>> g(n);
    int ans = 0;
    for(int i=0;i<m;i++){
        int a,b; cin >> a >> b; a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    // for(int i=0;i<n;i++){
    //     for(int j=0;j<g[i].size();j++){
    //         cout << g[i][j] << ' ';
    //     }cout << endl;
    // }cout << endl;

    queue<P>q;
    vector<bool>initial(n,false);
    initial[0]=true;
    q.push(P{0,initial});
    while(q.size()!=0){
        P tmp = q.front();q.pop();
        int e = tmp.first;
        vector<bool>already = tmp.second;

        // cout << e << ' ';
        // for(int i=0;i<already.size();i++) cout << already[i] << ' ';
        // cout << endl;

        bool change = false;
        for(int i=0;i<g[e].size();i++){
            if(already[g[e][i]]==false){
                change = true;
                vector<bool>next_already;
                copy(already.begin(), already.end(), back_inserter(next_already) );
                next_already[g[e][i]]=true;
                q.push(P{g[e][i],next_already});
            }
        }
        if(change == false){
            bool ok = true;
            for(int i=0;i<already.size();i++){
                if(already[i]==false){
                    ok = false;
                    break;
                }
            }
            if(ok == true) ans++;
        }
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef int64_t LL;

const int mod = 1000000007;
struct Mint {
    LL x; // typedef long long LL;
    Mint(LL x=0):x((x%mod+mod)%mod){}
    Mint operator-() const { return Mint(-x);}
    Mint& operator+=(const Mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    Mint& operator-=(const Mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    Mint& operator*=(const Mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    Mint operator+(const Mint a) const {
        Mint res(*this);
        return res+=a;
    }
    Mint operator-(const Mint a) const {
        Mint res(*this);
        return res-=a;
    }
    Mint operator*(const Mint a) const {
        Mint res(*this);
        return res*=a;
    }
    Mint pow(LL t) const {
        if (!t) return 1;
        Mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    Mint inv() const {
        return pow(mod-2);
    }
    Mint& operator/=(const Mint a) {
        return (*this) *= a.inv();
    }
    Mint operator/(const Mint a) const {
        Mint res(*this);
        return res/=a;
    }
};

istream& operator>>(istream&i,Mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const Mint&a){o<<a.x;return o;}

const int N = 2e5+5;
int n, a, b;
Mint ifact[N+1];

void init() {
    Mint res = 1;
    for(int i=1; i<=N; i++) res *= i;
    ifact[N] = res.inv();
    for(int i=N; i>0; i--) ifact[i-1] = ifact[i]*i;
}

Mint C(int n, int r) {
    Mint res=1;
    for(int i=0; i<r; i++) res *= (n-i);
    res *= ifact[r];
    return res;
}

int main() {
    cin >> n >> a >> b;
    init();
    Mint res = 2;
    Mint ans = res.pow(n) - 1;
    ans -= C(n, a) + C(n, b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
char mp[102][102];//mp[w][h]

void dfs(int wj,int hi,char c){
  mp[wj][hi] = '.';
  if(mp[wj+1][hi] == c) dfs(wj+1,hi,c);
  if(mp[wj-1][hi] == c) dfs(wj-1,hi,c);
  if(mp[wj][hi+1] == c) dfs(wj,hi+1,c);
  if(mp[wj][hi-1] == c) dfs(wj,hi-1,c);
  return;
}
  
int main(){
  int w,h,i,j;

  while(1){
    int cnt = 0;
     scanf("%d%d",&h,&w);
    if((!w) && (!h)) break;
    for(i=0;i <=w+1;i++) mp[i][0] ='.',mp[i][h+1] = '.';
    for(i=1;i <=h;i++) mp[0][i] = '.',mp[w+1][i] = '.';
    for(i=1;i <= h;i++){
      for(j=1;j <= w;j++){
        scanf(" %c",&mp[j][i]);
      }
    }
    for(i=1;i <= h;i++){
      for(j=1;j <= w;j++){
        if(mp[j][i] != '.') cnt++,dfs(j,i,mp[j][i]);
      }
    }

    printf("%d\n",cnt);
  }

  return 0;
}

Measured memory_bytes: 1072
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod=(1e9)+7;
const int N=100000+10;
int n;
int a[N],b[N];
int al[N],ar[N];
int bl[N],br[N];
inline int min(int a,int b){return a<b?a:b;}
inline int max(int a,int b){return a>b?a:b;}
int main()
{
    int i,j;
    while(~scanf("%d",&n))
    {
        for(i=1;i<=n;i++) scanf("%d",&a[i]);
        for(i=1;i<=n;i++) scanf("%d",&b[i]);
        for(i=1;i<=n;i++)
        {
            if(i==1)
            {
                al[i]=ar[i]=a[i];
                continue;
            }
            if(a[i]>a[i-1])
            {
                al[i]=ar[i]=a[i];
                continue;
            }
            al[i]=1;ar[i]=a[i];
        }
        for(i=n;i>=1;i--)
        {
            if(i==n)
            {
                bl[i]=br[i]=b[i];
                continue;
            }
            if(b[i]>b[i+1])
            {
                bl[i]=br[i]=b[i];
                continue;
            }
            bl[i]=1;br[i]=b[i];
        }
        ll ans=1;
        for(i=1;i<=n;i++)
        {
            al[i]=max(al[i],bl[i]);
            ar[i]=min(ar[i],br[i]);
            if(al[i]>ar[i])
            {
                ans=0;
                break;
            }
            ans=ans*((ll)ar[i]-(ll)al[i]+1)%mod;
        }
        cout<<ans<<endl;


    }

    return 0;
}


Measured memory_bytes: 2688
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input[] = sc.nextLine().split(" ");
		BigDecimal A = new BigDecimal(input[0]);
		BigDecimal B = new BigDecimal(input[1]);
		System.out.println(A.multiply(B).longValue());
		sc.close();
	}
}


Measured memory_bytes: 35880
#include <bits/stdc++.h>
using namespace std;
int dp[1<<12];
int main(){
    for(int i=0;i<(1<<12);i++) dp[i] = 1e9;
    dp[0] = 0;
    int n, m, a, b, x;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        scanf("%d%d", &a, &b);
        int bi = 0;
        for(int j=0;j<b;j++){
            scanf("%d", &x);
            x--;
            bi |= (1<<x);
        }

        for(int j=(1<<n)-1;j>=0;j--){
            if(dp[j] == 1e9) continue;
            dp[j|bi] = min(dp[j|bi], dp[j] + a);
        }
    }   
    if(dp[(1<<n)-1] == 1e9) dp[(1<<n)-1] = -1;
    printf("%d\n", dp[(1<<n)-1]);
}

Measured memory_bytes: 256
l=[0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())])

Measured memory_bytes: 3060