akhauriyash/Code-Regression huggingface dataset:
memo={}
def primes(n):
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            if d in memo:
                memo[d]+=1
            else:
                memo[d]=1
            n //= d
        d += 1
    if n > 1:
        if n in memo:
            memo[n]+=1
        else:
            memo[n]=1
    return None
n=int(input())
for i in range(1,n+1):
    primes(i)
ans=1
for i in memo.items():
    ans*=i[1]+1
print(ans%(10**9+7))

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	int n,k;
	int a[1000];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<k;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if(w>=v) cout<<"NO";
    else if(abs(b-a)<=(v-w)*t) cout<<"YES";
    else cout<<"NO";
    return 0;   
}




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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	string s;
	cin >> s;
	for (int i = b-1; i < d-1; i++) {
		if (s[i] == '#' && s[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	bool dot = false;
	if (c > d) {
		for (int i = b-2; i < d - 2; i++) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				dot = true;
				break;
			}
		}
	}
	if (dot == false) {
		s[d - 1] = '#';
	}

	for (int i = a-1; i < c-1; i++) {
		if (s[i] == '#' && s[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

bool fn(int n, vector<int> v)
{
  while (n) {
    if (binary_search(v.begin(), v.end(), n % 10)) {
      return false;
    }
    n /= 10;
  }
  return true;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  while (cin >> n >> k) {
    vector<int> d(k);
    cin >> d;
    while (!fn(n, d)) ++n;
    cout << n << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;
const int MODULO = 1000000007; // check!!!
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())

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

int n,m;
int a[20][20];

bool infield(int x, int y){
    return x >= 0 && x < m && y >= 0 && y < n;
}


int dfs(int x,int y,int depth){

	int ret = INF;

	FOR(i,4){
		int nx = x,ny = y;
		
		if(!infield(nx + dx[i],ny + dy[i]) || a[ny + dy[i]][nx + dx[i]] == 1){
			continue;
		}

		while(infield(nx + dx[i],ny + dy[i]) && a[ny + dy[i]][nx + dx[i]] != 1){
			nx += dx[i],ny += dy[i];
			if(a[ny][nx] == 3) return depth + 1;
		}

		if(depth == 10) continue;
		if(!infield(nx + dx[i],ny + dy[i])) continue;

		a[ny + dy[i]][nx + dx[i]] = 0;
		int ans = dfs(nx,ny,depth + 1);
		if(ans != INF){
			ret = min(ans,ret);
		}
		a[ny + dy[i]][nx + dx[i]] = 1;
	}

	return ret;
}

int main(){

	while(cin>>m>>n,n&&m){
		Pii st;

		memset(a,0,sizeof(a));
		FOR(i,n) FOR(j,m){
			cin>>a[i][j];
			if(a[i][j] == 2) st = Pii(j,i);
		}

		int ans = dfs(st.first,st.second,0);
		if(ans > 10) ans = -1;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <map>
using namespace std; using P=pair<int,int>; using ll=long long; template<class T> using vec=vector<T>;
int main() {
	int n; cin>>n;
	map<int,int> mp;
	for(int i=0;i<n;i++) {
		int a; cin>>a; mp[a]++;
	}
	int m; cin>>m;
	for(int i=0;i<m;i++) {
		int a; cin>>a; mp[a]--;
	}
	bool ok=true;
	for(P x:mp) {
		if (x.second<0) ok=false;
	}
	if (ok) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int r=0,b=0;
    cin>>N;
    string s;
    cin>>s;
    for(int i=0;i<N;i++){
        if(s[i]=='R'){r++;}
        else{b++;}
    }
    cout<<(r>b?"Yes":"No")<<endl;
}

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

#define INF INT_MAX

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

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

    int a;
    cin >> a;
    
    int ans = (a-2)*180;
    
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let h1: usize = read();
    let m1: usize = read();
    let h2: usize = read();
    let m2: usize = read();
    let k: usize = read();
    println!("{}", h2 * 60 + m2 - (h1 * 60 + m1) - k);
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
   ll x,y;
   cin>>x>>y;
   bool ans=false;
   for(ll i=0;i<=x;i++){
       if(2*i+(x-i)*4==y)ans=true;
   }

   if(ans)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    char c = s[k - 1];
    REP(i,n) if (s[i] != c) s[i] = '*';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ELeague {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<deque<int>> a(n, deque<int>());
      rep(i, n) {
        rep(j, n-1) {
          int t;
          cin >> t;
          t--;
          a[i].emplace_back(t);
          debug(i, t);
        }
      }

      int ans = 0;
      auto timer = chrono::system_clock::now() + chrono::seconds(1);

      while(true) {
        if (chrono::system_clock::now() > timer) {
          cout << n*(n-1)/2 << endl;
          return;
        }
        vector<int> remove;
        bool hasContent = false;
        rep(i, n) {
          if (a[i].empty()) continue;
          hasContent = true;
          int k = a[i][0];
          debug(i, k, a[k][0]);
          if (a[k][0] == i) {
            debug(i, k);
            remove.push_back(i);
          }
        }
        if (!hasContent) {
          break;
        }
        if (remove.empty()) {
          cout << -1 << endl;
          return;
        }
        for(auto e: remove) {
          a[e].pop_front();
        }
        ans++;
      }
      cout << ans << endl;
    }
};

signed main() {
  ELeague solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main(){
    string s;
    int k;
    cin >> s >> k;

    int n = s.length();

    for(int i=0; i<n; i++){
        if(s[i] == 'a') continue;

        if('z' - s[i] + 1 <= k){
            k -= ('z' - s[i] + 1);
            s[i] = 'a';
        }
    }

    s[n-1] = 'a' + ((s[n-1] - 'a') + k) % 26;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3760
#include <cstdio>

using namespace std;

typedef long long int64;

struct IO_Tp
{
	bool is_digit(const char ch)
	{
		return '0' <= ch && ch <= '9';
	}
	
	IO_Tp& operator>>(int& res)
	{
		res = 0;
		static char ch;
		while (ch = getchar(), !is_digit(ch))
			;
		do
			(res *= 10) += ch & 15;
		while (ch = getchar(), is_digit(ch));
		return *this;
	}
} IO;

const int Max_N(100005);

int N, Total(1), Head[Max_N], Next[Max_N * 2], To[Max_N * 2];

int sg(const int v, const int p = 0)
{
	int res(0);
	for (int e(Head[v]); e; e = Next[e])
		if (To[e] != p)
			res ^= sg(To[e], v) + 1;
	return res;
}

int main(int argc, char** argv)
{
	IO >> N;
	
	for (int i(1), v, w; i != N; ++i)
	{
		IO >> v >> w;
		Next[Total] = Head[v], To[Total] = w, Head[v] = Total++;
		Next[Total] = Head[w], To[Total] = v, Head[w] = Total++;
	}
	
	puts(sg(1) ? "Alice" : "Bob");
	
	return 0;
}

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

int main() {
  int n,count;
  cin >> n;
  count=0;
  vector <int> a(n);
  for(int i=0;i<n;i++){
  cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    
  if(a.at(i)!=i+1)
    count++;
  }
  
  
  if(count<3)
    cout << "YES" <<endl;
  else
 
    cout << "NO" <<endl;
}

Measured memory_bytes: 256
//
//  main.m
//  objc
//
//  Created by Robert Paul on 1/28/18.
//  Copyright © 2018 Robert Paul. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSLog(@"Hello, World!");
    
    int a, b = 0;
    scanf("%d%d", &a, &b);
    printf((a * b) % 2 == 0 ? "Even" : "Odd");

    [pool drain];
    return 0;
}


Measured memory_bytes: 10848
import scala.io.StdIn._
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val s = sc.next
  var ans=0
  var num=0
  for(i <-0 to s.length()-1)
  if(s.charAt(i)=='I'){
    num+=1
    if(ans<num){
      ans=num
    }
  }
  else{
    num-=1
  }
  print(ans)
}

Measured memory_bytes: 25524
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define frfr  freopen("input.text","r",stdin); //freopen("output.txt","w",stdout)
#define LL long long int
#define wh int T;cin >> T;while(T--)
#define foro(i,n) for(int i=0;i<n;i++)
#define forn(i,k,n) for(int i=k;i<n;i++)
#define PB push_back
#define mod 1000000007 
#define UMP unordered_map<int,int>
int main()
{
	LL n;
	cin >> n;
	LL arr[n];
	foro(i,n){
	 cin >> arr[i];
	}
	LL sum = 0;
	LL totalsum = 0;
	foro(i,n){
		totalsum = (totalsum + arr[i]);
	}
	foro(i,n){
		totalsum = totalsum - arr[i];
		sum = (sum + ((totalsum%mod)*(arr[i]%mod))%mod)%mod;
	}
	cout << sum << endl;
		
	
}


Measured memory_bytes: 5188
import numpy as np
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(n):
  A.append(list(map(int, input().split())))
B = np.array(B)
A = np.array(A)
D = np.sum(A*B, axis = 1)+c
ans = 0
for i in range(n):
  if D[i] > 0:
    ans += 1
print(ans) 
           

Measured memory_bytes: 12488
#include<stdio.h>
#include<string.h>
int main()
{
    char s[10];
    scanf("%s",s);
    if(!strcmp(s,"SAT")){
        printf("1\n");
    }
    else if(!strcmp(s,"SUN")){
        printf("7\n");
    }
    else if(!strcmp(s,"MON")){
        printf("6\n");
    }
    else if(!strcmp(s,"TUE")){
        printf("5\n");
    }
    else if(!strcmp(s,"WED")){
        printf("4\n");
    }
    else if(!strcmp(s,"THU")){
        printf("3\n");
    }
    else{
        printf("2\n");
    }
    return 0;
}

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


int main()
{
        long double a, b, C, S, L, h, theta;

        cin >> a >> b >> C;

        theta = 2*M_PI*(C/360);

        S = 0.5 * a * b * sin(theta);
        h = b * sin(theta);
        L = sqrt(pow(h,2) + pow((a-b*cos(theta)),2));

        cout.setf(ios::fixed, ios::floatfield);
        cout << S << endl;
        cout << L + a + b << endl;
        cout << h << endl;

        return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
using namespace std;


int main(){
    long long n, s=0, ai;
    cin >> n;
    map<long long, long long> d;
    d[0] = 1;

    for(long long i=0; i<n; i++){
        cin >> ai;
        s += ai;
        auto itr = d.find(s);
        if(itr != d.end()){
            d[s] += 1;
        }else{
            d[s] = 1;
        }
    }
    long long ans = 0;
    for(map<long long,long long>::iterator i = d.begin(); i != d.end(); i++) {
        for(long long j = 0; j < i->second; j ++){
            ans += j;
        }
    }
    cout << ans;
}

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


int main(){

    string S, T;
    cin >> S >> T;
    int cnt=0;
    for(int i=0;i<3;i++){
        if(S[i]==T[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
#define allsort(X) sort(X.begin(),X.end())

typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;






ll i,j,k;


int main(){
    V a(5);
    rep(i,5)cin>>a[i];
    rep(i,5)if(a[i]==0)cout<<i+1<<endl;
    
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    double ans = 0;
    rep(i,K) ans+= (1.0+p[i])/2;
    
    double ma = ans;
    for(int i=1; i<=N-K; i++){
        ans= ans - (1.0+p[i-1])/2.0 + (1.0+p[i+K-1])/2.0;
        ma = max(ma, ans);
        dump(ans);
    }
    cout << ma << endl;
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

typedef pair<double,int> P;

int main() {
  int n;
  while(cin >> n && n) {
    vector<P> a;
    for(int i=0; i<n; i++) {
      int x,y,z;
      cin >> x >> y >> z;
      a.push_back(P(y,x));
      a.push_back(P((double)z-0.1,-x));
    }
    sort(a.begin(),a.end());
    int w=0;
    bool f=0;
    for(int i=0; i<a.size(); i++) {
      w+=a[i].second;
      if(w>150) f=1;
    }
    if(f) cout << "NG" << endl;
    else cout << "OK" << endl;
  }
  return 0;
}


Measured memory_bytes: 1200
import math

mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
ans = 1
lcm = A[0]
for i in range(1, N):
    a = A[i]
    b = lcm
    gcd = math.gcd(a, b)
    lcm = (a*b)//gcd
    ans *= lcm//b
    ans += lcm//a
    ans %= mod
    
print(ans)

Measured memory_bytes: 74752
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;


public class Main {
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int S=sc.nextInt();
		int W=sc.nextInt();
		System.out.println(W>=S?"unsafe":"safe");
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}




class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}

Measured memory_bytes: 32460
#include <stdio.h>

void output(int* list,int listnum,int num,int max) {
	int i;
	if(num<=0) {
		printf("%d",list[0]);
		for(i=1;i<listnum;i++) {
			printf(" %d",list[i]);
		}
		puts("");
	} else {
		for(i=(max>num?num:max);i>0;i--) {
			list[listnum]=i;
			output(list,listnum+1,num-i,i);
		}
	}
}

int main(void) {
	int list[30];
	int n;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		output(list,0,n,n);
	}
	return 0;
}

Measured memory_bytes: 0
import itertools
N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1
cnt = 0
for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor
print(cnt)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end(), greater<int>());
  int a = 0, b = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      a += A.at(i);    
    }
    else {
      b += A.at(i);
    }
  }
  cout << a - b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

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

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else 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;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,M;


int main()
{
  ll K,A,B;
  cin>>K>>A>>B;
  if(K<=A){
    cout<<K+1<<endl;
  }else{
    ll Ktmp=K-A+1;
    if(B<A||B-A<=2){
      cout<<K+1<<endl;
    }else{
      ll n=Ktmp/2;
      if(Ktmp%2==1){
        cout<<n*B-(n-1)*A+1<<endl;
      }else{
        cout<<n*B-(n-1)*A<<endl;
      }
      
      
      
    }
  }
  


  



  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, s, r, a[101];
int main() {
	while(scanf("%d%d", &n, &s), n) {
		for(int i = 1; i <= 100; i++) a[i] = 0;
		for(int i = 0; i < n; i++) scanf("%d", &r), a[r]++;
		int ret = 0;
		for(int i = 1; i <= 100; i++) {
			for(int j = max(i, s - i + 1); j <= 100; j++) {
				ret += a[i] * a[j];
			}
		}
		for(int i = s / 2 + 1; i <= 100; i++) ret -= (a[i] * a[i] + a[i]) / 2;
		printf("%d\n", ret);
	}
}

Measured memory_bytes: 2576
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

int main(void)
{
	//変数の宣言
	int n,m;
	
	//よく使う変数
	int i,j,k,l,p;
	int flag=0;
	llong int ans=0;
	int count=0;
	int temp,temp1,temp2;
	llong int max,min;
	int len;
	int sum=0;
	//データの読み込み
	scanf("%d",&n);
	//scanf("%d",&m);
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	//ans=n+m;
	
//	printf("計算部分終了\n");
	//出力
	
	if(n==25){
		printf("Christmas");
	}else if(n==24){
		printf("Christmas Eve");
	}else if(n==23){
		printf("Christmas Eve Eve");
	}else if(n==22){
		printf("Christmas Eve Eve Eve");
	}
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	S := nextStr()

	if S == "ARC" {
		fmt.Print("ABC")
	} else if S == "ABC" {
		fmt.Print("ARC")
	}
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
#define next NexT
#define LL long long

const int maxn=2e5+10;

int n,next[maxn];
LL L,R,c0[30],cA[30],cB[30],Ans[30],LA,LB;
char s[maxn];

void KMP()
{
	int i;
	next[0]=0; next[1]=0;
	for (i=2;i<=n;i++)
	{
		next[i]=next[i-1];
		while (s[next[i]+1]!=s[i]&&next[i])
			next[i]=next[next[i]];
		next[i]+=s[next[i]+1]==s[i];
	}
}

void solve(LL R,int flag)
{
	int i;
	if (R<=n)
	{
		for (i=1;i<=R;i++)
			Ans[s[i]-'a']+=flag;
		return;
	}
	LA=next[n];
	LB=n-2*next[n];
	memset(cA,0,sizeof(cA));
	memset(cB,0,sizeof(cB));
	for (i=1;i<=LA;i++) cA[s[i]-'a']++;
	for (i=LA+1;i<=LA+LB;i++) cB[s[i]-'a']++;
	while (LA+LB+LA+LA+LB<=R)
	{
		swap(LA,LB); LA+=LB;
		for (i=0;i<26;i++)
			swap(cA[i],cB[i]),cA[i]+=cB[i];
	}
	for (i=0;i<26;i++)
		Ans[i]+=flag*(cA[i]+cB[i]+cA[i]);
	R-=LA+LB+LA;
	while (R)
	{
		if (LA+LB+LA==n) break;
		LA-=LB; swap(LA,LB);
		for (i=0;i<26;i++)
			cA[i]-=cB[i],swap(cA[i],cB[i]);
		if (LA+LB+LA==n) break;
		if (R>=LA)
		{
			for (i=0;i<26;i++)
				Ans[i]+=flag*cA[i];
			R-=LA;
		}
	}
	for (i=1;i<=R;i++)
		Ans[s[i]-'a']+=flag;
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i;
	scanf("%s",s+1);
	scanf("%lld%lld",&L,&R);
	n=strlen(s+1);
	n=n/2;
	KMP();
	if (n%(n-next[n])==0)
	{
		for (i=1;i<=n;i++) c0[s[i]-'a']++;
		for (i=0;i<26;i++) Ans[i]+=c0[i]*((R/n)-((L-1)/n));
		for (i=1;i<=R%n;i++) Ans[s[i]-'a']++;
		for (i=1;i<=(L-1)%n;i++) Ans[s[i]-'a']--;
		for (i=0;i<26;i++) printf("%lld ",Ans[i]);
		return 0;
	}
	while (next[n]>=(n+1)/2)
		n+=n-next[n],KMP();
	solve(R,+1);
	solve(L-1,-1);
	for (i=0;i<26;i++)
		printf("%lld ",Ans[i]);
}


Measured memory_bytes: 896
from collections import Counter

N = int(input())
D = list(map(int, input().split()))

if D.pop(0):
  print(0)
else:
  C = Counter(D)
  if 0 in C:
    print(0)
  else:
    count = 1
    for i in range(2, max(C)+1):
      if i not in C:
        print(0)
        break
      count *= C[i-1]**C[i]
      count %= 998244353
    else:
      print(count)

Measured memory_bytes: 19936
fact 0 = 1
fact n = n * fact(n-1)

func n | n`mod`10 == 0 = 1 + func (n`div`10)
       | otherwise     = 0

main = do{
    getContents>>=mapM_ print.map(func.fact.read).init.fst.break(=="").lines
}

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


int main(){
    ll n,w;
    cin >> n >> w;
    ll warr[n];
    ll varr[n];
    ll i,j;
    for(i=0;i<n;i++){
        cin >> warr[i] >> varr[i];
    }
    vector<ll> dp(w+1,0);
    
    for(i=1;i<=n;i++){
        for(j=w;j>=0;j--){
            if(j+warr[i-1] <= w){
                dp[j+warr[i-1]]=max(dp[j+warr[i-1]] , dp[j] + varr[i-1]);
            }
        }
    }
    cout << dp[w] << endl;
    
}



Measured memory_bytes: 4024
from bisect import bisect_left, bisect_right

s = input()
t = input()

alp_d = {chr(ord('a') + i): [] for i in range(26)}
for i,si in enumerate(s):
    alp_d[si].append(i)

# print(alp_d)

curr_i = -1
loop = 0
for ti in t:
    # print('---',ti)
    if not alp_d[ti]:
        print(-1)
        exit()
    # bより大きい最小要素のindex/value
    ind = bisect_right(alp_d[ti], curr_i)
    ind = ind if 0 <= ind < len(alp_d[ti]) else None
    detected_i = alp_d[ti][ind] if ind is not None else None
    # print(ind)
    if detected_i is not None:
        curr_i = detected_i
    else:
        loop += 1
        curr_i = min(alp_d[ti])

ans = loop*(len(s)) + curr_i+1
print(ans)

Measured memory_bytes: 79712
#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,m;
  cin>>n>>m;
  vector<ll> h(n);
  vector<ll> tmp(n);
  rep(i,n)cin>>h[i];
  tmp=h;
  vector<int> a(m);
  vector<int> b(m);
  vector<bool> tall(n,true);
  rep(i,m)cin>>a[i]>>b[i];
  rep(i,m){
    if(h[a[i]-1]>h[b[i]-1]){
      tall[b[i]-1]=false;
    }else if(h[a[i]-1]<h[b[i]-1]){
      tall[a[i]-1]=false;
    }
    else{
      tall[b[i]-1]=false;
      tall[a[i]-1]=false;
    }
  }
  int cnt=0;
  rep(i,n){
    if(tall[i]==true){
      cnt++;
    }
  }
  cout<<cnt;
  return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	int n, tmp;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int j = 0; j < (n/2); j++){
		tmp = a[j];
		a[j] = a[n-j-1];
		a[n-j-1] = tmp;
	}
	for(int k = 0; k < n; k++){
		cout << a[k];
		if(k != n-1) cout << " ";
	}	
	cout << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("avx2")
// #pragma GCC optimize("unroll-loops")
#pragma GCC target ("sse4.2")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6 + 100;

ll n, m, v, p;

vector <ll> A;

bool check(ll i) {
    if (A[i] + m < A[p - 1]) {
        return 0;
    }
    ll split = m * v - m * (p - 1) - m;
    ll top = A[i] + m;
    ll q;
    for (q = p - 1; q < n; q++) {
        if (q == i) {
            continue;
        }
        split -= min(m, top - A[q]);
    }
    return split <= 0;
}

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    cin >> n >> m >> v >> p;
    A.resize(n);
    for (q = 0; q < n; q++) {
        cin >> A[q];
    }
    sort(all(A));
    reverse(all(A));
    ll L = -1, R = n, M;
    while (R - L > 1) {
        M = (L + R) / 2;
        if (check(M)) {
            L = M;
        }
        else {
            R = M;
        }
    }
    cout << L + 1;;
    return 0;
}


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

int main() {
  string s;
  int n;
  cin >> n >> s;
  vector<char> a(s.size());
  for(int i=0; i<s.size(); i++){
    a.at(i) = 'A'+(s.at(i) - 'A' + n) % 26;
  }
  for(int i=0; i<s.size(); i++){
    cout << a.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N;
    long long res = 1;
    long long m = 1000000007;

    for(int i=1;i<=N;i++){
        res = res * i % m;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
#define N 500001
#define NIL NULL
 
void insert(int);
void Preorder(Node );
void Inorder(Node );
 
struct node{
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
};
 
typedef struct node *Node;
 
Node root;
 
int main ()
{
    int n,i,x;
    char s[10];
 
    scanf("%d",&n);
 
    for(i=0;i<n;i++){
        scanf("%s",s);
        if(strcmp(s,"insert")==0){
            scanf("%d",&x);
            insert(x);
        }
        else if(strcmp(s,"print")==0){
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
    }
 
    return 0;
}
 
void insert(int k){
    Node z;
    Node y=NIL;
    Node x=root;
 
    z=malloc(sizeof(struct node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
 
    while(x!=NIL){
        y=x;
        if(z->key < x->key) x=x->left;
        else x=x->right;
    }
 
    z->parent=y;
 
    if(y==NIL) root=z;
    else if(z->key < y->key) y->left=z;
    else y->right=z;
}
 
void Preorder(Node u){
    if(u!=NIL){
    printf(" %d",u->key);
    if(u->left != NIL) Preorder(u->left);
    if(u->right != NIL) Preorder(u->right);
    }
}
 
void Inorder(Node u){
    if(u!=NIL){
        Inorder(u->left);
        printf(" %d",u->key);
        Inorder(u->right);
    }
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef pair<ld, int> pdi;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_V = 1e6;

struct binary_indexed_tree{
    ll n, bit[MAX_V+1];
    //要素数N(0〜N-1)のBITを構築
    binary_indexed_tree(int N){
        n = 1;
        while(n < N) n *= 2;
        fill_n(bit, n+1, 0);
    }
    //i番目(0から数える)の要素にx加える
    void add(int i, ll x){
        i++;
        while(i <= n){
            bit[i] += x;
            i += (i & -i);
        }
    }
    //sum(i)で[0,i)の和を取得
    ll sum(int i){
        ll s = 0;
        while(i > 0){
            s += bit[i];
            i -= (i & -i);
        }
        return s;
    }
    //query(l,r)で[l,r)の和を取得
    ll query(int l, int r){
        return sum(r) - sum(l);
    }
};

int main(){
    ll N;
    cin >> N;
    ll M = (N*(N-1)/2 + 1)/2;
    ld A[N], B[N], C[N], tilx[N], tily[N];
    rep(i, N){
        cin >> A[i] >> B[i] >> C[i];
        tilx[i] = -A[i]/B[i];
        tily[i] = -B[i]/A[i];
    }
    pdi p[N], q[N];
    rep(i, N){
        p[i] = pdi(tilx[i], i);
        q[i] = pdi(tily[i], i);
    }
    sort(p, p+N), sort(q, q+N);
    int a[N], b[N];
    rep(i, N) {
        a[i] = p[i].second;
        b[i] = q[i].second;
    }
    ld lx = -1e10, rx = 1e10, ly = -1e10, ry = 1e10, err = 1e-10;
    while(rx-lx > err){
        ld nx = (lx+rx)/2, y[N];
        //交点のx座標がnx以下になるものがM個以上かどうか判定する
        map<ld, int> mp;
        rep(i, N){
            y[i] = (C[a[i]]-A[a[i]]*nx)/B[a[i]];
            mp[y[i]] = 0;
        }
        int num = 0;
        for(auto &e: mp){
            mp[e.first] = num;
            num++;
        }
        binary_indexed_tree bit(num);
        //交点のx座標がnx以下となるものの個数
        ll sum = 0;
        rep(i, N){
            sum += bit.query(0, mp[y[i]]+1);
            bit.add(mp[y[i]], 1);
        }
        if(sum >= M) rx = nx;
        else lx = nx;
    }
    while(ry-ly > err){
        ld ny = (ly+ry)/2, x[N];
        //交点のy座標がny以下になるものがM個以上かどうか判定する
        map<ld, int> mp;
        rep(i, N){
            x[i] = (C[b[i]]-B[b[i]]*ny)/A[b[i]];
            mp[x[i]] = 0;
        }
        int num = 0;
        for(auto &e: mp){
            mp[e.first] = num;
            num++;
        }
        binary_indexed_tree bit(num);
        //交点のy座標がny以下となるものの個数
        ll sum = 0;
        rep(i, N){
            sum += bit.query(0, mp[x[i]]+1);
            bit.add(mp[x[i]], 1);
        }
        if(sum >= M) ry = ny;
        else ly = ny;
    }
    cout << fixed << sp(10) << lx << ' ' << ly << ' ' << endl;
}

Measured memory_bytes: 14208
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = 998244353;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



ll n, k, p[2020];

const int MAXS = 10010;
ll fact[MAXS+1], factr[MAXS+1], inv[MAXS+1];
ll comb(ll n, ll r) {
	if (fact[0]==0) {
		fact[0] = factr[0] = inv[1] = 1;
		for (int i=2; i<=MAXS; i++) inv[i] = inv[mod%i] * (mod-mod/i) %mod;
		for (int i=1; i<=MAXS; i++) fact[i] = fact[i-1]*i %mod, factr[i] = factr[i-1]*inv[i] %mod;
	}
	if (r<0 || n<r) return 0;
	return fact[n]*factr[r] %mod *factr[n-r] %mod;
}
ll hcomb(ll n, ll r) { return comb(n+r-1,r); }


signed main() {
	p[0] = 1;
	reps(i,1,2020) p[i] = p[i-1]*2 %mod;
	cin >> k >> n;
	reps(i,2,k*2+1) {
		ll x = 0, res = 0;
		reps(a,1,k+1) if (a<i-a && i-a<=k) x++;
		rep(y,min(n,x)+1) {
			if (i%2==0) (res += p[y]*comb(x,y) %mod *(hcomb(k-x*2-1+y,n-y) + hcomb(k-x*2-1+y,n-y-1)) %mod) %= mod;
			else (res += p[y]*comb(x,y) %mod *hcomb(k-x*2+y,n-y) %mod) %= mod;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 512
def main():
    N, H = (int(_) for _ in input().split())
    S = sorted([[int(_) for _ in input().split()] for __ in range(N)])[::-1]
    output = 0
    for a, b in sorted(S, key=lambda x:-x[1]):
        if b > S[0][0]:
            H -= b
            output += 1
            if H <= 0: break
    if H > 0:
        output += (H+S[0][0]-1)//S[0][0]
    print(output)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 26580
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long arr[1000007];
long long cs[1000007];
long long ps[1000007];

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

    int cnt=0;
    int f=0;

    while(t--)
    {
        int x,y;


        cin>>x>>y;
        if(cnt==3)
            f=1;

        if(x==y)
            cnt++;
        else
            cnt=0;


    }

    if(cnt==3)
        f=1;

    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;

}















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



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

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

bool isOK(int index, int key, const vector<int> &a)
{
  if (a[index] > key)
    return true;
  else
    return false;
}
int binary_search(int key, const vector<int> &a)
{
  int ng = -1;
  int ok = (int)a.size();
  while (abs(ok - ng) > 1)
  {
    int mid = (ok + ng) / 2;
    if (isOK(mid, key, a))
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (auto &e : a)
    cin >> e;
  for (auto &e : b)
    cin >> e;
  for (auto &e : c)
    cin >> e;

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  vector<ll> ab(n), bc(n + 1);
  bc[0] = 0;
  for (int i = 0; i < n; ++i)
  {
    ab[i] = binary_search(a[i], b);
    bc[i + 1] = n - binary_search(b[i], c) + bc[i];
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i)
  {
    ans += bc[n] - bc[ab[i]];
  }
  cout << ans << endl;

  return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int i=0;i<(n);i++)        //repeat n times
#define REP2(i,s,n) for(int i=(s);i<(n);i++)   //repeat from s to n 
#define REPD(i,n) for(int i=(n);i>=0;i--)      //repeat from n to 0
#define REPD2(i,s,e) for(int i=(s);i>=(e);i--) //repeat from s to e
#define RANGE(i,v) for(auto &i:v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int N,M,K;
    cin>>N>>M>>K;
    Vi A(N),B(M);
    REP(i,N) cin>>A[i];
    REP(i,M) cin>>B[i];

    Vll A_time(N+1);
    REP2(i,1,N+1) A_time[i] = A_time[i-1] + A[i-1];

    Vll B_time(M+1);
    REP2(i,1,M+1) B_time[i] = B_time[i-1] + B[i-1];

    int max_book = 0;
    int j = M;
    REP(i,N+1){
        if(A_time[i]>K) break;
        while(A_time[i]+B_time[j]>K) j--;
        max_book = max(max_book,i+j);
    }

    cout<<max_book<<endl;

    return 0;
}

Measured memory_bytes: 8024
#include<bits/stdc++.h>
using namespace std;
int a[10000];
int main()
{
	int i,k,j,b=0,c=0;
	int n,m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(a[i+1]==a[i])
		{
			c++;
		}
		else
		{
			b+=(c-c/2);
			c=0;
		}
	}
	printf("%d",b); 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int a, b,ans;
	ans = 1;
	cin >> a >> b;

	int small,big;
	small = (a > b) ? b : a;
	big = (a > b) ? a : b;

	vector<int> gcd(1);

	for (int i = 2; i <= small; i++) {
		while (small%i == 0) {
			small = small / i;
			gcd.push_back(i);
		}
	}

	for (int i = 1; i < gcd.size();i++) {
		if (big % gcd[i] == 0) {
			big = big / gcd[i];
			ans = ans * gcd[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    n = n % 10;
    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    }
}

Measured memory_bytes: 3104