akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <ctime>

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

using namespace std;

// defines
#define rep(i, N) for (i=0;i<(N);i++)
#define sqr(x) (x) * (x)
#define all(v) (v.begin(), v.end())
#define pb push_back
#define random (rand() << 16 ^ rand())

// Typedefs
typedef pair<int, int> ii;

// constants
const int64_t inf = 1e18+7;
const int64_t mod = 1e9+7;


int main() {
	int64_t p[] = { 1LL, 100LL, 10000LL };
	int D, N;

	cin >> D >> N;

	int64_t ans = p[D] * N;
	if (N == 100) ans += p[D];

	cout << ans << endl;


	return 0;
}


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

using namespace std;

const int MAXN = 1e5 + 1;

vector<int> nxt[MAXN];
bool vis[MAXN];

void dfs(int v) {
	vis[v] = 1;
	for(int w : nxt[v])
		if(!vis[w]) dfs(w);
}


int main() {
	ios_base::sync_with_stdio(0);
	
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		nxt[x].push_back(y);
		nxt[y].push_back(x);
	}
	
	int ans = 0;
	for(int v = 1; v <= n; v++) {
		if(!vis[v]) {
			ans++;
			dfs(v);
		}
	}
	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// DIGNUM
std::vector<ll> dignum(ll x) {
  if (x == 0) return {0};
  std::vector<ll> res;
  while (x) {
    res.push_back(x % 10);
    x /= 10;
  }
  std::reverse(res.begin(), res.end());
  return res;
}

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

void solve()
{
  ll K, T;
  std::cin >> K >> T;
  std::vector<ll> va(T);
  for (ll i = 0; i < T; i++) {
    std::cin >> va[i];
  }

  std::sort(va.begin(), va.end(), std::greater<>());
  ll s = 0;
  for (; s < T; s++) {
    ll t = s+1;
    for (; t < T; t++) {
      if (va[s] >= va[t]) {
        va[s] -= va[t];
      } else {
        va[s] = 0;
        va[t] -= va[s];
        break;
      }
    }
    if (t == T) break;
  }

  print(std::max(0LL, va[s] - 1));
  return;
}

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

  solve();
  return 0;
}



Measured memory_bytes: 256
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 $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    let n = s.len();
    let tab = kmp_tab(&s);
    let mut c = vec![0; n];
    for i in 1..n + 1 {
        let l = i - tab[i];
        if i % l == 0 {
            c[i - 1] = l;
        } else {
            c[i - 1] = i;
        }
    }
    let tab_r = kmp_tab(&s.iter().cloned().rev().collect::<Vec<char>>());
    let mut cr = vec![0; n];
    for i in 1..n + 1 {
        let l = i - tab_r[i];
        if i % l == 0 {
            cr[n - i] = l;
        } else {
            cr[n - i] = i;
        }
    }
    if c[n - 1] == 1 {
        println!("{}", n);
        println!("1");
    } else if c[n - 1] == n {
        println!("1");
        println!("1");
    } else {
        println!("2");
        let mut ans = 0;
        for i in 0..n - 1 {
            if i + 1 == c[i] && n - i - 1 == cr[i + 1] {
                ans += 1;
            }
        }
        println!("{}", ans);
    }
}

fn kmp_tab(s: &[char]) -> Vec<usize> {
    let m = s.len();
    let mut tab: Vec<usize> = vec![0; m + 1];
    let mut i = 2;
    let mut j = 0;
    while i <= m {
        if s[i - 1] == s[j] {
            tab[i] = j + 1;
            i += 1;
            j += 1;
        } else if j > 0 {
            j = tab[j];
        } else {
            i += 1;
        }
    }
    tab
}


Measured memory_bytes: 24300
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007

void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   string s;
   cin>>s;
   if(s[0]==s[1] && s[1]==s[2] && s[0]=='R'){
    cout<<3;
    return 0;
   }
   if((s[0]==s[1] || s[1]==s[2]) && s[1]=='R'){
    cout<<2;
    return 0;
   }
   if(s[0]=='R' || s[1]=='R' || s[2]=='R'){
    cout<<1;
    return 0;
   }
   cout<<0;
   return 0;

   


}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, q;
    vector<ll> g[200010], sum(200010, 0);
    vector<bool> used(200010, false);
    queue<int> que;
    int i, j;
    int a, b;
    int p, x;

    cin >> n >> q;

    for (i = 1; i < n; i++)
    {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for (i = 0; i < q; i++)
    {
        cin >> p >> x;
        sum[p] += x;
    }

    que.push(1);
    used[1] = true;

    while (que.size())
    {
        int s = que.front();
        que.pop();

        for (auto &k : g[s])
        {
            if (used[k] == true)
            {
                continue;
            }

            used[k] = true;
            sum[k] += sum[s];
            que.push(k);
        }
    }

    for (i = 1; i <= n; i++)
    {
        printf("%lld%c", sum[i], i == n ? '\n' : ' ');
    }
}

Measured memory_bytes: 17136
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    S[K - 1] = tolower(S[K - 1]);
    write(S);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static String text;

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

		String line = scanner.nextLine();
		String[] lines = line.split(" ");
		int A = Integer.parseInt(lines[0]);
		int B = Integer.parseInt(lines[1]);
		int plus = A + B;
		int minus = A - B;
		int multi = A * B;
		int display;

		if (plus > minus && plus > multi)
			display = plus;
		else if (minus > plus && minus > multi)
			display = minus;
		else if(plus == minus && plus > multi)
			display = plus;
		else
			display = multi;

		System.out.println(display);
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> a(n);

    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >> s;
            s--;
            a[s] |= (1 << i);
        }
    }

    int p = 0;
    rep(i, m) {
        int x;
        cin >> x;
        p |= (x << i);
    }

    for(int b = 0; b < (1 << n); b++) {

        int t = 0;
        rep(i, n) {
            if( (b >> i) & 1 ) {
                t ^= a[i];
            }
        }

        if(t == p) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
l,r = map(int,input().split())

if(r-l >= 2018):
	print(0)
	exit()

mi = 2020
mi2 = 2020
for i in range(l,min(l+2019,r)):
	mi = min(mi,i%2019)
	for j in range(i+1,min(l+2019+1,r+1)):
		mi2 = min((i * j) % 2019,mi2)
print(min((mi * (mi + 1)) % 2019,mi2))

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
#define LL long long
#define MOD 1e9+7
#define pi acos(-1.0)
#define ULL unsigned long long
#define mem_1(str) memset(str,-1,sizeof(str))
#define mem0(str) memset(str,0,sizeof(str))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
using namespace std;
LL num[200000];
LL n,a,b;
bool check(LL x) 
{
    LL sum=0;
    LL q=a-b;
    for(int i=1;i<=n;i++) 
	{
        LL now=num[i]-b*x;
        if(now<=0) continue;
        else 
		{
            sum+=now/q;
            if(now%q) sum++;
            if(sum>x) return false;
        }
    }
    if(sum>x) return false;
    return true;
}
int main() 
{
    scanf("%lld%lld%lld",&n,&a,&b);
    for(int i=1;i<=n;i++) 
	{
        scanf("%lld",&num[i]);
    }
    LL l=1,r=(LL)1e9;
    LL ans=0;
    while(l<=r) {
        LL mid = (l + r)/2;
        if(check(mid)) 
		{
			r=mid-1;
			ans=mid;
		}
        else l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n;

int main() {
  cin >> n;
  set<int> a;
  int m;
  rep(i, n) {
    cin >> m;
    a.insert(m);
  }
  
  if(a.size() == n) cout << "YES";
  else cout <<"NO";
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

#define OBSTACLE_CHAR '#'


void hLight(vector<int> &col, string str, char del);


int main(int argc, const char * argv[]) {
    int H, W;
    cin >> H >> W;
    string *map = new string[H];
    vector<vector<int>> horizontal(H, vector<int>(W, W));
    for (int i = 0; i < H; i++) {
        cin >> map[i];
        hLight(horizontal[i], map[i], OBSTACLE_CHAR);
    }
    
    int light_max = -1;
    for (int w = 0; w < W; w++) {
        int v_count = 0;
        int h_max = -1;
        for (int h = 0; h < H; h++) {
            if (map[h][w] == OBSTACLE_CHAR) {
                if (h > 0 && map[h-1][w] != OBSTACLE_CHAR) {
                    light_max = max(h_max + v_count - 1, light_max);
                }
                v_count = 0;
                h_max = -1;
            } else {
                h_max = max(horizontal[h][w], h_max);
                v_count++;
                if (h == H - 1) {
                    light_max = max(h_max + v_count - 1, light_max);
                }
            }
        }
    }
    
    cout << max(light_max, 0) << endl;
    
    delete [] map;
    
    return 0;
}

void hLight(vector<int> &col, string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);
    
    vector<int> result;
    if (last == string::npos) {
        return;
    }
    
    while (first < str.size()) {
        result.push_back(last);
        for (int i = first; i < last; i++) {
            col[i] = last - first;
        }
        first = last + 1;
        last = str.find_first_of(del, first);
        if (last == string::npos) {
            if (first < str.size()) {
                for (int i = first; i < str.size(); i++) {
                    col[i] = str.size() - first;
                }
            }
            break;
        }
    }
}


Measured memory_bytes: 22016
s = input()
oe = [0,0]
cnt = [0]*(len(s))
for i in range(len(s)):
    if s[i] == 'L':
        cnt[i] += oe[0]
        cnt[i-1] += oe[1]
        oe = [0,0]
    else:
        oe[0] += 1
        oe.reverse()
oe = [0,0]
for i in range(len(s))[::-1]:
    if s[i] == 'R':
        cnt[i] += oe[0]
        cnt[i+1] += oe[1]
        oe = [0,0]
    else:
        oe[0] += 1
        oe.reverse()

print(*cnt)

Measured memory_bytes: 6400
#include "bits/stdc++.h"
using namespace std;

template<typename Mono>
class SegmentTree {
private:
	using F = function<Mono(Mono, Mono)>;
	vector<Mono> Node;
	long long Size;
	const F f;
	const Mono Unit;

public:
	SegmentTree(long long N, const F f, const Mono& M) : f(f), Unit(M) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.assign(Size * 2, Unit);
	}

	void Set(long long N, long long X) {
		Node[N + Size] = X;
	}

	void Set(vector<Mono> V) {
		for (int i = 0; i < V.size(); i++) {
			Set(i, V[i]);
		}
		for (int i = Size - 1; i > 0; i--) Node[i] = f(Node[i * 2], Node[i * 2 + 1]);
	}

	void Set(Mono V[], long long S) {
		for (int i = 0; i < S; i++) {
			Set(i, V[i]);
		}
		for (int i = Size - 1; i > 0; i--) Node[i] = f(Node[i * 2], Node[i * 2 + 1]);
	}

	void update(long long K, long long X) {
		K += Size;
		Node[K] = X;
		while (K >>= 1) Node[K] = f(Node[K * 2], Node[K * 2 + 1]);
	}

	Mono query(long long A, long long B, long long K = 1, long long L = 0, long long R = -1) {
		if (R == -1) R = Size;
		if (B <= L || R <= A) return Unit;
		if (A <= L && R <= B) return Node[K];
		return f(query(A, B, K * 2, L, (L + R) / 2), query(A, B, K * 2 + 1, (L + R) / 2, R));
	}

	Mono operator[](const long long K) const { return Node[K + Size]; };

	long long size() { return Size; };

	void put() {
		printf("%ld\n", Size);
		for (int i = 1; i < Size * 2; i++) {
			printf("%ld", Node[i]);
			if (i == Size * 2 - 1) printf("\n");
			else printf(" ");
		}
	}
};

int main() {
	static long long N, H[200000], A[200000], INF = 1000000000000000000;
	cin >> N;
	SegmentTree<long long> Seg(N + 1, [](long long A, long long B) {return max(A, B); }, -INF);
	Seg.update(0, 0);
	for (int i = 0; i < N; i++) cin >> H[i];
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		long long Q = Seg.query(0, H[i]);
		Seg.update(H[i], Q + A[i]);
	}
	cout << Seg.query(0, N + 1) << endl;
}

Measured memory_bytes: 7424
#include<cmath>
#include<iostream>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define ll long long

int main(){
    ll h; std::cin >> h;
    ll ans=0, depth=std::log2(h);
    rep(i,depth+1) ans += std::pow(2,i);
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 4108
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 150;
char table[MAX_N][MAX_N];
int n, m;
int bfs(int y, int x)
{
    queue<P> que;
    int used[m + 1][n + 1];
    for(int i = 0; i < m; i++) for(int j = 0; j < n; j++) used[i][j] = INF;
    que.push(P(y, x));
    used[y][x] = 0;
    while(que.size())
    {
        P p = que.front(); que.pop();
        for(int i = 0; i < 4; i++)
        {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            int cnt = used[p.first][p.second];
            if(ny >= m || nx >= n || ny < 0 || nx < 0) continue;
            //問題文に注意
            if(table[ny][nx] == '#' && not (table[p.first][p.second] == '#')) cnt++;
            if(used[ny][nx] > cnt)
            {
                used[ny][nx] = cnt;
                que.push(P(ny, nx));
            }
        }
    }
    int res = INF;
    for(int i = 0; i < m; i++) res = min({res, used[i][0], used[i][n - 1]});
    for(int j = 0; j < n; j++) res = min({res, used[0][j], used[m - 1][j]});
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m, n | m)
    {
        int sy, sx;
        for(int i = 0; i < m; i++)
        {
            for(int j = 0; j < n; j++)
            {
                cin >> table[i][j];
                if(table[i][j] == '&') sy = i, sx = j;
            }
        }
        cout << bfs(sy, sx) << endl;
    }
    return 0;
}




Measured memory_bytes: 3068
#include <cstdio>
int a[6];

void north(){
    
    int q[6];
    
    for (int i=0; i<6; i++) {
        
        q[i]=a[i];
        
    }
    
    a[0]=q[4];
    
    a[4]=q[5];
    
    a[5]=q[1];
    
    a[1]=q[0];
    
}

void east(){
    
    int q[6];
    
    for (int i=0; i<6; i++) {
        
        q[i]=a[i];
        
    }
    
    a[2]=q[0];
    
    a[0]=q[3];
    
    a[3]=q[5];
    
    a[5]=q[2];
    
}

void horizontal(){
    
    int q[6];
    
    for (int i=0; i<6; i++) {
        
        q[i]=a[i];
        
    }
    
    a[3]=q[4];
    
    a[1]=q[3];
    
    a[2]=q[1];
    
    a[4]=q[2];
    
}

int main(){
    int b[6];
    int f1 = 0;
    int c1 = 0;
        for (int i = 0; i < 6; ++i)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < 6; ++i)
    {
        scanf("%d", &b[i]);
    }
    
    for (int i = 0; i < 6; ++i)
    {
        if (i%2==0) {
            north();
        }
        if (i%2==1) {
            east();
        }
        
        for (int j = 0; j < 4; ++j)
        {
            horizontal();
            f1=0;
            for (int k = 0; k < 6; ++k)
            {
                if(a[k]==b[k]){
                    f1++;
                }
            }
            if(f1==6){
                c1=1;
            }
        }
    }
    
    
    if(c1==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}




Measured memory_bytes: 2684
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;

#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
typedef long long ll;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}

ll k, a, b;

int main() {
	cin >> k >> a >> b;
	if (k <= a)puts("1");
	else if (a <= b)puts("-1");
	else if ((k - a) % (a - b) == 0)cout << (k - a) / (a - b) * 2 + 1 << endl;
	else cout << (k - a) / (a - b) * 2 + 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

  

 long long a, b, x;
  cin>>a>>b>>x;
  if (a<=x&&x<=a+b) 
  {
    cout<<"YES"<<endl;
  } 
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import numpy as np 
N, M = input().split()
N = int(N)
M = int(M)
xs = []

for i in range(N):
    # select M
    x = np.array(input().split()).astype(np.int64)
    xs.append(x)
results = []
import itertools
for k in itertools.product((1,-1),(1,-1),(1,-1)):
    calcs = []
    for x in xs:
        calcs.append(k[0]*x[0]+k[1]*x[1]+k[2]*x[2])
    results.append(np.sort(calcs)[-M:].sum())
if M==0:
    print(0)
else:
    print(max(results))

Measured memory_bytes: 18840
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

void call(int n)
{
	int i = 1;
	int x;

	do {
		x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
		}
		else {
			do {
				if (x % 10 == 3) {
					printf(" %d", i);
					x = 0;
				}
				else x /= 10;
			} while (x);
		}
	} while (++i <= n);
	putchar('\n');
}

#if 1
int main()
{
	int n;

	scanf("%d", &n);
	call(n);
	return 0;
}
#endif


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
const int MAX_N = 100000;
struct UnionFind{
    int par[MAX_N];
    void init(int n){
        for(int i = 0;i < n;i++)par[i] = i;
    }
    int root(int x){
        if(par[x] == x)return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y)return;
        par[y] = x;
    }
};
main(){
    int N,M;
    cin >> N >> M;
    UnionFind uf;
    uf.init(M);
    vector<int> vl(N);
    rep(i,0,N){
        int K,l;
        cin >> K >> vl[i];
        rep(j,1,K){
            cin >> l;
            uf.unite(vl[i], l);
        }
    }
    rep(i,1,N){
        if(!uf.same(vl[0], vl[i])){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    string s;
    cin>>s;
    if((s[0]==s[1]&&s[1]!=s[2])||(s[0]==s[2]&&s[0]!=s[1])||(s[1]==s[2]&&s[1]!=s[0]))
    cout<<"Yes";
    else
    cout<<"No";
}
        

Measured memory_bytes: 256
def is_ok(a_list, f_list, score, k):
    cnt = 0
    for i in range(len(a_list)):
        target = score // f_list[i]
        cnt += max(0, a_list[i] - target)
        if cnt > k:
            return False
    return True


n, k = map(int, input().split())
a_list = list(map(int, input().split()))
f_list = list(map(int, input().split()))

a_list.sort()
f_list.sort()
f_list.reverse()

ok, ng = 10 ** 12, -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(a_list, f_list, mid, k):
        ok = mid
    else:
        ng = mid
print(ok)


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	string a, b, c;
	cin >> a >> b >> c;

	if (a.rbegin()[0] == b.begin()[0] && b.rbegin()[0] == c.begin()[0]) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int n, p, bowl;
		vector<int> cand;

		cin >> n >> p;
		bowl = p;

		//終了処理
		if( n == 0 && p == 0) break;

		for(int i = 0; i < n; i++)
			cand.push_back(0);	//各候補者が持っている石の数
		
		int j = 0;

		while(1) {

			if(bowl > 0) {
				//椀の中に石が残っているとき
				cand.at(j) ++;
				bowl --;

				if( bowl == 0 && cand.at(j) == p ) {
					cout << j << endl;
					break;
				}

			} else if(bowl == 0) {
				//椀の中に石が残っていないとき
				bowl += cand.at(j);
				cand.at(j) = 0;
			}

			j ++;	//順番を回す。円形であることに注意
			j = j % n;
		}
		

	}

	//while(1){}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int G = 0;
  int Y = 0;
  int P = 0;
  int W = 0;
  
  for(int i=0; i<N; i++){
    string x;
    cin >> x;
	
    if (x == "G"){
      G++;
    }
    else if (x == "Y"){
      Y++;
    }
    else if (x == "P"){
      P++;
    }
    else if (x == "W"){
      W++;
    }
  }
  
  if ( G > 0 && Y > 0 && P > 0 && W >0){
  cout << "Four" << endl;
  }

  else if ((G > 0 && Y > 0 && P > 0) ||
      (G > 0 && Y > 0 && W > 0) ||
      (G > 0 && W > 0 && P > 0) ||
      (Y > 0 && W > 0 && P > 0)) {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
include Math

if __FILE__==$0
	inf=Float::INFINITY
	
	readln_i=lambda{|dl|gets.chomp.split(dl).map(&:to_i)}
	read_i=lambda{gets.chomp.to_i}
	readln_s=lambda{|dl|fp.gets.chomp.split(dl)}
	read_s=lambda{fp.gets.chomp}
	
	q,h,s,d=readln_i[" "]
	n=read_i[]
	
	min=[q*4,h*2,s].sort[0]
	cs=[min,d]
	
	ans=0
	
	if n%2==1
		ans+=cs[0]
		n-=1
	end
	
	cs[0]*=2

	if n>0
		x=n/2
		a=cs[0]*x
		b=cs[1]*x
		ans+= a<=b ? a :b
	end
	p ans
	
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;cin>>n;
        ll u, v;
        ll ans = 0, cur = 0;
        vllp vec;
        vl dp(n);
        rep(i, n){
            cin>>u>>v;
            vec.pb({{u - v, 1}, i}); vec.pb({{u + v, 0}, i});
        }
        sort(all(vec));
        rep(i, 2*n){
            if(vec[i].fs == 1)  dp[vec[i].sec] = cur + 1;
            else cur = max(cur, dp[vec[i].sec]);
            ans = max(ans, dp[vec[i].sec]);
        }
        cout<<ans;
    }
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<long long> L(N+1);
  L[0] = 2;
  L[1] = 1;

  for (int i = 2; i <= N; i++) {
    L[i] = L[i-1] + L[i-2];
  }

  cout << L[N] << endl;

  return 0;
}


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

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

	long long cnt = 0;
	vector<char>used(20);
	int l=0, r;
	for (r = 0; r < N; r++) {
		bool flag = true;
		for (int j = 0; j < 20; j++)if (A[r] & 1 << j) if (used[j]) flag = false;
	
		if (flag) {
			for (int j = 0; j < 20; j++)if (A[r] & 1 << j)used[j] = true;
		}
		else {
			cnt += r - l;
			for (int j = 0; j < 20; j++)if (A[l] & 1 << j)used[j] = false;
			l++;
			r--;
		}
	}
	for (; l < N; l++)cnt += r - l;
	
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

const int N=100005;
int n, a[N];
int main() {
    cin >> n;
    REP(i, n) cin >> a[i];
    int mx=0;
    REP(i, n-1) {
        if(mx>a[i+1] || a[i]-1>a[i+1]) {
            cout << "No\n";
            return 0;
        }
        mx=max(mx, a[i]-1);
        // cout << mx << endl;
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 640
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    C = input()
    ans = 0

    for i in range(len(l_alp)):
        if l_alp[i] == C:
            print(l_alp[i+1])
            return

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <stdio.h>
int main(void){
    int t,s,m,h;
    scanf("%d",&t);
    h = t/(60*60) ;
    m = (t%(60*60)/60);
    s = (t%(60*60)%60);
    printf("%d:%d:%d\n",h,m,s);
    
    
}


Measured memory_bytes: 2740
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  string n;
  cin >> n;
  
  int sum = 0;
  rep(i, n.size()) {
    sum += n[i] - '0';
  }
  
  int N = stoi(n);
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}




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

struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

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

  vector<int> A(M);
  vector<int> B(M);
  rep(i, M) cin >> A[i] >> B[i];

  UnionFind uf(N);
  rep(i, M) uf.unite(A[i] - 1, B[i] - 1);

  set<int> st;
  rep(i, N) st.insert(uf.find(i));
  cout << st.size() - 1 << endl;
  return 0;
}

Measured memory_bytes: 7748
#include <iostream>
#include <cmath>
#include <vector>


int main(void) {
    int N, a;
    std::vector<uint64_t> A;

    std::cin >> N;

    for(int i = 0; i < N; i++) {
        std::cin >> a;
        A.push_back(a);
    }

    int head = 0, tail = 1;
    uint64_t flags = A[0];
    
    uint64_t patterns = 1;

    while(tail < N) {
        if((flags ^ A[tail]) == (flags + A[tail])) { //no dups
            flags ^= A[tail];
            tail++;
            patterns += (tail - head);
        }
        else {
            flags ^= A[head];
            head++;
        }
    }

    std::cout << patterns << std::endl;
}


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

int abs(int x){
  if(x<0){
    x=-x;
  }
  return x;
}

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> x(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i);
  }
  int ans=0;

  for(int i=0;i<N;i++){
    ans+=2*min(x.at(i),abs(K-x.at(i)));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
a = [int(input()) for _ in range(5)]
tempo_total = 0
entrega = 0
for i in range(5):
    resto = 10 - a[i] % 10
    if resto > entrega and resto != 10:
        entrega = resto
tempo_total -= entrega
for item in a:
    tempo_total += math.ceil(item/10) * 10
print(tempo_total)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	
	vector<ll> a(26,INF);
	
	rep(i,0,n){
		string s;
		cin >> s;
		int b[26] = {};
		rep(j,0,s.size()){
			char c = s[j];
			b[c-'a']++;	
		}

		rep(j,0,26)
			a[j] = min(a[j],(ll)b[j]);	
	}
	
	rep(i,0,26){
		char c = char( 'a' + i );
		rep(j,0,a[i])
			cout << c;
	}
	cout << endl;
	ret 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=400+5,mod=1e9+7;
typedef long long ll;
int n,arr[N];
ll dp[N][N];
ll solve(int i=1,int j=n){
    if(i==j)return 0;
    ll &ret=dp[i][j];
    if(~ret)return ret;
    ret=1e18;
    ll sum=0;
    for(int a=i;a<=j;a++)sum+=arr[a];

    for(int x=i;x<j;x++)
        ret=min(ret,sum + solve(i,x) + solve(x+1,j));
    

    return ret;

}
int main()
{
    Elhabashy
    input();
    cin>>n;
    for(int i=1;i<=n;i++)cin>>arr[i];
    memset(dp,-1,sizeof dp);
    cout<<solve()<<endl;
}


Measured memory_bytes: 4964
#include <stdio.h>

#define HASH 100003

typedef struct List {
	struct List* next;
	unsigned long long v;
} list;

typedef struct {
	unsigned long long key, id;
} data;

typedef struct {
	data obj[1000000];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key < h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key < h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, j, k, T;
	unsigned long long N, A, B, C, D, tmp, cost;
	const unsigned long long sup = 0xffffffffffffffff;
	list *p, *hash[HASH], e[1000000];
	data d;
	min_heap h;
	scanf("%d", &T);
	for (i = 1; i <= T; i++) {
		scanf("%llu %llu %llu %llu %llu", &N, &A, &B, &C, &D);
		
		for (j = 0, k = 0; j < HASH; j++) hash[j] = NULL;
		h.size = 0;
		d.key = 0;
		d.id = N;
		push(d, &h);
		
		while (h.obj[0].id > 0) {
			d = pop(&h);
			j = d.id % HASH;
			for (p = hash[j]; p != NULL; p = p->next) if (p->v == d.id) break;
			if (p != NULL) continue;
			
			e[k].v = d.id;
			e[k].next = hash[j];
			hash[j] = &(e[k++]);
			tmp = d.id;
			cost = d.key;
			
			if (tmp <= (sup - cost) / D) {
				d.id = 0;
				d.key = cost + D * tmp;
				push(d, &h);
			}
			
			for (j = 0; j <= 1; j++) {
				if ((tmp + j) % 2 == 0) {
					d.id = (tmp + j) / 2;
					d.key = cost + A + D * j;
					push(d, &h);
					if (tmp > j && j != 0) {
						d.id = (tmp - j) / 2;
						push(d, &h);
					}
				}
			}
			
			for (j = 0; j <= 2; j++) {
				if ((tmp + j) % 3 == 0) {
					d.id = (tmp + j) / 3;
					d.key = cost + B + D * j;
					push(d, &h);
				}
				if (tmp > j && j != 0 && (tmp - j) % 3 == 0) {
					d.id = (tmp - j) / 3;
					d.key = cost + B + D * j;
					push(d, &h);
				}
			}
			
			for (j = 0; j <= 4; j++) {
				if ((tmp + j) % 5 == 0) {
					d.id = (tmp + j) / 5;
					d.key = cost + C + D * j;
					push(d, &h);
				}
				if (tmp > j && j != 0 && (tmp - j) % 5 == 0) {
					d.id = (tmp - j) / 5;
					d.key = cost + C + D * j;
					push(d, &h);
				}
			}
		}
		printf("%llu\n", h.obj[0].key);
	}
}

Measured memory_bytes: 2912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //int n = int.Parse(Console.ReadLine());

            // 文字列配列の入力
            string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            //var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var strA = inputStrArray[0];
            long A = long.Parse(strA);

            var strB = inputStrArray[1];
            double B2 = double.Parse(strB);
            long B = (long)(B2*100+0.5);

            long result = A * B / 100;


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

//関数
void Eerase(vector<set<long>> &path,long a,long b){//二つの頂点が繋がってたら消す。
    set<long>::iterator ite2;;
    ite2=path.at(a).find(b);
    if(ite2!=path.at(a).end()){
        path.at(a).erase(b);
    }
    ite2=path.at(b).find(a);
    if(ite2!=path.at(b).end()){
        path.at(b).erase(a);
    }
}

void Verase(vector<set<long>> &path,long a){//一つの頂点を全消し
    set<long>::iterator ite3;;
    while(path.at(a).size()>0){
        ite3=path.at(a).begin();
        Eerase(path,a,*ite3);
    }
}

    
//main関数
int main() {
    
    
    //入力
    long N,M;
    cin>>N>>M;
    vector<long> A(M),B(M);
    for(int i=0;i<M;i++){
        cin>>A.at(i)>>B.at(i);
        A.at(i)--;
        B.at(i)--;
    }
    
    
    
    //計算
    vector<set<long>> path(N, set<long>());
    for(int i=0;i<M;i++){
        path.at(A.at(i)).insert(B.at(i));
        path.at(B.at(i)).insert(A.at(i));
    }
    
    set<long>::iterator ite;;
    
    vector<long> ansr(M),ansl(M);//>>答えの長さ
    long lengthr=1,lengthl=1;
    ansr.at(0)=0;
    ite=path.at(0).begin();//1つ目をとる
    ansl.at(0)=*ite;
    Eerase(path,ansr.at(0),ansl.at(0));//繋がってたら消す。
    
    bool ryet=(path.at(ansr.at(0)).size()>0),lyet=(path.at(ansl.at(0)).size()>0);
    
    
    while(ryet || lyet){
        if(ryet){
            lengthr++;
            ite=path.at(ansr.at(lengthr-2)).begin();
            ansr.at(lengthr-1)=*ite;
            Verase(path,ansr.at(lengthr-2));
            Eerase(path,ansr.at(lengthr-1),ansl.at(lengthl-1));
            //display(path,N);
        }
        
        ryet=(path.at(ansr.at(lengthr-1)).size()>0);
        lyet=(path.at(ansl.at(lengthl-1)).size()>0);
        if(lyet){
            lengthl++;
            ite=path.at(ansl.at(lengthl-2)).begin();
            ansl.at(lengthl-1)=*ite;
            Verase(path,ansl.at(lengthl-2));
            Eerase(path,ansr.at(lengthr-1),ansl.at(lengthl-1));
            //display(path,N);
        }
        
        ryet=(path.at(ansr.at(lengthr-1)).size()>0);
        lyet=(path.at(ansl.at(lengthl-1)).size()>0);
      //display(path,N);
    }
    
    //出力
    cout<<lengthr+lengthl<<endl;
    for(int i=lengthr-1;i>0;i--){
        cout<<ansr.at(i)+1<<" ";
    }
    cout<<1;
    for(int i=0;i<lengthl;i++){
        cout<<" "<<ansl.at(i)+1;
    }
    cout<<endl;
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, k, q, a, p[100008];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> k >> q;
	memset(p, 0, sizeof(p));
	rep(i, 1, q){
		cin >> a;
		p[a]++;
	}
	
	rep(i, 1, n){
		if(k-(q-p[i]) > 0){
			print("Yes")
		}
		else{
			print("No")
		}
	}
	
	return 0;
}

Measured memory_bytes: 1408
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    unordered_map<ll, ll> sum_appear_count;
    sum_appear_count[0] = 1;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        sum += Ai;
        ans += sum_appear_count[sum];
        sum_appear_count[sum]++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 11260
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	ll N, W; cin >> N >> W;
	V<ll> w(N + 1,0), v(N + 1,0);
	FOR(i,1,N+1) cin >> w[i] >> v[i];
	V<V<ll>> dp(N + 1, V<ll>(W + 1, 0));

	FOR(i,1,N+1){
		FOR(j,0,W+1){
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if (j + w[i] > W) continue;
			dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i - 1][j] + v[i]);
		}
	}
	//FOR(i,0,N+1) print(i,dp[i]);
	cout << *max_element(ALL(dp[N])) << endl;

	return 0;
}

Measured memory_bytes: 80256