akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    long long N, K;
    cin >> N >> K;
    vector<int> A(N + 1);
    rep(i,N) cin >> A[i + 1];

    vector<int> check(N + 1, -1);
    long long count = 1;
    check[A[1]] = count;
    int now = A[1];

    while (count < K) {
        count++;
        if (check[A[now]] > 0) {
            K -= check[A[now]];
            int mod = count - check[A[now]];
            K %= mod;
            now = A[now];
            rep(i,K) now = A[now];
            cout << now << endl;
            return 0;
        } else {
            now = A[now];
            check[now] = count;
        }
    }

    cout << now << endl;

    return 0;
}

Measured memory_bytes: 4844
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <time.h>

using namespace std;
typedef long long int ll;

int main()
{
	ll a, b;
	scanf("%lld %lld", &a, &b);
	printf("%lld\n", (b-a)*(b-a+1)/2-b);
	return 0;
}

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

using namespace std;


     
#define ll long long int
#define ld long double


#define fr first
#define se second



#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))


#define pb push_back
#define mp make_pair

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define emla(a, val) memset(a, val, sizeof(a))

#define easm(a, b) (a + b - 1)/b 


#define PI 3.141592653589793238
#define E  2.718281828459045235


ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}


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

const int N = 3000;
double dp[N][N], a[N];
int n;

double solve(int i, int cnt){
  if(i == n && cnt * 2 < n)return 1;
  if(i == n && cnt * 2 >= n)return 0;

  double &re = dp[i][cnt];
  if(re != -1)return re;
  double mx = 0;
  mx += solve(i + 1, cnt) * a[i];
  mx += solve(i + 1, cnt + 1) * (1.0 - a[i]);
  return re = mx;
}

int main(){
  //freopen("input.in", "r", stdin);
  //freopen("output.txt", "w", stdout);
  clock_t z = clock();
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    scanf("%lf", &a[i]);
  for(int i = 0; i < N; i++)
    for(int j = 0; j < N; j++)
      dp[i][j] = -1.;
  printf("%.10lf\n", solve(0, 0));
  debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
  /*
  *try tricky test cases:
    -bounds
    -integer overflow
    -small input (0, 1)
    -big input
    -random tests
  */
  return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 
 
 
int32_t main() {
    fastio;
    ll a;
    cin>>a;
    cout<<a + a*a + a*a*a<<endl;
}

Measured memory_bytes: 3612
#![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 s = read::<String>().chars().collect::<Vec<_>>();
    let s_set = s.iter().cloned().collect::<HashSet<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();

    for &ch in t.iter() {
        if !s_set.contains(&ch) {
            println!("-1");
            return;
        }
    }

    let mut char_poses = vec![vec![]; 26];

    for (i, &ch) in s.iter().enumerate() {
        let ch_idx = ch.to_digit(36).unwrap() as usize - 10;
        char_poses[ch_idx].push(i as i64);
    }
    let mut ans = 0i64;
    let mut cur_pointer = -1i64;
    for &ch in t.iter() {
        let ch_idx = ch.to_digit(36).unwrap() as usize - 10;
        let mut next_idx = char_poses[ch_idx].upper_bound(&cur_pointer);
        if next_idx == char_poses[ch_idx].len() {
            ans += s.len() as i64 - 1 - cur_pointer;
            cur_pointer = -1;
            next_idx = char_poses[ch_idx].upper_bound(&cur_pointer);
        }
        ans += char_poses[ch_idx][next_idx] - cur_pointer;
        // debug!(ch, ans);
        cur_pointer = char_poses[ch_idx][next_idx];
    }
    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()
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}


Measured memory_bytes: 8444
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n], x[n][n], y[n][n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }

    int max = 0;
    for (int i = 0; i < (1<<n); i++) {
        bitset<15> bit(i);
        int flag = 0;
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < a[j]; k++) {
                if (bit[j] == 1 && bit[x[j][k]-1] != y[j][k]) {
                    flag = 1;
                    break;
                }
            }
        }
        if (flag == 0 && bit.count() > max) max = bit.count();
    }

    cout << max << endl;
}


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

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

int main()
{
    int n , h , w ;

    scanf("%d %d %d",&h,&w,&n) ;

    int m = max(h,w) ;

    printf("%d\n" , (n+m-1)/m ) ;

    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int K, T; cin >> K >> T;
    vector<int> a(T);
    for(int i=0; i<T; i++) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    if(T == 1){
        cout << K-1 << endl;
    }
    else{
        cout << max(a[0]-(K-a[0])-1, 0) << endl;
    }
}

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

int main(void) {
    long long X,Y;
    cin>>X>>Y;
    
    int ans = 0;
    long long current=X;
    while(current<=Y){
        current*=2;
        ans++;
    }
    
    // Prints welcome message...
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n, y;
    cin >> n >> y;
    for (int m = 0; m <= n; m++) {
        for (int g = 0; m + g <= n; g++) {
            int s = n - m - g;
            if (m * 10000 + g * 5000 + s * 1000 == y) {
                printf("%d %d %d\n", m, g, s);
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

    int n;
    cin >> n;

    vector<int> p(n);
    int maxv = INF;
    rep(i,n){
        cin >> p[i];
    }

    int res = 0;
    rep(i,n){
        res += (maxv >= p[i]);
        chmin(maxv,p[i]);
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 1792
# AGC034B - ABC
def main():
    # "X" ("BC") comes on left in a section separated by "B" or "C"
    # -> each "X" need to pass through all "A" on the left (cur)
    S = input().rstrip().replace("BC", "X")
    ans, cur = 0, 0
    for i in S:
        if i == "A":
            cur += 1
        elif i == "X":
            ans += cur
        else:  # end of subsequence
            cur = 0
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3500
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;
struct Vertex {
  vector<int32_t> neighbours;
};

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

  int32_t N, M;
  cin >> N >> M;
  vector<Vertex> vertices(N);
  for (int32_t i = 0; i < M; ++i) {
    int32_t a, b;
    cin >> a >> b;
    vertices[a - 1].neighbours.push_back(b - 1);
    vertices[b - 1].neighbours.push_back(a - 1);
  }
  for (const Vertex &vertex : vertices) {
    cout << vertex.neighbours.size() << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a > c {
		c, a = a, c
	}
	if a > b {
		b, a = a, b
	}
	fmt.Println(a * b / 2)
}


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int k, t;
    cin >> k >> t;
    vector<int> as(t);
    for (auto& a : as)
    {
        cin >> a;
    }
    sort(as.begin(), as.end());

    const auto mx = *max_element(as.begin(), as.end());

    cout << max(0, k - 2 * (k - mx) - 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 998244353
#define bit(x) (1 << x)
#define par pair<int,int>
#define maxn 4005

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

ll N;

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

   cin >> N;

   cout << N/500 * 1000 + (N%500)/5 * 5;




}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void) {
	char S[10];
	scanf("%s", S);
	if (!strcmp(S,"Sunny"))
		printf("Cloudy");
	if (!strcmp(S,"Cloudy"))
		printf("Rainy");
	if (!strcmp(S,"Rainy"))
		printf("Sunny");
	return 0;
}

Measured memory_bytes: 128
//=====================================================
// 
// (setq backup-inhibited t)
// (setq auto-save-default nil)
// 
// (column-number-mode t)
// (setq-default tab-width 2 indent-tabs-mode nil)
// 
// (global-set-key "\C-h" 'delete-backward-char)
// 
// (setq indent-line-function 'indent-relative-maybe)
// (global-set-key "\C-m" 'newline-and-indent)
// 
//=====================================================

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

bool comp(const pair<int, int>& lhs, const pair<int, int>& rhs) {
  return lhs.second > rhs.second;
}

int main() {
  while(1){
    int n;
    cin >> n;
    if (!n) break;
    vector<int> v(86400);
    for (int i = 0; i < n; ++i) {
      int h[2],m[2],s[2];
      scanf("%d:%d:%d",&h[0],&m[0],&s[0]);
      scanf("%d:%d:%d",&h[1],&m[1],&s[1]);
      int bg = h[0]*3600 + m[0]*60 + s[0];
      int ed = h[1]*3600 + m[1]*60 + s[1];
      ++v[bg];
      --v[ed];
    }
    for (int i = 1; i < 86400; ++i) {
      v[i] += v[i-1];
    }
    cout << *max_element(begin(v), end(v)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1572
import java.util.Scanner;

public class Main {

    public static long sum = Long.MIN_VALUE;

    public static void dfs(int n, int [][] F, int [][] P, int period, int [] same) {
        if (period == 10) {
            int openCount = 0;
            for (int i = 0; i < n; ++i) {
                if (same[i] > 0) {
                    openCount++;
                    break;
                }
            }
            if (openCount == 0) {
                return;
            }
            long currentSum = 0;
            for (int i = 0; i < n; ++i) {
                currentSum += P[i][same[i]];
            }
            sum = Math.max(sum, currentSum);
            return;
        }

        //not choose this period
        dfs(n, F, P, period + 1, same);

        //choose this period
        for (int i = 0; i < n; ++i) {
            if (F[i][period] == 1) {
                ++same[i];
            }
        }

        dfs(n, F, P, period + 1, same);
        for (int i = 0; i < n; ++i) {
            if (F[i][period] == 1) {
                --same[i];
            }
        }
    }

    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [][] F = new int [n][10];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 10; ++j) {
                F[i][j] = sc.nextInt();
            }
        }
        int [][] P = new int[n][11];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j <= 10; ++j) {
                P[i][j] = sc.nextInt();
            }
        }
        int [] same = new int [n];
        dfs(n, F, P, 0, same);
        System.out.println(sum);

    }
}

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

void solv() {
    vector<char> aiueo = {'a', 'i', 'u', 'e', 'o'};
    char c;
    cin >> c;
    rep(i, aiueo.size()) {
        if (c == aiueo[i]) {
            cout << "vowel" << endl;
            return;
        }
    }
    cout << "consonant" << endl;
}

int main() {
    solv();
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=1e8;
const int oo=0x3f3f3f3f;
const double eps=1e-10;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,m;
const int Maxn=55;
int a[Maxn];
int ans;
int main(){
	n=in();m=in();
	rep(i,n)a[i]=in();
	if(m>=2*n){
		rep(i,n)if(a[i]>0)ans+=a[i];
		cout<<ans<<endl;
		return 0;
	}
	vector<int>v;
	for(int i=0;i<=min(n,m);i++){
		for(int n1=0;n1<=i;n1++){
			v.clear();
			rep(j,n1)v.push_back(a[j]);
			rep(j,i-n1)v.push_back(a[n-1-j]);
			sort(all(v));
//			if(i==3&&n1==3){
//				rep(j,SZ(v))cout<<v[j]<<' ';cout<<endl;
//				cout<<left<<endl;
//			}
			int left=m-i,pos=0;
			while(pos<SZ(v)&&v[pos]<0&&left>0){
				pos++;
				left--;
			}
			int sum=0;
			for(int j=pos;j<SZ(v);j++)sum+=v[j];
			chkmax(ans,sum);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
const int N=200005;

int main()
{
  int h,n;
  cin>>h>>n;
  int x,s=0;
  while(n--)
  {
    cin>>x;
    s+=x;
  }
  if(s>=h) cout<<"Yes";
  else cout<<"No";
	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 all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  map<int, int> arr;
  rep(i,n) {
    int a; cin >> a;
    ++arr[a];
  }

  int ans = 0;
  for (auto p : arr) {
    int num, count;
    tie(num,count) = p;
    if (num > count) ans += count;
    else if (num < count) ans += count - num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String S = sc.next();
			S = S.replaceAll("eraser", "");
			S = S.replaceAll("erase", "");
			S = S.replaceAll("dreamer", "");
			S = S.replaceAll("dream", "");
			if (S.length() == 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}


Measured memory_bytes: 15964
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int a, b, c; cin >> a >> b >> c;
	for (int i = 1; i <= b; i++) {
		if (a*( i ) % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    auto 色 = new bool[](n);
    色[0] = true;
    auto 個数 = new long[](n);
    個数[] = 1;
    foreach (i; 0 .. m)
    {
        long x, y;
        scan(x, y);
        // writeln(x, y);
        個数[x - 1] -= 1;
        個数[y - 1] += 1;
        if (色[x - 1])
        {
            色[y - 1] = true;
        }
        if (個数[x - 1] == 0)
        {
            色[x - 1] = false;
        }
    }
    // writeln(個数);
    // writeln(色);
    long cnt;
    foreach (i; 0 .. n)
    {
        if (色[i] == true && 個数[i] >= 0)
        {
            cnt += 1;
        }
    }
    writeln(cnt);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 5560
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 2000;
 
int N;
ll A[MAX_N];
ll memo[MAX_N][MAX_N];
 
ll memoize(int i, int j){
    if(memo[i][j] != -1) return memo[i][j];
    int i2 = (i == N - 1 ? 0 : i + 1);
    int j2 = (j == 0 ? N - 1 : j - 1);
    int itv = (i > j ? N + j - i : j - i);
    if((N - itv) % 2 == 1){
        if(i == j) return memo[i][j] = A[i];
        else return memo[i][j] = max(memoize(i2, j) + A[i], memoize(i, j2) + A[j]);
    }else{
        if(i == j) return memo[i][j] = 0LL;
        else if(A[i] > A[j]) return memo[i][j] = memoize(i2, j);
        else return memo[i][j] = memoize(i, j2);
    }
    return 0;
}
 
int main(){
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%lld", &A[i]);
    fill(memo[0], memo[N], -1);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            memo[i][j] = memoize(i, j);
        }
    }
    ll res = 0LL;
    for(int i = 0; i < N; i++) res = max(res, memo[i][(i + N - 1) % N]);
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 34076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

string s;

int main() {
    cin >> s;
    int n = s.length();
    int ans = 0;
    rep(i, n/2) {
        if (s[i] != s[n-1-i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
input = readlines()

n = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}

sum = 0

prev = list[0]
list.each_with_index do |l, i|
  next if i == 0
  if l >= prev
    prev = l
    next
  end
  diff = prev - l
  sum += diff
  prev = l + diff
end

puts sum


Measured memory_bytes: 29360
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, M, i, j, x[100001], y[100001], num[100001], red[100001], ans=0;

    cin >> N >> M;

    for(i=1; i<=N; i++){
        num[i] = 1;
        red[i] = 0;
    }

    red[1] = 1;

    for(i=1; i<=M; i++){
        cin >> x[i] >> y[i];

        if(red[x[i]]==1){
            if(num[x[i]]==1){
                red[x[i]] = 0;
            }
            red[y[i]] = 1;
        }

        num[x[i]]--;
        num[y[i]]++;
    }

    for(i=1; i<=N; i++){
        ans += red[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int p, q, r;
	scanf("%d %d %d", &p, &q, &r);
	int a, b, c;
	a = p + q;
	b = q + r;
	c = r + p;
	printf("%d\n", MIN(a, MIN(b, c)));
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

template <typename T> constexpr T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;
template <> constexpr double inf<double> = 1e18;

int main() {
    ll N, M; cin >> N >> M;
    if(N == 1 && M == 1) {
        cout << 1 << endl;
    } else if(N == 1 || M == 1) {
        cout << max(0LL, max(N, M) - 2) << endl;
    } else if(N == 2 || M == 2) {
        cout << 0 << endl;
    } else {
        cout << (N - 2) * (M - 2) << endl;
    }
}

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

int main() {
  ll n,x; cin >> n >> x;
  vector<ll> v(n);
  rep(i, n)
    cin >> v[i];
  
  ll cnt = 1;
  ll sum = 0;
  
  rep(i, n){
    sum += v[i];
    if(sum <= x)
      cnt ++;
    else
      break;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3628
n = int(input())
s = input()
nl = len(s)

alp =["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
s_ans = ""

for i in range(nl):
    newnumber = alp.index(s[i])+n
    if newnumber > 25:
        newnumber = newnumber - 26
    newi = alp[newnumber]
    s_ans += newi

print(s_ans)

Measured memory_bytes: 3064
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
team=array(N,0)
(N*(N-1)/2).times do
  a,b,c,d=get_i
  a-=1
  b-=1
  if c>d
      team[a]+=3
  elsif c<d
      team[b]+=3
  else
      team[a]+=1
      team[b]+=1
  end
end
ans=array(3*10000,0)
team.sort{|x,y| y<=>x}.each_with_index do|t,i|
    ans[t]=i+1 if ans[t].zero?
end
team.each do|i|
  puts ans[i]
end


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

int gcd(int a, int b)
{
	if (a % b == 0)
	{
		return b;
	}
	else
	{
		return (gcd(b, a % b));
	}
}

int main()
{
	int a, b;
	cin >> a >> b;
	long long p = max({a, b}) / gcd(a, b);
	cout << p * min({a, b}) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct edge {int dest; long long len; };
long long ans;
int n, root;
int weight[MAXN], size[MAXN];
vector <edge> a[MAXN];
void work(int pos, int fa) {
	size[pos] = 1;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i].dest != fa) {
			work(a[pos][i].dest, pos);
			size[pos] += size[a[pos][i].dest];
			weight[pos] = max(weight[pos], size[a[pos][i].dest]);
			ans += a[pos][i].len * min(size[a[pos][i].dest], n - size[a[pos][i].dest]) * 2;
		}
	weight[pos] = max(weight[pos], n - size[pos]);
	if (weight[pos] < weight[root]) root = pos;
}
int main() {
	read(n);
	for (int i = 1; i < n; i++) {
		int x, y, z;
		read(x), read(y), read(z);
		a[x].push_back((edge) {y, z});
		a[y].push_back((edge) {x, z});
	}
	weight[0] = n;
	work(1, 0);
	if (weight[root] * 2 == n) {
		for (unsigned i = 0; i < a[root].size(); i++)
			if (weight[a[root][i].dest] == weight[root]) ans -= a[root][i].len;
	} else {
		long long minnum = 1e9;
		for (unsigned i = 0; i < a[root].size(); i++)
			minnum = min(minnum, a[root][i].len);
		ans -= minnum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15360
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll A, B, M;
  cin >> A >> B >> M;
  vector<ll> a(A);
  vector<ll> b(B);
  vector<pair<ll, ll>> m(M);
  vector<ll> c(M);
  vector<ll> ans(M + 1);
  ll INF = 100000000;
  ll answer = INF;
  rep(i, ans.size())
  {
    ans.at(i) = INF;
  }
  rep(i, A)
  {
    cin >> a.at(i);
  }
  rep(i, B)
  {
    cin >> b.at(i);
  }
  rep(i, M)
  {
    cin >> m.at(i).first >> m.at(i).second >> c.at(i);
    m.at(i).first--;
    m.at(i).second--;
    ans.at(i) = a.at(m.at(i).first) + b.at(m.at(i).second) - c.at(i);
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(ans.begin(), ans.end());
  answer = min(ans.at(0), a.at(0) + b.at(0));
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4992
s = list(input().strip())
s.sort()
i = 0
for c in "abcdefghijklmnopqrstuvwxyz!":
    if i < len(s) and s[i] == c:
        while i < len(s) and s[i] == c:
            i += 1
    else:
        if c != "!":
            print(c)
        else:
            print("None")
        raise SystemExit

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long int a, b;
    int K;
    cin >> a >> b >> K;
    for(int i = 0;i < K;i++){
        if(i % 2 == 0){
            b += a/2;
            a /= 2;
        }
        else{
            a += b/2;
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

S = str(input())
sentence_dict = defaultdict(int)

for alpha in S:
    sentence_dict[alpha] += 1

count = 0
for i in sentence_dict.values():
    if i == 1:
        count += 1
        if count == len(sentence_dict):
            print("yes")
    else:
        print("no")
        break

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define MAXN 2550
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(a*b, c*d) << endl;
    return 0;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return siz[root(x)];
    }
};

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

  vector<int> p(N);
  REP(i, N) cin >> p[i];


  UnionFind uf(N);
  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    uf.unite(u, v);
  }

  int ans = 0;
  REP(i, N){
    if(uf.same(i, p[i]-1)) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print("0")
    exit()

m = a[0]
over = False
limit = pow(10, 18)
for i in a[1:]:
    m *= i
    if m > limit:
        over = True
        break

if over:
    print("-1")
else:
    print(m)

Measured memory_bytes: 21648
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define int long long
#define endl '\n'

const int N = 5003;
int n, m;

const pair<int,int> base = {67, 71};
const pair<int,int> mod = {1000000007, 1000000009};
pair<int,int> has[N];
pair<int,int> pw[N];
string s;
pair<int,int> ip[N];

#define fi first
#define se second

int fp(int _x, int _y, int _mod) {
	int _res = 1;
	while(_y){
		if(_y&1) _res = _res*_x%_mod;
		_x = _x*_x%_mod;
		_y >>= 1;
	}
	return _res;
}

pair<int,int> range(int l, int r){
	pair<int,int> res = has[r];
	res.fi -= has[l - 1].fi;
	res.se -= has[l - 1].se;
	res.fi %= mod.fi;
	res.se %= mod.se;
	if(res.fi < 0) res.fi += mod.fi;
	if(res.se < 0) res.se += mod.se;
	res.fi *= ip[l - 1].fi;
	res.se *= ip[l - 1].se;
	res.fi %= mod.fi;
	res.se %= mod.se;
	return res;
}

bool check(int len){
	for(int i = 1; i <= n - len ; i ++){
		pair<int,int> cur = range(i, i + len - 1);
		for(int j = i + len ; j + len - 1 <= n ; j ++){
			pair<int,int> now = range(j, j + len - 1);
			if(cur == now) return true;
		}
	}
	return false;
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	cin >> s;
	pw[0] = {1, 1};
	
	for(int i = 1 ; i <= n ; i ++){
		int tc = (s[i - 1] - 'a' + 1);
		pw[i].fi = pw[i - 1].fi*base.fi%mod.fi;
		pw[i].se = pw[i - 1].se*base.se%mod.se;
		has[i].fi = (has[i - 1].fi + tc*pw[i].fi)%mod.fi;
		has[i].se = (has[i - 1].se + tc*pw[i].se)%mod.se;
	}
	
	ip[n].fi = fp(pw[n].fi, mod.fi - 2, mod.fi);
	ip[n].se = fp(pw[n].se, mod.se - 2, mod.se);
	
	for(int i = n - 1 ; i >= 0 ; i --){
		ip[i].fi = ip[i + 1].fi * base.fi % mod.fi;
		ip[i].se = ip[i + 1].se * base.se % mod.se;
	}
	int L = 1, R = n/2, ans = 0;
	while(L <= R){
		int M = (L + R) >> 1;
		if(check(M)) ans = M, L = M + 1;
		else R = M - 1;
	}
	cout << ans;
}


Measured memory_bytes: 640
//بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ
//لا إله إلا الله محمد رسول الله

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define ll long long
#define pb push_back
#define fr first
#define sc second
#define in freopen("input.txt", "r" , stdin)
#define out freopen("snakes.out", "w", stdout)
using namespace std;

ll n;
ll h[100005];
ll dp[100005];
int main(){
    //in;
    //out;
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }

    dp[2] = abs(h[2]-h[1]);
    for (int i = 3; i <= n; i++) {
        if (dp[i-1] + abs (h[i] - h[i-1]) < dp[i-2] + abs (h[i] - h[i-2])) {
            dp[i] = dp[i-1] + abs (h[i] - h[i-1]);
        }
        else dp[i] = dp[i-2] + abs (h[i] - h[i-2]);
    }

    cout << dp[n];
}




Measured memory_bytes: 1792
#!/usr/bin/env python3

def main():
    N, M, C = map(int, input().split())
    B = [int(s) for s in input().split()]
    As =  [[int(s) for s in input().split()] for i in range(N)]

    correct_sorce = 0

    for A in As:
        line_score = 0
        for i in range(M):
            line_score += B[i] * A[i]
        if (line_score + C) > 0:
            correct_sorce += 1

    print(correct_sorce)



if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
n = input()
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = 1
min_err = 10 ** 9
for i, hn in enumerate(h):
  err = abs(a - (t - hn * 0.006))
  if err < min_err:
    min_err = err
    ans = i + 1
print(ans)

Measured memory_bytes: 62636
#include <iostream>
#include <cmath>
using namespace std;
long long n,a,b,h[100005];
bool check(long long k)
{
	long long ck=k;
	for(int i=0;i<n;i++)
	{
		if(k*b>=(long long) h[i]);
		else if(k*a>=(long long) h[i])
		{
			ck-=(long long) ceil((double) ((double) (h[i]-k*b))/((double) (a-b)));
			if(ck<0) return false;
		}
		else return false;
	}
	return true;
}
int solve()
{
	int lb=-1,rb=1e9;
	while (lb<rb-1)
	{
		int mid=(lb+rb)/(long long)2;
		if (!check(mid))
		{
			lb=mid;
		}
		else
		{
			rb=mid;
		}
	}
	return rb;
}
int main()
{
	cin >> n >> a >> b;
	for (int i=0;i<n;i++)
	{
		cin >> h[i];
	}
	cout << solve();
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    long[] a = new long[n];
    long ans = 1;
    long max = (long)Math.pow(10, 18);

    for(int i = 0; i < n; i++){
      a[i] = sc.nextLong();
      
      if(a[i] == 0){
        System.out.println(0);
        System.exit(0);
      }
    }

    for(int i = 0; i < n; i++){
      if(a[i] <= max / ans){
        ans *= a[i];
      } else {
        ans = -1;
        break;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 61512
import java.util.Scanner;

public class Main{
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a==0&&b==0) break;
            for(int i=0;i<a;i++){
                for(int j=0;j<b;j++){
                    if((i+j)%2==0){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int n,m;
    cin >> n >> m;

    map<ll,ll> mp;
    
    ll sum = 0;
    mp[sum]++;
    REP(i,n) {
        ll a;
        cin >> a;
        sum += a;
        mp[sum % m]++;
    }

    ll ans = 0;
    for(auto v:mp) ans += v.second*(v.second-1)/2;

    pl(ans)    

    return 0;
}


Measured memory_bytes: 4224
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d; 
    cout << (a-c) * (b-d);
    cout << endl;
}


Measured memory_bytes: 256
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * 3 for _ in range(n + 1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])
ans = 0
for i in range(3):
    ans = max(ans, dp[n][i])
print(ans)

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

const int N = 100005;
const int mod = 1000000007;

int dp[N][13];

signed main() {
    string s;
    cin >> s;

    int n = s.size();
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        if(s[i] == '?'){
            for(int j = 0; j < 10; j++){
                for(int k = 0; k < 13; k++){
                    dp[i+1][(k * 10 + j) % 13] += dp[i][k];
                    dp[i+1][(k * 10 + j) % 13] %= mod;
                }
            }
        } else {
            int x = s[i] - '0';
            for(int k = 0; k < 13; k++){
                dp[i+1][(k * 10 + x) % 13] += dp[i][k];
                dp[i+1][(k * 10 + x) % 13] %= mod;
            }
        }
    }
    cout << dp[n][5] << endl;
}


Measured memory_bytes: 5504