akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
struct edge{
	int to; ll cost;
};
  
int main()
{
	int n, m, s, t;
	scanf("%d %d %d %d", &n, &m, &s, &t);
	s--; t--;
	vector<edge> v1[100000], v2[100000];
	for(int i=0; i<m; i++){
		int u, v;
		ll a, b;
		scanf("%d %d %lld %lld", &u, &v, &a, &b);
		u--; v--;
		edge e;
		e.to=v, e.cost=a;
		v1[u].push_back(e);
		e.to=u;
		v1[v].push_back(e);
		e.to=v, e.cost=b;
		v2[u].push_back(e);
		e.to=u;
		v2[v].push_back(e);
	}
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, s));
	ll d1[100000], d2[100000];
	fill(d1, d1+n, INF);
	fill(d2, d2+n, INF);
	d1[s]=0;
	d2[t]=0;
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int x=p.second;
		if(p.first>d1[x]) continue;
		for(int i=0; i<v1[x].size(); i++){
			edge e=v1[x][i];
			if(d1[e.to]>d1[x]+e.cost){
				d1[e.to]=d1[x]+e.cost;
				que.push(P(d1[e.to], e.to));
			}
		}
	}
	que.push(P(0, t));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int x=p.second;
		if(p.first>d2[x]) continue;
		for(int i=0; i<v2[x].size(); i++){
			edge e=v2[x][i];
			if(d2[e.to]>d2[x]+e.cost){
				d2[e.to]=d2[x]+e.cost;
				que.push(P(d2[e.to], e.to));
			}
		}
	}
	ll ans[100000];
	ans[n-1]=d1[n-1]+d2[n-1];
	for(int i=n-2; i>=0; i--){
		ans[i]=ans[i+1];
		if(ans[i]>d1[i]+d2[i]) ans[i]=d1[i]+d2[i];
	}
	for(int i=0; i<n; i++){
		cout<<1000000000000000ll-ans[i]<<endl;
	}
    return 0;
}

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

int main(){
    ll n,a[100005],cnt=1,ans=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cnt++;
        }else{
            ans+=(cnt%2);
            cnt=1;
        }
    }
    ans+=(cnt%2);
    cout<<ans;
}

Measured memory_bytes: 4404
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

N = k()
A = l()
p = 0
ans = 1
for i in range(1, N):
    if p*(A[i]-A[i-1])<0:
        ans += 1
        p = 0
    elif A[i]-A[i-1] != 0:
        p = A[i]-A[i-1]
print(ans)


Measured memory_bytes: 22112
n = gets.to_i
h = gets.split.map &:to_i

cost = Array.new(n, 0)
cost[0] = 0

1.upto(n-1).each{|i|
    cost1 = cost2 = 1e8.to_i
    cost1 = (h[i] - h[i-1]).abs + cost[i-1] if i > 0
    cost2 = (h[i] - h[i-2]).abs + cost[i-2] if i > 1
    cost[i] = [cost1, cost2].min
}

puts cost.last


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, K; cin >> N >> K;
        vector<int> T(N), D(N); rep(i, N) cin >> T[i] >> D[i];

        map<int, pii> top1;
        rep(i, N) set_max(top1[T[i]], make_pair(D[i], i));

        set<int> top1_indices;
        for(auto &p : top1) top1_indices.insert(p.second.second);

        vector<int> top1_list, other_list;
        rep(i, N) (top1_indices.count(i) ? top1_list : other_list).push_back(D[i]);

        while(other_list.size() < N) other_list.push_back(0);

        auto make_sum = [] (vector<int> &l) {
            sort(all(l), greater<int>());
            vector<ll> sum(l.size() + 1);
            rep(i, l.size()) sum[i + 1] = sum[i] + l[i];
            return sum;
        };
        auto top1_sum = make_sum(top1_list);
        auto other_sum = make_sum(other_list);

        ll ans = 0;
        repeat(k, 1, K + 1) {
            ll l = K - k;
            if(k >= top1_sum.size()) continue;
            ll sum = top1_sum[k] + other_sum[l];

            if(l > 0) {
                int m = upper_bound(all(top1_list), other_list[l - 1], greater<int>()) - begin(top1_list) - 1 + 1;

                // if(k < m and m < top1_sum.size()) {
                //     sum = top1_sum[m] + other_sum[K - m];
                // }
            }
            set_max(ans, sum + (ll)k * k);
        }
        cout << ans << endl;

        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 14456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#define ll long long
#define endl '\n'
using namespace std;

vector<int> prime;

bool is_prime(int a)
{
    if(a == 2) return true;
    for(int i = 2; i * i <= a; i++)
    {
        if(a % i == 0)
            return false;
    }
    return true;
}

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    for(int i = 2; i <= 55555; i++)
    {
        if(is_prime(i) && i % 5 == 1)
            prime.push_back(i);
    }
    int N; cin >> N;

    for(int i = 0; i < N; i++)
    {
        cout << prime[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		int r1 = sc.nextInt() - 1;
		int c1 = sc.nextInt() - 1;
		int r2 = sc.nextInt() - 1;
		int c2 = sc.nextInt() - 1;
		char[][] field = new char[h][];
		for (int i = 0; i < h; i++) {
		    field[i] = sc.next().toCharArray();
		}
		PriorityQueue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(r1, c1, 4, 0, 0));
		int[][][] costs = new int[4][h][w];
		for (int[][] arr : costs) {
		    for (int[] arr2 : arr) {
		        Arrays.fill(arr2, Integer.MAX_VALUE);
		    }
		    arr[r1][c1] = 0;
		}
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    if (p.row < 0 || p.row >= h || p.col < 0 || p.col >= w || field[p.row][p.col] == '@') {
		        continue;
		    }
		    if (p.direction != 4) {
		        if (costs[p.direction][p.row][p.col] <= p.value) {
		            continue;
		        }
		        costs[p.direction][p.row][p.col] = p.value;
		    }
		    p.count++;
		    if (p.direction == 0)  {
		        queue.add(new Path(p.row + 1, p.col, 0, p.value + p.count / k, p.count % k));
		    } else {
		        queue.add(new Path(p.row + 1, p.col, 0, p.value + 1, 0));
		    }
		    if (p.direction == 1)  {
		        queue.add(new Path(p.row - 1, p.col, 1, p.value + p.count / k, p.count % k));
		    } else {
		        queue.add(new Path(p.row - 1, p.col, 1, p.value + 1, 0));
		    }
		    if (p.direction == 2)  {
		        queue.add(new Path(p.row, p.col + 1, 2, p.value + p.count / k, p.count % k));
		    } else {
		        queue.add(new Path(p.row, p.col + 1, 2, p.value + 1, 0));
		    }
		    if (p.direction == 3)  {
		        queue.add(new Path(p.row, p.col - 1, 3, p.value + p.count / k, p.count % k));
		    } else {
		        queue.add(new Path(p.row, p.col - 1, 3, p.value + 1, 0));
		    }
		}
		int ans = Integer.MAX_VALUE;
		for (int[][] arr : costs) {
		    ans = Math.min(ans, arr[r2][c2]);
		}
		if (ans == Integer.MAX_VALUE) {
		    System.out.println(-1);
		} else {
		    System.out.println(ans);
		}
	}
	
	static class Path implements Comparable<Path> {
	    int row;
	    int col;
	    int direction;
	    int value;
	    int count;
	    
	    public Path(int row, int col, int direction, int value, int count) {
	        this.row = row;
	        this.col = col;
	        this.direction = direction;
	        this.value = value;
	        this.count = count;
	    }
	    
	    public int compareTo(Path another) {
	        if (value == another.value) {
	            return count - another.count;
	        }
	        return value - another.value;
	    }
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const ll INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll sum = 0;
    rep(i, N) sum += A[i];
    ll x = 0, y = sum, ans = INF * INF;
    rep(i, N-1){
        x += A[i];
        y -= A[i];
        ans = min(ans, abs(x-y));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N; ll K;
    cin >> N >> K;

    ll A[N];
    REP(i, N) cin >> A[i];

    int M = 41;

    ll dp[M+1][2];
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    REP(i, M) {
        ll b = 1LL << (M - i - 1);

        int num = 0;
        REP(j, N) if(A[j] & b) ++num;

        ll v1 = b * (N - num); // if i-th bit of A is 1.
        ll v0 = b * num;  // if i-th bit of A is 0.

        debug(i, b, A, v1, v0);

        // smaller -> smaller
        if (dp[i][1] != -1) {
            dp[i+1][1] = max(v1, v0) + dp[i][1];
        }

        if (dp[i][0] != -1) {
            // exact -> smaller
            if (b & K) {
                dp[i+1][1] = max(dp[i+1][1], dp[i][0] + v0);
            }

            // exact -> exact
            if (b & K) {
                dp[i+1][0] = dp[i][0] + v1;
            } else {
                dp[i+1][0] = dp[i][0] + v0;
            }

        }
    }

    REP(i, M) {
        if (dp[i][0] == 0 && dp[i][1] == 0) continue;
        debug(i, dp[i][0], dp[i][1]);
    }

    cout << fixed << setprecision(20);
    cout << max(dp[M][0], dp[M][1]) << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W,N,M;
int x, y;
typedef long long int  ll;
vector<string> data;
int main(){
    cin >> H >> W;
    data.resize(H);
    for (int i = 0; i < H; ++i) cin >> data[i];
    // for(int i=0;i<H;i++){
    //     string tmps;
    //     cin >> tmps;
    //     data.push_back(tmps);
    // // }
    vector<vector<int>> left(H,vector<int>(W));
    vector<vector<int>> right(H,vector<int>(W));
    vector<vector<int>> up(H,vector<int>(W));
    vector<vector<int>> down(H,vector<int>(W));

    for(int i=0;i<H;i++){
        int tmp=0;
        
        for(int j=0;j<W;j++){
            if(data[i][j]=='#') tmp=0;
            else tmp++;
            left[i][j]=tmp;
        }
    }
    for(int i=0;i<H;i++){
        int tmp=0;
        for(int j=W-1;j>=0;j--){
            if(data[i][j]=='#') tmp=0;
            else tmp++;
            right[i][j]=tmp;
        }
    }
    for(int i=0;i<W;i++){
        int tmp=0;
        for(int j=0;j<H;j++){
            if(data[j][i]=='#') tmp=0;
            else tmp++;
            up[j][i]=tmp;
        }
    }
    for(int i=0;i<W;i++){
        int tmp=0;
        for(int j=H-1;j>=0;j--){
            if(data[j][i]=='#') tmp=0;
            else tmp++;
            down[j][i]=tmp;
        }
    }    
    int ans = -1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(data[i][j]=='#') continue;
            ans = max(ans,left[i][j]+right[i][j]+up[i][j]+down[i][j]-3);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 67200
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val (N, K) = listOfInt()
    val r = if(N % K == 0) { 0 } else { 1 }
    println(r)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33992
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto a = RD;
	auto b = RD;

	writeln(b < a ? a-1 : a);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(double x) {
  return (x < 70.0) + (x < 55.0) + (x < 50.0) + (x < 43.0) +
         (x < 40.0) + (x < 37.5) + (x < 35.5);
}

int g(double x) {
  return (x < 148.0) + (x < 116.0) + (x < 105.0) + (x < 89.0) +
         (x < 83.0) + (x < 77.0) + (x < 71.0);
}

void solve() {
  double t1, t2;
  string t[] = {"NA", "E", "D", "C", "B", "A", "AA", "AAA"};
  while (cin >> t1 >> t2) {
    cout << t[min(f(t1), g(t2))] << endl;
  }
}

Measured memory_bytes: 3044
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = int(input())

    print((a-1)//2)


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

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const double PI = acos(-1.0);
const int MOD = pow(10, 9) + 7;

#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (size_t i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

class Pos {
public:
	double x, y;
	Pos(double x, double y) {
		this->x = x;
		this->y = y;
	}
	Pos() {
		x = 0.0;
		y = 0.0;
	}
};

class Mod {
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}
	
	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};

inline double distance(Pos p1, Pos p2) {
	return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

inline int Kaijo(int n) {
	int ans = 1;
	for (int i = 2; i <= n; ++i) {
		ans *= i;
	}
	return ans;
}

template <typename T>
inline int keta(T num) {
	return to_string(num).length();
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
		cout << endl;
	}
}

int main() {
	bool debug = false;
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	if (debug) {
		cout << "\x1b[41m" << "Debug Mode このまま提出すると死" << endl;
	}
	try {
		(debug) ? DebugMain() : Main();
	}
	catch (exception& e) {
		cout << e.what() << endl;
	}
	return 0;
}

inline void Main(){
	double X;
	cin >> X;
	int count = 0;
	while (true) {
		X -= 105;
		count++;
		if (X <= 0) {
			if (count * 5 >= -X) {
				cout << 1;
				return;
			}
			else {
				cout << 0;
				return;
			}
		}
	}

}

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

long long N, A, B, C;
bool dp[100009][12][12][12];
string S[1 << 18];

int main() {
	cin >> N >> A >> B >> C;
	for (int i = 1; i <= N; i++) cin >> S[i];

	if (A + B + C >= 10) {
		vector<char> CC;
		for (int i = 1; i <= N; i++) {
			if (S[i] == "AB") { if (A > B) { CC.push_back('B'); A--; B++; } else { CC.push_back('A'); A++; B--; } }
			if (S[i] == "AC") { if (A > C) { CC.push_back('C'); A--; C++; } else { CC.push_back('A'); A++; C--; } }
			if (S[i] == "BC") { if (B > C) { CC.push_back('C'); B--; C++; } else { CC.push_back('B'); B++; C--; } }
			if (A < 0 || B < 0 || C < 0) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		for (int i = 0; i < (int)CC.size(); i++) cout << CC[i] << endl;
	}
	else {
		dp[0][A][B][C] = true;
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j <= A + B + C; j++) {
				for (int k = 0; k <= A + B + C; k++) {
					for (int l = 0; l <= A + B + C; l++) {
						if (dp[i - 1][j][k][l] == false) continue;
						if (S[i] == "AB") {
							int v1 = j, v2 = k, v3 = l;
							if (v2 >= 1) { dp[i][v1 + 1][v2 - 1][v3] = true; }
							if (v1 >= 1) { dp[i][v1 - 1][v2 + 1][v3] = true; }
						}
						if (S[i] == "AC") {
							int v1 = j, v2 = k, v3 = l;
							if (v3 >= 1) { dp[i][v1 + 1][v2][v3 - 1] = true; }
							if (v1 >= 1) { dp[i][v1 - 1][v2][v3 + 1] = true; }
						}
						if (S[i] == "BC") {
							int v1 = j, v2 = k, v3 = l;
							if (v3 >= 1) { dp[i][v1][v2 + 1][v3 - 1] = true; }
							if (v2 >= 1) { dp[i][v1][v2 - 1][v3 + 1] = true; }
						}
					}
				}
			}
		}

		int s1 = 0, s2 = 0, s3 = -1;
		for (int i = 0; i <= A + B + C; i++) {
			for (int j = 0; j <= A + B + C; j++) {
				for (int k = 0; k <= A + B + C; k++) {
					if (dp[N][i][j][k] == true) { s1 = i; s2 = j; s3 = k; }
				}
			}
		}

		if (s1 + s2 + s3 == -1) {
			cout << "No" << endl;
			return 0;
		}

		vector<char>CC;
		for (int i = N; i >= 1; i--) {
			if (S[i] == "AB") {
				if (s2 >= 1 && dp[i - 1][s1 + 1][s2 - 1][s3] == true) { CC.push_back('B'); s1++; s2--; }
				else { CC.push_back('A'); s1--; s2++; }
			}
			if (S[i] == "AC") {
				if (s3 >= 1 && dp[i - 1][s1 + 1][s2][s3 - 1] == true) { CC.push_back('C'); s1++; s3--; }
				else { CC.push_back('A'); s1--; s3++; }
			}
			if (S[i] == "BC") {
				if (s3 >= 1 && dp[i - 1][s1][s2 + 1][s3 - 1] == true) { CC.push_back('C'); s2++; s3--; }
				else { CC.push_back('B'); s2--; s3++; }
			}
		}
		reverse(CC.begin(), CC.end());

		cout << "Yes" << endl;
		for (int i = 0; i < N; i++) cout << CC[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 180688
import sys
from operator import itemgetter
input = sys.stdin.readline
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
c=[[] for i in range(n)]
d=[]
for i in range(n-1):
  c[l[i][0]-1].append(l[i][1]-1)
  c[l[i][1]-1].append(l[i][0]-1)
for i in range(n):
  d.append(len(c[i]))
print(max(d))
dmax=d.index(max(d))

def bfs(v):
  child=[[] for i in range(n)]
  next=[v]
  next2=set()
  visited=[-1]*n
  visitct=0
  colorL=[set() for i in range(n)]
  while len(next)!=0 and visitct!=n:
    for i in range(len(next)):
      if visited[next[i]]==-1:
        visited[next[i]]=1
        visitct+=1
        color=0
        for j in range(len(c[next[i]])):
          if visited[c[next[i]][j]]==-1:
            color+=1
            while color in colorL[next[i]]:
              color+=1
            child[next[i]].append((c[next[i]][j],color))
            next2.add(c[next[i]][j])
            colorL[c[next[i]][j]].add(color)
    next=list(next2)
    next2=set()
  return child

bfs=bfs(dmax)
ans={}
for i in range(n):
  for j in range(len(bfs[i])):
    ans[min(bfs[i][j][0],i)+1,max(bfs[i][j][0],i)+1]=bfs[i][j][1]

for i in range(n-1):
  print(ans[l[i][0],l[i][1]])

Measured memory_bytes: 123740
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};
// ll pas[5001][5002];
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll use[10] = {INF, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10002];

int main() {
	IOS();
	ll n, m;
	cin >> n >> m;
	for (int i = 0; i <= n; ++i) { dp[i] = "0"; }
	dp[0] = "1";
	vector<ll> a(m);
	for (int i = 0; i < m; ++i) { cin >> a[i]; }
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (i >= use[a[j]] && dp[i - use[a[j]]] != "0") {
				char x = a[j] + '0';
				string tmp;
				for (int k = 0; k < dp[i - use[a[j]]].size(); ++k) {
					if (dp[i - use[a[j]]][k] <= x) {
						tmp = x + dp[i - use[a[j]]].substr(0, k);
						tmp += dp[i - use[a[j]]].substr(k, n - k - 1);
						break;
					}
				}

				if (dp[i].size() < tmp.size()) {
					dp[i] = tmp;
				} else if (dp[i].size() == tmp.size()) {
					dp[i] = max(dp[i], tmp);
				}
			}
		}
	}
	string ans = dp[n].substr(0, dp[n].size() - 1);
	dump(ans);
	return 0;
}

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

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

Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n; cin>>n;
	int a[100];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int ans=0;
	for(int i=n-1;i>=0;i-=2){
		ans+=a[i];
	}
	for(int i=n-2;i>=0;i-=2){
		ans-=a[i];
	}
	cout << ans << endl;
}


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int N = 200001 * 4;
struct edge{ int to,cost; };
vector< edge > G[N];

void dikstra(int s,int t){
  typedef pair<int, int> P;
  const int INF = 1 << 30;

  priority_queue<P,vector<P>,greater<P>> que;
  vector<int> d(N,INF); //sからの最短距離
  d[s] = 0;
  que.push({0,s}); //{最短距離,頂点}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }
  if(d[t] == INF) cout << -1 << endl;
  else cout << d[t] << endl;
}

using P = pair<int,int>;

signed main(){

  int n,m; cin >> n >> m;
  vector<int> p(m),q(m),c(m);
  vector<vector<int>> station(n);
  vector<P> v;
  for(int i = 0; i < m; i++){
    cin >> p[i] >> q[i] >> c[i];
    p[i]--,q[i]--,c[i]--;
    station[p[i]].push_back(c[i]);
    station[q[i]].push_back(c[i]);
    v.push_back({p[i],c[i]});
    v.push_back({q[i],c[i]});
  }

  for(int i = 0; i < n; i++){
    v.push_back({i,-1});
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());

  map<pair<int,int>,int> mp;
  for(int i = 0; i < v.size(); i++){
    mp[v[i]] = i;
  }

  for(int i = 0; i < n; i++){
    for(int c : station[i]){
      int u = mp[{i,c}];
      int v = mp[{i,-1}];
      G[v].push_back({u,0});
      G[u].push_back({v,1});
    }
  }

  for(int i = 0; i < m; i++){
    int u = mp[{p[i],c[i]}];
    int v = mp[{q[i],c[i]}];
    G[u].push_back({v,0});
    G[v].push_back({u,0});
  }
  dikstra(mp[{0,-1}],mp[{n-1,-1}]);

  return 0;
}


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

void solve() {
    ll A, B;
    cin >> A >> B;
    if ( (A - B) % 2 != 0 ) {
        cout << "IMPOSSIBLE\n";
    } else {
        cout << (A+B) / 2 << "\n";
    }

}

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

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

int main(void){
    // Your code here!
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<1000;i++){//000~999でsの中に3桁あるか探す
        string sum ="";
        if(i<10){
            sum += "00";
        }else if(i<100){
            sum += "0";
        }
        
        sum += to_string(i);
        
        int cu = 0;
        
        for(int j=0;j<n;j++){
            if(sum[cu] == s[j]){
                cu++;
            }
            if(cu == 3) break;
        }
        
        if(cu == 3) ans++;
    }
    
    
    cout << ans << endl;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
struct Counters {
    int N, all;
    vector<vector<int>> vals;
    vector<int> prev;
    Counters(int n) : N(n), all(0), vals(n, {0}), prev(n) {}
    int get(int idx) {
        return vals[idx].back() + all - prev[idx];
    }
    void add(int idx, int val) {
        vals[idx].back() += val;
    }
    void addall(int val) {
        all += val;
    }
    void push(int idx) {
        vals[idx].back() += all - prev[idx];
        vals[idx].push_back(0);
        prev[idx] = all;
    }
    void pop(int idx) {
        vals[idx].pop_back();
        prev[idx] = all;
    }
};
int main() {
    Int N; cin >> N;
    vector<int> C(N); for (auto &c : C) cin >> c, c--;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<Int> ans(N, N + N * (N - 1) / 2);
    Counters cnt(N);
    auto recur = [&](auto &recur, int node, int prev) -> void {
        int color = C[node];
        cnt.addall(1);
        cnt.add(color, -1);
        for (auto next : G[node]) if (next != prev) {
            cnt.push(color);
            recur(recur, next, node);
            Int t = cnt.get(color);
            ans[color] -= t + t * (t - 1) / 2;
            cnt.pop(color);
        }
    };
    recur(recur, 0, -1);
    for (int color = 0; color < N; color++) {
        Int t = cnt.get(color);
        ans[color] -= t + t * (t - 1) / 2;
        cout << ans[color] << '\n';
    }
    return 0;
}


Measured memory_bytes: 54276
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, M;
    cin >> N >> M;

    if (N * 2 >= M)
    {
        cout << M / 2 << endl;
    }
    else
    {
        cout << N + (M - 2 * N) / 4 << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;

ll N,W,K;
vector<vector <ll> > dp(110, vector<ll> (10, 0));

void add(ll &a, ll b){
    a += b;
    a %= mod;
}

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

    dp[0][0] = 1;

    for(int i = 0;i<=N;i++){
        for(int j = 0;j<=W;j++){

            for(int bit = 0;bit < 1<<(W-1);bit++){
                bool ok = true;
                for(int x=0;x < W-2;x++){
                    if(bit & 1<<x && bit & 1<<(x+1)) ok = false;
                }
                if(!ok) continue;

                ll nj = j;
                if(bit & (1<<j)) nj = j+1;
                else if(j > 0 && bit & 1<<(j-1)) nj = j-1;
                add(dp[i+1][nj], dp[i][j]);
            }
        }
    }

    cout << dp[N][K-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define xx first
#define yy second

double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 2e5+1;



int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){
int n;
cin>>n;
cout<<((n+999)/1000)*1000-n<<"\n";

}
return 0;
}

/*_*/


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n, in;
    cin >> n;
    int co = 0;
    vector<int> a(8);
    rep(i, 8) a.at(i) = 0;
    rep(i, n){
        cin >> in;
        if(in < 400){
            a.at(0) = 1;
        }else if(in < 800){
            a.at(1) = 1;
        }else if(in < 1200){
            a.at(2) = 1;
        }else if(in < 1600){
            a.at(3) = 1;
        }else if(in < 2000){
            a.at(4) = 1;
        }else if(in < 2400){
            a.at(5) = 1;
        }else if(in < 2800){
            a.at(6) = 1;
        }else if(in < 3200){
            a.at(7) = 1;
        }else{
            co++;
        }
    }
    int ans = 0;
    rep(i, 8) ans += a.at(i);
    if(ans == 0 && co != 0){ ans = 1; co--;}
    cout << ans << ' ' << ans + co << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


K = int(input())
A, B = lmi()
for i in range(1001):
    if A <= K * i and K * i <= B:
        print("OK")
        exit()
print("NG")


Measured memory_bytes: 9460
#include<iostream>
#include<string>
#include<sstream>
using namespace std;


int digit( int n ){
    int d = 0;
    while( n != 0 ){
        n /= 10;
        d++;
    }
    return d;
}

int main(){
    string str;
    while (getline(cin, str)) {
        istringstream stream(str);
        int a, b;
        stream >> a >> b;
        cout << digit(a+b) << endl;
    }

    return 0;
}

Measured memory_bytes: 3144
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
const long e9 = 1000000000;

int main() {

	long S; cin >> S;

	long P, Q; P = S % e9; Q = (S - P) / e9;

	long Y1, Y2;

	if (Q == 0) {
		Y2 = 1;
		Y1 = e9 - S;
	}
	else {
		Y1 = e9 - P;
		Y2 = Q + 1;
		if (P == 0) {
			Y1 = 0; Y2--;
		}
	}

	cout << 0 << " " << 0 << " " << e9 << " " << Y1 << " " <<  1 << " " << Y2;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, X, M = map(int, readline().split())
    rem = N

    if X == 0:
        return print(0)

    seq = [0] * 200001
    seq[1] = X
    visited = set()
    visited.add(X)

    cur = X
    cnt = 1

    while cnt < N:
        cur = cur ** 2 % M
        cnt += 1
        if cur in visited:
            break
        elif cur == 0:
            return print(sum(seq))
        else:
            seq[cnt] = cur
            visited.add(cur)
    else:
        return print(sum(seq))

    first = seq.index(cur)
    l = cnt - first

    rem -= first
    p = rem // l
    q = rem % l

    ans = 0
    ans += sum(seq[:first])
    ans += p * sum(seq[first:])

    rem = q
    i = 0
    while i <= rem:
        x = seq[first + i]
        ans += x
        i += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 76380
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 7);
int main(){
  int n;cin>>n;
  vector<int> x(n), y(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
    y[i]=x[i];
  }
  sort(x.begin(), x.end(), greater<int>());
  for(int i=0;i<n;i++){
    if(y[i]!=x[0])cout<<x[0]<<endl;
    else if(x[0]==x[1])cout<<x[0]<<endl;
    else cout<<x[1]<<endl;
  }
}

Measured memory_bytes: 3200
#include <stdio.h>

int main(void) {
  int a, max, i;
  while( 1 ) {
    scanf("%d", &max);
    if(!max) break;
    for(i = 0; i < 9; ++i) {
      scanf("%d", &a);
      max -= a;
    }
    printf("%d\n", max);
  }
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

template<typename T>
T mypow(T a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    T res = mypow(a, n/2);
    return res * res;
  }
  return a * mypow(a, n-1);
}

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

  int n, k;
  cin >> n >> k;
  double ans = 0;
  REP(i,n+1) {
    int cnt = 0;
    int ten = i;
    while(ten < k) {
      cnt++;
      ten *= 2;
    }
    int tmp = mypow(2,cnt) * n;
    ans += (double)1 / (double)tmp;
  }
  printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
map<int, bool> mp;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		int x;
		cin >>x;
		if (mp[x])
		{
			cout <<"NO";
			return 0;
		}
		else mp[x]=1;
	}
	cout <<"YES";
	return 0;
}

Measured memory_bytes: 9600
import sys
input = sys.stdin.readline

def main():
    n, a, b = map(int, input().split())
    s = input()

    c_all = 0
    c_b = 0

    for i in range(n):
        if s[i] == 'c' or c_all >= a+b:
            print('No')
        elif s[i] == 'a':
            c_all += 1
            print('Yes')
        elif s[i] == 'b' and c_b < b:
            c_all += 1
            c_b += 1
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
int euc(int a, int b){
  if(a == 0){
    return b;
  }else if(b == 0){
    return a;
  }
   int m,l,o,p;
  if(a > b){
    m = a;
    l = b;
  }else{
    m = b;
    l = a;
  }
  while(1){
      o = m % l;
      if(o == 0){
        p = l;
        break;
      }
      m = l;
      l = o;
  }
  return p;
}

int loop(int b, int c, vector<int> a,int n){
  int d = euc(a[b],a[c]);
  int e = d;
  int i,j = 0;
  for(i = 0;i<n;i++){
    j = euc(d,a[i]);
    if(j < d){
      e = d;
      d = j;
    }else{
    e = euc(e,a[i]);
    }
  }
  return e;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> l(n);
  vector<int> r(n);
  int i;
  for(i = 0;i < n;i++){
    cin >> a[i];
  }
  l[0] = 0;
  l[1] = a[0];
  r[n-1] = 0;
  r[n-2] = a[n-1];
  for(i = 2;i < n;i++){
    l[i] = euc(l[i-1],a[i-1]);
    r[n-1-i] = euc(r[n-i],a[n-i]);
  }
  int min,x;
  min = euc(l[0],r[0]);
  for(i = 1;i < n;i++){
    x = euc(l[i],r[i]);
    if(x > min ){
      min = x;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 1408
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut list: Vec<Vec<usize>> = vec![vec![0; 2]; n + 1];
    for i in 0..n {
        list[a[i]][0] += 1;
    }
    let mut sum = 0;
    for i in 0..n {
        if list[a[i]][0] > 1 && list[a[i]][1] == 0 {
            sum += list[a[i]][0] * (list[a[i]][0] - 1) / 2;
            list[a[i]][1] = 1;
        }
    }
    for i in 0..n {
        if list[a[i]][0] <= 1 {
            println!("{}", sum);
        } else {
            let tmp = sum - (list[a[i]][0] * (list[a[i]][0] - 1) / 2)
                + ((list[a[i]][0] - 1) * (list[a[i]][0] - 2) / 2);
            println!("{}", tmp);
        }
    }
}


Measured memory_bytes: 16696
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  int X;
  long long ans, tmp;
  cin >> X;
  ans = tmp = 0;
  tmp = X / 500;
  X = X - 500 * tmp;
  ans = (X / 5) * 5;
  ans += 1000 * tmp;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
// dp[x][y] = xth position and y candies, no. of ways
// dp[x][0] = 1

// dp[first][0] = dp[first][1] = ..... dp[first][a[0]] = 1

// dp[x][y] = dp[x-1][y] + dp[x-1][y-1] + dp[x-1][y-2] + ...
 				// ..... + dp[x-1][y-a[x]]
// dp[x-1] -> prefix_sum
// dp[x][y] = prefix_sum[y] - prefix_sum[y-a[x]-1]

// dp[last][k]
#include "bits/stdc++.h"
using namespace std;

const int M = 1e9 + 7;

int dp[100][100005];
int a[100];

int main(){
	int n,k;
	cin>>n>>k;
	for(int i = 0;i < n; i++){
		cin>>a[i];
	}
	
	for(int i = 0; i <= a[0]; i++){
		dp[0][i] = 1;
	}
	
	for(int i = 1; i < n; i++){
		// dp[i]
		vector<int> prefix_sum(k+1);
		prefix_sum[0] = dp[i-1][0];
		for(int j = 1; j < k+1; j++){
			prefix_sum[j] = (prefix_sum[j-1] + dp[i-1][j]) % M;
		}
		for(int j = 0; j < k+1; j++){
			// dp[i][j]
			if(j > a[i])
				dp[i][j] = (prefix_sum[j] + M - prefix_sum[j-a[i]-1]) % M;
			else
				dp[i][j] = prefix_sum[j];
		}
		
	}
	cout << dp[n-1][k];
}

Measured memory_bytes: 42956
h,w,k = map(int,input().split())
c = [list(input()) for i in range(h)]
ans = 0
for i in range(2**h):
    h_list = [False] * h
    for j in range(h):
        if (i >> j) & 1:
            h_list[h - 1 - j] = True
    
    for l in range(2**w):
        w_list = [False] * w
        for m in range(w):
            if (l >> m) & 1:
                w_list[w - 1 - m] = True

        cnt = 0
        for a in range(h):
            for b in range(w):
                if c[a][b] == '#' and not h_list[a] and not w_list[b]:
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

bool ok_ng(int x,int m,int n){
    
    rep(p,0,x){
        rep(q,0,x){

            if(p*m+q*n==x){
                return true;
            }

        }
    }
    
    return false;

}

int main(){
    
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    
    double max=0;
    int anss=0,ans=0;
    
    rep(i,a,f/100){
    
        if(ok_ng(i,a,b)){
        
            rep(j,0,e*i){
            
                if(ok_ng(j,c,d)){
                
                    double c;
                    c = (static_cast<double>(j)*100)/static_cast<double>(100*i+j);
                    ans = (max<=c&&100*i+j<=f?100*i+j:ans);
                    anss = (max<=c&&100*i+j<=f?j:anss);
                    max = (max<=c&&100*i+j<=f?c:max);
                
                }else{
                
                    continue;
                
                }
            }
        }else{
            
            continue;
        
        }
    }
    
    
    cout << ans << ' ' << anss << endl;
    return 0;
}


Measured memory_bytes: 256