akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(x: int):
    if x == 7 or x == 5 or x == 3:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys,collections

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a=I()

  for h in range(1,3501):
    for n in range(1,3501):
      x=(4*h*n-a*n-a*h)
      if x==0:
        continue
      w=a*h*n/x
      if w>0 and w==int(w) and w<=3500:
        print(h,n,int(w))
        exit()

main()
# print(main())


Measured memory_bytes: 39408
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

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


def main():
    K = I()
    ans = 0

    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                ans += gcd(gcd(a, b), c)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74432
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


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


Measured memory_bytes: 3608
A, B, K = map(int, input().split())

if K > (B - A) / 2:
    for i in range(A, B + 1):
        print(i)
else:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)

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

using namespace std;

struct CumulativeSum
{
  vector< int > data;

  CumulativeSum(int sz) : data(++sz, 0) {};

  inline void add(int k, int x)
  {
    data[k] += x;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      data[i] += data[i - 1];
    }
  }

  inline int query(int k)
  {
    if(k < 0) return (0);
    return (data[min(k, (int) data.size() - 1)]);
  }
};

int main()
{
  string S, T;

  cin >> S;
  cin >> T;

  vector< CumulativeSum > sum1(26, CumulativeSum(S.size()));
  vector< CumulativeSum > sum2(26, CumulativeSum(T.size()));
  for(int i = 0; i < 26; i++) {
    for(int j = 0; j < S.size(); j++) sum1[i].add(j, S[j] - 'a' == i);
    for(int j = 0; j < T.size(); j++) sum2[i].add(j, T[j] - 'a' == i);
    sum1[i].build();
    sum2[i].build();
  }

  vector< int > bb(26);
  for(int i = min(S.size(), T.size()); i > 0; i--) {
    set< vector< int > > st;
    for(int j = 0; j <= S.size() - i; j++) {
      for(int k = 0; k < 26; k++) {
        bb[k] = sum1[k].query(j + i - 1) - sum1[k].query(j - 1);
      }
      st.emplace(bb);
    }
    for(int j = 0; j <= T.size() - i; j++) {
      for(int k = 0; k < 26; k++) {
        bb[k] = sum2[k].query(j + i - 1) - sum2[k].query(j - 1);
      }
      if(st.count(bb)) {
        cout << i << endl;
        return (0);
      }
    }
  }

  cout << 0 << endl;
}

Measured memory_bytes: 4460
#include<iostream>
using namespace std;
int f(long a){int r=0;for(;a;r++)a/=10;return r;}
main()
{
	long n;int ans=99;cin>>n;
	for(long i=1;i*i<=n;i++)
	{
		if(n%i<1)ans=min(ans,max(f(i),f(n/i)));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
//
// Created by Akifumi Ohata on 2017/09/29.
//


#include<iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(){

    int N;

    cin >> N ;

    std::vector<int> scores;

    for(int n=0;n<N ;n++) {
        int tmp;
        cin >>tmp;

        scores.push_back(tmp);

    }

    std::sort(scores.begin(),scores.end());

    ONEMOER:

    int score_sum =std::accumulate(scores.begin(), scores.end(), 0);


    if(score_sum%10 ==0 && score_sum !=0){


        for(int k =0;k<scores.size();k++){
            if (scores[k] % 10 ==0){
                continue;
            }else{
                scores.erase(scores.begin()+k);
                goto ONEMOER;

            }

        }
       // scores.erase(scores.begin());

       // goto ONEMOER;

    }



    if(score_sum%10==0){
        score_sum=0;
    }

    cout << score_sum <<endl;

    return 0;
}

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

int main(void){
    string list[4] = {"dream", "dreamer", "erase", "eraser"};
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    for(int i=0;i<4;i++){
        reverse(list[i].begin(), list[i].end());
    }
    
    bool split1 = true;
    for(int i=0;i<s.size();){
        bool split2 = false;//4 個の文字列のどれでも分割できるか
        for (int j=0;j<4;j++){
            string li = list[j];
            if(s.substr(i, li.size()) == li){//li番目の文字で分割できるか
                split2 = true;
                i += li.size();
            }
        }
        if(!split2){
        split1 = false;
        break;
        }
    }
    
    if(split1){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string s,t;
  int n;
  
  cin >>n;
  cin >>s >>t;
  
  for(int i = 0;i<n;++i){
   cout << s[i] <<t[i]; 
    
  }
  
cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define maxn 101000

LL qpow(LL x) {return x*x*x;}
int main()
{
	LL n,k;
	scanf("%lld%lld",&n,&k);
	if (k&1) printf("%lld\n",qpow(n/k));
	else
	{
		LL ans=qpow(n/k);
		//k/2
		if (n%k>=k/2) ans+=qpow(n/k+1);
		else ans*=2;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#include<set>
using namespace std;
int n,a[110000],ans;
multiset<int> q;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	fo(i,1,n){
		auto it=q.lower_bound(a[i]);
		if (it==q.begin()){
			ans++;
			q.insert(a[i]);
		}else{
			it--;
			q.erase(it);//erase(*it)
			q.insert(a[i]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    cout << (a[x] == a[y] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for(int i = 0; i < n; i++)
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}

signed main(){
  int N;
  cin >> N;
  if(N == 100000){
    cout << "90909" <<endl;
  }
  else if(N >= 10000 && N < 100000){
    int a = N - 9999;
    cout << a + 909 << endl;
  }
  else if(N >= 1000 && N < 10000){
    cout << "909" << endl;
  }
  else if(N >= 100 && N < 1000){
    int a = N - 99;
    cout << a + 9 << endl;
  }
  else if(N >= 10 && N < 100){
    cout << '9' << endl;
  }
  else if (N >= 1 && N < 10){
    cout << N << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	int list[13];
};



signed main() {
	int i, j, k, n, m, sum = 0, cnt = 0;
	string s, s1, s2;
	bool flag = false;
	vector<vector<int>>list(1005, vector<int>(1005, 0));
	vector<int>list2;
	vector<int>list3(10005, 0);
	int a, b;
	

	cin >> n >> m;


	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> list[i][j];
		}
	}

	for (i = 0; i < m; i++) {
		int num;
		cin >> num;
		list2.push_back(num);
	}



	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			list3[i] += (list2[j] * list[i][j]);
		}
	}

	for (j = 0; j < n; j++) {
		cout << list3[j] << endl;
	}




	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 6668
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
       int a=sc.nextInt();
       int b=sc.nextInt();
        int p=(int)(a/0.08);
        while((int)(p*0.08)<a){
            p++;
        }
        int q=(int)((a+1)/0.08);
        while((int)(q*0.08)>a){
            q--;
        }
        int x=b*10;
        int y=b*10+9;
        int c[]=new int[10010];
        for(int i=p;i<=q;i++)
            c[i]++;
        for(int i=x;i<=y;i++)
            c[i]++;
        int flag=0;
        for(int i=0;i<c.length;i++)
            if(c[i]==2) {
                System.out.println(i);
                flag++;
                break;
            }
        if(flag==0)
            System.out.println("-1");

    }
}





Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int H,W;cin >> H >> W;
    int ans = H*W;
    int h,w;cin >> h >> w;
    cout << ans - W*h - H*w + h*w << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define o 1000005
#define re register int
#define ll long long
#define g0(a) memset(a,0,sizeof(a))
#define gc(a,b) memcpy(a,b,sizeof(a))
using namespace std;
inline int read()
{
	register int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<1)+(data<<3)+(ch^48),ch=getchar();
	return data*w;
}
int n,k,f[2005],g[2005],dp[2005][2005][2][2];
vector<int> v[2005];
const int mod=924844033;
int jc[o];
const int Mx=2e3;
int add(int x,int y)
{
	return x+y>=mod?x+y-mod:x+y;
}
int main()
{
	jc[0]=1;
	for(int i=1;i<=Mx;i++)jc[i]=1ll*jc[i-1]*i%mod;
	n=read(),k=read();
	for(int i=1;i<=n;i++)v[i%k].push_back(i);
	dp[0][0][0][0]=1;g[0]=1;
	for(int i=0;i<k;i++)
	{
		int lim=v[i].size();
		int las=0;
		for(auto x:v[i])
		{
			for(int k=0;k<lim;k++)
				for(int s=0;s<=1;s++)
					for(int s2=0;s2<=1;s2++)
					{
						if(!dp[las][k][s][s2])continue;
//						cout<<las<<' '<<k<<" "<<s<<" "<<s2<<"\n";
						dp[x][k][s2][0]=add(dp[x][k][s2][0],dp[las][k][s][s2]);//填其他 
						if(x!=v[i].back())dp[x][k+1][s2][1]=add(dp[x][k+1][s2][1],dp[las][k][s][s2]);//填后面 
						if(!s&&las)dp[x][k+1][s2][0]=add(dp[x][k+1][s2][0],dp[las][k][s][s2]);//填前面
					}
			las=x;
		}
//		cout<<dp[4][1][0][0]<<"\n";
		gc(f,g);g0(g);
		for(int k=0;k<=lim;k++)
		{
			int sum=0;
			for(int s=0;s<=1;s++)
				for(int s2=0;s2<=1;s2++)
					sum=add(sum,dp[las][k][s][s2]);
//			cout<<k<<" "<<sum<<"\n";
			for(int t=0;t<=n;t++)
				if(t+k<=n)g[t+k]=add(g[t+k],1ll*f[t]*sum%mod);
		}
	}
	int ans=jc[n];
	for(int i=1,w=mod-1;i<=n;i++,w=1ll*w*(mod-1)%mod)
		ans=(ans+1ll*w*g[i]%mod*jc[n-i]%mod)%mod;
	cout<<ans<<"\n";
	return 0;
}

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

using namespace std;

long long a,b,ans; 
vector<long long> v;

int main()
{
	cin>>a>>b;
	while (a--)
	{
		int x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (int i=b;i<v.size();i++) ans+=v[i];
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 2420
#include<stdio.h>
int main(void)
{
	int n,y,b,r,t,i,k,a,z;
	double x;
	scanf("%d %d",&n,&y);
	while(n!=0){
		a=0;
		z=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&b,&r,&t);
			if(t==1){
				x=(double)10000*(100+y*r)/100;
//				printf("b=%d 1x=%lf\n",b,x);
			}
			else{
				x=10000;
				for(k=0;k<y;k++)  {
					x=(double)x*(100+r)/100;
//					printf("x=%lf\n",x);
				}
//				printf("b=%d 2x=%lf\n",b,x);
			}
			if(z<x){
				a=b;  z=x;
			}
		}
		printf("%d\n",a);
		scanf("%d %d",&n,&y);
	}
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define f first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
typedef long long ll ;
typedef long double ld ;
typedef long long int lli;

using namespace std;
//reference: geeks
ll mult(ll a,ll b, ll p=mod){	return ((a%p)*(b%p))%p;	}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll sub(ll a, ll b, ll p=mod){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
#define INF 10000000000

int main()
{	
	ios
	int n,k;
	cin>>n>>k;
	int a[n];
	int dp[n];
	for(int i=0;i<n;i++)	cin>>a[i];
	dp[0]=0;
	
	
	for(int i=1;i<n;i++)
	{
		dp[i]=INT_MAX;
		for(int j=max(0,i-k);j<i;j++)
		{
			dp[i]=min(dp[i],dp[j]+abs(a[j]-a[i]));
		}
	}
	
	cout<<dp[n-1];
}



Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

s = sum(a)
nums = {}
for i in range(n):
    if a[i] in nums:
        nums[a[i]] += 1
    else:
        nums[a[i]] = 1

for i in range(int(input())):
    b, c = map(int, input().split())
    if b in nums:
        s -= nums[b]*b
        s += nums[b]*c
        if c in nums:
            nums[c] += nums[b]
        else:
            nums[c] = nums[b]
        nums[b] = 0
    print(s)

Measured memory_bytes: 20848
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  int N;
  cin >> N;
  if(H>W){
    cout << N/H + (N%H?1:0) << endl;
  }else{
    cout << N/W + (N%W?1:0) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<31)-1
typedef long long int ll;

typedef struct ST{ 
	vector<ll> a;
	int n;
	void init(vector<ll> &b){
		int size= b.size();
		n=1;
		while(n<size) n*=2;
		a =vector<ll> (2*n-1,INF);
		for(int i=0;i<size;i++)	a[i+n-1] = b[i];
		for(int i=n-2;i>=0;i--) a[i] = min(a[i*2+1],a[i*2+2]); //RMQ
	}
	void update(int k,ll val){
		k+=n-1;
		a[k] = val;
		while(k>0){
			k = (k-1)/2;
			a[k] = min(a[k*2+1],a[k*2+2]);//RMQ
		}
	}
	// [aa,b)の最小値
	// kは節点番号l,rはその節点が[l,r)に対応
	// get(aa,b,0,0,n)
	ll get(int aa,int b,int k,int l,int r){
		//[aa,b)に完全に[l,r)が含んでいる場合 この節点
		if(aa<=l && r<=b) return a[k];
		
		//[aa,b)と[l,r)が交差しなければ INF
		if(r<=aa || b<=l) return INF;
		ll vl = get(aa,b,k*2+1,l,(l+r)/2);
		ll vr = get(aa,b,k*2+2,(l+r)/2,r);
		return min(vl,vr);
	}
	ll find(int aa,int b){
		return get(aa,b,0,0,n);
	}	
}ST;



int main(){
	int n,q;
	cin>>n>>q;
	vector<ll> a(n,INF);
	ST seg;
	seg.init(a);
	for(int i=0;i<q;i++){
		ll c,x,y;
		cin>>c>>x>>y;
		if(c==0)	seg.update(x,y);
		else	cout<<seg.find(x,y+1)<<endl;
	}
	//cout<<seg.n<<endl;
	//for(int i=0;i<seg.a.size();i++)cout<<seg.a[i]<<endl;
	return 0;
}



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

#define ll long long
#define endl "\n"

int main(void)
{
    string s;
    getline(cin, s);
    if(s == "Sunny")
        cout << "Cloudy\n";
    else if(s == "Cloudy")
        cout << "Rainy\n";
    else if(s == "Rainy")
        cout << "Sunny\n";

    return 0;
}


Measured memory_bytes: 256
dishes = []
n = 5
max_rest = 10
for i in range(n):
    dish = int(input())
    if (dish - 1) % 10 < (max_rest - 1) % 10:
        max_rest = dish
    
    dishes.append((dish + 9) // 10 * 10) 
    
res = sum(dishes) - (max_rest + 9) // 10 * 10 + max_rest
print(res)
# print(dishes)



Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  int N, q;
  cin >> N;
  int idx = 0;
  ll B = 0;
  priority_queue<ll, vector<ll>, less<ll>> qL;
  priority_queue<ll, vector<ll>, greater<ll>> qR;
  ll cent;
  bool remain = false;
  ll L = 0;
  ll R = 0;
  for (int i=0; i<N; i++) {
    ll a, b;
    cin >> q;
    if (q == 1) {
      cin >> a >> b;
      B += b;
      if (!remain) {
        if (qL.size() > 0 && qL.top() > a) {
          cent = qL.top();
          L -= cent;
          L += a;
          qL.pop();
          qL.push(a);
        } else if (qR.size() > 0 && qR.top() < a) {
          cent = qR.top();
          R -= cent;
          R += a;
          qR.pop();
          qR.push(a);
        } else {
          cent = a;
        }
        remain = true;
      } else {
        ll l = min(cent,a);
        ll r = max(cent,a);
        L += l;
        R += r;
        qL.push(l);
        qR.push(r);
        while (qL.top() > qR.top()) {
          l = qL.top();
          r = qR.top();
          L -= l;
          L += r;
          R -= r;
          R += l;
          qL.pop(); qL.push(r);
          qR.pop(); qR.push(l);
        }
        remain = false;
      }
    } else {
      if (remain) {
        cout << cent << ' ';
      } else {
        cout << qL.top() << ' ';
      }
      cout << B + R - L << endl;
    }
  }
}

Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[] tasks = new int[3];

		tasks[0] = sc.nextInt();
		tasks[1] = sc.nextInt();
		tasks[2] = sc.nextInt();

		int minimumCost = Integer.MAX_VALUE;

		for (int i = 0; i < 3; i++) {
			int firstTask = tasks[i];
			int c1 = Math.abs(tasks[(i+1)%3]-firstTask) + Math.abs(tasks[(i+2)%3]-tasks[(i+1)%3]);
			int c2 = Math.abs(tasks[(i+2)%3]-firstTask) + Math.abs(tasks[(i+1)%3]-tasks[(i+2)%3]);
			int cost = Math.min(c1,c2); 
			minimumCost = Math.min(minimumCost, cost);
		}
		System.out.println(minimumCost);
		sc.close();
	}
}


Measured memory_bytes: 23124
#!/user/bin/env python3
# -*- conding: utf-8 -*-


def main():
    K = int(input())
    li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(li[K-1])
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;

char grid[1000][1000];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    FOR(i, 0, b){
        FOR(j, 0, a){
            grid[i][j]='0';
        }
    }
    FOR(i, 0, b){
        FOR(j, a, w){
            grid[i][j]='1';
        }
    }
    FOR(i, b, h){
        FOR(j, 0, a){
            grid[i][j]='1';
        }
    }
    FOR(i, b, h){
        FOR(j, a, w){
            grid[i][j]='0';
        }
    }
    FOR(i, 0, h){
        FOR(j, 0, w){
            cout << grid[i][j];
        }
        cout << "\n";
    }

}


Measured memory_bytes: 2176
#include<stdio.h>
int main()
 {
     int a,b;
     scanf("%d %d", &a, &b);
     if(a==b)
        printf("%d", 2*a);
     else if(a>b)
        printf("%d", 2*a-1);
     else
        printf("%d", 2*b-1);

     return 0;
 }


Measured memory_bytes: 1680
#include <iostream> 
#include <iomanip> 
#include <vector> 
#include <algorithm> 
#include <numeric> 
#include <functional> 
#include <cmath> 
#include <queue> 
#include <stack> 

#define Ford(i,a,b) for (int i=(a);i<(b);i++) 
#define For(i,n) Ford(i,0,n) 
typedef long long ll; 

using namespace std;

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=min(a,b);i>=1;i--){
    if((a%i==0)&&(b%i==0)){
        --k;
      }
      if(k==0){
        cout<<i<<endl;
        return 0;
      }
    }
}




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

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    int d;
    int a;

    vector<bool> sunuke;
    for (int i = 0; i < N; i++)
    {
        sunuke.push_back(true);
    }
    
    for (int i = 0; i < K; i++)
    {
        cin >> d;        
        for (int j = 0; j < d; j++)
        {
            cin >> a;
            sunuke[a-1] = false;           
        }
    }
    int res = 0;


    for (int i = 0; i < N; i++)
    {
        if (sunuke[i])
        {
            res++;
        }        
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3632
count = 0 
INFTY = 10 ** 10

def merge(A, left, mid, right):
  global count
  n1 = mid - left;
  n2 = right - mid;

  L = []
  R = []

  L = A[left:left+n1]
  R = A[mid:mid+n2]

  L.append(INFTY)
  R.append(INFTY)

  i = 0
  j = 0
  for k in range(left, right):
    count = count + 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1

def mergeSort(A, left, right):
  if left+1 < right:
    mid = int((left + right)/2);
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

import sys

n = sys.stdin.readline()
for line in sys.stdin:
  items = line.strip().split()
  items = [ int(x) for x in items ]
  mergeSort(items, 0, len(items))
  print(" ".join(map(str, items)))
  print(count)

Measured memory_bytes: 73480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  vector<vector<char>> ans(101,vector<char>(101,'.'));
  FOR(i,1,51)FOR(j,1,101) ans[i][j]='#';
  P now=P(1,1);
  a--,b--;
  while(a--){
    ans[now.fi][now.se]='.';
    if(now.se+2>100){
      if(now.fi%2==1) now.se=2;
      else now.se=1;
      now.fi+=2;
    }else{
      now.se+=2;
    }
  }
  now=P(52,1);
  while(b--){
    ans[now.fi][now.se]='#';
    if(now.se+2>100){
      if(now.fi%2==1) now.se=2;
      else now.se=1;
      now.fi+=2;
    }else{
      now.se+=2;
    }
  }
  cout<<100<<' '<<100<<endl;
  FOR(i,1,101){
    FOR(j,1,101){
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

// バイナリである

func main() {
	var n int
	fmt.Scan(&n)
	ans := 0.0
	switch {
	case n < 2:
		ans = 0.0
	case n < 4:
		ans = 1.0
	case n < 8:
		ans = 2.0
	case n < 16:
		ans = 3.0
	case n < 32:
		ans = 4.0
	case n < 64:
		ans = 5.0
	default:
		ans = 6.0
	}
	fmt.Println(int(math.Pow(2.0, ans)))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
const int MOD = 1e9+7,mxN = 50,INF = 1e9;
int n=2,q;


void solve()
{
    vi a(3,1);
    while(n--)
    {
        int k;
        cin>>k;
        a[k-1]=0;
    }
    for(int i=0;i<=2;i++)
        if(a[i])
            cout<<i+1;
    
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int n;
string s;
bool used[105];
int cnt1,cnt2;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='('&&!used[i]){
			used[i]=1;
			bool found=0;
			for(int j=i+1;j<n;j++){
				if(s[j]==')'&&!used[j]){
					used[j]=1;
					found=1;
					break;
				}
			}
			if(!found) cnt2++;
		}
		if(s[i]==')'&&!used[i]){
			used[i]=1;
			bool found=0;
			for(int j=i-1;j>=0;j--){
				if(s[j]=='('&&!used[j]){
					used[j]=1;
					found=1;
					break;
				}
			}
			if(!found) cnt1++;
		}
	}
	for(int i=0;i<cnt1;i++) cout<<'(';
	cout<<s;
	for(int i=0;i<cnt2;i++) cout<<')';
	re 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define IOS   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define qe	  998244353
#define MAXN  10000
#define mx    10000005
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
//	#ifndef ONLINE_JUDGE
//    if (fopen("input.txt", "r"))
//    {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
//    }
//	#endif
	IOS;
	ll t,n,l,l1;
	ll i,j,m,mn,q,d,x,y,ans=0,sum=0,r,p,k,c;
	string s,s1;
//	cin>>t;
	cin>>n>>k;
	ll a[n],cost[n+1];
	rep(i,0,n)cin>>a[i];
	rep(i,0,n+1)cost[i]=mod;
	cost[0]=0,cost[1]=0;
	cost[2]=abs(a[1]-a[0]);
	rep(i,2,n+1){
		rep(j,1,k+1){
			if(i>j)cost[i]=min(cost[i],cost[i-j]+abs(a[i-1]-a[i-j-1]));
		}
		
	}
//	rep(i,0,n+1)cout<<cost[i]<<" ";
cout<<cost[n];
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1;i <= n;i += 2)
    {
        int count = 0;
        for(int j = 1;j < sqrt(i);j++)
        {
            if(i % j == 0 && j != i / j)
            {
                count += 2;
            }
        }
        if(count == 8)
        {
            ans++;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
   long long int a,b,c,m;


    cin >> a >> b >> c;
    m=c-a-b;
    if(m<0)
    {
        cout << "No\n";
        return 0;
    }
   else if((4*a*b)<(m*m))
    {
        cout << "Yes\n";
        return 0;
    }
    else
    {
        cout << "No\n";
    }

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename T>
void printvec(vector<T> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    int n; cin >> n;
    double ans = 3.14159265358 * 2*n;
    cout << ans << endl;
}

Measured memory_bytes: 3784
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

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

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    ll k; cin >> k;
    ll n = s.size();
    vector dp(n + 1, vector(2, vector(2, vector(k + 1, 0LL))));

    dp[0][0][0][0] = 1;
    rep(i,0,n) rep(j,0,2) rep(l,0,2) rep(m,0,k + 1) rep(d, 0,10){
        ll t = s[i] - '0';
        if(j == 0 && d > t)break;

        ll _i = i + 1;
        ll _j = j == 0 && t == d ? 0 : 1;
        ll _l = l == 0 && d == 0 ? 0 : 1;
        ll _m = d != 0 ? m + 1 : m;
        if(_m > k)continue;
        dp[_i][_j][_l][_m] += dp[i][j][l][m];
    }
    debug(dp[n]);
    ll ans = 0;
    ans = dp[n][0][1][k] + dp[n][1][1][k];

    cout << ans << endl;
}

Measured memory_bytes: 3660
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        K: usize,
        sushi: [(usize1, usize); N],
    }
    sushi.sort_by(|a, b| b.1.cmp(&a.1));

    let mut s: Vec<(usize, usize)> = sushi.iter().rev().skip(N-K).cloned().collect();
    let mut neta_num: Vec<usize> = vec![0; 100000]; 
    let mut f = vec![0; K];
    for &(t, d) in s.iter() {
        neta_num[t] += 1;
        f[0] += d;
    }
    let min = neta_num.iter().filter(|num| **num > 0).count();

    let mut index_sushi = K;
    let mut index_s = 0;
    let mut p = f[0];
    'outer: for n in f.iter_mut().skip(1) {
        loop {
            if index_s >= s.len() {
                break 'outer;
            }
            let (t, d) = s[index_s]; 
            if neta_num[t] > 1 {
                neta_num[t] -= 1;
                *n = p - d;
                index_s += 1;
                break;
            }
            index_s += 1;
        }

        loop {
            if index_sushi >= sushi.len() {
                *n = 0;
                break 'outer;
            }
            let (t, d) = sushi[index_sushi];
            if neta_num[t] < 1 {
                neta_num[t] += 1;
                *n += d;
                p = *n;
                index_sushi += 1;
                break;
            }
            index_sushi += 1;
        }
    }

    let g = f.iter().take_while(|fs| **fs > 0).enumerate()
        .map(|(ind, d)| d + (min + ind) * (min + ind)).max().unwrap();

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


Measured memory_bytes: 10492
# https://atcoder.jp/contests/abc123/tasks/abc123_c

# ボトルネックを探し，そこに詰まらない量だけ流す
n = int(input())
a_e = [int(input()) for _ in range(5)]

min_ae = min(a_e)
# city1に全員がつくためにかかる時間
arr_city1 = n // min_ae if n % min_ae == 0 else n//min_ae + 1
ans = arr_city1 + 4
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  double s, l, h, rad;
  rad = 2.00000 * PI * c / 360.00000;
  h = b * sin(rad);
  s = 0.50000 * a * h;
  printf("%.6lf\n", s);
  l = a + b + sqrt(a*a + b*b -2*a*b*cos(rad));
  printf("%.6lf\n", l);
  printf("%.6lf\n", h);
}


Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
int main(){
    int k,n,ma;
    cin>>k>>n;
    int a[n];
    rep(i,0,n)cin>>a[i];
    ma=a[0]+k-a[n-1];
    rep(i,1,n)ma=max(ma,a[i]-a[i-1]);
    cout<<k-ma<<endl;
}

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

int main(){ 
long long int a , b , c; cin >> a >> b >> c;
if( a % 2 == 0 || b % 2 == 0 || c % 2 == 0 ) { cout << 0 << endl; return 0; }
unsigned long long int min=9223372036854775807;
long long int diff = ( a - a / 2 ) * b * c - a / 2 * b * c;
if( min > diff ) min = diff;
diff = a * ( b - b / 2 ) * c - a * ( b / 2 ) * c;
if( min > diff ) min = diff;
diff = a * b * ( c - c / 2 ) - a * b * ( c / 2 );
if( min > diff ) min = diff;
cout << min << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
            #return self.find(self.parents[x])

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
n,m,k = map(int,input().split())
uf = UnionFind(n)
#初期化したら友達関係を受け取ってufを形成していく union
friend = [0]*n
# 友達が何人いるかも必要
for i in range(m):
    a,b = map(int,input().split())
    friend[a-1] += 1
    friend[b-1] += 1
    uf.union(a-1,b-1)
# uf が完成したら,c,d を受け取り、parentの値が同じならblock[c],bloc[d]+=1をする
block = [0]*n
for j in range(k):
    c,d = map(int,input().split())
    if uf.find(c-1) == uf.find(d-1):
        block[c-1]+=1
        block[d-1]+=1
"""
print(uf.parents)
print(block)
print(friend)"""
for i in range(n):
    #print(abs(uf.parents[uf.find(i)]),":",i)
    print(abs(uf.parents[uf.find(i)]) - 1 - friend[i] - block[i],end=" ")

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 n, t[101], d[101], v[101];
int sp[40404];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> t[i];
		t[i] <<= 1;
		d[i] = d[i-1]+t[i];
	}
	for(int i = 1; i <= n; ++i){
		cin >> v[i];
		v[i] <<= 1;
		fill(sp+d[i-1], sp+d[i], v[i]); //max
	}
	
	for(int i = 1; i <= n; i++){
		if(v[i] > v[i-1]){
			for(int j = d[i-1]; j < d[i]; ++j){
				if(!chmin(sp[j], v[i-1]+j-d[i-1])) break;
			}
		}
		if(v[i] > v[i+1]){
			for(int j = d[i+1]; j >= d[i]; --j){
				if(!chmin(sp[j], v[i+1]+d[i+1]-j)) break;
			}
		}
	}
	for(int i = 1; i < 40000; ++i){
		chmin(sp[i], sp[i-1]+1);
	}
	for(int i = 40000; i > 0; --i){
		chmin(sp[i], sp[i+1]+1);
	}
	
	i64 ans = 0;
	for(int i = 1; i < 40000; i++){
		ans += sp[i];
		
	}
	printf("%.10f\n", ans/4.0);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

vector<lld> prime_num;

void n_Prime(lld n)
{
    lld a;
    a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            prime_num.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    prime_num.push_back(n);
}

int main() {
    lld N;
    cin >> N;
    n_Prime(N);
    lld ans = 0;
    lld next_c = 1;
    lld count = 0;
    lld nowv = -1;
    if(N == 1){
        cout << "0" << endl;
        exit(0);
    }
    for (int i = 0; i < prime_num.size(); i++) {
        if(nowv == prime_num[i]){
            count++;
            if(next_c == count){
                next_c++;
                ans++;
                count = 0;
            }
        } else {
            nowv = prime_num[i];
            next_c = 2;
            count = 0;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=true;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
vector<ull> cnt(64,0);
ull dp[51][2];
ull num,k;

ull digit_dp(ull n, bool smaller){
    ull res;
    if(n==-1)return 0;
    if(dp[n][smaller]!=-1)return dp[n][smaller];
    if(smaller){
        res=digit_dp(n-1,true)+(max(cnt[n],(num-cnt[n]))<<n);
    }else{
        if(k>>n&1){
            res=digit_dp(n-1,true)+(cnt[n]<<n);
            res=max(res,digit_dp(n-1,false)+(num-cnt[n]<<n));
        }else{
            res=digit_dp(n-1,false)+(cnt[n]<<n);
        }
    }
    // DEBUG{printf("n : %llu, cnt[n] : %llu, smaller : %d, res : %lld\n",n,cnt[n],int(smaller),res);}
    return dp[n][smaller]=res;
}

int main(void) {
    cin >> num >> k;
    rep(i,num){
        ull tmp;
        cin >> tmp;
        rep(j,51)cnt[j]+=(tmp>>j)&1;
    }
    // DEBUG{
    //     rep(i,51)cout << cnt[i] << endl;
    // }
    rep(i,51)rep(j,2)dp[i][j]=-1;
    ull res = digit_dp(50,false);
    cout << res << endl;

    return 0;
}


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

namespace _156_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            var N = int.Parse(s[0]);
            var R = int.Parse(s[1]);
            Console.WriteLine((100 * (10 - N)) > 0 ? R + 100 * (10 - N) : R);
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
a = list(map(int,input().split()))
di = 10**9+7
##試し割り
import math
import collections
def trial_division_prime(n, prime_list,prime_count):
    tmp=collections.Counter()
    for i in prime_list:
        if i * i > n:
            break
        while n % i == 0:
            n /= i
            tmp[i] += 1
    if n > 1:
        tmp[int(n)] += 1
    for num,rui in tmp.items():
        if prime_count[num]<rui:
            prime_count[num]=rui
        else:
            continue
    return prime_count
##ふるい
import itertools
def eratosthenes_sieve(n):
    table = [0] * (n + 1)
    prime_list = []

    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1

    return prime_list

lis = eratosthenes_sieve(int(math.sqrt(max(a))+1))
prime_count = collections.Counter()
for i in a:
    cnt = trial_division_prime(i,lis,prime_count)
#print(cnt)
lcm=1
for s,t in prime_count.items():
    lcm=(lcm*pow(s,t,di))%di
#print(lcm)
su = 0
for i in a:
    div = pow(i,di-2,di)
    su = (su+(lcm*div)%di)%di
print(su)


Measured memory_bytes: 48476
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<ll> a(n, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  vector<pair<ll, ll>> q(m);
  for(int i = 0; i < m; i++)
  {
    ll b, c;
    cin >> b >> c;
    q[i] = {c, b};
  }
  sort(q.begin(), q.end());
  reverse(q.begin(), q.end());
  sort(a.begin(), a.end());
  int index = 0;
  for(int i = 0; i < m; i++)
  {
    for(int j = 0; j < q[i].second; j++)
    {
      if(a[index] < q[i].first){
        a[index] = q[i].first;
        index++;
      }else{
        break;
      }
    }
  }
  ll result = 0;
  for(auto e : a){
    result += e;
  }
  cout << result << endl;
}


Measured memory_bytes: 2560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn ceil_div(t: u64, s: u64) -> u64 {
    (t + s - 1) / s
}

fn main() {
    input! {
        a: u64,
        b: u64,
    }
    println!("{}", ceil_div((a+b),2));
}


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

int main() {
  int A,a,b,c,d;
  char x,y,z;
  cin >> A;
  d=A%10;
  A/=10;
  c=A%10;
  A/=10;
  b=A%10;
  a=A/10;
  if(a+b+c+d==7){
    x='+';
    y='+';
    z='+';
  }
  if(a+b+c-d==7){
    x='+';
    y='+';
    z='-';
  }
  if(a+b-c+d==7){
    x='+';
    y='-';
    z='+';
  }
  if(a-b+c+d==7){
    x='-';
    y='+';
    z='+';
  }
  if(a+b-c-d==7){
    x='+';
    y='-';
    z='-';
  }
  if(a-b-c+d==7){
    x='-';
    y='-';
    z='+';
  }
  if(a-b+c-d==7){
    x='-';
    y='+';
    z='-';
  }
  if(a-b-c-d==7){
    x='-';
    y='-';
    z='-';
  }
  cout <<a<<x<<b<<y<<c<<z<<d<<"=7"<<endl;
}


Measured memory_bytes: 384
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <iomanip>

#include<iostream>
using namespace std;

int main()
{
    
    int N, M;
    int i, j, tmp;
    int tres;

    //[input]
    cin >> N >> M;
    int num[N];
    for( i=0 ; i<N ; i=i+1 )
    {
        cin >> num[i];
    }

    //[sort]
    for( i=0 ; i<N ; i=i+1 )
    {
        for( j=i+1 ; j<N ; j=j+1 )
        {
            if( num[i] > num[j] )
            {
                //變數交換
                tmp = num[i];
                num[i] = num[j];
                num[j] = tmp;
            }
        }
    }
    tres = 0;
    
    //[output]
    for( i=0 ; i<N ; i=i+1 )
    {
        // cout << num[i] << " ";
        tres = tres + num[i];
    }
    // cout<<num[N+1-M]<<endl;
    // cout<<tres/4.0/M<<endl;
    if (num[N-M]>=tres/4.00000/M){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    // float tress = tres/4/M;;
    // tress = tres/4/M;
    // cout << endl;
    // cout << setprecision(3) <<tress << endl;

    return 0;
}

Measured memory_bytes: 256
s = str(input())
cnt = 0
ans = 0

for i in range(len(s)):
	if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
		cnt += 1
		if i == len(s)-1 and ans <= cnt:
			ans = cnt
	else:
		if ans < cnt:
			ans = cnt
		cnt = 0
print(ans)

Measured memory_bytes: 3060