akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
#define house 4
#define floor 3
#define room 10
 
int main()
{
  short people[house][floor][room] = {0};
  short n;
 
  fscanf(stdin, "%hd", &n);
 
  short i, b, f, r, v;
  for (i = 0; i < n; i++) {
    fscanf(stdin, "%hd %hd %hd %hd", &b, &f, &r, &v);
    people[b - 1][f - 1][r - 1] += v;
  }
     
  short j, k;
  for (i = 0; i < house; i++) {
    for (j = 0; j < floor; j++) {
      for (k = 0; k < room; k++) {
        fprintf(stdout, " %hd", people[i][j][k]);
      }
      putchar('\n');
    }
    if (i < house - 1) {
      fprintf(stdout, "####################\n");
    }
  }
     
  return 0;
}

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

int main(void){
	int h1,m1,h2,m2,k;
	cin >>h1 >> m1 >> h2 >> m2 >> k;
	int h=60*(h2-h1);
	//if(m2-m1 >=0){
		cout << h+(m2-m1)-k <<endl;
	//}

return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
typedef long long ll;
char s[N];ll k;
int l[N];
int n;
ll ans=0;
int main()
{
	scanf("%s",s+1);cin >> k;
	n=strlen(s+1);
	for(int u=1,v;u<=n;u=v+1){
		v=u;while(v+1<=n&&s[v+1]==s[u])++v;
		l[u] = l[v] = v-u+1;
		ans += k*(l[u]/2);
	}
	if(s[1]==s[n]){
		ans-=k*(l[1]/2)+k*(l[n]/2);
		ans+= l[1]/2+l[n]/2+(k-1)*((l[1]+l[n])/2);
	}
	if(l[1]==n){
		ans=n*k/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N,K = isRaw()
    As = isRaw()
    for k in range(K,N):
        if As[k]>As[k-K]:
            print("Yes")
        else:
            print("No")
main()


Measured memory_bytes: 92604
# coding: utf-8

num = input().split()
thp = int(num[0])
tatk = int(num[1])
ahp = int(num[2])
aatk = int(num[3])

turn = 1

while thp > 0 and ahp > 0:
    if turn % 2 == 1:
        ahp -= tatk
        turn += 1
        if ahp <= 0:
            print("Yes")
            break
    else:
        thp -= aatk
        turn += 1
        if thp <= 0:
            print("No")
            break

Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
long long dp[2][2020];
vector<pair<pair<long long,long long>,pair<long long,long long> > >E;
main()
{
	cin>>N;
	for(int i=0;i<=2000;i++)dp[0][i]=-1e18;
	for(int i=0;i<N;i++)
	{
		long long R,A,W,T;
		cin>>R>>A>>W>>T;
		T--;
		E.push_back({{T,R},{A,W}});
	}
	sort(E.begin(),E.end(),[](
	pair<pair<long long,long long>,pair<long long,long long> >a,
	pair<pair<long long,long long>,pair<long long,long long> >b
	){return a.first.first+a.first.second>b.first.first+b.first.second;}
	);
	for(int i=0;i<N;i++)
	{
		long long R,A,W,T;
		R=E[i].first.second;
		A=E[i].second.first;
		W=E[i].second.second;
		T=E[i].first.first;
		for(int j=0;j<=2000;j++)dp[1][j]=-1e18;
		for(int j=R;j<=2000;j++)
		{
			dp[1][min(T,j-R)]=max(dp[1][min(T,j-R)],dp[0][j]+A);
		}
		dp[1][T]=max(dp[1][T],A);
		for(int j=T;j>=R;j--)
		{
			dp[1][j-R]=max(dp[1][j-R],dp[1][j]+W);
		}
		for(int j=0;j<=2000;j++)dp[0][j]=max(dp[0][j],dp[1][j]);
	}
	long long ans=0;
	for(int j=0;j<=2000;j++)ans=max(ans,dp[0][j]);
	cout<<ans<<endl;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
ll a,b,c,r=0;
cin>>a>>b>>c;
r=b+c-a;
if(r>=0)
cout<<r;
else
cout<<'0';
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
void QSort(long long x[ ], int left, int right);
void Swap(long long x[ ], int i, int j);
 
 
 
int main(){
  int n;
  
  scanf("%d",&n);

  long long l[n*2];
  
  for(int i=0;i<n*2;i++){
    scanf("%lld",&l[i]);
    
  }
 
  QSort(l,0,2*n-1);

  long long k=0;
  
  for(int i=0;i<n;i++){
    k=k+l[2*i+1];
  }
  
 
  printf("%lld\n",k);
    
  
  return 0;
}
 
  /* クイックソートを行う */
void QSort(long long x[ ], int left, int right)
{
    int i, j;
    long long pivot;
 
    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */
 
    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */
 
    while (1) {                    /* 無限ループ */
 
        while (x[i] > pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */
 
        while (pivot > x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */
 
        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
   
 
    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}
 
  /* 配列の要素を交換する */
void Swap(long long x[ ], int i, int j)
{
    long long temp;
 
    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M;
ll x[1000], y[1000], z[1000], res, t;
priority_queue<ll>q;
int main(){
	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i] >> z[i];
	}
	for (int i = 0; i < N; ++i) {
		q.push(x[i] + y[i] + z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	for (int i = 0; i < N; ++i) {
		q.push(x[i] + y[i] + z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	for (int i = 0; i < N; ++i) {
		q.push(x[i] + y[i] - z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	for (int i = 0; i < N; ++i) {
		q.push(x[i] - y[i] + z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	for (int i = 0; i < N; ++i) {
		q.push(-x[i] + y[i] + z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	for (int i = 0; i < N; ++i) {
		q.push(x[i] - y[i] - z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	for (int i = 0; i < N; ++i) {
		q.push(-x[i] + y[i] - z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	for (int i = 0; i < N; ++i) {
		q.push(-x[i] - y[i] + z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	for (int i = 0; i < N; ++i) {
		q.push(-x[i] - y[i] - z[i]);
	}
	for (int i = 0; i < M; ++i) {
		t += q.top();
		q.pop();
	}
	res = max(res, t);
	t = 0;
	q = priority_queue<ll>();
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<cstdlib>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<stack>
#include<map>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)

using namespace std;

int main()
{
	int a, b,tmp,sign;
	int ans;
	cin >> a >> b;
	ans =(a > 0) - (a < 0);
	tmp = (b > 0) - (b < 0);
	if (ans == 1 && tmp == -1 || ans == -1 && tmp == 1) {
		cout << "Zero" << endl;
		return 0;
	}
	for (int i = a+1; i <= b; i++) {
		sign = (i > 0) - (i < 0);
		ans *= sign;
	}
	if (ans == 1) {
		cout << "Positive"<<endl;
	}
	else if (ans == -1) {
		cout << "Negative" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
flg = True

while flg:
    for i in range(N):
        if A[i] % 2:
            flg = False
            break
        else:
            A[i] >>= 1

    if flg:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    LL cnt = 0;
    for(LL i = 0; i+1 < s.size(); ++i){
        if(s[i] != s[i+1]) cnt += 1;
    }
    LL ans = n - 1 - max(0LL, cnt - 2*k);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD (long)(1e9+7)
int main(){
  #define int long
  int N,res=1;
  string S;
  map<char,int> m;
  cin>>N>>S;
  for(int i=0;i<N;++i)m[S[i]]++;
  for(auto i=m.begin();i!=m.end();++i)
    res = ((res%MOD)*((i->second+1)%MOD))%MOD;
  cout<<(res-1)%MOD;
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




ll dp[105][300][105];

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    
    dp[0][0][0] = 1;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < 260; j++){
            for(ll l = 0; l < n; l++){
                dp[i + 1][j ^ a[i]][l + 1] += dp[i][j][l];
                dp[i + 1][j ^ a[i]][l + 1] %= MOD;
                dp[i + 1][j][l] += dp[i][j][l];
                dp[i + 1][j][l] %= MOD;
            }
        }
    }
    
    vector<ll> r(105);
    r[1] = 1;
    for(ll i = 2; i <= 102; i++){
        r[i] = r[i - 1] * i;
        r[i] %= MOD;
    }
    
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ans += (dp[n][k][i] * r[i]) % MOD;
        ans %= MOD; 
    }
    cout << ans << endl;
}


Measured memory_bytes: 24576
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <math.h>
#include <limits.h>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<long long> monsters(n);
	unsigned long long total = 0;
	for (int i = 0; i < n; i++) {
		cin >> monsters[i];
		total += monsters[i];
	}
	sort(monsters.begin(), monsters.end());
	if (k == 0) cout << total << endl;
	else if (k >= n) {
		cout << 0 << endl;
	}
	else {
		for (int i = n - 1; i >= 0; i--) {
			total -= monsters[i];
			k--;
			if (k == 0) break;
		}
		cout << total << endl;
	}
	return 0;
}

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

double x[10],y[10];

int f(int n)
{
    if(n==0)return 1;
    return n*f(n-1);
}

int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            cin>>x[i]>>y[i];
        }
        int k=0;
        double sum=0;
        for(int i=0;i<n-1;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                double t=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
                sum+=sqrt(t);
                k++;
            }
        }
        double ans;
        double q;
        q=2*f(n-2)+(n-2)*2*f(n-2);
        ans=(sum*q)/f(n);
        printf("%.10lf\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> dp;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

void solve()
{
    ll n;
    cin>>n;
    ll a[n+1];
    repf(i,1,n+1) cin>>a[i];
    ll dp[n+1][2];
    repf(i,1,n+1) dp[i][0]=dp[i][1]=-1e18;
    dp[1][0]=dp[1][1]=0;
    dp[2][1]=a[2],dp[2][0]=a[1];
    repf(i,3,n+1)
    {
        if(i&1) 
        {
            dp[i][1]=a[i]+max(dp[i-2][1],dp[i-2][0]);
            dp[i][0]=max(dp[i-1][1],dp[i-1][0]);
        }
        else
        {
            dp[i][1]=a[i]+dp[i-1][0];
            dp[i][0]=a[i-1]+dp[i-2][0];
        }
        // cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<endl;
    }
    cout<<max(dp[n][0],dp[n][1])<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}     


Measured memory_bytes: 8308
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	Vec2 operator*(T s) const { return Vec2(x*s, y*s); }
	T dot(const Vec2& rhs) const { return x*rhs.x + y*rhs.y; }
	T cross(const Vec2& rhs) const { return x*rhs.y - y*rhs.x; }

	bool operator<(const Vec2& rhs) const
	{
		if (x != rhs.x) return x < rhs.x;
		return y < rhs.y;
	}

	T x;
	T y;
};

typedef Vec2<int> VecI;

template<class T>
T cross(const Vec2<T> &O, const Vec2<T> &A, const Vec2<T> &B)
{
	return (A - O).cross(B - O);
}

int main()
{
	int N;
	scanf("%d", &N);

	static VecI P[100000];
	for (int i = 0; i < N; i++) {
		int x, y;
		scanf("%d %d", &P[i].y, &P[i].x);
	}
	sort(P, P+N);

	static int H[100000];
	int k = 0;
	for (int i = 0; i < N; i++) {
		while (k >= 2 && cross(P[H[k - 2]], P[H[k - 1]], P[i]) < 0) {
			k--;
		}
		H[k++] = i;
	}

	int t = k + 1;
	for (int i = N - 2; i >= 0; i--) {
		while (k >= t && cross(P[H[k - 2]], P[H[k - 1]], P[i]) < 0) {
			k--;
		}
		H[k++] = i;
	}

	printf("%d\n", k-1);
	for (int i = k-1; i > 0; i--) {
		printf("%d %d\n", P[H[i]].y, P[H[i]].x);
	}

	return 0;
}



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

int main() {
	char b, ans;
	cin >> b;
	if (b == 'A') ans = 'T';
	else if (b == 'T') ans = 'A';
	else if (b == 'C') ans = 'G';
	else if (b == 'G') ans = 'C';
	cout << ans;
	return 0;
}

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

int main() {
  int N;
  string S,T;
  cin >> N >> S >> T;
  
  string ans;
  for (int i = 0; i < N; i++) {
    ans = ans + S[i] + T[i];
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=411, inf=2e9;

int n, h;

int indeg[MX], outdeg[MX];

int U[MX];
int find(int x){
    return x==U[x] ? x : U[x]=find(U[x]);
}
void unite(int x, int y){
    U[find(y)]=find(x);
}

bool solve(){
    bool st[MX]={}, ed[MX]={};
    for(int i=1; i<=h; i++){
        if(indeg[i]<outdeg[i]) return false;
        if(indeg[i]==outdeg[i]) continue;
        ed[find(i)]=true;
    }
    for(int i=h+1; i<=2*h; i++){
        if(indeg[i]>outdeg[i]) return false;
        if(indeg[i]==outdeg[i]) continue;
        st[find(i)]=true;
    }
    for(int i=1; i<=2*h; i++){
        if(indeg[i]==0 && outdeg[i]==0) continue;
        int x=find(i);
        if(!st[x] || !ed[x]) return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>h; h++;
    iota(U, U+2*h+1, 0);
    for(int i=1; i<=n; i++){
        int a, b, c, d; cin>>a>>b>>c>>d;
        int x = (c==0 ? h+a : c), y = (d==0 ? b : h+d);
        unite(x, y);
        outdeg[x]++, indeg[y]++;
    }
    cout<<(solve() ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll k, x;
	cin >> k >> x;
	ll mn = x - k + 1;
	mn = max(mn, (ll)-1000000);
	ll mx = x + k - 1;
	mx = min(mx, (ll)1000000);
	for(ll i = mn; i<=mx; i++)
		cout << i << " ";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
	return *(  int *) b - *(int *) a;
	//qsort(b, a, sizeof(long long int), int_sort);
}

int main() {

	long int k,a,b,kuki=1,en=0;
	cin>>k>>a>>b;
	if(b-a<=1){
		cout<<1+k;
		return 0;
	}

	while(k>0) {
		k--;
		if(en>=1){
			en-=1;
			kuki+=b;
		}
		else if(kuki<a ||k==0){
			kuki++;
		}
		else if(kuki>=a){
			kuki-=a;
			en++;
		}
		//cout<<kuki<<" "<<en<<"\n";
	}


	
	cout<<kuki;
	return 0;


}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
const char* bits[] = {
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111",
};

int main () {
	int n;
	while (cin >> n, n != -1) {
		char current[] = "0000000";
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			for (int i = 0; i < 7; i++) {
				if (current[i] != bits[x][i]) {
					cout << '1';
					current[i] = bits[x][i];
				}
				else {
					cout << '0';
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main()
{
	int c1, c5, c10, c50, c100, c500;

	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	c5 = c5 * 5;
	c10 = c10 * 10;
	c50 = c50 * 50;
	c100 = c100 * 100;
	c500 = c500 * 500;
	if( c1 + c5 + c10 + c50 + c100 + c500 >= 1000 ){
		cout << '1' << endl;
	}
	else{
		cout << '0' << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 1e14
#define N 300001
#define K 33

int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int n;
    cin >> n;
    vector<int> v(n + 1,0);
    for(int x = 1;x <= 100;x++)
    {
        for(int y = 1;y <= 100;y++)
        {
            for(int z = 1;z <= 100;z++)
            {
                int a = x * x + y * y + z * z + z * x + x * y + z * y;
                if(a <= n)
                    v[a]++;
            }
        }
    }
    for(int i = 1; i <= n;i++)
        cout << v[i] << " " ;


    
    return 0;    
} 


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
char s[1000005];
signed main(){
	scanf("%s",s+1);
	for(int i=1;s[i];++i)if(s[i]=='?')s[i]='D';
	puts(s+1);
	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll R, G;

    cin >> R >> G;

    cout << 2 * G - R << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 177, task a, 2020/08/29
//ms,
/*
添え字が1-indexになってるのに気づいてなくて草。
入力時に1小さいものをとるか、最初に配列を一つ大きくとるか。
*/

int main(void){
  int N, M;
  vector<vector<int>> friends(200000);
  queue<int> next;
  vector<int> dist(200000, -1);
  int ans=1;
  int group_size;

  cin >>N >>M;

  //input
  for(int i=0;i<M;i++){
    int u, v;
    cin >>u >>v;
    friends[u-1].push_back(v-1);
    friends[v-1].push_back(u-1);
  }

  //bfs
  for(int v=0;v<N;v++){
    if(dist[v] != -1) continue;

    dist[v]=0;
    next.push(v);
    group_size=1;

    while(next.size()!=0){
      int u = next.front();
      next.pop();

      for(long unsigned int i=0;i<friends[u].size();i++){
        int w = friends[u][i];
        if(dist[w] != -1) continue;

        dist[w] = dist[u]+1;
        next.push(w);
        group_size++;
      }
    }//end while
    ans = max(ans, group_size);
  }//end for

  cout <<ans<<endl;
  return 0;
}
/*
お手上げ！！！
解法はunion find木とBFSの二通り。
BFSは連結な重みなしのグラフの最短路問題を線形時間で解けるのが特徴。
また、未探索の頂点が消えるまでやり続ければ連結成分の様子がなんでもわかる。
今回は後者の特徴を使う。
友達のネットワークのグラフの、最大の連結成分の成分個のグループがあればよい。
*/


Measured memory_bytes: 15496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n,x,y; cin >> n >> x >> y;
    int table[n+1][n+1];
    int c[n];
    for(int i = 0; i < n; i++){
        c[i] = 0;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            
            if(j <= x) table[i][j] = j-i;
            else if(y <= i) table[i][j] = j-i;
            else table[i][j] = min(j-i, abs(x-i) + 1 + abs(y-j));

            c[table[i][j]]++;
        }
    }
    for(int i = 1; i < n; i++){
        cout << c[i] << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

#define FOR(i,a,b) for (int i=a;i<b;i++)
#define fi first
#define se second
#define pb push_back

int n;
int odd[100005];
int even[100005];
bool cmp1(int a, int b){
    return odd[a] < odd[b];
}
bool cmp2(int a, int b){
    return even[a] < even[b];
}
vi ODD, EVEN;
int oddSame = 0, evenSame = 0;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++){
        int k;
        cin >> k;
        if (i&1){
            odd[k]++;
        } else even[k]++;
    }
    for (int i = 1; i <= 100000; i++){
        if (odd[i] > 0) ODD.pb(i);
        if (even[i] > 0) EVEN.pb(i);
    }
    if (ODD.size() == 1){
        ODD.pb(0);
    }
    if (EVEN.size() == 1){
        EVEN.pb(0);
    }
    sort(ODD.begin(), ODD.end(), cmp1);
    sort(EVEN.begin(), EVEN.end(), cmp2);
    // for (auto i : ODD) cout << i << '/' << odd[i] << ' ';
    // cout << '\n';
    // for (auto i : EVEN) cout << i << '/' << even[i] << ' ';
    // cout << '\n';
    int ans = n;
    if (ODD.back() == EVEN.back()){
        ans -= odd[ODD.back()];
        ans -= max(odd[ODD[ODD.size()-2]], even[EVEN[EVEN.size()-2]]);
    } else {
        ans -= odd[ODD.back()];
        ans -= even[EVEN.back()];
    }
    cout <<ans << endl;
    return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		
//		String[] ID = new String[n];
		ArrayList<String> ID = new ArrayList<String>();
		
		for(int i = 0; i < n; i++){
			ID.add(br.readLine());
		}
		
		int m = Integer.parseInt(br.readLine());
		
		boolean lock = true;
		
		for(int i = 0; i < m; i++){
			String str = br.readLine();
			
			if(ID.contains(str)){
				if(lock){
					System.out.println("Opened by "+str);
				}
				else{
					System.out.println("Closed by "+str);
				}
				
				lock = !lock;
			}
			
			else {
				System.out.println("Unknown "+str);
			}
		}
	}

}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

ll mod = 1e9 + 7;
vi fat, fatI;
int maxn = 2e6+42;

ll expMod(ll a, ll b, ll mod){
    ll ans = 1;
    while(b){
        if(b&1) ans = (ans*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return ans;
}

void init(){
    fat.resize(maxn+1);
    fatI.resize(maxn+1);
    fat[0] = fatI[0] = 1;
    for(int i=1; i<=maxn;i++){
        fat[i] = (fat[i-1]*ll(i))%mod;
        fatI[i] = expMod(fat[i], mod-2, mod);
    }
}

int C(int n, int k){
    ll tmp = (fat[n]*ll(fatI[k]))%mod;
    tmp *= fatI[n-k];
    tmp %= mod;
    return tmp;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();
    int n,k,i;
    cin >> k;
    string s;
    cin >> s;
    n = s.size();
    ll ans = 0;
    int p25 = expMod(25, k, mod);
    ll p25I = expMod(25, mod-2, mod);
    int p26 = 1;
    for(i=0;i<=k;i++){
        ll tmp = C(n+k-i-1, n-1);
        tmp *= p25; tmp %= mod;
        tmp *= p26; tmp %= mod;
        ans += tmp; ans %= mod;
        p26 = (p26*ll(26))%mod;
        p25 = (p25*p25I)%mod;
    }
    cout << ans << "\n";

    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i=0;i<M;i++){
    cin >> L.at(i) >> R.at(i);
  }
  //万能カードのうち、最大・最小の番号を調べる。
  int maxnum = N;
  int minnum = 0;
  for(int i=0;i<M;i++){
    maxnum = min(maxnum,R.at(i));
    minnum = max(minnum,L.at(i));
  }
  if(maxnum >= minnum){
    cout << maxnum - minnum +1 << endl;
  }else{
    cout << 0 << endl;
  }
}

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

checkList = []

def checkCount(num):
    count = 0
    while(num > 0):
        if num % 2 == 0:
            num/=2
            count+=1
        else:
            break
    checkList.append(count)

for num in A:
    checkCount(num)
    
print(min(checkList))

Measured memory_bytes: 3060
import numpy as np
N = int(input())
h = np.array(list(map(int, input().split())))

# N =  8
# h = np.array(list(map(int, "4 23 75 0 23 96 50 100".split())))

a = np.zeros(N)
h_min = min(h)
h_max = max(h)
n_loop = h_max - h_min

cnt = 0
for zzz in range(n_loop):
    tmp = (h >= h_min+1+zzz)*1
#     print(tmp)
    for idx, i in enumerate(tmp):
        if idx==0:
            first = i
            a0 = i
            continue
            
        if i==a0:
            continue
        else:
            if i==1:
                cnt+=1
            a0 = i
    else:
        if first==1:
            cnt+=1
            
print(cnt+h_min)

Measured memory_bytes: 12508
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e2 + 5;
ll n,g;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    g = n / 2;
    if(n & 1) g += 1;
    cout<<setprecision(7)<<fixed<<(long double) g / (long double) n;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
#define ENDL printf("\n");
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

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;}

signed main(){
    int n; cin >> n;
    VI a(n+1);
    VI boss(n+1,0);
    a[0] = a[1] = 0;
    for(int i = 2 ; i <= n ; ++i) cin >> a[i];
    for(int i = 2 ; i <= n ; ++i){
        ++boss[a[i]];
    }
    for(int i = 1 ; i <= n ; ++i ){
        cout << boss[i] << endl;
    }
}

Measured memory_bytes: 4844
# import inbuilt standard input output  
from sys import stdin, stdout  
  
# suppose a function called main() and 
# all the operations are performed 
def main(): 
  
    # input via readline method 
    info_input = stdin.readline() 
    vote_input = stdin.readline() 

    info = [int(x) for x in info_input.split()] 
    votes = [int(x) for x in vote_input.split()] 

    n = info[0]; m = info[1]; 

    counter = 0 
    bound = 1/(4*m)
    total = sum(votes)

    votes.sort(reverse=True)

    for vote in votes:
    	if vote >= bound*total:
    		counter += 1
    		if counter == m:
    			return "Yes"
    	else:
    		return "No"

   
# call the main method 
if __name__ == "__main__": 
    print(main())     

Measured memory_bytes: 3064
#include<stdio.h>
#define gc() getchar()
int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}
int main()
{
	char a[7];
	gets(a);
	if (a[5] == a[4] && a[3] == a[2])
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 128
n = int(input())
p = list(map(float,input().split()))
dp = [[0] * (n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
    for j in range(i+1):
        if j > 0:
            dp[i][j] = dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
        else:
            dp[i][j] = dp[i-1][j]*(1-p[i-1])
ans = 0
for i in range(n//2+1,n+1):
    ans += dp[n][i]
print(ans)

Measured memory_bytes: 204072
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static int[] nk;
    static int[][] ab;
    static void Solve()
    {
        nk = Input.ar;
        ab = Input.ar2D(nk[0]);
        var s = Convert.ToString(nk[1], 2);
        var res = calc(nk[1]);
        for(var i = 0; i <= 30; i++)
        {
            if ((1 << i) > nk[1]||s[i]=='0') continue;
            var qq = new char[s.Length];
            for (var j = 0; j < s.Length; j++)
                if (j < i) qq[j] = s[j];
                else if (j == i) qq[j] = '0';
                else qq[j] = '1';
            res = Max(res, calc(ToInt32(new string(qq),2)));
        }
        WriteLine(res);
    }
    private static long calc(int b)
    {
        var c = 0L;
        for (var i = 0; i < nk[0]; i++)
            if ((b | ab[i][0]) == b) c += ab[i][1];
        return c;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 25916
#include <cstddef>
#include <limits>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstdlib>
#include <new>
#include <typeinfo>
#include <exception>
#include <initializer_list>
#include <cstdalign>
#include <stdexcept>
#include <cassert>
#include <cerrno>
#include <system_error>
#include <string>

#if __has_include(<string_view>)
#   include <string_view>
#endif

#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>

#if __has_include(<filesystem>)
#   include <filesystem>
#endif

#include <cstdio>
#include <cinttypes>


#include <regex>
#include <atomic>
#include <thread>
#include <mutex>
#include <shared_mutex>
#include <condition_variable>
#include <future>

using namespace std::literals ;
using namespace std;

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

    int N;
    cin >> N;

    double n;
    if (N % 2 == 0) {
        // 整数が偶数
        n = N / 2;
    } else {
        n = N / 2 + 1;
    }

    double answer = n / N;
    cout << std::fixed<< std::setprecision(10) << answer;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

string S[3];

int main(){
    rep(i,3) cin>>S[i];

    int idx[3]={0,0,0};
    int t=0;
    while(S[t].size()>idx[t]){
        if(S[t][idx[t]]=='a'){idx[t]++; t=0;}
        else if(S[t][idx[t]]=='b'){idx[t]++; t=1;}
        else if(S[t][idx[t]]=='c'){idx[t]++; t=2;}
    }

    string ans;
    if(t==0) ans='A';
    if(t==1) ans='B';
    if(t==2) ans='C';

    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n,mn=100,mx=0;
	cin >> n;
	vector<int> x(n);
	for (int i = 0;i < n;i++) {
		cin >> x[i];
		if (mx < x[i])mx = x[i];
		if (mn > x[i])mn = x[i];
	}
	int ans = 10000000000;
;
	for (int i = mn; i <= mx;i++) {
		int cost = 0;
		for (int j = 0;j < n;j++) {
			cost += (x[j] - i) * (x[j] - i);
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int MAXN=200005;

int n;
char str[MAXN];
int cnt[30];

int main()
{
	scanf("%s",str);
	n=strlen(str);
	for(int i=0;i<n;i++)
		cnt[str[i]-'a']++;
	long long ans=1LL*n*(n-1)/2;
	for(int i=0;i<26;i++)
		ans-=1LL*cnt[i]*(cnt[i]-1)/2;
	ans++;
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

int main(){
	map<string,int>p;
	string s,t,u;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	p[s]=a;
	p[t]=b;
	cin>>u;
	p[u]-=1;
	cout<<p[s]<<" "<<p[t]<<endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = {}
max = 1

for i in range(n):
    tmp = input()
    if tmp in s:
        s[tmp] += 1
        if max < s[tmp]:
            max = s[tmp]
    else:
        s[tmp] = 1

result = []
for k, v in s.items():
    if v == max:
        result.append(k)
result.sort()
for v in result:
    print(v)


Measured memory_bytes: 32096
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	char ch;
	cin >> ch;

	if ((ch >= 'a') && (ch <= 'z')) cout << "a\n";
	else cout << "A\n";



	return 0;
}


Measured memory_bytes: 3036
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>l>>r>>x;
     m=l/x;
     n=r/x;
     if(l%x!=0){
        m++;
     }
     cout<<n-m+1<<endl;
     return EXIT_SUCCESS;
}


Measured memory_bytes: 3580
H, W = map(lambda x:int(x)+2, input().split())
grid = "."*W
for _ in range(H-2):
  grid += "."+input()+"."
grid += "."*W

Flag = True
move_list = [1, -1, W, -W]

for i in range(1, H-1):
  for j in range(1, W-1):
    if grid[i*W+j] == "#" and all(grid[i*W+j+move] == "." for move in move_list):
      Flag = False
      break

if Flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	string s,t;
	rep(i,0,a) s.push_back(b+'0');
	rep(i,0,b) t.push_back(a+'0');
	cout<<min(s,t);
	return 0;
}

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

dp=[[0 for i in range(3)] for j in range(N)]
dp[1][2]=abs(h[0]-h[1])

def min(a,b):
    if a<=b:
        return a
    else:
        return b

for i in range (2,N):
    dp[i][0]=dp[i-2][2]+abs(h[i-2]-h[i])
    dp[i][1]=dp[i-1][2]+abs(h[i-1]-h[i])
    dp[i][2]=min(dp[i][0],dp[i][1])

print(dp[N-1][2])


Measured memory_bytes: 64056
var pnt,cnt:array[1..200000] of longint;
    a,b,p,x,i,n,q:longint;

begin
	readln(n,q);
  for i := 2 to n do begin
    readln(a,b);
    pnt[b]:=a
  end;
  for i := 1 to q do begin
    readln(p,x);
    cnt[p]:=cnt[p]+x
  end;
  write(cnt[1]);
	for i := 2 to n do begin
    cnt[i]:=cnt[i]+cnt[pnt[i]];
    write(' ',cnt[i])
  end;
  writeln;
end.

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,n;
    cin>>n;
    long long a[n+1],b[n];
    long long s=0,x=0,p=0;
    for(i=0;i<n+1;i++) cin>>a[i];
    for(i=0;i<n;i++) cin>>b[i];
    for(i=0;i<n;i++){
        if(a[i]>=b[i]){
            s+=b[i];
        }
        else{
            s+=x+a[i];
            b[i]-=x+a[i];
            if(b[i]>=a[i+1]){
                s+=a[i+1];
                a[i+1]=0;
            }
            else{
                a[i+1]-=b[i];
                s+=b[i];
            }
        }
    }
 
    cout<<s<<endl;
 
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		string st; cin >> st;
		int f = 0;
		vector<int>hs(N);
		int p = 0;
		for (int i = 0; i < 100; ++i) {
			if (st[i] == 'S') {
				f += 1 + hs[p];
				hs[p] = 0;
			}
			else if (st[i] == 'M') {
				hs[p]++;
			}
			else {
				hs[p] += 1 + f;
				f = 0;
			}
			p = (p + 1) % N;
		}
		sort(hs.begin(), hs.end());
		for (int i = 0; i < N; ++i) {
			cout << hs[i] << " ";
		}
		cout << f << endl;
	}
	return 0;
}

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

void push(int);
int pop();
int top,s[1000];

int main(void){
	int a,b;
	char s[100];
	
	while(scanf("%s",s)!=EOF){
		
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(s[0]=='-'){
			b=pop();
			a=pop();
			
			push(a-b);
		}
		else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
			
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}

void push(int x){
	s[++top]=x;
}
int pop(){
	top--;
	return s[top+1];
}


Measured memory_bytes: 2080
#include<stdio.h>
#include<stdint.h>

int main(){
    long long int N, sum = 0, before[2] = {0, 0};
    scanf("%lld", &N);
    for(int i = 0; i <= N; i++){
        if(i == 0) sum = 2;
        else if(i == 1) sum = 1;
        else{
            sum += before[1];
        }
        before[1] = before[0];
        before[0] = sum;
    }
    printf("%lld", sum);
}

Measured memory_bytes: 128
n=int(input())
w=[]
for i in range(n):
    x=input()
    w.append(x)

s=set(w)
if len(s)<len(w):
    print('No')
    exit()

for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        print('No')
        exit()

print ('Yes')


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

const ll INF = 1e18;

void wf(const graph& g, vector<vector<ll>>& d) {
  ll v = (ll)g.size();
  rep(v, k) {
    rep(v, i) {
      rep(v, j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

void solve(void){
  ll v, e; cin >> v >> e;
  graph g(v, vector<ll>(v, -1));
  vector<vector<ll>> dist(v, vector<ll>(v, INF));

  rep(e, i) {
    ll ta, tb, tc; cin >> ta >> tb >> tc;
    --ta, --tb;
    g[ta][tb] = tc;
    g[tb][ta] = tc;
    dist[ta][tb] = tc;
    dist[tb][ta] = tc;
  }

  rep(v, i) {
    rep(v, j) {
      if (i == j) dist[i][j] = 0;
    }
  }

  wf(g, dist);

  ll res = 0;
  rep(v, i) {
    for(ll j = i + 1; j < v; ++j) {
      if (g[i][j] > 0 && (g[i][j] > dist[i][j])) ++res;
    }
  }

  cout << res << endl;
}

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


Measured memory_bytes: 3752