akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#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;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	pair<pair<string, int>, int>  store[110];
	rep(i, N) {
		string S;
		ll P;
		cin >> S >> P;
		store[i] = make_pair(make_pair(S, 1000-P), i);
	}
	sort(store,store+N);
	rep(i, N) {
		cout << store[i].second + 1 << endl;
	}
}


Measured memory_bytes: 256
#coding:utf-8
N = 10**9
S = int(input())
x1 = (S // N) + 1
y2 = N
x2 = 1
y1 = (x1*y2) - S
if S == 10**18:
    x1 = N
    y2 = N
    x2 = 0
    y1 = 0
print (" ".join(map(str,[x1,y1,x2,y2,0,0])))

    


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    map<ll, ll> hats;
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        hats[temp]++;
    }
    if(hats.size() == 1) {
        if(hats.find(0) == hats.end()) cout << "No" << endl;
        else cout << "Yes" << endl;
    } else if(hats.size() == 2) {
        if(hats.find(0) != hats.end() && hats[0] == N / 3) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else if(hats.size() == 3) {
        auto iter = hats.begin();
        pair<ll, ll> x, y, z;
        x = *iter++;
        y = *iter++;
        z = *iter;
        if((x.second == y.second && y.second == z.second) && (x.first ^ y.first ^ z.first) == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
int N, M;
int p[100000], y[100000];
vector<int> v[100010];
int main() {
	COME_LET_THE_GAMES_BEGIN();
	cin >> N >> M;
	rep(i, M) {
		cin >> p[i] >> y[i];
		v[p[i]].push_back(y[i]);
	}
	rrep(i, N) {
		sort(v[i].begin(), v[i].end());
	}
	rep(i, M) {
		printf("%06d%06d\n", p[i], lower_bound(v[p[i]].begin(), v[p[i]].end(), y[i]) - v[p[i]].begin() + 1);
	}
}

Measured memory_bytes: 7808
#include <stdio.h>
#include <string.h>
int main()
{
	char S[200];
	int i;
	scanf("%s",S);
	i=(strlen(S)/2);
	for(;i--;){
		if(!strncmp(S,S+i,i)){
			printf("%d",i*2);
			return 0;
		}
	}
	return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i>=b;i--)

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double

#define V vector<ll>
#define pp pair<ll,ll>
#define pb push_back
#define mp make_pair
#define Pr pair<ll,ll>
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin().A.rend()

#define ff first
#define ss second
#define len length()
ll max3(ll a,ll b,ll c)
{
    if(a>=b&&a>=c)
        return a;
    else if(b>=a&&b>=c)
        return b;
    else
        return c;
}
int min3(int a,int b,int c)
{
    if(a<=b&&a<=c)
        return a;
    else if(b<=a&&b<=c)
        return b;
    else
        return c;
}
int binarySearch(ll arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;

        if (arr[mid] == x)
            return mid;

        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);


        return binarySearch(arr, mid + 1, r, x);
    }

    return -1;
}
int main()
{
	fast;

           int a;
           cin>>a;
           string s;
           cin>>s;
           if(a<3200)
            cout<<"red"<<endl;
           else
            cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define sync()      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileIO()    freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
#define F           first
#define S           second
#define ers         erase
#define ins         insert
#define db          pop_back
#define pb          push_back
#define df          pop_front
#define pf          push_front
#define SZ(x)       ((ll)x.size())
#define sqr(x)      (x)*(x)
#define Blz(x)      __builtin_clz(x)
#define Brz(x)      __builtin_ctz(x)
#define Bones(x)    __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define kill(x)     return cout<<x,0
#define dbgp(x)     cerr<< #x << " = " << x.F << ", " << x.S << endl
#define dbg(x)      cerr<< #x << " = " << x << endl
#define ddbg(i,x)   cerr<< #i << " = " << i << " / ", dbg(x[i])
#define tdbg(i,E,x) cerr<< #i << " = " << i << " / ", ddbg(E,x[i])
typedef long long                                    ll;
typedef long double                                  ld;
typedef unsigned short int                           usi;
typedef pair<long long,bool>                         plb;
typedef pair<long long,long long>                    pll;
typedef pair<int,int>                                pii;
typedef string                                       str;
typedef priority_queue<ll>                           maxheap;
typedef priority_queue<ll,vector<ll>,greater<ll>>    minheap;
typedef priority_queue<pll,vector<pll>,greater<pll>> djq;
const ll maxn=1e4+10, wax=20, inf=4e18, mod=1e9+7; const ld pi=3.14159265359, eps=1e-9;
ll n,m;
bool mk[10];
ll tmp[]={0,2,5,5,4,5,6,3,7,6};
string jj[maxn];
string maxi(string a,string b){
    if(SZ(a)!=SZ(b)) return (SZ(a)>SZ(b) ? a:b);
    return (a>b ? a:b);
}
int main(){
    sync();
    cin>>n>>m;
    ll a;
    for(int i=1;i<=m;i++) cin>>a, mk[a]=1;
    for(int i=1;i<maxn;i++) jj[i]="-";
    jj[0]="";
    for(int i=1;i<=9;i++){
        if(mk[i]){
            for(int j=tmp[i];j<=n;j++){
                if(jj[j-tmp[i]]!="-"){
                    jj[j]=maxi((jj[j]=="-" ? "":jj[j]),char(i+'0')+jj[j-tmp[i]]);
                    //ddbg(j,jj);
                }
            }
        }
    }
    cout<<jj[n];
    return 0;
}
/**

 (                            )   (   )
 )\ )             (      )  ( /(  () /(
(()/(  (  (    (  )\  ( /(  )\()) )\ ())
 /(_))_)  )\   )\((_) )(_))(_)\) ((_)(_)
(_)) __| ((_) ((_)| |((_)_)| |(_)| |_| |
  | (_ |/ _ \/ _ \| |/ _` || / / |  _  |
   \___|\___/\___/|_|\__,_||_\_\ |_| |_|

I'm burning in rage and hatred...
**/


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

int main(){
  double n,m;
  int d;
  cin >> n >> m >> d;
  double p = (n-(double)d)*2./(n*n);
  if(d == 0) p = 1.0/n;
  cout << fixed << setprecision(9) << p*(m  -1) << endl;
  return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int pow2(int n) {
    int res = 1;

    if(n==0) return 1;
    else {
        for(int in=0;in<n;in++) {
            res *= 2;
        }
    return res;
    }
}

int main(void) {
    int n, m;
    cin >> n >> m;

    cout << 1900*pow2(m)*m + (n-m)*100*pow2(m) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
vector<int> ans;
bool isOK(vector<int> &b)
{
    for(int i = 0; i < b.size(); i++) if(b[i] > i + 1) return true;
    return false;
}
void solve(vector<int> v)
{
    int d = 0;
    for(int i = v.size() - 1; i >= 0; i--)
    {
        if(v[i] == v.size() - d)
        {
            ans.push_back(v[i]);
            v.erase(v.begin() + i);
            solve(v);
            return;
        }
        d++;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> b(n);
    for(int i = 0; i < n; i++) cin >> b[i];
    if(isOK(b))
    {
        cout << -1 << endl;
        return 0;
    }
    solve(b);
    reverse(ans.begin(), ans.end());
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

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

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m == -1 && f == -1 && r == -1 ) break;

            if( m == -1 || f == -1 ){
                System.out.println("F");
            } else if(m+f >= 80){
                System.out.println("A");
            } else if(m+f >= 65){
                System.out.println("B");
            } else if(m+f >= 50 || r >= 50){
                System.out.println("C");
            } else if(m+f >= 30){
                System.out.println("D");
            } else {
                System.out.println("F");
            }
        }
    }
}




Measured memory_bytes: 26336
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "1" : "0");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

  int n, d; cin >> n >> d;
  ll a[n][d];

  for(int i=0; i<n; i++) {
    for(int j=0; j<d; j++) {
      cin >> a[i][j];
    }
  }

  ll ans = 0;
  for(int i=0; i<n; i++) {
    for(int j=0; j<i; j++) {
      ll z = 0;
      for(int k=0; k<d; k++)
        z += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
      ll p = 0;
      for(; p*p<z; p++);
      if( p*p == z ) ans++;
    }
  }
  cout << ans << endl;
}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let (n, x, m) = read_cols!(i64, usize, usize);

    let a0 = (0..m).map(|i| (i, i * i % m)).collect::<Vec<_>>();

    let a = once((1, a0.clone()))
        .chain((1..=34).scan((1, a0), |aa, _| {
            aa.0 = 2 * aa.0;
            aa.1 = (0..m)
                .map(|i| {
                    let j = aa.1[i].1;
                    (aa.1[i].0 + aa.1[j].0, aa.1[j].1)
                })
                .collect();

            Some(aa.clone())
        }))
        .collect::<Vec<_>>();

    let ans = a
        .iter()
        .rev()
        .fold((n, x, 0), |(nn, xx, s), (p, b)| {
            let p = *p;
            if nn < p {
                (nn, xx, s)
            } else {
                (nn - p, b[xx].1, s + b[xx].0)
            }
        })
        .2;

    println!("{}", ans);
}


Measured memory_bytes: 58232
#include <cstdio>
#include <queue>
using namespace std;
int n,a[100005],b[100005],ab[100005],ans; 
long long sumab,sums;
priority_queue<int>q;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	for(int i=1;i<=n;++i)scanf("%d",b+i);
	for(int i=1;i<=n;++i){
		ab[i]=a[i]-b[i];
		sumab+=ab[i];
		if(ab[i]>0)q.push(ab[i]);
	}
	if(sumab<0)printf("-1\n");
	else{
		for(int i=1;i<=n;++i){
			if(ab[i]<0){
				++ans;
				while(sums+ab[i]<0){
					ab[i]+=sums;
					++ans;
					sums=q.top();
					q.pop();
				}
				sums+=ab[i];
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 4452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
using namespace std;

int n;
int main() {
	cin >> n;
    vector<int> a(n);
	rep(_, 0, n-1){
		int t; cin >> t;
		t--;
		a[t]++;
	}
	rep(i, 0, n){
		cout << a[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3668
#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;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int m;
int main(){
    cin>>n>>m;
    vector<vector<int>> s(m);
    rep(i,m){
        int k;
        cin>>k;
        s[i].resize(k);
        rep(j,k){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(m);
    rep(i,m) cin>>p[i];
    int ans=0;
    for(int i = 0;i < (1<<n); i++){//2^n回のループ
        bool ok=true;
        for(int j=0;j<m;j++){//j個のスイッチに対して探索
            int cnt=0;
            for(int k=0;k<s[j].size();k++){
                if((i>>s[j][k])&1) cnt++; 
            }
            cnt%=2;
            if(cnt!=p[j]){
                ok=false;
            }
        }
        if(ok) ans++;
    }
    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int sq(int m){
	return m*m;
}

int main(){
	int n;	
	scanf("%d",&n);
		
	int a[n];
	int b[n];
	int c[n];
	int i;
	
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	
	for(i=0;i<n;i++){
		if(sq(a[i])==sq(b[i])+sq(c[i])||sq(b[i])==sq(a[i])+sq(c[i])||sq(c[i])==sq(a[i])+sq(b[i])){
			printf("YES\n");
		}else {printf("NO\n");}
	}
	
	return 0;
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;

    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    rep(i,k){
        vector<int> new_a(n+1,0);
        bool m=true;
        rep(j,n){
            new_a[max(j-a[j],0ll)]++;
            new_a[min(j+a[j]+1,n)]--;
        }
        a[0]=new_a[0];
        rep(j,1,n){
            new_a[j]+=new_a[j-1];
            if(new_a[j-1]!=n)m=false;
            if(new_a[j]!=n)m=false;
            a[j]=new_a[j];
        }
        if(m)break;
    }
    rep(i,n){
        cout<<a[i];
        if(i+1==n)cout<<endl;
        else cout<<' ';
    }
}

Measured memory_bytes: 6364
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
using namespace std;

int main() {
   string S;
   cin >> S;
    int A = (S[0] -'0')*10 +(S[1]- '0');
    int B = (S[2] -'0')*10 +(S[3]- '0');
    
    bool YYMM = (1 <= B && B <= 12);
    bool MMYY = (1 <= A && A <= 12);
    if(YYMM)
        if(MMYY){puts("AMBIGUOUS");
        
        }
        else{ 
        puts("YYMM");
        
    }else{
        if(MMYY)
        puts("MMYY");
        else puts("NA");
    }
}

Measured memory_bytes: 256
def solve():
    H, W = map(int, input().split())
    Sss = ['#'*(W+2)] + ['#'+input()+'#' for _ in range(H)] + ['#'*(W+2)]

    numLss = [[0]*(W+2) for _ in range(H+2)]
    numRss = [[0]*(W+2) for _ in range(H+2)]
    numUss = [[0]*(W+2) for _ in range(H+2)]
    numDss = [[0]*(W+2) for _ in range(H+2)]
    for i in range(1, H+1):
        for j in range(1, W+1):
            if Sss[i][j] == '.':
                numLss[i][j] = numLss[i][j-1] + 1
        for j in reversed(range(1, W+1)):
            if Sss[i][j] == '.':
                numRss[i][j] = numRss[i][j+1] + 1
    for j in range(1, W+1):
        for i in range(1, H+1):
            if Sss[i][j] == '.':
                numUss[i][j] = numUss[i-1][j] + 1
        for i in reversed(range(1, H+1)):
            if Sss[i][j] == '.':
                numDss[i][j] = numDss[i+1][j] + 1

    ans = 0
    for i in range(1, H+1):
        for j in range(1, W+1):
            num = numLss[i][j] + numRss[i][j] + numUss[i][j] + numDss[i][j] - 3
            ans = max(ans, num)

    print(ans)


solve()


Measured memory_bytes: 179588
#include <stdio.h>

int main(void) {
	int n;
	int asumi_kana[32];
	int kitamura_eri = 0;
	int horie_yui, tamura_yukari;
	int result;
	if (scanf("%d", &n) != 1) return 1;

	horie_yui = n;
	for (tamura_yukari = 2; tamura_yukari * tamura_yukari <= horie_yui; tamura_yukari++) {
		if (horie_yui % tamura_yukari == 0) {
			asumi_kana[kitamura_eri++] = tamura_yukari;
			while (horie_yui % tamura_yukari == 0) horie_yui /= tamura_yukari;
		}
	}
	if (horie_yui > 1) asumi_kana[kitamura_eri++] = horie_yui;

	result = n;
	tamura_yukari = 1 << kitamura_eri;
	for (horie_yui = 1; horie_yui < tamura_yukari; horie_yui++) {
		int s = 1, c = 1;
		int i;
		for (i = 0; i < tamura_yukari; i++) {
			if ((horie_yui >> i) & 1) {
				s = -s;
				c *= asumi_kana[i];
			}
		}
		result += s * (n / c);
	}
	printf("%d\n", result);
	return 0;
}



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

using namespace std;

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long p, q, r, s;
	p = a * c;
	q = b * c;
	r = a * d;
	s = b * d;
	cout << max(p, max(q, max(r, s))) << endl;
	return 0;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

bool IsPrime(ll n)
{
	if (n == 1)
		return false;
	if (n == 2)
		return true;

	for (ll i = 2; i*i <= n; i++)
		if (n%i == 0)
			return false;
	return true;
}

void solve()
{
	int n, k;
	cin >> n >> k;
	ll r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;

	ll ans = 0;

	vector<int> kek(n);

	for (int i = 0; i < n; i++)
		if (t[i] == 'r')
		{
			ans += p;
			kek[i] = p;
		}
		else
			if (t[i] == 's')
			{
				ans += r;
				kek[i] = r;
			}
			else
				if (t[i] == 'p')
				{
					ans += s;
					kek[i] = s;
				}


	for (int i = k; i < n; i++)
		if (t[i - k] == t[i])
		{
			ans -= kek[i];
			t[i] = '*';
		}

	cout << ans;

}

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


#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("journey.in", "r", stdin);
	//freopen("journey.out", "w", stdout);


	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();


}

Measured memory_bytes: 848
N,dum=gets.chomp.split(' ').map{|n| n.to_i}
a=gets.chomp.split(' ').map{|n| n.to_i}

ans = []
max = a.max{|a,b| a.abs <=> b.abs}
max_i = a.index(max)
0.upto(N-1){|i|
	a[i] += max
}
# すべて正か，すべて非負整数かのパターンに帰着
if(a[max_i] > 0)
	0.upto(N-2){|i|
		a[i+1] += a[i]
	}
else
	(N-2).downto(0){|i|
		a[i] += a[i+1]
	}
end

#puts "#{a.join(" ")}"
puts N+N-1
0.upto(N-1){|i|
	puts "#{max_i+1} #{i+1}"
}
if(a[max_i] > 0)
	0.upto(N-2){|i|
		puts "#{i+1} #{i+2}"
	}
else
	(N-2).downto(0){|i|
		puts "#{i+2} #{i+1}"
	}
end


Measured memory_bytes: 3836
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }

  if(k < u->key){
    return treeSearch(u->left,k);
  }else{
    return treeSearch(u->right,k);
  }
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  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 inorder(Node u){
  if (u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

a,b=map(int,input().split())
if abs(a-b)>=2:
    print(0)
    exit()
mod=10**9+7
re=2 if a==b else 1
def kaijou(n):
    if n==1:return 1
    else:
        return (kaijou(n-1)*n)%mod


print(kaijou(a)*kaijou(b)*re%mod)

Measured memory_bytes: 92096
def calc_taxed_price(original_price, tax_rate)
  (original_price * (100.0+tax_rate)/100.0).to_i
end

readlines.each{|s|
  prev_tax_rate,new_tax_rate,prev_taxed_sum = s.chomp.split.map &:to_i
  if prev_tax_rate == 0 then break end



results = []

(1...prev_taxed_sum).each{|price_iter1|
  (1...prev_taxed_sum).each{|price_iter2|
    prev_taxed_price1 = calc_taxed_price price_iter1,prev_tax_rate
    prev_taxed_price2 = calc_taxed_price price_iter2,prev_tax_rate

    if prev_taxed_price1 + prev_taxed_price2 == prev_taxed_sum
      results.push [price_iter1, price_iter2]
    end
  }
}

# p results

price1,price2 = results.max_by{|price_iter1, price_iter2|
    prev_taxed_price1 = calc_taxed_price price_iter1,prev_tax_rate
    prev_taxed_price2 = calc_taxed_price price_iter2,prev_tax_rate
    new_taxed_price1 = calc_taxed_price price_iter1,new_tax_rate
    new_taxed_price2 = calc_taxed_price price_iter2,new_tax_rate
    new_taxed_sum = new_taxed_price1 + new_taxed_price2
    new_taxed_sum
}

new_taxed_price1 = calc_taxed_price price1,new_tax_rate
new_taxed_price2 = calc_taxed_price price2,new_tax_rate
p new_taxed_price1 + new_taxed_price2

}



Measured memory_bytes: 6884
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
 
int32_t main()
{
    c_p_c();
    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe";
    }
    else
    {
        cout<<"safe";
    }
    return 0;
}

Measured memory_bytes: 3652
//#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 100;
char s[N];
int n,k;
double p;
int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i)
    {
        double pp = 1.0 / n;
        int tmp = i;
        while (tmp < k)
            tmp <<= 1, pp /= 2;
        p += pp;
    }
    printf("%.10f\n", p);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  string s;
  cin >> s;
  if (s == "KIHBR" || s == "AKIHBR" || s == "KIHABR" || s == "KIHBAR" || s == "KIHBRA" ||
      s == "AKIHABR" || s == "AKIHBAR" || s == "AKIHBRA" || s == "KIHABAR" || s == "KIHABRA" ||
      s == "KIHBARA" || s == "AKIHABAR" || s == "AKIHABRA" || s == "AKIHBARA" || s == "KIHABARA" ||
      s == "AKIHABARA")
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,z,i,j,a[101][101]={};
  scanf("%d%d",&x,&y);
  for(i=0;i<x;i++){
    for(j=0;j<y;j++){
      scanf("%d",&z);
      a[i][j]=z;
    }
  }
  for(i=0;i<x;i++){
    for(j=0;j<y;j++){
      a[i][y]+=a[i][j];
      a[x][j]+=a[i][j];
    }
    a[x][y]+=a[i][y];
  }
  for(i=0;i<x+1;i++){
    for(j=0;j<y+1;j++){
      if(j!=y)
      printf("%d ",a[i][j]);
      else printf("%d",a[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	double ct=n/2;
	if (n%2) ct++;
	cout<<setprecision(10)<<fixed<<(ct/n)<<endl;
	return 0;
}


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

int main(){
  string w;
  cin >> w;

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

  int cnt = 0;
  bool flag = true;

  for(int i = 0; i < w.size(); i++){
    if(i == 0) cnt++;

    else if(w[i] == w[i-1]){
      cnt++;
    }

    else{
      if(cnt%2 != 0){
        flag = false;
        break;
      }
      else cnt = 1;
    }
  }

  if(cnt%2 != 0) flag = false;

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;

}


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

A_={}
for a_idx,a in enumerate(A):
    A_[a_idx+1] = a

visit={}
first={}
for n in range(N):
    visit[n+1]=0
    first[n+1]=-1
    
v=1
Loop=[]
for n in range(2*N):   
    Loop.append(v)
    if visit[v] == 0:
        first[v] = n
    visit[v]+=1
#     print(v,visit)
    if visit[v] == 2:
        break
        
    v=A_[v]

if K-first[v] < 0:
    print(Loop[K])
else:  
    ans_idx=(K-first[v])%(n-first[v])
    print(Loop[first[v]:n][ans_idx])

Measured memory_bytes: 78740
n=int(input())
t,a=map(int, input().split())
h=list(map(int,input().split()))
min_gap=999
for i in range(n):
    tmp=t-0.006*h[i]
    if(abs(tmp-a)<min_gap):
        min_gap=abs(tmp-a)
        min_i=i

print(min_i+1)


Measured memory_bytes: 3060
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000



d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

n, a, b = LI()


ans = pow(2, n, mod) - 1
# math.factorial()

# print(ans % mod)

def fur(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod

print((ans - fur(n, a) - fur(n, b)) % mod)

Measured memory_bytes: 6344
#include <bits/stdc++.h>
#include<numeric>
#include<cstdlib>
#include <iostream>
#define ll long long int
#define all(x) x.begin(),x.end()

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define v vector<long long int> 
#define vv vector< int> 
#define gcd(m,n) __gcd(m,n)
#define vp vector<pair<long long int ,long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int ,long long int> 
#define f(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,n) for (ll i=a ; i<n ;i+=1)
#define fe(d,e) for(auto d:e)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll,ll>
# define N 100005LL
# define cout1(x) cout<<x<<"\n";
# define  deb(x) cout<<#x<<" "<<x<<"\n";
#define  vii vector<pa>;
using namespace std;

v visited(N);
vector<ll> ans={-1};
v level(N);
v ind(N);
ll sz[N];




// void dfs(ll node, ll par){
    
//     visited[node]=1;
//     if (node==1)level[1]=0;
//     else level[node] = level[par]+1;
//     ans.pb(node);
//     for(auto x:graph[node]){
//         if (!visited[x]){
//             dfs(x,node);
//             sz[node]+=sz[x];

//         }
       
//     }
//      ++sz[node];
    
// }
// map<ll,ll> cnt;
// ll answer(ll ans,ll x){
//     cout<<ans<<" "<<x<<endl;
//     if (cnt[ans%x]==0)return ans;
//     else if (cnt[ans%x==1] && ans>x)return ans;
//     else{
//         cnt[ans%x]-=1;
//         cnt[ans]+=1;
//         answer(ans+1,x);
//     }



// }

int main(){
    ll n;
    cin>>n;
    v arr(n);
    f(i,n)cin>>arr[i];
    sort(all(arr));
    ll ans=0;
    for(int i=0;i<n-2;i++){
        for (int j=i+1;j<n-1;j++){
            int k = lower_bound(all(arr),arr[i]+arr[j])-arr.begin();
            if (k>j){
                // cout<<i<<" "<<j<<" "<<k<<endl;
                ans+=(k-j-1);
            }
        }
    }
    cout<<ans<<"\n";
}
  
    
    

        


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

int main() {
    int h,w;
    while (cin>>h>>w,h!=0&&w!=0)
    {
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cout << "#";
            }
            cout << endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

ll a, b, c;

int main(void) {
	cin >> a >> b >> c;
	if (c >= a && c <= b)ct("Yes");
	else ct("No");

	return 0;
}

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL)
const int N=100003,M=5002;

int main()
{
	int n;
	cin>>n;
	map<string,int> mm;
	int r=0;
	while(n--)
	{
		string s;
		cin>>s;
		if(mm.find(s)==mm.end()) r++;
		mm[s]=1;
	}
	cout<<r;
	return 0;
}

Measured memory_bytes: 19252
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main(){
  int N; cin >> N;
  vector<pair<string,int>> rest;
  map<pair<string,int>,int> mp;
  for(int i = 1;i <= N;i++){
    string s; cin >> s;
    int p; cin >> p;
    rest.push_back(make_pair(s,-p));
    mp[make_pair(s,-p)] = i;
  }

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

  for(int i = 0;i < N;i++){
    cout << mp[rest[i]] << endl;
  }


}


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

int main(){

    int n,k;
    cin >> n >> k;

    vector<double> p(n);
    double kitai = 0; 
    vector<double> ki(n);
    double ma = 0;

    for(int i = 0; i < n; ++i){
        cin >> p[i];
        ki[i] = 1;
        for(int j = 2; j <= p[i]; ++j){
            ki[i] += j;
        }
        ki[i] /= p[i];

        kitai += ki[i];

        if(i >= k){
            kitai -= ki[i-k];
        }
        ma = max(kitai, ma);
    }

    cout << setprecision(7)<< ma << endl;

}

Measured memory_bytes: 3328
#include <stdio.h>

int H, W;
int sx, sy;
char map[100][100]; // Y X                                                                                                      
int dist[100][100]; // Y X                                                                                                      

void clearDist() { for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) dist[i][j] = -1; }

int list_top; // いま埋めようとしている                                                                                         
struct { int x, y, count; } todo[10240]; // 埋めるリスト                                                                        

static int set(int x, int y, int count) {
  if (x < 0 || y < 0 || x >= W || y >= H) return 0;
  if (map[y][x] != '.') return 0;
  if (dist[y][x] >= 0) return 0;
  todo[list_top].x = x; todo[list_top].y = y; dist[y][x] = count;
  todo[list_top].count = count+1;
  list_top++;
  return 1;
}

void provision(int x, int y) {
  int i = 0, count;
  list_top = 1;
  todo[0].x = x; todo[0].y = y; todo[0].count = 1;
  dist[y][x] = 0;
  for (i = 0; i < list_top; i++) {
    x = todo[i].x; y = todo[i].y; count = todo[i].count;
    set(x-1,y,count);
    set(x+1,y,count);
    set(x,y-1,count);
    set(x,y+1,count);
  }
}
int findMax() {
  int max = 0;
  for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
      if (max < dist[i][j]) { sx = j; sy = i; max = dist[i][j]; }
    }
  return max;
}
int main() {
  int i, max, maxmax = 0;
  scanf("%d %d", &H, &W);
  for (i = 0; i < H; i++) {
    scanf("%s", &(map[i][0]));
  }
  for (int i = 0; i < H; i++) for (int j = 0; j < W; j++)
      if (map[i][j] == '.') {
        clearDist(); provision(j, i); max = findMax();
        if (maxmax < max) maxmax = max;
      }
  printf("%d\n", maxmax);
}



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

int main() {
    ll N;
    cin >> N;
    vector<string> S(N);
    for (ll i=0; i<N; i++) {
        cin >> S.at(i);
    }

    //
    vector<string> S_new(N);
    sort(S.begin(),S.end());
    S_new = S;
    ll count = 1;
    for (ll i=0; i<N-1; i++) {
        if (S.at(i) != S.at(i+1)) {
            count++;
        }
    }
    cout << count << endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    int ans=0;
    for(int i=0;i<n;i=i+2){
        if(i==n-1)ans+=a[i];
        else ans+=a[i]-a[i+1];
    }
    cout<<ans<<endl;
    return 0;
}

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

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

def main():
    import math
    mod=10**9+7
    a,b,x3=MI()
    
    x=x3/(a**2) #引数勘違いしてた
    
    if (a*b)//2 >= a*x :
        y=(2*a*x)/b
        th=math.atan2(b,y)
        
    else:
        rem=a*(b-x)
        z=rem*2/a
        th=math.atan2(z,a)
        
    print(th/math.pi * 180)
        

main()


Measured memory_bytes: 62488
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
 /*  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);//abcabca
   #endif
   /********************* Code starts here ***********************/
   int a,b,c;
   cin>>a>>b>>c;
   if((a+b)>=c)
   	cout<<"Yes"<<endl;
   else
   	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  long long a,b,c,d=0,e=0;
  cin>>a>>b>>c;
  if(b==0){
    cout<<0;
    return 0;
  } 
  d=a/(b+c)*b;
  e=a%(b+c);
    if(e==0){
      cout<<d;
      return 0;
    }
    else{
      cout<<d+min(b,e);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <fstream>

using namespace std;

typedef unsigned long long ll;

vector<int> arr;
vector<int> memo;

ll dp(int index )
{
    if( memo[index] != -1)
        return memo[index];


    if(index == arr.size()-1 && arr[index] != -1)
    {
        memo[index] = 1;
        return 1;
    }


    if(arr[index] == -1 )
    {
        memo[index] = 0;
        return 0;
    }


    ll result = 0;

    if(index <= arr.size()-2)
        if(arr[index+1] != -1)
            result += dp(index+1) % 1000000007;

    if(index <= arr.size()-3)
        if(arr[index+2] != -1)
            result += dp(index+2) % 1000000007;

    memo[index] = result;
    return result % 1000000007;

}

int main() {

    int n;
    int m;
    cin >> n >> m;
    arr.resize(n+1);
    vector<int> numbers (n+1);
    memo.resize(n+1);

    for(int i = 0; i < memo.size(); i++)
        memo[i] = -1;

    for(int i = 0; i < m; i++)
    {
        int index;
        cin >> index;
        arr[index] = -1;

    }


    ll solution = dp(0)  % 1000000007;

    cout << solution;

    return 0;


}

Measured memory_bytes: 6144
def mod_pow(a, n):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


n = int(input())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7

cnt = [0] * 60
for v in a:
    for i in range(60):
        if (v >> i) & 1:
            cnt[i] += 1

pow_2 = [1]
for i in range(60):
    pow_2.append(pow_2[-1] * 2 % mod)

res = 0
for v in a:
    for i in range(60):
        if (v >> i) & 1:
            res = (res + (n - cnt[i]) * pow_2[i] % mod) % mod
        else:
            res = (res + cnt[i] * pow_2[i] % mod) % mod

print(res * mod_pow(2, mod - 2) % mod)

Measured memory_bytes: 123184