akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Gosu_Hiroo
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

//#define int ll

class CNotSoDiverse {
public:
    int N, K;
    map<int, int> M;
void solve(std::istream& cin, std::ostream& cout) {
    cin >> N >> K;
    ll ans = 0;
    _for(i,N)M[readint] ++;
    vector<int> V;
    auto it = begin(M);
    while(it != end(M)){
        V.emplace_back(it->second);
        it = next(it);

    }
    sort(all(V));
//    error(V);
    if(M.size() > K)
        _for(i,M.size() - K)ans += V[i];


    cout << ans << endl;
}


};


#undef int
int main() {


	CNotSoDiverse solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, c; cin >> a >> b >> c;
    ll add = a%b;
    if(add == 0){
        (add == c) ? YES() : NO();
        return 0;
    }

    for(ll i=add; i<=10000; i+=add){
        if(i%b == c){ YES(); return 0; }
    }
    NO();
}

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

long long fact(long long n){
    if(n == 0 || n == 1) return 0;
    return n * (n-1) / 2;
}

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



Measured memory_bytes: 3092
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    int[] val = new int[n];
    
    for(int i = 0; i < n; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    
    long ans = 0;
    for(int i = 0; i < n; i++){
      for(int j = i; j < n; j++){
        if(i != j){
          ans += (val[i] * val[j]);
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,ans=0,sum;
vp p;
string s;
ll solve(){
    if(k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
        return -1;
    }
    x=(n-1)*(n-2)/2-k;
    cout<<x+(n-1)<<endl;
    rep(i,n-1){
        cout<<i+1<<" "<<n<<endl;
    }
    rep(i,n-1){
        rep(j,i){
            if(x==0)return 0;
            cout<<i+1<<" "<<j+1<<endl;
            x--;
        }
    }
    
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>k;
    solve();
}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, long long K){
  cout << ((((N/2)+(N%2)) >= K) ? YES : NO) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

namespace AtCoder.ABC044
{
    class ProblemB
    {
        static void Main()
        {
            var texts = ReadLine();
            var ans = texts.GroupBy(v => v).All(v => v.Count() % 2 == 0) ? "Yes" : "No";
            Console.WriteLine(ans);
        }

        public static string ReadLine() => Console.ReadLine();

        public static int ReadInt() => int.Parse(ReadLine());

        public static int[] ReadIntArray() => ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
    }
}


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

using namespace std;

int main()
{
  int N, num[100010] = {0};
  cin >> N;
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    num[a]++, num[b+1]--;
  }
  partial_sum(num, num + 100010, num);
  int ans = 0;
  for(int i = 1; i <= N; i++){
    if(i <= num[i+1]) ans = max(ans, i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1560
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using Deq = deque<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define pf push_front
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

Vec2<ll> graph;

int main(void){
	ll n, m;
	cin >> n >> m;
	graph.resize(n);
	rep(i, m){
		ll a, b;
		cin >> a >> b;
		a--, b--;
		graph[a].pb(b);
		graph[b].pb(a);
	}

	Deq ans;
	ans.pb(0);
	unordered_set<ll> ust;
	ust.insert(0);

	ll node = 0;
	bool flg = true;
	while(flg){
		flg = false;
		for(ll i : graph[node]){
			if(ust.find(i) == ust.end()){
				ans.pb(i);
				ust.insert(i);
				node = i;
				flg = true;
				break;
			}
		}
	}

	node = 0;
	flg = true;
	while(flg){
		flg = false;
		for(ll i : graph[node]){
			if(ust.find(i) == ust.end()){
				ans.pf(i);
				ust.insert(i);
				node = i;
				flg = true;
				break;
			}
		}
	}

	co(ans.size());
	for(ll i : ans) cosp(i + 1);
	co();

	return 0;
}


Measured memory_bytes: 11172
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
long long i[3000000];
lol u[111111];
lol ii[121111];
bool o;
bool ans[5];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h=0,j=0,can;
  string s;
  cin >>a;
  for(int n=0;n<a;n++){
    cin >>s;
    if(s[0]=='Y') o=true;
  }
  if(o) cout <<"Four\n";
  else cout <<"Three\n";
  return (0);
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String... args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	List<Integer> nums = new ArrayList<>();
	int b = (int) (Math.pow(10, 9) / 2);
	while (sc.hasNext()) {
		nums.add(sc.nextInt());
	}

	for (int index = 0 ; index < nums.size() ; index++) {
		int num = nums.get(index);
		int c = 0;
		while (num % 2 == 0) {
			num = num / 2;
			c = c + 1;
		}
		if (c < b) {
			b = c;
		}
	}
	System.out.println(b);

  }
}


Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main(void){
    int n,t;
    cin>>n>>t;
    int MIN=1<<30;
    int root=0,cnt=0;
    
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        MIN=min(a,MIN);
        if(a-MIN>root){
            root=a-MIN;
            cnt=1;
        }
        else if(a-MIN==root){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


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

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    vector<int> V;
    V.push_back(A),V.push_back(B),V.push_back(C);
    sort(V.begin(),V.end());
    for (int i=0; i<K; i++) {
        V[2]*=2;
    }
    cout<<V[0]+V[1]+V[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e9)
using namespace std;
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,T;
    ll c[110], t[110];
    cin >> N >> T;
    rep(i,0,N){
        cin >> c[i] >> t[i];
    }
    ll ans = 1e9;
    rep(i,0,N){
        if(t[i] <= T){
            ans = min(ans, c[i]);
        }
    }
    if(ans == 1e9){
        print("TLE");
    }else{
        print(ans);
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const int N = 200005, mod = 1e9 + 7;
const ll inf = 1e18;
vector<ll> a(N), b(N);
ll n, m, k, ans;
void solve(){
    ans = 0;
    cin >> n >> m >> k;
    a.resize(n);
    b.resize(m);
    for(ll &i : a){
        cin >> i;
    }
    for(ll &i : b){
        cin >> i;
    }
    for(ll i = 1; i < n; i++){
        a[i] += a[i - 1];
    }
    if(b[0] <= k) ans = 1;
    for(ll i = 1; i < m; i++){
        b[i] += b[i - 1];
        if(b[i] <= k) ans = i + 1;
    }
    for(ll i = 0; i < n; i++){
        if(a[i] <= k){
            ll j = lower_bound(all(b), k - a[i]) - b.begin();
            if(j < m && b[j] == k - a[i]) ans = max(ans, i + 2 + j);
            else if(j < m && b[j] > k - a[i]) ans = max(ans, i + 1 + j);
            else if(j == m) ans = max(ans, i + 1 + m);
        }
        else break;
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);//cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 6268
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void AnsYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void AnsYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}







//ここまでライブラリ
//ここから本文





int main() {
	string s;
	cin >> s;
	bool flag = true;
	int cnt = 0;
	if (s.at(0) != 'A') flag = false;
	for (int i = 1; i < s.size(); i++) {
		if (i >= 2 && i <= s.size() - 2) {
			if (s.at(i) == 'C') cnt++;
			else {
				if ('a' > s.at(i) || s.at(i) > 'z') flag = false;
			}
		}
		else {
			if ('a' > s.at(i) || s.at(i) > 'z') flag = false;
		}

	}
	if (cnt != 1) flag = false;
	if (flag == true) cout << "AC" << endl; else cout << "WA" << endl;
}


Measured memory_bytes: 256
N = gets.to_i
A = [nil] + gets.split.map(&:to_i)
B = [nil] + gets.split.map(&:to_i)
C = [nil] + gets.split.map(&:to_i)
ans = 0
for i in 1..N
    ans += B[A[i]]
    if A[i-1] == A[i] - 1
        ans += C[A[i-1]]
    end
end
p ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
	if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += MOD-a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint mpow(ll a, ll b) {
	if (b == 0) return 1;
	mint x = mpow(a, b/2);
	x *= x;
	if (b % 2 == 1) x *= a;
	return x;
}

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

	mint ans = 0;
	for (ll k = 0; k < 60; k++) {
		ll cnt1 = 0;
		rep(i,n) {
			if (v[i] & (1ll << k)) cnt1++;
		}
		ll cnt0 = n - cnt1;
		mint t = cnt0 * cnt1;
		t *= mpow(2,k);
		ans += t;
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =2e6;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

ld n , k;
ld a[maxn];
ld b[maxn];
ld mx = 0 , sum = 0;
queue < int > q;

int main(){
    migmig
    cin >> n >> k;
    for (int i = 0 ; i < n; i ++){
        cin >> a[i];
        b[i] = (1.0 + (ld)a[i]) / (ld)2;
    }
    for (int i = 0 ; i < k ; i ++){
        sum+=b[i];
        q.push(i);
    }
    mx = max(mx , sum);
    for (int i = k ; i < n ; i ++){
        sum-=b[q.front()];
        q.pop();
        sum+=b[i];
        q.push(i);
        mx = max(mx , sum);
    }
    cout << std::setprecision(10) << mx;

    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


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

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a > b) {
        swap(a, b);
    }
    if (a > c) {
        swap(a, c);
    }
    if (b > c) {
        swap(b, c);
    }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 3092
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define divup(a, b) ((a) % (b) == 0 ? (a) / (b) : (a) / (b) + 1)
#define exist_in(list, value) (list.end() != std::find(all(list),value))
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }
//template<class T> bool exist_in(const T& c, const typename T::value_type& v) {	return (c.end() != std::find(c.begin(), c.end(), v));}

/*****/

void Main()
{
	int a, b;
	cin >> a >> b;
	cout << divup(a + b, 2);
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 384
MOD=998244353
def facinv(N):
    fac,finv,inv=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    fac[0]=1;fac[1]=1;finv[0]=1;finv[1]=1;inv[1]=1
    for i in range(2,N+1):
        fac[i]=fac[i-1]*i%MOD
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i]=finv[i-1]*inv[i]%MOD
    return fac,finv,inv

def COM(n,r):
    if n<r or r<0:
        return 0
    else:
        return ((fac[n]*finv[r])%MOD*finv[n-r])%MOD

N,M,K=map(int,input().split())
fac,finv,inv=facinv(N)
mm=[1]
for i in range(N+1):
    mm.append(mm[-1]*(M-1)%MOD)
ans=0
for i in range(K+1):
    ans=(ans+(COM(N-1,N-i-1)*M%MOD*mm[N-i-1]%MOD))%MOD
print(ans)

Measured memory_bytes: 85776
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	string S;
	ll K;
	cin >> S >> K;
	int N = S.size();
	ll ans1 = 0;
	ll ans2 = 0;
	string Stemp = S;
	for (int i = 1; i < N; i++) {
		if (S[i] == S[i - 1]) {
			ans1 += 1;
			S[i] = '-1';
		}
	}
	Stemp[0] = '-1';
	for (int i = 2; i < N; i++) {
		if (Stemp[i] == Stemp[i - 1]) {
			ans2 += 1;
			Stemp[i] = '-1';
		}
	}

	if (S[0] != S[N - 1]) {
		puts(ans1*K);
	}
	else if (Stemp[N-1] != S[0]){
		puts(((K+1)/2LL)*ans1 + (K/2LL)*(ans2+1LL));
	}
	else {
		puts(ans1 + (K-1)*(ans2+1));
	}

	return 0;
}

Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

n = int(readline())
a = np.array(readline().split(), dtype=np.int32)
b = np.array(readline().split(), dtype=np.int32)
c = -np.array(readline().split(), dtype=np.int32)

a.sort()
b.sort()
c.sort()

cnt_a=np.searchsorted(a,b)
cnt_c=np.searchsorted(c,-b)
print((cnt_a*cnt_c).sum())

Measured memory_bytes: 20048
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>

// さんこう :https://beta.atcoder.jp/contests/abc109/submissions/3153889
using namespace std;

typedef long long ll;
ll WARU = 1000000007;

ll N, M;
ll dp[200010][30];

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

map <ll, ll> bunkai;
map <ll, ll> count;

map <ll, ll> fact;

ll req(ll k) {
   ll sum = 1;
   for (ll i=1;i<=k;i++) {
      sum = (i * sum);
   }
   return sum;
}
ll req2(ll k, ll n) {
   ll sum = 1;
   for (ll i=n;i<=k;i++) {
      sum = (i * sum);
   }
   return sum;
}

ll combination(ll n, ll r) {
   if (r == 0 || r ==n )
      return 1;
   else if (r == 1)
      return n;

   if (dp[n][r] > 0) {
      return dp[n][r];
   }
   ll ans = combination(n-1,r-1) + combination(n-1,r);
   ans %= WARU;
   dp[n][r] = ans;
   return ans;
}

int main() {
   cin >> N >> M;
   bunkai = prime_factor(M);
   ll count = 1;
   for (auto itr = bunkai.begin();itr != bunkai.end(); ++itr) {
      //count *= (req2(N-1+itr->second, N) / (req(itr->second))) % WARU;
      count *= combination(N-1+itr->second, itr->second) % WARU;
      count %= WARU;
   }
   cout << count % WARU << endl;
}


Measured memory_bytes: 29568
n,m=map(int,input().split())
a=0
x=[0 for i in range(n)]
y=[0 for i in range(n)]
z=[0 for i in range(n)]
for i in range(n):
    x[i],y[i],z[i]=map(int,input().split())
for i in [-1,1]:
    for j in [-1,1]:
        for k in [-1,1]:
            b=[]
            for l in range(n):
                b.append(x[l]*i+y[l]*j+z[l]*k)
            b.sort()
            b.reverse()
            f=sum(b[0:m])
            a=max(a,f)
print(a)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil -> next;
	while(cur != nil && cur -> key != key){
		cur = cur -> next;
	}
	return cur;
}

void init(){
	nil = new Node;
	nil -> next = nil;
	nil -> prev = nil;
}

void printList(){
	Node *cur = nil -> next;
	int isf = 0;
	while(1){
		if(cur == nil) break;
		if(isf++ > 0) printf(" ");
		printf("%d", cur -> key);
		cur = cur -> next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if(t == nil) return;
	t -> prev -> next = t -> next;
	t -> next -> prev = t -> prev;
	delete(t);
}

void deleteFirst(){
	deleteNode(nil -> next);
}

void deleteLast(){
	deleteNode(nil -> prev);
}

void deleteKey(int key){

	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x = new Node;
	x -> key = key;

	x -> next = nil -> next;
	nil -> next -> prev = x;
	nil -> next = x;
	x -> prev = nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for(i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		if(com[0] == 'i') {insert(key); np++; size++;}
		else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F') deleteFirst();
				else if(com[6] == 'L') deleteLast();
			}else{
				deleteKey(key); nd++;
			}
			size--;
		}
	}

	printList();

	return 0;
}

Measured memory_bytes: 33824
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m:usize,
        mut a:[i64;n],
        mut p:[(i64,i64);m],
    }

    a.sort();
    p.sort_by(|x,y| x.1.cmp(&y.1));
    let mut p_i = m-1;
    let mut ans = 0;
    let mut flag = false;

    for i in 0..n{
        let x = a[i];
        let y = p[p_i].1;

        if x >= y || flag{
            ans += x;
        }else{
            ans += y;
            p[p_i].0 -= 1;
        }

        if p[p_i].0 == 0{
            if p_i == 0{
                flag = true;
            }else{
                p_i -= 1;
            }
        }
    }

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


Measured memory_bytes: 7516
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  int ans=0;
  rep(i,N-1){
    if(S[i]==S[i+1]) ans++;
  }
  ans=min(N-1,ans+2*K);
  cout<<ans<<endl;
}



Measured memory_bytes: 512
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int[][] x = new int[n][d];
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < d ; j++){
                x[i][j] = sc.nextInt();
            }
        }
        int ebishu = 0;
        sc.close();
        for(int i = 0 ;i < n ; i++){
            for(int j = 0 ; j < i ; j++){
                double yono = 0;
                for(int k = 0 ; k < d ; k++){
                    yono += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
                }
                yono = Math.sqrt(yono);
                if(yono % 1 == 0){
                    ebishu++;
                }
            }
        }
        System.out.println(ebishu);
    }
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=310,M=1000010;
const int inf=0x3f3f3f3f;
inline ll read();
inline void write(ll x);
inline void writeln(ll x);

int n,m,ans=inf;
int a[N][N];
int num[N];
int pos[N];
bool del[N];

inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^48);
	if(flag) return -s;
	return s;
}
inline void write(ll x)
{
	if(!x)
	{
		putchar('0'),putchar(' ');
		return ;
	}
	if(x<0) putchar('-'),x=-x;
	char ch[20];
	int tot=0;
	while(x) ch[++tot]=x%10,x/=10;
	for(int i=tot;i;--i) putchar(ch[i]^'0');
	putchar(' ');
}
inline void writeln(ll x)
{
	write(x);
	putchar('\n');
}

int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)
	{
		pos[i]=1;
		for(int j=1;j<=m;j++) a[i][j]=read();
	}
	bool yes=false;
	while(1)
	{
		for(int i=1;i<=n;i++) num[a[i][pos[i]]]++;
//		for(int i=1;i<=n;i++) write(pos[i]);
//		putchar('\n');
		int maxn=0;
		for(int i=1;i<=m;i++) maxn=max(maxn,num[i]);
		ans=min(ans,maxn);
		for(int i=1;i<=m;i++)
		{
			if(num[i]==maxn) del[i]=true;
			num[i]=0;
		}
		for(int i=1;i<=n;i++)
		{
			while(del[a[i][pos[i]]]&&pos[i]<=m) pos[i]++;
			if(pos[i]>m)
			{
				yes=true;
				break;
			}
		}
		if(yes) break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main() {

    int n;
    int a[100], b[100];
    scanf("%d", &n);

    int count = 0;
    for (int i = 0; i < n - 1; i++) {
        scanf("%d", &b[i]);
    }

    a[0] = b[0];
    a[1] = b[0];
    for (int i = 1; i < n; i++) {
        a[i + 1] = b[i];
        if (a[i] > b[i]) {
            a[i] = b[i];
        }
    }
    a[n - 1] = b[n - 2];

    int sum;
    for (int i = 0; i < n; i++) {
        // printf("%d ", a[i]);
        sum = sum + a[i];
    }
    printf("\n");
    printf("%d", sum);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k=-(scan.nextInt());
		int x=scan.nextInt();
		for(int i=k+1;i<-k;i++){
			System.out.println(x+i);
		}
	}
}


Measured memory_bytes: 22740
using System;
class AGC_033_B
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int H = int.Parse(input[0]);
        int W = int.Parse(input[1]);
        int N = int.Parse(input[2]);

        string[] input2 = Console.ReadLine().Split(' ');
        int sr = int.Parse(input2[0]);
        int sc = int.Parse(input2[1]);

        string S = Console.ReadLine();
        string T = Console.ReadLine();

        int TL = 0;
        int TR = 0;
        int TU = 0;
        int TD = 0;

        int AL = 0;
        int AR = 0;
        int AU = 0;
        int AD = 0;

        Action[] Takahashi = new Action[N];
        Action[] Aoki = new Action[N];

        for (int i = 0; i < N; i++)
        {
            if (S[i] == 'L') TL++;
            else if (S[i] == 'R') TR++;
            else if (S[i] == 'U') TU++;
            else if (S[i] == 'D') TD++;

            if (T[i] == 'L' && sc + TR - AL > 1) AL++;
            else if (T[i] == 'R' && sc - TL + AR < W) AR++;
            else if (T[i] == 'U' && sr + TD - AU > 1) AU++;
            else if (T[i] == 'D' && sr - TU + AD < H) AD++;

            Takahashi[i] = new Action(TL, TR, TU, TD);
            Aoki[i] = new Action(AL, AR, AU, AD);
        }

        bool result = false;
        for (int i = 0; i < N; i++)
        {
            Action TakahashiAction = Takahashi[i];
            Action AokiAction = i==0 ?  new Action(0,0,0,0) :Aoki[i-1];


            if (sc - TakahashiAction.L + AokiAction.R <= 0)
            {
                result = true;
                break;
            }

            if (sc + TakahashiAction.R - AokiAction.L > W)
            {
                result = true;
                break;
            }

            if (sr - TakahashiAction.U + AokiAction.D <= 0)
            {
                result = true;
                break;
            }

            if (sr + TakahashiAction.D - AokiAction.U > H)
            {
                result = true;
                break;
            }

        }

        if (result)
        {
            Console.WriteLine("NO");
        }
        else
        {
            Console.WriteLine("YES");
        }
    }
}

struct Action
{
    public int L,R,U,D;

    public Action(int l, int r, int u, int d)
    {
        L = l;
        R = r;
        U = u;
        D = d;
    }
}

Measured memory_bytes: 18656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,i;
	cin>>a>>b>>c;
	for(i=1;i<=1000;i++)
	{
		if(a*i%b==c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

#define INF 1e9+7
int dist[110][110];

int main(){
    
    int N,M; cin >> N >> M;
    REP(i,110)REP(j,110) dist[i][j] = INF;
    for(int i=1;i<=N;i++) dist[i][i] = 0;
    
    vector<int> a(M),b(M),c(M);
    REP(i,M) cin >> a[i] >> b[i] >> c[i];
    REP(i,M) dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
    
    for(int k=1;k<=N;k++){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    
    int ans=0;
    REP(k,M){
        bool flag = false;
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                int l1 = dist[i][j];
                int l2 = dist[i][a[k]] + c[k] + dist[b[k]][j];
                if(l1==l2)flag = true;
            }
        }
        if(flag)ans++;
    }
    
    cout<<M-ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}


int32_t main()
{
  io
int s,w;
cin>>s>>w;
if(w>=s)
{
  cout<<"unsafe"<<endl;
}else cout<<"safe"<<endl;

}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
int n,x,a[2][100010],mx1[2],mx2[2];
int read() {
    int tmp=0, fh=1; char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
    while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
    return tmp*fh;
}
int main() {
	n=read();
	for (int i=1;i<=n;i++) {
		x=read(); a[i&1][x]++;
		if (a[i&1][x]>a[i&1][mx1[i&1]]) {
			mx2[i&1]=mx1[i&1]; mx1[i&1]=x;
		} else if (x!=mx1[i&1]&&a[i&1][x]>a[i&1][mx2[i&1]]) mx2[i&1]=x;
	}
	if (mx1[0]!=mx1[1]) printf("%d\n",n-a[0][mx1[0]]-a[1][mx1[1]]);
	else printf("%d\n",n-max(a[0][mx2[0]]+a[1][mx1[1]],a[0][mx1[0]]+a[1][mx2[1]]));
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int l[n];
    int mx = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        sum += l[i];
        mx = max(mx, l[i]);
    }

    if (mx < sum - mx) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, x, y = map(int, input().split())
    c *= 2
    if a + b > c:
        cost1 = max(x, y) * c
        cost2 = min(x, y) * c
        plus = ((y - x) * b) if x < y else (x - y) * a
        res = min(cost1, cost2 + plus)
    else:
        res = x * a + y * b
    print(res)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {

	set <string> s;
	ll n;
	cin >> n;
	for (ll i = 0; i < n; i++) {
		string t;
		cin >> t;
		s.insert(t);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 19224
#include<stdio.h>
#include<string.h>
 
int main(void){
 
  int i;
  char str[1200];
 
  gets(str);

  for(i=0;i<=strlen(str);i++){
    if(str[i]>=97 && str[i]<=122)
      str[i]=str[i]-32;
  	else if(str[i]>=65 && str[i]<=90)
  	  str[i]=str[i]+32;
  }
  printf("%s\n", str);
 
  return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(void) {

	int diceo[6];
	int dicet[6];
	int i, j, k, a;
	int tatea[7] = { 0, 1, 5, 4, 0, 1, 5 };
	int tateb[7] = { 0, 4, 5, 1, 0, 4, 5 };
	int yokoa[7] = { 1, 2, 4, 3, 1, 2, 4 };
	int yokob[7] = { 1, 3, 4, 2, 1, 3, 4 };
	int hokaa[7] = { 0, 2, 5, 3, 0, 2, 5 };
	int hokab[7] = { 0, 3, 5, 2, 0, 3, 5 };
	int ue[6] = { 2, 3, 0, 5, 4, 1 };
	int ty[7];
	int idice[4];
	int co = 0;
	int diceoto = 0;
	int dicetto = 0;

	for (i = 0; i < 6; i++) {
		scanf("%d", &diceo[i]);
		diceoto += diceo[i];
	}

	for (i = 0; i < 6; i++) {
		scanf("%d", &dicet[i]);
		dicetto += dicet[i];
	}

	for (i = 0; i < 6; i++) {
		if (diceoto != dicetto) break;
		for (j = 0; j < 7; j++) {
			switch (i) {
			case 0:
				ty[j] = tatea[j];
				break;
			case 1:
				ty[j] = tateb[j];
				break;
			case 2:
				ty[j] = yokoa[j];
				break;
			case 3:
				ty[j] = yokob[j];
				break;
			case 4:
				ty[j] = hokaa[j];
				break;
			case 5:
				ty[j] = hokab[j];
				break;
			}
		}
		for (j = 0; j < 4; j++) {
			for (k = 0; k < 4; k++) {
				idice[k] = dicet[ty[k + j]];
			}
			for (k = 0; k < 4; k++) {
				if (idice[k] != diceo[yokoa[k]]) break;
				if ((idice[3] == diceo[yokoa[3]]) && (k = 3)) co++;
			}
			if (co == 1) break;
		}
		if (co == 1) break;
	}
	if (dicet[ue[i]] == diceo[0]) co++;
	if (co == 2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> mao(n);
  for (int i=0; i<n; i++)
    cin>> mao.at(i);
  
  
  vector<int> mao2=mao;
  sort(mao2.begin(),mao2.end());
  
  int z=0;
  for (int i=0; i<n;i++)
    if (mao.at(i)!=mao2.at(i)) z++;
  
  if (z==0 || z==2) cout<< "YES"<<endl;
  else cout<< "NO"<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::vector<int>a(3);

int main()
{
	in >> a[0] >> a[1] >> a[2];
	std::sort(a.begin(), a.end());
	out << a[2] - a[1] + a[1] - a[0] << std::endl;
	return 0;
}


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


int main (void){
    ll n, k;
    cin >> n>> k;
    vector<ll> a(n);
    ll ans[n + 5] = {};


    rep(i,n){
        cin >> a[i];
    }


    if (k >= n){
        cout << 0 << endl;
        return 0;
    }


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

    ans[0] = a[0];
    for(int i=1;i<n-k;i++){
        ans[i] += (ans[i - 1] + a[i]);
    }
    cout << ans[n-k-1] << endl;
    return 0;
}

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

using namespace std;

const int MAXN = 1001;

int H, N, A[MAXN], B[MAXN];

int dp[1001][10001];

int solve(int i, int h) {

	if (h <= 0) {
		return 0;
	}

	if (i >= N) {
		return 0x3f3f3f3f;
	}

	int &p = dp[i][h];
	if (p != -1) return p;

	int a = solve(i + 1, h);
	int b = solve(i, h - A[i]) + B[i];

	return p = min(a, b);
}

int main () {

	scanf("%d %d", &H, &N);

	for (int i = 0; i < N; ++i) 
		scanf("%d %d", &A[i], &B[i]);
	
	memset(dp, -1, sizeof(dp));

	printf("%d\n", solve(0, H));

	return 0;
	
}
 

Measured memory_bytes: 39808
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])

s = 0
ans = 0
for abi in ab:
    a, b = map(int, abi)
    if s + b < m:
        s += b
        ans += a * b
    else:
        ans += a * (m - s)
        break

print(ans)

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

int main() {
    int N; cin >> N;
    vector<int> id(N + 1);
    rep(i, 1, N + 1) {
        int a; cin >> a;
        id[a] = i;
    }
    set<long long> st;
    st.insert(0);
    st.insert(N + 1);
    long long ans = 0;
    rep(i, 1, N + 1) {
        long long v = id[i];
        auto it = st.lower_bound(v);
        auto jt = prev(it);
        long long add = (v - *jt) * (*it - v);
        ans += add * i;
        st.insert(v);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368