akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long
const int M = 1000000007;

class Scc{
	private:
		static const int MAX_V = 10000;
		vector<int> g[MAX_V];	//??°??????
		vector<int> rg[MAX_V];	//?????????????????£?????°??????
		vector<int> vs;			//??°?????????????????????
		vector<pair<int, int>> edge;
		bool used[MAX_V];

		void rdfs(int v, int k){
			used[v] = true;
			cmp[v] = k;
			rep(i,rg[v].size()){
				if(not used[rg[v][i]]) rdfs(rg[v][i], k);
			}
		}
		void dfs(int v){
			used[v] = true;
			rep(i,g[v].size()){
				if(not used[g[v][i]]) dfs(g[v][i]);
			}
			vs.emplace_back(v);
		}
		void buildGraph(){
			for(auto i : edge){
				if(cmp[i.first] == cmp[i.second]) continue;
				dag[ cmp[i.first] ].emplace_back(cmp[i.second]);
			}
		}
	public:
		vector<int> dag[MAX_V]; //?????£?????????????§£????????£?????????DAG??°??????
		int cmp[MAX_V]; //?±????????????£????????????????????????????????????

		void addEdge(int from, int to){
			edge.emplace_back(from,to);
			g[from].emplace_back(to);
			rg[to].emplace_back(from);
		}
		int solve(int v){ //scc??????????????°?????????
			memset(used, 0, sizeof(used));
			vs.clear();
			rep(i,v){
				if(not used[i]) dfs(i);
			}
			memset(used, 0, sizeof(used));
			int k = 0;
			for(int i = vs.size() - 1; i >= 0; i--){
				if(not used[vs[i]]) rdfs(vs[i], k++);
			}
			buildGraph();
			return k;
		}
};

pair<int, int> dfs(int cur, vector<bool>& used, Scc& scc){
	used[cur] = true;
	pair<int, int> res = make_pair(1,1);
	for(auto to : scc.dag[cur]){
		if(used[to]) continue;
		pair<int, int> tmp = dfs(to, used, scc);
		res.first *= tmp.first + tmp.second;
		res.first %= M;
	}
	return res;
}

signed main(){
	int n, m;
	while(cin >> n >> m){
		Scc scc;
		rep(i,m){
			int a, b;
			cin >> a >> b;
			a--; b--;
			scc.addEdge(b,a);
		}

		int k = scc.solve(n);

		int ans = 1;
		vector<bool> used(n,0);
		rep(i,k){
			if(used[i]) continue;
			pair<int, int> tmp = dfs(i, used, scc);
			//show(tmp.first + tmp.second)
			ans *= tmp.first + tmp.second;
			ans %= M;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3984
#include<stdio.h>

int main(){
  char s[11];
  scanf("%s",s);
  int max=0;
  int count=0;
  for(int i=0;s[i]!='\0';i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      count++;
      if(max<count){
        max=count;
      }
    }else{
      count=0;
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	vector<ll> arr(n, 0);
	f(i, 0, n)
		cin >> arr[i];
	ll count = 0;
	ll one=0, two=0;
	f(i, 0, n-1)
	{
		if (arr[i] > arr[i + 1])
		{
			count += 1;
			if (count == 1)
				one = i;
			else
				two = i+1;
		}
	}
	if (count > 2)
	{
		cout << "NO";
		return 0;
	}
	else
	{
		ll temp = arr[one];
		arr[one] = arr[two];
		arr[two] = temp;
		string flag = "YES";
		f(i, 0, n-1)
		{
			if(arr[i]>arr[i+1])
			{
				flag = "NO";
				break;
			}
		}
		cout << flag;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    while (n != "0") {
        int result = 0;

        for (int i = 0; i < n.size(); i++)
            result += n[i] - '0';

        cout << result << endl;

        cin >> n;
    }

    return 0;
}




Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  for(int i=0;i<B;i++){
    for(int j=0;j<A;j++)cout<<0;
    for(int j=A;j<W;j++)cout<<1;
    cout<<endl;
  }
  for(int i=B;i<H;i++){
    for(int j=0;j<A;j++)cout<<1;
    for(int j=A;j<W;j++)cout<<0;
    cout<<endl;
  }
}

Measured memory_bytes: 3624
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
using llint = long long int;
using lint = long int;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>
#include <limits>
#include <type_traits>
using namespace std;

int gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main() {
	int n;
	cin >> n;
	vector<lint> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int max_a = a[0];
	int max_b = a[1];
	int max_c = gcd(a[0], a[1]);
	for (int i = 2; i < n; i++) {
		int a_new = max(gcd(a[i], max_a), gcd(a[i], max_b));
		int b_new = max_c;
		int c_new = gcd(max_c, a[i]);
		max_a = a_new;
		max_b = b_new;
		max_c = c_new;
	}
	cout << max({max_a, max_b, max_c}) << endl;
	
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
map<ll,ll> mp;
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        ll a;
        cin>>a;
        mp[a]++;
    }
    for(auto p:mp){
        if(p.second>1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    int r[n];
    rep(i,n) cin >> r[i];
    
    int cnt = 0;
    rep(i,n){
        int minj = i;
        for(int j=i;j<n;j++){
            if(r[j]<r[minj]) minj = j;
        }
        if(r[i]>r[minj]){
            swap(r[i],r[minj]);
            cnt++;
        }
    }
    
    rep(i,n) cout << r[i] << (i != n-1 ? ' ' : '\n');
    cout << cnt << endl;
}







Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,W;
    cin>>n>>W;
    long long int v[n],w[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    long long int dp[n+1][W+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(i==0||j==0){
                dp[i][j]=0;
            }
            else if(w[i-1]<=j){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]]+v[i-1]);
            }
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 82296
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n;
    cin>>n;
    vector<ll> vec(n);
    ll ans = 1;
    for(int i = 0; i < n; i++){
        cin>>vec[i];
        if(vec[i] == 0){
            cout<<"0";
            return ;
        }
    }
    // sort(vec.begin(), vec.end());
    for(ll k : vec){
        if(ans > INF/k){
            cout<<-1;
            return ;
        }
        ans *= k;
    }
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 4012
fun main(args: Array<String>) {
    abc143c()
}

fun abc143c() {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var cnt = 1
    for (i in 1..s.lastIndex) if (s[i - 1] != s[i]) cnt++

    println(cnt)
}


Measured memory_bytes: 34124
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> Ais(N);
    rep(i,0,N) {
        cin >> Ais[i];
    }
    vector<ll> sums(N+1);
    rep(n,1,N+1) {
        sums[n] = sums[n-1] + Ais[n-1];
    }
    vector<ll> subsums;
    subsums.reserve(N*(N+1)/2);
    rep(i,0,N) {
        rep(j,i+1,N+1) {
            // [i,j)
            subsums.push_back(sums[j]-sums[i]);
        }
    }
    assert(subsums.size() == N*(N+1)/2);
    vector<ll> left;
    left.reserve(N*(N+1)/2);
    ll ans = 0;
    rrep(bit,63,0) {
        rep(i,0,subsums.size()) {
            if (subsums[i] & ((ll)1 << bit)) {
                left.push_back(subsums[i]);
            }
        }
        if (left.size() >= K) {
            ans |= ((ll)1 << bit);
            swap(left, subsums);
        }
        left.clear();
    }
    cout << ans << endl;
}




Measured memory_bytes: 6656
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
int x,k,q,r[100010],maxn[100010],mini[100010],c[100010];
int rd(){
	int x=0;
	char c;
	do c=getchar();
	while(!isdigit(c));
	do{
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}while(isdigit(c));
	return x;
}
void InitInput(){
	x=rd(),k=rd();
	for(int i=1;i<=k;i++)
		r[i]=rd();
	maxn[0]=x,r[0]=mini[0]=c[0]=0;
	for(int i=1;i<=k;i++){
		maxn[i]=maxn[i-1];
		mini[i]=mini[i-1];
		if(i&1){
			mini[i]=max(mini[i],min(r[i]-r[i-1]-c[i-1],maxn[i]));
			c[i]=max(c[i-1]+mini[i-1]-r[i]+r[i-1],0)-mini[i];
		}else{
			maxn[i]=min(maxn[i],max(x-r[i]+r[i-1]-c[i-1],mini[i]));
			c[i]=min(c[i-1]+maxn[i-1]+r[i]-r[i-1],x)-maxn[i];
		}
	}
	return;
}
void Ask(){
	q=rd();
	for(int i=1;i<=q;i++){
		int t=rd(),a=rd();
		int pos=upper_bound(r+1,r+k+1,t)-r-1,ans=c[pos];
		if(a<=mini[pos])
			ans+=mini[pos];
		else if(a>=maxn[pos])
			ans+=maxn[pos];
		else
			ans+=a;
		if(pos&1)
			ans=min(x,ans+t-r[pos]);
		else ans=max(0,ans-t+r[pos]);
		printf("%d\n",ans);
	}
}
int main(){
	InitInput();
	Ask();
	return 0;
}

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

int main(void)
{
  long long int a,b,n,ans,x;
  scanf("%lld %lld %lld",&a,&b,&n);
  if(b <= n)
    {
      x = b-1;
    }
  else
    {
      x = n;
    }
  ans = a*x / b;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1728
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
m = 0
for i in range(1, len(A)):
    if A[i]-A[i-1]>m:
        m=A[i]-A[i-1]
if K-A[-1]+A[0]>m:
    print(A[-1]-A[0])
else:
    print(K-m)


Measured memory_bytes: 26444
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
int rint();char rch();long long rlong();
int main() 
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s; cin>>s;
  int n=s.length();
  int a=0,b=0,c=0;
  for (int i=0;i<n;i++) {
    char x=s[i];
    if (x=='a')a++;
    if (x=='b')b++;
    if (x=='c')c++;
  }
  int lo=min({a,b,c});
  int hi=max({a,b,c});
  if (hi-lo<=1) printf("YES\n");
  else printf("NO\n");
}




static char stdinBuffer[1024];
static char* stdinDataEnd = stdinBuffer + sizeof (stdinBuffer);
static const char* stdinPos = stdinDataEnd;

void readAhead(size_t amount)
{
    size_t remaining = stdinDataEnd - stdinPos;
    if (remaining < amount) {
       memmove(stdinBuffer, stdinPos, remaining);
       size_t sz = fread(stdinBuffer + remaining, 1, sizeof (stdinBuffer) - remaining, stdin);
       stdinPos = stdinBuffer;
       stdinDataEnd = stdinBuffer + remaining + sz;
       if (stdinDataEnd != stdinBuffer + sizeof (stdinBuffer))
         *stdinDataEnd = 0;
    }
}

int rint()
{
    readAhead(16);

    int x = 0;
    bool neg = false;
    while(*stdinPos==' '||*stdinPos=='\n') ++stdinPos;
    if (*stdinPos == '-') {
       ++stdinPos;
       neg = true;
    }

    while (*stdinPos >= '0' && *stdinPos <= '9') {
       x *= 10;
       x += *stdinPos - '0';
       ++stdinPos;
    }

    return neg ? -x : x;
}
char rch()
{
    readAhead(16);
    while(*stdinPos==' '||*stdinPos=='\n') ++stdinPos;
    char ans=*stdinPos;
    ++stdinPos;
    return ans;
}
long long rlong()
{
    readAhead(32);

    long long x = 0;
    bool neg = false;
    while(*stdinPos==' '||*stdinPos=='\n') ++stdinPos;
    if (*stdinPos == '-') {
       ++stdinPos;
       neg = true;
    }

    while (*stdinPos >= '0' && *stdinPos <= '9') {
       x *= 10;
       x += *stdinPos - '0';
       ++stdinPos;
    }

    return neg ? -x : x;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll N,M;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M;
	ll lb=1,ub=N;
	REP(i,M){
		ll l,r;
		cin>>l>>r;
		lb=max(lb,l);
		ub=min(ub,r);
	}
	cout<<max(ub-lb+1,0ll)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		mp[a]=1;
	}
	cout<<mp.size();
	return 0;
}

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

int gcd(int x, int y){

  if(y > x) swap(x, y);

  while(y != 0){
    int p = x % y;
    x = y;
    y = p;
  }

  return x;

}

int main(){

  int n, a[111111], r[111111] = {}, l[111111] = {}, ans = 0;

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

  for(int i=0;i<n;i++) l[i+1] = gcd(l[i], a[i]);
  for(int i=n-1;i>=0;i--) r[i] = gcd(r[i+1], a[i]);

  // for(int i=0;i<n;i++) cout << l[i] << " ";
  // cout << endl;
  //
  // for(int i=0;i<n;i++) cout << r[i] << " ";
  // cout << endl;

  for(int i=0;i<n;i++) ans = max(ans, gcd(l[i], r[i+1]));

  cout << ans << endl;

}

Measured memory_bytes: 1536
h,w = map(int,input().split())
l = []
for i in range(h):
  x = list(input())
  if "#" in x:
    l.append(x)

for j in range(w):
  if all(l[k][j] == "." for k in range(len(l))):
    for k in range(len(l)):
      l[k][j] = ""
for m in range(len(l)):
  print(''.join(l[m]))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <stdio.h>
#include <iomanip>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    ll N, K;
    cin >> N >> K;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    vector<ll> cnt(N);
    vector<ll> cnt2(N);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(v[i] > v[j]){
                if(i < j) cnt[i]++;
                if(i > j) cnt2[i]++;
            }
        }
    }

    ll mul  = (K + 1) * K / 2;
    ll mul2 = (K - 1) * K / 2;
    mul  %= 1000000007;
    mul2 %= 1000000007;

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans +=  cnt[i] * mul;
        ans += cnt2[i] * mul2;
        ans %= 1000000007;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(500000)

n,x= map(int,input().split())
a = input().rstrip().split()
b = [0]*n
# a
for i in range(0,n):
    b[i]=abs(int(a[i])-x)
b.sort()#昇順

def GCD(a,b):
    if b == 0:
        return a
    return GCD(b,a%b)

def multi_GCD(le):
    # print(le)
    if len(le)==1:
        return
    mxle=le[-1]
    del(le[-1])
    le[-1]=GCD(le[-1],mxle)
    multi_GCD(le)

if(len(b)==1):
    print(b[0])
if(len(b)==2):
    print(GCD(b[0],b[1]))
if(len(b)>2):
    multi_GCD(b)
    print(b[0])


Measured memory_bytes: 96400
def m():
    n = int(input())
    s = [int(input()) for _ in range(n)]
    tens = 0
    others = []
    for i in range(n):
        if s[i] % 10 == 0:
            tens += s[i]
        else:
            others.append(s[i])
    if len(others) == 0:
        return 0
    total = tens + sum(others)
    if total % 10 == 0:
        return total - min(others)
    else:
        return total
print(m())

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

using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int val[maxn];
ll dp[maxn];

int main()
{
	ios::sync_with_stdio(false);
	int n,k;
	while(cin>>n>>k){
		for(int i=0;i<n;i++){
			cin>>val[i];
		}
		dp[0]=0;
		for(int i=1;i<n;i++){
			dp[i]=inf;
		}
		for(int i=1;i<n;i++){
			for(int j=1;j<=k&&(i-j>=0);j++){
				dp[i]=min(dp[i],abs(val[i]-val[i-j])+dp[i-j]);
			}
		}
		cout<<dp[n-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

int main() {
	vector<bool> a(200000, true);
	a[0] = a[1] = false;
	for (int i = 2; i < 200000; i++)
		if (a[i])
			for (int j = i * 2; j < 200000; j += i)
				a[j] = false;
	vector<int> p;
	for (int i = 0; i < 200000; i++)
		if (a[i]) p.push_back(i);
	for (;;) {
		int N, P; cin >> N >> P;
		if (N == -1) break;
		int k = upper_bound(p.begin(), p.end(), N) - p.begin();
		vector<int> v;
		for (int i = 0; i < P; i++)
			for (int j = i; j < P; j++)
				v.push_back(p[k + i] + p[k + j]);
		sort(v.begin(), v.end());
		cout << v[P - 1] << endl;
	}
}

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

#include <bits/stdc++.h>

using namespace std;

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

void d_err() {
    cerr << endl;
}

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

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

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

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

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

    sort(ALL(A), greater<>());

    ll ans = 0;

    ans += A[0];
    if (N == 2) {
        print(ans);
        return 0;
    }

    int idx = 0;
    REP(i, N - 2) {
        if (i % 2 == 0) idx++;
        ans += A[idx];
    }

    print(ans);
    
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int a,b,ans=1;
signed main(){
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    b--;
    int ans=(b+a-2)/(a-1);
    cout<<ans<<endl;
    return 0;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct range{
  int l,r;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  return (p->r-p->l)-(q->r-q->l);
}

void add(int *bit,int l,int r){
  int i;
  for(i=l;i<=bit[0];i+=i&-i) bit[i]++;
  for(i=r;i<=bit[0];i+=i&-i) bit[i]--;
  return;
}

int get(int *bit,int index){
  int res=0;
  int i;
  for(i=index;i>0;i-=i&-i) res+=bit[i];
  return res;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  node *array=(node *)malloc(sizeof(node)*n);
  int i;
  for(i=0;i<n;i++){
    int l,r;
    scanf("%d%d",&l,&r);
    array[i].l=l;
    array[i].r=r;
  }
  qsort(array,n,sizeof(node),cmp);
  int *bit=(int *)calloc(m+2,sizeof(int));
  bit[0]=m+1;
  int d;
  for(d=1,i=0;d<=m;d++){
    while(i<n && array[i].r-array[i].l+1<d){
      add(bit,array[i].l,array[i].r+1);
      i++;
    }
    int ans=n-i;
    int j;
    for(j=d;j<=m;j+=d){
      ans+=get(bit,j);
    }
    printf("%d\n",ans);
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 4860
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  vector<int> L(n), R(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  L[0] = a[0];
  for (int i = 1; i < n; ++i) L[i] = max(L[i - 1], a[i]);
  R[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; --i) R[i] = max(R[i + 1], a[i]);
  vector<int> ret(n);
  ret[0] = R[1];
  ret[n - 1] = L[n - 2];
  for (int i = 1; i < n - 1; ++i) {
    ret[i] = max(L[i - 1], R[i + 1]);
  }
  for (int i = 0; i < n; ++i) {
    printf("%d\n", ret[i]);
  }
  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
double n, m, d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> d;
  dout((m-1)*(n-d)*(1+(d>0))/n/n);
}

Measured memory_bytes: 256
main = getLine >>= putStrLn . f . (\(a, b) -> (read a, read b)) . splitAt 2
  where
    f :: (Int, Int) -> String
    f (a, b)
      | inMonth a && inMonth b =  "AMBIGUOUS"
      | not (inMonth a) && inMonth b =  "YYMM"
      | inMonth a && not (inMonth b) =  "MMYY"
      | otherwise = "NA"
    inMonth x = 1 <= x && x <= 12


Measured memory_bytes: 508
#include<stdio.h>

int main(void) {
	char integer[4];
	unsigned char n;
	char YorN = 0;

	//3桁の整数を入力
	scanf("%s", &integer);
	//いずれかの桁に7を含むか調べる
	for (n = 0;n < 3;n++) {
		if (integer[n] == '7') {
			YorN = 1;
		}
	}
	//7が含まれるならYes,含まれないならNoを出力
	if (YorN == 1) {
		printf("\nYes\n");
	}
	else if (YorN == 0) {
		printf("\nNo\n");
	}
	else {}

	return 0;
}

Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int k = 0;
  while (n > 0) {
    k++;
    n -=k;
  }
  if (n < 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << k + 1 << endl;
  vector<vector<int>> s(k + 1, vector<int>(0));
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = i + 1; j <= k; j++) {
      cnt++;
      s[i].push_back(cnt);
      s[j].push_back(cnt);
    }
  }
  for (int i = 0; i <= k; i++) {
    cout << k << ' ';
    for (int j = 0; j < k; j++) {
      cout << s[i][j] << (j < k - 1 ? ' ' : '\n');
    }
  }
  cout << flush;
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  if(n % 2) cout << n/2 << endl;
  else cout << n/2 - 1 << endl;
}


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

N = int(input())
A = [int(input()) for _ in range(N)]
ans = A[0] - 1
P = 2
for i in range(1, N):
    if A[i] == P:
        P += 1
        continue
    ans += (A[i]-  1) // P
print(ans)

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

int main(){
    int n,m;
    cin >>n>>m;
    vector<vector<int> >H(n+1, vector<int>(m+1));
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >>H[i][j];
        }
    }
    for(int i=0; i<n; i++){
        int sum=0;
        for(int j=0; j<m; j++){
            sum+=H[i][j];
        }
        H[i][m] = sum;
    }
    for(int i=0; i<m; i++){
        int sum=0;
        for(int j=0; j<n; j++){
            sum+=H[j][i];
        }
        H[n][i] = sum;
    }
    for(int i=0; i<n; i++){
        H[n][m] += H[i][m];
    }
    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            if(j!=m){
                cout <<H[i][j] <<" ";
            }if(j==m){
                cout <<H[i][j];
            }
        }
        cout << endl;
    }
    
    
}


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

using namespace std;

int main()
{

	unsigned long long int a = 1, b = 0, c = 100, d = 0, e = 0, maxy = 0, min = 0, ans = 1, count = 0;

	int yoko = 0, tate = 0;
	int array[1001] = { 0 };
	std::string output, output2, output3, input = {};
	bool okada = false;


	cin >> a >> b;
	
	if (a >= b / 2) {
		cout << b/2 << endl;
	}
	else {
		cout << a + (b - a * 2) / 4 << endl;
	}

}






Measured memory_bytes: 256
N = int(input())

tmp = [0,0,0]
ans = 0
for i in range(N):
    s = input()
    ans += s.count("AB")
    if s.endswith("A") and s.startswith("B"):
        tmp[0] += 1
    elif s.endswith("A"):
        tmp[1] += 1
    elif s.startswith("B"):
        tmp[2] += 1


if tmp[0] > 0:
    ans += tmp[0] - 1

    if tmp[1] > 0:
        ans += 1
        tmp[1] -= 1

    if tmp[2] > 0:
        ans += 1
        tmp[2] -= 1

ans += min(tmp[1], tmp[2])
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<(n);i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
  int x;
  cin >> x;
  if(x==0){
    cout << '1' << endl;
  }
  else{
    cout << '0' << endl;
  }
  return 0;
}

Measured memory_bytes: 3664
def main():
    S = input()
    T = input()
    items = {}
    items2 = {}
    can = True
    for s, t in zip(S, T):
        if s in items2:
            if items2[s] == t:
                continue
            can = False
            break
        if t in items:
            if items[t] == s:
                continue
            can = False
            break
        items[t] = s
        items2[s] = t
    if can:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int func(int x){
    if(x%2==1)return 0;
    return func(x/2)+1;
}
int main(){
    int n;
    cin>>n;
    int ans=1;
    for(int i=1;i<=n;i++)if(func(i)>func(ans))ans=i;
    cout<<ans<<endl;
}

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

int main() {
  
  string s;
  cin >> s;
  
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
    cout << "Yes" << endl;				
  }
  else{
    cout << "No" << endl;
  }
  
  
  
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,N) for(i=0;i<N;i++)

ll N,K;

int main(void){
  cin >> N >> K;
  vector<ll> A(N);
  ll i,j,k,X=0,sum;
  FOR(i,N) cin >> A[i];
  for(j=1;K/j!=0;j=j*2){
    k=0;
    FOR(i,N){
      //k：各桁の1の数
      k += A[i]/j % 2;
    }
    if(k < (N+1)/2) X += j;
  }
  for(j/=2;X>K;j/=2){
    if(X/j % 2 > K/j %2){
      X-=j;
    }
  }
  sum = 0;
  FOR(i,N){
    sum += X ^ A[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
/*
TASK: Derangement
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define EPS 1e-9
#define ALL(x) (x).begin(),(x).end()
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define FOR(i,st,ed) for(int (i)=(st);(i)<(ed);(i)++)
typedef pair<int,int> PII;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long LL;

int N,M,T;
int tb[100005];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("xxx.in","r",stdin);
	//freopen("xxx.out","w",stdout);
	int i,j,k;
	cin >> N;
	for(i=1;i<=N;i++)
        cin >> tb[i];
    k=0;
    for(i=1;i<N;i++)
        if(tb[i]==i)
            swap(tb[i],tb[i+1]),k++;
    if(tb[N]==N)
        k++;
    cout << k << '\n';
	return 0;
}


Measured memory_bytes: 640
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

auto Px = [-1, 0, 1, 0];
auto Py = [ 0, 1, 0,-1];

void main()
{

    auto line = split(readln()).map!(a => to!int(a));

    int z = 0;
    auto ret = solve(line[z++], line[z++], line[z++], line[z++], line[z++]);

    writeln(ret ? "Yes" : "No");

}

bool solve(int W, int H, int x, int y, int r)
{
    for (int i = 0; i < 4; i++) {
        auto px = x - Px[i] * r;
        auto py = y - Py[i] * r;

        if (!(0 <= py && py <= H && 0 <= px && px <= W)) {
            return false;
        }
    }
    return true;

}

Measured memory_bytes: 1068
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  


 void solve() {
      long double r,res;
      cin>>r;
      res=2.0*PI*r;
      cout<<res<<endl;
      
						   
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main(){
  string s;
  cin>>s;
  set<char> st;
  rep(i,s.size()){
    if(st.count(s[i])){
      cout<<"no"<<endl;
      return 0;
    }
    st.insert(s[i]);
  }
  cout<<"yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N;
    cin >> N;
    vector<vector<pair<ll,ll>>> s(N);
    for(int i = 0; i < N; i++){
        s[i] = vector<pair<ll,ll>>(0);
        ll tmp;
        cin >> tmp;
        for(int j = 0; j < tmp; j++){
            ll x,y;
            cin >> x >> y;
            x--;
            s[i].push_back(make_pair(x,y));
        }
    }
    int M = 0;
    for(int a = 0; a < (1 << N); a++){
        bool judge = true;
        for(int i = 0; i < N; i++){
            if(a & (1 << i)){
                // iは正直者である、審議判定
                //cout << i << "isHonest."<<endl;
                for(int j = 0; j < s[i].size(); j++){
                    //cout << (a & (1 << s[i][j].first)) << "," << s[i][j].second << endl;
                    if(((a & (1 << s[i][j].first)) == 0) != (s[i][j].second == 0)){
                        //矛盾検知
                        //cout << "Error" << endl;
                        judge = false;
                        break;
                    }
                }
            }
            if(!judge){
                break;
            }
        }
        if(judge){
            //cout << "No Error" << endl;
            //最大値更新
            int tmp = 0;
            for(int i = 0; i < N; i++){
                if(a & (1 << i)){
                    tmp++;
                }
            }
            M = max(M,tmp);
        }
    }
    cout << M << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


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

    vector<double> sum(n+1,0); //累積和
    rep(i,n) {
        double tmp = (double)(p[i]+1)/2;
        sum[i+1] = sum[i] + tmp;
    }
    double ans = 0;
    rep(i,n-k+1) {
        chmax(ans, sum[i+k] - sum[i]);
    }
    printf("%.9f\n", ans);
}   

Measured memory_bytes: 5524
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

vector<pii> getDiv(int n){
	if(n == 1){
		vector<pii> v;
		v.PB({1,1});
		return v;
	}
	vector<pii> v;
	for(int i = 1; i*i <= n; i++){
		if(n % i == 0){
			v.PB({i,n/i});
		}
	}
	return v;
}


int32_t main(){
	int n;
	cin >> n;
	
	vector<pii> v = getDiv(n);
	
	int ans = 1e18;
	
	for(auto x : v){
		ans = min(ans,x.F-1+x.S-1);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 384
def main():
	A = int(input())
	B = int(input())
	C = int(input())
	X = int(input())
	cnt = 0

	for i in range(A + 1):
		for j in range(B + 1):
			for k in range(C + 1):
				if 500 * i + 100 * j + 50 * k == X:
					cnt += 1

	print(cnt)

  
if __name__ == "__main__":
  	main()

Measured memory_bytes: 9096
N=gets.to_i
a1=[0] + gets.chomp.split.map(&:to_i)
a2=[0] + gets.chomp.split.map(&:to_i)

csum1=[0]
csum2=[0]
1.upto(N) {|i| csum1[i] = csum1[i-1] + a1[i]}
1.upto(N) {|i| csum2[i] = csum2[i-1] + a2[i]}

ans = -1
1.upto(N) do |i|
  t = csum1[i] + csum2[N] - csum2[i-1]
  ans = t if t > ans
end
puts ans

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  int sum = 0;
  for(auto e:A) sum += e;

  int cnt = 0;
  rep(i, N){
   if(A.at(i)*(4*M) >= sum) cnt++;
  }
  if(cnt >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




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


int main(){
	bool prime[60000];
	for(int i=0;i<60000;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=0;i*i<60000;i++){
		if(prime[i]==1){
			for(int j=i*2;j<60000;j+=i){
				prime[j]=0;
			}
		}
	}
	int n;
	while(cin>>n){
		int i;
		for(i=1;prime[n-i]==0;i++);
		cout<<n-i<<" ";
		for(i=1;prime[n+i]==0;i++);
		cout<<n+i<<endl;
	}
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int l;
bool bl[20];
vector<pair<P, int>> ans;
int cnt2;

signed main() {
	cin >> l;
	int cnt = 1;
	int mi = INF;
	int k = 0;
	for (int i = 1; i <= l / 2; i *= 2) {
		ans.push_back({ {cnt,cnt + 1},0 });
		ans.push_back({ {cnt,cnt + 1},i });
		cnt2 += 2;
		cnt++;
		mi = min(mi, l - i * 2);
		k = i * 2;
	}
	for (int i = 0; i < 20; i++) {
		if (mi&(1 << i)) {
			ans.push_back({ {i + 1,cnt},k });
			k += (1 << i);
			cnt2++;
		}
	}
	cout << cnt << " " << cnt2 << endl;
	for (int i = 0; i < (int)ans.size(); i++)cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=((res%mod)*(x%mod))%mod;
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s,s1;
    cin>>s;
    s1=s;
    ll i,k,c=0;
    cin>>k;
    if(s.size()==1)
    {
        cout<<k/2<<endl;
        return 0;
    }
    if(count(s.begin(),s.end(),s[0])==s.size())
    {
        cout<<(s.size()*k)/2<<endl;
        return 0;
    }
    for(i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1])
        {
            s[i]='X';
            c++;
        }
    }
     if(k==1)
     {
         cout<<c<<endl;
         return 0;
     }
     s=s+s1;
     ll p=0;
     for(i=s1.size();i<s.size();i++)
     {
         if(s[i]==s[i-1])
         {
             s[i]='X';
             p++;
         }
     }
     cout<<c+p*(k-1)<<endl;
}


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

using namespace std;
using ll = long long int;

int main() {
    int H, W;
    cin >> H >> W;
    string field[H];
    for (int h = 0; h < H; h++) {
        cin >> field[h];
    }

    int N = H * W;
    int dest[N][N];
    for (int hf = 0; hf < H; hf++) {
        for (int wf = 0; wf < W; wf++) {
            for (int ht = 0; ht < H; ht++) {
                for (int wt = 0; wt < W; wt++) {
                    int d = abs(hf - ht) + abs(wf - wt);
                    int nt = ht * W + wt;
                    int nf = hf * W + wf;

                    if (field[ht][wt] == '#' or field[hf][wf] == '#') {
                        dest[nf][nt] = -1;
                        dest[nt][nf] = -1;
                    } else if (d == 1) {
                        dest[nf][nt] = 1;
                        dest[nt][nf] = 1;
                    } else if (d == 0) {
                        dest[nf][nt] = 0;
                    } else {
                        dest[nf][nt] = -1;
                        dest[nt][nf] = -1;
                    }
                }
            }
        }
    }

    for (int k = 0; k < 3; k++) {
        for (int nt = 0; nt < N; nt++) {
            for (int nf = 0; nf < N; nf++) {
                for (int n = 0; n < N; n++) {
                    if (dest[nf][n] >= 0 and dest[n][nt] >= 0) {
                        if (dest[nf][nt] == -1) {
                            dest[nf][nt] = dest[nf][n] + dest[n][nt];
                        } else {
                            dest[nf][nt] = min(dest[nf][nt],
                                               dest[nf][n] + dest[n][nt]);
                        }
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans = max(dest[i][j], ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

void solve(int n){
    vector<P> v;
    int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
    for(int i=0; i<n; i++){
        if(i == 0){
            v.push_back(P{0, 0});
            continue;
        }
        int ni, d;
        cin >> ni >> d;
        int x = v[ni].first, y = v[ni].second;
        if(d == 0) x--;
        else if(d == 1) y--;
        else if(d == 2) x++;
        else if(d == 3) y++;
        v.push_back(P{x, y});
        xmin = min(xmin, x);
        ymin = min(ymin, y);
        xmax = max(xmax, x);
        ymax = max(ymax, y);
    }
    cout << abs(xmax - xmin) + 1 << " " << abs(ymax - ymin) + 1 << endl;
    return;
}

int main(){
    int n;
    while(true){
        cin >> n;
        if(n == 0) break;
        solve(n);
    }
    
    return 0;
}


Measured memory_bytes: 3012
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().ToCharArray();
        var t = Console.ReadLine().ToCharArray();

        Array.Sort(s);
        Array.Sort(t, (a, b) => b - a);

        if (0 > new string(s).CompareTo(new string(t)))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13408