akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int cnt[100005];
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		if(a>100000)ans++;
		else cnt[a]++;
	}
	for(int i=1;i<=100000;i++)
	{
		if(cnt[i]<i)ans=ans+cnt[i];
		else ans=ans+cnt[i]-i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
A = [input() for i in range(H)]
X = [1,0,-1,0]
Y = [0,-1,0,1]

INF = 99999
dp = [[-1]*W for i in range(H)]
q = deque()
for y, row in enumerate(A):
  for x,c in enumerate(row):
    if c == "#":
      dp[y][x] = 0
      q.append((y,x))
while q:
  y,x = q.popleft()
  d = dp[y][x]
  for i in range(4):
    nx = x + X[i]
    ny = y + Y[i]
    if (0 <= nx < W) and (0 <= ny < H) and (dp[ny][nx] == -1):
      dp[ny][nx] = d + 1
      q.append((ny,nx))
#print(max(max(row) for row in dp))
ans = 0
for i in dp:
  ans = max(ans,max(i))
print(ans)

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

int main() {
  int n,t; cin >> n >> t ;
  vector <int> c(n);
  vector <int> h(n);

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

  int mi = 10000;
  rep(i, n) {
    if (min({mi, c[i]}) == c[i] && h[i] <= t ){
      mi = c[i];
    }
  }

  if (mi == 10000)
    cout << "TLE" << endl;
  else
    cout << mi << endl;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
ta=[list(map(int,input().split())) for i in range(n)]
t,a=ta[0][0],ta[0][1]
for i in range(n-1):
    wa=sum(ta[i+1])
    j=max((t+a+wa-1)//wa,(t+ta[i+1][0]-1)//ta[i+1][0],(a+ta[i+1][1]-1)//ta[i+1][1])
    # while wa*j<t+a or j*ta[i+1][0]<t or j*ta[i+1][1]<a:
    #     j+=1
    t,a=j*ta[i+1][0],j*ta[i+1][1]
    # print([t,a])
print(t+a)

Measured memory_bytes: 39152
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int num;
            int i;

            for (i = 1;; i++)
            {
                num = int.Parse(Console.ReadLine());
                if (num == 0)
                {
                    break;
                }
                Console.WriteLine("Case {0}: {1}", i, num);
            }
        }
    }
}

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;


int main() {
    int n;
    ll x;
    cin >> n >> x;
    ll b = 1, t = 8 * pow(2,n-1) - 3;
   // cout<<t<<endl;
    int lev = n;
    ll ans = 0;
    while (lev >= 1) {
        if(lev==1){
             ll tmp = x - b;
             ans+=min(tmp,(ll)3);
             break;
        }
        if(b==x)break;
        if(t==x){
            ans+=(4*(pow(2,lev-1))-1);
            break;
        }
        lev--;
        ll now = (b + t) / 2;
        if (x >= now) {
            ans += (4 * pow(2,lev-1) - 1);
            ans++;
            b = now+1;
            t--;
        }
        else {
            t = now-1;
            b++;
        }
        if (x == now)break;
    }
    
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n[3];
  cin >> n[0] >> n[1] >> n[2];

  sort( n, n + 3 );

  cout << n[ 0 ] << " " << n[ 1 ] << " " << n[ 2 ] << endl;

  return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define mod 1000000007
using namespace std;

int h[12345],A[12345];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);


int n;
cin>>n;

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

int c=0;
for(int i=0;i<n;i++)
{
    if(A[i]<=399 && A[i]>=1 )
        h[0]++;
     if(A[i]<=799 && A[i]>=400 )
        h[1]++;
        if(A[i]<=1199 && A[i]>=800 )
        h[2]++;
        if(A[i]<=1599 && A[i]>=1200 )
        h[3]++;

        if(A[i]<=1999 && A[i]>=1600 )
        h[4]++;
        if(A[i]<= 2399&& A[i]>=2000 )
        h[5]++;
        if(A[i]<=2799 && A[i]>=2400 )
        h[6]++;

        if(A[i]<=3199 && A[i]>=2800 )
        h[7]++;

       if(A[i]>=3200)
        h[8]++;
}

int c1=0;
for(int i=0;i<=7;i++)
    if(h[i])
        c1++;

        int mn;
if(c1==0)
    mn = 1;
else
   mn = c1;

  int mx  = c1+h[8];

  cout<<mn<<" "<<mx<<"\n";
return 0;
}


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

using namespace std;

int main(){
    long N;
    string S;
    cin>>N>>S;
    
    string a="";
    for(int i=0; i<S.length(); ++i){
        a+='A'+((S[i]-'A')+N)%26;
    }

    cout<<a<<endl;
    
    return 0;
}









Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC132
{
    class Program5
    {
        public class Pair
        {
            public int Node { get; set; }
            public int Cost { get; set; }

            public Pair(int x, int y)
            {
                Node = x;
                Cost = y;
            }
        }

        static void Main()
        {
            var NM = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var edges = new int[NM[1]][];
            for (int i = 0; i < NM[1]; i++)
                edges[i] = Console.ReadLine().Split(' ').Select(k => (int.Parse(k) - 1) * 3).ToArray();
            var ST = Console.ReadLine().Split(' ').Select(i => (int.Parse(i) - 1) * 3).ToArray();

            var map = new List<int>[NM[0] * 3];//nodeNum,0.1.2~ = target
            for (int i = 0; i < NM[0] * 3; i++)
                map[i] = new List<int>();
            foreach (var edge in edges)
                for (int i = 0; i < 3; i++)
                    map[edge[0] + i].Add(edge[1] + (i + 1) % 3);

            var isReached = new bool[NM[0] * 3];
            var que = new Queue<Pair>();
            que.Enqueue(new Pair(ST[0], 0));
            while (que.Count > 0)
            {
                var node = que.Dequeue();
                if(isReached[node.Node])
                    continue;

                isReached[node.Node] = true;

                if (node.Node == ST[1])
                {
                    Console.WriteLine(node.Cost / 3);
                    que.Enqueue(new Pair(0, 0));
                    break;
                }

                foreach (var v in map[node.Node])
                    que.Enqueue(new Pair(v, node.Cost + 1));
            }

            if (que.Count == 0)
                Console.WriteLine("-1");
        }
    }
}


Measured memory_bytes: 51360
from sys import stdin
from itertools import groupby

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

li = [len(tuple(s)) for _ , s in groupby(s)]

if s[0] == s[-1] and k>1:
    if len(li) == 1:
        print(li[0]*k//2)
        exit()
    else:
        co = 0
        for l in range(1,len(li)-1):
            co += li[l]//2
        co = co*k
        co += li[0]//2+li[-1]//2+((li[0]+li[-1])//2)*(k-1)
        print(co)
        exit()

else:
    co = 0
    for j in range(len(li)):
        co += li[j]//2
    print(co*k)
    exit()

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N, M, V, P; cin >> N >> M >> V >> P;

    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.rbegin(), A.rend());

    vector<ll> B(N);
    int ub = N, lb = -1;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;

        // mid 番目の問題は P 位以内に入るか？
        ll target = A[mid] + M;

        // target よりも大きい要素の数が P-1 以下ならおっけー
        ll rem = M * (V - 1);
        B = A; B[mid] = target;

        vector< pair<ll, ll> > vote;
        for(int i=0; i<N; i++) {
            // なにもしない
            if(i == mid) {
                vote.emplace_back(B[i], M);
                continue;
            }
            
            // 最初から超えているので M 票全部振る
            if(B[i] > target) {
                ll diff = min(rem, M);
                rem -= diff;
                B[i] += diff;
                vote.emplace_back(B[i], diff);
            }
            // 超えてないので target を超えないように追加
            // ただし最大でも min(rem, M) 票まで
            else {
                ll diff = min({target - B[i], rem, M});
                rem -= diff;
                B[i] += diff;
                vote.emplace_back(B[i], diff);
            }
        }

        // target より小さい -> rem が残ってないか M 票全部いれたかなのでこれ以上どうしようもない
        // target より大きい -> すでに M 票つかってるはずなのでどうしようもない
        // それ以外 (target と等しい) -> まだ余ってるかも (たくさん入れられるところに貪欲に入れるしかない)
        sort(vote.begin(), vote.end(), [](auto a, auto b) {
                return a.second < b.second;
            });
        
        for(int i=0; i<N and rem>0; i++) {
            ll diff = min(rem, M - vote[i].second);
            rem -= diff;
            vote[i].first += diff;
            vote[i].second += diff;
        }
        assert(rem == 0);

        sort(vote.rbegin(), vote.rend());        
        int cnt = 0;
        for(int i=0; i<N; i++) if(vote[i].first > target) cnt++;

        if(cnt < P) lb = mid;
        else ub = mid;
    }
    cout << ub << endl;
    return 0;
}


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

#define int long long
const int MOD=998244353;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
inline void Cinit(){
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=(Factorial[i-1]*i)%MOD;
  Finverse[499999]=pw(Factorial[499999],MOD-2);
  for(int i=499998;i>=0;i--)Finverse[i]=(i+1)*Finverse[i+1]%MOD;
}
int nCk(int n,int k){
  if(n<k)return 0;if(k<0)return 0;
  if(!Factorial[0])Cinit();
  int res=Factorial[n];
  (res*=Finverse[k])%=MOD;
  (res*=Finverse[n-k])%=MOD;
  return res;
}

signed main(){
  int n,m,k;cin>>n>>m>>k;
  int ans=0;
  for(int i=0;i<=k;i++)(ans+=m*pw(m-1,n-i-1)%MOD*nCk(n-1,i))%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 81268
#include <bits/stdc++.h>
#define ll long long int
#define booga cout << "booga" << endl
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

void testcase(){

}

int main(int argc, char** argv){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a;
	string s;
	cin >> a >> s;
	if(!(a < 3200)){
		cout << s;
	}
	else{
		cout << "red";
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

int main(void){
    int N, ctr = 1, number = 0, preIndex = 0, ans;
    cin >> N;

    int a[N];
    REP(i, N) cin >> a[i];

    for(int i = preIndex; i < N; i++){
        if(a[i] == ctr){
            number++;
            ctr++;
            preIndex++;
        }
    }

    if(number == 0) cout << "-1";
    else cout << N - number;
    
    return 0;
}

Measured memory_bytes: 1024
//Codes by: Umar Bin Qamar

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

bool compare(int a,int b){
    return a>b;
}

int32_t main(){


char s[4];
cin>>s;
if(s[0]=='7' || s[1]=='7' ||s[2]=='7'){
    cout<<"Yes"<<endl;
}
    else{
        cout<<"No"<<endl;
    }


    return 0;
}




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

int main() {
    int n, temp, ans;
    cin >> n;
    map<int, int> even, odd;
    rep(i, n) {
        cin >> temp;
        if(i % 2) even[temp]++;
        else odd[temp]++;
    }
    pair<int, int> e1 = make_pair(0, 0), e2, o1 = make_pair(0, 0), o2;
    for(pair<int, int> p : even) {
        if(e1.second <= p.second) {
            e2 = e1;
            e1 = p;
        } else if(e2.second < p.second) {
            e2 = p;
        }
    }
    for(pair<int, int> p : odd) {
        if(o1.second <= p.second) {
            o2 = o1;
            o1 = p;
        } else if(o2.second < p.second) {
            o2 = p;
        }
    }
    if(e1.first != o1.first) ans = n - (e1.second + o1.second);
    else ans = n - max(e1.second + o2.second, e2.second + o1.second);
    cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  bool a = false;
  
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      if(N==i*j){
        a = true;
      }
    }
  }
  
  if(a){
    cout<<"Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import math
N, M = map(int, input().split())
s=[] #kとs
num=pow(2,N+1)-1
flag=True
count=0
for i in range(M):
  s2=list(map(int,input().split()))
  s.append(s2) #s[0]がk, それ以降はs
p=list(map(int,input().split())) #p
for i in range(pow(2,N)): # スイッチの全てのパターン
  if N<10:
    S=format(num, '0'+str(N)+'b')
  else:
    S=format(num, str(N)+'b')
  S2=list(S)
  flag=True
  for j in range(M): #各電球を見ていく
    sum=0
    for k in range(s[j][0]):#電球iのonの和
      sum=sum+int(S[s[j][k+1]])
    if sum%2 != p[j]:
      flag=False
  if flag==True:
    count=count+1
  num=num-1
print(count)
  

      
      

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
#define PI 3.14159265

int main(void)
{
	double a, b, C,rad;
	double S, L, h;
		scanf("%lf%lf%lf", &a, &b, &C);
		rad = C * 2 * PI / 360;
		S = a*b*sin(rad) / 2;
		L = a + b + sqrt(a*a + b*b - 2*a*b*cos(rad));;
		h = 2*S/a;
		printf("%lf\n%lf\n%lf\n", S, L, h);
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 998244353
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
#define N 100010
ll fac[N],inv[N],ivf[N];
ll C(ll n,ll k){
    if(n<k)return 0;
  if(n<0||k<0)return 0;
    return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll H(ll n,ll k){
    //if(k==0)return 1;
    return C(n+k-1,k);
}
ll P(ll n,ll k){
    return fac[n]*ivf[n-k]%mod;
}
ll po(ll x,ll y){
    ll res=1;
    for(;y;y>>=1){
	if(y&1)res=res*x%mod;
	x=x*x%mod;
    }
    return res;
}
ll solve(ll a,ll b,ll n){
    ll res=0;
    for(ll p=0;p<=b;p++){
	ll cur=C(b,p)*po(2,p)%mod;
	mul(cur,H(a+p,n-p));
	mad(res,cur);
    }
  //cout<<"#"<<a<<" "<<b<<" "<<n<<" "<<res<<endl;
    return res;
}
int main(){
    fac[0]=ivf[0]=inv[1]=1;
    for(int i=1;i<N;i++){
	if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
	fac[i]=fac[i-1]*i%mod;
	ivf[i]=ivf[i-1]*inv[i]%mod;
    }
  ll k,n; cin>>k>>n;
  for(ll i=2;i<=2*k;i++){
      ll a,b;
      a=abs(k-i+1);
      b=(k-a)/2;
      ll ans=solve(a,b,n);
      if(i%2==0){
	  mad(ans,solve(a,b,n-1));
      }
      if(ans<0)ans+=mod;
      cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
using namespace std;

int main(){
    string N;
    int a=0;
    int t;
    cin >>N;
    for (int i=0;i<N.size();i++)
    {
        a=a+N[i]-'0';
    }
    stringstream hi(N);
    hi>>t;
    if (t%a==0){
        cout <<"Yes";
    }
    else {
    cout <<"No";
    }
    return 0;
}

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

int main() {
    int N;
    std::cin >> N;

    std::unordered_map<int, int> m;
    int A;
    for (int i = 0; i < N; ++i) {
        std::cin >> A;
        if (m.count(A) == 0) {
            m[A] = 1;
        } else {
            m[A] += 1;
        }

        if (m.count(A + 1) == 0) {
            m[A+1] = 1;
        } else {
            m[A+1] += 1;
        }

        if (m.count(A-1) == 0) {
            m[A-1] = 1;
        } else {
            m[A-1] += 1;
        }
    }

    int max = 0;
    for (const auto& p : m) {
        max = std::max(max, p.second);
    }

    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 4260
#include<iostream>
#include<cmath>
using namespace std;
int main() {
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    int h;
    cin >> h;
    double tmp = t - h * 0.006;
    int id = 1;
    for (int i = 1; i < n; i++) {
        cin >> h;
        if (abs(tmp - a) > abs((t - h * 0.006)- a)) {
            tmp = t - h * 0.006;
            id = i + 1;
        }
    }
    cout << id << endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

S = []
for i in range(H):
	S.append("." + input() + ".")

S = ["."*(W+2)] + S + ["."*(W+2)]
flag = 1
for i in range(H):
	for j in range(W):
		if S[i][j]=="#":
			if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
				flag = 0
print("Yes" if flag else "No") 

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void)
{
    long long N;

    cin >> N;

    if(N == 2){
        cout << 0 << endl;
    }

    else if(N % 2 == 0){
        cout  <<  N/2-1 << endl;
    }

    else{
        cout <<  N/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
  Contest 098
  A - Add Sub Mul
  Rakesh Kumar --> 24/09/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0;
    std::cin >> a >> b;
    std::cout << std::max(std::max(a - b, a * b), a + b);

    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int a,b,c,x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	rep(i, a+1) {
		rep(j, b+1) {
			rep(k, c+1) {
				if (i * 500 + j * 100 + k * 50 == x)ans++;
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]

c = Counter(a)

ans = False
if len(c) == 1:
    ans = a[0] == 0
elif n % 3 == 0 and len(c) <= 3:
    nums = []
    for i in c:
        if c[i] % (n // 3) != 0:
            break
        else:
            nums += [i] * (c[i] // (n // 3))
    else:
        ans = (nums[0] ^ nums[1] ^ nums[2]) == 0

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


Measured memory_bytes: 14468
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int p[200010], a[200010], b[200010];

int main(){
	int n; cin >> n;
	REP(i,0,n) cin >> p[i];
	REP(i,0,n) a[p[i] - 1] = i + 1;
	REP(i,0,n) b[p[i] - 1] = i + 1;
	REP(i,0,n - 1) a[i + 1] += a[i];
	RREP(i, n - 1, 1) b[i - 1] += b[i];
	
	REP(i,0,n) cout << a[i] << " "; cout << endl;
	REP(i,0,n) cout << b[i] << " "; cout << endl;
	return 0;
}


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

int main()
{
    // 入力
    int N;
    int R_cnt=0,W_cnt=0,result=0;
    cin >> N;
    string c;
    cin >> c;

    //cout << "" << endl;
    // 計算
    rep (i,N){
        if (c.substr(i,1) == "R") R_cnt++;
        else W_cnt++;
    }
    rep (i,R_cnt){
        if (c.substr(i,1) == "R") result--;
    }
    result += R_cnt;

    // 出力
    cout << result << endl;
    return 0;  
}


Measured memory_bytes: 3740
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  int cnt = 0;
  if (2 * x == W && 2 * y == H) cnt++;
  printf("%.10f ", (1.0 * H * W) / 2.0);
  cout << cnt << endl;
  return 0;
}


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


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int OO = 100000000,n,m;
int dp[100009];
vector<vector<int>>edges(1e5);
int ans(int i){
    int &ret=dp[i];
    if(~ret)return ret;
    if(i==n+1||edges[i].empty())return 0;
    ret =0;
    for (int j = 0; j <edges[i].size() ; ++j) {
        ret=max (ret,1+ans(edges[i][j]));
    }
    return ret;
}



int main() {
    fast();
    cin>>n>>m;
    clr(dp,-1);
    for (int i = 0; i < m; ++i) {
        int a,b;cin>>a>>b;
        edges[a].push_back(b);
    }
    int s=0;
    for (int j = 1; j <= n; ++j) {
     s=max(s,ans(j));
    }
    cout<<s;
}

Measured memory_bytes: 7424
N, K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

INF = 10**9

dp = [INF]*100010

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i < N-j: dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp[N-1])


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

#define BR "\n"
#define SP " "

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (b > c) swap(b, c);
  if (a > b) swap(a, b);
  if (b > c) swap(b, c);

  cout << a << SP << b << SP << c << BR;

  return 0;
}


Measured memory_bytes: 3104
N, K = map(int, input().split())
# N, K = 3, 3
A = list(map(int, input().split()))
# A = [i for i in range(3, 0, -1)]
mod = 10 ** 9 + 7
ans = 0
x = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            x += 1
ans += x * K
ans %= mod

cnt = [0] * N
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            cnt[i] += 1

cnt_sum = sum(cnt)
x = ((K - 1) * K // 2) % mod

ans += cnt_sum * x
ans %= mod
print(ans)

Measured memory_bytes: 70800
#include <stdio.h>

int main(void){
    char str[1200];
    int i;
    
    scanf("%[^\n]",str);
    for(i=0;str[i]!='\0';i++){
        if(str[i]>='a'&&str[i]<='z') printf("%c",str[i]-32);
        else if(str[i]>='A'&&str[i]<='Z') printf("%c",str[i]+32);
        else printf("%c",str[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  string s;
  cin >> s;
  
  if (s[0] == s[1] && s[1] == s[2])
    cout << "No" << endl;
  else
    cout << "Yes" << endl;




  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, A[200005], sum[200005];

typedef pair<int, int> P;
P digit[30];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

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

    REP(j, 30) {
        P& d = digit[j];
        if (A[0] >> j & 1) {
            d.first = 1;
            d.second = 0;
        }
    }
    sum[0] = 1;
    REPS(i, N - 1) {
        int maxl = -1;
        REP(j, 30) {
            P& d = digit[j];
            if ((A[i] >> j & 1) && d.first == 1) {
                maxl = max(maxl, d.second);
            }
            if (A[i] >> j & 1) {
                d.first = 1;
                d.second = i;
            }
        }

        if (maxl >= 0 && maxl == i - 1) {
            sum[i] = 1;
        } else if (maxl >= 0) {
            sum[i] = i - maxl;
        } else {
            sum[i] = sum[i - 1] + 1;
        }

        if (maxl == -1) continue;
        REP(j, 30) {
            P& d = digit[j];
            if (d.second < maxl) {
                d.first = 0;
                d.second = 0;
            }
        }
    }

    int ans = 0;
    REP(i, N) ans += sum[i];
    cout << ans << endl;

    return 0;
}


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

int main()
{
    int s;
    
    cin >> s;
    int h = s / 3600; s %= 3600;
    int m = s / 60; s %= 60;
    cout << h << ":" << m << ":" << s << endl;
    
    
}

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

int main(void){
	bool isham[1000001];
	vector<int> ham;
	isham[1] = true;
	ham.push_back(1);
	for(int i=1;i<500001;i++){
		if(!isham[i]) continue;
		if(i*2 < 1000001){
			isham[i*2] = true;
			if(find(ham.begin(),ham.end(),i*2) == ham.end()){
				ham.push_back(i*2);
			}
		}
		if(i*3 < 1000001){
			isham[i*3] = true;
			if(find(ham.begin(),ham.end(),i*3) == ham.end()){
				ham.push_back(i*3);
			}
		}
		if(i*5 < 1000001){
			isham[i*5] = true;
			if(find(ham.begin(),ham.end(),i*5) == ham.end()){
				ham.push_back(i*5);
			}
		}
	}
	sort(ham.begin(),ham.end());

	int n,m;
	while(cin >> n && n){
		cin >> m;
		cout << upper_bound(ham.begin(),ham.end(),m) - lower_bound(ham.begin(),ham.end(),n) << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
int main()
{
	int n;
	cin >> n;
	bool ans = false;

	rep(i,26){
		rep(j,15){
			if(n == 4*i + 7*j){
				ans = true;
				goto Looped;
			}
		}
	}
Looped:
	if(ans) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#coding: utf-8
#ALDS1_1D
import sys

n=int(raw_input())
minv=float("inf")
maxv=float("-inf")
for i in xrange(1,n+1):
 r=int(raw_input())
 maxv=max(maxv,r-minv)
 minv=min(minv,r)

print maxv

Measured memory_bytes: 6420
implicit none
integer :: n,m
integer,allocatable :: cnt(:)
integer :: i,a,b
read *,n,m
allocate(cnt(n))
cnt(:) = 0
do i = 1,m
   read *,a,b
   cnt(a) = cnt(a) + 1
   cnt(b) = cnt(b) + 1
enddo

do i = 1, n
   print '(i0)',cnt(i)
enddo
stop
end

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

int main()
{
  string s;
  cin >> s;
  int c =0;
  for(int i=0; i<3;++i){
    if(s[i]=='R') c++;
  }
  if(s == "RSR") c=1;
  cout << c << endl;

  
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, max;
    int cnt = 0;

    cin >> N;

    vector<int> data(N);

    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
    }

    for (int i = 0; i < data.size(); i++) {
        if (i == 0) {
            max = data.at(i);
            cnt++;
        }

        if (i != 0 && max <= data.at(i)) {
            max = data.at(i);
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
// AtCoder-Sheep and Wolves
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int s,w;
  cin>>s>>w;
  if(w>=s)
  cout<<"unsafe\n";
  else cout<<"safe\n";
  return 0;
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const int MAXN = 2e5 + 10;

int n;
string A[ MAXN ];
map < vi, int > mapa;

int main()
{
	cin >> n;
	ll sol = 0;
	FOR( i, 0, n )
	{
		cin >> A[ i ];
		vi v( 26, 0 );
		FOR( j, 0, ( int )A[ i ].size() )
		{
			v[ ( int )A[ i ][ j ] - 97 ]++;
		}
		
		sol += mapa[ v ];
		mapa[ v ]++;
	}
	
	cout << sol << "\n";
	return 0;
}


Measured memory_bytes: 26752
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
using namespace std; 
const int N=1e5+5; 
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,m,num[N],ans;
bool may[N];
int main(){
	n=read(),m=read();
	inc(i,1,n) num[i]=1;may[1]=1;
	inc(i,1,m){
		int x=read(),y=read();
		if(may[x]){
			if(num[x]==1) may[x]=0;
			may[y]=1;
		}
		num[x]--,num[y]++;
	}
	inc(i,1,n) if(may[i]) ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 768
#include <bits/stdc++.h> 
using namespace std;
  int main() { 
    int n; 
    cin >> n; 
    vector<int> d(n); 
    for(int i = 0; i < n; i++) cin >> d[i]; 
    int ans = 0; 
    for(int i = 0; i < n; i++) { 
      for(int j = i + 1; j < n; j++) { 
        ans += d[i] * d[j]; 
      } 
    } 
    cout << ans << endl; 
      return 0; 
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
long long ans;

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int n;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++)cin>>s[i];
	int cnt[30],mi[30];
	for(int i=0;i<26;i++)mi[i]=114514;
	for(int i=0;i<n;i++){
		for(int j=0;j<26;j++)cnt[j]=0;
		for(int j=0;j<s[i].size();j++){
			cnt[s[i][j]-'a']++;
		}
		for(int j=0;j<26;j++){
			mi[j]=min(mi[j],cnt[j]);
		}
	}
	for(int i=0;i<26;i++){
		char z='a'+i;
		for(int j=0;j<mi[i];j++){
				cout<<z;
		}
	}
	cout<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int sum;
		if(a >= b) {
			sum = b;
		}else {
			sum = a;
		}
		if(c >= d) {
			sum = sum + d;
		}else {
			sum = sum + c;
		}
		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
using namespace std;
const ll mod=1e9+7;         
const int N=1e5+4;
int main()                  
{
    ll ans=0;
    map<string,ll> m;
    int n;
    scn(n);
    rep(i,0,n)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        if(m.find(s)==m.end())
        m[s]=1;
        else
        m[s]++;
    }
    for(auto it:m)
    {
        ll val=it.S;
        val*=(it.S-1);
        val/=2;
        ans+=val;
    }
    lpri(ans);
}

Measured memory_bytes: 11136
n=int(input())
for i in range(1,3501):
  for j in range(1,3501):
    if (4*i*j-n*i-n*j)!=0:
      if (n*i*j)%(4*i*j-n*i-n*j)==0 and (n*i*j)//(4*i*j-n*i-n*j)>0:
        k=(n*i*j)//(4*i*j-n*i-n*j)
        break
  else:
    continue
  break
print(i,j,k)

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

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool ok = true;
  for (int i = 0; i < s.size(); i++) {
    if (i == a && s.at(i) != '-') {
      ok = false;
    }
    if (i != a && !isdigit(s.at(i))) {
      ok = false;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define LL long long
vector <int> G[N];
LL Ans[N],D[N];
void dfs(int x,int pre,LL d) {
	Ans[x] = D[x] + d;
	d += D[x];
	for(int i=0; i<(int)G[x].size(); i++) {
		int e = G[x][i];
		if(e == pre) continue;
		dfs(e,x,d);
	}
	return ;
}
int main() {
	int n,Q;
	cin >> n >> Q;
	for(int i=1,a,b; i<n; i++) {
		scanf("%d%d",&a,&b);
		G[a].push_back(b),G[b].push_back(a);
	}
	int p,x;
	while(Q--) {
		scanf("%d%d",&p,&x);
		D[p] += x;
	}
	dfs(1,0,0);
	for(int i=1; i<=n; i++) printf("%lld ",Ans[i]);
	return 0;
}

Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
int N;
ll X,D;
ll gcdl(ll a,ll b){
	if(a<b)swap(a,b);
	if(b==0)return a;
	return gcdl(b,a%b);
}
vector<pair<ll,ll> > datas[214514];
int main(){
	cin>>N>>X>>D;
	if(D==0){
	    if(X!=0)cout<<N+1<<endl;
	    else cout<<1<<endl;
	    return 0;
	    
	}
	ll A=X-D;
	ll G=gcdl(abs(A),abs(D));
	ll x=D/G,y=A/G;//y*D=x*A
	if(x<0){
		x=-x;
		y=-y;
	}
	if(x<N){
		ll ans=0;
		ll lef=0,rig=0;
		datas[0].pb(mp((ll)0,(ll)0));
		rep(i,N){
			lef+=(ll)(i+1);
			rig+=(ll)(N-i);
			int anum=i+1;
			int sho=anum/x;
			datas[anum%x].pb(mp(lef+y*sho,rig+y*sho));
		}
		rep(i,x){
			sort(all(datas[i]));
			ll lef=datas[i][0].first,rig=datas[i][0].second;
			rep(j,datas[i].size()){
				ll cl=datas[i][j].first,cr=datas[i][j].second;
				if(cr<lef || rig<cl){
					ans+=rig-lef+1;
					lef=cl;
					rig=cr;
				}else{
					lef=min(lef,cl);
					rig=max(rig,cr);
				}
			}
			ans+=rig-lef+1;
		}
		cout<<ans<<endl;
	}else{
		ll ans=1;
		ll lef=0,rig=0;
		rep(i,N){
			lef+=(ll)(i+1);
			rig+=(ll)(N-i);
			ans+=(rig-lef+1);
		}
		cout<<ans<<endl;
	}
}


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

using namespace std;

int main (){
  string s;
  cin >> s;
  for(int i = 0; i< s.length();i++){
    if(i % 2 == 1){
      if (s[i] == 'R') {
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(s[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  
  return 0;
}

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll > 
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;
 
const double EPS = 1e-12;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
 
ll dp[N] , h[N];
ll n;
ll fun(ll i){

  if(i == n - 1){
    return abs(h[i] - h[n]);
  }
  if(i >= n){
    return 0;
  }
  if(dp[i] != -1){
    return dp[i];
  }

  return dp[i] = min(fun(i+1) + abs(h[i] - h[i+1]), fun(i+2) + abs(h[i] - h[i+2]));
  //return dp[n];
}
 
 
int main()
{
    fast;
    //ll n;
    cin >> n;
    for(int i = 1 ; i <= n; i++ ){
      cin >> h[i];
    }

  dp[1] = 0 , dp[2] = abs(h[1] - h[2]);
   for(int i = 3 ;  i <= n ; i++ ){
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]));
   }
   cout << dp[n];





















    
    return 0;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    vector<int> sorted_x = x;
    sort(ALL(sorted_x));
    int mid = sorted_x[n/2-1];
    for(int i = 0; i <= n-1; ++i){
        if(x[i] <= mid) cout << sorted_x[n/2] << endl;
        else cout << mid << endl;
    }
    return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

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

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

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

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DDiceInLine {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      vector<ll> e(n);
      rep(i, n) {
        int p; cin >> p;
        e[i] = p+1;
      }

      vector<ll> sume(n+1);
      rep(i, n) {
        sume[i+1] = sume[i] + e[i];
      }

      double ans = 0;
      for(int i=0; i+k<=n; i++) {
        int j = i+k;
        double sum = sume[j]-sume[i];
        sum /= 2;
        chmax(ans, sum);
      }
      cout << setprecision(10) << fixed;
      cout << ans << endl;


    }
};

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

Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int w, x, y, z;
	long double ww, xx;
	long double  s, ans;
	scanf("%d %d %d %d", &w, &x, &y, &z);
	ww = (long double)w;
	xx = (long double)x;
	ans = (ww*xx) / 2.0;
	if (y * 2 == w && z * 2 == x) {
		printf("%Lf 1\n",ans);
	}
	else printf("%Lf 0\n", ans);


	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
int n,k,v[51],a[101];
LL ans;
LL solve(int x,int y)
{
	int tot=0;LL sum=0;
	for(int i=1;i<=x;i++) a[++tot]=v[i];
	for(int i=n;i>=n-y+1;i--) a[++tot]=v[i];
	sort(a+1,a+tot+1);
	for(int i=1;i<=min(k-x-y,tot);i++) if(a[i]>0) sum+=a[i];
	for(int i=k-x-y+1;i<=tot;i++) sum+=a[i];
	return sum;
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&v[i]);
	for(int i=0;i<=min(n,k);i++)
	  for(int j=0;j<=min(k-i,n-i);j++)
	  {
	  	ans=max(ans,solve(i,j));
	  }
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int main(){
  
  int i,j,n,flag,tmp,count = 0;
  int arr[N];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
  
  for(i=0;i<n;i++){
    flag=1;
    while(flag){
      flag = 0;
      for(j=n-1;j>=1;j--){
	if(arr[j]<arr[j-1]){
	  tmp = arr[j];
	  arr[j] = arr[j-1];
	  arr[j-1] = tmp;
	  count++;	
	  flag=1;
	  break;
	}}}}

  for(j=0;j<n-1;j++){
    printf("%d ",arr[j]);
  }
  
  printf("%d\n",arr[n-1]);
  
  printf("%d\n",count);
  
  
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  int n;
  while(cin>>n,n!=-1) {
    string s;
    do {
      s += '0' + n % 4;
      n /= 4;
    } while(n != 0);
    reverse(ALL(s));
    cout << s << endl;
  }
}

Measured memory_bytes: 0
import Data.List

main=do
    line<-getLine
    ctx<-getContents
    let p =[read x::Int | x<-lines ctx]
    let m=maxL p
    let r= length [1 | x<-p,(maxL p)==x]
    let s= if r==1 then maxL [x |x<-p ,x /= m] else m

    output p m s
    
maxL :: [Int]->Int
maxL [x] =x
maxL (x:xs) = max x (maxL xs)

output :: [Int]->Int->Int->IO()
output [] _ _ = return()
output (x:xs) m s
    | m/=s =do
         if x==m then putStrLn (show s) else putStrLn (show m )
         output xs m s
    | otherwise =do
         putStrLn (show m)
         output xs m s

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

char c[52][52];
int h,w;

bool check(int i,int j)
{
	if(c[i+1][j] != '#' && c[i][j+1] != '#' && c[i][j-1] != '#' && c[i-1][j] != '#')
			return false;
	return true;
}

int main()
{
	cin >> h >> w;
	for(int i=0;i<h+2;i++)
		for(int j=0;j<w+2;j++)
		{
			if(i == 0 || j == 0 || i == h+1 || j == w+1)
				c[i][j]='.';
			else 
				cin >> c[i][j];
		}
	for(int i=1;i<h+1;i++)
		for(int j=1;j<w+1;j++)
			if(c[i][j] == '#')
			{
				if(!check(i,j))
				{
					puts("No");
					return 0;
				}
			}
	puts("Yes");
	return 0;
}

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

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

    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        string iStr = to_string(i);
        if (iStr.size() % 2 == 1)
        {
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,k,s=map(int,input().split())
a=[]

for i in range(n):
    if (i+1)<=k:
        a.append(s)
    else:
        if s==10**9:
            a.append(10**9-1)
        else:
            a.append(10**9)



for i in range(n):
    print(a[i],end=" ")


Measured memory_bytes: 49696
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for a_i in range(a + 1):
    for b_i in range(b + 1):
        for c_i in range(c + 1):
            if x == 500 * a_i + 100 * b_i + 50 * c_i:
                cnt += 1

print(cnt)


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

int main(){
    int h, a;
    cin >> h >> a;
    int i = 0;
    int count = 0;
    while (i * a < h){
        count++;
        i++;
    }
    
    cout << count << endl;
}

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

    for h in range(1, 3501):
        for n in range(h, 3501):
            if (4*h*n - N*h - N*n)>0 and N*h*n % (4*h*n - N*h - N*n)==0:
                w = N*h*n // (4*h*n - N*h - N*n)
                print(h, n, w)
                exit()

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	aa := make([]int, n)
	stack := make([]int, n)
	ll := make([]int, n)
	rr := make([]int, n)
	si := 0
	var ans int64
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner) - 1
		for si > 0 && aa[stack[si-1]] > aa[i] {
			rr[aa[stack[si-1]]] = i - stack[si-1]
			si--
		}
		stack[si] = i
		si++
	}
	for si > 0 {
		rr[aa[stack[si-1]]] = n - stack[si-1]
		si--
	}
	for i := n - 1; i >= 0; i-- {
		for si > 0 && aa[stack[si-1]] > aa[i] {
			ll[aa[stack[si-1]]] = stack[si-1] - i
			si--
		}
		stack[si] = i
		si++
	}
	for si > 0 {
		ll[aa[stack[si-1]]] = stack[si-1] + 1
		si--
	}
	for i := 0; i < n; i++ {
		ans += int64(ll[i]) * int64(rr[i]) * int64(i+1)
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 8960
import sys

N = int(sys.stdin.readline().rstrip())
counter=0
if N >= 10:
  counter+=9
else:
  counter+=N
  print(counter)
  exit()

if N < 100:
  print(counter)
  exit()
  
if N >= 1000:
  counter+=900
else:
  counter+=N-99
  print(counter)
  exit()
  
if N < 10000:
  print(counter)
  exit()
  
if N >= 100000:
  counter+=90000
else:
  counter+=N-9999
  
print(counter)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n; cin >> n;
    ll ans = 0;
    FOR(i,1,n+1){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596