akhauriyash/Code-Regression huggingface dataset:
use std::io::{BufRead, Write};
use std::io;
use std::cmp;
use std::collections::HashMap;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let n = split.next().unwrap().parse::<u64>().unwrap();
    let w = split.next().unwrap().parse::<u64>().unwrap();
    let wv = (0..n)
        .map(|_| {
                 let mut s = String::new();
                 input.read_line(&mut s).unwrap();
                 let mut split = s.split_whitespace();
                 let w = split.next().unwrap().parse::<u64>().unwrap();
                 let v = split.next().unwrap().parse::<u64>().unwrap();
                 (w, v)
             })
        .collect::<Vec<_>>();
    let mut cache = HashMap::<(u64, u64), u64>::new();
    fn dp(i: u64, j: u64, cache: &mut HashMap<(u64, u64), u64>, wv: &[(u64, u64)]) -> u64 {
        if i == 0 {
            0
        } else {
            if let Some(&hit) = cache.get(&(i, j)) {
                hit
            } else {
                let val = cmp::max(dp(i - 1, j, cache, wv),
                                   if wv[i as usize - 1].0 <= j {
                                       dp(i - 1, j - wv[i as usize - 1].0, cache, wv) +
                                       wv[i as usize - 1].1
                                   } else {
                                       0
                                   });
                cache.insert((i, j), val);
                val
            }
        }
    }
    writeln!(output, "{}", dp(n, w, &mut cache, &wv)).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("4 6
2 1
3 4
4 10
3 4\n",
             "11\n");
    }
    #[test]
    fn case2() {
        test("4 6
2 1
3 7
4 10
3 6\n",
             "13\n");
    }
    #[test]
    fn case3() {
        test("4 10
1 100
1 100
1 100
1 100\n",
             "400\n");
    }
    #[test]
    fn case4() {
        test("4 1
10 100
10 100
10 100
10 100\n",
             "0\n");
    }
}



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

int main(){

	int num,c=0;
	double w,h;

	while(~scanf("%d,%lf,%lf\n", &num, &w, &h)){
		if(25<=w/(h*h)){
			cout << num << endl;
			c++;
		}
	}

	if(c==0){
		cout << "ツ該ツ督鳴づ按つオ" << endl;
	}

	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 1;
  
  for (int i =0; i<N; i++) {
    if (sum * 2 < sum + K) {
          sum *= 2;
    } else {
      sum += K;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    vector<i_i>v;
    v.pb(i_i(0,-1));
    ll max=0;
    rep(i,0,n-1){
        if(max<a[i]){
            max=a[i];
            v.pb(i_i(a[i],i));
        }
    }
    ll ans[n];memset(ans,0,sizeof(ans));
    sort(a,a+n);
    ll t=n-1,vlen=v.size();
    for(int vpos=vlen-1;vpos>=1;vpos--){
        ans[v[vpos].second]=(n-t-1)*(v[vpos].first-v[vpos-1].first);
        while(t>=0){
            if(a[t]<v[vpos-1].first)break;
            ans[v[vpos].second]+=(a[t]-v[vpos-1].first);
            t--;
        }
    }
    /*rep(i,0,n-1){
        ans[v[0].second]+=min(v[0].first,a[i]);
    }*/
    rep(i,0,n-1){
        cout<<ans[i]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int a,b,c;
     cin>>a>>b>>c;
     int res=c%b;
     long long sum=0;
     for(int i=1;i<=1000;i++){
          sum=a*i;

          if(sum%b==res){
               cout<<"YES"<<endl;
               return 0;
          }
     }
     cout<<"NO"<<endl;
     return 0;



}


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

int n, k, x, y;
long long fee;
int main() {
    cin >> n >> k >> x >> y;
    
    if (n > k) {
        fee += k * x;
        fee += (n - k) * y;
    } else
        fee += n * x;
    
    cout << fee;
    
    
    return 0;
}




Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int n = Cin.Ni();
        string s = Cin.Next();
        int count = 0;
        int max = 0;

        for (int i = 0; i < n; i++) {
            if (s[i] == 'I') {
                count++;
            } else {
                count--;
            }
            max = Math.Max(count, max);
        }
        Console.WriteLine(max);
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 2648
#include <cstdio>
const int MAXN = 1E5+5;
int graph[MAXN]{ };
int Ans=0, N;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i)
		scanf("%d", &graph[i]);
	for(int i = 1; i <= N; ++i)
	{
		int& nxt = graph[graph[i]];
		if(nxt == i) ++Ans;
	}
	printf("%d\n", Ans >> 1);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    map<ll,int> mli;
    rep(i,n){
        ll x;
        cin >> x;
        mli[x]++;
    }
    vector<pair<ll,int>> v;
    for(auto u : mli){
        v.push_back({u.first,u.second});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    ll ans = 1;
    bool one = 0;
    for(auto u : v){
        if(u.second>=2){
            if(u.second>=4){
                if(one) cout << ans*u.first << endl;
                else cout << u.first*u.first << endl;
                return 0;
            }
            else{
                if(one) {
                    cout << ans*u.first << endl;
                    return 0;
                }
                else ans *= u.first;
            }
            one = 1;
        }
    }
    cout << 0 << endl; 
    return 0;
}

Measured memory_bytes: 8696
#include <stdio.h>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int n, R[MAX];
    
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", &R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for (int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n", maxv);
    
    return 0;
}


Measured memory_bytes: 3380
N = int(input())
A = list(map(int, input().split()))

money = 1000
stock = 0

for i in range(N-1):
    if stock:
        if A[i] > A[i + 1]:
            money += stock * A[i]
            stock = 0
    else:
        if A[i] < A[i + 1]:
            stock, money = divmod(money, A[i])

print(money + stock * A[i+1])


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli dp[10009][102][2];
lli calc(string& s, lli index, lli sum, lli e, lli d){
    lli n = s.size();
    if(sum % d == 0 && index == n)
        return 1;
    else if(index >= n)
        return 0;
    else if(dp[index][sum][e] != -1)
        return dp[index][sum][e];
    lli ans = 0;
    lli m = e == 0 ? 10 : s[index]-'0'+1;
    loop(i, 0, m){
        lli ne = e & ((s[index]-'0') == i);
        lli temp = sum;
        temp += i;
        temp %= d;
        ans += calc(s, index+1, temp, ne, d);
        ans %= M;
    }
    dp[index][sum][e] = ans;
    return ans;
}
lli solve(){
    string k;
    lli d;
    cin>>k>>d;
    memset(dp, -1, sizeof(dp));
    cout<<(calc(k, 0, 0, 1, d) - 1 + M)%M;
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 20552
#include<bits/stdc++.h>
#define MX 200005
using namespace std;
vector<int>adj[MX];
int vis[MX];
int dfs(int u){
  int ret=1;
  vis[u]=1;
  for(int v:adj[u])
    if(!vis[v])ret+=dfs(v);
  return ret;
}
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int u,v;
    cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int mx=1;
  for(int i=1;i<=n;i++)
    if(!vis[i])
      mx=max(mx,dfs(i));
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 24708
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,d;
  cin >> A >> B >> d;
  int x=0,X=A;
  for(int i=0;i<B-A+1;i++){
    if(X%d==0){
      x++;
    }
    X++;
  }
  cout << x << endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
int a,b,c;
int temp;
scanf("%d %d %d",&a,&b,&c);

if(a>b){
temp=a;
a=b;
b=temp;
}
if(b>c){
temp=c;
c=b;
b=temp;
}
if(a>b){
temp=a;
a=b;
b=temp;
}
printf("%d %d %d\n",a,b,c);
return 0;
}


Measured memory_bytes: 2760
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define sz(x) (int) x.size()
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<str> vstr;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

//

int32_t main() {
  FAST_IO;
  int a, b, n;
  cin >> a >> b >> n;
  int x = min(b - 1, n);
  cout << (a * x) / b;
  rtn 0;
}


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

int main(){
	string a;
	cin>>a;
	int b[101];
	memset(b,0,sizeof(b));
	for(int i=0;i<4;i++){
		int c = a[i]-'0';
		//cout<<c<<endl;
		b[c]++;
	}
	int cnt = 0;
	for(int i=0;i<101;i++){
		if(b[i]==2)cnt++;
	}
	if(cnt==2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
n, m = map(int, input().split())

if abs(n-m)>1:
    print(0)
    exit()

def factorial(k):
    mod = 10**9+7
    ret = 1
    for i in range(1,k+1):
        ret = (ret * (i%mod))%mod
    return ret

if abs(n-m)==1:
    ans =  (factorial(n)*factorial(m))%(10**9+7)
else:
    ans = (factorial(n)*factorial(m)*2)%(10**9+7)

print(ans)

Measured memory_bytes: 3064
/*
  #問題：



  #分析：
  #オブジェクト：

  #条件：


  #要求：


  #解法：

*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#include <bitset>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define fst first
#define snd second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int bf0 = (1<<0);
const unsigned int bf1 = (1<<1);
const unsigned int bf2 = (1<<2);
const unsigned int bf3 = (1<<3);
const unsigned int bf4 = (1<<4);
const unsigned int bf5 = (1<<5);
const unsigned int bf6 = (1<<6);
const unsigned int bf7 = (1<<7);


//#include <boost/format.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
namespace bm = boost::math;

int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}

int main(void){
  int n; cin>>n;
  int a,b,c; cin>>a>>b>>c;
  vector<int> l(n);
  FOR(i,0,n){
    cin >> l[i];
  }

  int cnt_min=INT_MAX;
  for (int bit=0; bit < (1<<(2*n)); ++bit) { // bitは組み合わせ．ここは組み合わせループ．
    int da=0,db=0,dc=0;
    int cnt=0;
    // cerr << bitset<14>(bit) << endl;
    for (int i = 0; i < 2*n; i+=2) { // iは竹．ここは竹ループ．
      if (         (bit & ((0b11)<<i) )  == ( (0b11)<<i )        ) {
        dc += l[i/2];
        cnt+=10;
      }
      else if ( (bit & ((0b10)<<i) ) == ( (0b10) << i ) ) {
        db += l[i/2];
        cnt+=10;
      }
      else if ( ( bit & ( (0b01) << i ) ) == ( (0b01) << i ) ) {
        da += l[i/2];
        cnt+=10;
      }
    }
    if (da==0|db==0|dc==0) {continue;}
    // cerr << "da " << "db " << "dc :" << da<<" " << db <<" " << dc << endl;
    cnt+=abs(a-da)+abs(b-db)+abs(c-dc)-30;
    // cerr << "cnt: " <<cnt<< endl;
    if (cnt<cnt_min) {cnt_min=cnt;}
    // cerr << "cnt_min: " <<cnt_min<<endl;
  }
  cout << cnt_min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct edge { int to, cost; };

vector<vector<edge> >G;


typedef pair<int, int> P;
VI d;
int N;
void dikstra(int s) {
	priority_queue<P, vector<P>, greater<P> >que;
	REP(i, N)d[i] = INF;
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		REP(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void chokkei(int *s, int *g) {
	dikstra(0);
	int ma = -1;
	REP(i, N) {
		if (ma < d[i]) {
			*s = i;
			ma = d[i];
		}
	}
	dikstra(*s);
	ma = -1;
	REP(i, N) {
		if (ma < d[i]) {
			*g = i;
			ma = d[i];
		}
	}
}

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

	cin >> N;
	G.resize(N);
	d.resize(N);
	REP(i, N - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back((edge) { b, 1 });
		G[b].push_back((edge) { a, 1 });
	}
	int s, g;
	chokkei(&s,&g);
	//cout << d[g] << endl;
	if (d[g] % 3 == 1)cout << "Second" << endl;
	else cout << "First" << endl;
	

	return 0;
}



Measured memory_bytes: 23092
import qualified Text.Printf as Text

newtype Count = Count { getCount :: (Int, Int, Int, Int) }

instance Show Count where
  show c = Text.printf "AC x %d\nWA x %d\nTLE x %d\nRE x %d" ac wa tle re
    where
      (ac, wa, tle, re) = getCount c

count :: [String] -> Count
count xs = Count $ classify xs (0, 0, 0, 0)
  where
    classify (x:xs) (ac, wa, tle, re)
      | x == "AC" = classify xs (ac + 1, wa, tle, re)
      | x == "WA" = classify xs (ac, wa + 1, tle, re)
      | x == "TLE" = classify xs (ac, wa, tle + 1, re)
      | x == "RE" = classify xs (ac, wa, tle, re + 1)
      | otherwise = error $ "Invalid input. " ++ x
    classify [] result = result

main :: IO ()
main = readLn >>= getInput >>= print . count
  where
    getInput n = sequence $ replicate n getLine

Measured memory_bytes: 32488
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i, n) cin >> s[i];

  int score1 = 0;
  rep(i, n) {
    score1 += s[i];
  }

  sort(s.begin(), s.end());
  int score2 = score1;
  rep(i, n) {
    if(s[i] % 10 != 0) {
      score2 -= s[i];
      break;
    }
  }

  score1 = (score1 % 10 == 0 ? 0 : score1);
  score2 = (score2 % 10 == 0 ? 0 : score2);
  cout << max(score1, score2) << endl;

  return 0;
}

Measured memory_bytes: 256
n,x,y=map(int,input().split())
dis=[0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    d=j-i
    if d>abs(j-x)+1+abs(i-y):
      d=abs(j-x)+1+abs(i-y)
    if d>abs(j-y)+1+abs(i-x):
      d=abs(j-y)+1+abs(i-x)
    dis[d-1]+=1
for i in dis:
  print(i)

Measured memory_bytes: 3444
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "limits.h"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
using namespace std;

int n, y;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int main(){
	cin >> n >> y;
	lp(n + 1) {
		lop(n + 1 - i, j) {
			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y) {
				cout << i << sp << j << sp << n - i - j << endl;
				return 0;
			}
		}
	}
	cout << -1 << sp << -1 << sp << -1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <random>
#include <typeinfo>
#include <type_traits>

using namespace std;

template <typename T>	constexpr T	rep_start(const T &end)			{ return 0; }
template <typename T>	constexpr T	rep_start(const T &start, const T &end)	{ return start; }
template <typename T>	constexpr T	rep_end(const T &end)				{ return end; }
template <typename T>	constexpr T	rep_end(const T &start, const T &end)		{ return end; }

#define rep(index, ...) for (auto index = rep_start(__VA_ARGS__); index < rep_end(__VA_ARGS__); ++index)
#define irep(index, ...) for (auto index = rep_end(__VA_ARGS__) - 1; index >= rep_start(__VA_ARGS__); --index)

using llong = long long;
using ullong = unsigned long long;

int main ()
{
	int AB, BC, CA;
	cin >> AB >> BC >> CA;

	cout << AB * BC / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
input=stdin.readline
a=1
ok=0
n=int(input())
ar=list(map(int,input().strip().split()))
ar.sort()
for i in ar:
    a*=i
    if(i==0):
        ok=1
        print(0)
        break
    if(a>1000000000000000000):
        ok=1
        print(-1)
        break
    # print(i)
if(ok==0):
    print(a)

Measured memory_bytes: 21652
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200005;
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=-1,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
int n,Len,T;
int x[N],w[N],res[N];
vector <int> v1,v2;
int s1,s2;
bool check(int x){
	int L,R;
	if (!w[0])
		L=(x-1)>>1,R=x>>1;
	else
		L=x>>1,R=(x-1)>>1;
	LL tot=1LL*(L/s1)*Len+v1[L%s1]
		  +1LL*(R/s2)*Len+v2[R%s2];
//printf("check %d : L = %d , R = %d , tot = %lld\n",x,L,R,tot);
	return tot<=(T<<1);
}
int main(){
	n=read(),Len=read(),T=read();
	v1.clear();
	v2.clear();
	for (int i=0;i<n;i++){
		x[i]=read(),w[i]=read()&1;
		if (w[i])
			res[i]=(x[i]+T)%Len;
		else
			res[i]=((x[i]-T)%Len+Len)%Len;
		if (!w[i])
			v2.push_back(x[i]-x[0]);
		else
			v1.push_back((x[0]-x[i]+Len)%Len);
	}
	if (v1.empty()||v2.empty()){
		for (int i=0;i<n;i++)
			printf("%d\n",res[i]);
		return 0;
	}
	sort(res,res+n);
	sort(v1.begin(),v1.end());
//for (auto y : v1)printf("%d ",y);puts("");
//for (auto y : v2)printf("%d ",y);puts("");
	s1=v1.size(),s2=v2.size();
	int L=1,R=T<<1,ans=0;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid))
			L=mid+1,ans=mid;
		else
			R=mid-1;
	}
//printf("%d\n",ans);
	int p0;
	if (ans==0)
		p0=w[0]?(x[0]+T)%Len:(x[0]+Len-T)%Len;
	else {
		if (!w[0])
			L=(ans-1)>>1,R=ans>>1;
		else
			L=ans>>1,R=(ans-1)>>1;
//printf("L = %d , R = %d\n",L,R);
		int tot=L/s1*Len+v1[L%s1]+R/s2*Len+v2[R%s2];
//printf("%d\n",tot);
		T=(T<<1)-tot;
		LL p=(R/s2*Len+v2[R%s2])-(L/s1*Len+v1[L%s1]);
//printf("T' = %d , p = %lld\n",T,p);
		if (w[0]^(ans&1))
			p+=T;
		else
			p-=T;
//printf("pp = %lld\n",p);
		p/=2;
		p0=((p+x[0])%Len+Len)%Len;
	}
//printf("%d\n\n",p0);
	int p=lower_bound(res,res+n,p0)-res;
	if (w[0]^(ans&1)){
		if (n>2&&res[(p+1)%n]==res[p])
			p++;
	}
	else
		if (n>2&&res[(p+n-1)%n]==res[p])
			p--;
	for (int i=0;i<n;i++)
		printf("%d\n",res[(p+i)%n]);
	return 0;
}
/*
3 10 7
2 1
3 1
7 2

Time 
0	2 3 7
1	3 4 6
2	4 5 5 
3	4 5 6 1
4	3 6 7 
5	2 7 8
6	1 8 9
7	0 9 0 2
*/




Measured memory_bytes: 2892
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;

using namespace std;

int main(void)
{
	int A, B, C;

	cin >> A >> B >> C;

	cout << min(B / A, C) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
int N,Q;
bool t[MAX_N];
bool u[MAX_N];

int main(){
  cin>>N>>Q;
  
  t[1]=true;
  u[1]=u[2]=true;
  for(int i=0;i<Q;i++){
    int a,b;
    cin>>a>>b;

    if(t[a-1]||t[a+1]){
      u[b]=true;
    }
    if(t[b-1]||t[b+1]){
      u[a]=true;
    }
    
    swap(t[a],t[b]);
    swap(u[a],u[b]);
    if(t[a])u[a-1]=u[a]=u[a+1]=true;
    if(t[b])u[b-1]=u[b]=u[b+1]=true;
  }

  int ans=0;
  for(int i=1;i<=N;i++){
    if(u[i]){
      ans++;
      //      cout<<i<<endl;
    }
    
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <cmath>
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

int main() {
    double N,M;
    cin >> N >>M ;
    vector<int> vec(N);
    double summ =0 ;
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
        summ+=vec.at(i);
    }
    sort(vec.begin(), vec.end());
    if(vec.at(N  - M) < summ / (4 * M)) {
        cout << "No"<<endl;

    }
    else {
        cout << "Yes"<< endl;
    }
}

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

int main(){
    int n;
    long long ai,sum,max,min;
    cin >> n;
    
    sum = 0;
    max = -10000000;
    min = 10000000;
    
    for ( int i =1; i<=n ; i++){
        cin >> ai;
        
        if(ai > max){
            max = ai;
        }else{
            max = max;
        }
        
        
        if(ai < min){
            min = ai;
        }else{
            min = min;
        }
        
        sum = sum + ai;
    }
    
    cout << min << " " << max <<" " << sum <<endl;
    
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;

map<ll, int> cnt;
priority_queue<ll> que;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    ll tmp;
    scanf("%lld", &tmp);

    cnt[tmp] += 1;
  }

  for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
    if (itr->second > 1) {
      for (int i = 0; i < itr->second / 2; ++i) {
        que.push(itr->first);
      }
    }
  }

  if (que.empty()) {
    printf("%lld\n", 0);
    return 0;
  }

  ll first = que.top();
  que.pop();

  if (que.empty()) {
    printf("%lld\n", 0);
    return 0;
  }

  ll second = que.top();
  que.pop();

  printf("%lld\n", first * second);

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
const int inf=1e9;
int main() {
  
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
    	string s,ans;cin>>s;
    	ans="Yes";
    	int n=sz(s);
    	rep(i,n){
    		if(s[i]!=s[n-1-i]){
    			ans="No";
    		}
    	}
    	int k=(n-1)/2;
    	rep(i,(k)){
    		if(s[i]!=s[k-1-i]){
    			ans="No";
    		}
    	}
    	for(int i=(n+3)/2-1;i<n;i++){
    		if(s[i]!=s[n-1-i]){
    			ans="No";
    		}
    	}
    	cout<<ans;
    }   
    return 0;   
}   	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
using namespace std; 

typedef long long ll; 
typedef unsigned long long ull;
typedef unsigned uint; 
typedef long double l_double;

#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define st_ct static_cast // <>
#define TEST uint _ {}; cin >> _; while (_--)
#define PI (3.1415926535897932384626433832795)
#define MOD st_ct<int>(1e9 + 7)
#define EPS 1e-9
#define deb(x) cout<< #x << " --> " << x << endl;

template<typename T>
void vtrS(const vector<T> &ARR) 
{ for (T const &val: ARR) cout<<val<<" "; cout<<endl; }

template<typename T>
void vtrV(const vector<T> &ARR) 
{ for (T const &val: ARR) cout<<val<<endl; }

template<typename T>
void read_vvtr(vector<vector<T>> &ARR) 
{ for (vector<T> &i: ARR) for (T &j: i) cin >> j; }

template<typename T>
void vvtrS(const vector<vector<T>> &ARR) 
{ for (vector<T> const &i: ARR) { for (T const &j: i) cout<<j<<" "; cout<<endl; } }

template<typename T>
void vvtrNS(const vector<vector<T>> &ARR) 
{ for (vector<T> const &i: ARR) { for (T const &j: i) cout<<j; cout<<endl; } }

template<typename T>
T cntDigits(const T &N) { return (floor(log10(N)) + 1); }

template<typename T>
bool isPowOfTwo(const T &N) { return (N && (!(N&(N-1)))); }

template<typename T>
T lcm(T a, T b) { return ((a*b)/gcd(a, b)); }
// --------------------------------------------------------------------------------

//

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout.setf(std::ios::boolalpha);
    cout<<std::fixed<<std::setprecision(20); 
    // --------------------------------------
    
    double r {};
    cin >> r;
    cout<<(2 * PI) * r<<endl;
    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

// セグメント木　学習中
template <class T>
class SegmentTree {
	int n;	// 葉の数
	vector<T> data;	// データを格納するvector
	T def;	// 初期値かつ単位元
	function<T(T, T)> operation; // 区間クエリで使う処理
	function<T(T, T)> update;	// 点更新で使う処理

	// 区間[a,b)の総和。ノードk=[l,r)に着目している。
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def; // 交差しない
		if (a <= l && r <= b)
			return data[k]; // a,l,r,bの順で完全に含まれる
		else {
			return operation(_query(a, b, 2 * k + 1, l, (l + r) / 2), _query(a, b, 2 * k + 2, (l + r) / 2, r));	//左右を分割して再帰
		}
	}

public:
	// _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
	// _update:更新関数
	SegmentTree(size_t _n, T _def, function<T(T, T)> _operation,
		function<T(T, T)> _update)
		: def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}

	// 場所i(0-indexed)の値をxで更新
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	// [a, b)の区間クエリを実行
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}

	// 添字でアクセス
	T operator[](int i) {
		return data[i + n - 1];
	}
};

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N, X, T;
	cin >> N >> X >> T;

	ll cnt = N / X;
	if (N % X > 0) {
		cnt++;
	}
	cout << cnt * T << endl;
	return 0;
}


Measured memory_bytes: 3588
def mark(n):
    for i in range(n):
        num = int(input())
        if num in A:
            A[A.index(num)]=0

def tate():
    for i in range(3):
        if A[i]==A[i+3] and A[i]==A[i+6]:
            return 1
    return 0

def yoko():
    for i in range(0,7,3):
        if A[i]==A[i+1] and A[i]==A[i+2]:
            return 1
    return 0

def naname():
    if A[4]==A[0] and A[4]==A[8]:
        return 1
    elif A[4]==A[2] and A[4]==A[6]:
        return 1
    else:
        return 0

a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
A=a1+a2+a3
n = int(input())
mark(n)
if tate()+yoko()+naname()>0:
    print("Yes")
else:
    print("No")

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 341;
int MOD;

int n, k;

int C[MAX][MAX];

int add(int a, int b) {
	return (a + b) % MOD;
}

int mult(int a, int b) {
	return (ll) a * b % MOD;
}

void init() {
	fi(0, MAX - 1) {
		C[i][0] = 1;
		fj(1, i) {
			C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
		}
	}
}

int d[MAX][MAX];
int d1[MAX][MAX];

int rec(int x, int r);
int rec1(int x, int r);

int rec1(int x, int r) {
	if (x > k) return 0;
	if (d1[x][r] != -1) return d1[x][r];
	int res = 0;
	res = add(res, rec1(x + 1, r));
	res = add(res, rec(x, r));
	d1[x][r] = res;
	return res;
}

int rec(int x, int r) {
	if (r == 0) return 1;
	if (d[x][r] != -1) {
		return d[x][r];
	}
	int res = 0;
	fi(0, r - 1) {
		int v1 = C[r - 1][i];
		int v2 = rec(x, r - i - 1);
		int v3 = rec1(x + 1, i);
		int v = mult(v1, mult(v2, v3));
		res = add(res, v);				
	}
	d[x][r] = res;
	return res;
}

int ans;

void solve() {
	memset(d, 255, sizeof(d));
	memset(d1, 255, sizeof(d1));	
	ans = rec(0, n);
	printf("%d\n", ans);		
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d %d %d", &n, &k, &MOD);  
	init();
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N, K; std::cin >> N >> K;
  std::vector<int> A(N);

  int k = 0;
  for(int i=0; i<N; i++) {
    std::cin >> A[i];
    if ( A[i] == 1 ) k = i;
  }
  std::cout << std::ceil((float)(N-1)/(K-1)) << std::endl;
  return 0;
}


Measured memory_bytes: 640
from functools import reduce
from operator import mul


def end_of_loop():
    raise StopIteration


def main():
    N, K = map(int, input().split())
    print(sum(reduce(mul, (0.5
                           if i << j < K
                           else end_of_loop()
                           for j in range(len(bin(K)) - 2)), 1 / N)
              for i in range(1, N + 1)))
    return


main()


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    pair<int,int> A[200000];
    for(int i=0; i<N; i++){
        cin >> A[i].first;
        A[i].second=i;
    }
    sort(A,A+N);
    
    int ans[200000];
  
    for(int i=0; i<N; i++){
        ans[i]=A[N-1].first;
    }
    ans[A[N-1].second]=A[N-2].first;
    for(int i=0; i<N; i++){
        cout<<ans[i]<<endl;
    }
    
    
    return 0;
}



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

using namespace std;

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

  cout << "Christmas";
  int diff = 25 - d;

  for (int i = 0 ;i < diff; i ++) {
    cout << " Eve";
  }
  cout << "\n";
	return 0;
}


Measured memory_bytes: 256
def main():
    a, b, c, d = map(int, input().split())

    while a > 0 and c > 0:
        c -= b
        if c <= 0:
            print('Yes')
            return
        a -= d
        if a <= 0:
            print('No')
            return


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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


int main() {
    ll n;
    cin >> n;
	ll m = n;
    vector<pair<ll, int>> fs;
    for (ll i = 2; i*i <= m; i++) {
        int x = 0;
        while (n%i == 0) {
            n /= i;
            x++;
        }
        
        fs.emplace_back(i, x);
    }
    if (n != 1) fs.emplace_back(n, 1);

    int ans = 0;
    for (auto p : fs) {
        int x = p.second;
        int b = 1;
        while (b <= x) {
            x -= b;
            b++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


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

	sort(d.begin(), d.end());

	cout << d[n / 2] - d[n / 2 - 1] << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			A[i] = a - (i + 1);
		}

		Arrays.sort(A);

		int median = (N - 1) / 2;
		long answer = 0;

		for (int i = 0; i < N; i++) {
			answer += (long)Math.abs(A[i] - A[median]);
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 66092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int x, y, z, k;
	cin >> x >> y >> z >> k;
	V<ll> a(x), b(y), c(z);
	rep(i, x)cin >> a[i];sort(all(a), greater<ll>());
	rep(i, y)cin >> b[i];sort(all(b), greater<ll>());
	rep(i, z)cin >> c[i];sort(all(c), greater<ll>());
	
	priority_queue<ll, V<ll>, less<ll>> pq;
	rep(i, x)rep(j, y)rep(l, z){
		if ((i + 1) * (j + 1) * (l + 1) > k)break;
		pq.push(a[i] + b[j] + c[l]);
	}
	
	rep(i, k) {
		cout << pq.top() << endl;
		pq.pop();
	}

}

Measured memory_bytes: 4308
H,W,K = map(int,input().split())
masu_list = []
ans = 0
for i in range(H):
    masu_list.append(input())
    
for tate in range(2**H):
    for yoko in range(2**W):
        black = 0
        for i in range(H):
            for j in range(W):
                if format(tate>>i,"b")[-1] == "0" and format(yoko>>j,"b")[-1] == "0" and masu_list[i][j] == "#":
                    black += 1
        if black == K:
            ans += 1
print(ans)

Measured memory_bytes: 9204
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>




int main() {
	int n, k, c; std::cin >> n >> k >> c;
	std::string str; std::cin >> str;
	std::vector<int> max_prev(n + c + 1, 0), max_next(n + c + 1, 0);
	for (auto i = 0; i < n; ++i) {
		if (i > 0) max_prev[i] = std::max(max_prev[i], max_prev[i - 1]);
		if (str[i] == 'o') {
			max_prev[i + c + 1] = std::max(max_prev[i + c + 1], max_prev[i] + 1);
		}
	}
	for (int i = n - 1; i >= 0; --i) {
		max_next[i] = std::max(max_next[i], max_next[i + 1]);
		if (str[i] == 'o') {
			max_next[i] = std::max(max_next[i], max_next[i + c + 1] + 1);
		}
	}
	std::vector<int> result;
	std::deque<int> deque;
	for (auto i = 0; i < n; ++i) {
		while (!deque.empty() && deque.front() + c < i) deque.pop_front();
		if (str[i] == 'o') {
			if (max_prev[i] + max_next[i + 1] < k && deque.empty()) 
				result.push_back(i);
			const auto current = max_prev[i] + max_next[i];
			if (current >= k) 
				deque.push_back(i);
		}
	}
	for (const auto d : result) std::cout << d + 1 << '\n';
}


Measured memory_bytes: 4340
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  int N;
  IN(N);
  vector<ll> X(N);
  REP(i,N) IN(X[i]);
  int ans=0;
  int i=-1;
  while(1){
    ++i;
  	int cnt=0;
    while(X[i] >= X[i+1]){
      ++i;
      ++cnt;
      if(i >= N-1){
        break;
      }
    }
//    OUT(cnt);
    if(cnt>ans) ans=cnt;
    if(ans>N-i) break;
    if(i >=N-2) break;
  }
  if(N==1) ans=0;
  OUT(ans);
}

Measured memory_bytes: 1152