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

int main(){
int sx ,sy, tx ,ty;
  cin>>sx>>sy>>tx>>ty;
  int a,b;
  a=tx-sx;
  b=ty-sy;
  for(int i=0;i<a;i++){
cout<<"R";
  }
  for(int i=0;i<b+1;i++){
cout<<"U";
  }
  for(int i=0;i<a+1;i++){
cout<<"L";
  }
  for(int i=0;i<b+1;i++){
cout<<"D";
  }
  cout<<"R"<<"D";
   for(int i=0;i<a+1;i++){
cout<<"R";
  }
   for(int i=0;i<b+1;i++){
cout<<"U";
  }
  for(int i=0;i<a+1;i++){
cout<<"L";
  }
    for(int i=0;i<b;i++){
cout<<"D";
  }
  cout<<endl;
}
    


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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		String s = sc.next();
		//'\'の位置
		Deque<Integer> Slt = new ArrayDeque<Integer>();
		//
		Deque<Pond> Spnd = new ArrayDeque<Pond>();
		int sumArea = 0;
		for(int i = 0; i < s.length(); ++i){
			if(s.charAt(i) == '_') continue;
			if(s.charAt(i) == '\\')
				Slt.push(i);
			else if(s.charAt(i) == '/' && Slt.size() > 0){
				int j = Slt.pop();
				int a = i - j; sumArea += a;
				while(Spnd.size() > 0 && Spnd.getLast().getLeft() > j){
					a += Spnd.pollLast().getArea();
				}
				Spnd.addLast(new Pond(j, a));
			}
		}
		
		System.out.println(sumArea);
		System.out.print(Spnd.size());
		for(Pond p: Spnd){
			System.out.printf(" %d", p.getArea());
		}
		System.out.println();
	}
	
	static class Pond{
		int left; int area;
		public Pond(int l, int a){
			left = l; area = a;
		}
		public void setLeft(int l){
			left = l;
		}
		public int getLeft(){
			return left;
		}
		public void setArea(int a){
			area = a;
		}
		public int getArea(){
			return area;
		}
	}


}

class NScanner {

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	private boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


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

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

    ll a[n];
    int flag = 0;
    map<ll, int> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] != 0){
            flag = 1;
        }

        auto itr = m.find(a[i]);
        if(itr == m.end()){
            m[a[i]] = 1;
        }else{
            m[a[i]]++;
        }
    }

    if(flag == 0){
        cout << "Yes" << endl;
    }else{
        if(m.size() >= 4 || m.size() == 1){
            cout << "No" << endl;
        }else if(m.size() == 2){
            ll c[2];
            int cou[2];
            int i = 0;
            for(auto itr = m.begin(); itr != m.end(); ++itr){
                c[i] = itr->first;
                cou[i] = itr->second;
                i++;
            }

            i = 0;
            if(c[0] != 0 && c[1] != 0){
                i++;
            }else if(n % 3 == 0){
                int k = n / 3;
                if(c[0] == 0){
                    if(cou[0] != k){
                        i++;
                    }
                }else{
                    if(cou[1] != k){
                        i++;
                    }
                }
            }else{
                i++;
            }

            if(i == 0){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else{
            ll c[3];
            int cou[3];
            int i = 0;
            for(auto itr = m.begin(); itr != m.end(); ++itr){
                c[i] = itr->first;
                cou[i] = itr->second;
                i++;
            }

            i = 0;
            ll o = c[0] ^ c[1];
            o = o ^ c[2];
            if(o != 0){
                i++;
            }else if(n % 3 != 0){
                i++;
            }else{
                int k = n / 3;
                for(int j = 0; j < 3; j++){
                    if(cou[j] != k){
                        i++;
                        break;
                    }
                }
            }

            if(i == 0){
                cout << "Yes" << endl;
            }else{
                
                cout << "No" << endl;
            }
        }
    }

    
}

Measured memory_bytes: 8908
program name

    implicit none
    integer A,B
    read*, A,B
    if ( A==1 .or. B==1 ) then
        if (A==B) then
            print*, "Draw"
        elseif (A>B) then
            print*, "Bob"
        else
            print*, "Alice"
        end if
    else
        if (A==B) then
            print*, "Draw"
        elseif (A>B) then
            print*, "Alice"
        else
            print*, "Bob"
        end if
    end if
end program

Measured memory_bytes: 256
N,M = map(int,input().split())
a_list = []
b_list = []
c_list = []
d_list = []
lists = []
for i in range(N):
    a,b = map(int,input().split())
    a_list.append(a)
    b_list.append(b)
for i in range(M):
    c,d = map(int,input().split())
    c_list.append(c)
    d_list.append(d)
for i in range(N):
    min = 9999999999999999999999999
    for j in range(M):
        distance = abs(a_list[i] - c_list[j]) + abs(b_list[i] - d_list[j])
        if min > distance:
            min = distance
            ind = j
    lists.append(ind+1)
for i in range(len(lists)):
    print(lists[i])
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


int main(){
    int A, B;
    cin >> A >> B;

    if(B%A == 0) cout << A+B << endl;
    else cout << B-A << endl;

}



Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

template <class T>
void cin_vec(T* vec, int n) {
    FOR(i, n) cin >> vec[i];
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int lcm(int a, int b) {
    return (a * b) / gcd(a, b);
}

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

    int A, B;
    cin >> A >> B;

    if (A <= 8 and B <= 8)
        cout << "Yay!";
    else
        cout << ":(";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		int N; input_returnner(int N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(int N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---
signed main(void) {
	SETUP;
	solve();
	return 0;
}

void solve() {
	int K, T; cin >> K >> T;
	priority_queue<pii> que;
	REP(i, T){
		int a; cin >> a;
		que.push(MP(a, i));
	}

	while (not que.empty()) {
		pii a = que.top(); que.pop();
		if (que.empty()) {
			cout << a.first - 1  << endl;
			return;
		}
		pii b = que.top(); que.pop();
		a.first -= b.first;
		b.first = 0;
		if (a.first != 0) que.push(a);
		if(b.first != 0) que.push(b);
	}
	cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define pb push_back


///Input/Output macros!
#define gi(x) scanf("%d", &x)
#define gi2(x, y) scanf("%d%d", &x, &y)
#define gi3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define gill(x) scanf("%lld", &x)
#define gill2(x, y) scanf("%lld%lld", &x, &y)
#define gill3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pill(x) printf("%lld\n", x)


///Basic Debugging macros!
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(ll __i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(ll __i__=0;__i__<r;__i__++){for(ll __j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}

using namespace std;

///Power of 2 till 2^31!
ll pow2[32] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648};

///Power function!
ll power(ll x,ll y)
{
        ll res = 1;
        while(y>0){
            if(y&1)
                res *= x;
            y>>=1;
            x*=x;
        }
        return res;
}

///Basic Sieve of Eratosthenes!
void Sieve(ll n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (ll p=2; p<=n; p++)
       if (prime[p])
        cout<<p<<' ';
          //cout <<  << " ";
}

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

bool isPerfectSquare(ll x){ ll s = sqrt(x); return (s*s == x);}

bool isFibonacci(int n){return isPerfectSquare(5*n*n + 4) || isPerfectSquare(5*n*n - 4);}

bool isPrime(int n){if (n <= 1)return false;if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0)return false;
    return true;
}

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;


const int MOD = 1000000007;
const long double PI = 4*atan((long double)1);
const ll INF = 1e18;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt = 0;
    if(n&1) {cout<<"No"<<'\n';return 0;}
    for(int i=0;i<n/2;++i){
        if(s[i]!=s[i+n/2]){
            ++cnt;
            break;
        }
    }
    cout<<(cnt ? "No" : "Yes")<<'\n';
    return 0;
}


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

signed main() {
  int n;
  cin>>n;
  int a;
  cin>>a;
  int ans=a-1;
  int t=2;
  for(int i=1;i<n;i++){
    cin>>a;
    if(t==a)t++;
    else{
      ans+=(a-1)/t;
    }
  }
  cout<<ans;





  return 0;
}


Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
// pub mod at {
//     use std;
// }
// use at::*;
use std::cmp::{max, min};
fn main() {
    input! { n, k, q, a: [usize; n] };
    let mut b = a.iter().cloned().collect::<Vec<_>>();
    b.sort();
    let mut ans = b[q - 1] - b[0];
    for i in 1..n - q + 1 {
        let res = b[i + q - 1] - b[i];
        let mut l = 0;
        let mut acc = 0;
        loop {
            while l < n && b[i] > a[l] {
                l += 1;
            }
            if l == n {
                break;
            }
            let mut r = l;
            let mut c = 0;
            while r < n && b[i] <= a[r] {
                if a[r] <= b[i + q - 1] {
                    c += 1;
                }
                r += 1;
            }
            acc += min(c, max(0, (r - l + 1) as isize - k as isize));
            l = r;
        }
        if acc >= q as isize {
            ans = min(ans, res);
        }
    }
    println!("{}", ans);
}


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

using namespace std;

const int kMod = 1e9 + 7;

vector<long long> aib;

void Update(int pos, long long val) {
    for (++pos; pos < (int)aib.size(); pos += (pos & -pos)) {
        aib[pos] = max(aib[pos], val);
    }  
}
long long Query(int pos) {
    long long ret = 0;
    for (++pos; pos > 0; pos -= (pos & -pos)) {
        ret = max(ret, aib[pos]);
    }
    return ret;
}

int main() {
    
    int n; cin >> n;
    vector<int> a(n);
    vector<pair<int, int>> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i].first;
        h[i].second = i;
    }
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    aib.resize(n + 1, 0);

    long long best = 0;
    sort(h.begin(), h.end());
    for (auto p : h) {
        int i = p.second;
        long long now = Query(i) + a[i];
        best = max(best, now);
        Update(i, now);
    }

    cout << best << endl;

    return 0;
}


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

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

	constexpr int MAX_N = 1000;

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

	bitset<MAX_N> back;

	for(int i = 0; i < m; ++i) {
		int c, d;
		cin >> c >> d;

		if(c > d) continue;
		for(int j = c; j < d; ++j) {
			back[j] = true;
		}
	}

	cout << n + 1 + back.count() * 2 << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<string.h>
int main(){
    int n;
    scanf("%d",&n);
    char str[10001];
    scanf("%s",str);
    int length;
    int hoge = 0;
    while(1){
        if(str[hoge] =='\0'){
            break;
        }
        hoge++;
    }
    length = hoge;
    //printf("%d",length);
    for(int i = 0;i < length;i++){
        str[i] += n;
        if(str[i] > 90){
            str[i] -= 26;
        }
    }
    printf("%s",str);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a+b+c >=22){
			System.out.println("bust");
		}else{
			System.out.println("win");
		}
	}
}

Measured memory_bytes: 21844
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        M: usize,
        e: [(usize1, usize1); M],
    }
    let mut edges = vec![vec![false; N]; N];
    for &(a, b) in e.iter() {
        edges[a][b] = true;
        edges[b][a] = true;
    }
    let mut visited = [false; 8];
    let mut count = 0;
    dfs(0, 0, visited, &edges, &mut count);
    println!("{}", count);
}

fn dfs(now: usize, prev: usize, mut visited: [bool; 8], 
       edges: &[Vec<bool>], count: &mut usize) 
{   
    let n = edges.len();
    if visited[now] { return; }
    else { visited[now] = true; }
    
    if visited.iter().take(n).fold(true, |acc, &b| acc&&b) {
        *count += 1;
    } else {
        for (next, _) in edges[now].iter()
        .enumerate()
        .filter(|&(ind, &b)| b) 
        {
            dfs(next, now, visited, edges, count);
        }
    }
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(3)

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

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

    string st;
    cin >> st;

    vvi pos(26, vi(1, st.size()+1));
    vi dp(st.size()+2, INF-1);
    dp[st.size()+1] = 0;
    vi back(st.size()+1, INF-1);
    vector<char> ans(st.size()+1);
    for (int i = st.size(); i >= 0; i--) {
        if (i != st.size()) pos[st[i]-'a'].pb(i+1);
        int ptr = st.size()+1, ch;
        rep(j, 26) {
            if (dp[i] > dp[pos[j].back()]+1) {
                dp[i] = dp[pos[j].back()]+1;
                ptr = pos[j].back();
                ch = j;
            }
        }
        back[i] = ptr;
        ans[i] = (ch + 'a');
    }
    /*
    rep(i, dp.size()) {
        cout << dp[i] << " ";
    } cout << endl;

    rep(i, back.size()) {
        cout << back[i] << " ";
    }cout << endl;

    rep(i, ans.size()) {
        cout << ans[i] << " ";
    } cout << endl;
    */
    int now = 0;
    while (now < st.size()+1) {
        cout << ans[now];
        now = back[now];
    }
    cout << endl;
        


    return 0;
}



Measured memory_bytes: 5780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;

    vector<vector<double>> dp(N + 2, vector<double>(N + 2));
    for (int i = 0; i <= N; ++i)
        dp[0][i] = 1;

    for (int i = 0; i < N; ++i) {
        double p;
        cin >> p;
        for (int j = 0; j <= N; ++j) {
            dp[i + 1][j] += dp[i][j] * p;
            dp[i + 1][j + 1] += dp[i][j] * (1 - p);
        }
    }

    printf("%.10lf\n", dp[N][(N - 1) / 2]);
    return 0;
}


Measured memory_bytes: 70784
N = int(input())
T, A = map(int, input().split())
height_list = list(map(int, input().split()))

temperature_diff_list = []
for height in height_list:
  temperature = T - height*0.006
  temperature_diff = temperature - A if temperature > A else A - temperature 
  temperature_diff_list.append(temperature_diff)

print(temperature_diff_list.index(min(temperature_diff_list)) + 1)

Measured memory_bytes: 9236
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n,a,o=0,i,m=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        o+=(a-1)/(m+1);
        if(a>m+1)a=1;
        m=max(m,a);
    }
    cout<<o<<'\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
     
    int N;
    int A[20];
    int x[20][20];
    int y[20][20];
     
    int counter(int x) {
        if(x == 0) return 0;
        return counter(x >> 1) + (x & 1);
    }
     
    void solve() {
        cin >> N;
        for(int i = 1; i <= N; i++) {
            cin >> A[i];
            for(int j = 1; j <= A[i]; j++) {
                cin >> x[i][j] >> y[i][j];
            }
        }
        int ans = 0;
        for(int bits = 1; bits < (1 << N); bits++) {
            bool ok = true;
            for(int i = 1; i <= N; i++) {
                if(!(bits & (1 << (i-1)))) continue;
                for(int j = 1; j <= A[i]; j++) {
                    if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
                }
            }
            if(ok) ans = max(ans, counter(bits));
        }
        cout << ans << endl;
        return;
    }
     
    int main() {
        solve();
        return 0;
    }

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

int main() {
  int yenSum, yen1;
  cin >> yenSum >> yen1;
  
  if (yenSum % 500 <= yen1) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> m >> n;
    int waru=m/2;
    int waru2=m/2+1;
    rep(i,0,n){
        //cout << "a";
        int x,y;
        cin >> x >>y;
        if(m&1){
            if(x>waru2){
                x=m-x+1;
            }
            if(y>waru2){
                y=m-y+1;
            }
        }else{
           // cout << "b";
            if(x>waru){
                x=m-x+1;
            }
            if(y>waru){
                y=m-y+1;
            }
        }
        int tail=min(x,y)%3;
        cout << ((tail==0)?3:tail) << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
# include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
using namespace std;
const int N = 52;
const int M = 52 * 52 * 52;
const int inf = 0x3f3f3f3f;
int n,x,d,lim,fa[N],pos[N],ans;
int dp[N][M],s[N],sz[N],num;	
bool cmp(int x,int y){return 1LL * sz[x] * s[y] > 1LL * sz[y] * s[x];}
int main()
{
	scanf("%d %d %d",&n,&x,&d);
	scanf("%d",&s[1]);lim = min(n,d);
	for(int i = 2;i <= n;i++)
	scanf("%d %d",&s[i],&fa[i]);
	for(int i = n;i >= 1;i--)
	{
		pos[i] = i;
		s[fa[i]] = min(s[fa[i]] + s[i],x + 1);
		sz[fa[i]] += ++sz[i];
		num += n * sz[i];
    }
    sort(pos + 1,pos + n + 1,cmp);
    for(int i = 1;i <= num;i++)dp[0][i] = inf;
    for(int i = 1;i <= n;i++)
    {
    	memcpy(dp[i],dp[i - 1],sizeof dp[i]);
    	if(s[i] > x)continue;
    	for(int j = 0;j <= num;j++)
    	 for(int k = 1;k <= lim && j - k * sz[i] >= 0 && k * s[i] <= x;k++)
    	 dp[i][j] = min(dp[i][j],min(x + 1,dp[i - 1][j - k * sz[i]] + k * s[i]));
    }
    for(int i = 0;i <= num;i++)
    {
    	if(dp[n][i] > x)continue;
    	int tmp = i,w = x - dp[n][i],t;
    	for(int j = 1;j <= n;j++)
    	{
    		if(s[pos[j]] > w)continue;
    		if(pos[j] == 1)t = w / s[pos[j]];
    		else t = min(max(d - n,0),w / s[pos[j]]);
    		w -= t * s[pos[j]];
    		tmp += t * sz[pos[j]];
    	}
    	ans = max(ans,tmp);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 27904
#include <stdio.h>
#include <string.h>

int main(void) {

  char s[100001];
  scanf("%s", s);
  int count = 0;
  for (int i = 1; i < strlen(s); i++) {
    if (s[i] != s[i-1]) {
      count++;
    }
  }
  printf("%d\n", count);

  return 0;
}

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

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

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

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

#define deb(x) cerr << #x << " = " << x << endl;

int dp[2005];
int solve(int n) {
    if (dp[n]!=-1) {
        return dp[n];
    }
    if (n==0) {
        return 1;
    } else if(n==1 || n==2) {
        return 0;
    }
    int ans = 0;
    for(int i=n; i>=3; i--) {
        ans = (ans+solve(n-i))%mod;
    }
    return dp[n]=ans;
}
int32_t main(){
    ios::sync_with_stdio(false);
    int s;
    cin>>s;
    memset(dp,-1,sizeof(dp));
    cout<<solve(s)<<"\n";

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

int main()
{	
	int a, b;
	cin >> a >> b;
    string s1(b, a+'0');
    string s2(a, b+'0');
    if(a<b) cout << s1 << endl;
    else cout << s2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		String c = sc.next();
		System.out.println((char)(c.toCharArray()[0] + 1));
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mpp make_pair
#define int long long int
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 998244353
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define MAXN 200008
#define MAXI 10000000000007

 
signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int x, y, z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;
const int inf = TEN(18) * 3 + 10;

int N, Q;
string S;

int calc(int k)
{
	int ans = 0;

	int cur = 0;
	int m = 0, c = 0;

	range(i, 0, k - 1) {
		if (S[i] == 'M') {
			m++;
		}
		if (S[i] == 'C') {
			c++;
			cur += m;
		}
	}

	/*
   printf("initial: cur = %lld\n", cur);
   printf("[0, %lld]: m = %lld, c = %lld\n", k - 2, m, c);
	*/
	range(i, 1, N) {
		if (S[i - 1] == 'C') {
			c--;
		}
		if (S[i - 1] == 'M') {
			cur -= c;
			m--;
		}

		if (S[i + k - 2] == 'C') {
			cur += m;
			c++;
		}
		if (S[i + k - 2] == 'M') {
			m++;
		}

		if (S[i - 1] == 'D') {
			ans += cur;
			//printf("i = %lld, ans += %lld\n", i, cur);
		}

		//printf("[%lld, %lld]: m = %lld, c = %lld\n", i, i + k - 2, m, c);
	}
	//puts("");

	return ans;
}

signed main()
{
	cin >> N >> S >> Q;

	rep(i, N + 5) S += ' ';

	rep(_, Q) {
		int k; cin >> k;
		cout << calc(k) << endl;
		//calc(k);
	}
}



Measured memory_bytes: 2436
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
  	int B[N+1];
    for (int i=1;i<N;i++)cin >> B[i];
    B[0]=B[1];
    B[N]=B[N-1];
    int out=0;
  	for (int k=0;k<N;k++){
      if(B[k]<B[k+1])out+=B[k];
        else out+=B[k+1];
    }
  	cout << out;
  	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]
ret = 0
for sx in (-1, 1):
    for sy in (-1, 1):
        for sz in (-1, 1):
            a = sorted(x * sx + y * sy + z * sz for (x, y, z) in xyz)
            ret = max(ret, sum(a[len(a) - m:]))
print(ret)

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
    while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2)
    {
        if (max(xa1, xb1) <= min(xa2, xb2) && max(ya1, yb1) <= min(ya2, yb2))
        {
            OP("YES");
        }
        else
        {
            OP("NO");
        }
    }
    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

  int n,m;
  cin>>n>>m;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }

  int p=a[0],q=a[0]/2;
  rep(i,n){
    p=p*a[i]/__gcd(p,a[i]);
    q=q*(a[i]/2)/__gcd(q,a[i]/2);
  }

  if(m-q<0){
    cout<<0<<endl;
  }else{
    rep(i,n){
      if((q/(a[i]/2))%2==0){
        cout<<0<<endl;
        return 0;
      }
    }
    cout<<(m-q)/p+1<<endl;
  }

}

Measured memory_bytes: 1024
using System;

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

			int[] a = new int[n];
			string[] vs = Console.ReadLine().Split(' ');

			for(int i = 0; i < n; i++) {
				a[i] = int.Parse(vs[i]);
			}

			bool flag = true;
			int swap = 0;
			while(flag) {
				flag = false;
				for(int j = n - 1; j >= 1; j--) {
					if(a[j] < a[j - 1]) {
						int tmp = a[j];
						a[j] = a[j - 1];
						a[j - 1] = tmp;
						flag = true;
						swap++;
					}
				}
			}

			Output(a, n);
			Console.WriteLine(swap);
		}

		static void Output(int[] vs, int n)
		{
			string text = string.Empty;

			for(int i = 0; i < n; i++) {
				text += i == 0 ? $"{vs[i]}" : $" {vs[i]}";
			}

			Console.WriteLine(text);
		}
	}
}



Measured memory_bytes: 15980
#!/usr/bin/env python
# coding: utf-8

# In[8]:


N = int(input())
D,X = map(int, input().split())
A = []
for _ in range(N):
    A.append(int(input()))


# In[9]:


ans = 0
for i in range(N):
    ans += -(-D//A[i])
ans += X
print(ans)


# In[ ]:






Measured memory_bytes: 3060
def AC():
    def solve(s):
        if s.count('[')==1:
            return int(s[1:-1])
        elif '][' in s and ']][[' not in s:
            tmp = sorted(map(int,s[2:-2].split('][')))
            ans=0
            for i in range(len(tmp)//2+1):
                ans+=tmp[i]//2+1
            return ans
        else:
            count=0
            for i in range(len(s)):
                if s[i]=='[':
                    count+=1
                else:
                    count-=1
                    break
            tmp=s[1:-1].split(']'*count+'['*count)
            d=[]
            for i in range(len(tmp)):
                if i==0:
                    tmp[i]=tmp[i]+']'*count
                elif i==len(tmp)-1:
                    tmp[i]='['*count+tmp[i]
                else:
                    tmp[i]='['*count+tmp[i]+']'*count
                d.append(solve(tmp[i]))
            tmp = sorted(d)
            ans=0
            for i in range(len(tmp)//2+1):
                ans+=tmp[i]
            return ans
    
    if __name__ == '__main__':
        n=int(input())
        for i in range(n):
            print(solve(input()))
AC()


Measured memory_bytes: 5700
package main

import (
       "bufio"
       "fmt"
       "os"
       "strconv"
       "sort"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
     sc.Scan()
     i, e := strconv.Atoi(sc.Text())
     if e != nil {
     	panic(e)
     }
     return i
}

func MaxIntSlice(v []int) int {
  sort.Ints(v)
  return v[len(v)-1]
}

func main() {
     sc.Split(bufio.ScanWords)
     k := nextInt()
     n := nextInt()

     a := make([]int, n)
     b := make([]int, n)

     for i:=0; i<n; i++ {
     	 a[i] = nextInt()
     }

     b[0] = a[0] + (k - a[n-1])
     for i:=1; i<n; i++ {
     	 b[i] = a[i] - a[i-1]
     }

     max := MaxIntSlice(b)
     fmt.Println(k - max)
}     

Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
struct edge{ ll to, cost; };//　一つ目は結んでいるノード,二つ目はその辺の重みを指す
//#define sort(a) sort(a.begin(),a.end())
using Graph = vector<vector<edge>>;  //隣接リスト
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int MOD = 1e9+7;
const ll INF =1e18;
int m[1010];

int main(){
  int n;cin>>n;
  ll x;cin>>x;
  ll ans = n;
  int mi;
  cin>>m[0];
  mi = m[0];
  x -= m[0];
  fr(i,n-1){
    cin>>m[i+1];
    x -= m[i+1];
    mi = min(mi,m[i+1]);
  }
  ans += x/mi;
  cout << ans << endl;
}

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

int main() {
  int64_t X;
  cin >> X;
  
  int n = 0;
  int64_t total = 100;
  
  while (total < X) {
    n++;
    total *=1.01;
  }
  
  cout << n << endl;
}

Measured memory_bytes: 3596
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = IR(n)
    dp = [float("inf")]*n
    for i in a:
        j = bisect.bisect_right(dp,-i)
        dp[j] = -i
    print(n-dp.count(float("inf")))
    return

#Solve
if __name__ == "__main__":
    solve()


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

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

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

typedef complex<double> P;
const double EPS = 1e-10;

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) {a = _a, b = _b, v = b - a;}
    L(double _ax, double _ay, double _bx, double _by) {
        a = P(_ax, _ay), b = P(_bx, _by), v = b - a;
    }
};

P crosspointSS(L l1, L l2) {
    double d1 = abs(cross(l2.v, l1.a - l2.a));
    double d2 = abs(cross(l2.v, l1.b - l2.a));
    double t = d1 / (d1 + d2);
    return l1.a + t * l1.v;
}

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

    int q;
    cin >> q;
    while (q--) {
        double v[4][2];
        rep(i, 4) rep(j, 2) cin >> v[i][j];
        L l1(v[0][0], v[0][1], v[1][0], v[1][1]);
        L l2(v[2][0], v[2][1], v[3][0], v[3][1]);
        P p = crosspointSS(l1, l2);
        printf("%.10f %.10f\n", p.real(), p.imag());
    }

}

Measured memory_bytes: 3304
class C_question
    def calc(n,a,b,c,d,e)
        div_list = [a,b,c,d,e]
        div = ((n%div_list.min == 0)? n/div_list.min : n/div_list.min + 1 )
        return div + 4
    end
end

N = gets.chomp.to_i
A = gets.chomp.to_i
B = gets.chomp.to_i
C = gets.chomp.to_i
D = gets.chomp.to_i
E = gets.chomp.to_i
ans = C_question.new.calc(N,A,B,C,D,E)
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll r;
  cin >> r;
  cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
import std.stdio, std.typecons, std.array, std.conv;

alias Tuple!(int, "id", int, "hop") Node;

void main() {
  int number, n; readf("%d\n", &number);
  int[][int] edges;
  foreach(i; 0..number) {
    int from, k;
    scanf("%d %d", &from, &k);
    foreach(j; 0..k) {
      int to;
      scanf(j == k - 1 ? "%d\n" : "%d ", &to);
      edges[from] ~= to;
    }
    if (k == 0) edges[from] = [];
  }
  scanf("%d\n", &n);
  foreach(i; 0..n) {
    int to, from, ttl, ans = -1;
    Node[] queue;
    int[] used = new int[](number + 1);
    scanf("%d %d %d", &from, &to, &ttl);
    queue ~= Node(from, 1);
    used[from] = true; 
    while(!queue.empty) {
      Node node = queue.front;
      if (node.id == to) {ans = node.hop; break;}
      queue.popFront;
      foreach(j; edges[node.id]) {
        if (!used[j]) {
          queue ~= Node(j, node.hop + 1);
          used[j] = true;
        }
      }
    }
    writeln((ans == -1 || ans > ttl) ? "NA" : ans.to!string);
  }
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    string S,moji={};
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            moji += S[i];
        }
    }
    cout << moji << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;
#define LIM 40000000

bool isPrime[LIM];
vector<int> prime;
int main()
{
   ll N;
   cin >> N;
   memset(isPrime, true, sizeof(isPrime));
   N *= 2;
   for (int i = 2; i < LIM; i++)
   {
      if (isPrime[i])
      {
         prime.emplace_back(i);
         for (int j = i + i; j < LIM; j += i)
         {
            isPrime[j] = false;
         }
      }
   }
   vector<ll> factors;
   for (int i = 0; i < (int)prime.size(); i++)
   {
      ll p = prime[i];
      if (p * p > N)
      {
         break;
      }
      if (N % p == 0)
      {
         int ind = factors.size();
         factors.emplace_back(1);
         while (N % p == 0)
         {
            N /= p;
            factors[ind] *= p;
         }
      }
   }
   if (N != 1)
   {
      factors.emplace_back(N);
   }
   int size = factors.size();
   ll ret = LLONG_MAX;
   for (int mask = 0; mask < (1LL << size); mask++)
   {
      vector<ll> r;
      for (int j = 0; j < size; j++)
      {
         if ((mask & (1 << j)))
         {
            r.emplace_back(factors[j] - 1);
         }
         else
         {
            r.emplace_back(0);
         }
      }
      auto ans = crt(r, factors);
      //cout << ans.first << " " << ans.second << endl;
      ret = min(ans.first == 0 ? ans.second : ans.first, ret);
   }
   /*
   for (auto f : factors)
   {
      cout << f << " ";
   }*/
   cout << ret << endl;
   return 0;
}


Measured memory_bytes: 58880